Mark Hammond should get his act into gear (his words :-). Zero length
strings _are_ valid!
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 6cb1ea8..14866ab 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1554,7 +1554,7 @@
/* First get the size of the result */
DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0);
- if (usize==0)
+ if (size > 0 && usize==0)
return PyErr_SetFromWindowsErrWithFilename(0, NULL);
v = _PyUnicode_New(usize);
@@ -1577,9 +1577,14 @@
{
PyObject *repr;
char *s;
+ DWORD mbcssize;
+
+ /* If there are no characters, bail now! */
+ if (size==0)
+ return PyString_FromString("");
/* First get the size of the result */
- DWORD mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL);
+ mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL);
if (mbcssize==0)
return PyErr_SetFromWindowsErrWithFilename(0, NULL);