summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/lib/_iotools.py7
-rw-r--r--numpy/lib/npyio.py8
2 files changed, 6 insertions, 9 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py
index f5368526d..a576925d6 100644
--- a/numpy/lib/_iotools.py
+++ b/numpy/lib/_iotools.py
@@ -18,6 +18,8 @@ def _decode_line(line, encoding=None):
----------
line : str or bytes
Line to be decoded.
+ encoding : str
+ Encoding used to decode `line`.
Returns
-------
@@ -27,9 +29,8 @@ def _decode_line(line, encoding=None):
"""
if type(line) is bytes:
if encoding is None:
- line = line.decode('latin1')
- else:
- line = line.decode(encoding)
+ encoding = "latin1"
+ line = line.decode(encoding)
return line
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 805e59bc1..3b2de3e61 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -965,10 +965,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
if comments is not None:
line = regex_comments.split(line, maxsplit=1)[0]
line = line.strip('\r\n')
- if line:
- return line.split(delimiter)
- else:
- return []
+ return line.split(delimiter) if line else []
def read_data(chunk_size):
"""Parse each line, including the first.
@@ -1030,11 +1027,10 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None,
user_converters = converters
+ byte_converters = False
if encoding == 'bytes':
encoding = None
byte_converters = True
- else:
- byte_converters = False
if usecols is not None:
# Allow usecols to be a single int or a sequence of ints