Skip to content

SystemError: AST constructor recursion depth mismatch #387

Open
@luhn

Description

@luhn

After upgrading to Python 3.11 and Chameleon 4.2.0, I'm encounter errors seemingly at random when rendering my templates.

SystemError: AST constructor recursion depth mismatch (before=174, after=138)

My rendering code is pretty straightforward. Each invocation instantiates a fresh PageTemplate

def _render_html(template_name, template_data):
    """
    Load the chameleon template and render it.

    This may be blocking and should not be called in the main reactor thread.

    """
    macro = PageTemplate(_load_file('emails/template.pt'))
    template_data['template'] = macro.macros['template']
    macro = PageTemplate(_load_file('emails/dw_template.pt'))
    template_data['dw_template'] = macro.macros['template']
    template = PageTemplate(
        _load_file('emails/{}.pt'.format(template_name)),
        encoding='utf8',
    )
    return template(**template_data)

I attempted to set CHAMELEON_EAGER=1 as suggested in #361, but the errors still persist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions