Bug 2322715 - python-chameleon fails to build with Python 3.14: AttributeError: module 'ast' has no attribute 'Str'
Summary: python-chameleon fails to build with Python 3.14: AttributeError: module 'ast...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-chameleon
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Fedora Infrastructure SIG
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.14
TreeView+ depends on / blocked
 
Reported: 2024-10-30 11:34 UTC by Karolina Surma
Modified: 2024-12-31 13:33 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-12-31 13:33:12 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2024-10-30 11:34:16 UTC
python-chameleon fails to build with Python 3.14.0a1.

_ TestZopePageTemplates.test_txt_files[inputs/hello_world.txt-outputs/hello_world.txt-None] _

self = <chameleon.tests.test_templates.TestZopePageTemplates object at 0x7fc845341a90>
input_path = 'inputs/hello_world.txt', output_path = 'outputs/hello_world.txt'
language = None

    @find_files(".txt")
    def test_txt_files(self, input_path, output_path, language):
        from chameleon.zpt.template import PageTextTemplateFile
>       self.execute(input_path, output_path, language, PageTextTemplateFile)

src/chameleon/tests/test_templates.py:675: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/chameleon/tests/test_templates.py:704: in execute
    template.cook_check()
src/chameleon/template.py:401: in cook_check
    self.cook(body)
src/chameleon/template.py:204: in cook
    program = self._cook(body, digest, names)
src/chameleon/template.py:301: in _cook
    source = self._compile(body, builtins)
src/chameleon/template.py:337: in _compile
    compiler = Compiler(
src/chameleon/compiler.py:1019: in __init__
    module.body += self.visit(node)
src/chameleon/compiler.py:1082: in visit
    iterator = visitor(node)
src/chameleon/compiler.py:1127: in visit_Module
    program = self.visit(node.program)
src/chameleon/compiler.py:1082: in visit
    iterator = visitor(node)
src/chameleon/compiler.py:1151: in visit_MacroProgram
    stmts = self.visit(macro)
src/chameleon/compiler.py:1084: in visit
    for key, group in itertools.groupby(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <chameleon.compiler.Compiler object at 0x7fc844648730>
node = <Macro name=None body=[<Context node=<Sequence items=[<Interpolation value=<Substitution "${'Hello world!'}\n" (1:0)> ...nslation=False default='"?"' default_marker='"?"' at 7fc84483a910>] at 7fc844838150> at 7fc844839c90>] at 7fc84483b950>

    def visit_Macro(self, node):
        body = []
    
        # Initialization
        body += template("__append = __stream.append")
        body += template("__re_amp = g_re_amp")
        body += template("__token = None")
        body += template("__re_needs_escape = g_re_needs_escape")
    
        body += emit_func_convert("__convert")
        body += emit_func_convert_and_escape("__quote")
    
        # Resolve defaults
        for name in self.defaults:
            body += template(
                "NAME = econtext[KEY]",
>               NAME=name, KEY=ast.Str(s="__" + name)
            )
E           AttributeError: module 'ast' has no attribute 'Str'

src/chameleon/compiler.py:1185: AttributeError


According to: https://docs.python.org/dev/whatsnew/3.14.html#id2

Remove the following classes. They were all deprecated since Python 3.8, and have emitted deprecation warnings since Python 3.12:
ast.Bytes
ast.Ellipsis
ast.NameConstant
ast.Num
ast.Str

Use ast.Constant instead. As a consequence of these removals, user-defined visit_Num, visit_Str, visit_Bytes, visit_NameConstant and visit_Ellipsis methods on custom ast.NodeVisitor subclasses will no longer be called when the NodeVisitor subclass is visiting an AST. Define a visit_Constant method instead.

Also, remove the following deprecated properties on ast.Constant, which were present for compatibility with the now-removed AST classes:
ast.Constant.n
ast.Constant.s

Use ast.Constant.value instead.
(Contributed by Alex Waygood in gh-119562.)


https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08189189-python-chameleon/

For all our attempts to build python-chameleon with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-chameleon/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.


Note You need to log in before you can comment on or make changes to this bug.