Skip to content
Myr

Merge branch '3.1.x'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parents a0dd775, 8efee35 · Browse files · 6 files+56 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+56 added−13 removed

  • other:+56 added−13 removed

6 files+56 added−13 removed

modified:requirements/dev.txt+1 added-1 removed
18 unmodified lines
19filelock==3.6.020 # via21 # tox22 # virtualenv23identify==2.4.1223identify==2.5.024 # via pre-commit25nodeenv==1.6.026 # via pre-commit27pep517==0.12.0
33 unmodified lines
modified:requirements/typing.txt+1 added-1 removed
3 unmodified lines
4# To update, run:5#6# pip-compile-multi7#8mypy==0.9428mypy==0.9509 # via -r requirements/typing.in10mypy-extensions==0.4.311 # via mypy12tomli==2.0.1
3 unmodified lines
modified:src/jinja2/bccache.py+48 added-6 removed
77 unmodified lines
78 except (EOFError, ValueError, TypeError):79 self.reset()80 return8182 def write_bytecode(self, f: t.BinaryIO) -> None:82 def write_bytecode(self, f: t.IO[bytes]) -> None:83 """Dump the bytecode into the file or file like object passed."""84 if self.code is None:85 raise TypeError("can't write empty bucket")86 f.write(bc_magic)
174 unmodified lines
261262 def load_bytecode(self, bucket: Bucket) -> None:263 filename = self._get_cache_filename(bucket)264265 if os.path.exists(filename):266 with open(filename, "rb") as f:267 bucket.load_bytecode(f)265 # Don't test for existence before opening the file, since the266 # file could disappear after the test before the open.267 try:268 f = open(filename, "rb")269 except (FileNotFoundError, IsADirectoryError, PermissionError):270 # PermissionError can occur on Windows when an operation is271 # in progress, such as calling clear().272 return273274 with f:275 bucket.load_bytecode(f)276277 def dump_bytecode(self, bucket: Bucket) -> None:270 with open(self._get_cache_filename(bucket), "wb") as f:271 bucket.write_bytecode(f)278 # Write to a temporary file, then rename to the real name after279 # writing. This avoids another process reading the file before280 # it is fully written.281 name = self._get_cache_filename(bucket)282 f = tempfile.NamedTemporaryFile(283 mode="wb",284 dir=os.path.dirname(name),285 prefix=os.path.basename(name),286 suffix=".tmp",287 delete=False,288 )289290 def remove_silent() -> None:291 try:292 os.remove(f.name)293 except OSError:294 # Another process may have called clear(). On Windows,295 # another program may be holding the file open.296 pass297298 try:299 with f:300 bucket.write_bytecode(f)301 except BaseException:302 remove_silent()303 raise304305 try:306 os.replace(f.name, name)307 except OSError:308 # Another process may have called clear(). On Windows,309 # another program may be holding the file open.310 remove_silent()311 except BaseException:312 remove_silent()313 raise314315 def clear(self) -> None:316 # imported lazily here because google app-engine doesn't support317 # write access on the file system and the function does not exist318 # normally.
88 unmodified lines
modified:src/jinja2/filters.py+3 added-3 removed
1284 unmodified lines
12851286 Total: {{ items|sum(attribute='price') }}12871288 .. versionchanged:: 2.61289 The `attribute` parameter was added to allow suming up over1290 attributes. Also the `start` parameter was moved on to the right.1289 The ``attribute`` parameter was added to allow summing up over1290 attributes. Also the ``start`` parameter was moved on to the right.1291 """1292 if attribute is not None:1293 iterable = map(make_attrgetter(environment, attribute), iterable)12941295 return sum(iterable, start)1295 return sum(iterable, start) # type: ignore[no-any-return, call-overload]129612971298@async_variant(sync_do_sum) # type: ignore1299async def do_sum(
541 unmodified lines
modified:.pre-commit-config.yaml+2 added-2 removed
modified:CHANGES.rst+1 added
11 unmodified lines
12Unreleased1314- Add parameters to ``Environment.overlay`` to match ``__init__``.15 :issue:`1645`16- Handle race condition in ``FileSystemBytecodeCache``. :issue:`1654`171819Version 3.1.120-------------
961 unmodified lines