[pypy-commit] pypy default: check for no args in result_type
bdkearns
noreply at buildbot.pypy.org
Thu Oct 9 19:39:47 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r73866:83d8f679414d
Date: 2014-10-09 13:39 -0400
http://bitbucket.org/pypy/pypy/changeset/83d8f679414d/
Log: check for no args in result_type
diff --git a/pypy/module/micronumpy/arrayops.py b/pypy/module/micronumpy/arrayops.py
--- a/pypy/module/micronumpy/arrayops.py
+++ b/pypy/module/micronumpy/arrayops.py
@@ -292,6 +292,8 @@
args_w, kw_w = __args__.unpack()
if kw_w:
raise oefmt(space.w_TypeError, "result_type() takes no keyword arguments")
+ if not args_w:
+ raise oefmt(space.w_ValueError, "at least one array or dtype is required")
result = None
for w_arg in args_w:
if isinstance(w_arg, W_NDimArray):
diff --git a/pypy/module/micronumpy/test/test_arrayops.py b/pypy/module/micronumpy/test/test_arrayops.py
--- a/pypy/module/micronumpy/test/test_arrayops.py
+++ b/pypy/module/micronumpy/test/test_arrayops.py
@@ -202,6 +202,8 @@
def test_result_type(self):
import numpy as np
+ exc = raises(ValueError, np.result_type)
+ assert str(exc.value) == "at least one array or dtype is required"
exc = raises(TypeError, np.result_type, a=2)
assert str(exc.value) == "result_type() takes no keyword arguments"
assert np.result_type(True) is np.dtype('bool')
More information about the pypy-commit
mailing list