From 1df82ed1bf92e5b92fdb8bf298b71e39f71468b1 Mon Sep 17 00:00:00 2001 From: Guo Ci Date: Mon, 1 Dec 2025 10:33:02 -0500 Subject: [PATCH] [ctypes] Add `_layout_` attribute for `ctypes.Structure` (#15091) --- stdlib/_ctypes.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/_ctypes.pyi b/stdlib/_ctypes.pyi index c87cf5e32..4650dd7fe 100644 --- a/stdlib/_ctypes.pyi +++ b/stdlib/_ctypes.pyi @@ -5,7 +5,7 @@ from abc import abstractmethod from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p from types import GenericAlias -from typing import Any, ClassVar, Final, Generic, TypeVar, final, overload, type_check_only +from typing import Any, ClassVar, Final, Generic, Literal, TypeVar, final, overload, type_check_only from typing_extensions import Self, TypeAlias _T = TypeVar("_T") @@ -266,6 +266,10 @@ class Structure(_CData, metaclass=_PyCStructType): if sys.version_info >= (3, 13): _align_: ClassVar[int] + if sys.version_info >= (3, 14): + # _layout_ can be defined by the user, but is not always present. + _layout_: ClassVar[Literal["ms", "gcc-sysv"]] + def __init__(self, *args: Any, **kw: Any) -> None: ... def __getattr__(self, name: str) -> Any: ... def __setattr__(self, name: str, value: Any) -> None: ...