PYTHONCOERCECLOCALE PYTHONDEVMODE PYTHONUTF8 As a consequence of the changes in those lower level APIs, other higher level APIs also exhibit different default behaviours: If set to 1 , enables the interpreter’s UTF-8 mode, where $_{UTF-8}$is used as the text encoding for system interfaces, regardless of the current locale setting. This means that: If this environment variable is set to a non-empty string, enable Python Development Mode, introducing ad- ditional runtime checks that are too expensive to be enabled by default. New in version 3.7. New in version 3.7: See PEP 538 for more details. Availability: *nix. Also note that even when locale coercion is disabled, or when it fails to find a suitable target locale, PYTHONUTF8 will still activate by default in legacy ASCII-based locales. Both features must be disabled in order to force the interpreter to use$_{ASCII}$ instead of$_{UTF-8}$for system interfaces. For debugging purposes, setting$_{PYTHONCOERCECLOCALE=warn}$ will cause Python to emit warning mes- sages on$_{stderr}$ if either the locale coercion activates, or else if a locale that would have triggered coercion is still active when the Python runtime is initialized. Configuring one of these locales (either explicitly or via the above implicit locale coercion) automatically en- ables the$_{surrogateescape}$error handler for$_{sys.stdin}$ and$_{sys.stdout}$ ($_{sys.stderr}$continues to use$_{backslashreplace}$ as it does in any other locale). This stream handling behavior can be overridden using PYTHONIOENCODING as usual. If setting one of these locale categories succeeds, then the$_{LC_CTYPE}$ environment variable will also be set accordingly in the current process environment before the Python runtime is initialized. This ensures that in addition to being seen by both the interpreter itself and other locale-aware components running in the same process (such as the GNU readline library), the updated setting is also seen in subprocesses (regardless of whether or not those processes are running a Python interpreter), as well as in operations that query the environment rather than the current C locale (such as Python’s own locale.getdefaultlocale() ). If this variable is not set (or is set to a value other than 0 ), the LC_ALL locale override environment variable is also not set, and the current locale reported for the LC_CTYPE category is either the default C locale, or else the explicitly ASCII-based POSIX locale, then the Python CLI will attempt to configure the following locales for the$_{LC_CTYPE}$ category in the order listed before loading the interpreter runtime: If set to the value 0 , causes the main Python command line application to skip coercing the legacy ASCII-based C and POSIX locales to a more capable UTF-8 based alternative. Availability: Windows. New in version 3.6. • C.UTF-8 • C.utf8 • UTF-8 • sys.getfilesystemencoding() returns$_{'UTF-8'}$ (the locale encoding is ignored). • locale.getpreferredencoding() returns$_{'UTF-8'}$ (the locale encoding is ignored, and the function’s$_{do_setlocale}$ parameter has no effect). • sys.stdin , sys.stdout , and $_{sys.stderr}$all use UTF-8 as their text encoding, with the $_{surrogateescape}$error handler being enabled for $_{sys.stdin}$and sys.stdout ($_{sys.}$ $_{stderr}$continues to use$_{backslashreplace}$ as it does in the default locale-aware mode) • Command line arguments, environment variables and filenames are decoded to text using the UTF-8 encoding. Chapter 1. Command line and environment 12 Python Setup and Usage, Release 3.9.5