[Python-checkins] cpython (merge 3.2 -> default): Issue 12514: Use try/finally to assure that timeit restores GC when done.
raymond.hettinger
python-checkins at python.org
Fri Jul 29 09:08:28 CEST 2011
http://hg.python.org/cpython/rev/7df53f5788a4
changeset: 71548:7df53f5788a4
parent: 71545:80a3bf889cf6
parent: 71547:1cdb281a78ce
user: Raymond Hettinger <python at rcn.com>
date: Fri Jul 29 00:08:19 2011 -0700
summary:
Issue 12514: Use try/finally to assure that timeit restores GC when done.
files:
Lib/timeit.py | 8 +++++---
Misc/ACKS | 1 +
Misc/NEWS | 3 +++
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/Lib/timeit.py b/Lib/timeit.py
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -191,9 +191,11 @@
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
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -771,6 +771,7 @@
Marc Recht
John Redford
Terry Reedy
+Gareth Rees
Steve Reeves
Lennart Regebro
Ofir Reichenberg
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -246,6 +246,9 @@
- 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.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list