[docs] [issue4600] __class__ assignment: new-style? heap? == confusing

Jonas H. report at bugs.python.org
Sun Feb 27 19:00:32 CET 2011


Jonas H. <jonas at lophus.org> added the comment:

Here comes a patch, changing the behaviour to:

./python -q
>>> class C:
...   pass
... 
>>> (1).__class__ = 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __class__ must be set to a class defined by a class statement, not 'int' object
>>> (1).__class__ = object
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: class__ must be set to a class defined by a class statement, not 'object'
>>> (1).__class__ = C
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __class__ assignment: only for instances of classes defined by class statements

----------
keywords: +patch
nosy: +jonash
Added file: http://bugs.python.org/file20937/4600.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4600>
_______________________________________


More information about the docs mailing list