From 26cf4ad4b7570252838cbe63f02ce3a1c4d07dd6 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Wed, 25 Jan 2023 10:04:58 -0800 Subject: [PATCH 1/6] gh-101326: Fix regression when passing None to FutureIter.throw --- Modules/_asynciomodule.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 6fe4ca46947526..055dded05431df 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -1694,7 +1694,12 @@ FutureIter_throw(futureiterobject *self, PyObject *const *args, Py_ssize_t nargs val = args[1]; } - if (tb != NULL && !PyTraceBack_Check(tb)) { + if (val == Py_None) { + val = NULL; + } + if (tb == Py_None ) { + tb = NULL; + } else if (tb != NULL && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "throw() third argument must be a traceback"); return NULL; } From 78a74bef64a44ae19e785973bc1c677524396aac Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 25 Jan 2023 18:07:23 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst diff --git a/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst b/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst new file mode 100644 index 00000000000000..7f673ac2d8be3f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst @@ -0,0 +1 @@ +Fix regression when passing ``None`` to ``FutureIter.throw``. From aa59b1323aef9c48af355e485ff7c8b269d82bdb Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Wed, 25 Jan 2023 10:09:43 -0800 Subject: [PATCH 3/6] test --- Lib/test/test_asyncio/test_futures.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py index 56b0b864de2ddf..f8b9d30238f015 100644 --- a/Lib/test/test_asyncio/test_futures.py +++ b/Lib/test/test_asyncio/test_futures.py @@ -613,6 +613,8 @@ def test_future_iter_throw(self): self.assertRaises(TypeError, fi.throw, Exception("elephant"), Exception("elephant")) self.assertRaises(TypeError, fi.throw, list) + # https://github.com/python/cpython/issues/101326 + self.assertRaises(ValueError, fi.throw, ValueError, None, None) def test_future_del_collect(self): class Evil: From a252e3a1d8c9c33e219643b747c631920897c3d5 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Wed, 25 Jan 2023 10:16:11 -0800 Subject: [PATCH 4/6] swallow warning --- Lib/test/test_asyncio/test_futures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py index f8b9d30238f015..2184b2091f84ee 100644 --- a/Lib/test/test_asyncio/test_futures.py +++ b/Lib/test/test_asyncio/test_futures.py @@ -612,9 +612,9 @@ def test_future_iter_throw(self): Exception, Exception("elephant"), 32) self.assertRaises(TypeError, fi.throw, Exception("elephant"), Exception("elephant")) + # https://github.com/python/cpython/issues/101326 + self.assertRaises(ValueError, fi.throw, ValueError, None, None) self.assertRaises(TypeError, fi.throw, list) - # https://github.com/python/cpython/issues/101326 - self.assertRaises(ValueError, fi.throw, ValueError, None, None) def test_future_del_collect(self): class Evil: From 5d79981e951498d9c722eb5d8787e847bd6ff825 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 25 Jan 2023 11:06:38 -0800 Subject: [PATCH 5/6] Improve NEWS file Co-authored-by: Sebastian Rittau --- .../next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst b/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst index 7f673ac2d8be3f..0f80914fc53dbc 100644 --- a/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst +++ b/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst @@ -1 +1 @@ -Fix regression when passing ``None`` to ``FutureIter.throw``. +Fix regression when passing ``None`` as third argument to ``FutureIter.throw``. From e53c5c87bf7aa1adf0bb6cda033c925e3ee020c1 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Wed, 25 Jan 2023 11:25:01 -0800 Subject: [PATCH 6/6] Update Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst --- .../next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst b/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst index 0f80914fc53dbc..54b69b9430910d 100644 --- a/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst +++ b/Misc/NEWS.d/next/Library/2023-01-25-18-07-20.gh-issue-101326.KL4SFv.rst @@ -1 +1 @@ -Fix regression when passing ``None`` as third argument to ``FutureIter.throw``. +Fix regression when passing ``None`` as second or third argument to ``FutureIter.throw``.