[issue24912] The type of cached objects is mutable

Nathaniel Smith report at bugs.python.org
Sun Aug 30 01:51:45 CEST 2015


Nathaniel Smith added the comment:

Well, yeah, that indeed sucks.

Not sure what the best solution is. Some options:

1) "Don't do that then"

2) Explicitly add a "__class__" property to every immutable type, that unconditionally errors out on assignment.

3) Add a hack to typeobject.c checking for the important immutable types

4) Something cleverer...? A new type flag?

The immutable types are: int, float, str, tuple, bool, frozenset, complex, bytes, and... anything else?

----------

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


More information about the Python-bugs-list mailing list