aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/build_py.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-12-09 02:49:48 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-12-09 02:49:48 -0500
commit2ef88b8e709f0c090a3f7f8c7f612aacbbcd648f (patch)
treeecfc237f07f50fa2e12f80c174b10a92db2f83a1 /setuptools/command/build_py.py
parente76a139ca4fad75c4ce8b3bc95e0009ea0823eb5 (diff)
downloadexternal_python_setuptools-2ef88b8e709f0c090a3f7f8c7f612aacbbcd648f.tar.gz
external_python_setuptools-2ef88b8e709f0c090a3f7f8c7f612aacbbcd648f.tar.bz2
external_python_setuptools-2ef88b8e709f0c090a3f7f8c7f612aacbbcd648f.zip
Use context manager for closing file
Diffstat (limited to 'setuptools/command/build_py.py')
-rw-r--r--setuptools/command/build_py.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py
index 779adf2a..c971626c 100644
--- a/setuptools/command/build_py.py
+++ b/setuptools/command/build_py.py
@@ -159,7 +159,8 @@ class build_py(orig.build_py, Mixin2to3):
else:
return init_py
- f = io.open(init_py, 'rb')
+ with io.open(init_py, 'rb') as f:
+ contents = f.read()
if 'declare_namespace'.encode() not in f.read():
from distutils.errors import DistutilsError
@@ -169,7 +170,6 @@ class build_py(orig.build_py, Mixin2to3):
'fix it.\n(See the setuptools manual under '
'"Namespace Packages" for details.)\n"' % (package,)
)
- f.close()
return init_py
def initialize_options(self):