Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 72861:6358e5d29dea
Use PyUnicode_AsUnicodeAndSize() instead of PyUnicode_GET_SIZE()
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Tue, 11 Oct 2011 21:55:01 +0200 |
| parents | 81380082d216 |
| children | 4be55c2c2356 |
line wrap: on
line diff
--- a/Python/import.c Tue Oct 11 20:58:41 2011 +0200 +++ b/Python/import.c Tue Oct 11 21:55:01 2011 +0200 @@ -2282,6 +2282,8 @@ WIN32_FIND_DATAW data; HANDLE h; int cmp; + wchar_t *wname; + Py_ssizet wname_len; if (Py_GETENV("PYTHONCASEOK") != NULL) return 1; @@ -2294,9 +2296,12 @@ return 0; } FindClose(h); - cmp = wcsncmp(data.cFileName, - PyUnicode_AS_UNICODE(name), - PyUnicode_GET_SIZE(name)); + + wname = PyUnicode_AsUnicodeAndSize(name, &wname_len); + if (wname == NULL) + return -1; + + cmp = wcsncmp(data.cFileName, wname, wname_len); return cmp == 0; #elif defined(USE_CASE_OK_BYTES) int match;
