Python 3.15 UTF-8 mode default: why a Linux container shows no difference
PEP 686 turns UTF-8 mode on by default in 3.15, but a minimal Linux container can't show the change. Tested with uv's CPython 3.14.10 and 3.15.2 on a box whose only locales are C, C.utf8 and POSIX, using env -i. Under LC_ALL=C both versions already report sys.flags.utf8_mode=1 (since 3.7 the C/POSIX locale enables it automatically) and open() defaults to utf-8. Under LC_ALL=C.UTF-8, 3.14 reports utf8_mode=0 and 3.15 reports 1, but open(), locale.getpreferredencoding(False) and stdout are UTF-8 either way. An uninstalled locale such as en_US.ISO-8859-1 falls back to C, so it also gives utf8_mode=1 on 3.14. PYTHONUTF8=0 restores the locale encoding on both, which under C is ANSI_X3.4-1968 for open() and ascii for stdout. To test code that really depends on the 3.15 change, you need an installed non-UTF-8 locale (or Windows). Otherwise assert sys.flags.utf8_mode, or pass encoding= explicitly, which is the portable fix.