summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-07-29 07:08:19 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-07-29 07:08:19 (GMT)
commitabe9dc3f30b9166e2c4c9c5e21a235ec655a6ca0 (patch)
treee48df1629e7baa0b3f5d55f6c74efa6decc5f3ab
parent1d8b968c683be51619c38f892f2e91bdeafab20d (diff)
parent3a081f526d1556129facd38a1bb6a1b8af3abbe7 (diff)
downloadcpython-abe9dc3f30b9166e2c4c9c5e21a235ec655a6ca0.zip
cpython-abe9dc3f30b9166e2c4c9c5e21a235ec655a6ca0.tar.gz
cpython-abe9dc3f30b9166e2c4c9c5e21a235ec655a6ca0.tar.bz2
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 f2510ea..f45168b 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 d9185e2..3124099 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -771,6 +771,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 c7b36e0..6ba892c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -246,6 +246,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.