summaryrefslogtreecommitdiffstats
path: root/Lib/profile.py
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2013-02-12 01:04:27 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2013-02-12 01:04:27 (GMT)
commit2f50aaf2ff427fb713e82699a6dcbeeb038b10c2 (patch)
tree0e2c24897b8918f19d8504915ccebd466c0bbd92 /Lib/profile.py
parentfd6e6cfa29b2289e711dc7f57f36897c78899ee7 (diff)
downloadcpython-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.zip
cpython-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.tar.gz
cpython-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.tar.bz2
modernize some modules' code by using with statement around open()
Diffstat (limited to 'Lib/profile.py')
-rwxr-xr-xLib/profile.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/profile.py b/Lib/profile.py
index 743e77d..553f210 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -373,10 +373,9 @@ class Profile:
print_stats()
def dump_stats(self, file):
- f = open(file, 'wb')
- self.create_stats()
- marshal.dump(self.stats, f)
- f.close()
+ with open(file, 'wb') as f:
+ self.create_stats()
+ marshal.dump(self.stats, f)
def create_stats(self):
self.simulate_cmd_complete()