@@ -222,15 +222,20 @@ Object getName(VirtualFrame frame, PMethod method,
222
222
public abstract static class MethodQualName extends PythonUnaryBuiltinNode {
223
223
@ Specialization (limit = "3" )
224
224
Object getQualName (VirtualFrame frame , PMethod method ,
225
- @ Cached ("create(__QUALNAME__)" ) GetAttributeNode getQualNameAttrNode ,
226
225
@ Cached ("create(__NAME__)" ) GetAttributeNode getNameAttrNode ,
226
+ @ Cached ("create(__QUALNAME__)" ) GetAttributeNode getQualNameAttrNode ,
227
227
@ Cached TypeNodes .IsTypeNode isTypeNode ,
228
228
@ Cached CastToJavaStringNode castToJavaStringNode ,
229
229
@ CachedLibrary ("method.getSelf()" ) PythonObjectLibrary pol ) {
230
230
Object self = method .getSelf ();
231
- String selfName = castToJavaStringNode .execute (getNameAttrNode .executeObject (frame , self ));
232
- if (self instanceof PythonModule ) {
233
- return selfName ;
231
+ String methodName ;
232
+ try {
233
+ methodName = castToJavaStringNode .execute (getNameAttrNode .executeObject (frame , method ));
234
+ } catch (CannotCastException e ) {
235
+ throw raise (PythonBuiltinClassType .TypeError , ErrorMessages .IS_NOT_A , __NAME__ , "unicode object" );
236
+ }
237
+ if (self == null || self instanceof PythonModule ) {
238
+ return methodName ;
234
239
}
235
240
236
241
Object type = isTypeNode .execute (self ) ? self : pol .getLazyPythonClass (self );
@@ -241,7 +246,7 @@ Object getQualName(VirtualFrame frame, PMethod method,
241
246
throw raise (PythonBuiltinClassType .TypeError , ErrorMessages .IS_NOT_A , __QUALNAME__ , "unicode object" );
242
247
}
243
248
244
- return getQualNameGeneric (typeQualName , selfName );
249
+ return getQualNameGeneric (typeQualName , methodName );
245
250
}
246
251
247
252
@ TruffleBoundary
0 commit comments