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.
This commit is contained in:
Henry Schreiner
2022-03-28 18:23:03 -04:00
committed by GitHub
parent a3245db63c
commit da08cd30d0

View File

@@ -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: ...