[Python-checkins] r64165 - python/trunk/Lib/test/crashers/loosing_mro_ref.py
armin.rigo
python-checkins at python.org
Thu Jun 12 11:50:58 CEST 2008
Author: armin.rigo
Date: Thu Jun 12 11:50:58 2008
New Revision: 64165
Log:
Sounds obvious, but I didn't even realize that you can put non-string
keys in type dictionaries without using this locals() hack.
Modified:
python/trunk/Lib/test/crashers/loosing_mro_ref.py
Modified: python/trunk/Lib/test/crashers/loosing_mro_ref.py
==============================================================================
--- python/trunk/Lib/test/crashers/loosing_mro_ref.py (original)
+++ python/trunk/Lib/test/crashers/loosing_mro_ref.py Thu Jun 12 11:50:58 2008
@@ -27,10 +27,9 @@
class Base2(object):
mykey = 'from Base2'
-class X(Base):
- # you can't add a non-string key to X.__dict__, but it can be
- # there from the beginning :-)
- locals()[MyKey()] = 5
+# 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