Skip to content
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

mock.patch introspects original even when new_callable set #119600

Closed
rbtcollins opened this issue May 27, 2024 · 0 comments
Closed

mock.patch introspects original even when new_callable set #119600

rbtcollins opened this issue May 27, 2024 · 0 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@rbtcollins
Copy link
Member

rbtcollins commented May 27, 2024

Bug report

Bug description:

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.

CPython versions tested on:

3.11, 3.12

Operating systems tested on:

Linux, macOS, Windows, Other

Linked PRs

@rbtcollins rbtcollins added the type-bug An unexpected behavior, bug, or error label May 27, 2024
rbtcollins added a commit to rbtcollins/cpython that referenced this issue May 27, 2024
…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.
@Eclips4 Eclips4 added the stdlib Python modules in the Lib dir label May 27, 2024
rbtcollins added a commit to rbtcollins/cpython that referenced this issue May 27, 2024
…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.
rbtcollins added a commit to rbtcollins/cpython that referenced this issue Jun 10, 2024
…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.
cjw296 pushed a commit that referenced this issue Jun 11, 2024
…le is set (#119601)

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.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 11, 2024
…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 <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 11, 2024
…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 <[email protected]>
cjw296 pushed a commit that referenced this issue Jun 11, 2024
…_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 <[email protected]>
cjw296 pushed a commit that referenced this issue Jun 11, 2024
…_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 <[email protected]>
@hugovk hugovk closed this as completed Jun 15, 2024
mrahtz pushed a commit to mrahtz/cpython that referenced this issue Jun 30, 2024
…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.
noahbkim pushed a commit to hudson-trading/cpython that referenced this issue Jul 11, 2024
…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.
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants