8000 Use Unicode unconditionally for _winapi.CreateFile (GH-114611) · python/cpython@74bd566 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74bd566

Browse files
authored
Use Unicode unconditionally for _winapi.CreateFile (GH-114611)
Currently it switches based on build settings, but argument clinic does not handle it correctly.
1 parent c95cdd0 commit 74bd566

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

Modules/_winapi.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ _winapi_ConnectNamedPipe_impl(PyObject *module, HANDLE handle,
439439
/*[clinic input]
440440
_winapi.CreateFile -> HANDLE
441441
442-
file_name: LPCTSTR
442+
file_name: LPCWSTR
443443
desired_access: DWORD
444444
share_mode: DWORD
445445
security_attributes: LPSECURITY_ATTRIBUTES
@@ -450,12 +450,12 @@ _winapi.CreateFile -> HANDLE
450450
[clinic start generated code]*/
451451

452452
static HANDLE
453-
_winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
453+
_winapi_CreateFile_impl(PyObject *module, LPCWSTR file_name,
454454
DWORD desired_access, DWORD share_mode,
455455
LPSECURITY_ATTRIBUTES security_attributes,
456456
DWORD creation_disposition,
457457
DWORD flags_and_attributes, HANDLE template_file)
458-
/*[clinic end generated code: output=417ddcebfc5a3d53 input=6423c3e40372dbd5]*/
458+
/*[clinic end generated code: output=818c811e5e04d550 input=1fa870ed1c2e3d69]*/
459459
{
460460
HANDLE handle;
461461

@@ -466,14 +466,15 @@ _winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
466466
}
467467

468468
Py_BEGIN_ALLOW_THREADS
469-
handle = CreateFile(file_name, desired_access,
470-
share_mode, security_attributes,
471-
creation_disposition,
472-
flags_and_attributes, template_file);
469+
handle = CreateFileW(file_name, desired_access,
470+
share_mode, security_attributes,
471+
creation_disposition,
472+
flags_and_attributes, template_file);
473473
Py_END_ALLOW_THREADS
474474

475-
if (handle == INVALID_HANDLE_VALUE)
475+
if (handle == INVALID_HANDLE_VALUE) {
476476
PyErr_SetFromWindowsErr(0);
477+
}
477478

478479
return handle;
479480
}

Modules/clinic/_winapi.c.h

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0