From: Armin Rigo Date: Thu, 12 Jun 2008 09:50:58 +0000 (+0000) Subject: Sounds obvious, but I didn't even realize that you can put non-string X-Git-Tag: v2.6b1~67 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ffae306784a067c9a604856e0886fa9d5e716337;p=thirdparty%2FPython%2Fcpython.git Sounds obvious, but I didn't even realize that you can put non-string keys in type dictionaries without using this locals() hack. --- diff --git a/Lib/test/crashers/loosing_mro_ref.py b/Lib/test/crashers/loosing_mro_ref.py index f0b8047d8d19..b5fa93b53d4b 100644 --- a/Lib/test/crashers/loosing_mro_ref.py +++ b/Lib/test/crashers/loosing_mro_ref.py @@ -27,10 +27,9 @@ class Base(object): 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.