Skip to content

SystemError caused by _interpreters.create() with invalid unicode argument #126223

@devdanzin

Description

@devdanzin

Bug report

Bug description:

It's possible to make a debug build of Python abort by passing an invalid Unicode argument to _interpreters.create(), resulting in SystemError: <built-in function create> returned a result with an exception set.

$ ./python -c "import _interpreters; _interpreters.create('\udc80')"
Fatal Python error: _Py_CheckFunctionResult: a function returned a result with an exception set
Python runtime state: initialized
UnicodeEncodeError: 'utf-8' codec can't encode character '\udc80' in position 0: surrogates not allowed

The above exception was the direct cause of the following exception:

SystemError: <built-in function create> returned a result with an exception set

Current thread 0x00007f0234dca740 (most recent call first):
  File "<string>", line 1 in <module>
Aborted

Found using fusil by @vstinner.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux, Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixesextension-modulesC modules in the Modules dirtopic-subinterpreterstype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions