You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 20, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 20, 2026. It is now read-only.
docs: use explicit UTF-8 encoding in redirect generation script #7749
python/docs/redirects/redirects.py reads and writes redirect-related files without specifying an explicit encoding.
The script currently reads redirect_template.html and redirect_urls.txt, then writes generated redirect index.html files using Python's default system encoding.
This is probably fine in most environments, but on some Windows locales where the default encoding is not UTF-8, the script could fail with a UnicodeDecodeError or UnicodeEncodeError if the files contain non-ASCII characters.
This is more of a docs tooling portability issue than a runtime bug.
What do you want to see in the doc?
I think python/docs/redirects/redirects.py should explicitly use encoding="utf-8" when reading and writing text files.
Sure, let's address this. We've seen similar issues in the past where explicit encoding can prevent unexpected errors, especially on different operating systems. Here's what we can do:
Explicit Encoding: We should explicitly set the encoding to utf-8 for both reading and writing files. This ensures that the script works consistently across different environments.
Code Example: Here's how you can modify the script:
I agree that explicitly setting encoding="utf-8" is important to avoid platform-dependent issues across different OS locales.
I’ve already opened PR #7750 to address this by applying explicit UTF-8 encoding to the relevant read/write operations in redirects.py. Please let me know if any additional tests or documentation updates are needed.
I'd like to take this one (docs: use explicit UTF-8 encoding in redirect generation scr). I'll dig into the root cause and follow up with a PR shortly. (claiming via Stella (@LeonxLJX))
I'd like to take this one (docs: use explicit UTF-8 encoding in redirect generation scr). I'll look into the root cause and follow up with a PR. (claiming via Stella (@LeonxLJX))
Activity
reallyticsai commentedon May 29, 2026
Sure, let's address this. We've seen similar issues in the past where explicit encoding can prevent unexpected errors, especially on different operating systems. Here's what we can do:
Explicit Encoding: We should explicitly set the encoding to
utf-8for both reading and writing files. This ensures that the script works consistently across different environments.Code Example: Here's how you can modify the script:
Testing: After making these changes, it's crucial to test the script in different locales to ensure it handles non-ASCII characters correctly.
Documentation: Update the doc to reflect these changes and explain why explicit encoding is important.
By making these adjustments, we can avoid potential runtime errors and ensure the script runs smoothly across various locales.
wkd09 commentedon May 29, 2026
Thanks for the suggestion.
I agree that explicitly setting
encoding="utf-8"is important to avoid platform-dependent issues across different OS locales.I’ve already opened PR #7750 to address this by applying explicit UTF-8 encoding to the relevant read/write operations in
redirects.py. Please let me know if any additional tests or documentation updates are needed.fix(docs): use explicit UTF-8 encoding in redirect generation script
LeonxLJX commentedon Sep 1, 2026
I'd like to take this one (
docs: use explicit UTF-8 encoding in redirect generation scr). I'll dig into the root cause and follow up with a PR shortly. (claiming via Stella (@LeonxLJX))LeonxLJX commentedon Sep 1, 2026
I'd like to take this one (
docs: use explicit UTF-8 encoding in redirect generation scr). I'll look into the root cause and follow up with a PR. (claiming via Stella (@LeonxLJX))LeonxLJX commentedon Sep 1, 2026
Hi! I'd like to add explicit UTF-8 encoding in the redirect generation script. Trivial fix. May I be assigned?
docs: use explicit UTF-8 encoding in redirect generation script
docs: use explicit UTF-8 encoding in redirect generation script