Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2e829c02
Commit
2e829c02
authored
Aug 15, 2004
by
Matthias Klose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Bug #891637, patch #1005466: fix inspect.getargs() crash on def foo((bar)).
parent
e5069019
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
Lib/inspect.py
Lib/inspect.py
+15
-7
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+8
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/inspect.py
View file @
2e829c02
...
...
@@ -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
...
...
Lib/test/test_inspect.py
View file @
2e829c02
...
...
@@ -374,3 +374,11 @@ test(defaults is None, 'A.m defaults')
# Doc/lib/libinspect.tex claims there are 11 such functions
count
=
len
(
filter
(
lambda
x
:
x
.
startswith
(
'is'
),
dir
(
inspect
)))
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'
)
Misc/NEWS
View file @
2e829c02
...
...
@@ -76,6 +76,8 @@ Library
to
return
a
list
of
all
doctests
,
and
you
can
filter
that
list
by
any
computable
criteria
before
passing
it
to
a
DocTestRunner
instance
.
-
Bug
#
891637
,
patch
#
1005466
:
fix
inspect
.
getargs
()
crash
on
def
foo
((
bar
)).
Tools
/
Demos
-----------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment