[issue11145] '%o' % user-defined instance
Armin Rigo
report at bugs.python.org
Mon Nov 17 18:33:45 CET 2014
Armin Rigo added the comment:
Ah, sorry. Ok. Now a different issue: the user-defined function can return an interned string. If it has a refcount of 1, _PyString_FormatLong() will mutate it. Then when we DECREF it, string_dealloc() will not find it any more in the interned dict and crash with a fatal error.
Note that I'm mostly having fun finding holes in delicate logic, like mutating strings in-place. It would be much more simple to either (1) stop calling the user-defined functions and behave similarly to most other built-in types; or (2) stop trying to mutate that poor string in-place and always just create a new one. :-)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11145>
_______________________________________
More information about the Python-bugs-list
mailing list