Skip to content

Commit

Permalink
[mypyc] Fix generators on Python 3.12
Browse files Browse the repository at this point in the history
I think we relied on undocumented behavior on older Python versions.
Now it works consistently across all supported Python versions.

Work on mypyc/mypyc#995.
  • Loading branch information
JukkaL committed Jun 19, 2023
1 parent 719e7e7 commit df10932
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mypyc/lib-rt/exc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ void CPy_Reraise(void) {
}

void CPyErr_SetObjectAndTraceback(PyObject *type, PyObject *value, PyObject *traceback) {
if (!PyType_Check(type) && value == Py_None) {
// The first argument must be an exception instance
value = type;
type = (PyObject *)Py_TYPE(value);
}

// Set the value and traceback of an error. Because calling
// PyErr_Restore takes away a reference to each object passed in
// as an argument, we manually increase the reference count of
Expand Down

0 comments on commit df10932

Please sign in to comment.