40
40
*/
41
41
package com .oracle .graal .python .lib ;
42
42
43
+ import static com .oracle .graal .python .runtime .exception .PythonErrorType .AttributeError ;
44
+
43
45
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
44
46
import com .oracle .graal .python .builtins .objects .PNone ;
45
47
import com .oracle .graal .python .builtins .objects .PythonAbstractObject ;
46
48
import com .oracle .graal .python .builtins .objects .function .BuiltinMethodDescriptor ;
47
49
import com .oracle .graal .python .builtins .objects .object .ObjectBuiltinsFactory ;
48
50
import com .oracle .graal .python .builtins .objects .type .PythonManagedClass ;
49
51
import com .oracle .graal .python .builtins .objects .type .SpecialMethodSlot ;
52
+ import com .oracle .graal .python .nodes .ErrorMessages ;
53
+ import com .oracle .graal .python .nodes .PRaiseNode ;
50
54
import com .oracle .graal .python .nodes .attributes .LookupAttributeInMRONode ;
51
55
import com .oracle .graal .python .nodes .attributes .LookupCallableSlotInMRONode ;
52
56
import com .oracle .graal .python .nodes .attributes .ReadAttributeFromObjectNode ;
@@ -108,6 +112,7 @@ static Object getFixedAttr(VirtualFrame frame, Object receiver, @SuppressWarning
108
112
@ Shared ("lookupSet" ) @ Cached (parameters = "Set" ) LookupCallableSlotInMRONode lookupSet ,
109
113
@ Shared ("callGet" ) @ Cached CallTernaryMethodNode callGet ,
110
114
@ Shared ("readAttr" ) @ Cached ReadAttributeFromObjectNode readAttr ,
115
+ @ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ,
111
116
@ Cached BranchProfile hasDescr ,
112
117
@ Cached BranchProfile returnDataDescr ,
113
118
@ Cached BranchProfile returnAttr ,
@@ -146,7 +151,7 @@ static Object getFixedAttr(VirtualFrame frame, Object receiver, @SuppressWarning
146
151
returnBoundDescr .enter ();
147
152
return new BoundDescriptor (callGet .execute (frame , getMethod , descr , receiver , lazyClass ));
148
153
}
149
- return new BoundDescriptor ( descr );
154
+ throw raiseNode . raise ( AttributeError , ErrorMessages . OBJ_P_HAS_NO_ATTR_S , receiver , name );
150
155
}
151
156
152
157
// No explicit branch profiling when we're looking up multiple things
@@ -159,7 +164,8 @@ static Object getDynamicAttr(Frame frame, Object receiver, String name,
159
164
@ Shared ("lookupGet" ) @ Cached (parameters = "Get" ) LookupCallableSlotInMRONode lookupGet ,
160
165
@ Shared ("lookupSet" ) @ Cached (parameters = "Set" ) LookupCallableSlotInMRONode lookupSet ,
161
166
@ Shared ("callGet" ) @ Cached CallTernaryMethodNode callGet ,
162
- @ Shared ("readAttr" ) @ Cached ReadAttributeFromObjectNode readAttr ) {
167
+ @ Shared ("readAttr" ) @ Cached ReadAttributeFromObjectNode readAttr ,
168
+ @ Shared ("raiseNode" ) @ Cached PRaiseNode raiseNode ) {
163
169
boolean methodFound = false ;
164
170
Object descr = lookupNode .execute (lazyClass , name );
165
171
Object getMethod = null ;
@@ -185,6 +191,6 @@ static Object getDynamicAttr(Frame frame, Object receiver, String name,
185
191
if (getMethod != null ) {
186
192
return new BoundDescriptor (callGet .execute (frame , getMethod , descr , receiver , lazyClass ));
187
193
}
188
- return new BoundDescriptor ( descr );
194
+ throw raiseNode . raise ( AttributeError , ErrorMessages . OBJ_P_HAS_NO_ATTR_S , receiver , name );
189
195
}
190
196
}
0 commit comments