New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-43510: Implement PEP 597 opt-in EncodingWarning. #19481
Conversation
c37295e
to
6f72b38
Compare
The warning is raised only in dev mode. pathlib uses the new `io.text_encoding` helper function. Other libraries will follow.
sys.flags.encoding_warning -> warn_default_encoding -X warn_encoding -> warn_default_encoding PYTHONWARNENCODING -> PYTHONWARNDEFAULTENCODING
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Thanks @methane ! I've replied to your comments with updated suggestions to reflect your feedback. |
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
I will merge this PR next week if there are no objections. |
|
|
|
test_locale fail is unrelating to this PR. See bpo-37945. |
Thanks @methane ! Excited to see this in Python 3.10. |
See [PEP 597](https://www.python.org/dev/peps/pep-0597/). * Add `-X warn_default_encoding` and `PYTHONWARNDEFAULTENCODING`. * Add EncodingWarning * Add io.text_encoding() * open(), TextIOWrapper() emits EncodingWarning when encoding is omitted and warn_default_encoding is enabled. * _pyio.TextIOWrapper() uses UTF-8 as fallback default encoding used when failed to import locale module. (used during building Python) * bz2, configparser, gzip, lzma, pathlib, tempfile modules use io.text_encoding(). * What's new entry
See PEP 597.
-X warn_default_encoding
andPYTHONWARNDEFAULTENCODING
.bpo-43510