From 368e361585cded8adc3eb9a7ba70cbdb7484d1e8 Mon Sep 17 00:00:00 2001 From: donbarbos Date: Sat, 22 Aug 2026 10:23:31 +0400 Subject: [PATCH] [mmap] Allow None for mmap.flush in Python 3.14 At runtime, `size` accepts `None` from `3.14.1` through `3.14.7` (the latest `3.14` release), and only accepts `-1` starting with `3.15.0`. --- stdlib/@tests/stubtest_allowlists/py314.txt | 4 ---- stdlib/mmap.pyi | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py314.txt b/stdlib/@tests/stubtest_allowlists/py314.txt index caac7ec2a477..149db40348b1 100644 --- a/stdlib/@tests/stubtest_allowlists/py314.txt +++ b/stdlib/@tests/stubtest_allowlists/py314.txt @@ -24,10 +24,6 @@ concurrent.interpreters._crossinterp.UNBOUND_REMOVE # Condition functions are exported in __init__ threading.Condition.locked -# Starting with Python 3.14.1, these methods accept None for some of their -# parameters, but would raise a TypeError with Python 3.14.0. -mmap.mmap.flush - # ==================================== # Pre-existing errors from Python 3.13 # ==================================== diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index ef673e130ef4..442a7807753a 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -70,7 +70,10 @@ class mmap: def close(self) -> None: ... if sys.version_info >= (3, 15): - def flush(self, offset: int = 0, size: int = ..., /, *, flags: int = 0) -> None: ... + def flush(self, offset: int = 0, size: int = -1, /, *, flags: int = 0) -> None: ... + elif sys.version_info >= (3, 14): + # size default changed in Python 3.14.1 + def flush(self, offset: int = 0, size: int | None = None, /) -> None: ... else: def flush(self, offset: int = 0, size: int = ..., /) -> None: ...