Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.14: assertion failure related to ast._const_node_type_names #810

Open
musicinmybrain opened this issue Mar 11, 2025 · 0 comments
Open
Labels
bug Unexpected or incorrect user-visible behavior

Comments

@musicinmybrain
Copy link

Describe the bug

In rope/base/ast.py, it’s expected that ast._const_node_type_names exists. Otherwise, the library falls back to a backport intended for Python 3.7 and older, and this assumption is confirmed with an assertion:

rope/rope/base/ast.py

Lines 7 to 22 in 55169bb

try:
# Suppress the mypy complaint: Module "ast" has no attribute "_const_node_type_names"
from ast import _const_node_type_names # type:ignore
except ImportError:
# backported from stdlib `ast`
assert sys.version_info < (3, 8)
_const_node_type_names = {
bool: "NameConstant", # should be before int
type(None): "NameConstant",
int: "Num",
float: "Num",
complex: "Num",
str: "Str",
bytes: "Bytes",
type(...): "Ellipsis",
}

However, as of Python 3.14.0a5, Python 3.14 also lacks ast._const_node_type_names, so importing rope.base.ast results in an assertion failure.

To Reproduce
Steps to reproduce the behavior:

$ git checkout https://github.com/python-rope/rope.git
$ cd rope
$ uv venv --python 3.14
$ source .venv/bin/activate
(rope) $ uv pip install -e .[dev]
(rope) $ python -m pytest
  1. Describe the error or unexpected result that you are getting
ImportError while loading conftest '/home/ben/src/forks/rope/ropetest/conftest.py'.
ropetest/conftest.py:10: in <module>
    from ropetest import testutils
ropetest/testutils.py:9: in <module>
    import rope.base.project
rope/base/project.py:13: in <module>
    from rope.base import exceptions, history, pycore, taskhandle, utils
rope/base/pycore.py:6: in <module>
    import rope.base.libutils
rope/base/libutils.py:7: in <module>
    from rope.base import pyobjectsdef, taskhandle, utils
rope/base/pyobjectsdef.py:1: in <module>
    import rope.base.builtins
rope/base/builtins.py:6: in <module>
    import rope.base.evaluate
rope/base/evaluate.py:5: in <module>
    import rope.base.pynames
rope/base/pynames.py:5: in <module>
    import rope.base.pyobjects
rope/base/pyobjects.py:3: in <module>
    from rope.base import ast, exceptions, utils
rope/base/ast.py:12: in <module>
    assert sys.version_info < (3, 8)
E   AssertionError

Screenshots
If applicable, add screenshots to help explain your problem.

Editor information (please complete the following information):

  • Project Python version: ...
  • Rope Python version: ...
  • Rope version: ...
  • Text editor/IDE and version: ...

Additional context
Add any other context about the problem here.

@musicinmybrain musicinmybrain added the bug Unexpected or incorrect user-visible behavior label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect user-visible behavior
Projects
None yet
Development

No branches or pull requests

1 participant