|
33 | 33 | import static com.oracle.graal.python.builtins.modules.io.IONodes.T_WRITE;
|
34 | 34 | import static com.oracle.graal.python.builtins.objects.PNone.NONE;
|
35 | 35 | import static com.oracle.graal.python.builtins.objects.PNone.NO_VALUE;
|
36 |
| -import static com.oracle.graal.python.builtins.objects.PNotImplemented.NOT_IMPLEMENTED; |
37 | 36 | import static com.oracle.graal.python.compiler.RaisePythonExceptionErrorCallback.raiseSyntaxError;
|
38 | 37 | import static com.oracle.graal.python.nodes.BuiltinNames.J_ABS;
|
39 | 38 | import static com.oracle.graal.python.nodes.BuiltinNames.J_ALL;
|
|
166 | 165 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsSameTypeNode;
|
167 | 166 | import com.oracle.graal.python.builtins.objects.type.TypeNodes.IsTypeNode;
|
168 | 167 | import com.oracle.graal.python.builtins.objects.type.slots.TpSlotIterNext.CallSlotTpIterNextNode;
|
169 |
| -import com.oracle.graal.python.lib.RichCmpOp; |
170 | 168 | import com.oracle.graal.python.compiler.Compiler;
|
171 | 169 | import com.oracle.graal.python.compiler.RaisePythonExceptionErrorCallback;
|
172 | 170 | import com.oracle.graal.python.lib.IteratorExhausted;
|
|
200 | 198 | import com.oracle.graal.python.lib.PyObjectStrAsObjectNode;
|
201 | 199 | import com.oracle.graal.python.lib.PyObjectStrAsTruffleStringNode;
|
202 | 200 | import com.oracle.graal.python.lib.PyUnicodeFSDecoderNode;
|
| 201 | +import com.oracle.graal.python.lib.RichCmpOp; |
203 | 202 | import com.oracle.graal.python.nodes.BuiltinNames;
|
204 | 203 | import com.oracle.graal.python.nodes.ErrorMessages;
|
205 | 204 | import com.oracle.graal.python.nodes.PConstructAndRaiseNode;
|
|
224 | 223 | import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
|
225 | 224 | import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
|
226 | 225 | import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
|
| 226 | +import com.oracle.graal.python.nodes.call.special.SpecialMethodNotFound; |
227 | 227 | import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
|
228 | 228 | import com.oracle.graal.python.nodes.frame.GetFrameLocalsNode;
|
229 | 229 | import com.oracle.graal.python.nodes.frame.ReadCallerFrameNode;
|
@@ -1450,11 +1450,12 @@ public IsInstanceNode createRecursive(byte newDepth) {
|
1450 | 1450 |
|
1451 | 1451 | private static TriState isInstanceCheckInternal(VirtualFrame frame, Object instance, Object cls, LookupAndCallBinaryNode instanceCheckNode,
|
1452 | 1452 | PyObjectIsTrueNode castToBooleanNode) {
|
1453 |
| - Object instanceCheckResult = instanceCheckNode.executeObject(frame, cls, instance); |
1454 |
| - if (instanceCheckResult == NOT_IMPLEMENTED) { |
| 1453 | + try { |
| 1454 | + Object instanceCheckResult = instanceCheckNode.executeObject(frame, cls, instance); |
| 1455 | + return TriState.valueOf(castToBooleanNode.execute(frame, instanceCheckResult)); |
| 1456 | + } catch (SpecialMethodNotFound ignore) { |
1455 | 1457 | return TriState.UNDEFINED;
|
1456 | 1458 | }
|
1457 |
| - return TriState.valueOf(castToBooleanNode.execute(frame, instanceCheckResult)); |
1458 | 1459 | }
|
1459 | 1460 |
|
1460 | 1461 | @Specialization(guards = "isPythonClass(cls)")
|
@@ -1508,11 +1509,12 @@ static boolean isSubclass(VirtualFrame frame, Object derived, Object cls,
|
1508 | 1509 | @Cached("create(Subclasscheck)") LookupAndCallBinaryNode subclassCheckNode,
|
1509 | 1510 | @Cached PyObjectIsTrueNode castToBooleanNode,
|
1510 | 1511 | @Cached IsSubtypeNode isSubtypeNode) {
|
1511 |
| - Object instanceCheckResult = subclassCheckNode.executeObject(frame, cls, derived); |
1512 |
| - if (instanceCheckResult != NOT_IMPLEMENTED) { |
| 1512 | + try { |
| 1513 | + Object instanceCheckResult = subclassCheckNode.executeObject(frame, cls, derived); |
1513 | 1514 | return castToBooleanNode.execute(frame, instanceCheckResult);
|
| 1515 | + } catch (SpecialMethodNotFound ignore) { |
| 1516 | + return isSubtypeNode.execute(frame, derived, cls); |
1514 | 1517 | }
|
1515 |
| - return isSubtypeNode.execute(frame, derived, cls); |
1516 | 1518 | }
|
1517 | 1519 |
|
1518 | 1520 | @NeverDefault
|
@@ -1930,14 +1932,15 @@ public static Object format(VirtualFrame frame, Object obj, Object formatSpec,
|
1930 | 1932 | @Cached InlinedConditionProfile formatIsNoValueProfile,
|
1931 | 1933 | @Cached PRaiseNode raiseNode) {
|
1932 | 1934 | Object format = formatIsNoValueProfile.profile(inliningTarget, isNoValue(formatSpec)) ? T_EMPTY_STRING : formatSpec;
|
1933 |
| - Object res = callFormat.executeObject(frame, obj, format); |
1934 |
| - if (res == NO_VALUE) { |
| 1935 | + try { |
| 1936 | + Object res = callFormat.executeObject(frame, obj, format); |
| 1937 | + if (!PGuards.isString(res)) { |
| 1938 | + throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_MUST_RETURN_S_NOT_P, T___FORMAT__, "str", res); |
| 1939 | + } |
| 1940 | + return res; |
| 1941 | + } catch (SpecialMethodNotFound ignore) { |
1935 | 1942 | throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_FORMAT, obj);
|
1936 | 1943 | }
|
1937 |
| - if (!PGuards.isString(res)) { |
1938 |
| - throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.S_MUST_RETURN_S_NOT_P, T___FORMAT__, "str", res); |
1939 |
| - } |
1940 |
| - return res; |
1941 | 1944 | }
|
1942 | 1945 |
|
1943 | 1946 | @NeverDefault
|
@@ -1980,11 +1983,11 @@ static Object round(VirtualFrame frame, Object x, Object n,
|
1980 | 1983 | @Bind("this") Node inliningTarget,
|
1981 | 1984 | @Cached("create(Round)") LookupAndCallBinaryNode callRound,
|
1982 | 1985 | @Shared @Cached PRaiseNode raiseNode) {
|
1983 |
| - Object result = callRound.executeObject(frame, x, n); |
1984 |
| - if (result == NOT_IMPLEMENTED) { |
| 1986 | + try { |
| 1987 | + return callRound.executeObject(frame, x, n); |
| 1988 | + } catch (SpecialMethodNotFound ignore) { |
1985 | 1989 | throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.TYPE_DOESNT_DEFINE_METHOD, x, T___ROUND__);
|
1986 | 1990 | }
|
1987 |
| - return result; |
1988 | 1991 | }
|
1989 | 1992 | }
|
1990 | 1993 |
|
|
0 commit comments