Skip to content

Commit f42a79e

Browse files
committed
Check kwargs in math.hypot
1 parent ed65249 commit f42a79e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
import com.oracle.graal.python.builtins.Builtin;
4141
import com.oracle.graal.python.builtins.CoreFunctions;
42+
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
4243
import com.oracle.graal.python.builtins.PythonBuiltins;
4344
import com.oracle.graal.python.builtins.objects.PNone;
4445
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
@@ -1984,9 +1985,12 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments,
19841985
}
19851986

19861987
@Specialization(guards = "arguments.length == 2")
1987-
public double hypot2(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords,
1988+
public double hypot2(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, PKeyword[] keywords,
19881989
@Cached("create()") CastToDoubleNode xCastNode,
19891990
@Cached("create()") CastToDoubleNode yCastNode) {
1991+
if (keywords.length != 0) {
1992+
throw raise(PythonBuiltinClassType.TypeError, "hypot() takes no keyword arguments");
1993+
}
19901994
double x = xCastNode.execute(frame, arguments[0]);
19911995
double y = yCastNode.execute(frame, arguments[1]);
19921996
double result = Math.hypot(x, y);
@@ -1997,8 +2001,11 @@ public double hypot2(VirtualFrame frame, @SuppressWarnings("unused") Object self
19972001
}
19982002

19992003
@Specialization
2000-
public double hypotGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords,
2004+
public double hypotGeneric(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] arguments, PKeyword[] keywords,
20012005
@Cached("create()") CastToDoubleNode castNode) {
2006+
if (keywords.length != 0) {
2007+
throw raise(PythonBuiltinClassType.TypeError, "hypot() takes no keyword arguments");
2008+
}
20022009
double max = 0.0;
20032010
boolean foundNan = false;
20042011
double[] coordinates = new double[arguments.length];

0 commit comments

Comments
 (0)