Skip to content

Create a new release to fix incompatibility with Python 3.14 #205

Description

@Random-Penguin
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.14/tkinter/__init__.py", line 2114, in __call__
    return self.func(*args)
           ~~~~~~~~~^^^^^^^
  File "/usr/lib/python3.14/tkinter/__init__.py", line 885, in callit
    func(*args, **kw)
    ~~~~^^^^^^^^^^^^^
  File "/opt/mrpython/PyInterpreter.py", line 91, in run_loop
    ok, report = interp.execute()
                 ~~~~~~~~~~~~~~^^
  File "/opt/mrpython/PyInterpreter.py", line 159, in execute
    ok = runner.execute(self.locals)
  File "/opt/mrpython/StudentRunner.py", line 107, in execute
    if not self.check_rules(self.report):
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/mrpython/StudentRunner.py", line 244, in check_rules
    if not self.check_types():
           ~~~~~~~~~~~~~~~~^^
  File "/opt/mrpython/StudentRunner.py", line 289, in check_types
    type_ctx = typecheck_from_ast(self.AST, self.filename, self.source)
  File "/opt/mrpython/typechecking/typechecker.py", line 3461, in typecheck_from_ast
    prog.build_from_ast(ast, filename, source)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/mrpython/typechecking/prog_ast.py", line 101, in build_from_ast
    fun_ast = FunctionDef(node)
  File "/opt/mrpython/typechecking/prog_ast.py", line 188, in __init__
    if isinstance(first_instr, ast.Expr) and isinstance(first_instr.value, ast.Str):
                                                                           ^^^^^^^
AttributeError: module 'ast' has no attribute 'Str'

According to the changelog, the ast module has removed the Str attribute in favor of Constant, of which Str has been an alias of since Python 3.8. This results in type checking failing with the above error in the CLI, while the GUI appears to be running indefinitely, waiting for the type checking subprocess to return.

To fix, unless you wish to maintain compatibility with Python <3.8 or I am missing something, you must replace every instance of ast.Str, along with potentially ast.Bytes, ast.Ellipsis, ast.NameConstant and ast.Num, with ast.Constant.

Additional info:

  • Machine: Arch Linux
  • Python version: 3.14.7
  • MrPython version: 5.1.6-beta (acquired through the AUR)

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions