summaryrefslogtreecommitdiff
path: root/Python/import.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-11 21:55:01 +0200
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-11 21:55:01 +0200
commitbeac78bb242ba56088570d9df3a852f581adc0d5 (patch)
tree23482d5390130c302c2783344903218a1ab229aa /Python/import.c
parente459a0877e0ca76e3af1057722a0e366395c661f (diff)
downloadcpython-git-beac78bb242ba56088570d9df3a852f581adc0d5.tar.gz
Use PyUnicode_AsUnicodeAndSize() instead of PyUnicode_GET_SIZE()
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/import.c b/Python/import.c
index 3d6c6ed1d4..6f564a65da 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -2282,6 +2282,8 @@ case_ok(PyObject *filename, Py_ssize_t prefix_delta, PyObject *name)
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 @@ case_ok(PyObject *filename, Py_ssize_t prefix_delta, PyObject *name)
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;