Skip to content

Builtin functions and methods lack a .__text_signature__ property #2410

Description

@verhovsky

On CPython:

>>> import inspect, struct
>>> inspect.signature(struct.unpack_from)
<Signature (format, /, buffer, offset=0)>

Running this under the debugger (import pdb; pdb.runcall(inspect.signature, struct.unpack_from)), you see that inspect does getattr(struct.unpack_from, "__text_signature__") which is defined in CPython here, and that's not implemented in RustPython, so you get this instead:

>>>>> import inspect, struct
>>>>> inspect.signature(struct.unpack_from)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/boris/code/RustPython/vm/pylib-crate/Lib/inspect.py", line 3093, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
  File "/home/boris/code/RustPython/vm/pylib-crate/Lib/inspect.py", line 2843, in from_callable
    follow_wrapper_chains=follow_wrapped)
  File "/home/boris/code/RustPython/vm/pylib-crate/Lib/inspect.py", line 2297, in _signature_from_callable
    skip_bound_arg=skip_bound_arg)
  File "/home/boris/code/RustPython/vm/pylib-crate/Lib/inspect.py", line 2107, in _signature_from_builtin
    raise ValueError("no signature found for builtin {!r}".format(func))
ValueError: no signature found for builtin <builtin_function_or_method object at 0x55f59d0558d0>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions