Skip to content

Commit

Permalink
πŸš‘ Use 'f' @ commit hashes @ Towncrier template
Browse files Browse the repository at this point in the history
This patch work around the Jinja's `int` filter bug that allows certain commit
hash-based filenames trigger an `OverflowError` in the Towncrier template.

Ref: pallets/jinja#1921
  • Loading branch information
webknjaz committed Dec 30, 2023
1 parent c444a3b commit 71bd03e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion CHANGES/.TEMPLATE.rst
Expand Up @@ -14,8 +14,19 @@
{% for text, change_note_refs in sections[section][category].items() %}
- {{ text + '\n' }}

{%
{#
NOTE: Replacing 'e' with 'f' is a hack that prevents Jinja's `int`
NOTE: filter internal implementation from treating the input as an
NOTE: infinite float when it looks like a scientific notation (with a
NOTE: single 'e' char in between digits), raising an `OverflowError`,
NOTE: subsequently. 'f' is still a hex letter so it won't affect the
NOTE: check for whether it's a (short or long) commit hash or not.
Ref: https://github.com/pallets/jinja/issues/1921
-#}
{%-
set pr_issue_numbers = change_note_refs
| map('lower')
| map('replace', 'e', 'f')
| map('int', default=None)
| select('integer')
| map('string')
Expand Down

0 comments on commit 71bd03e

Please sign in to comment.