mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
gh-101326: Fix regression when passing None to FutureIter.throw (#101327)
This commit is contained in:
parent
952a1d9cc9
commit
a178ba82bf
3 changed files with 9 additions and 1 deletions
|
@ -612,6 +612,8 @@ class BaseFutureTests:
|
||||||
Exception, Exception("elephant"), 32)
|
Exception, Exception("elephant"), 32)
|
||||||
self.assertRaises(TypeError, fi.throw,
|
self.assertRaises(TypeError, fi.throw,
|
||||||
Exception("elephant"), Exception("elephant"))
|
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)
|
self.assertRaises(TypeError, fi.throw, list)
|
||||||
|
|
||||||
def test_future_del_collect(self):
|
def test_future_del_collect(self):
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix regression when passing ``None`` as second or third argument to ``FutureIter.throw``.
|
|
@ -1694,7 +1694,12 @@ FutureIter_throw(futureiterobject *self, PyObject *const *args, Py_ssize_t nargs
|
||||||
val = args[1];
|
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");
|
PyErr_SetString(PyExc_TypeError, "throw() third argument must be a traceback");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue