]> granicus.if.org Git - python/commitdiff
Issue 12514: Use try/finally to assure that timeit restores GC when done.
authorRaymond Hettinger <python@rcn.com>
Fri, 29 Jul 2011 06:56:38 +0000 (23:56 -0700)
committerRaymond Hettinger <python@rcn.com>
Fri, 29 Jul 2011 06:56:38 +0000 (23:56 -0700)
Lib/timeit.py
Misc/ACKS
Misc/NEWS

index a095313950e35c9851e6ccacee71d78e8ab56968..da9e819bc07b07ac09a9885374ce8051386df10d 100644 (file)
@@ -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):
index 0958490d6d6b95ae9f2722f85065bd2081777aa6..bfbbf691eca26da9d72b0470713d144b97a7d568 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -672,6 +672,7 @@ Chris Rebert
 Marc Recht
 John Redford
 Terry Reedy
+Gareth Rees
 Steve Reeves
 Lennart Regebro
 Ofir Reichenberg
index e3c404fff9489a6468750bb585ee2dc7df2c5753..de2cff51124e5002a5b0d94d319a720dd093abcc 100644 (file)
--- 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.