17
17
import com .oracle .graal .python .nodes .ErrorMessages ;
18
18
import com .oracle .graal .python .nodes .PGuards ;
19
19
import com .oracle .graal .python .nodes .PRaiseNode ;
20
+ import com .oracle .graal .python .runtime .PythonContext ;
20
21
import com .oracle .graal .python .runtime .formatting .ErrorMessageFormatter ;
21
22
import com .oracle .graal .python .runtime .object .PythonObjectFactory ;
22
23
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
@@ -40,8 +41,8 @@ private static Object noValueToNone(Object obj) {
40
41
return obj != PNone .NO_VALUE ? obj : PNone .NONE ;
41
42
}
42
43
43
- private static Object noneToNoValue ( Object obj ) {
44
- return obj != PNone .NONE ? obj : PNone . NO_VALUE ;
44
+ private static Object noneToNativeNull ( Node node , Object obj ) {
45
+ return obj != PNone .NONE ? obj : PythonContext . get ( node ). getNativeNull () ;
45
46
}
46
47
47
48
@ GenerateUncached
@@ -97,12 +98,12 @@ static void doManaged(PBaseException exception, Object value) {
97
98
}
98
99
99
100
@ Specialization (guards = "check.execute(inliningTarget, exception)" )
100
- static void doNative (@ SuppressWarnings ( "unused" ) Node inliningTarget , PythonAbstractNativeObject exception , Object value ,
101
+ static void doNative (Node inliningTarget , PythonAbstractNativeObject exception , Object value ,
101
102
@ SuppressWarnings ("unused" ) @ Cached PyExceptionInstanceCheckNode check ,
102
103
@ Cached CApiTransitions .PythonToNativeNode excToNative ,
103
104
@ Cached CApiTransitions .PythonToNativeNode valueToNative ,
104
105
@ Cached CExtNodes .PCallCapiFunction callSetter ) {
105
- callSetter .call (NativeMember .CAUSE .getSetterFunctionName (), excToNative .execute (exception ), valueToNative .execute (noneToNoValue ( value )));
106
+ callSetter .call (NativeMember .CAUSE .getSetterFunctionName (), excToNative .execute (exception ), valueToNative .execute (noneToNativeNull ( inliningTarget , value )));
106
107
}
107
108
108
109
@ Specialization
@@ -156,21 +157,21 @@ public static void executeUncached(Object e, Object value) {
156
157
157
158
@ Specialization (guards = "isNone(value)" )
158
159
static void doManaged (PBaseException exception , @ SuppressWarnings ("unused" ) PNone value ) {
159
- exception .setCause (null );
160
+ exception .setContext (null );
160
161
}
161
162
162
163
@ Specialization (guards = "!isNone(value)" )
163
164
static void doManaged (PBaseException exception , Object value ) {
164
- exception .setCause (value );
165
+ exception .setContext (value );
165
166
}
166
167
167
168
@ Specialization (guards = "check.execute(inliningTarget, exception)" )
168
- static void doNative (@ SuppressWarnings ( "unused" ) Node inliningTarget , PythonAbstractNativeObject exception , Object value ,
169
+ static void doNative (Node inliningTarget , PythonAbstractNativeObject exception , Object value ,
169
170
@ SuppressWarnings ("unused" ) @ Cached PyExceptionInstanceCheckNode check ,
170
171
@ Cached CApiTransitions .PythonToNativeNode excToNative ,
171
172
@ Cached CApiTransitions .PythonToNativeNode valueToNative ,
172
173
@ Cached CExtNodes .PCallCapiFunction callSetter ) {
173
- callSetter .call (NativeMember .CONTEXT .getSetterFunctionName (), excToNative .execute (exception ), valueToNative .execute (noneToNoValue ( value )));
174
+ callSetter .call (NativeMember .CONTEXT .getSetterFunctionName (), excToNative .execute (exception ), valueToNative .execute (noneToNativeNull ( inliningTarget , value )));
174
175
}
175
176
176
177
@ Specialization
@@ -196,11 +197,11 @@ static boolean doManaged(PBaseException exception) {
196
197
}
197
198
198
199
@ Specialization (guards = "check.execute(inliningTarget, exception)" )
199
- static boolean doNative (@ SuppressWarnings ( "unused" ) Node inliningTarget , PythonAbstractNativeObject exception ,
200
+ static boolean doNative (Node inliningTarget , PythonAbstractNativeObject exception ,
200
201
@ SuppressWarnings ("unused" ) @ Cached PyExceptionInstanceCheckNode check ,
201
202
@ Cached CApiTransitions .PythonToNativeNode toNative ,
202
203
@ Cached CExtNodes .PCallCapiFunction callGetter ) {
203
- return (byte ) callGetter .call (NativeMember .SUPPRESS_CONTEXT .getGetterFunctionName (), toNative .execute (noneToNoValue ( exception ))) != 0 ;
204
+ return (byte ) callGetter .call (NativeMember .SUPPRESS_CONTEXT .getGetterFunctionName (), toNative .execute (noneToNativeNull ( inliningTarget , exception ))) != 0 ;
204
205
}
205
206
206
207
@ Specialization
@@ -301,12 +302,12 @@ static void doManaged(PBaseException exception, PTraceback value) {
301
302
}
302
303
303
304
@ Specialization (guards = "check.execute(inliningTarget, exception)" )
304
- static void doNative (@ SuppressWarnings ( "unused" ) Node inliningTarget , PythonAbstractNativeObject exception , Object value ,
305
+ static void doNative (Node inliningTarget , PythonAbstractNativeObject exception , Object value ,
305
306
@ SuppressWarnings ("unused" ) @ Cached PyExceptionInstanceCheckNode check ,
306
307
@ Cached CApiTransitions .PythonToNativeNode excToNative ,
307
308
@ Cached CApiTransitions .PythonToNativeNode valueToNative ,
308
309
@ Cached CExtNodes .PCallCapiFunction callSetter ) {
309
- callSetter .call (NativeMember .TRACEBACK .getSetterFunctionName (), excToNative .execute (exception ), valueToNative .execute (noneToNoValue ( value )));
310
+ callSetter .call (NativeMember .TRACEBACK .getSetterFunctionName (), excToNative .execute (exception ), valueToNative .execute (noneToNativeNull ( inliningTarget , value )));
310
311
}
311
312
312
313
@ Specialization
0 commit comments