[GH-ISSUE #1184] UnicodeDecodeError on Windows when running tito module complete (cp1252 vs UTF-8 encoding issue) when completing module 03 #4343

Closed
opened 2026-04-19 12:21:28 -05:00 by GiteaMirror · 4 comments
Owner

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

Image

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.

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 <img width="1860" height="982" alt="Image" src="https://github.com/user-attachments/assets/06f5cac6-dafa-4974-8939-750148749ab7" /> **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.
GiteaMirror added the type: bugarea: tinytorch labels 2026-04-19 12:21:28 -05:00
Author
Owner

@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

<!-- gh-comment-id:3938889633 --> @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
Author
Owner

@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-contributorsrc
  • tinytorch/README.md
  • Main README.md

We love recognizing our contributors! ❤️

<!-- gh-comment-id:3938892803 --> @github-actions[bot] commented on GitHub (Feb 21, 2026): I've added @Pratham-ja as a contributor to **tinytorch**! :tada: **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-contributorsrc` - `tinytorch/README.md` - Main `README.md` We love recognizing our contributors! :heart:
Author
Owner

@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!

<!-- gh-comment-id:3938935521 --> @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!
Author
Owner

@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. 🙏

<!-- gh-comment-id:3938938036 --> @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. 🙏
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#4343