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

Skip to content

Commit 102569d

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 f9c5056 commit 102569d

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
@@ -441,7 +441,7 @@ _winapi_ConnectNamedPipe_impl(PyObject *module, HANDLE handle,
441441
/*[clinic input]
442442
_winapi.CreateFile -> HANDLE
443443
444-
file_name: LPCTSTR
444+
file_name: LPCWSTR
445445
desired_access: DWORD
446446
share_mode: DWORD
447447
security_attributes: LPSECURITY_ATTRIBUTES
@@ -452,12 +452,12 @@ _winapi.CreateFile -> HANDLE
452452
[clinic start generated code]*/
453453

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

@@ -468,14 +468,15 @@ _winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
468468
}
469469

470470
Py_BEGIN_ALLOW_THREADS
471-
handle = CreateFile(file_name, desired_access,
472-
share_mode, security_attributes,
473-
creation_disposition,
474-
flags_and_attributes, template_file);
471+
handle = CreateFileW(file_name, desired_access,
472+
share_mode, security_attributes,
473+
creation_disposition,
474+
flags_and_attributes, template_file);
475475
Py_END_ALLOW_THREADS
476476

477-
if (handle == INVALID_HANDLE_VALUE)
477+
if (handle == INVALID_HANDLE_VALUE) {
478478
PyErr_SetFromWindowsErr(0);
479+
}
479480

480481
return handle;
481482
}

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