mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-102755: PyErr_DisplayException only in ABI >= 3.12. Tests cover PyErr_Display as well (GH-102849)
This commit is contained in:
parent
82eb9469e7
commit
5c471f3f2a
3 changed files with 31 additions and 4 deletions
|
@ -40,12 +40,22 @@ static PyObject *
|
|||
exception_print(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *exc;
|
||||
int legacy = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O:exception_print", &exc)) {
|
||||
if (!PyArg_ParseTuple(args, "O|i:exception_print", &exc, &legacy)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyErr_DisplayException(exc);
|
||||
if (legacy) {
|
||||
PyObject *tb = NULL;
|
||||
if (PyExceptionInstance_Check(exc)) {
|
||||
tb = PyException_GetTraceback(exc);
|
||||
}
|
||||
PyErr_Display((PyObject *) Py_TYPE(exc), exc, tb);
|
||||
Py_XDECREF(tb);
|
||||
}
|
||||
else {
|
||||
PyErr_DisplayException(exc);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue