summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/release/upcoming_changes/19593.compatibility.rst19
-rw-r--r--numpy/lib/npyio.py2
2 files changed, 1 insertions, 20 deletions
diff --git a/doc/release/upcoming_changes/19593.compatibility.rst b/doc/release/upcoming_changes/19593.compatibility.rst
deleted file mode 100644
index bf65d3517..000000000
--- a/doc/release/upcoming_changes/19593.compatibility.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-loadtxt raises TypeError instead of ValueError when fname is wrong type
------------------------------------------------------------------------
-``numpy.loadtxt`` now raises a `TypeError` instead of a `ValueError` when the
-type of the ``fname`` parameter is incorrect.
-
-Previous behavior::
-
- >>> np.loadtxt(1) # doctest: +SKIP
- Traceback (most recent call last):
- ...
- ValueError: fname must be a string, file handle, or generator
-
-Current behavior::
-
- >>> np.loadtxt(1) # doctest: +SKIP
- Traceback (most recent call last):
- ...
- TypeError: fname must be a string, filehandle, list of strings,
- or generator. Got <class 'int'> instead.
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index ff8aa1349..68972bba6 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -1076,7 +1076,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
fh = iter(fname)
fencoding = getattr(fname, 'encoding', 'latin1')
except TypeError as e:
- raise TypeError(
+ raise ValueError(
f"fname must be a string, filehandle, list of strings,\n"
f"or generator. Got {type(fname)} instead."
) from e