Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit80eec52

Browse files
devdanzinpicnixzJelleZijlstra
authored
gh-126018: Avoid aborting due to unnecessary assert insys.audit (#126020)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parentdc76a4a commit80eec52

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

‎Lib/test/audit-tests.py‎

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

569569

570+
deftest_assert_unicode():
571+
importsys
572+
sys.addaudithook(lambda*args:None)
573+
try:
574+
sys.audit(9)
575+
exceptTypeError:
576+
pass
577+
else:
578+
raiseRuntimeError("Expected sys.audit(9) to fail.")
579+
580+
570581
if__name__=="__main__":
571582
fromtest.supportimportsuppress_msvcrt_asserts
572583

‎Lib/test/test_audit.py‎

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

308308
self.assertEqual(actual,expected)
309309

310+
deftest_assert_unicode(self):
311+
# See gh-126018
312+
returncode,_,stderr=self.run_python("test_assert_unicode")
313+
ifreturncode:
314+
self.fail(stderr)
315+
316+
310317
if__name__=="__main__":
311318
unittest.main()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a crash in:func:`sys.audit` when passing a non-string as first argument
2+
and Python was compiled in debug mode.

‎Python/sysmodule.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,6 @@ sys_audit(PyObject *self, PyObject *const *args, Py_ssize_t argc)
519519
}
520520

521521
assert(args[0]!=NULL);
522-
assert(PyUnicode_Check(args[0]));
523522

524523
if (!should_audit(tstate->interp)) {
525524
Py_RETURN_NONE;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp