summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-07-29 00:02:04 -0700
committerRaymond Hettinger <python@rcn.com>2011-07-29 00:02:04 -0700
commit3a081f526d1556129facd38a1bb6a1b8af3abbe7 (patch)
tree8371abaaf2caa7bcc9c208bbd8cd9cb0792e272a
parentef4902af879cd571e3b57d745c355f255daa09af (diff)
downloadcpython-git-3a081f526d1556129facd38a1bb6a1b8af3abbe7.tar.gz
Issue 12514: Use try/finally to assure that timeit restores GC when done.
-rw-r--r--Lib/timeit.py8
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
3 files changed, 9 insertions, 3 deletions
diff --git a/Lib/timeit.py b/Lib/timeit.py
index 8e04645262..461c891070 100644
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -191,9 +191,11 @@ class Timer:
it = [None] * number
gcold = gc.isenabled()
gc.disable()
- timing = self.inner(it, self.timer)
- if gcold:
- gc.enable()
+ try:
+ timing = self.inner(it, self.timer)
+ finally:
+ if gcold:
+ gc.enable()
return timing
def repeat(self, repeat=default_repeat, number=default_number):
diff --git a/Misc/ACKS b/Misc/ACKS
index 4a2c06e620..820206acf4 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -722,6 +722,7 @@ Chris Rebert
Marc Recht
John Redford
Terry Reedy
+Gareth Rees
Steve Reeves
Lennart Regebro
Ofir Reichenberg
diff --git a/Misc/NEWS b/Misc/NEWS
index e7c3a75a37..0e78bf2139 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -39,6 +39,9 @@ Library
- Issue #12603: Fix pydoc.synopsis() on files with non-negative st_mtime.
+- Issue #12514: Use try/finally to assure the timeit module restores garbage
+ collections when it is done.
+
- Issue #12607: In subprocess, fix issue where if stdin, stdout or stderr is
given as a low fd, it gets overwritten.