[issue36920] inspect.getcallargs sees optional arg to builtin as required

Karthikeyan Singaravelan report at bugs.python.org
Wed May 15 03:09:34 EDT 2019


Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:

This not reproducible on master and seems to fixed as part of PEP 570 related changes. Bisecting gives me d5d2b4546939b98244708e5bb0cfccd55b99d244 . Before d5d2b4546939b98244708e5bb0cfccd55b99d244 it produces an internal index error. I can reproduce the reported TypeError before PEP 570 was merged. I guess it's working perhaps as an unintended effect of the commit and internal error tells me it was not tested. Perhaps it's good to add a test for this? Note the change in fullargspec output between commits. Adding Pablo who will have better context.

➜  cpython git:(d5d2b45469) ./python.exe -c 'import inspect; print(inspect.getfullargspec(str.strip)); print(inspect.getcallargs(str.strip, "a"))'
/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/inspect.py:1114: DeprecationWarning: Use inspect.signature() instead of inspect.getfullargspec()
  warnings.warn("Use inspect.signature() instead of inspect.getfullargspec()",
FullArgSpec(args=['self', 'chars'], varargs=None, varkw=None, defaults=(None,), kwonlyargs=[], kwonlydefaults=None, annotations={})
{'self': 'a', 'chars': None}

d5d2b45469~1 commit

➜  cpython git:(81c5a90595) ./python.exe -c 'import inspect; print(inspect.getfullargspec(str.strip)); print(inspect.getcallargs(str.strip, "a"))'
FullArgSpec(args=[], varargs=None, varkw=None, defaults=(None,), posonlyargs=['self', 'chars'], kwonlyargs=[], kwonlydefaults=None, annotations={})
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/inspect.py", line 1365, in getcallargs
    arg2value[posonlyargs[i]] = positional[i]
IndexError: tuple index out of range

----------
nosy: +pablogsal, xtreak

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36920>
_______________________________________


More information about the Python-bugs-list mailing list