Skip to content

Failed assertion in codegen_nameop #133516

Closed

Description

@TERESH1

Crash report

What happened?

>>> compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
python: Python/codegen.c:3189: int codegen_nameop(compiler *, location, identifier, expr_context_ty): Assertion `!_PyUnicode_EqualToASCIIString(name, "None") && !_PyUnicode_EqualToASCIIString(name, "True") && !_PyUnicode_EqualToASCIIString(name, "False")' failed.
Aborted (core dumped)

The _PyPegen_new_identifier function normalizes to NFKC non-ASCII strings, which allows you to set keywords (None, True, False) with a different character representation as an identifier.

Found by Linux Verification Center (portal.linuxtesting.ru) with libFuzzer
Author S.Tereshin (s.tereshin@fobos-nt.ru)

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

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

Python 3.14.0a7+ (heads/main-dirty:3dfed2309, May 6 2025, 13:36:58) [Clang 18.1.8 (Fedora 18.1.8-1.fc40)]

Linked PRs

Activity

  1. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    on May 6, 2025
  2. added a commit that references this issue on May 6, 2025
    17aae76
  3. ZeroIntensity commented on May 6, 2025

    @ZeroIntensity
    Member

    I couldn't reproduce this:

    Python 3.14.0a7+ (heads/main:3dfed23092, May  6 2025, 16:44:44) [GCC 14.2.1 20250207] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
    Traceback (most recent call last):
      File "<python-input-0>", line 1, in <module>
        compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
        ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ValueError: identifier field can't represent 'False' constant
    
  4. TERESH1 commented on May 7, 2025

    @TERESH1
    ContributorAuthor

    I couldn't reproduce this:

    Python 3.14.0a7+ (heads/main:3dfed23092, May  6 2025, 16:44:44) [GCC 14.2.1 20250207] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
    Traceback (most recent call last):
      File "<python-input-0>", line 1, in <module>
        compile(source=b'Fal\xc5\xbfe', filename="<test>", mode="exec")
        ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ValueError: identifier field can't represent 'False' constant
    

    Configure without --with-pydebug, only --with-assertions

  5. added 2 commits that reference this issue on May 7, 2025
  6. added 2 commits that reference this issue on May 8, 2025
  7. added a commit that references this issue on May 8, 2025
  8. added a commit that references this issue on Jul 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-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