commit | 31f4beb15e959e818947db3297ac639bc2afc067 | [log] [tgz] |
---|---|---|
author | Benjamin Peterson <benjamin@python.org> | Thu Jul 14 12:48:01 2011 -0500 |
committer | Benjamin Peterson <benjamin@python.org> | Thu Jul 14 12:48:01 2011 -0500 |
tree | 3633e894c665049abd960ea17189069f77e389a0 | |
parent | c917494528b3e116d4d17df52daea74f112e2b68 [diff] |
add a contextmanager to disable the gc
diff --git a/Lib/test/support.py b/Lib/test/support.py index ba53ab9..64864de 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py
@@ -1005,6 +1005,16 @@ gc.collect() gc.collect() +@contextlib.contextmanager +def disable_gc(): + have_gc = gc.isenabled() + gc.disable() + try: + yield + finally: + if have_gc: + gc.enable() + def python_is_optimized(): """Find if Python was built with optimizations."""