From 63ddd28cf3e4a9a11a39d03418c5ad92785af4ff Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 18 Jul 2024 01:02:08 -0700 Subject: [PATCH] gh-121921: Make bogus_code_obj.py crash the interpreter (#121922) --- Lib/test/crashers/bogus_code_obj.py | 8 ++++---- .../Tests/2024-07-17-08-25-06.gh-issue-121921.HW8CIS.rst | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2024-07-17-08-25-06.gh-issue-121921.HW8CIS.rst diff --git a/Lib/test/crashers/bogus_code_obj.py b/Lib/test/crashers/bogus_code_obj.py index e71b3582cf2..b3ff07995c9 100644 --- a/Lib/test/crashers/bogus_code_obj.py +++ b/Lib/test/crashers/bogus_code_obj.py @@ -12,8 +12,8 @@ the user build or load random bytecodes anyway. Otherwise, this is a """ -import types +def f(): + pass -co = types.CodeType(0, 0, 0, 0, 0, 0, b'\x04\x00\x71\x00', - (), (), (), '', '', 1, b'') -exec(co) +f.__code__ = f.__code__.replace(co_code=b"") +f() diff --git a/Misc/NEWS.d/next/Tests/2024-07-17-08-25-06.gh-issue-121921.HW8CIS.rst b/Misc/NEWS.d/next/Tests/2024-07-17-08-25-06.gh-issue-121921.HW8CIS.rst new file mode 100644 index 00000000000..ef14fa9dfbd --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2024-07-17-08-25-06.gh-issue-121921.HW8CIS.rst @@ -0,0 +1,2 @@ +Update ``Lib/test/crashers/bogus_code_obj.py`` so that it crashes properly +again.