FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

JInja extraction fails silently without error if there's an unrecognized do statement with {a:b} inside · Issue #1216 · python-babel/babel · GitHub

Repository navigation

JInja extraction fails silently without error if there's an unrecognized do statement with {a:b} inside #1216

Open

Description

See the following MWE.

[templates/test.html]

{% set a = "foo" %}
{% set b = "bar" %}
{% set d = [1, 2, 3] %}
{% set mydict = {} %}

{% for c in d %}
  {% do mydict.update({a: b}) %}
{% endfor %}

{{ _("Hello!") }}

Deleting the entirely nonsense block before _("Hello") makes it able to extract Hello, but in its current state, no messages are extracted.

[babel.cfg]

[jinja2: templates/**.html]
encoding=utf-8

Anyways: Babel 2.17.0 is used.

Activity

  1. akx commented on Jul 8, 2025

    Member

    I think the actual issue is that you're using a {% do %} statement, which is implemented as a Jinja extension.

    No extensions are loaded by default unless you tell the Jinja extractor to; as documented in the Jinja docs, you would need

    [jinja2: templates/**.html]
    encoding = utf-8
    extensions = jinja2.ext.do

    to have the extension (and thus the do statement, and thus no parsing error from Jinja) loaded for extraction.

  2. johnzhou721 commented on Jul 8, 2025

    Author

    But I think we at least an error message, not just stay silent about it.

  3. johnzhou721 commented on Jul 8, 2025

    Author

    Something like "unknown statement do"

  4. changed the title [-]Jinja Extraction Fails when {a: b} is present in a dictionary[/-] [+]JInja extraction fails silently without error if there's an unrecognized do statement with {a:b} inside[/+] on Jul 8, 2025
  5. added theissue type on Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL