summaryrefslogtreecommitdiff
path: root/numpy/lib/_datasource.py
diff options
context:
space:
mode:
authorcgohlke <cgohlke@uci.edu>2013-10-15 14:17:40 -0700
committercgohlke <cgohlke@uci.edu>2013-10-15 14:17:40 -0700
commita1ebc6765dea098f3f9b9180baa2cc50b042da8c (patch)
treee5843a81d5b5ff5e9ddf2543125ec1141e03fd9e /numpy/lib/_datasource.py
parent61c8568e8ae2fe0afbb7a96b72902573ac4e22e7 (diff)
downloadnumpy-a1ebc6765dea098f3f9b9180baa2cc50b042da8c.tar.gz
BUG: close file-like objects returned by urlopen
Fix `ResourceWarning: unclosed file` on Python 3
Diffstat (limited to 'numpy/lib/_datasource.py')
-rw-r--r--numpy/lib/_datasource.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py
index 617acdac1..96d9af905 100644
--- a/numpy/lib/_datasource.py
+++ b/numpy/lib/_datasource.py
@@ -297,6 +297,7 @@ class DataSource (object):
copyfileobj(openedurl, f)
finally:
f.close()
+ openedurl.close()
except URLError:
raise URLError("URL not found: %s" % path)
else:
@@ -445,6 +446,7 @@ class DataSource (object):
if self._isurl(path):
try:
netfile = urlopen(path)
+ netfile.close()
del(netfile)
return True
except URLError: