[Python-Dev] re: __class__ assignment in 2.2a1

James_Althoff@i2.com James_Althoff@i2.com
Tue, 14 Aug 2001 15:36:52 -0700

I guess the rule is that you can only assign __class__ for classic class
instances and the new value has to be a classic class also (ignoring
C-written metaclasses, etc.).  So __dynamic__ doesn't come into play.
Still seems like the error message is a bit confusing.


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?

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