| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
mock_open's _exit_side_effect had a fixed 3-arg signature, but contextlib.ExitStack calls __exit__ with 4 args (self + 3 exc info). Use *args to accept any number of arguments. Fixes python#150484
|
Thanks @factnn for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, something went wrong.
|
GH-151861 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
|
My pleasure. |
Sorry, something went wrong.
…H-151829) (GH-151861) mock_open's _exit_side_effect had a fixed 3-arg signature, but contextlib.ExitStack calls __exit__ with 4 args (self + 3 exc info). Use *args to accept any number of arguments. (cherry picked from commit 85fa295) Co-authored-by: Zang Peiyu <166481866+factnn@users.noreply.github.com>
…Stack mock_open().__exit__ only misbehaves on 3.13 and 3.14, where it was fixed directly by pythonGH-151829 and backported as pythonGH-151861. Only the regression test belongs on main.
| Back | FazBrowse Home | New Git URL |
Fixes #150484.
mock_open()'s __exit__ raises TypeError when used with contextlib.ExitStack because _exit_side_effect had a fixed 3-arg signature (exctype, excinst, exctb), but ExitStack.__exit__ calls it with 4 args (self, exctype, excinst, exctb). Since the function body only calls handle.close() and doesn't use the arguments, the fix changes the signature to *args.
This is the 3.14 backport of #150521 (opened per request).