Skip to content

Commit 3a7aca4

Browse files
committed
Add constants
1 parent 30242e0 commit 3a7aca4

File tree

7 files changed

+45
-42
lines changed

7 files changed

+45
-42
lines changed

Include/internal/pycore_global_objects_fini_generated.h

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

Include/internal/pycore_global_strings.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,7 @@ struct _Py_global_strings {
428428
STRUCT_FOR_ID(env)
429429
STRUCT_FOR_ID(errors)
430430
STRUCT_FOR_ID(event)
431-
STRUCT_FOR_ID(event_category)
432431
STRUCT_FOR_ID(event_id)
433-
STRUCT_FOR_ID(event_type)
434432
STRUCT_FOR_ID(eventmask)
435433
STRUCT_FOR_ID(exc)
436434
STRUCT_FOR_ID(exc_type)

Include/internal/pycore_runtime_init_generated.h

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

Include/internal/pycore_unicodeobject_generated.h

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

Lib/test/test_winapi.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,18 @@ def test_report_event(self):
179179
# Test with strings and raw data
180180
test_strings = ["Test message 1", "Test message 2"]
181181
test_data = b"test raw data"
182-
_winapi.ReportEvent(handle, 4, 1, 1002, test_strings, test_data)
182+
_winapi.ReportEvent(handle, _winapi.EVENTLOG_SUCCESS, 1, 1002,
183+
test_strings, test_data)
183184

184185
# Test with empty strings list
185-
_winapi.ReportEvent(handle, 2, 0, 1003, [])
186+
_winapi.ReportEvent(handle, _winapi.EVENTLOG_AUDIT_FAILURE ,2, 0, 1003,
187+
[])
186188

187189
with self.assertRaisesRegex(OSError, '[WinError 6]'):
188-
_winapi.ReportEvent(_winapi.INVALID_HANDLE_VALUE, 1, 0, 1001, [], test_data)
190+
_winapi.ReportEvent(_winapi.INVALID_HANDLE_VALUE,
191+
_winapi.EVENTLOG_AUDIT_SUCCESS, 0, 1001, [],
192+
test_data)
189193

190194
with self.assertRaisesRegex(TypeError, 'All strings must be unicode'):
191-
_winapi.ReportEvent(handle, 1, 0, 1001, ["string", 123])
195+
_winapi.ReportEvent(handle, _winapi.EVENTLOG_ERROR_TYPE, 0, 1001,
196+
["string", 123])

Modules/_winapi.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,12 +2986,14 @@ _winapi.RegisterEventSource -> HANDLE
29862986
source_name: LPCWSTR
29872987
The name of the event source to register.
29882988
/
2989+
2990+
Retrieves a registered handle to the specified event log.
29892991
[clinic start generated code]*/
29902992

29912993
static HANDLE
29922994
_winapi_RegisterEventSource_impl(PyObject *module, LPCWSTR unc_server_name,
29932995
LPCWSTR source_name)
2994-
/*[clinic end generated code: output=e376c8950a89ae8f input=16ae3c812a905cab]*/
2996+
/*[clinic end generated code: output=e376c8950a89ae8f input=9642e69236d0a14e]*/
29952997
{
29962998
HANDLE handle;
29972999

@@ -3013,11 +3015,13 @@ _winapi.DeregisterEventSource
30133015
handle: HANDLE
30143016
The handle to the event log to be deregistered.
30153017
/
3018+
3019+
Closes the specified event log.
30163020
[clinic start generated code]*/
30173021

30183022
static PyObject *
30193023
_winapi_DeregisterEventSource_impl(PyObject *module, HANDLE handle)
3020-
/*[clinic end generated code: output=7387ff34c7358bce input=0973c68eddcfd5a7]*/
3024+
/*[clinic end generated code: output=7387ff34c7358bce input=947593cf67641f16]*/
30213025
{
30223026
BOOL success;
30233027

@@ -3036,23 +3040,25 @@ _winapi.ReportEvent
30363040
30373041
handle: HANDLE
30383042
The handle to the event log.
3039-
event_type: int
3043+
type: int
30403044
The type of event being reported.
3041-
event_category: int
3045+
category: int
30423046
The event category.
30433047
event_id: int
30443048
The event identifier.
30453049
strings: object(subclass_of='&PyList_Type')
30463050
A list of strings to be inserted into the event message.
30473051
raw_data: Py_buffer = None
30483052
The raw data for the event.
3053+
3054+
Writes an entry at the end of the specified event log.
30493055
[clinic start generated code]*/
30503056

30513057
static PyObject *
3052-
_winapi_ReportEvent_impl(PyObject *module, HANDLE handle, int event_type,
3053-
int event_category, int event_id, PyObject *strings,
3058+
_winapi_ReportEvent_impl(PyObject *module, HANDLE handle, int type,
3059+
int category, int event_id, PyObject *strings,
30543060
Py_buffer *raw_data)
3055-
/*[clinic end generated code: output=9066f114cdfdf5f2 input=fade978a0b25e611]*/
3061+
/*[clinic end generated code: output=62348d38f92d26e8 input=4ac507ddabbf91ca]*/
30563062
{
30573063
BOOL success;
30583064
LPCWSTR *string_array = NULL;
@@ -3098,7 +3104,7 @@ _winapi_ReportEvent_impl(PyObject *module, HANDLE handle, int event_type,
30983104
}
30993105

31003106
Py_BEGIN_ALLOW_THREADS
3101-
success = ReportEventW(handle, event_type, event_category, event_id,
3107+
success = ReportEventW(handle, type, category, event_id,
31023108
NULL, num_strings, data_size,
31033109
string_array, data);
31043110
Py_END_ALLOW_THREADS
@@ -3220,6 +3226,12 @@ static int winapi_exec(PyObject *m)
32203226
WINAPI_CONSTANT(F_DWORD, ERROR_PIPE_CONNECTED);
32213227
WINAPI_CONSTANT(F_DWORD, ERROR_PRIVILEGE_NOT_HELD);
32223228
WINAPI_CONSTANT(F_DWORD, ERROR_SEM_TIMEOUT);
3229+
WINAPI_CONSTANT(F_DWORD, EVENTLOG_SUCCESS);
3230+
WINAPI_CONSTANT(F_DWORD, EVENTLOG_AUDIT_FAILURE);
3231+
WINAPI_CONSTANT(F_DWORD, EVENTLOG_AUDIT_SUCCESS);
3232+
WINAPI_CONSTANT(F_DWORD, EVENTLOG_ERROR_TYPE);
3233+
WINAPI_CONSTANT(F_DWORD, EVENTLOG_INFORMATION_TYPE);
3234+
WINAPI_CONSTANT(F_DWORD, EVENTLOG_WARNING_TYPE);
32233235
WINAPI_CONSTANT(F_DWORD, FILE_FLAG_FIRST_PIPE_INSTANCE);
32243236
WINAPI_CONSTANT(F_DWORD, FILE_FLAG_OVERLAPPED);
32253237
WINAPI_CONSTANT(F_DWORD, FILE_GENERIC_READ);

Modules/clinic/_winapi.c.h

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

0 commit comments

Comments
 (0)