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

IndentationError: expected an indented block on updating to 2.9.3 #651

Closed
Garito opened this issue Jan 9, 2017 · 12 comments

Comments

@Garito
Copy link

commented Jan 9, 2017

Traceback (most recent call last):
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/flask/app.py", line 1994, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/flask_debugtoolbar/__init__.py", line 125, in dispatch_request
    return view_func(**req.view_args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cProfile.py", line 149, in runcall
    return func(*args, **kw)
  File "/Users/garito/TimeFounder/App/0.3/TimeFounder/__init__.py", line 491, in tree
    method = getattr(obj, action)
  File "/Users/garito/TimeFounder/App/0.3/TimeFounder/paper.py", line 42, in __getattr__
    return getattr(self, runner["method"])(runner["runner"], name)
  File "/Users/garito/TimeFounder/App/0.3/TimeFounder/paper.py", line 322, in run_view
    runned = runner(context)
  File "/Users/garito/TimeFounder/App/0.3/TimeFounder/runner.py", line 75, in __call__
    result = getattr(self, deal)(node, context) if deal else self._noDeal(node, context)
  File "/Users/garito/TimeFounder/App/0.3/TimeFounder/runner.py", line 349, in Factory
    return getattr(model, action)
  File "/Users/garito/TimeFounder/App/0.3/TimeFounder/paper.py", line 42, in __getattr__
    return getattr(self, runner["method"])(runner["runner"], name)
  File "/Users/garito/TimeFounder/App/0.3/TimeFounder/paper.py", line 343, in run_view
    return self.run_form(runner, runned, preRun, context, name, security)
  File "/Users/garito/TimeFounder/App/0.3/TimeFounder/paper.py", line 489, in run_form
    result = current_app.jinja_env.get_template("stepsForm.html" if hasattr(form, "tfGroups") and form.tfGroups else "simpleForm.html")
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/jinja2/environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/jinja2/environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/jinja2/loaders.py", line 125, in load
    code = environment.compile(source, name, filename)
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/jinja2/environment.py", line 588, in compile
    return self._compile(source, filename)
  File "/Users/garito/TimeFounder/App/0.3/env/lib/python2.7/site-packages/jinja2/environment.py", line 551, in _compile
    return compile(source, filename, 'exec')
File "/Users/garito/TimeFounder/App/0.3/TimeFounder/templates/stepsForm.html", line 57
    if ('csss' in (undefined(name='assets') if l_0_assets is missing else l_0_assets) and environment.getitem((undefined(name='assets') if l_0_assets is missing else l_0_assets), 'csss')):
     ^
IndentationError: expected an indented block

This traceback is from an error that appeared after updating to version 2.9.3.

@ThiefMaster

This comment has been minimized.

Copy link
Member

commented Jan 9, 2017

Can you please post the relevant code from the template too? Ideally a minimal case reproducing it.

@ThiefMaster

This comment has been minimized.

Copy link
Member

commented Jan 9, 2017

@mitsuhiko: The last traceback line looks broken - shouldn't it include the actual code from the template instead of the generated Python code?

@mitsuhiko

This comment has been minimized.

Copy link
Member

commented Jan 9, 2017

@ThiefMaster not on generated syntax errors.

@mitsuhiko

This comment has been minimized.

Copy link
Member

commented Jan 9, 2017

I assume that might happen if an if-block is completely empty.

@Garito

This comment has been minimized.

Copy link
Author

commented Jan 9, 2017

Here the template's code stepsForm.html:

{%- from "snippets.html" import metasFacebook with context -%}
{%- from "snippets.html" import metasTwitter with context -%}
{%- from "snippets.html" import cssGenerator with context -%}
{%- from "snippets.html" import jsGenerator with context -%}
{%- from "snippets.html" import formMaker -%}
{%- from "snippets.html" import stepsIndicator -%}

{%- extends "base.html" -%}

{%- if "action" in assets -%}
  {%- set action = assets["action"] -%}
{%- endif -%}

{%- block title %}TimeFounder - {{ form.title }}{% endblock -%}

{%- if "metaDescription" in assets or "metaFacebook" in assets or "metaTwitter" in assets or "favicon" in assets -%}
  {%- block metas -%}
    {{ super() }}
    {%- if "metaDescription" in assets and assets["metaDescription"] -%}
      <meta name="Description" content="{{ assets['metaDescription'] }}"/>
    {%- endif -%}
    {%- if "metaFacebook" in assets and assets["metaFacebook"] -%}
      {{ metasFacebook(assets["metaFacebook"]) }}
    {%- endif -%}
    {%- if "metaTwitter" in assets and assets["metaTwitter"] -%}
      {{ metasTwitter(assets["metaTwitter"]) }}
    {%- endif -%}
    {%- if "favicon" in assets and assets["favicon"] -%}
      {{ assets["favicon"] | safe }}
    {%- endif -%}
  {%- endblock -%}
{%- endif -%}

{%- if "csss" in assets and assets["csss"] -%}
  {%- block styles -%}
    {{ super() }}
    {{ cssGenerator(assets["csss"]) }}
  {%- endblock -%}
{%- endif -%}

{%- block content -%}
  <div class="container-fluid">
    <i class="fa fa-angle-double-left swipe-left visible-xs"></i>
    {{ stepsIndicator(form.tfGroups) }}
    <h1>{{ form.title }}</h1>
    {{ formMaker(form, tree_dict) }}
    <i class="fa fa-angle-double-right swipe-right visible-xs"></i>
  </div>
{%- endblock -%}

{%- if "jss" in assets and assets["jss"] -%}
  {%- block scripts -%}
    {{ super() }}
    {{ jsGenerator(assets["jss"]) }}
  {%- endblock -%}
{%- endif -%}

The error is raised on line 57 but the file has only 56

@mitsuhiko

This comment has been minimized.

Copy link
Member

commented Jan 9, 2017

Minimal repo

{% extends "base.html" %}
{% if expr %}{% block wah %}stuff{% endblock %}{% endif %}
@ThiefMaster

This comment has been minimized.

Copy link
Member

commented Jan 9, 2017

Unrelated recommendation: You can simplify {%- if "csss" in assets and assets["csss"] -%} to this:

{%- if assets.get("csss") -%}

or even (if you do not use StrictUndefined):

{%- if assets["csss"] -%}
@Garito

This comment has been minimized.

Copy link
Author

commented Jan 9, 2017

Is this meaning that I can't wrap a block in a if?

@Garito

This comment has been minimized.

Copy link
Author

commented Jan 9, 2017

@ThiefMaster nice recommendation: THANKS!

@ThiefMaster

This comment has been minimized.

Copy link
Member

commented Jan 9, 2017

It's a bug in 2.9. Wrapping a block inside if is perfectly fine.

@Garito

This comment has been minimized.

Copy link
Author

commented Jan 9, 2017

ok
Do you need any other information?
How can I help?

@mitsuhiko mitsuhiko closed this in e73c574 Jan 9, 2017

@Garito

This comment has been minimized.

Copy link
Author

commented Jan 9, 2017

@mitsuhiko Thanks: you are so damn fast (and I'm really jealous) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.