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

python3: 'jinja2.utils.Cycler object' has no attribute 'next' #524

Closed
iffy opened this issue Dec 29, 2015 · 1 comment · Fixed by #525
Closed

python3: 'jinja2.utils.Cycler object' has no attribute 'next' #524

iffy opened this issue Dec 29, 2015 · 1 comment · Fixed by #525

Comments

@iffy
Copy link
Contributor

iffy commented Dec 29, 2015

The jinja2.utils.Cycler object no longer has a next() method in Python 3:

Running the following with Python 3:

from jinja2 import Environment

env = Environment()
t = env.from_string('''
{% set a = cycler('odd', 'even') %}
{{ a.next() }}
{{ a.next() }}
''')
result = t.render()
print(result)

Results in this error:

Traceback (most recent call last):
  File "example.py", line 9, in <module>
    result = t.render()
  File "/private/tmp/a/py3/lib/python3.4/site-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/private/tmp/a/py3/lib/python3.4/site-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/private/tmp/a/py3/lib/python3.4/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 3, in top-level template code
jinja2.exceptions.UndefinedError: 'jinja2.utils.Cycler object' has no attribute 'next'

I'm going to work around this by adding the new built-in next() function as an environment global.

@ThiefMaster
Copy link
Member

dup of #474 and there's a PR #493 but the author apparently never updated it with my suggestions...

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

Successfully merging a pull request may close this issue.

2 participants