[Python-Dev] __class__ assignment in 2.2a1

James_Althoff@i2.com James_Althoff@i2.com
Tue, 14 Aug 2001 14:37:11 -0700


The following seems like it could use a more helpful error message.
Presumably it fails because you can only set the value of __class__ to that
of another class object whose __dynamic__  attribute == 1?

C:\>python
Python 2.2a1 (#21, Jul 18 2001, 04:25:46) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> class C(object): pass
...
>>> class D: pass
...
>>> class E: pass
...
>>> d = D()
>>> d.__class__ = E
>>> d.__class__ = C
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: __class__ must be set to a class
>>>

Jim