Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(82126)

Unified Diff: Lib/inspect.py

Issue 19611: inspect.getcallargs doesn't properly interpret set comprehension code objects.
Patch Set: Created 3 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Doc/library/inspect.rst ('k') | Lib/test/test_inspect.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/inspect.py Fri Jun 03 19:14:52 2016 +0000
+++ b/Lib/inspect.py Fri Jun 03 17:15:39 2016 -0700
@@ -2396,6 +2396,20 @@
if not isinstance(name, str):
raise TypeError("name must be a str, not a {!r}".format(name))
+ if name[0] == '.' and name[1:].isdigit():
+ # These are implicit arguments generated by comprehensions. In
+ # order to provide a friendlier interface to users, we recast
+ # their name as "implicitN" and treat them as positional-only.
+ # See issue 19611.
+ if kind != _POSITIONAL_OR_KEYWORD:
+ raise ValueError(
+ 'implicit arguments must be passed in as {}'.format(
+ _POSITIONAL_OR_KEYWORD
+ )
+ )
+ self._kind = _POSITIONAL_ONLY
+ name = 'implicit{}'.format(name[1:])
+
if not name.isidentifier():
raise ValueError('{!r} is not a valid parameter name'.format(name))
« no previous file with comments | « Doc/library/inspect.rst ('k') | Lib/test/test_inspect.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+