Repository navigation
Importing unittest.mock fails when CPython is built without docstrings #113407
Copy link
Copy link
Closed
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
$ ./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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
serhiy-storchaka commentedon Dec 22, 2023
This causes failing 109 of 469 tests.
serhiy-storchaka commentedon Dec 22, 2023
It perhaps was caused by c5726b7 (gh-83076). @carljm
pythongh-113407: Fix import of unittest.mock when CPython is built wi…
gh-113407: Fix import of unittest.mock when CPython is built without …
pythongh-113407: Fix import of unittest.mock when CPython is built wi…
[3.12] gh-113407: Fix import of unittest.mock when CPython is built w…
pythongh-113407: Fix import of unittest.mock when CPython is built wi…
carljm commentedon Jan 1, 2024
Thanks for this fix, @serhiy-storchaka !
pythongh-113407: Fix import of unittest.mock when CPython is built wi…
pythongh-113407: Fix import of unittest.mock when CPython is built wi…
pythongh-113407: Fix import of unittest.mock when CPython is built wi…