-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
mock.seal has infinite recursion with int class attributes #89319
Comments
The code below seems to have infinite recursion in the mock.seal call with python 3.9.2. from unittest import mock
class Foo:
foo = 0
foo = mock.create_autospec(Foo)
mock.seal(foo) |
Reproduced on 3.11:
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/iritkatriel/src/cpython-1/Lib/unittest/mock.py", line 2917, in seal
seal(m)
^^^^^^^
File "/Users/iritkatriel/src/cpython-1/Lib/unittest/mock.py", line 2917, in seal
seal(m)
^^^^^^^
File "/Users/iritkatriel/src/cpython-1/Lib/unittest/mock.py", line 2917, in seal
seal(m)
^^^^^^^
[Previous line repeated 645 more times]
File "/Users/iritkatriel/src/cpython-1/Lib/unittest/mock.py", line 2911, in seal
m = getattr(mock, attr)
^^^^^^^^^^^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/Lib/unittest/mock.py", line 662, in __getattr__
result = create_autospec(
^^^^^^^^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/Lib/unittest/mock.py", line 2672, in create_autospec
mock = Klass(parent=_parent, _new_parent=_parent, _new_name=_new_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/Lib/unittest/mock.py", line 416, in __new__
new = type(cls.__name__, bases, {'__doc__': cls.__doc__})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt |
Pdb) list |
I've proposed a solution, based on the assumption that we don't need to recurse into
It seems like a simple and reasonable thing to do. |
Thanks for the report and the fix! |
mock.seal()
#28300Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: