[Python-3000] C API cleanup str
"Martin v. Löwis"
martin at v.loewis.de
Sun Aug 5 22:32:16 CEST 2007
> You mean if it were fixed it could fail, right? Code calling it should
> be checking for errors anyway because it allocates memory.
>
> Have you tried making this particular change and seeing what fails?
I now tried, and it turned out that bytes.__reduce__ would break
(again); I fixed it and changed it in r56755.
It turned out that PyUnicode_FromString was even documented to
accept latin-1.
While I was looking at it, I wondered why PyUnicode_FromStringAndSize
allows a NULL first argument, creating a null-initialized Unicode
object. This functionality is already available as
PyUnicode_FromUnicode, and callers who previously wrote
obuf = PyString_FromStringAndSize(NULL, bufsize);
if (!obuf)return NULL;
buf = PyString_AsString(buf);
could be tricked into believing that they now can change the
string object they just created - which they cannot, as
buf will just be the UTF-8 encoded version of the real string.
Regards,
Martin
More information about the Python-3000
mailing list