8000 [3.13] gh-119600: mock: do not access attributes of original when new_callable is set (GH-119601) by miss-islington · Pull Request #120334 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.13] gh-119600: mock: do not access attributes of original when new_callable is set (GH-119601) #120334

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

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

miss-islington
Copy link
Contributor
@miss-islington miss-islington commented Jun 11, 2024

In order to patch flask.g e.g. as in GH-84982, that
proxies getattr must not be invoked. For that,
mock must not try to read from the original
object. In some cases that is unavoidable, e.g.
when doing autospec. However, patch("flask.g",
new_callable=MagicMock) should be entirely safe.
(cherry picked from commit 422c4fc)

Co-authored-by: Robert Collins robert.collins@cognite.com

…callable is set (pythonGH-119601)

In order to patch flask.g e.g. as in pythonGH-84982, that
proxies getattr must not be invoked. For that,
mock must not try to read from the original
object. In some cases that is unavoidable, e.g.
when doing autospec. However, patch("flask.g",
new_callable=MagicMock) should be entirely safe.
(cherry picked from commit 422c4fc)

Co-authored-by: Robert Collins <robert.collins@cognite.com>
@miss-islington miss-islington requested a review from cjw296 as a code owner June 11, 2024 05:41
@cjw296 cjw296 enabled auto-merge (squash) June 11, 2024 05:44
@cjw296 cjw296 merged commit aba5f2a into python:3.13 Jun 11, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0