summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-05-04 15:52:20 (GMT)
committerGuido van Rossum <guido@python.org>2000-05-04 15:52:20 (GMT)
commit03e29f1ae9999ae341c9f1a9c9bba15ddfa6e7b1 (patch)
tree38d0ebd790b4b925571d425a2f17563e6643068a
parent301f3f6baa074f8ea4d430fb73ebc84a37b465bd (diff)
downloadcpython-03e29f1ae9999ae341c9f1a9c9bba15ddfa6e7b1.zip
cpython-03e29f1ae9999ae341c9f1a9c9bba15ddfa6e7b1.tar.gz
cpython-03e29f1ae9999ae341c9f1a9c9bba15ddfa6e7b1.tar.bz2
Mark Hammond should get his act into gear (his words :-). Zero length
strings _are_ valid!
-rw-r--r--Objects/unicodeobject.c9
1 files changed, 7 insertions, 2 deletions
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 @@ 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);