Skip to content

Commit 7c7a9b6

Browse files
committed
rename raiseIndexError to reflect what it does
1 parent 8ababfd commit 7c7a9b6

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PythonCextBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,7 +1957,7 @@ PBytes doLongOvf(long size,
19571957
try {
19581958
return doInt(PInt.intValueExact(size));
19591959
} catch (ArithmeticException e) {
1960-
throw raiseNode.raiseIndexError(IndexError, size);
1960+
throw raiseNode.raiseNumberTooLarge(IndexError, size);
19611961
}
19621962
}
19631963

@@ -1972,7 +1972,7 @@ PBytes doPIntOvf(PInt size,
19721972
try {
19731973
return doInt(size.intValueExact());
19741974
} catch (ArithmeticException e) {
1975-
throw raiseNode.raiseIndexError(IndexError, size);
1975+
throw raiseNode.raiseNumberTooLarge(IndexError, size);
19761976
}
19771977
}
19781978
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ public int asIndexWithState(LazyPythonClass type, ThreadState state,
745745
} catch (ArithmeticException e) {
746746
overflow.enter();
747747
if (ignoreOverflow.profile(type != null)) {
748-
throw raise.raiseIndexError(type, result);
748+
throw raise.raiseNumberTooLarge(type, result);
749749
} else {
750750
// If no error-handling desired then the default clipping is done as in CPython.
751751
if (longResult < 0) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/IndexNodes.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ int doLongOvf(long index, int length, String errorMessage,
213213
try {
214214
return doLong(index, length, errorMessage, negativeIndexProfile, boundsCheckNode);
215215
} catch (ArithmeticException e) {
216-
throw raiseNode.raiseIndexError(PythonBuiltinClassType.IndexError, index);
216+
throw raiseNode.raiseNumberTooLarge(PythonBuiltinClassType.IndexError, index);
217217
}
218218
}
219219

@@ -233,7 +233,7 @@ int doPIntOvf(PInt index, int length, String errorMessage,
233233
try {
234234
return doPInt(index, length, errorMessage, negativeIndexProfile, boundsCheckNode);
235235
} catch (ArithmeticException e) {
236-
throw raiseNode.raiseIndexError(PythonBuiltinClassType.IndexError, index);
236+
throw raiseNode.raiseNumberTooLarge(PythonBuiltinClassType.IndexError, index);
237237
}
238238
}
239239

@@ -272,7 +272,7 @@ int doLongOvf(long index, int length, String errorMessage,
272272
try {
273273
return doLong(index, length, errorMessage, negativeIndexProfile);
274274
} catch (ArithmeticException e) {
275-
throw raiseNode.raiseIndexError(PythonBuiltinClassType.IndexError, index);
275+
throw raiseNode.raiseNumberTooLarge(PythonBuiltinClassType.IndexError, index);
276276
}
277277
}
278278

@@ -290,7 +290,7 @@ int doPIntOvf(PInt index, int length, String errorMessage,
290290
try {
291291
return doPInt(index, length, errorMessage, negativeIndexProfile);
292292
} catch (ArithmeticException e) {
293-
throw raiseNode.raiseIndexError(PythonBuiltinClassType.IndexError, index);
293+
throw raiseNode.raiseNumberTooLarge(PythonBuiltinClassType.IndexError, index);
294294
}
295295
}
296296
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/DefaultPythonLongExports.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int withOverflow(Long self, LazyPythonClass type,
7474
try {
7575
return PInt.intValueExact(self);
7676
} catch (ArithmeticException e) {
77-
throw raise.raiseIndexError(type, self);
77+
throw raise.raiseNumberTooLarge(type, self);
7878
}
7979
}
8080
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRaiseNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ public final PException raise(PythonBuiltinClassType type, Exception e) {
7676
throw execute(type, PNone.NO_VALUE, getMessage(e), new Object[0]);
7777
}
7878

79-
public final PException raiseIndexError(LazyPythonClass type, Object result) {
79+
/**
80+
* Raise an error saying that the {@code result} cannot fit into an
81+
* index-sized integer. Use the specified {@code type} as exception class.
82+
*/
83+
public final PException raiseNumberTooLarge(LazyPythonClass type, Object result) {
8084
return execute(type, PNone.NO_VALUE, "cannot fit '%p' into an index-sized integer", new Object[] { result });
8185
}
8286

0 commit comments

Comments
 (0)