File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -92,8 +92,13 @@ static void
9292sync_module_capture_exc (PyThreadState * tstate , struct sync_module * data )
9393{
9494 assert (_PyErr_Occurred (tstate ));
95- data -> cached .failed = _PyErr_GetRaisedException (tstate );
96- _PyErr_SetRaisedException (tstate , Py_NewRef (data -> cached .failed ));
95+ PyObject * context = data -> cached .failed ;
96+ PyObject * exc = _PyErr_GetRaisedException (tstate );
97+ _PyErr_SetRaisedException (tstate , Py_NewRef (exc ));
98+ if (context != NULL ) {
99+ PyException_SetContext (exc , context );
100+ }
101+ data -> cached .failed = exc ;
97102}
98103
99104
@@ -667,7 +672,7 @@ _PyPickle_Loads(struct _unpickle_context *ctx, PyObject *pickled)
667672
668673finally :
669674 if (exc != NULL ) {
670- ctx -> main . cached . failed = _PyErr_GetRaisedException ( tstate );
675+ sync_module_capture_exc ( tstate , & ctx -> main );
671676 // We restore the original exception.
672677 // It might make sense to chain it (__context__).
673678 _PyErr_SetRaisedException (tstate , exc );
You can’t perform that action at this time.
0 commit comments