From 3a40587965d7598b2f035f682d76ed3631d9dd86 Mon Sep 17 00:00:00 2001 From: Guo Ci Date: Wed, 3 Dec 2025 17:12:12 -0500 Subject: [PATCH 1/3] [stdlib] memoryview updates for version 3.14 docs: https://docs.python.org/dev/library/stdtypes.html#memoryview.count https://docs.python.org/dev/library/stdtypes.html#memoryview.index src: https://github.com/python/cpython/blob/c0c65141b37029bfb364094a6dfb4c75ebf8359e/Objects/memoryobject.c#L2786-L2905 --- stdlib/builtins.pyi | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 38be452e8d49..fd095abcfcc8 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -944,11 +944,15 @@ class memoryview(Sequence[_I]): def hex(self, sep: str | bytes = ..., bytes_per_sep: SupportsIndex = 1) -> str: ... def __buffer__(self, flags: int, /) -> memoryview: ... def __release_buffer__(self, buffer: memoryview, /) -> None: ... + if sys.version_info >= (3, 14): + def index(self, value: object, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ... + def count(self, value: object, /) -> int: ... + else: + # These are inherited from the Sequence ABC, but don't actually exist on memoryview. + # See https://github.com/python/cpython/issues/125420 + index: ClassVar[None] # type: ignore[assignment] + count: ClassVar[None] # type: ignore[assignment] - # These are inherited from the Sequence ABC, but don't actually exist on memoryview. - # See https://github.com/python/cpython/issues/125420 - index: ClassVar[None] # type: ignore[assignment] - count: ClassVar[None] # type: ignore[assignment] if sys.version_info >= (3, 14): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... From 2eaedba00d24b76e0f4d05d242b9e17ccbb5cf1f Mon Sep 17 00:00:00 2001 From: Guo Ci Date: Thu, 4 Dec 2025 14:57:15 -0500 Subject: [PATCH 2/3] fix memoryview test --- stdlib/@tests/test_cases/builtins/check_memoryview.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stdlib/@tests/test_cases/builtins/check_memoryview.py b/stdlib/@tests/test_cases/builtins/check_memoryview.py index 9bcec4e5fb7f..5a06338ae92b 100644 --- a/stdlib/@tests/test_cases/builtins/check_memoryview.py +++ b/stdlib/@tests/test_cases/builtins/check_memoryview.py @@ -57,5 +57,9 @@ mv = memoryview(b"abc") mv.cast("abc") # type: ignore -mv.index(42) # type: ignore -mv.count(42) # type: ignore +if sys.version_info >= (3, 14): + mv.index(42) + mv.count(42) +else: + mv.index(42) # type: ignore + mv.count(42) # type: ignore From 1e6432657d2334769a911345bdbceca47a069b24 Mon Sep 17 00:00:00 2001 From: Guo Ci Date: Thu, 4 Dec 2025 15:01:48 -0500 Subject: [PATCH 3/3] Add import for sys module in check_memoryview.py --- stdlib/@tests/test_cases/builtins/check_memoryview.py | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/@tests/test_cases/builtins/check_memoryview.py b/stdlib/@tests/test_cases/builtins/check_memoryview.py index 5a06338ae92b..1ece6e6b850b 100644 --- a/stdlib/@tests/test_cases/builtins/check_memoryview.py +++ b/stdlib/@tests/test_cases/builtins/check_memoryview.py @@ -1,6 +1,7 @@ from __future__ import annotations import array +import sys from typing_extensions import assert_type # Casting to bytes.