From da08cd30d08b827e532a611ff6acdb7ece026fac Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 28 Mar 2022 18:23:03 -0400 Subject: [PATCH] locale: getlocale may return None's (#7562) According to the docs at https://docs.python.org/3/library/locale.html#locale.getlocale, this function may return None for either of the two items in the return sequence, which is missed in the current form. Also adjust `locale.setlocale()`, which can accept a tuple of `(None, None)` for the second argument. --- stdlib/locale.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index 899bf0000..e5227beca 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -32,7 +32,7 @@ __all__ = [ # as a type annotation or type alias. from builtins import str as _str from decimal import Decimal -from typing import Any, Callable, Iterable, Mapping, Sequence +from typing import Any, Callable, Iterable, Mapping CODESET: int D_T_FMT: int @@ -107,11 +107,11 @@ CHAR_MAX: int class Error(Exception): ... -def setlocale(category: int, locale: _str | Iterable[_str] | None = ...) -> _str: ... +def setlocale(category: int, locale: _str | Iterable[_str | None] | None = ...) -> _str: ... def localeconv() -> Mapping[_str, int | _str | list[int]]: ... def nl_langinfo(__key: int) -> _str: ... def getdefaultlocale(envvars: tuple[_str, ...] = ...) -> tuple[_str | None, _str | None]: ... -def getlocale(category: int = ...) -> Sequence[_str]: ... +def getlocale(category: int = ...) -> tuple[_str | None, _str | None]: ... def getpreferredencoding(do_setlocale: bool = ...) -> _str: ... def normalize(localename: _str) -> _str: ... def resetlocale(category: int = ...) -> None: ...