Skip to content

Commit 620f682

Browse files
committed
Test that passing a non-string to sys.audit doesn't trigger an assert in debug builds.
1 parent ba8ac4d commit 620f682

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Lib/test/audit-tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,15 @@ def hook(event, args):
567567
_winapi.CreateNamedPipe(pipe_name, _winapi.PIPE_ACCESS_DUPLEX, 8, 2, 0, 0, 0, 0)
568568

569569

570+
def test_assert_unicode():
571+
import sys
572+
sys.addaudithook(lambda *args: None)
573+
try:
574+
sys.audit(9)
575+
except:
576+
pass
577+
578+
570579
if __name__ == "__main__":
571580
from test.support import suppress_msvcrt_asserts
572581

Lib/test/test_audit.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,11 @@ def test_winapi_createnamedpipe(self):
307307

308308
self.assertEqual(actual, expected)
309309

310+
def test_assert_unicode(self):
311+
returncode, events, stderr = self.run_python("test_assert_unicode")
312+
if returncode:
313+
self.fail(stderr)
314+
315+
310316
if __name__ == "__main__":
311317
unittest.main()

0 commit comments

Comments
 (0)