This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients georg.brandl, jcea, mark.dickinson, ncoghlan, pitrou
Date 2011-02-22.15:20:59
SpamBayes Score 3.3648035e-08
Marked as misclassified No
Message-id <1298388060.38.0.667500660925.issue11286@psf.upfronthosting.co.za>
In-reply-to
Content
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);
History
Date User Action Args
2011-02-22 15:21:00pitrousetrecipients: + pitrou, georg.brandl, jcea, mark.dickinson, ncoghlan
2011-02-22 15:21:00pitrousetmessageid: <1298388060.38.0.667500660925.issue11286@psf.upfronthosting.co.za>
2011-02-22 15:20:59pitroulinkissue11286 messages
2011-02-22 15:20:59pitroucreate