Use PyUnicode_AsUnicodeAndSize() instead of PyUnicode_GET_SIZE()

This commit is contained in:
Victor Stinner 2011-10-11 21:55:01 +02:00
parent e459a0877e
commit beac78bb24
3 changed files with 15 additions and 9 deletions

View file

@ -2529,10 +2529,9 @@ posix_listdir(PyObject *self, PyObject *args)
po_wchars = L".";
len = 1;
} else {
po_wchars = PyUnicode_AsUnicode(po);
po_wchars = PyUnicode_AsUnicodeAndSize(po, &len);
if (po_wchars == NULL)
return NULL;
len = PyUnicode_GET_SIZE(po);
}
/* Overallocate for \\*.*\0 */
wnamebuf = malloc((len + 5) * sizeof(wchar_t));