##// END OF EJS Templates
Don't let parentheses level go below 0
Thomas Kluyver -
Show More
@@ -81,7 +81,7 b' def cell_magic(lines):'
81 81 # -----
82 82
83 83 def _find_assign_op(token_line):
84 # Find the first assignment in the line ('=' not inside brackets)
84 # Get the index of the first assignment in the line ('=' not inside brackets)
85 85 # We don't try to support multiple special assignment (a = b = %foo)
86 86 paren_level = 0
87 87 for i, ti in enumerate(token_line):
@@ -91,7 +91,8 b' def _find_assign_op(token_line):'
91 91 if s in '([{':
92 92 paren_level += 1
93 93 elif s in ')]}':
94 paren_level -= 1
94 if paren_level > 0:
95 paren_level -= 1
95 96
96 97 def find_end_of_continued_line(lines, start_line: int):
97 98 """Find the last line of a line explicitly extended using backslashes.
@@ -386,7 +387,8 b' def make_tokens_by_line(lines):'
386 387 elif token.string in {'(', '[', '{'}:
387 388 parenlev += 1
388 389 elif token.string in {')', ']', '}'}:
389 parenlev -= 1
390 if parenlev > 0:
391 parenlev -= 1
390 392 except tokenize.TokenError:
391 393 # Input ended in a multiline string or expression. That's OK for us.
392 394 pass
General Comments 0
You need to be logged in to leave comments. Login now