My previous thread is hijacked about "auto guessing" idea, so I split this thread for pathlib.
Path.open() was added in Python 3.4. Path.read_text() and Path.write_text() was added in Python 3.5. Their history is shorter than built-in open(). Changing its default encoding should be easier than built-in open and TextIOWrapper. New default encodings are:
* read_text() default encoding is "utf-8-sig" * write_text() default encoding is "utf-8" * open() default encoding is "utf-8-sig" when mode is "r" or None, "utf-8" otherwise.
Of course, we need a regular deprecation period. When encoding is omitted, they emit DeprecationWarning (or EncodingWarning which is a subclass of DeprecationWarning) in three versions (Python 3.10~3.12).
How do you think this idea? Should we "change all at once" rather than "step-by-step"?
Regards, -- Inada Naoki email@example.com