Issue #12400: test_cprofile now restores correctly the previous sys.stderr
Copy sys.stderr before replacing it, instead of using sys.__stderr__
This commit is contained in:
parent
0aafa4f1e2
commit
7f86811d55
|
@ -18,6 +18,8 @@ class CProfileTest(ProfileTest):
|
|||
def test_bad_counter_during_dealloc(self):
|
||||
import _lsprof
|
||||
# Must use a file as StringIO doesn't trigger the bug.
|
||||
orig_stderr = sys.stderr
|
||||
try:
|
||||
with open(TESTFN, 'w') as file:
|
||||
sys.stderr = file
|
||||
try:
|
||||
|
@ -26,7 +28,8 @@ class CProfileTest(ProfileTest):
|
|||
obj = _lsprof.Profiler(1)
|
||||
obj.disable()
|
||||
finally:
|
||||
sys.stderr = sys.__stderr__
|
||||
sys.stderr = orig_stderr
|
||||
finally:
|
||||
unlink(TESTFN)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue