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

Skip to content

Commit d7cbb04

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 c09eae3 commit d7cbb04

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

Modules/_winapi.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ _winapi_ConnectNamedPipe_impl(PyObject *module, HANDLE handle,
451451
/*[clinic input]
452452
_winapi.CreateFile -> HANDLE
453453
454-
file_name: LPCTSTR
454+
file_name: LPCWSTR
455455
desired_access: DWORD
456456
share_mode: DWORD
457457
security_attributes: LPSECURITY_ATTRIBUTES
@@ -462,12 +462,12 @@ _winapi.CreateFile -> HANDLE
462462
[clinic start generated code]*/
463463

464464
static HANDLE
465-
_winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
465+
_winapi_CreateFile_impl(PyObject *module, LPCWSTR file_name,
466466
DWORD desired_access, DWORD share_mode,
467467
LPSECURITY_ATTRIBUTES security_attributes,
468468
DWORD creation_disposition,
469469
DWORD E2DC flags_and_attributes, HANDLE template_file)
470-
/*[clinic end generated code: output=417ddcebfc5a3d53 input=6423c3e40372dbd5]*/
470+
/*[clinic end generated code: output=818c811e5e04d550 input=1fa870ed1c2e3d69]*/
471471
{
472472
HANDLE handle;
473473

@@ -478,14 +478,15 @@ _winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
478478
}
479479

480480
Py_BEGIN_ALLOW_THREADS
481-
handle = CreateFile(file_name, desired_access,
482-
share_mode, security_attributes,
483-
creation_disposition,
484-
flags_and_attributes, template_file);
481+
handle = CreateFileW(file_name, desired_access,
482+
share_mode, security_attributes,
483+
creation_disposition,
484+
flags_and_attributes, template_file);
485485
Py_END_ALLOW_THREADS
486486

487-
if (handle == INVALID_HANDLE_VALUE)
487+
if (handle == INVALID_HANDLE_VALUE) {
488488
PyErr_SetFromWindowsErr(0);
489+
}
489490

490491
return handle;
491492
}

Modules/clinic/_winapi.c.h

Lines changed: 10 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