summaryrefslogtreecommitdiff
path: root/Lib/cProfile.py
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2013-02-12 02:04:27 +0100
committerGiampaolo Rodola' <g.rodola@gmail.com>2013-02-12 02:04:27 +0100
commit2f50aaf2ff427fb713e82699a6dcbeeb038b10c2 (patch)
tree0e2c24897b8918f19d8504915ccebd466c0bbd92 /Lib/cProfile.py
parentfd6e6cfa29b2289e711dc7f57f36897c78899ee7 (diff)
downloadcpython-git-2f50aaf2ff427fb713e82699a6dcbeeb038b10c2.tar.gz
modernize some modules' code by using with statement around open()
Diffstat (limited to 'Lib/cProfile.py')
-rwxr-xr-xLib/cProfile.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py
index c24d45bab4..81e722b1ec 100755
--- a/Lib/cProfile.py
+++ b/Lib/cProfile.py
@@ -77,10 +77,9 @@ class Profile(_lsprof.Profiler):
def dump_stats(self, file):
import marshal
- 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.disable()