Title: [228626] releases/WebKitGTK/webkit-2.20/Tools
Revision
228626
Author
carlo...@webkit.org
Date
2018-02-19 01:35:49 -0800 (Mon, 19 Feb 2018)

Log Message

Merge r228131 - prepare-ChangeLog gets confused about Python docstrings that contain the word "class" or "def"
https://bugs.webkit.org/show_bug.cgi?id=182405

Reviewed by David Kilzer.

String literal statements, including docstrings, do not demarcate a new scope in Python.
So, do not treat them like they do when building up the list of modified functions.

* Scripts/prepare-ChangeLog:
(get_function_line_ranges_for_python):
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt:
The expected ending line number for the last "pass" statement inside the scope of Class5 changed
from 97 to 98 because empty lines do not effect scope. This is consistent with the parsing
of the second "pass" statement in the scope of class Class5. A "pass" is a null operation that
is used as a syntactic placeholder when a statement is required. Ideally we would make
the parsing code smarter so as to avoid emitting ranges for "pass" statements that serve
not syntactic purpose.
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py:
(Class5):
(Class6):
(Class6.__init__):
(Class7):
(Class7.__init__):
(Class8):
(Class8.__init__):
Add some more tests.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.20/Tools/ChangeLog (228625 => 228626)


--- releases/WebKitGTK/webkit-2.20/Tools/ChangeLog	2018-02-19 09:32:40 UTC (rev 228625)
+++ releases/WebKitGTK/webkit-2.20/Tools/ChangeLog	2018-02-19 09:35:49 UTC (rev 228626)
@@ -1,3 +1,32 @@
+2018-02-05  Daniel Bates  <daba...@apple.com>
+
+        prepare-ChangeLog gets confused about Python docstrings that contain the word "class" or "def"
+        https://bugs.webkit.org/show_bug.cgi?id=182405
+
+        Reviewed by David Kilzer.
+
+        String literal statements, including docstrings, do not demarcate a new scope in Python.
+        So, do not treat them like they do when building up the list of modified functions.
+
+        * Scripts/prepare-ChangeLog:
+        (get_function_line_ranges_for_python):
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt:
+        The expected ending line number for the last "pass" statement inside the scope of Class5 changed
+        from 97 to 98 because empty lines do not effect scope. This is consistent with the parsing
+        of the second "pass" statement in the scope of class Class5. A "pass" is a null operation that
+        is used as a syntactic placeholder when a statement is required. Ideally we would make
+        the parsing code smarter so as to avoid emitting ranges for "pass" statements that serve
+        not syntactic purpose.
+        * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py:
+        (Class5):
+        (Class6):
+        (Class6.__init__):
+        (Class7):
+        (Class7.__init__):
+        (Class8):
+        (Class8.__init__):
+        Add some more tests.
+
 2018-02-05  John Wilander  <wilan...@apple.com>
 
         Storage Access API: Add testRunner.getAllStorageAccessEntries() to make testing easier and more explicit

Modified: releases/WebKitGTK/webkit-2.20/Tools/Scripts/prepare-ChangeLog (228625 => 228626)


--- releases/WebKitGTK/webkit-2.20/Tools/Scripts/prepare-ChangeLog	2018-02-19 09:32:40 UTC (rev 228625)
+++ releases/WebKitGTK/webkit-2.20/Tools/Scripts/prepare-ChangeLog	2018-02-19 09:35:49 UTC (rev 228626)
@@ -1783,8 +1783,13 @@
 
     my @ranges;
 
+    my $multilineStringLiteralSentinelRegEx = qr#(?:"""|''')#;
+    my $multilineStringLiteralStartRegEx = qr#^\s*$multilineStringLiteralSentinelRegEx#;
+    my $multilineStringLiteralEndRegEx = qr#$multilineStringLiteralSentinelRegEx\s*$#;
+
     my @scopeStack = ({ line => 0, indent => -1, name => undef });
     my $lastLine = 0;
+    my $inComment = 0;
     until ($lastLine) {
         $_ = <$fileHandle>;
         unless ($_) {
@@ -1795,7 +1800,7 @@
             $lastLine = 1;
         }
         chomp;
-        next unless /^(\s*)([^#].*)$/;
+        next unless /^(\s*)([^#].*)$/; # Skip non-indented lines that begin with a comment.
 
         my $indent = length $1;
         my $rest = $2;
@@ -1824,6 +1829,17 @@
             $scope->{line} = $.;
         }
 
+        # Skip multi-line string literals and docstrings.
+        next if /$multilineStringLiteralStartRegEx.*$multilineStringLiteralEndRegEx/;
+        if (!$inComment && /$multilineStringLiteralStartRegEx/) {
+            $inComment = 1;
+        } elsif ($inComment && /$multilineStringLiteralEndRegEx/) {
+            $inComment = 0;
+        }
+        next if $inComment;
+
+        next if /^\s*[#'"]/; # Skip indented and non-indented lines that begin with a comment or string literal (includes docstrings).
+
         next unless $rest =~ /(?:class|def)\s+(\w+)/;
         my $name = $1;
         my $fullName = $scope->{name} ? join('.', $scope->{name}, $name) : $name;

Modified: releases/WebKitGTK/webkit-2.20/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt (228625 => 228626)


--- releases/WebKitGTK/webkit-2.20/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt	2018-02-19 09:32:40 UTC (rev 228625)
+++ releases/WebKitGTK/webkit-2.20/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt	2018-02-19 09:35:49 UTC (rev 228626)
@@ -124,8 +124,53 @@
     ],
     [
       '97',
-      '97',
+      '98',
       'Class5'
-    ]
+    ],
+    [
+      '112',
+      '113',
+      'Class6'
+    ],
+    [
+      '112',
+      '113',
+      'Class6'
+    ],
+    [
+      '114',
+      '117',
+      'Class6.__init__'
+    ],
+    [
+      '119',
+      '120',
+      'Class7'
+    ],
+    [
+      '119',
+      '120',
+      'Class7'
+    ],
+    [
+      '121',
+      '124',
+      'Class7.__init__'
+    ],
+    [
+      '136',
+      '141',
+      'Class8'
+    ],
+    [
+      '136',
+      '141',
+      'Class8'
+    ],
+    [
+      '142',
+      '143',
+      'Class8.__init__'
+    ],
   ]
 }

Modified: releases/WebKitGTK/webkit-2.20/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py (228625 => 228626)


--- releases/WebKitGTK/webkit-2.20/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py	2018-02-19 09:32:40 UTC (rev 228625)
+++ releases/WebKitGTK/webkit-2.20/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py	2018-02-19 09:35:49 UTC (rev 228626)
@@ -95,3 +95,49 @@
     def func11():
         pass
     pass
+
+"""class A"""
+
+'class A'
+
+"class A"
+
+"""def A"""
+
+'def A'
+
+"def A"
+
+"""class Class6"""
+class Class6:
+    """class Class6_1"""
+    def __init__(self):
+        """class Class6_2"""
+        pass
+
+"""def Class7"""
+class Class7:
+    """def Class7_1"""
+    def __init__(self):
+        """def Class7_2"""
+        pass
+
+"""a
+class b
+"""
+
+"""a
+def b
+"""
+
+"""
+class class8
+"""
+class Class8:
+    pass
+
+    """
+    def Class8_1
+    """
+    def __init__(self):
+        pass
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to