Crash report
What happened?
It's possible to make the interpreter abort by calling _interpreters.run_string with an instance of a subclass of str as the script argument:
import _interpreters class weird_str(str): pass _interpreters.create() _interpreters.run_string(1, weird_str('1')) python: ./Modules/_interpretersmodule.c:333: get_code_str: Assertion `PyUnicode_CheckExact(arg) && (check_code_str((PyUnicodeObject *)arg) == NULL)' failed. Aborted (core dumped)
This happens because, after a check that arg is a str or subclass, there's an assertion that arg is exactly an instance of str:
if (PyUnicode_Check(arg)) { assert(PyUnicode_CheckExact(arg) && (check_code_str((PyUnicodeObject *)arg) == NULL));
Found using fusil by @vstinner.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a6+ (heads/main:04bc681e7cf, Apr 4 2025, 12:38:19) [GCC 11.4.0]