Skip to content

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

Closed

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

Activity

  1. serhiy-storchaka commented on Dec 22, 2023

    @serhiy-storchaka
    MemberAuthor

    This causes failing 109 of 469 tests.

  2. added
    type-bugAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directory
    3.12only security fixes
    3.13only security fixes
    on Dec 22, 2023
  3. serhiy-storchaka commented on Dec 22, 2023

    @serhiy-storchaka
    MemberAuthor

    It perhaps was caused by c5726b7 (gh-83076). @carljm

  4. added 2 commits that reference this issue on Dec 22, 2023
  5. added a commit that references this issue on Dec 24, 2023
  6. added a commit that references this issue on Dec 24, 2023
  7. added a commit that references this issue on Dec 26, 2023
  8. carljm commented on Jan 1, 2024

    @carljm
    Member

    Thanks for this fix, @serhiy-storchaka !

  9. added a commit that references this issue on Jan 22, 2024
  10. added a commit that references this issue on Feb 11, 2024
  11. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13only 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