diff options
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/format.py | 4 | ||||
-rw-r--r-- | numpy/lib/tests/test__datasource.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_io.py | 4 | ||||
-rw-r--r-- | numpy/lib/utils.py | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py index 1e508f3e5..bff582f7d 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -334,7 +334,7 @@ def read_array_header_1_0(fp): # "descr" : dtype.descr try: d = safe_eval(header) - except SyntaxError, e: + except SyntaxError as e: msg = "Cannot parse header: %r\nException: %r" raise ValueError(msg % (header, e)) if not isinstance(d, dict): @@ -356,7 +356,7 @@ def read_array_header_1_0(fp): raise ValueError(msg % (d['fortran_order'],)) try: dtype = numpy.dtype(d['descr']) - except TypeError, e: + except TypeError as e: msg = "descr is not a valid dtype descriptor: %r" raise ValueError(msg % (d['descr'],)) diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py index ed5af516f..3f8697507 100644 --- a/numpy/lib/tests/test__datasource.py +++ b/numpy/lib/tests/test__datasource.py @@ -92,7 +92,7 @@ class TestDataSourceOpen(TestCase): self.assertRaises(IOError, self.ds.open, url) try: self.ds.open(url) - except IOError, e: + except IOError as e: # Regression test for bug fixed in r4342. assert_(e.errno is None) diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index f8caeedb6..b7fa94448 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -151,7 +151,7 @@ class TestSavezLoad(RoundtripTest, TestCase): arr = np.random.randn(500, 500) try: np.savez(tmp, arr=arr) - except OSError, err: + except OSError as err: error_list.append(err) finally: os.remove(tmp) @@ -207,7 +207,7 @@ class TestSavezLoad(RoundtripTest, TestCase): for i in range(1, 1025): try: np.load(tmp)["data"] - except Exception, e: + except Exception as e: raise AssertionError("Failed to load data from a file: %s" % e) finally: os.remove(tmp) diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index dc6c16767..820e6d8f9 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -1154,11 +1154,11 @@ def safe_eval(source): walker = SafeEval() try: ast = compiler.parse(source, mode="eval") - except SyntaxError, err: + except SyntaxError as err: raise try: return walker.visit(ast) - except SyntaxError, err: + except SyntaxError as err: raise #----------------------------------------------------------------------------- |