]> 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 07:02:04 +0000 (00:02 -0700)
committerRaymond Hettinger <python@rcn.com>
Fri, 29 Jul 2011 07:02:04 +0000 (00:02 -0700)
Lib/timeit.py
Misc/ACKS
Misc/NEWS

index 8e0464526250d29ed9292ba173fa49d5aff41e64..461c8910702b171e671876b642cfc6937a3e69ba 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 4a2c06e620d2753bbb052231565f236f586ce260..820206acf4f5b50b30ea26ee911cdefceb2233ce 100644 (file)
--- 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
index e7c3a75a37bbaf163378c677876818a0f1f7de9e..0e78bf213905d49948b6a86d828af682ec0131d6 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.