diff options
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index cbef1a6e2..e7287ea8f 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1088,7 +1088,12 @@ def savetxt(fname, X, fmt='%.18e', delimiter=' ', newline='\n', header='', fh.write(asbytes(format % tuple(row2) + newline)) else: for row in X: - fh.write(asbytes(format % tuple(row) + newline)) + try: + fh.write(asbytes(format % tuple(row) + newline)) + except TypeError: + raise TypeError("Mismatch between array dtype ('%s') and " + "format specifier ('%s')" + % (str(X.dtype), format)) if len(footer) > 0: footer = footer.replace('\n', '\n' + comments) fh.write(asbytes(comments + footer + newline)) |