Edgewall Software
Modify

Opened 4 years ago

Closed 4 years ago

Last modified 2 years ago

#13242 closed defect (fixed)

UndefinedError: the inline if-expression on line 109 in 'theme.html' evaluated to false and no else section was defined.

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.4.1
Component: general Version: 1.4
Severity: normal Keywords: jinja2
Cc: Branch:
Release Notes:

Fixed compatibility issues with Jinja2 version 2.11.

API Changes:
Internal Changes:

Description

Tests pass with Jinja2 2.10.3, but 2.11 released on 27 Jan 2020 has the following failure:

SKIP_FUNCTIONAL_TESTS=1 python  -m unittest -f -c trac.test.test_suite
..............................E
======================================================================
ERROR: test_preview_valid_xhtml (trac.tests.attachment.AttachmentModuleTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "trac/tests/attachment.py", line 610, in test_preview_valid_xhtml
    result = render(attachment)
  File "trac/tests/attachment.py", line 605, in render
    {'fragment': True})
  File "trac/web/chrome.py", line 1441, in render_template
    fragment, iterable, method)
  File "trac/web/chrome.py", line 1526, in _render_jinja_template
    s = self.render_template_string(template, data, text)
  File "trac/web/chrome.py", line 1675, in render_template_string
    string = template.render(data)
  File "/Users/rjollos/.pyenv/versions/trac-2.7.15/lib/python2.7/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/Users/rjollos/.pyenv/versions/trac-2.7.15/lib/python2.7/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "trac/templates/attachment.html", line 14, in top-level template code
    # set parent = attachments.parent if attachments else attachment.resource.parent
  File "trac/templates/layout.html", line 12, in top-level template code
    # import "macros.html" as jmacros with context
  File "trac/templates/theme.html", line 22, in top-level template code
    # block body
  File "trac/templates/theme.html", line 109, in block "body"
    # include resourcepath_template if resourcepath_template ignore missing
  File "/Users/rjollos/.pyenv/versions/trac-2.7.15/lib/python2.7/site-packages/jinja2/loaders.py", line 179, in get_source
    pieces = split_template_path(template)
  File "/Users/rjollos/.pyenv/versions/trac-2.7.15/lib/python2.7/site-packages/jinja2/loaders.py", line 28, in split_template_path
    for piece in template.split("/"):
UndefinedError: the inline if-expression on line 109 in 'theme.html' evaluated to false and no else section was defined.

----------------------------------------------------------------------
Ran 31 tests in 0.466s

FAILED (errors=1)
make: *** [unit-test] Error 1

Attachments (0)

Change History (6)

comment:1 by Ryan J Ollos, 4 years ago

Owner: set to Ryan J Ollos
Status: newassigned

The following changes seems to fix the issue:

  • trac/templates/theme.html

    diff --git a/trac/templates/theme.html b/trac/templates/theme.html
    index c1798c16f..7d613b4d8 100644
    a b  
    106106         'uisymbols': req.session.get('ui.use_symbols'),
    107107         'uinohelp': req.session.get('ui.hide_help'),
    108108         }}|htmlattr}>
    109       # include resourcepath_template if resourcepath_template ignore missing
     109      # if resource_template:
     110      #   include resourcepath_template ignore missing
     111      # endif
    110112      <div id="ctxtnav" class="nav">
    111113        <h2>${_("Context Navigation")}</h2>
    112114        # if chrome.ctxtnav:
  • trac/ticket/templates/milestone_view.html

    diff --git a/trac/ticket/templates/milestone_view.html b/trac/ticket/templates/milestone_view.html
    index c982990cf..af55e3163 100644
    a b  
    5757          ${_("No date set")}
    5858          # endif
    5959          </p>
    60         # include 'progress_bar.html' if stats.count ignore missing
     60        # if stats.count:
     61        #   include 'progress_bar.html' ignore missing
     62        # endif
    6163      </div>
    6264
    6365      # if available_groups and stats.count:
     
    8183            </script>
    8284          </legend>
    8385          # with summary = _('Shows the milestone completion status grouped by %(grouped_by)s', grouped_by=grouped_by)
    84           #   include 'progress_bar_grouped.html' if groups ignore missing
     86          #   if groups:
     87          #     include 'progress_bar_grouped.html' ignore missing
     88          #   endif
    8589          # endwith
    8690        </fieldset>
    8791      </form>
  • trac/ticket/templates/query.html

    diff --git a/trac/ticket/templates/query.html b/trac/ticket/templates/query.html
    index c82840179..afa60d2dc 100644
    a b  
    335335      </form>
    336336
    337337      # include 'query_results.html'
    338       # include 'batch_modify.html' if tickets and batch_modify ignore missing
     338      # if tickets:
     339      #   include 'batch_modify.html' ignore missing
     340      # endif
    339341
    340342      <div id="trac-report-buttons" class="buttons">
    341343        # set edit = report_resource and 'REPORT_MODIFY' in perm(report_resource)
  • trac/ticket/templates/roadmap.html

    diff --git a/trac/ticket/templates/roadmap.html b/trac/ticket/templates/roadmap.html
    index a3b24910f..75db9d6d1 100644
    a b  
    9595            #   set stats = mstats.stats
    9696            #   set interval_hrefs = mstats.interval_hrefs
    9797            #   set stats_href = mstats.stats_href
    98             #   include 'progress_bar.html' if stats.count ignore missing
     98            #   if stats.count:
     99            #     include 'progress_bar.html' ignore missing
     100            #   endif
    99101            # endwith
    100102          </div>
Version 2, edited 4 years ago by Ryan J Ollos (previous) (next) (diff)

comment:2 by Jun Omae, 4 years ago

That changes look good to me.

comment:3 by Ryan J Ollos, 4 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Thanks, committed in [17236:17237].

comment:4 by Ryan J Ollos, 4 years ago

See #13248 for regression introduced by r17236.

comment:5 by Ryan J Ollos, 4 years ago

Edited TracDev/PortingFromGenshiToJinja@49.

I haven't found a way to write an inline conditional that uses ignore missing after Jinja2 2.11. I made the same comment here as well.

comment:6 by Ryan J Ollos, 4 years ago

Version: 1.4

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.