diff options
author | Martin v. L?wis <martin@v.loewis.de> | 2012-04-20 14:37:17 +0200 |
---|---|---|
committer | Martin v. L?wis <martin@v.loewis.de> | 2012-04-20 14:37:17 +0200 |
commit | b467205669cae187c9bbce311069c4875518bfae (patch) | |
tree | ce7686f020917e8883d1818b8fadece2cc15fa06 /Lib/test/test_cprofile.py | |
parent | f235cad91035d648e09ae7a1867fc9aa49ae8963 (diff) | |
parent | 2c826ad61cf991d15646ae7bfac2d0cb34535cd8 (diff) | |
download | cpython-b467205669cae187c9bbce311069c4875518bfae.tar.gz |
merge 3.2: issue 14629
Diffstat (limited to 'Lib/test/test_cprofile.py')
-rw-r--r-- | Lib/test/test_cprofile.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/Lib/test/test_cprofile.py b/Lib/test/test_cprofile.py index ae17c2b694..56766682b3 100644 --- a/Lib/test/test_cprofile.py +++ b/Lib/test/test_cprofile.py @@ -18,16 +18,19 @@ class CProfileTest(ProfileTest): def test_bad_counter_during_dealloc(self): import _lsprof # Must use a file as StringIO doesn't trigger the bug. - with open(TESTFN, 'w') as file: - sys.stderr = file - try: - obj = _lsprof.Profiler(lambda: int) - obj.enable() - obj = _lsprof.Profiler(1) - obj.disable() - finally: - sys.stderr = sys.__stderr__ - unlink(TESTFN) + orig_stderr = sys.stderr + try: + with open(TESTFN, 'w') as file: + sys.stderr = file + try: + obj = _lsprof.Profiler(lambda: int) + obj.enable() + obj = _lsprof.Profiler(1) + obj.disable() + finally: + sys.stderr = orig_stderr + finally: + unlink(TESTFN) def test_main(): |