What is the doc issue?
Describe the issue
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.
Suggested change:
HTML_REDIRECT_TEMPLATE = HTML_PAGE_TEMPLATE_FILE.open("r", encoding="utf-8").read()
with open(redirect_page_path, "w", encoding="utf-8") as f:
f.write(redirect_page)
with open(REDIRECT_URLS_FILE, "r", encoding="utf-8") as f:
lines = f.readlines()
Link to the doc page, if applicable
https://github.com/microsoft/autogen/blob/main/python/docs/redirects/redirects.py
What is the doc issue?
Describe the issue
python/docs/redirects/redirects.pyreads and writes redirect-related files without specifying an explicit encoding.The script currently reads
redirect_template.htmlandredirect_urls.txt, then writes generated redirectindex.htmlfiles 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
UnicodeDecodeErrororUnicodeEncodeErrorif 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.pyshould explicitly useencoding="utf-8"when reading and writing text files.Suggested change:
Link to the doc page, if applicable
https://github.com/microsoft/autogen/blob/main/python/docs/redirects/redirects.py