[Python-checkins] r69067 - in python/branches/release30-maint/Lib/test/crashers: loosing_mro_ref.py losing_mro_ref.py
raymond.hettinger
python-checkins at python.org
Wed Jan 28 22:06:01 CET 2009
Author: raymond.hettinger
Date: Wed Jan 28 22:06:01 2009
New Revision: 69067
Log:
Fix spelling in filename.
Added:
python/branches/release30-maint/Lib/test/crashers/losing_mro_ref.py
- copied unchanged from r69066, /python/branches/release30-maint/Lib/test/crashers/loosing_mro_ref.py
Removed:
python/branches/release30-maint/Lib/test/crashers/loosing_mro_ref.py
Deleted: python/branches/release30-maint/Lib/test/crashers/loosing_mro_ref.py
==============================================================================
--- python/branches/release30-maint/Lib/test/crashers/loosing_mro_ref.py Wed Jan 28 22:06:01 2009
+++ (empty file)
@@ -1,35 +0,0 @@
-"""
-There is a way to put keys of any type in a type's dictionary.
-I think this allows various kinds of crashes, but so far I have only
-found a convoluted attack of _PyType_Lookup(), which uses the mro of the
-type without holding a strong reference to it. Probably works with
-super.__getattribute__() too, which uses the same kind of code.
-"""
-
-class MyKey(object):
- def __hash__(self):
- return hash('mykey')
-
- def __eq__(self, other):
- # the following line decrefs the previous X.__mro__
- X.__bases__ = (Base2,)
- # trash all tuples of length 3, to make sure that the items of
- # the previous X.__mro__ are really garbage
- z = []
- for i in range(1000):
- z.append((i, None, None))
- return 0
-
-
-class Base(object):
- mykey = 'from Base'
-
-class Base2(object):
- mykey = 'from Base2'
-
-# you can't add a non-string key to X.__dict__, but it can be
-# there from the beginning :-)
-X = type('X', (Base,), {MyKey(): 5})
-
-print(X.mykey)
-# I get a segfault, or a slightly wrong assertion error in a debug build.
More information about the Python-checkins
mailing list