While testing PR #395, I found that test_rendering.py::TestRenderTimesheet::test_creates_only_final_file fails locally on Windows with:
UnicodeEncodeError: 'charmap' codec can't encode characters in position 570-575: character maps to
This happens in tuttle/rendering.py at the render_timesheet function, when writing the rendered HTML:
timesheet_file.write(html)
The file write doesn't specify an encoding, so Python defaults to the system locale encoding (cp1252 on Windows) instead of UTF-8, which fails on non-ASCII characters in the rendered template.
This doesn't show up in CI (likely running on Linux/macOS where UTF-8 is the default), but it does reproduce consistently on Windows. Confirmed via git stash that this also fails on main, unrelated to my PR (#395).
Suggested fix: explicitly open the file with encoding="utf-8", e.g.:
with open(path, "w", encoding="utf-8") as timesheet_file:
...
While testing PR #395, I found that
test_rendering.py::TestRenderTimesheet::test_creates_only_final_filefails locally on Windows with:UnicodeEncodeError: 'charmap' codec can't encode characters in position 570-575: character maps to
This happens in
tuttle/rendering.pyat therender_timesheetfunction, when writing the rendered HTML:The file write doesn't specify an encoding, so Python defaults to the system locale encoding (cp1252 on Windows) instead of UTF-8, which fails on non-ASCII characters in the rendered template.
This doesn't show up in CI (likely running on Linux/macOS where UTF-8 is the default), but it does reproduce consistently on Windows. Confirmed via
git stashthat this also fails onmain, unrelated to my PR (#395).Suggested fix: explicitly open the file with
encoding="utf-8", e.g.: