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
Confusing error w/ Python 3 and templates that use iteritems() #150
Comments
Dictionaries do not have iteritem methods in 3.x. You will need to change to |
It would be nice if there were a built-in filter for this and other python 2to3 oddities. |
Unless you have huge dicts, using |
Here's a way to get around it: import six
Then in your template: use: It's kinda ugly, but it does work. |
using .items() instead .iteritems() worked |
Consider:
When run w/ Python 3, you get an confusing exception:
This is because the template uses iteritems, which is removed in Python 3. From the above exception, it's not clear the problem is in the template—it should be.
It works for normal Python 3 dictionaries because lines 205–210 of Jinja2 v2.61 add back an iteritems method:
What's the best way to fix this? Better detect dict-like objects, try to spit out a better error, etc?
The text was updated successfully, but these errors were encountered: