Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-37251: MagicMock with function spec used as a spec in mock.patch should return a MagicMock#14117

Closed
tirkarthi wants to merge 2 commits into
python:masterpython/cpython:masterfrom
tirkarthi:bpo37251tirkarthi/cpython:bpo37251Copy head branch name to clipboard
Closed

bpo-37251: MagicMock with function spec used as a spec in mock.patch should return a MagicMock#14117
tirkarthi wants to merge 2 commits into
python:masterpython/cpython:masterfrom
tirkarthi:bpo37251tirkarthi/cpython:bpo37251Copy head branch name to clipboard

Conversation

@tirkarthi

@tirkarthi tirkarthi commented Jun 15, 2019

Copy link
Copy Markdown
Member

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
Copy Markdown
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.