|
25 | 25 | */
|
26 | 26 | package com.oracle.graal.python.builtins.modules;
|
27 | 27 |
|
| 28 | +import static com.oracle.graal.python.builtins.PythonBuiltinClassType.OverflowError; |
28 | 29 | import static com.oracle.graal.python.builtins.objects.cext.NativeCAPISymbols.FUN_ADD_NATIVE_SLOTS;
|
29 | 30 | import static com.oracle.graal.python.builtins.objects.cext.NativeCAPISymbols.FUN_PY_OBJECT_GENERIC_NEW;
|
30 | 31 | import static com.oracle.graal.python.builtins.objects.slice.PSlice.MISSING_INDEX;
|
@@ -967,11 +968,16 @@ Object floatFromLong(LazyPythonClass cls, long arg) {
|
967 | 968 | }
|
968 | 969 |
|
969 | 970 | @Specialization(guards = "!isNativeClass(cls)")
|
970 |
| - Object floatFromPInt(LazyPythonClass cls, PInt arg) { |
| 971 | + Object floatFromPInt(LazyPythonClass cls, PInt arg, |
| 972 | + @Cached PRaiseNode raise) { |
| 973 | + double value = arg.doubleValue(); |
| 974 | + if (Double.isInfinite(value)) { |
| 975 | + throw raise.raise(OverflowError, "int too large to convert to float"); |
| 976 | + } |
971 | 977 | if (isPrimitiveFloat(cls)) {
|
972 |
| - return arg.doubleValue(); |
| 978 | + return value; |
973 | 979 | }
|
974 |
| - return factory().createFloat(cls, arg.doubleValue()); |
| 980 | + return factory().createFloat(cls, value); |
975 | 981 | }
|
976 | 982 |
|
977 | 983 | @Specialization(guards = "!isNativeClass(cls)")
|
@@ -2544,7 +2550,7 @@ private String mangle(String privateobj, String ident) {
|
2544 | 2550 | plen -= ipriv;
|
2545 | 2551 |
|
2546 | 2552 | if ((long) plen + nlen >= Integer.MAX_VALUE) {
|
2547 |
| - throw raise(PythonBuiltinClassType.OverflowError, "private identifier too large to be mangled"); |
| 2553 | + throw raise(OverflowError, "private identifier too large to be mangled"); |
2548 | 2554 | }
|
2549 | 2555 |
|
2550 | 2556 | /* ident = "_" + priv[ipriv:] + ident # i.e. 1+plen+nlen bytes */
|
|
0 commit comments