diff options
author | Matthias Klose <doko@ubuntu.com> | 2004-08-15 17:04:33 (GMT) |
---|---|---|
committer | Matthias Klose <doko@ubuntu.com> | 2004-08-15 17:04:33 (GMT) |
commit | 2e829c0214fc68655f1aaf2d4279697ee55394b3 (patch) | |
tree | 6e4a0cb9f8849395f2b6029d3897b08327898090 /Lib/inspect.py | |
parent | e5069019e7bd33ed5d6072c38ad149694053aaca (diff) | |
download | cpython-2e829c0214fc68655f1aaf2d4279697ee55394b3.zip cpython-2e829c0214fc68655f1aaf2d4279697ee55394b3.tar.gz cpython-2e829c0214fc68655f1aaf2d4279697ee55394b3.tar.bz2 |
- Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)).
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 7f73264..42eda77 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -624,14 +624,22 @@ def getargs(co): count.append(value) elif opname == 'STORE_FAST': stack.append(names[value]) - remain[-1] = remain[-1] - 1 - while remain[-1] == 0: - remain.pop() - size = count.pop() - stack[-size:] = [stack[-size:]] - if not remain: break + + # Special case for sublists of length 1: def foo((bar)) + # doesn't generate the UNPACK_TUPLE bytecode, so if + # `remain` is empty here, we have such a sublist. + if not remain: + stack[0] = [stack[0]] + break + else: 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] varargs = None |