|
83 | 83 | import com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.CApiUnaryBuiltinNode; |
84 | 84 | import com.oracle.graal.python.builtins.modules.cext.PythonCextFileBuiltins.PyFile_WriteObject; |
85 | 85 | import com.oracle.graal.python.builtins.objects.PNone; |
| 86 | +import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.ExceptionState; |
86 | 87 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PyErrFetchNode; |
87 | 88 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PyErrOccurredNode; |
88 | 89 | import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.NativeToPythonNode; |
@@ -203,28 +204,26 @@ static Object doGeneric(Object pType, Object pValue, Object pTraceback, |
203 | 204 | @Cached PythonToNativeNewRefNode toNativeNewRefNode, |
204 | 205 | @Cached CStructAccess.WritePointerNode writePointerNode) { |
205 | 206 | PythonContext.PythonThreadState threadState = getThreadStateNode.execute(inliningTarget); |
206 | | - Object[] exceptionState = pyErrFetchNode.execute(inliningTarget, threadState); |
207 | | - // null or [type, value, traceback] |
208 | | - assert exceptionState == null || exceptionState.length == 3; |
| 207 | + ExceptionState exceptionState = pyErrFetchNode.execute(inliningTarget, threadState); |
209 | 208 | if (exceptionState == null) { |
210 | 209 | /* |
211 | 210 | * This should be caught in native by checking 'PyErr_Occurred' and avoiding the |
212 | 211 | * upcall. But let's be defensive and treat that case on a slow path. |
213 | 212 | */ |
214 | 213 | doNoException(pType, pValue, pTraceback); |
215 | 214 | } else { |
216 | | - assert exceptionState[0] != null; |
217 | | - assert exceptionState[1] != null; |
| 215 | + assert exceptionState.type() != null; |
| 216 | + assert exceptionState.value() != null; |
218 | 217 | /* |
219 | 218 | * NOTE: We cannot use 'WriteObjectNewRefNode' because we are writing to out |
220 | 219 | * variables (C type 'PyObject **out') where the previous value (i.e. '*out') of |
221 | 220 | * those is unspecified. 'WriteObjectNewRefNode' would try to decref the previous |
222 | 221 | * object and we MUST NOT do that. Therefore, we use the combination of |
223 | 222 | * 'WritePointerNode' and 'PythonToNativeNewRefNode'. |
224 | 223 | */ |
225 | | - writePointerNode.write(pType, toNativeNewRefNode.execute(exceptionState[0])); |
226 | | - writePointerNode.write(pValue, toNativeNewRefNode.execute(exceptionState[1])); |
227 | | - writePointerNode.write(pTraceback, toNativeNewRefNode.execute(exceptionState[2] != null ? exceptionState[2] : PNone.NO_VALUE)); |
| 224 | + writePointerNode.write(pType, toNativeNewRefNode.execute(exceptionState.type())); |
| 225 | + writePointerNode.write(pValue, toNativeNewRefNode.execute(exceptionState.value())); |
| 226 | + writePointerNode.write(pTraceback, toNativeNewRefNode.execute(exceptionState.traceback() != null ? exceptionState.traceback() : PNone.NO_VALUE)); |
228 | 227 | } |
229 | 228 | return PNone.NO_VALUE; |
230 | 229 | } |
@@ -460,17 +459,15 @@ static Object raise(int set_sys_last_vars, |
460 | 459 | if (err != nativeNull && IsBuiltinObjectProfile.profileObjectUncached(err, PythonBuiltinClassType.SystemExit)) { |
461 | 460 | handleSystemExit(excInfoNode, getItemNode, isInstanceNode, restoreNode, (SysModuleBuiltins) sys.getBuiltins(), writeFileNode, exitNode); |
462 | 461 | } |
463 | | - Object[] fetched = PyErrFetchNode.executeUncached(threadState); |
464 | | - // null or [type, value, traceback] |
465 | | - assert fetched == null || fetched.length == 3; |
| 462 | + ExceptionState fetched = PyErrFetchNode.executeUncached(threadState); |
466 | 463 | Object type = null; |
467 | 464 | Object val = null; |
468 | 465 | Object tb = null; |
469 | 466 |
|
470 | 467 | if (fetched != null) { |
471 | | - type = fetched[0]; |
472 | | - val = fetched[1]; |
473 | | - tb = fetched[2]; |
| 468 | + type = fetched.type(); |
| 469 | + val = fetched.value(); |
| 470 | + tb = fetched.traceback(); |
474 | 471 | } |
475 | 472 | if (type == null || type == PNone.NONE) { |
476 | 473 | return PNone.NONE; |
|
0 commit comments