This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Mark.Shannon, benjamin.peterson, larry, njs, pitrou, serhiy.storchaka
Date 2015-08-30.06:01:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1440914495.13.0.800393670808.issue24912@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-08-30 06:01:35serhiy.storchakasetrecipients: + serhiy.storchaka, pitrou, larry, benjamin.peterson, njs, Mark.Shannon
2015-08-30 06:01:35serhiy.storchakasetmessageid: <1440914495.13.0.800393670808.issue24912@psf.upfronthosting.co.za>
2015-08-30 06:01:35serhiy.storchakalinkissue24912 messages
2015-08-30 06:01:34serhiy.storchakacreate