Skip to content

Commit c82e5ac

Browse files
committed
Using LPCWSTR convertor
1 parent f786db6 commit c82e5ac

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

Modules/_winapi.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,33 +3057,18 @@ Writes an entry at the end of the specified event log.
30573057
static PyObject *
30583058
_winapi_ReportEvent_impl(PyObject *module, HANDLE handle,
30593059
unsigned short type, unsigned short category,
3060-
unsigned int event_id, PyObject *string)
3061-
/*[clinic end generated code: output=8eb5e919369c9c6d input=6db2c51252f95b93]*/
3060+
unsigned int event_id, LPCWSTR string)
3061+
/*[clinic end generated code: output=4281230b70a2470a input=8fb3385b8e7a6d3d]*/
30623062
{
30633063
BOOL success;
3064-
LPCWSTR wide_string = NULL;
3065-
3066-
if (!PyUnicode_Check(string)) {
3067-
PyErr_SetString(PyExc_TypeError, "string must be a str");
3068-
return NULL;
3069-
}
3070-
3071-
wide_string = PyUnicode_AsWideCharString(string, NULL);
3072-
if (!wide_string) {
3073-
return NULL;
3074-
}
30753064

30763065
Py_BEGIN_ALLOW_THREADS
30773066
success = ReportEventW(handle, type, category, event_id, NULL, 1, 0,
3078-
&wide_string, NULL);
3067+
&string, NULL);
30793068
Py_END_ALLOW_THREADS
30803069

3081-
int ret = GetLastError();
3082-
3083-
PyMem_Free((void *)wide_string);
3084-
30853070
if (!success) {
3086-
return PyErr_SetFromWindowsErr(ret);
3071+
return PyErr_SetFromWindowsErr(0);
30873072
}
30883073

30893074
Py_RETURN_NONE;

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)