Skip to content

Commit e30a2e0

Browse files
committed
Call __index__ from asJavaLong
1 parent a0ab80a commit e30a2e0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,9 +1148,12 @@ public long asJavaLongWithState(ThreadState state,
11481148

11491149
assert !MathGuards.isNumber(this) : this.getClass().getSimpleName();
11501150

1151-
Object func = lib.lookupAttributeOnType(this, __INT__);
1151+
Object func = lib.lookupAttributeOnType(this, __INDEX__);
11521152
if (func == PNone.NO_VALUE) {
1153-
throw raise.raise(TypeError, ErrorMessages.MUST_BE_NUMERIC, this);
1153+
func = lib.lookupAttributeOnType(this, __INT__);
1154+
if (func == PNone.NO_VALUE) {
1155+
throw raise.raise(TypeError, ErrorMessages.MUST_BE_NUMERIC, this);
1156+
}
11541157
}
11551158
Object result = methodLib.callUnboundMethodWithState(func, state, this);
11561159
try {

0 commit comments

Comments
 (0)