From 2978893013ef2c2ca8700432f3789c50c4f8deb0 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Sat, 10 Dec 2022 05:04:50 -0500 Subject: [PATCH 1/5] Fix potential flakiness in `test_run_until_complete_baseexception` (#100148) From fc2eb2641414c157f0b1b1498455e93eba7f1879 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Sat, 10 Dec 2022 05:05:24 -0500 Subject: [PATCH 2/5] Fix potential flakiness in `test_run_until_complete_baseexception` (#100148) From 9aad32a73931c3c8215178678e40c3c7a38c7949 Mon Sep 17 00:00:00 2001 From: colorfulappl Date: Sat, 17 Dec 2022 14:40:51 +0800 Subject: [PATCH 3/5] gh-99240: Reset pointer to NULL when the pointed memory is freed in argument parsing (#99890) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Erlend E. Aasland From 744b398300faeaeccf03407839c5e229cd84eb4d Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sat, 24 Dec 2022 11:21:48 +0530 Subject: [PATCH 4/5] GH-91166: Implement zero copy writes for `SelectorSocketTransport` in asyncio (#31871) Co-authored-by: Guido van Rossum From 2440a48e7a0bf92cc88a5bfe3f9694dc5335a348 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 11 Mar 2023 07:55:47 -0800 Subject: [PATCH 5/5] Initial test_fetch_exception_with_broken_init --- Lib/test/test_capi/test_exceptions.py | 9 ++++++++ Modules/_testcapi/exceptions.c | 30 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Lib/test/test_capi/test_exceptions.py b/Lib/test/test_capi/test_exceptions.py index 55f131699a2567..06d12b70ae1a12 100644 --- a/Lib/test/test_capi/test_exceptions.py +++ b/Lib/test/test_capi/test_exceptions.py @@ -169,5 +169,14 @@ class Broken(Exception, metaclass=Meta): with self.assertRaises(ZeroDivisionError) as e: _testcapi.exc_set_object(Broken, Broken()) + def test_fetch_exception_with_broken_init(self): + + class FlakyException(Exception): + def __init__(self): + raise ValueError("Broken __init__") + + fetched_type_name = _testcapi.exc_set_object_fetch(FlakyException, ()) + self.assertEqual(fetched_type_name, 'FlakyException') + if __name__ == "__main__": unittest.main() diff --git a/Modules/_testcapi/exceptions.c b/Modules/_testcapi/exceptions.c index a0575213987ffc..ad87a4e9236d35 100644 --- a/Modules/_testcapi/exceptions.c +++ b/Modules/_testcapi/exceptions.c @@ -92,6 +92,35 @@ exc_set_object(PyObject *self, PyObject *args) return NULL; } +static PyObject * +exc_set_object_fetch(PyObject *self, PyObject *args) +{ + PyObject *exc; + PyObject *obj; + PyObject *type; + PyObject *value; + PyObject *tb; + + if (!PyArg_ParseTuple(args, "OO:exc_set_object", &exc, &obj)) { + return NULL; + } + + PyErr_SetObject(exc, obj); + PyErr_Fetch(&type, &value, &tb); + Py_XDECREF(value); + Py_XDECREF(tb); + if (!PyType_Check(type)) { + Py_XDECREF(type); + PyErr_SetString(PyExc_RuntimeError, + "PyErr_Fetch() produced invalid type"); + return NULL; + } + PyObject *fetched_type_name = PyUnicode_FromString( + ((PyTypeObject *) type)->tp_name); + Py_XDECREF(type); + return fetched_type_name; +} + static PyObject * raise_exception(PyObject *self, PyObject *args) { @@ -262,6 +291,7 @@ static PyMethodDef test_methods[] = { {"make_exception_with_doc", _PyCFunction_CAST(make_exception_with_doc), METH_VARARGS | METH_KEYWORDS}, {"exc_set_object", exc_set_object, METH_VARARGS}, + {"exc_set_object_fetch", exc_set_object_fetch, METH_VARARGS}, {"raise_exception", raise_exception, METH_VARARGS}, {"raise_memoryerror", raise_memoryerror, METH_NOARGS}, {"set_exc_info", test_set_exc_info, METH_VARARGS},