mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives (in Python/) (#102193)
This commit is contained in:
parent
85b1fc1fc5
commit
4c87537efb
8 changed files with 42 additions and 72 deletions
|
@ -93,16 +93,12 @@ static PyObject *do_mkvalue(const char**, va_list *, int);
|
|||
static void
|
||||
do_ignore(const char **p_format, va_list *p_va, char endchar, Py_ssize_t n, int flags)
|
||||
{
|
||||
PyObject *v;
|
||||
Py_ssize_t i;
|
||||
assert(PyErr_Occurred());
|
||||
v = PyTuple_New(n);
|
||||
for (i = 0; i < n; i++) {
|
||||
PyObject *exception, *value, *tb, *w;
|
||||
|
||||
PyErr_Fetch(&exception, &value, &tb);
|
||||
w = do_mkvalue(p_format, p_va, flags);
|
||||
PyErr_Restore(exception, value, tb);
|
||||
PyObject *v = PyTuple_New(n);
|
||||
for (Py_ssize_t i = 0; i < n; i++) {
|
||||
PyObject *exc = PyErr_GetRaisedException();
|
||||
PyObject *w = do_mkvalue(p_format, p_va, flags);
|
||||
PyErr_SetRaisedException(exc);
|
||||
if (w != NULL) {
|
||||
if (v != NULL) {
|
||||
PyTuple_SET_ITEM(v, i, w);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue