-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inspect.signature(bytes.hex) raises ValueError "builtin has invalid signature" #87233
Comments
On Python 3.9 >>> import inspect
>>> inspect.signature(bytes.hex)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.9/inspect.py", line 3118, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
File "/usr/lib/python3.9/inspect.py", line 2867, in from_callable
return _signature_from_callable(obj, sigcls=cls,
File "/usr/lib/python3.9/inspect.py", line 2322, in _signature_from_callable
return _signature_from_builtin(sigcls, obj,
File "/usr/lib/python3.9/inspect.py", line 2135, in _signature_from_builtin
return _signature_fromstr(cls, func, s, skip_bound_arg)
File "/usr/lib/python3.9/inspect.py", line 2005, in _signature_fromstr
raise ValueError("{!r} builtin has invalid signature".format(obj))
ValueError: <method 'hex' of 'bytes' objects> builtin has invalid signature This is also true for memoryview.hex and bytearray.hex . This happens because >>> bytes.hex.__text_signature__
'($self, /, sep=<unrepresentable>, bytes_per_sep=1)' when it would make more sense for it to return '($self, /, sep='', bytes_per_sep=1)' or at least sep=None |
I am looking at this because I realized it's preventing us from testing some signatures in typeshed. I got this to work:
But it feels wrong to claim My leaning is to apply the fix suggested above in 3.13, and put some hack in stubtest (or other tools that want to inspect signatures) to make it work on earlier versions. |
@serhiy-storchaka said that future |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: