@@ -248,7 +248,7 @@ def _resolve_includes_blocks_and_extends(template: str):
248
248
endblock_match = _find_named_endblock (template , block_name )
249
249
250
250
if endblock_match is None :
251
- raise ValueError ( r "Missing {% endblock %} for block: " + block_name )
251
+ raise SyntaxError ( "Missing {% endblock %} for block: " + block_name )
252
252
253
253
block_content = template [block_match .end () : endblock_match .start ()]
254
254
@@ -457,7 +457,7 @@ def _create_template_rendering_function( # pylint: disable=,too-many-locals,too
457
457
indentation_level -= 1
458
458
459
459
if not nested_if_statements :
460
- raise SyntaxError ("No matching {% if ... %} block for {% endif %}" )
460
+ raise SyntaxError ("Missing {% if ... %} block for {% endif %}" )
461
461
462
462
nested_if_statements .pop ()
463
463
@@ -479,9 +479,7 @@ def _create_template_rendering_function( # pylint: disable=,too-many-locals,too
479
479
indentation_level -= 1
480
480
481
481
if not nested_for_loops :
482
- raise SyntaxError (
483
- "No matching {% for ... %} block for {% endfor %}"
484
- )
482
+ raise SyntaxError ("Missing {% for ... %} block for {% endfor %}" )
485
483
486
484
nested_for_loops .pop ()
487
485
@@ -496,7 +494,7 @@ def _create_template_rendering_function( # pylint: disable=,too-many-locals,too
496
494
497
495
if not nested_while_loops :
498
496
raise SyntaxError (
499
- "No matching {% while ... %} block for {% endwhile %}"
497
+ "Missing {% while ... %} block for {% endwhile %}"
500
498
)
501
499
502
500
nested_while_loops .pop ()
@@ -517,7 +515,7 @@ def _create_template_rendering_function( # pylint: disable=,too-many-locals,too
517
515
elif token == r"{% endautoescape %}" :
518
516
if not nested_autoescape_modes :
519
517
raise SyntaxError (
520
- "No matching {% autoescape ... %} block for {% endautoescape %}"
518
+ "Missing {% autoescape ... %} block for {% endautoescape %}"
521
519
)
522
520
523
521
nested_autoescape_modes .pop ()
@@ -534,15 +532,15 @@ def _create_template_rendering_function( # pylint: disable=,too-many-locals,too
534
532
# Checking for unclosed blocks
535
533
if len (nested_if_statements ) > 0 :
536
534
last_if_statement = nested_if_statements [- 1 ]
537
- raise SyntaxError (f "Missing {{ % endif %}} for { last_if_statement } " )
535
+ raise SyntaxError ("Missing {% endif %} for " + last_if_statement )
538
536
539
537
if len (nested_for_loops ) > 0 :
540
538
last_for_loop = nested_for_loops [- 1 ]
541
- raise SyntaxError (f "Missing {{ % endfor %}} for { last_for_loop } " )
539
+ raise SyntaxError ("Missing {% endfor %} for " + last_for_loop )
542
540
543
541
if len (nested_while_loops ) > 0 :
544
542
last_while_loop = nested_while_loops [- 1 ]
545
- raise SyntaxError (f "Missing {{ % endwhile %}} for { last_while_loop } " )
543
+ raise SyntaxError ("Missing {% endwhile %} for " + last_while_loop )
546
544
547
545
# No check for unclosed autoescape blocks, as they are optional and do not result in errors
548
546
0 commit comments