mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 21:04:29 +08:00
Fix a backslash issue
This commit is contained in:
@@ -517,7 +517,7 @@ def tokenize_lines(lines, version_info, start_pos=(1, 0)):
|
||||
start = match.end()
|
||||
spos = (lnum, start)
|
||||
|
||||
if new_line and initial not in '\r\n\\#':
|
||||
if new_line and initial not in '\r\n#' and (initial != '\\' or pseudomatch is None):
|
||||
new_line = False
|
||||
if paren_level == 0 and not fstring_stack:
|
||||
i = 0
|
||||
|
||||
@@ -1332,3 +1332,19 @@ def test_wrong_indent_in_def(differ):
|
||||
differ.initialize(code1)
|
||||
differ.parse(code2, parsers=1, expect_error_leaves=True)
|
||||
differ.parse(code1, parsers=1)
|
||||
|
||||
|
||||
def test_backslash_issue(differ):
|
||||
code1 = dedent('''
|
||||
pre = (
|
||||
'')
|
||||
after = 'instead'
|
||||
''')
|
||||
code2 = dedent('''
|
||||
pre = (
|
||||
'')
|
||||
\\if
|
||||
''')
|
||||
differ.initialize(code1)
|
||||
differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)
|
||||
differ.parse(code1, parsers=1, copies=1)
|
||||
|
||||
Reference in New Issue
Block a user