diff options
author | Ralf Gommers <ralf.gommers@googlemail.com> | 2013-12-23 10:34:13 +0100 |
---|---|---|
committer | Ralf Gommers <ralf.gommers@googlemail.com> | 2013-12-23 15:45:40 +0100 |
commit | 8d4cc1e485d518a48111ce1b0e38edd7a8279946 (patch) | |
tree | de94234a42829c6a493a42872f48df067927fe49 | |
parent | bc82e93cbc0d8b3294764932339eb78a8a1e6e3c (diff) | |
download | numpy-8d4cc1e485d518a48111ce1b0e38edd7a8279946.tar.gz |
MAINT: don't use open(.., 'U') in Python 3.x, is deprecated.
This is default behavior in 3.x; in 2.x open() doesn't have a `newline`
kw. So make code Python-version-specific.
-rw-r--r-- | numpy/lib/npyio.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index dced7fd78..af259cfef 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -726,8 +726,10 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, elif fname.endswith('.bz2'): import bz2 fh = iter(bz2.BZ2File(fname)) - else: + elif sys.version_info[0] == 2: fh = iter(open(fname, 'U')) + else: + fh = iter(open(fname)) else: fh = iter(fname) except TypeError: @@ -1330,7 +1332,10 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, own_fhd = False try: if isinstance(fname, basestring): - fhd = iter(np.lib._datasource.open(fname, 'rbU')) + if sys.version_info[0] == 2: + fhd = iter(np.lib._datasource.open(fname, 'rbU')) + else: + fhd = iter(np.lib._datasource.open(fname, 'rb')) own_fhd = True else: fhd = iter(fname) |