From 50aaf9938a4437db7f2949df6ecb6460c789ff28 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 19 Aug 2015 19:47:55 +0100 Subject: Open file in context manager --- setuptools/command/easy_install.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'setuptools/command/easy_install.py') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 15b260dd..0e912156 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1538,9 +1538,8 @@ class PthDistributions(Environment): if os.path.islink(self.filename): os.unlink(self.filename) - f = open(self.filename, 'wt') - f.write(data) - f.close() + with open(self.filename, 'wt') as f: + f.write(data) elif os.path.exists(self.filename): log.debug("Deleting empty %s", self.filename) -- cgit v1.2.1