@@ -40,10 +40,9 @@ _PyErr_FormatV(PyThreadState *tstate, PyObject *exception,
40
40
void
41
41
_PyErr_SetRaisedException (PyThreadState * tstate , PyObject * exc )
42
42
{
43
- // GraalPy change
44
- // PyObject *old_exc = tstate->current_exception;
43
+ PyObject * old_exc = tstate -> current_exception ;
45
44
tstate -> current_exception = exc ;
46
- // Py_XDECREF(old_exc);
45
+ Py_XDECREF (old_exc );
47
46
}
48
47
49
48
static PyObject *
@@ -80,13 +79,13 @@ _PyErr_Restore(PyThreadState *tstate, PyObject *type, PyObject *value,
80
79
assert (value == NULL );
81
80
assert (traceback == NULL );
82
81
_PyErr_SetRaisedException (tstate , NULL );
83
- // return;
82
+ return ;
84
83
}
85
- #if 0 // GraalPy change
86
84
assert (PyExceptionClass_Check (type ));
87
85
if (value != NULL && type == (PyObject * )Py_TYPE (value )) {
88
86
/* Already normalized */
89
- assert (((PyBaseExceptionObject * )value )-> traceback != Py_None );
87
+ // GraalPy change
88
+ // assert(((PyBaseExceptionObject *)value)->traceback != Py_None);
90
89
}
91
90
else {
92
91
PyObject * exc = _PyErr_CreateException (type , value );
@@ -112,24 +111,20 @@ _PyErr_Restore(PyThreadState *tstate, PyObject *type, PyObject *value,
112
111
return ;
113
112
}
114
113
}
115
- PyObject * old_traceback = ((PyBaseExceptionObject * )value )-> traceback ;
116
- ((PyBaseExceptionObject * )value )-> traceback = traceback ;
117
- Py_XDECREF (old_traceback );
114
+ // GraalPy change: upcall for setting the traceback
115
+ GraalPyTruffleErr_SetTraceback (value , traceback );
116
+ // GraalPy change: the traceback is now owned by the managed side
117
+ Py_XDECREF (traceback );
118
118
_PyErr_SetRaisedException (tstate , value );
119
119
Py_DECREF (type );
120
- #else // GraalPy change: different implementation
121
- PyErr_Restore (type , value , traceback );
122
- #endif // GraalPy change
123
120
}
124
121
125
- #if 0 // GraalPy change
126
122
void
127
123
PyErr_Restore (PyObject * type , PyObject * value , PyObject * traceback )
128
124
{
129
125
PyThreadState * tstate = _PyThreadState_GET ();
130
126
_PyErr_Restore (tstate , type , value , traceback );
131
127
}
132
- #endif // GraalPy change
133
128
134
129
void
135
130
PyErr_SetRaisedException (PyObject * exc )
@@ -138,15 +133,7 @@ PyErr_SetRaisedException(PyObject *exc)
138
133
_PyErr_SetRaisedException (tstate , exc );
139
134
}
140
135
141
-
142
136
#if 0 // GraalPy change
143
- void
144
- PyErr_Restore (PyObject * type , PyObject * value , PyObject * traceback )
145
- {
146
- PyThreadState * tstate = _PyThreadState_GET ();
147
- _PyErr_Restore (tstate , type , value , traceback );
148
- }
149
-
150
137
_PyErr_StackItem *
151
138
_PyErr_GetTopmostException (PyThreadState * tstate )
152
139
{
@@ -160,7 +147,6 @@ _PyErr_GetTopmostException(PyThreadState *tstate)
160
147
}
161
148
return exc_info ;
162
149
}
163
- #endif // GraalPy change
164
150
165
151
static PyObject *
166
152
get_normalization_failure_note (PyThreadState * tstate , PyObject * exception , PyObject * value )
@@ -183,6 +169,7 @@ get_normalization_failure_note(PyThreadState *tstate, PyObject *exception, PyObj
183
169
}
184
170
return note ;
185
171
}
172
+ #endif // GraalPy change
186
173
187
174
void
188
175
_PyErr_SetObject (PyThreadState * tstate , PyObject * exception , PyObject * value )
537
524
_PyErr_Fetch (PyThreadState * tstate , PyObject * * p_type , PyObject * * p_value ,
538
525
PyObject * * p_traceback )
539
526
{
540
- #if 0 // GraalPy change
541
527
PyObject * exc = _PyErr_GetRaisedException (tstate );
542
528
* p_value = exc ;
543
529
if (exc == NULL ) {
@@ -546,18 +532,9 @@ _PyErr_Fetch(PyThreadState *tstate, PyObject **p_type, PyObject **p_value,
546
532
}
547
533
else {
548
534
* p_type = Py_NewRef (Py_TYPE (exc ));
549
- * p_traceback = Py_XNewRef (((PyBaseExceptionObject * )exc )-> traceback );
535
+ // GraalPy change: upcall to get the traceback
536
+ * p_traceback = PyException_GetTraceback (* p_value );
550
537
}
551
- #else // GraalPy change: different implementation
552
- if (_PyErr_Occurred (tstate )) {
553
- // avoid the upcall if there is no current exception
554
- GraalPyTruffleErr_Fetch (p_type , p_value , p_traceback );
555
- } else {
556
- * p_type = NULL ;
557
- * p_value = NULL ;
558
- * p_traceback = NULL ;
559
- }
560
- #endif // GraalPy change
561
538
}
562
539
563
540
@@ -690,6 +667,7 @@ _PyErr_StackItemToExcInfoTuple(_PyErr_StackItem *err_info)
690
667
exc_value ? exc_value : Py_None ,
691
668
exc_traceback ? exc_traceback : Py_None );
692
669
}
670
+ #endif // GraalPy change
693
671
694
672
695
673
/* Like PyErr_Restore(), but if an exception is already set,
@@ -751,6 +729,7 @@ _PyErr_ChainExceptions1(PyObject *exc)
751
729
}
752
730
}
753
731
732
+ #if 0 // GraalPy change
754
733
/* Set the currently set exception's context to the given exception.
755
734
756
735
If the provided exc_info is NULL, then the current Python thread state's
0 commit comments