Skip to content

Commit 61dbcbf

Browse files
committed
Readd print handling into PyNumberRshift
1 parent d0c1e3f commit 61dbcbf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

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

43+
import static com.oracle.graal.python.nodes.BuiltinNames.T_PRINT;
44+
import static com.oracle.graal.python.util.PythonUtils.TS_ENCODING;
45+
4346
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
4447
import com.oracle.graal.python.builtins.objects.PNotImplemented;
48+
import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod;
4549
import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
4650
import com.oracle.graal.python.builtins.objects.type.slots.TpSlot;
4751
import com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpSlot;
4852
import com.oracle.graal.python.nodes.ErrorMessages;
53+
import com.oracle.graal.python.nodes.PRaiseNode;
4954
import com.oracle.graal.python.nodes.PRaiseNode.Lazy;
5055
import com.oracle.graal.python.nodes.expression.BinaryOpNode;
5156
import com.oracle.graal.python.nodes.object.GetClassNode;
5257
import com.oracle.graal.python.runtime.exception.PException;
58+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
5359
import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
5460
import com.oracle.truffle.api.dsl.Cached;
5561
import com.oracle.truffle.api.dsl.Fallback;
@@ -108,9 +114,19 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, Object v, Object w,
108114

109115
@InliningCutoff
110116
private static PException raiseNotSupported(Node inliningTarget, Object v, Object w, Lazy raiseNode) {
117+
if (v instanceof PBuiltinMethod) {
118+
handlePossiblePrint(inliningTarget, v, w);
119+
}
111120
return raiseNode.get(inliningTarget).raise(PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P, ">>", v, w);
112121
}
113122

123+
@TruffleBoundary
124+
private static void handlePossiblePrint(Node inliningTarget, Object v, Object w) {
125+
if (v instanceof PBuiltinMethod method && method.getBuiltinFunction().getName().equalsUncached(T_PRINT, TS_ENCODING)) {
126+
throw PRaiseNode.raiseUncached(inliningTarget, PythonBuiltinClassType.TypeError, ErrorMessages.UNSUPPORTED_OPERAND_TYPES_FOR_S_P_AND_P_PRINT, ">>", v, w);
127+
}
128+
}
129+
114130
@NeverDefault
115131
public static PyNumberRshiftNode create() {
116132
return PyNumberRshiftNodeGen.create();

0 commit comments

Comments
 (0)