Commit 2b6220d8 authored by Raymond Hettinger's avatar Raymond Hettinger

SF bug #762455: Python segfaults when sys.stdout is changed in getattr

* Added unittest that fails before, but not after Neil's fix to ceval.c.
parent c5131bc2
...@@ -3916,6 +3916,20 @@ def weakref_segfault(): ...@@ -3916,6 +3916,20 @@ def weakref_segfault():
o.whatever = Provoker(o) o.whatever = Provoker(o)
del o del o
# Fix SF #762455, segfault when sys.stdout is changed in getattr
def filefault():
if verbose:
print "Testing sys.stdout is changed in getattr..."
import sys
class StdoutGuard:
def __getattr__(self, attr):
sys.stdout = sys.__stdout__
raise RuntimeError("Premature access to sys.stdout.%s" % attr)
sys.stdout = StdoutGuard()
try:
print "Oops!"
except RuntimeError:
pass
def test_main(): def test_main():
weakref_segfault() # Must be first, somehow weakref_segfault() # Must be first, somehow
...@@ -4007,6 +4021,7 @@ def test_main(): ...@@ -4007,6 +4021,7 @@ def test_main():
isinst_isclass() isinst_isclass()
proxysuper() proxysuper()
carloverre() carloverre()
filefault()
if verbose: print "All OK" if verbose: print "All OK"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment