60
60
import static com .oracle .graal .python .nodes .BuiltinNames .T_LAST_VALUE ;
61
61
import static com .oracle .graal .python .nodes .ErrorMessages .EXCEPTION_NOT_BASEEXCEPTION ;
62
62
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__ ;
65
63
import static com .oracle .graal .python .nodes .SpecialAttributeNames .T___DOC__ ;
66
64
import static com .oracle .graal .python .nodes .SpecialAttributeNames .T___MODULE__ ;
67
65
import static com .oracle .graal .python .nodes .SpecialAttributeNames .T___TRACEBACK__ ;
@@ -553,9 +551,9 @@ abstract static class PyException_SetCause extends CApiBinaryBuiltinNode {
553
551
@ Specialization
554
552
Object setCause (Object exc , Object cause ,
555
553
@ 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 ;
559
557
}
560
558
}
561
559
@@ -564,8 +562,8 @@ abstract static class PyException_GetCause extends CApiUnaryBuiltinNode {
564
562
@ Specialization
565
563
Object getCause (Object exc ,
566
564
@ 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 ));
569
567
}
570
568
}
571
569
@@ -574,8 +572,8 @@ abstract static class PyException_GetContext extends CApiUnaryBuiltinNode {
574
572
@ Specialization
575
573
Object setCause (Object exc ,
576
574
@ 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 ));
579
577
}
580
578
}
581
579
@@ -584,9 +582,9 @@ abstract static class PyException_SetContext extends CApiBinaryBuiltinNode {
584
582
@ Specialization
585
583
Object setContext (Object exc , Object context ,
586
584
@ 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 ;
590
588
}
591
589
}
592
590
@@ -596,8 +594,8 @@ abstract static class PyException_GetTraceback extends CApiUnaryBuiltinNode {
596
594
@ Specialization
597
595
Object getTraceback (Object exc ,
598
596
@ 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 ));
601
599
}
602
600
}
603
601
0 commit comments