-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
GH-119496: accept UTF-8 BOM in .pth files #119503
GH-119496: accept UTF-8 BOM in .pth files #119503
Conversation
`Out-File -Encoding utf8` in Windows Powershell 5.1 emits UTF-8 with a BOM maker, which the regular `utf-8` codec decodes incorrectly. `utf-8-sig` accepts a BOM, but also works correctly without one.
I flagged this as skipping news, as it seems like part of the not-yet-released gh-77102 changes to me. |
PowerShell 5.1 is very old and will be EOL in 2025. I am not sure about adding some support for it is worth enough. |
+1 from me. Any time we know we're decoding the start of a file, there's no harm in using I wouldn't use it anywhere we write to a file. It's a bit unfortunate we don't have an encoding that will silently drop a BOM at the start of a buffer without also adding one going the other direction. (Or an encoding that will detect a BOM and switch to UTF-8, or else use |
Co-authored-by: Inada Naoki <[email protected]>
Thanks @ncoghlan for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
`Out-File -Encoding utf8` and similar commands in Windows Powershell 5.1 emit UTF-8 with a BOM marker, which the regular `utf-8` codec decodes incorrectly. `utf-8-sig` accepts a BOM, but also works correctly without one. This change also makes .pth files match the way Python source files are handled. (cherry picked from commit bf5b646) Co-authored-by: Alyssa Coghlan <[email protected]> Co-authored-by: Inada Naoki <[email protected]>
`Out-File -Encoding utf8` and similar commands in Windows Powershell 5.1 emit UTF-8 with a BOM marker, which the regular `utf-8` codec decodes incorrectly. `utf-8-sig` accepts a BOM, but also works correctly without one. This change also makes .pth files match the way Python source files are handled. (cherry picked from commit bf5b646) Co-authored-by: Alyssa Coghlan <[email protected]> Co-authored-by: Inada Naoki <[email protected]>
GH-119508 is a backport of this pull request to the 3.13 branch. |
GH-119509 is a backport of this pull request to the 3.12 branch. |
|
`Out-File -Encoding utf8` and similar commands in Windows Powershell 5.1 emit UTF-8 with a BOM marker, which the regular `utf-8` codec decodes incorrectly. `utf-8-sig` accepts a BOM, but also works correctly without one. This change also makes .pth files match the way Python source files are handled. Co-authored-by: Inada Naoki <[email protected]>
Out-File -Encoding utf8
in Windows Powershell 5.1 emitsUTF-8 with a BOM marker, which the regular
utf-8
codecdecodes incorrectly.
utf-8-sig
accepts a BOM, but alsoworks correctly without one.