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
a6d25063
Commit
a6d25063
authored
Jun 23, 2014
by
Yury Selivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inspect: Validate that __signature__ is None or an instance of Signature.
Closes #21801.
parent
fee5c441
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
+13
-0
Lib/inspect.py
Lib/inspect.py
+4
-0
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+7
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/inspect.py
View file @
a6d25063
...
...
@@ -1912,6 +1912,10 @@ def _signature_internal(obj, follow_wrapper_chains=True, skip_bound_arg=True):
pass
else
:
if
sig
is
not
None
:
if
not
isinstance
(
sig
,
Signature
):
raise
TypeError
(
'unexpected object {!r} in __signature__ '
'attribute'
.
format
(
sig
))
return
sig
try
:
...
...
Lib/test/test_inspect.py
View file @
a6d25063
...
...
@@ -3048,6 +3048,13 @@ class TestMain(unittest.TestCase):
self
.
assertEqual
(
lines
[:
-
1
],
inspect
.
getsource
(
module
).
splitlines
())
self
.
assertEqual
(
err
,
b''
)
def
test_custom_getattr
(
self
):
def
foo
():
pass
foo
.
__signature__
=
42
with
self
.
assertRaises
(
TypeError
):
inspect
.
signature
(
foo
)
@
unittest
.
skipIf
(
ThreadPoolExecutor
is
None
,
'threads required to test __qualname__ for source files'
)
def
test_qualname_source
(
self
):
...
...
Misc/NEWS
View file @
a6d25063
...
...
@@ -105,6 +105,8 @@ Library
- Issue #21538: The plistlib module now supports loading of binary plist files
when reference or offset size is not a power of two.
- Issue #21801: Validate that __signature__ is None or an instance of Signature.
Build
-----
...
...
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