Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae8e6ad

Browse files
authored
Merge pull request #175 from python/master
Sync Fork from Upstream Repo
2 parents b21fcff + 2b1df45 commit ae8e6ad

6 files changed

Lines changed: 16 additions & 8 deletions

File tree

Include/cpython/pyerrors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ typedef PyOSErrorObject PyWindowsErrorObject;
7676

7777
PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *);
7878
_PyErr_StackItem *_PyErr_GetTopmostException(PyThreadState *tstate);
79+
PyAPI_FUNC(void) _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, PyObject **);
7980

8081
/* Context manipulation (PEP 3134) */
8182

Include/internal/pycore_ceval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct _frame;
1515

1616
#include "pycore_pystate.h" /* PyInterpreterState.eval_frame */
1717

18-
PyAPI_FUNC(void) _Py_FinishPendingCalls(struct pyruntimestate *runtime);
18+
PyAPI_FUNC(void) _Py_FinishPendingCalls(PyThreadState *tstate);
1919
PyAPI_FUNC(void) _PyEval_Initialize(struct _ceval_runtime_state *);
2020
PyAPI_FUNC(void) _PyEval_FiniThreads(
2121
struct _ceval_runtime_state *ceval);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a private ``_PyErr_GetExcInfo()`` function to retrieve exception information of the specified Python thread state.

Python/ceval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,11 @@ make_pending_calls(_PyRuntimeState *runtime)
585585
}
586586

587587
void
588-
_Py_FinishPendingCalls(_PyRuntimeState *runtime)
588+
_Py_FinishPendingCalls(PyThreadState *tstate)
589589
{
590590
assert(PyGILState_Check());
591591

592-
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
592+
_PyRuntimeState *runtime = tstate->interp->runtime;
593593
struct _pending_calls *pending = &runtime->ceval.pending;
594594

595595
PyThread_acquire_lock(pending->lock, WAIT_LOCK);

Python/errors.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,21 +433,27 @@ PyErr_Clear(void)
433433

434434

435435
void
436-
PyErr_GetExcInfo(PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
436+
_PyErr_GetExcInfo(PyThreadState *tstate,
437+
PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
437438
{
438-
PyThreadState *tstate = _PyThreadState_GET();
439-
440439
_PyErr_StackItem *exc_info = _PyErr_GetTopmostException(tstate);
441440
*p_type = exc_info->exc_type;
442441
*p_value = exc_info->exc_value;
443442
*p_traceback = exc_info->exc_traceback;
444443

445-
446444
Py_XINCREF(*p_type);
447445
Py_XINCREF(*p_value);
448446
Py_XINCREF(*p_traceback);
449447
}
450448

449+
450+
void
451+
PyErr_GetExcInfo(PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
452+
{
453+
PyThreadState *tstate = _PyThreadState_GET();
454+
return _PyErr_GetExcInfo(tstate, p_type, p_value, p_traceback);
455+
}
456+
451457
void
452458
PyErr_SetExcInfo(PyObject *p_type, PyObject *p_value, PyObject *p_traceback)
453459
{

Python/pylifecycle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ Py_FinalizeEx(void)
13401340
wait_for_thread_shutdown(tstate);
13411341

13421342
// Make any remaining pending calls.
1343-
_Py_FinishPendingCalls(runtime);
1343+
_Py_FinishPendingCalls(tstate);
13441344

13451345
/* The interpreter is still entirely intact at this point, and the
13461346
* exit funcs may be relying on that. In particular, if some thread

0 commit comments

Comments
 (0)