X Tutup
Skip to content

Commit db3a34d

Browse files
committed
Fix paren handling in argument parsing for argspec.
This will close issue #54.
1 parent 8b4b634 commit db3a34d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

bpython/cli.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,18 @@ def parsekeywordpairs(signature):
112112
if token is Token.Punctuation:
113113
if value == u'(':
114114
parendepth += 1
115-
elif value == u')' and parendepth:
115+
elif value == u')':
116116
parendepth -= 1
117-
elif value == ':':
117+
elif value == ':' and parendepth == -1:
118118
# End of signature reached
119119
break
120120

121-
if parendepth:
121+
if parendepth > 0:
122122
substack.append(value)
123123
continue
124124

125-
if ((token is Token.Punctuation and value == ')')
126-
or (token is Token.Punctuation and value == u',')
127-
and not parendepth):
125+
if (token is Token.Punctuation and
126+
(value == ',' or (value == ')' and parendepth == -1))):
128127
stack.append(substack[:])
129128
del substack[:]
130129
continue

0 commit comments

Comments
 (0)
X Tutup