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

seg fault when rendering template under Python 2.7 with Jinja2 2.5.5 #4

Closed
scyclops opened this issue Oct 25, 2010 · 9 comments
Closed

Comments

@scyclops
Copy link

I have a template that starts out like this:

When it tries to render I get a seg fault. I switched to an older version of Jinja2 (2.2.1) that the template had previously rendered with and I got this error:

"/usr/local/lib/python2.7/site-packages/Jinja2-2.2.1-py2.7.egg/jinja2/environment.py",
line 839, in from_code
exec code in namespace
File "/var/www/templates/post_alert.html", line 1, in

TypeError: an integer is required

And I also saw the same traceback but with the exception "ImportError: No module named division" but I'm not sure how to duplicate that. My setup uses a FileSystemLoader with a MemcachedBytecodeCache and autoescape=True, auto_reload=True, line_statement_prefix='#'

I had previously been using Python 2.6 to render this template with no problems using Jinja2 2.2.1.

In any case, my hack to fix this problem was to change the body style: font:13px/1.5
to just: font:13px

@mitsuhiko
Copy link
Contributor

The template is not complete. Please provide a full testcase.

@scyclops
Copy link
Author

The template code doesn't seem to be displaying properly above so I've put it here instead:

http://gist.github.com/645489

@mitsuhiko
Copy link
Contributor

That problem might be caused by having leftovers from Python 2.6 in your cache and now Python barks on broken bytecodes. You seem to have fixed it by changing the timestamp of the templates. To fix this you might just have to flush your cache.

@scyclops
Copy link
Author

Ahhh, that makes sense, because the memory cache never got flushed.

@mitsuhiko
Copy link
Contributor

Can you confirm if this fixes the problem? If yes I will close the ticket.

@scyclops
Copy link
Author

Yep, I cleared the cache and now it works with the old template.

@themartorana
Copy link

I'd like to make a suggestion that clearing the byte code cache after installing a new version of Python be made part of the documentation. I spent a half-day pulling my hair out on this one (not your fault) until I fell upon this posting.

Thanks!

@mitsuhiko
Copy link
Contributor

The proper solution would be detecting that. I will try to see if that can be accomplished.

@mitsuhiko
Copy link
Contributor

Jinja 2.6 will detect that. For earlier versions I added a note to the changelog, I hope that Google picks it up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants