Skip to content

Conversation

@tirkarthi
Copy link
Member

@tirkarthi tirkarthi commented Jun 15, 2019

MagicMock with a function spec will have __code__ object. When it is used a spec to mock.patch then __code__ object which is a MagicMock is used to detect if it's a coroutine. MagicMock.__code__ & 128 returns another MagicMock which is evaluated to True and returned as a coroutine incorrectly. Hence check __code__ to be a CodeType to make sure MagicMock with __code__ is not detected as coroutine.

https://bugs.python.org/issue37251

@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label Jun 21, 2019
lisroach referenced this pull request in lisroach/cpython Sep 9, 2019
@tirkarthi
Copy link
Member Author

Closing in favor of #15830 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review type-bug An unexpected behavior, bug, or error

5 participants