Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mypyc] Fix Python 3.11 C API errors #12850

Merged
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mypyc/lib-rt/exc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void CPy_RestoreExcInfo(tuple_T3OOO info) {
}

bool CPy_ExceptionMatches(PyObject *type) {
return PyErr_GivenExceptionMatches(CPy_ExcState()->exc_type, type);
return PyErr_GivenExceptionMatches((PyObject *)Py_TYPE(CPy_ExcState()->exc_value), type);
}

PyObject *CPy_GetExcValue(void) {
Expand Down Expand Up @@ -189,6 +189,13 @@ void CPy_TypeError(const char *expected, PyObject *value) {
}
}

// The PyFrameObject type definition (struct _frame) has been moved
// to the internal C API: to the pycore_frame.h header file.
// https://github.com/python/cpython/pull/31530
#if PY_VERSION_HEX >= 0x030b00a6
#include "internal/pycore_frame.h"
#endif

// This function is basically exactly the same with _PyTraceback_Add
// which is available in all the versions we support.
// We're continuing to use this because we'll probably optimize this later.
Expand Down
2 changes: 1 addition & 1 deletion mypyc/lib-rt/misc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int CPy_YieldFromErrorHandle(PyObject *iter, PyObject **outp)
{
_Py_IDENTIFIER(close);
_Py_IDENTIFIER(throw);
PyObject *exc_type = CPy_ExcState()->exc_type;
PyObject *exc_type = (PyObject *)Py_TYPE(CPy_ExcState()->exc_value);
PyObject *type, *value, *traceback;
PyObject *_m;
PyObject *res;
Expand Down