Skip to content

Importing unittest.mock fails when CPython is built without docstrings #113407

@serhiy-storchaka

Description

@serhiy-storchaka
$ ./python -c 'import unittest.mock' Traceback (most recent call last): File "<string>", line 1, in <module> import unittest.mock File "/home/serhiy/py/cpython/Lib/unittest/mock.py", line 2233, in <module> _CODE_SIG = inspect.signature(partial(CodeType.__init__, None)) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/serhiy/py/cpython/Lib/inspect.py", line 3378, in signature return Signature.from_callable(obj, follow_wrapped=follow_wrapped, ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ globals=globals, locals=locals, eval_str=eval_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/serhiy/py/cpython/Lib/inspect.py", line 3108, in from_callable return _signature_from_callable(obj, sigcls=cls, ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ follow_wrapper_chains=follow_wrapped, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ globals=globals, locals=locals, eval_str=eval_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/serhiy/py/cpython/Lib/inspect.py", line 2603, in _signature_from_callable wrapped_sig = _get_signature_of(obj.func) ~~~~~~~~~~~~~~~~~^^^^^^^^^^ File "/home/serhiy/py/cpython/Lib/inspect.py", line 2599, in _signature_from_callable return _signature_from_builtin(sigcls, obj, ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ skip_bound_arg=skip_bound_arg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/serhiy/py/cpython/Lib/inspect.py", line 2398, in _signature_from_builtin raise ValueError("no signature found for builtin {!r}".format(func)) ValueError: no signature found for builtin <slot wrapper '__init__' of 'object' objects> 

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions