diff options
author | Sarthak Vineet Kumar <sarthakchaudhary13@gmail.com> | 2020-07-09 02:39:03 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 14:09:03 -0700 |
commit | 996e6419e44668a6daa28f58efcc0d2c07b3a9da (patch) | |
tree | 01c14df8ecbe2ee4740bde37dd8745b154066ebd /numpy/lib/_datasource.py | |
parent | 2c2291136aca50b58cd7c09b29a25490c89c9b8a (diff) | |
download | numpy-996e6419e44668a6daa28f58efcc0d2c07b3a9da.tar.gz |
MAINT: Tidy exception handling in _datasource.py (#16761)
Remove unnecessary try/except from DataSource.
Diffstat (limited to 'numpy/lib/_datasource.py')
-rw-r--r-- | numpy/lib/_datasource.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py index f5d0cc217..7a23b1651 100644 --- a/numpy/lib/_datasource.py +++ b/numpy/lib/_datasource.py @@ -37,7 +37,6 @@ Example:: import os import shutil import io -from contextlib import closing from numpy.core.overrides import set_module @@ -333,12 +332,9 @@ class DataSource: # TODO: Doesn't handle compressed files! if self._isurl(path): - try: - with closing(urlopen(path)) as openedurl: - with _open(upath, 'wb') as f: - shutil.copyfileobj(openedurl, f) - except URLError: - raise URLError("URL not found: %s" % path) + with urlopen(path) as openedurl: + with _open(upath, 'wb') as f: + shutil.copyfileobj(openedurl, f) else: shutil.copyfile(path, upath) return upath |