Kaydet (Commit) 2e829c02 authored tarafından Matthias Klose's avatar Matthias Klose

- Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)).

üst e5069019
...@@ -624,14 +624,22 @@ def getargs(co): ...@@ -624,14 +624,22 @@ def getargs(co):
count.append(value) count.append(value)
elif opname == 'STORE_FAST': elif opname == 'STORE_FAST':
stack.append(names[value]) stack.append(names[value])
remain[-1] = remain[-1] - 1
while remain[-1] == 0: # Special case for sublists of length 1: def foo((bar))
remain.pop() # doesn't generate the UNPACK_TUPLE bytecode, so if
size = count.pop() # `remain` is empty here, we have such a sublist.
stack[-size:] = [stack[-size:]] if not remain:
if not remain: break stack[0] = [stack[0]]
break
else:
remain[-1] = remain[-1] - 1 remain[-1] = remain[-1] - 1
if not remain: break while remain[-1] == 0:
remain.pop()
size = count.pop()
stack[-size:] = [stack[-size:]]
if not remain: break
remain[-1] = remain[-1] - 1
if not remain: break
args[i] = stack[0] args[i] = stack[0]
varargs = None varargs = None
......
...@@ -374,3 +374,11 @@ test(defaults is None, 'A.m defaults') ...@@ -374,3 +374,11 @@ test(defaults is None, 'A.m defaults')
# Doc/lib/libinspect.tex claims there are 11 such functions # Doc/lib/libinspect.tex claims there are 11 such functions
count = len(filter(lambda x:x.startswith('is'), dir(inspect))) count = len(filter(lambda x:x.startswith('is'), dir(inspect)))
test(count == 11, "There are %d (not 11) is* functions", count) test(count == 11, "There are %d (not 11) is* functions", count)
def sublistOfOne((foo)): return 1
args, varargs, varkw, defaults = inspect.getargspec(sublistOfOne)
test(args == [['foo']], 'sublistOfOne args')
test(varargs is None, 'sublistOfOne varargs')
test(varkw is None, 'sublistOfOne varkw')
test(defaults is None, 'sublistOfOn defaults')
...@@ -76,6 +76,8 @@ Library ...@@ -76,6 +76,8 @@ Library
to return a list of all doctests, and you can filter that list by to return a list of all doctests, and you can filter that list by
any computable criteria before passing it to a DocTestRunner instance. any computable criteria before passing it to a DocTestRunner instance.
- Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)).
Tools/Demos Tools/Demos
----------- -----------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment