diff options
Diffstat (limited to 'Lib/cProfile.py')
-rwxr-xr-x | Lib/cProfile.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/cProfile.py b/Lib/cProfile.py index c24d45b..81e722b 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() |