Skip to content

Failure when running test_inspect locally #136549

Closed
@ZeroIntensity

Description

@ZeroIntensity

Bug report

Bug description:

When running test_inspect locally (either via unittest or via executing Lib/test/test_inspect/test_inspect.py), I see this failure:

ERROR: test_threading_module_has_signatures (__main__.TestSignatureDefinitions.test_threading_module_has_signatures) [supported] (builtin='excepthook')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peter/develop/cpython/Lib/test/test_inspect/test_inspect.py", line 5717, in _test_module_has_signatures
    self.assertIsNotNone(inspect.signature(obj))
                         ~~~~~~~~~~~~~~~~~^^^^^
  File "/home/peter/develop/cpython/Lib/inspect.py", line 3312, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                   globals=globals, locals=locals, eval_str=eval_str,
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                   annotation_format=annotation_format)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/peter/develop/cpython/Lib/inspect.py", line 3027, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
                                    follow_wrapper_chains=follow_wrapped,
                                    globals=globals, locals=locals, eval_str=eval_str,
                                    annotation_format=annotation_format)
  File "/home/peter/develop/cpython/Lib/inspect.py", line 2508, in _signature_from_callable
    return _signature_from_builtin(sigcls, obj,
                                   skip_bound_arg=skip_bound_arg)
  File "/home/peter/develop/cpython/Lib/inspect.py", line 2294, in _signature_from_builtin
    return _signature_fromstr(cls, func, s, skip_bound_arg)
  File "/home/peter/develop/cpython/Lib/inspect.py", line 2150, in _signature_fromstr
    raise ValueError("{!r} builtin has invalid signature".format(obj))
ValueError: <built-in function _excepthook> builtin has invalid signature

I'm able to reproduce this back to 3.13, so it's definitely not a recent failure.

Interestingly, this failure does not show up when running through regrtest (python -m test test_inspect), both in CI or locally. I'm not sure if this is a misconfiguration that regrtest fixes, or an actual bug that's being hidden.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixestestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions