Repository navigation
Implement Python 3.15 Windows event-log APIs #9086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """Check Windows event-log conversions without invoking host operations.""" | ||
|
|
||
| import sys | ||
|
|
||
| from testutils import assert_raises | ||
|
|
||
| if sys.platform == "win32": | ||
| import _winapi | ||
|
|
||
| # Every call fails before a host operation. ReportEvent overflow cases | ||
| # also retain an embedded NUL as an independent safety barrier. | ||
| assert _winapi.EVENTLOG_SUCCESS == 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This newly created snippet adds assertion logic, which is outside the only two test-file changes permitted by the root AGENTS.md reference: AGENTS.md:L273-L280 Useful? React with 👍 / 👎. |
||
| assert _winapi.EVENTLOG_ERROR_TYPE == 1 | ||
| assert _winapi.EVENTLOG_WARNING_TYPE == 2 | ||
| assert _winapi.EVENTLOG_INFORMATION_TYPE == 4 | ||
| assert _winapi.EVENTLOG_AUDIT_SUCCESS == 8 | ||
| assert _winapi.EVENTLOG_AUDIT_FAILURE == 16 | ||
|
|
||
| assert_raises(TypeError, _winapi.RegisterEventSource, 1, "source\0") | ||
| assert_raises(TypeError, _winapi.RegisterEventSource, None, 1) | ||
| assert_raises(TypeError, _winapi.RegisterEventSource, None, None) | ||
| assert_raises(ValueError, _winapi.RegisterEventSource, None, "source\0") | ||
| assert_raises(ValueError, _winapi.RegisterEventSource, "server\0", "source\0") | ||
| assert_raises(ValueError, _winapi.RegisterEventSource, "", "source\0") | ||
| assert_raises(TypeError, _winapi.DeregisterEventSource, "invalid handle") | ||
| assert_raises(TypeError, _winapi.DeregisterEventSource, None) | ||
| assert_raises( | ||
| TypeError, _winapi.ReportEvent, "invalid handle", 0, 0, 0, "message\0" | ||
| ) | ||
| assert_raises(ValueError, _winapi.ReportEvent, 0, 0, 0, 0, "message\0") | ||
| assert_raises(TypeError, _winapi.ReportEvent, 0, 0, 0, 0, None) | ||
| for index, bits in ((1, 16), (2, 16), (3, 32)): | ||
| for invalid, exception in ((-1, ValueError), (1 << bits, OverflowError)): | ||
| arguments = [0, 0, 0, 0, "message\0"] | ||
| arguments[index] = invalid | ||
| assert_raises(exception, _winapi.ReportEvent, *arguments) | ||
| arguments = [0, 0, 0, 0, "message\0"] | ||
| arguments[index] = "invalid integer" | ||
| assert_raises(TypeError, _winapi.ReportEvent, *arguments) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdlib_winapi.py