summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-06-11 06:04:06 (GMT)
committerGitHub <noreply@github.com>2024-06-11 06:04:06 (GMT)
commitaba5f2a4d10a7b261d4af03a54a8b1083bd83700 (patch)
tree9a0f5010d55c7493a3ec9f51d44847dbc1e22590 /Misc
parentffc8e21c80627c46be7a7467ee5427924fdeb885 (diff)
downloadcpython-aba5f2a4d10a7b261d4af03a54a8b1083bd83700.zip
cpython-aba5f2a4d10a7b261d4af03a54a8b1083bd83700.tar.gz
cpython-aba5f2a4d10a7b261d4af03a54a8b1083bd83700.tar.bz2
[3.13] gh-119600: mock: do not access attributes of original when new_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 422c4fc855afd18bcc6415902ea1d85a50cb7ce1) Co-authored-by: Robert Collins <robert.collins@cognite.com>
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Library/2024-06-10-14-00-40.gh-issue-119600.jJMf4C.rst2
1 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2024-06-10-14-00-40.gh-issue-119600.jJMf4C.rst b/Misc/NEWS.d/next/Library/2024-06-10-14-00-40.gh-issue-119600.jJMf4C.rst
new file mode 100644
index 0000000..04c9ca9
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-06-10-14-00-40.gh-issue-119600.jJMf4C.rst
@@ -0,0 +1,2 @@
+Fix :func:`unittest.mock.patch` to not read attributes of the target when
+``new_callable`` is set. Patch by Robert Collins.