Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
serhiy-storchaka opened this issue Dec 22, 2023 · 3 comments
Closed
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Dec 22, 2023

$ ./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

@serhiy-storchaka
Copy link
Member Author

This causes failing 109 of 469 tests.

@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir 3.12 bugs and security fixes 3.13 bugs and security fixes labels Dec 22, 2023
@serhiy-storchaka
Copy link
Member Author

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

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Dec 22, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 24, 2023
…thout docstrings (pythonGH-113408)

(cherry picked from commit 0c57454)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue Dec 24, 2023
…ithout docstrings (GH-113408) (GH-113454)

(cherry picked from commit 0c57454)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
ryan-duve pushed a commit to ryan-duve/cpython that referenced this issue Dec 26, 2023
@carljm
Copy link
Member

carljm commented Jan 1, 2024

Thanks for this fix, @serhiy-storchaka !

kulikjak pushed a commit to kulikjak/cpython that referenced this issue Jan 22, 2024
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants