gh-119600: mock: do not access attributes of original when … …new_callable is set#119601
gh-119600: mock: do not access attributes of original when … …new_callable is set#119601cjw296 merged 3 commits intopython:mainfrom
Conversation
|
(I haven't contributed to CPython for some years, so please forgive any irregularities and let me know what I need to do to make the PR acceptable !) I can of course write a test; its likely worth it, but that will need to be a few days away |
4e69397 to
224f2b5
Compare
|
Yes, please add a reproducer test that fails before the change and succeeds after. |
|
@cjw296 added! |
|
@cjw296 ping? |
cjw296
left a comment
There was a problem hiding this comment.
LGTM, need to add blurb to make the news check happy.
Also curious about why it's not finding the issue number?
…new_callable is set In order to patch flask.g e.g. as in python#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.
72cfa30 to
7f422a3
Compare
tirkarthi
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the patch.
|
Thanks @rbtcollins for the PR, and @cjw296 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…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>
|
GH-120334 is a backport of this pull request to the 3.13 branch. |
…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>
|
GH-120335 is a backport of this pull request to the 3.12 branch. |
…_callable is set (GH-119601) (#120335) gh-119600: mock: do not access attributes of original when new_callable is set (GH-119601) 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 (GH-119601) (#120334) gh-119600: mock: do not access attributes of original when new_callable is set (GH-119601) 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 (python#119601) In order to patch flask.g e.g. as in python#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.
…callable is set (python#119601) In order to patch flask.g e.g. as in python#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.
…callable is set (python#119601) In order to patch flask.g e.g. as in python#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.
In order to patch flask.g e.g. as in #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.