From 7a88b441b713e6b32557ba691f0a5fab86f14296 Mon Sep 17 00:00:00 2001 From: Micah Cochran Date: Wed, 16 Dec 2015 11:45:35 -0600 Subject: [PATCH] stops ResourceWarnings for unclosed files Closes files bdatfile and bdatmetafile. This seems to be the simplest way to accomplish this. This solves warnings like this: ``` /.../lib/python3.4/site-packages/mpl_toolkits/basemap/__init__.py:1087: ResourceWarning: unclosed file <_io.TextIOWrapper name='/.../lib/python3.4/site-packages/mpl_toolkits/basemap/data/gshhsmeta_c.dat' mode='r' encoding='UTF-8'> self._readboundarydata('gshhs',as_polygons=True) /.../python3.4/site-packages/mpl_toolkits/basemap/__init__.py:1095: ResourceWarning: unclosed file <_io.BufferedReader name='/.../lib/python3.4/site-packages/mpl_toolkits/basemap/data/gshhs_c.dat'> self._readboundarydata('gshhs',as_polygons=False) ``` ResourceWarnings are most of the warning raised when running test.py. --- lib/mpl_toolkits/basemap/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/mpl_toolkits/basemap/__init__.py b/lib/mpl_toolkits/basemap/__init__.py index 0177a1634..fe2fa13f9 100644 --- a/lib/mpl_toolkits/basemap/__init__.py +++ b/lib/mpl_toolkits/basemap/__init__.py @@ -1460,6 +1460,8 @@ def _readboundarydata(self,name,as_polygons=False): if not as_polygons or len(b) > 4: polygons.append(list(zip(b[:,0],b[:,1]))) polygon_types.append(typ) + bdatfile.close() + bdatmetafile.close() return polygons, polygon_types def _getmapboundary(self):