Properly handle and close file in setup.py
authorHarmon <Harmon758@gmail.com>
Wed, 16 Oct 2019 17:50:02 +0000 (12:50 -0500)
committerHarmon <Harmon758@gmail.com>
Wed, 16 Oct 2019 17:50:02 +0000 (12:50 -0500)
setup.py

index 3cf35899ac811a16898b3368be1756e48fe967cd..226988a79a4d84249840667feccb14ba9c6b622f 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -5,9 +5,9 @@ import re
 from setuptools import find_packages, setup
 
 VERSIONFILE = "tweepy/__init__.py"
-ver_file = open(VERSIONFILE, "rt").read()
 VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
-mo = re.search(VSRE, ver_file, re.M)
+with open(VERSIONFILE, "rt") as ver_file:
+    mo = re.search(VSRE, ver_file.read(), re.M)
 
 if mo:
     version = mo.group(1)