Python 3.15, released on October 9, introduced PEP 686, which sets UTF-8 as the default encoding for file operations. This change affects the open() function, subprocess calls, and standard streams, which previously relied on the system locale to determine encoding.
Applications interacting with legacy systems using cp1251, such as 1C exports or bank statements, may encounter errors or data corruption if the encoding is not explicitly defined. While some scripts will fail immediately with a UnicodeDecodeError, others may silently write incorrectly encoded files.
To identify potential issues, developers can use the -X warn_default_encoding flag to trigger warnings for any file operations missing an explicit encoding argument. Additionally, the ruff linter provides the PLW1514 rule to detect unspecified encodings in the codebase.
The recommended fix is to explicitly specify the encoding in all file-related functions. For external files, the correct encoding (e.g., cp1251) should be set, while internal files should use utf-8. For temporary compatibility, the environment variable PYTHONUTF8=0 can revert to the old behavior.




