mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-11 17:02:22 -05:00
[GH-ISSUE #1184] UnicodeDecodeError on Windows when running tito module complete (cp1252 vs UTF-8 encoding issue) when completing module 03
#4343
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Pratham-ja on GitHub (Feb 19, 2026).
Original GitHub issue: https://github.com/harvard-edge/cs249r_book/issues/1184
UnicodeDecodeError on Windows when running "tito module complete 03" (cp1252 vs UTF-8 issue)
Description
When running:
tito module complete 03 on Windows, the command crashes during the Unit Tests step with a UnicodeDecodeError, followed by a secondary AttributeError.This prevents module completion even when the implementation is correct.
Environment
OS: Windows 11
Shell: Git Bash (MINGW64)
Python: 3.11.x
TinyTorch: latest version
Default Windows encoding: cp1252
Full Error Trace
Root Cause
On Windows: subprocess.run() defaults to the system encoding (cp1252).
The unit test output contains UTF-8 characters
cp1252 cannot decode certain UTF-8 byte sequences
The subprocess reader thread crashes
result.stdout becomes None
_parse_test_output() assumes stdout is a string and calls .split()
This causes the secondary AttributeError
This is a platform-specific encoding issue due to not explicitly setting encoding="utf-8" in subprocess.run().
Proposed Fix
Explicitly specify UTF-8 encoding when running subprocess in:
tito/commands/module/workflow.py
Change the subprocess call to:
result = subprocess.run(
...,
text=True,
encoding="utf-8",
errors="replace"
)
This ensures consistent behavior across platforms.
Temporary Workaround (for Windows users)
Users can run if they are using git bash:
export PYTHONUTF8=1
before executing tito module complete. However, this should not be required and should ideally be handled within the tool.
Contribution
I’d be glad to take this up and submit a PR implementing the UTF-8 encoding fix along with the defensive safeguard.
Please feel free to assign this issue to me if the proposed solution aligns with the project direction.
@profvjreddi commented on GitHub (Feb 21, 2026):
Hi @Pratham-ja
Thanks for the detailed report and suggested fix. I’ve implemented the UTF-8 encoding change in tito/commands/module/workflow.py — both subprocess.run() calls now use encoding="utf-8" and errors="replace", which should resolve the UnicodeDecodeError on Windows.
I’ve also added you as a co-author on the commit since the fix follows your proposal. 🤗
@all-contributors please add @Pratham-ja as a contributor for Bug, Code in TinyTorch
@github-actions[bot] commented on GitHub (Feb 21, 2026):
I've added @Pratham-ja as a contributor to tinytorch! 🎉
Recognized for: code, bug
Project: tinytorch (explicitly mentioned in comment)
Based on: @all-contributors please add @Pratham-ja as a contributor for Bug, Code in TinyTorch
The contributor list has been updated in:
tinytorch/.all-contributorsrctinytorch/README.mdREADME.mdWe love recognizing our contributors! ❤️
@Pratham-ja commented on GitHub (Feb 21, 2026):
Thank you for implementing the fix so quickly and for adding me as a co-author — I truly appreciate it!
I'm glad the proposed solution worked well. I’m looking forward to contributing more to TinyTorch — it’s a really great project, and I’d be happy to stay involved.
Thanks again!
@profvjreddi commented on GitHub (Feb 21, 2026):
Hey @Pratham-ja, sure thing. My favorite thing about this project (or, in fact, any project) is when the community gets involved. Thank you for spending time on this and making it better for everyone. 🙏