40
40
*/
41
41
package com .oracle .graal .python .lib ;
42
42
43
- import static com .oracle .graal .python .nodes .SpecialAttributeNames .__MODULE__ ;
44
- import static com .oracle .graal .python .nodes .SpecialAttributeNames .__QUALNAME__ ;
43
+ import static com .oracle .graal .python .nodes .SpecialAttributeNames .__NAME__ ;
45
44
46
- import com .oracle .graal .python .builtins .objects .PNone ;
47
45
import com .oracle .graal .python .builtins .objects .str .PString ;
48
46
import com .oracle .graal .python .nodes .PNodeWithContext ;
49
47
import com .oracle .truffle .api .dsl .Cached ;
@@ -62,21 +60,22 @@ public abstract class PyObjectFunctionStr extends PNodeWithContext {
62
60
63
61
@ Specialization
64
62
String str (VirtualFrame frame , Object function ,
65
- @ Cached PyObjectLookupAttr lookupQualname ,
66
- @ Cached PyObjectLookupAttr lookupModule ,
63
+ @ Cached PyObjectLookupAttr lookupName ,
67
64
@ Cached PyObjectStrAsJavaStringNode asStr ) {
68
- Object qualname = lookupQualname .execute (frame , function , __QUALNAME__ );
69
- if (qualname == PNone .NO_VALUE ) {
70
- return asStr .execute (function );
71
- }
72
- Object module = lookupModule .execute (frame , function , __MODULE__ );
73
- if (!(module instanceof PNone )) {
74
- String moduleStr = asStr .execute (frame , module );
75
- if (!"builtins" .equals (moduleStr )) {
76
- return PString .cat (moduleStr , "." , asStr .execute (frame , qualname ), "()" );
77
- }
78
- }
79
- return PString .cat (asStr .execute (frame , qualname ), "()" );
65
+ return PString .cat (asStr .execute (lookupName .execute (frame , function , __NAME__ )), "()" );
66
+ // The following code is for 3.11
67
+ // Object qualname = lookupQualname.execute(frame, function, __QUALNAME__);
68
+ // if (qualname == PNone.NO_VALUE) {
69
+ // return asStr.execute(function);
70
+ // }
71
+ // Object module = lookupModule.execute(frame, function, __MODULE__);
72
+ // if (!(module instanceof PNone)) {
73
+ // String moduleStr = asStr.execute(frame, module);
74
+ // if (!"builtins".equals(moduleStr)) {
75
+ // return PString.cat(moduleStr, ".", asStr.execute(frame, qualname), "()");
76
+ // }
77
+ // }
78
+ // return PString.cat(asStr.execute(frame, qualname), "()");
80
79
}
81
80
82
81
public static PyObjectFunctionStr create () {
0 commit comments