70
70
import com .oracle .graal .python .lib .PyObjectAsFileDescriptor ;
71
71
import com .oracle .graal .python .lib .PyObjectCallMethodObjArgs ;
72
72
import com .oracle .graal .python .lib .PyObjectDelItem ;
73
- import com .oracle .graal .python .lib .PyObjectGetAttr ;
74
73
import com .oracle .graal .python .lib .PyObjectLookupAttr ;
75
74
import com .oracle .graal .python .lib .PyObjectReprAsObjectNode ;
76
- import com .oracle .graal .python .lib .PyObjectSetAttr ;
77
75
import com .oracle .graal .python .lib .PyObjectSetItem ;
78
76
import com .oracle .graal .python .lib .PyObjectStrAsObjectNode ;
77
+ import com .oracle .graal .python .nodes .SpecialMethodNames ;
78
+ import static com .oracle .graal .python .nodes .SpecialMethodNames .__SETATTR__ ;
79
79
import com .oracle .graal .python .nodes .attributes .GetAttributeNode .GetAnyAttributeNode ;
80
80
import com .oracle .graal .python .nodes .call .CallNode ;
81
+ import com .oracle .graal .python .nodes .call .special .CallBinaryMethodNode ;
82
+ import com .oracle .graal .python .nodes .call .special .CallTernaryMethodNode ;
81
83
import com .oracle .graal .python .nodes .call .special .CallUnaryMethodNode ;
82
84
import com .oracle .graal .python .nodes .classes .IsSubtypeNode ;
83
85
import com .oracle .graal .python .nodes .expression .BinaryComparisonNode ;
@@ -481,8 +483,16 @@ Object asFileDescriptor(VirtualFrame frame, Object obj,
481
483
abstract static class PyObjectGenericGetAttrNode extends PythonBinaryBuiltinNode {
482
484
@ Specialization
483
485
Object getAttr (VirtualFrame frame , Object obj , Object attr ,
484
- @ Cached PyObjectGetAttr getAttrNode ) {
485
- return getAttrNode .execute (frame , obj , attr );
486
+ @ Cached PyObjectLookupAttr lookupSetAttrNode ,
487
+ @ Cached CallBinaryMethodNode callNode ,
488
+ @ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
489
+ try {
490
+ Object setAttrCallable = lookupSetAttrNode .execute (frame , getCore ().lookupType (PythonBuiltinClassType .PythonObject ), SpecialMethodNames .__GETATTRIBUTE__ );
491
+ return callNode .executeObject (frame , setAttrCallable , obj , attr );
492
+ } catch (PException e ) {
493
+ transformExceptionToNativeNode .execute (frame , e );
494
+ return getContext ().getNativeNull ();
495
+ }
486
496
}
487
497
}
488
498
@@ -491,10 +501,12 @@ Object getAttr(VirtualFrame frame, Object obj, Object attr,
491
501
abstract static class PyObjectGenericSetAttrNode extends PythonTernaryBuiltinNode {
492
502
@ Specialization
493
503
int setAttr (VirtualFrame frame , Object obj , Object attr , Object value ,
494
- @ Cached PyObjectSetAttr setAttrNode ,
504
+ @ Cached PyObjectLookupAttr lookupSetAttrNode ,
505
+ @ Cached CallTernaryMethodNode callNode ,
495
506
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
496
507
try {
497
- setAttrNode .execute (frame , obj , attr , value );
508
+ Object setAttrCallable = lookupSetAttrNode .execute (frame , getCore ().lookupType (PythonBuiltinClassType .PythonObject ), __SETATTR__ );
509
+ callNode .execute (frame , setAttrCallable , obj , attr , value );
498
510
return 0 ;
499
511
} catch (PException e ) {
500
512
transformExceptionToNativeNode .execute (frame , e );
0 commit comments