[issue36593] Trace function interferes with MagicMock isinstance?
Karthikeyan Singaravelan
report at bugs.python.org
Wed Apr 10 20:19:37 EDT 2019
Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:
There are very few changes to mock.py on bisecting with the example in the report is d358a8cda75446a8e0b5d99149f709395d5eae19 the problem? I am surprised by the reason this commit leads to change in behavior with set trace.
➜ cpython git:(master) ✗ cat ../backups/bpo36593.py
import sys
def trace(frame, event, arg):
return trace
if len(sys.argv) > 1:
sys.settrace(trace)
from unittest.mock import MagicMock
class A:
pass
m = MagicMock(spec=A)
print("isinstance: ", isinstance(m, A))
➜ cpython git:(master) ✗ git checkout d358a8cda75446a8e0b5d99149f709395d5eae19 Lib/unittest/mock.py
➜ cpython git:(master) ✗ ./python.exe ../backups/bpo36593.py 1
isinstance: False
➜ cpython git:(master) ✗ git checkout d358a8cda75446a8e0b5d99149f709395d5eae19~1 Lib/unittest/mock.py
➜ cpython git:(master) ✗ ./python.exe ../backups/bpo36593.py 1
isinstance: True
commit d358a8cda75446a8e0b5d99149f709395d5eae19
Author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
Date: Mon Jan 21 01:37:54 2019 -0800
bpo-20239: Allow repeated deletion of unittest.mock.Mock attributes (GH-11629)
* Allow repeated deletion of unittest.mock.Mock attributes
* fixup! Allow repeated deletion of unittest.mock.Mock attributes
* fixup! fixup! Allow repeated deletion of unittest.mock.Mock attributes
(cherry picked from commit 222d303ade8aadf0adcae5190fac603bdcafe3f0)
Co-authored-by: Pablo Galindo <Pablogsal at gmail.com>
----------
nosy: +pablogsal
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36593>
_______________________________________
More information about the Python-bugs-list
mailing list