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
28231453
Commit
28231453
authored
Feb 21, 2014
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inspect: Fix getfullargspec to support builtin module-level functions. Issue #20711
parent
b8c67f22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
Lib/inspect.py
Lib/inspect.py
+9
-2
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+7
-0
No files found.
Lib/inspect.py
View file @
28231453
...
...
@@ -1827,9 +1827,16 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True):
p
(
f
.
args
.
kwarg
,
empty
)
if
self_parameter
is
not
None
:
# Possibly strip the bound argument:
# - We *always* strip first bound argument if
# it is a module.
# - We don't strip first bound argument if
# skip_bound_arg is False.
assert
parameters
if
getattr
(
obj
,
'__self__'
,
None
)
and
skip_bound_arg
:
# strip off self, it's already been bound
_self
=
getattr
(
obj
,
'__self__'
,
None
)
self_isbound
=
_self
is
not
None
self_ismodule
=
ismodule
(
_self
)
if
self_isbound
and
(
self_ismodule
or
skip_bound_arg
):
parameters
.
pop
(
0
)
else
:
# for builtins, self parameter is always positional-only!
...
...
Lib/test/test_inspect.py
View file @
28231453
...
...
@@ -643,6 +643,13 @@ class TestClassesAndFunctions(unittest.TestCase):
self
.
assertFullArgSpecEquals
(
_pickle
.
Pickler
(
io
.
BytesIO
()).
dump
,
args_e
=
[
'self'
,
'obj'
],
formatted
=
'(self, obj)'
)
self
.
assertFullArgSpecEquals
(
os
.
stat
,
args_e
=
[
'path'
],
kwonlyargs_e
=
[
'dir_fd'
,
'follow_symlinks'
],
kwonlydefaults_e
=
{
'dir_fd'
:
None
,
'follow_symlinks'
:
True
},
formatted
=
'(path, *, dir_fd=None, follow_symlinks=True)'
)
@
cpython_only
@
unittest
.
skipIf
(
MISSING_C_DOCSTRINGS
,
"Signature information for builtins requires docstrings"
)
...
...
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