Skip to content

Commit a5ab825

Browse files
committed
Allow 'NotImplemented' to be returned in a subscript operation.
1 parent 0ff7d28 commit a5ab825

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallBinaryNode.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -270,20 +270,14 @@ boolean callBoolean(double left, double right,
270270
Object callObject(Object left, Object right,
271271
@Cached("create(name)") LookupInheritedAttributeNode getattr) {
272272
Object leftCallable = getattr.execute(left);
273-
Object result;
274273
if (leftCallable == PNone.NO_VALUE) {
275-
result = PNotImplemented.NOT_IMPLEMENTED;
276-
} else {
277-
result = ensureDispatch().executeObject(leftCallable, left, right);
278-
}
279-
if (handlerFactory != null && result == PNotImplemented.NOT_IMPLEMENTED) {
280-
if (handler == null) {
281-
CompilerDirectives.transferToInterpreterAndInvalidate();
282-
handler = insert(handlerFactory.get());
274+
if (handlerFactory != null) {
275+
return runErrorHandler(left, right);
276+
} else {
277+
return PNotImplemented.NOT_IMPLEMENTED;
283278
}
284-
return handler.execute(left, right);
285279
}
286-
return result;
280+
return ensureDispatch().executeObject(leftCallable, left, right);
287281
}
288282

289283
@Specialization(guards = "isReversible()")
@@ -319,12 +313,16 @@ Object callObject(Object left, Object right,
319313
result = ensureReverseDispatch().executeObject(rightCallable, right, left);
320314
}
321315
if (handlerFactory != null && result == PNotImplemented.NOT_IMPLEMENTED) {
322-
if (handler == null) {
323-
CompilerDirectives.transferToInterpreterAndInvalidate();
324-
handler = insert(handlerFactory.get());
325-
}
326-
return handler.execute(left, right);
316+
return runErrorHandler(left, right);
327317
}
328318
return result;
329319
}
320+
321+
private Object runErrorHandler(Object left, Object right) {
322+
if (handler == null) {
323+
CompilerDirectives.transferToInterpreterAndInvalidate();
324+
handler = insert(handlerFactory.get());
325+
}
326+
return handler.execute(left, right);
327+
}
330328
}

0 commit comments

Comments
 (0)