Message129082
This is because of the buffer pointer passed to the codecs machinery being NULL when the empty string is being decoded.
Quick patch follows (needs a test). Also, it is not clear whether it is allowed to store a NULL pointer in the "buf" member of a Py_buffer when the length is 0. Nick, Mark?
Index: Objects/unicodeobject.c
===================================================================
--- Objects/unicodeobject.c (révision 88500)
+++ Objects/unicodeobject.c (copie de travail)
@@ -1460,6 +1460,7 @@
PyObject *buffer = NULL, *unicode;
Py_buffer info;
char lower[11]; /* Enough for any encoding shortcut */
+ static const char empty[] = "";
if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();
@@ -1485,6 +1486,8 @@
/* Decode via the codec registry */
buffer = NULL;
+ if (s == NULL)
+ s = empty;
if (PyBuffer_FillInfo(&info, NULL, (void *)s, size, 1, PyBUF_FULL_RO) < 0)
goto onError;
buffer = PyMemoryView_FromBuffer(&info); |
|
Date |
User |
Action |
Args |
2011-02-22 15:21:00 | pitrou | set | recipients:
+ pitrou, georg.brandl, jcea, mark.dickinson, ncoghlan |
2011-02-22 15:21:00 | pitrou | set | messageid: <1298388060.38.0.667500660925.issue11286@psf.upfronthosting.co.za> |
2011-02-22 15:20:59 | pitrou | link | issue11286 messages |
2011-02-22 15:20:59 | pitrou | create | |
|