Skip to content

Commit

Permalink
Merge pull request numpy#12604 from danielhrisca/fromfile-bugfix
Browse files Browse the repository at this point in the history
BUG: Check dtype and formats arguments for None in numpy.core.records.fromfile
  • Loading branch information
charris authored Jan 19, 2019
2 parents b5b47a3 + 148a07b commit 749f6c4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion numpy/core/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,)
Expand Down

0 comments on commit 749f6c4

Please sign in to comment.