Commit Graph

496 Commits

Author SHA1 Message Date
Adam Englander
a3dce7bb64
fix type/lint/format findings 2025-05-28 10:08:39 -07:00
David Lord
220e67ae99
Merge branch 'stable' 2025-03-05 12:15:40 -08:00
David Lord
065334d1ee
attr filter uses env.getattr 2025-03-05 10:08:48 -08:00
David Lord
6aeab5d1da
Merge branch 'stable' 2024-12-21 10:47:46 -08:00
Kevin Brown-Silva
66587ce989
Fix bug where set would sometimes fail within if
There was a bug that came as the result of an early optimization done
within ID tracking that caused loading parameters to fail in a very
specific and rare edge case. That edge case only occurred when the
parameter was being set within all 3 standard branches of an if block,
since the optimization would assume that the parameter was never being
referenced and was only ever being set. This would cause the variable to
be set to undefined.

The fix for this was to remove the optimization and still continue to
load in the parameter even if it is set in all 3 branches.
2024-12-21 09:40:06 -08:00
Kevin Brown-Silva
ee832194cd
Add support for namespaces in tuple assignment
This fixes a bug that existed because namespaces within `{% set %}`
were treated as a special case. This special case had the side-effect
of bypassing the code which allows for tuples to be assigned to.

The solution was to make tuple handling (and by extension, primary token
handling) aware of namespaces so that namespace tokens can be handled
appropriately. This is handled in a backwards-compatible way which
ensures that we do not try to parse namespace tokens when we otherwise
would be expecting to parse out name tokens with attributes.

Namespace instance checks are moved earlier, and deduplicated, so that
all checks are done before the assignment. Otherwise, the check could be
emitted in the middle of the tuple.
2024-12-20 14:09:40 -08:00
Rens Groothuijsen
d05bd3858c
Pass context when using select 2024-12-19 20:47:24 -08:00
наб
0cd6948192
don't apply urlize to @a@b 2024-12-19 20:37:58 -08:00
David Lord
aaa083d265
separate messages, add test 2024-12-19 20:15:10 -08:00
David Lord
227edfd372
clean up message, add test 2024-12-19 19:34:34 -08:00
David Lord
b4b28ec01c
fix default for Environment.overlay(enable_async) (#2061) 2024-12-19 18:23:52 -08:00
SamyCookie
e45bc745a7
Bugfix: wrong default argument for Environment.overlay(enable_async) parameter 2024-12-19 18:22:32 -08:00
Sigurd Spieckermann
56a724644b
fix f-string syntax error in code generation 2024-12-19 18:08:42 -08:00
Lydxn
91a972f580
sandbox indirect calls to str.format 2024-12-19 12:34:27 -08:00
Dylan Scott
b512058270
sandbox disallows clear and pop on mutable sequence 2024-12-19 08:33:38 -08:00
Matt Clay
7232b82462
Fix pickle/copy support for the missing singleton 2024-12-19 08:19:07 -08:00
Matt Davis
d4fb0e8c40
preserve __slots__ on Undefined classes 2024-12-19 08:11:49 -08:00
Anentropic
4936e4d482
make tuple unpacking deterministic in compiler 2024-12-19 08:02:33 -08:00
Felipe Moreno
2eb4542cba
int filter handles OverflowError to handle scientific notation 2024-12-19 07:58:25 -08:00
Mehdi ABAAKOUK
76af7110ea
make unique filter async-aware 2024-12-19 07:19:13 -08:00
Martin Krizek
d3a0b1a4ab
use env.concat when calling block reference 2024-12-19 07:12:43 -08:00
David Lord
7f0fc0ad2c
Merge branch '3.1.x' 2024-08-23 16:52:48 -07:00
James Addison
f8323cf404
Additional test coverage for async rendering of native type templates (#1807) 2024-07-10 09:14:52 -07:00
Thomas Grainger
679af7f816
fix test_package_zip_list on 3.13 2024-05-13 20:04:38 +01:00
David Lord
004476c22b
test on python 3.13
update dev dependencies
refactor update tox envs
3.7 requires an old version of trio

xfail zip loader template test
2024-05-13 08:40:44 -07:00
Thomas Grainger
1655128cfc
test on trio, fix all missing aclose related warnings (#1960) 2024-05-11 15:01:12 -07:00
David Lord
d655030770
disallow invalid characters in keys to xmlattr filter 2024-05-02 09:14:00 -07:00
David Lord
0ee5eb41d1
satisfy formatter, linter, and strict mypy 2024-04-23 09:29:26 -07:00
Aarni Koskela
19a55db3b4
Make nested-trans-block exceptions nicer 2024-01-10 14:27:09 -08:00
Calum Hutton
7dd3680e6e
xmlattr filter disallows keys with spaces 2024-01-10 14:01:13 -08:00
David Lord
ae312b3065
update dependencies 2023-06-01 10:47:07 -07:00
David Lord
051df10c7b
fix check for empty required block (#1858) 2023-06-01 10:42:27 -07:00
David Lord
3fadee01b7
update dependencies 2022-12-29 10:39:00 -08:00
David Lord
1b02fccaf4
normpath on final template filename 2022-03-25 15:23:00 -07:00
David Lord
040088a395
use posixpath.join when loading template names 2022-03-15 13:58:22 -07:00
David Lord
e690f7c596
add case_sensitive parameter groupby filter
Co-authored-by: Yuri Sukhov <yuri.sukhov@gmail.com>
2022-03-08 06:55:05 -08:00
David Lord
a150ff749a
add parens around auto_await for filters and calls 2022-03-07 09:14:21 -08:00
Armin Ronacher
1c036cac2f
add items filter 2022-03-07 08:29:16 -08:00
Jeff Dairiki
ac3ac6c965
async_variant filters are pickleable 2022-03-07 07:52:04 -08:00
David Lord
b6f50df85b
specify context for translation block 2021-12-26 11:51:54 -07:00
Martin Krizek
2903565262
support native types in macros 2021-11-10 11:17:33 -08:00
David Lord
6faf093f9d
remove deprecated legacy resolve mode for context subclass 2021-11-10 11:07:04 -08:00
David Lord
a42b291bf2
Merge branch '3.0.x' 2021-11-09 12:28:39 -08:00
David Lord
eec0db8642
PackageLoader works with single module file 2021-11-09 12:18:53 -08:00
David Lord
e01e0a21f9
Merge pull request #1509 from kianmeng/fix-typos
Fix typos
2021-11-09 09:17:51 -08:00
Kristian Klette
9b96b4817a
Use object.__hash__ for Node.__hash__
This fixes a regression in commit 60293416db that
changed the `__hash__` implementation of Node from the default pointer
hash, to a hash based on the node fields.

Since these fields contains list objects, they are not hashable, making
every call to `Node.__hash__` fail.

This breaks some third-party usage such as in `django-compressor`
(See: https://github.com/django-compressor/django-compressor/issues/1060)

This changed reverts the hash method back to using `object.__hash__` as
the hash implementation.
2021-11-09 09:12:22 -08:00
Martin Krizek
bb0db82b91
native: keep same behavior on Python 3.10 2021-11-09 08:41:02 -08:00
David Lord
5308c9588d
drop Python 3.6 2021-11-08 08:07:29 -08:00
David Lord
5e2385ca0c
Merge branch '3.0.x' 2021-11-05 07:22:41 -07:00
Miro Hrončok
757756696c
Tests: Adapt expected traceback regexes for Python 3.11.0a1
Fixes https://github.com/pallets/jinja/issues/1526

Before:

      File ".../broken.html", line 2, in <module>
        {{ fail() }}
      File ".../test_debug.py", line 32, in <lambda>
        tmpl.render(fail=lambda: 1 / 0)
    ZeroDivisionError: division by zero

After:

      File ".../broken.html", line 2, in <module>
        {{ fail() }}
        ^^^^^^^^^^^^
      File ".../test_debug.py", line 32, in <lambda>
        tmpl.render(fail=lambda: 1 / 0)
                                 ~~^~~
    ZeroDivisionError: division by zero
2021-11-05 07:19:04 -07:00