Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bf5b646

Browse filesBrowse files
ncoghlanmethane
andauthored
GH-119496: accept UTF-8 BOM in .pth files (GH-119503)
`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 <songofacandy@gmail.com>
1 parent 92fab33 commit bf5b646
Copy full SHA for bf5b646

File tree

1 file changed

+3
-1
lines changed
Filter options

1 file changed

+3
-1
lines changed

‎Lib/site.py

Copy file name to clipboardExpand all lines: Lib/site.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ def addpackage(sitedir, name, known_paths):
185185
return
186186

187187
try:
188-
pth_content = pth_content.decode()
188+
# Accept BOM markers in .pth files as we do in source files
189+
# (Windows PowerShell 5.1 makes it hard to emit UTF-8 files without a BOM)
190+
pth_content = pth_content.decode("utf-8-sig")
189191
except UnicodeDecodeError:
190192
# Fallback to locale encoding for backward compatibility.
191193
# We will deprecate this fallback in the future.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.