Skip to content

Commit 343ca2f

Browse files
committed
Raise OverflowError in complex.__abs__
1 parent b6e064d commit 343ca2f

File tree

1 file changed

+5
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex

1 file changed

+5
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ public abstract static class AbsNode extends PythonUnaryBuiltinNode {
135135
final double scaledH = Math.sqrt(scaledX * scaledX + scaledY * scaledY);
136136

137137
// remove scaling
138-
return scalb(scaledH, middleExp);
138+
double r = scalb(scaledH, middleExp);
139+
if (Double.isInfinite(r)) {
140+
throw raise(PythonErrorType.OverflowError, ErrorMessages.ABSOLUTE_VALUE_TOO_LARGE);
141+
}
142+
return r;
139143
}
140144
}
141145
}

0 commit comments

Comments
 (0)