Skip to content

Commit 8df19be

Browse files
committed
Fix: Remove PString specialization in PyObjectStrAsJavaStringNode.
As PString subclasses can overwrite `__str__` (which is demonstrated for example in `test_unicode.py#test_format_subclass`) we need to check `__str__` for PString instances, too, and have to rely on the generic implementation for them.
1 parent 5ae7b9c commit 8df19be

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyObjectStrAsJavaStringNode.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
*/
4141
package com.oracle.graal.python.lib;
4242

43-
import com.oracle.graal.python.builtins.objects.str.PString;
4443
import com.oracle.graal.python.nodes.PNodeWithContext;
4544
import com.oracle.graal.python.nodes.util.CannotCastException;
4645
import com.oracle.graal.python.nodes.util.CastToJavaStringNode;
@@ -72,16 +71,6 @@ static String doString(String obj) {
7271
return obj;
7372
}
7473

75-
@Specialization
76-
static String doPString(PString obj,
77-
@Cached CastToJavaStringNode castToString) {
78-
try {
79-
return castToString.execute(obj);
80-
} catch (CannotCastException e) {
81-
throw CompilerDirectives.shouldNotReachHere("PString result not convertible to string");
82-
}
83-
}
84-
8574
@Specialization
8675
static String doGeneric(VirtualFrame frame, Object obj,
8776
@Cached PyObjectStrAsObjectNode strNode,

0 commit comments

Comments
 (0)