Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e751c3

Browse files
committed
Mark Hammond withdraws his fix -- the size includes the trailing 0 so
a size of 0 *is* illegal.
1 parent a6edfd9 commit 4e751c3

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

Objects/unicodeobject.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ PyObject *PyUnicode_DecodeMBCS(const char *s,
15551555

15561556
/* First get the size of the result */
15571557
DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0);
1558-
if (size > 0 && usize==0)
1558+
if (usize==0)
15591559
return PyErr_SetFromWindowsErrWithFilename(0, NULL);
15601560

15611561
v = _PyUnicode_New(usize);
@@ -1578,14 +1578,9 @@ PyObject *PyUnicode_EncodeMBCS(const Py_UNICODE *p,
15781578
{
15791579
PyObject *repr;
15801580
char *s;
1581-
DWORD mbcssize;
1582-
1583-
/* If there are no characters, bail now! */
1584-
if (size==0)
1585-
return PyString_FromString("");
15861581

15871582
/* First get the size of the result */
1588-
mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL);
1583+
DWORD mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL);
15891584
if (mbcssize==0)
15901585
return PyErr_SetFromWindowsErrWithFilename(0, NULL);
15911586

0 commit comments

Comments
 (0)