Skip to content

Commit 24d93b9

Browse files
committed
fix __repr__ for PNone, handle ...at 0xabcd> in unit test output
1 parent 463562b commit 24d93b9

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/PythonTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public static void assertPrints(String expected, String code) {
169169
String source = code;
170170
PythonTests.runScript(new String[0], source, printStream, System.err);
171171
String result = byteArray.toString().replaceAll("\r\n", "\n");
172-
assertEquals(expected, result);
172+
assertEquals(expected.replaceAll(" at 0x[0-9a-f]*>", " at 0xabcd>"), result.replaceAll(" at 0x[0-9a-f]*>", " at 0xabcd>"));
173173
}
174174

175175
public static VirtualFrame createVirtualFrame() {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ public abstract static class ReprNode extends PythonUnaryBuiltinNode {
175175
@TruffleBoundary
176176
Object repr(Object self,
177177
@Cached("create()") GetClassNode getClass) {
178+
if (self == PNone.NONE) {
179+
return "None";
180+
}
178181
return String.format("<%s object at 0x%x>", getClass.execute(self).getName(), self.hashCode());
179182
}
180183
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetClassNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,6 @@ public static String getNameSlowPath(Object o) {
207207
if (PGuards.isForeignObject(o)) {
208208
return BuiltinNames.FOREIGN;
209209
}
210-
return PythonBuiltinClassType.fromClass(o.getClass()).name();
210+
return PythonBuiltinClassType.fromClass(o.getClass()).toString();
211211
}
212212
}

0 commit comments

Comments
 (0)