Serhiy Storchaka added the comment:

Later I had got a crash.

>>> class S(str): __slots__ = ()
... 
>>> 'a'.__class__ = S
>>> 
>>> def f(a): pass
... 
Fatal Python error: non-string found in code slot

Current thread 0xb7583700 (most recent call first):
Aborted (core dumped)

The stdlib is full of implicit caches. Virtually any hashable object can be 
cached and shared. Why __class__ assignment is allowed at all? There are only 
two uses of __class__ assignment in the stdlib besides tests (in 
Lib/importlib/util.py and in Lib/xml/sax/saxutils.py), and in both cases it 
looks as optimization trick.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24912>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to