Skip to content

Commit fc4095d

Browse files
committed
Mind dicts and lists on argument parsing for hightlighting.
1 parent 8c01848 commit fc4095d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

bpython/cli.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,13 @@ def getargspec(func):
522522
if not OPTS.arg_spec:
523523
return False
524524

525-
stack = [['', 0]]
525+
stack = [['', 0, '']]
526526
try:
527527
for (token, value) in PythonLexer().get_tokens(self.s):
528528
if token is Token.Punctuation:
529-
if value == '(':
530-
stack.append(['', 0])
531-
elif value == ')':
529+
if value in '([{':
530+
stack.append(['', 0, value])
531+
elif value in ')]}':
532532
stack.pop()
533533
elif value == ',':
534534
try:
@@ -542,8 +542,10 @@ def getargspec(func):
542542
stack[-1][1] = stack[-1][0]
543543
else:
544544
stack[-1][0] = ''
545-
_, arg_number = stack.pop()
546-
func, _ = stack.pop()
545+
while stack[-1][2] in '[{':
546+
stack.pop()
547+
_, arg_number, _ = stack.pop()
548+
func, _, _ = stack.pop()
547549
except IndexError:
548550
return False
549551

0 commit comments

Comments
 (0)