bpo-29235: Make cProfile.Profile a context manager (GH-6808)

This commit is contained in:
Scott Sanderson 2018-06-01 16:36:23 -04:00 committed by Brett Cannon
parent 252f6abe0a
commit 2e01b75884
4 changed files with 52 additions and 0 deletions

View file

@ -110,6 +110,13 @@ class Profile(_lsprof.Profiler):
finally:
self.disable()
def __enter__(self):
self.enable()
return self
def __exit__(self, *exc_info):
self.disable()
# ____________________________________________________________
def label(code):