MCPcopy Index your code
hub / github.com/RustPython/RustPython / getdefaultlocale

Function getdefaultlocale

Lib/locale.py:524–554  ·  view source on GitHub ↗

Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default loc

(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE'))

Source from the content-addressed store, hash-verified

522 'two strings -- language code, encoding.') from None
523
524def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
525
526 """ Tries to determine the default locale settings and returns
527 them as tuple (language code, encoding).
528
529 According to POSIX, a program which has not called
530 setlocale(LC_ALL, "") runs using the portable 'C' locale.
531 Calling setlocale(LC_ALL, "") lets it use the default locale as
532 defined by the LANG variable. Since we don't want to interfere
533 with the current locale setting we thus emulate the behavior
534 in the way described above.
535
536 To maintain compatibility with other platforms, not only the
537 LANG variable is tested, but a list of variables given as
538 envvars parameter. The first found to be defined will be
539 used. envvars defaults to the search path used in GNU gettext;
540 it must always contain the variable name 'LANG'.
541
542 Except for the code 'C', the language code corresponds to RFC
543 1766. code and encoding can be None in case the values cannot
544 be determined.
545
546 """
547
548 import warnings
549 warnings._deprecated(
550 "locale.getdefaultlocale",
551 "{name!r} is deprecated and slated for removal in Python {remove}. "
552 "Use setlocale(), getencoding() and getlocale() instead.",
553 remove=(3, 15))
554 return _getdefaultlocale(envvars)
555
556
557def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):

Callers 1

_print_localeFunction · 0.85

Calls 1

_getdefaultlocaleFunction · 0.85

Tested by

no test coverage detected