Skip to content

Commit f9e7216

Browse files
committed
[GR-24744] Fix PBuiltinFunction#toString not to use context
PullRequest: graalpython/1106
2 parents b1d349f + 53b6931 commit f9e7216

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PBuiltinFunction.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ public Object getEnclosingType() {
130130
@Override
131131
public String toString() {
132132
CompilerAsserts.neverPartOfCompilation();
133-
if (enclosingType == null) {
134-
return String.format("PBuiltinFunction %s at 0x%x", name, hashCode());
135-
} else {
136-
return String.format("PBuiltinFunction %s.%s at 0x%x", GetNameNode.doSlowPath(enclosingType), name, hashCode());
137-
}
133+
return String.format("PBuiltinFunction %s at 0x%x", qualname, hashCode());
138134
}
139135

140136
public PBuiltinFunction boundToObject(PythonBuiltinClassType klass, PythonObjectFactory factory) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/PythonObject.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
import com.oracle.graal.python.builtins.objects.PNone;
3434
import com.oracle.graal.python.builtins.objects.PythonAbstractObject;
3535
import com.oracle.graal.python.builtins.objects.common.PHashingCollection;
36-
import com.oracle.graal.python.builtins.objects.type.TypeNodes;
36+
import com.oracle.graal.python.builtins.objects.type.PythonManagedClass;
37+
import com.oracle.graal.python.nodes.PGuards;
3738
import com.oracle.graal.python.nodes.attributes.WriteAttributeToDynamicObjectNode;
3839
import com.oracle.truffle.api.Assumption;
3940
import com.oracle.truffle.api.CompilerAsserts;
@@ -174,7 +175,15 @@ public int compareTo(Object o) {
174175
*/
175176
@Override
176177
public String toString() {
177-
return "<" + TypeNodes.GetNameNode.doSlowPath(PythonObjectLibrary.getUncached().getLazyPythonClass(this)) + " object at 0x" + Integer.toHexString(hashCode()) + ">";
178+
String className = "unknown";
179+
if (storedPythonClass instanceof PythonManagedClass) {
180+
className = ((PythonManagedClass) storedPythonClass).getName();
181+
} else if (storedPythonClass instanceof PythonBuiltinClassType) {
182+
className = ((PythonBuiltinClassType) storedPythonClass).getName();
183+
} else if (PGuards.isNativeClass(storedPythonClass)) {
184+
className = "native";
185+
}
186+
return "<" + className + " object at 0x" + Integer.toHexString(hashCode()) + ">";
178187
}
179188

180189
@ExportMessage

0 commit comments

Comments
 (0)