mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 05:34:51 +08:00
Simplify the regexes
This commit is contained in:
@@ -388,8 +388,10 @@ class DiffParser(object):
|
||||
# endmarker or another dedented code block.
|
||||
typ, string, start_pos, prefix = next(tokens)
|
||||
if '\n' in prefix or '\r' in prefix:
|
||||
prefix = re.sub(r'(?<=\n|\r)[^\n\r]+$', '', prefix)
|
||||
prefix = re.sub(r'[^\n\r]+\Z', '', prefix)
|
||||
else:
|
||||
# This is basically the next line and it still needs to
|
||||
# be parserd.
|
||||
prefix = ''
|
||||
yield PythonToken(
|
||||
PythonTokenTypes.ENDMARKER, '',
|
||||
|
||||
@@ -955,6 +955,10 @@ def test_wrong_backslash(differ):
|
||||
differ.parse(code1, parsers=1, copies=1)
|
||||
|
||||
|
||||
def test_comment_change(differ):
|
||||
differ.initialize('')
|
||||
|
||||
|
||||
def test_random_unicode_characters(differ):
|
||||
"""
|
||||
Those issues were all found with the fuzzer.
|
||||
@@ -970,3 +974,4 @@ def test_random_unicode_characters(differ):
|
||||
differ.parse(s + '\n', parsers=1, expect_error_leaves=True)
|
||||
differ.parse(' result = (\r\f\x17\t\x11res)', parsers=2, expect_error_leaves=True)
|
||||
differ.parse('')
|
||||
differ.parse(' a( # xx\ndef', parsers=2, expect_error_leaves=True)
|
||||
|
||||
Reference in New Issue
Block a user