Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
bpo-42658: Using LCMapStringEx in ntpath.normcase#32010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
060cd716ecbc48c1429b981be3816108d203b4a5cbef669416c0366b6c6f2e215749b87b2c62ca89adc04119cc28a63de26789cd9d4303717e0dcf8File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Support native Windows case-insensitive path comparisons by using | ||
| ``LCMapStringEx`` instead of :func:`str.lower` in :func:`ntpath.normcase`. | ||
| Add ``LCMapStringEx`` to the :mod:`_winapi` module. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1512,6 +1512,50 @@ _winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size) | ||
| } | ||
| } | ||
| /*[clinic input] | ||
| _winapi.LCMapStringEx | ||
| locale: LPCWSTR | ||
| flags: DWORD | ||
| src: LPCWSTR | ||
| [clinic start generated code]*/ | ||
| static PyObject * | ||
| _winapi_LCMapStringEx_impl(PyObject *module, LPCWSTR locale, DWORD flags, | ||
| LPCWSTR src) | ||
| /*[clinic end generated code: output=cf4713d80e2b47c9 input=9fe26f95d5ab0001]*/ | ||
| { | ||
| if (flags & (LCMAP_SORTHANDLE | LCMAP_HASH | LCMAP_BYTEREV | | ||
| LCMAP_SORTKEY)) { | ||
| return PyErr_Format(PyExc_ValueError, "unsupported flags"); | ||
| } | ||
| int dest_size = LCMapStringEx(locale, flags, src, -1, NULL, 0, | ||
| NULL, NULL, 0); | ||
| if (dest_size == 0) { | ||
| return PyErr_SetFromWindowsErr(0); | ||
| } | ||
| wchar_t* dest = PyMem_NEW(wchar_t, dest_size); | ||
aisk marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| if (dest == NULL) { | ||
| return PyErr_NoMemory(); | ||
| } | ||
| int nmapped = LCMapStringEx(locale, flags, src, -1, dest, dest_size, | ||
| NULL, NULL, 0); | ||
| if (nmapped == 0) { | ||
| DWORD error = GetLastError(); | ||
| PyMem_DEL(dest); | ||
| return PyErr_SetFromWindowsErr(error); | ||
| } | ||
| PyObject *ret = PyUnicode_FromWideChar(dest, dest_size - 1); | ||
| PyMem_DEL(dest); | ||
| return ret; | ||
| } | ||
| /*[clinic input] | ||
| _winapi.ReadFile | ||
| @@ -2023,6 +2067,7 @@ static PyMethodDef winapi_functions[] = { | ||
| _WINAPI_OPENFILEMAPPING_METHODDEF | ||
| _WINAPI_OPENPROCESS_METHODDEF | ||
| _WINAPI_PEEKNAMEDPIPE_METHODDEF | ||
| _WINAPI_LCMAPSTRINGEX_METHODDEF | ||
| _WINAPI_READFILE_METHODDEF | ||
| _WINAPI_SETNAMEDPIPEHANDLESTATE_METHODDEF | ||
| _WINAPI_TERMINATEPROCESS_METHODDEF | ||
| @@ -2160,6 +2205,22 @@ static int winapi_exec(PyObject *m) | ||
| WINAPI_CONSTANT(F_DWORD, FILE_TYPE_PIPE); | ||
| WINAPI_CONSTANT(F_DWORD, FILE_TYPE_REMOTE); | ||
| WINAPI_CONSTANT("u", LOCALE_NAME_INVARIANT); | ||
| WINAPI_CONSTANT(F_DWORD, LOCALE_NAME_MAX_LENGTH); | ||
| WINAPI_CONSTANT("u", LOCALE_NAME_SYSTEM_DEFAULT); | ||
| WINAPI_CONSTANT("u", LOCALE_NAME_USER_DEFAULT); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_FULLWIDTH); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_HALFWIDTH); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_HIRAGANA); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_KATAKANA); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_LINGUISTIC_CASING); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_LOWERCASE); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_SIMPLIFIED_CHINESE); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_TITLECASE); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_TRADITIONAL_CHINESE); | ||
| WINAPI_CONSTANT(F_DWORD, LCMAP_UPPERCASE); | ||
| WINAPI_CONSTANT("i", NULL); | ||
| return 0; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.