TypeError: cannot use 'tuple' as a dict key in LRUCache on Python 3.14
Environment:
- Python 3.14.5
- Jinja2 3.1.6
- Starlette/FastAPI (TemplateResponse)
- Windows 10
- Running as a PyInstaller bundled executable
Error: TypeError: cannot use 'tuple' as a dict key (unhashable type: 'dict')
Traceback: File "jinja2\environment.py", line 964, in _load_template template = self.cache.get(cache_key) File "jinja2\\utils.py", line 477, in get return self[key] File "jinja2\\utils.py", line 515, in getitem rv = self._mapping[key] TypeError: cannot use 'tuple' as a dict key (unhashable type: 'dict')
To reproduce: Use Jinja2's TemplateResponse via Starlette on Python 3.14. The LRUCache in jinja2/utils.py constructs a cache key that contains a dict under Python 3.14, which is no longer hashable.
Workaround:
Setting env.cache = None on the Jinja2 Environment disables the cache
and prevents the error.
Notes: This may be related to changes in how Python 3.14 handles tuple hashing or dict construction internally. The cache_key generation in environment.py may be producing a different type under 3.14 than expected.
Environment:
- Python version:
- Jinja version:
Source: pallets/jinja