Skip to content

Commit 0588bb3

Browse files
committed
use PyErr_WriteUnraisable
1 parent 163f948 commit 0588bb3

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

Modules/clinic/cmathmodule.c.h

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/cmathmodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ if (errno == EDOM) {
4040
PyObject *exc = PyErr_GetRaisedException();
4141
PyObject *value = PyComplex_FromCComplex(_return_value);
4242
43-
if (value) {
44-
PyObject_SetAttrString(exc, "value", value);
43+
if (!value || PyObject_SetAttrString(exc, "value", value)) {
44+
PyErr_WriteUnraisable(NULL);
4545
}
4646
Py_XDECREF(value);
4747
PyErr_SetRaisedException(exc);
@@ -56,7 +56,7 @@ else {
5656
}
5757
""".strip())
5858
[python start generated code]*/
59-
/*[python end generated code: output=da39a3ee5e6b4b0d input=25da698732cbffe0]*/
59+
/*[python end generated code: output=da39a3ee5e6b4b0d input=e8ab0c05f14885e9]*/
6060

6161
#if (FLT_RADIX != 2 && FLT_RADIX != 16)
6262
#error "Modules/cmathmodule.c expects FLT_RADIX to be 2 or 16"
@@ -904,8 +904,8 @@ cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj)
904904
PyObject *exc = PyErr_GetRaisedException();
905905
PyObject *value = PyComplex_FromCComplex(x);
906906

907-
if (value) {
908-
PyObject_SetAttrString(exc, "value", value);
907+
if (!value || PyObject_SetAttrString(exc, "value", value)) {
908+
PyErr_WriteUnraisable(NULL);
909909
}
910910
Py_XDECREF(value);
911911
PyErr_SetRaisedException(exc);

0 commit comments

Comments
 (0)