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

non-deterministic output from compile templates when using tuple unpacking #2021

Open
anentropic opened this issue Sep 3, 2024 · 0 comments · May be fixed by #2022
Open

non-deterministic output from compile templates when using tuple unpacking #2021

anentropic opened this issue Sep 3, 2024 · 0 comments · May be fixed by #2022

Comments

@anentropic
Copy link

Ideally compile_templates will have deterministic output so we can use git diff etc

See also #1453 and #1452

Found another case where this occurs, e.g. I'm randomly getting these changes or their inverse:

-    context.vars.update({'triage_reports': l_0_triage_reports, 'open_group_index': l_0_open_group_index})
-    context.exported_vars.update(('triage_reports', 'open_group_index'))
+    context.vars.update({'open_group_index': l_0_open_group_index, 'triage_reports': l_0_triage_reports})
+    context.exported_vars.update(('open_group_index', 'triage_reports'))

or:

-                _loop_vars.update({'row_spans': l_2_row_spans, 'row': l_2_row})
+                _loop_vars.update({'row': l_2_row, 'row_spans': l_2_row_spans})

I can see that both of the cases above are a result of using tuple unpacking to set multiple new context vars in a single set call
e.g.

{% set triage_reports, open_group_index = get_nav_list_items(TRIAGE_REPORTS_NAV, url_name, url_func=url) %}
{% set row, row_spans = row %}

The output from compiling the templates should be stable if the underlying template hasn't changed, rather than varying randomly each time you run it.

Environment:

  • Python version: 3.11.5
  • Jinja version: 3.1.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant