Changeset 228131 in webkit
- Timestamp:
- Feb 5, 2018 2:54:17 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r228118 r228131 1 2018-02-05 Daniel Bates <dabates@apple.com> 2 3 prepare-ChangeLog gets confused about Python docstrings that contain the word "class" or "def" 4 https://bugs.webkit.org/show_bug.cgi?id=182405 5 6 Reviewed by David Kilzer. 7 8 String literal statements, including docstrings, do not demarcate a new scope in Python. 9 So, do not treat them like they do when building up the list of modified functions. 10 11 * Scripts/prepare-ChangeLog: 12 (get_function_line_ranges_for_python): 13 * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt: 14 The expected ending line number for the last "pass" statement inside the scope of Class5 changed 15 from 97 to 98 because empty lines do not effect scope. This is consistent with the parsing 16 of the second "pass" statement in the scope of class Class5. A "pass" is a null operation that 17 is used as a syntactic placeholder when a statement is required. Ideally we would make 18 the parsing code smarter so as to avoid emitting ranges for "pass" statements that serve 19 not syntactic purpose. 20 * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py: 21 (Class5): 22 (Class6): 23 (Class6.__init__): 24 (Class7): 25 (Class7.__init__): 26 (Class8): 27 (Class8.__init__): 28 Add some more tests. 29 1 30 2018-02-05 Matt Lewis <jlewis3@apple.com> 2 31 -
trunk/Tools/Scripts/prepare-ChangeLog
r220032 r228131 1784 1784 my @ranges; 1785 1785 1786 my $multilineStringLiteralSentinelRegEx = qr#(?:"""|''')#; 1787 my $multilineStringLiteralStartRegEx = qr#^\s*$multilineStringLiteralSentinelRegEx#; 1788 my $multilineStringLiteralEndRegEx = qr#$multilineStringLiteralSentinelRegEx\s*$#; 1789 1786 1790 my @scopeStack = ({ line => 0, indent => -1, name => undef }); 1787 1791 my $lastLine = 0; 1792 my $inComment = 0; 1788 1793 until ($lastLine) { 1789 1794 $_ = <$fileHandle>; … … 1796 1801 } 1797 1802 chomp; 1798 next unless /^(\s*)([^#].*)$/; 1803 next unless /^(\s*)([^#].*)$/; # Skip non-indented lines that begin with a comment. 1799 1804 1800 1805 my $indent = length $1; … … 1824 1829 $scope->{line} = $.; 1825 1830 } 1831 1832 # Skip multi-line string literals and docstrings. 1833 next if /$multilineStringLiteralStartRegEx.*$multilineStringLiteralEndRegEx/; 1834 if (!$inComment && /$multilineStringLiteralStartRegEx/) { 1835 $inComment = 1; 1836 } elsif ($inComment && /$multilineStringLiteralEndRegEx/) { 1837 $inComment = 0; 1838 } 1839 next if $inComment; 1840 1841 next if /^\s*[#'"]/; # Skip indented and non-indented lines that begin with a comment or string literal (includes docstrings). 1826 1842 1827 1843 next unless $rest =~ /(?:class|def)\s+(\w+)/; -
trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt
r105837 r228131 125 125 [ 126 126 '97', 127 '9 7',127 '98', 128 128 'Class5' 129 ] 129 ], 130 [ 131 '112', 132 '113', 133 'Class6' 134 ], 135 [ 136 '112', 137 '113', 138 'Class6' 139 ], 140 [ 141 '114', 142 '117', 143 'Class6.__init__' 144 ], 145 [ 146 '119', 147 '120', 148 'Class7' 149 ], 150 [ 151 '119', 152 '120', 153 'Class7' 154 ], 155 [ 156 '121', 157 '124', 158 'Class7.__init__' 159 ], 160 [ 161 '136', 162 '141', 163 'Class8' 164 ], 165 [ 166 '136', 167 '141', 168 'Class8' 169 ], 170 [ 171 '142', 172 '143', 173 'Class8.__init__' 174 ], 130 175 ] 131 176 } -
trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py
r104132 r228131 96 96 pass 97 97 pass 98 99 """class A""" 100 101 'class A' 102 103 "class A" 104 105 """def A""" 106 107 'def A' 108 109 "def A" 110 111 """class Class6""" 112 class Class6: 113 """class Class6_1""" 114 def __init__(self): 115 """class Class6_2""" 116 pass 117 118 """def Class7""" 119 class Class7: 120 """def Class7_1""" 121 def __init__(self): 122 """def Class7_2""" 123 pass 124 125 """a 126 class b 127 """ 128 129 """a 130 def b 131 """ 132 133 """ 134 class class8 135 """ 136 class Class8: 137 pass 138 139 """ 140 def Class8_1 141 """ 142 def __init__(self): 143 pass
Note: See TracChangeset
for help on using the changeset viewer.