summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2003-08-15 13:07:47 (GMT)
committerMichael W. Hudson <mwh@python.net>2003-08-15 13:07:47 (GMT)
commitb2c7de46673e654aec8d2c9b000cce2b071a5093 (patch)
tree9f70390e3c74935ed99f0fa1090435d82bf5d47c /Lib/test/test_descr.py
parentf02bcee095bf0343b9871fd28cf2d580337c599a (diff)
downloadcpython-b2c7de46673e654aec8d2c9b000cce2b071a5093.zip
cpython-b2c7de46673e654aec8d2c9b000cce2b071a5093.tar.gz
cpython-b2c7de46673e654aec8d2c9b000cce2b071a5093.tar.bz2
Fix for
[ 784825 ] fix obscure crash in descriptor handling Should be applied to release23-maint and in all likelyhood release22-maint, too. Certainly doesn't apply to release21-maint.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index b3336d1..e001562 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -3938,6 +3938,36 @@ def filefault():
except RuntimeError:
pass
+def vicious_descriptor_nonsense():
+ # A potential segfault spotted by Thomas Wouters in mail to
+ # python-dev 2003-04-17, turned into an example & fixed by Michael
+ # Hudson just less than four months later...
+ if verbose:
+ print "Testing vicious_descriptor_nonsense..."
+
+ class Evil(object):
+ def __hash__(self):
+ return hash('attr')
+ def __eq__(self, other):
+ del C.attr
+ return 0
+
+ class Descr(object):
+ def __get__(self, ob, type=None):
+ return 1
+
+ class C(object):
+ attr = Descr()
+
+ c = C()
+ c.__dict__[Evil()] = 0
+
+ vereq(c.attr, 1)
+ # this makes a crash more likely:
+ import gc; gc.collect()
+ vereq(hasattr(c, 'attr'), False)
+
+
def test_main():
weakref_segfault() # Must be first, somehow
do_this_first()
@@ -4029,6 +4059,7 @@ def test_main():
proxysuper()
carloverre()
filefault()
+ vicious_descriptor_nonsense()
if verbose: print "All OK"