summaryrefslogtreecommitdiff
path: root/numpy/core/records.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2019-01-19 16:25:07 -0700
committerGitHub <noreply@github.com>2019-01-19 16:25:07 -0700
commit749f6c475979489049c4207182bcdb52dbe534fe (patch)
treeaec40cfd3694b893bece0a34ee25e57492d146ba /numpy/core/records.py
parentb5b47a3989c86b1c530998ba9740e136844c4d11 (diff)
parent148a07b5023bff303d0d07a2d7896c928642d9d4 (diff)
downloadnumpy-749f6c475979489049c4207182bcdb52dbe534fe.tar.gz
Merge pull request #12604 from danielhrisca/fromfile-bugfix
BUG: Check dtype and formats arguments for None in numpy.core.records.fromfile
Diffstat (limited to 'numpy/core/records.py')
-rw-r--r--numpy/core/records.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/numpy/core/records.py b/numpy/core/records.py
index 4ea83accc..42aca5b60 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -721,7 +721,7 @@ def fromstring(datastring, dtype=None, shape=None, offset=0, formats=None,
a string"""
if dtype is None and formats is None:
- raise ValueError("Must have dtype= or formats=")
+ raise TypeError("fromstring() needs a 'dtype' or 'formats' argument")
if dtype is not None:
descr = sb.dtype(dtype)
@@ -768,6 +768,9 @@ def fromfile(fd, dtype=None, shape=None, offset=0, formats=None,
>>> r.shape
(10,)
"""
+
+ if dtype is None and formats is None:
+ raise TypeError("fromfile() needs a 'dtype' or 'formats' argument")
if (shape is None or shape == 0):
shape = (-1,)