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

SystemError AST constructor recursion depth mismatch error on Python 3.11 #361

Closed
mikeckennedy opened this issue Dec 14, 2022 · 8 comments
Closed

Comments

@mikeckennedy
Copy link

Hey there. Love Chameleon. But since upgrading our site to run on 3.11, we've been getting a fair number of errors like this:

SystemError: AST constructor recursion depth mismatch (before=396, after=241)

on chameleon/astutil.py in parse at line 46. Any idea what's happening? Most of the time the pages run fine, but some of the time, we get this.

@malthe
Copy link
Owner

malthe commented Dec 14, 2022

It might be that you've got the same template which is being rendered from different call sites such that the stack depth could vary between runs.

What happens if you use the environment variable CHAMELEON_EAGER=1 – ?

@mikeckennedy
Copy link
Author

mikeckennedy commented Dec 15, 2022

Thanks @malthe Here's what I get:

pyramid.httpexceptions.HTTPNotFound: The resource could not be found.

During handling of the above exception, another exception occurred:
    d['__loader'] = self._loader
AttributeError: 'PyramidPageTemplateFile' object has no attribute '_loader'

Does that tell you what's happening? I don't know what to make of this. Obviously, without this setting there is no HTTPNotFound error.

This code has been mostly unchanged for a long time and this error only started appearing on Python 3.11 (though it may have been hiding in there somewhere before).

@malthe
Copy link
Owner

malthe commented Dec 15, 2022

@mikeckennedy I have fixed this issue; are you able to apply this patch to see if we're getting any result out of CHAMELEON_EAGER=1 now?

@mikeckennedy
Copy link
Author

H @malthe i. I tried it out. I think it fixes it. Certainly no more errors that I could find. Thank you very much!

@malthe
Copy link
Owner

malthe commented Dec 16, 2022

I'm closing this one out because I think the root cause is that the stack is too deep which is out of our control. Eager parsing is a remedy in this case (which has now been fixed).

@malthe malthe closed this as completed Dec 16, 2022
@mikeckennedy
Copy link
Author

Awesome, thanks. Do I need to set CHAMELEON_EAGER=1 on my servers? It sounds like I should.

@malthe
Copy link
Owner

malthe commented Dec 16, 2022

@mikeckennedy released now as https://pypi.org/project/Chameleon/3.10.2/.

Yes – you would have to use that environment variables on your servers, simply because of how your app apparently works. Well, that's our "working theory" about it at least ...

@mikeckennedy
Copy link
Author

Great, thanks for the info. That’s fine by me. Just want to make sure I’m “doing it right.” :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants