]> granicus.if.org Git - python/commitdiff
Mark Hammond should get his act into gear (his words :-). Zero length
authorGuido van Rossum <guido@python.org>
Thu, 4 May 2000 15:52:20 +0000 (15:52 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 4 May 2000 15:52:20 +0000 (15:52 +0000)
strings _are_ valid!

Objects/unicodeobject.c

index 6cb1ea83ffc54eff99f6d07461a1465a7b4c4393..14866ab0526bef7d29a3ded3948dfada9c9d90bb 100644 (file)
@@ -1554,7 +1554,7 @@ PyObject *PyUnicode_DecodeMBCS(const char *s,
 
     /* 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 *PyUnicode_EncodeMBCS(const Py_UNICODE *p,
 {
     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);