[Python-Dev] Modifying the PyUnicode_FromUnicode result

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Sat, 21 Apr 2001 11:51:56 +0200


Currently, a number of routines assume that the result of
PyUnicode_FromUnicode can be modified, i.e. they mutate the resulting
unicode object. Look at unicodeobject.c:fixup for an example, and
assume that fixfct is fixtitle (*).

This is different from PyString_FromStringAndSize, whose result can be
only modified if the str argument is NULL.

These routines broke after I applied my caching patch, since now
PyUnicode_FromUnicode may return an existing string.

Is that difference intentional? My feeling is that it is an error to
modify a unicode object, unless it is known not to be initialized.

Regards,
Martin

P.S. This was actually the first failure case when running
test_unicodedata under my patch.