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

Failed assertion in_PyUnicode_Equal fromcalculate_suggestions with non-string candidate #129573

Open
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump
@devdanzin

Description

@devdanzin

Crash report

What happened?

The interpreter will abort ifrunpy._run_module_code is called with invalid values:

importrunpyrunpy._run_module_code("A", {0:""},"")

Another way to trigger:

classParent:def__dir__(self):return [0]classWithNonStringAttrs(Parent):blech=NoneWithNonStringAttrs().bluch

Abort message:

python: Objects/unicodeobject.c:10799: _PyUnicode_Equal: Assertion `PyUnicode_Check(str2)' failed.Aborted (core dumped)

The suggestions machinery is the source of the issue, withcalculate_suggestions calling_PyUnicode_Equal(name, item) for an item that might not be unicode.

Only aborts in 3.12. In 3.13 and main it results in an error in the traceback machinery:

Exception ignored in the internal traceback machinery:Traceback (most recent call last):  File "/home/danzin/projects/upstream_cpython/Lib/traceback.py", line 139, in _print_exception_bltin    return print_exception(exc, limit=BUILTIN_EXCEPTION_LIMIT, file=file, colorize=colorize)  File "/home/danzin/projects/upstream_cpython/Lib/traceback.py", line 129, in print_exception    te = TracebackException(type(value), value, tb, limit=limit, compact=True)  File "/home/danzin/projects/upstream_cpython/Lib/traceback.py", line 1090, in __init__    suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name)  File "/home/danzin/projects/upstream_cpython/Lib/traceback.py", line 1531, in _compute_suggestion_error    return _suggestions._generate_suggestions(d, wrong_name)TypeError: all elements in 'candidates' must be strings[...]

Will submit a PR shortly.

Found usingfusil by@vstinner.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.12.8+ (heads/3.12:580d7810946, Feb 2 2025, 01:56:47) [GCC 13.3.0]

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp