Browse Source

setup: Explicitly close file

Stein Magnus Jodal 10 năm trước cách đây
mục cha
commit
036e3cf91e
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      setup.py

+ 3 - 3
setup.py

@@ -6,9 +6,9 @@ from setuptools import find_packages, setup
 
 
 def get_version(filename):
-    content = open(filename).read()
-    metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", content))
-    return metadata['version']
+    with open(filename) as fh:
+        metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", fh.read()))
+        return metadata['version']
 
 
 setup(