Skip to content

ast.parse raises SystemError: <class 'UnicodeDecodeError'> returned a result with an error set #134021

Not planned
@gabe-sherman

Description

@gabe-sherman

Bug report

Bug description:

The below code triggers the following exception message: SystemError: <class 'UnicodeDecodeError'> returned a result with an error set. On later Python versions(>3.9), this shows up as just a UnicodeDecodeError, so it seems like the issue does not occur in later versions. I tried checking to see if this was known to exist in version 3.9, but didn't see anything, so I am reporting it here. Note that the type_comments argument must be set to True in order for this to occur.

Reproducer

import ast 
d = b'def hello(*onRlionRRasR,#type:RR,rRBRliRRf, o:\n f, o:\n ionRleloionRRasR,#type:RR,rRBRl\x8fRRf, o:\n cRRRlction= la:::::\x1c:\xad\xa2"\n'
parseval1 = ast.parse(d, type_comments = True)

Trace

Traceback (most recent call last):
  File "rep.py", line 5, in <module>
    ast.parse(d, type_comments = True)
  File "/usr/lib/python3.9/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
SystemError: <class 'UnicodeDecodeError'> returned a result with an error set

CPython versions tested on:

3.9

Operating systems tested on:

Linux

Activity

ronaldoussoren

ronaldoussoren commented on May 14, 2025

@ronaldoussoren
Contributor

3.9 only receives security fixes at this time and this is not a security issue.

Also note that 3.9 will go to end of life by the end of the year (which means it will receive no further updates from us from that point forward, not even security updates)

sergey-miryanov

sergey-miryanov commented on May 15, 2025

@sergey-miryanov
Contributor

@gabe-sherman It would be wonderful if you point in following issues that you are fuzzing.

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

    3.9only security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      `ast.parse` raises `SystemError: <class 'UnicodeDecodeError'> returned a result with an error set` · Issue #134021 · python/cpython

      Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

      Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant