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

Side by Side Diff: Lib/inspect.py

Issue 19611: inspect.getcallargs doesn't properly interpret set comprehension code objects.
Patch Set: Created 3 years, 4 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « Doc/library/inspect.rst ('k') | Lib/test/test_inspect.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Get useful information from live Python objects. 1 """Get useful information from live Python objects.
2 2
3 This module encapsulates the interface provided by the internal special 3 This module encapsulates the interface provided by the internal special
4 attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion. 4 attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion.
5 It also provides some help for examining source code and class layout. 5 It also provides some help for examining source code and class layout.
6 6
7 Here are some of the useful functions provided by this module: 7 Here are some of the useful functions provided by this module:
8 8
9 ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(), 9 ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(),
10 isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(), 10 isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(),
(...skipping 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after
2388 msg = '{} parameters cannot have default values'.format(kind) 2388 msg = '{} parameters cannot have default values'.format(kind)
2389 raise ValueError(msg) 2389 raise ValueError(msg)
2390 self._default = default 2390 self._default = default
2391 self._annotation = annotation 2391 self._annotation = annotation
2392 2392
2393 if name is _empty: 2393 if name is _empty:
2394 raise ValueError('name is a required attribute for Parameter') 2394 raise ValueError('name is a required attribute for Parameter')
2395 2395
2396 if not isinstance(name, str): 2396 if not isinstance(name, str):
2397 raise TypeError("name must be a str, not a {!r}".format(name)) 2397 raise TypeError("name must be a str, not a {!r}".format(name))
2398
2399 if name[0] == '.' and name[1:].isdigit():
2400 # These are implicit arguments generated by comprehensions. In
2401 # order to provide a friendlier interface to users, we recast
2402 # their name as "implicitN" and treat them as positional-only.
2403 # See issue 19611.
2404 if kind != _POSITIONAL_OR_KEYWORD:
2405 raise ValueError(
2406 'implicit arguments must be passed in as {}'.format(
2407 _POSITIONAL_OR_KEYWORD
2408 )
2409 )
2410 self._kind = _POSITIONAL_ONLY
2411 name = 'implicit{}'.format(name[1:])
2398 2412
2399 if not name.isidentifier(): 2413 if not name.isidentifier():
2400 raise ValueError('{!r} is not a valid parameter name'.format(name)) 2414 raise ValueError('{!r} is not a valid parameter name'.format(name))
2401 2415
2402 self._name = name 2416 self._name = name
2403 2417
2404 def __reduce__(self): 2418 def __reduce__(self):
2405 return (type(self), 2419 return (type(self),
2406 (self._name, self._kind), 2420 (self._name, self._kind),
2407 {'_default': self._default, 2421 {'_default': self._default,
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
3020 else: 3034 else:
3021 print('Line: {}'.format(lineno)) 3035 print('Line: {}'.format(lineno))
3022 3036
3023 print('\n') 3037 print('\n')
3024 else: 3038 else:
3025 print(getsource(obj)) 3039 print(getsource(obj))
3026 3040
3027 3041
3028 if __name__ == "__main__": 3042 if __name__ == "__main__":
3029 _main() 3043 _main()
OLDNEW
« 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+