This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: inspect.signature(bytes.hex) raises ValueError "builtin has invalid signature"
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: boris
Priority: normal Keywords:

Created on 2021-01-29 21:00 by boris, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg385940 - (view) Author: Борис Верховский (boris) * Date: 2021-01-29 21:00
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/", line 3118, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/usr/lib/python3.9/", line 2867, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
  File "/usr/lib/python3.9/", line 2322, in _signature_from_callable
    return _signature_from_builtin(sigcls, obj,
  File "/usr/lib/python3.9/", line 2135, in _signature_from_builtin
    return _signature_fromstr(cls, func, s, skip_bound_arg)
  File "/usr/lib/python3.9/", 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
Date User Action Args
2022-04-11 14:59:40adminsetgithub: 87233
2021-01-29 21:00:52boriscreate