Skip to content

Commit 243c3f3

Browse files
committed
Fix PyException_Set* builtins with NULL argument
1 parent b4a51b3 commit 243c3f3

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextErrBuiltins.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
import static com.oracle.graal.python.nodes.BuiltinNames.T_LAST_VALUE;
6161
import static com.oracle.graal.python.nodes.ErrorMessages.EXCEPTION_NOT_BASEEXCEPTION;
6262
import static com.oracle.graal.python.nodes.ErrorMessages.MUST_BE_MODULE_CLASS;
63-
import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___CAUSE__;
64-
import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___CONTEXT__;
6563
import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___DOC__;
6664
import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___MODULE__;
6765
import static com.oracle.graal.python.nodes.SpecialAttributeNames.T___TRACEBACK__;
@@ -553,9 +551,9 @@ abstract static class PyException_SetCause extends CApiBinaryBuiltinNode {
553551
@Specialization
554552
Object setCause(Object exc, Object cause,
555553
@Bind("this") Node inliningTarget,
556-
@Cached PyObjectSetAttr setAttrNode) {
557-
setAttrNode.execute(inliningTarget, exc, T___CAUSE__, cause);
558-
return PNone.NONE;
554+
@Cached ExceptionNodes.SetCauseNode setCauseNode) {
555+
setCauseNode.execute(inliningTarget, exc, cause != PNone.NO_VALUE ? cause : PNone.NONE);
556+
return PNone.NO_VALUE;
559557
}
560558
}
561559

@@ -564,8 +562,8 @@ abstract static class PyException_GetCause extends CApiUnaryBuiltinNode {
564562
@Specialization
565563
Object getCause(Object exc,
566564
@Bind("this") Node inliningTarget,
567-
@Cached PyObjectGetAttr getAttrNode) {
568-
return noneToNativeNull(inliningTarget, getAttrNode.execute(inliningTarget, exc, T___CAUSE__));
565+
@Cached ExceptionNodes.GetCauseNode getCauseNode) {
566+
return noneToNativeNull(inliningTarget, getCauseNode.execute(inliningTarget, exc));
569567
}
570568
}
571569

@@ -574,8 +572,8 @@ abstract static class PyException_GetContext extends CApiUnaryBuiltinNode {
574572
@Specialization
575573
Object setCause(Object exc,
576574
@Bind("this") Node inliningTarget,
577-
@Cached PyObjectGetAttr getAttrNode) {
578-
return noneToNativeNull(inliningTarget, getAttrNode.execute(inliningTarget, exc, T___CONTEXT__));
575+
@Cached ExceptionNodes.GetContextNode getContextNode) {
576+
return noneToNativeNull(inliningTarget, getContextNode.execute(inliningTarget, exc));
579577
}
580578
}
581579

@@ -584,9 +582,9 @@ abstract static class PyException_SetContext extends CApiBinaryBuiltinNode {
584582
@Specialization
585583
Object setContext(Object exc, Object context,
586584
@Bind("this") Node inliningTarget,
587-
@Cached PyObjectSetAttr setAttrNode) {
588-
setAttrNode.execute(inliningTarget, exc, T___CONTEXT__, context);
589-
return PNone.NONE;
585+
@Cached ExceptionNodes.SetContextNode setContextNode) {
586+
setContextNode.execute(inliningTarget, exc, context != PNone.NO_VALUE ? context : PNone.NONE);
587+
return PNone.NO_VALUE;
590588
}
591589
}
592590

@@ -596,8 +594,8 @@ abstract static class PyException_GetTraceback extends CApiUnaryBuiltinNode {
596594
@Specialization
597595
Object getTraceback(Object exc,
598596
@Bind("this") Node inliningTarget,
599-
@Cached PyObjectGetAttr getAttrNode) {
600-
return noneToNativeNull(inliningTarget, getAttrNode.execute(inliningTarget, exc, T___TRACEBACK__));
597+
@Cached ExceptionNodes.GetTracebackNode getTracebackNode) {
598+
return noneToNativeNull(inliningTarget, getTracebackNode.execute(inliningTarget, exc));
601599
}
602600
}
603601

0 commit comments

Comments
 (0)