Skip to content

Conversation

sugarkwork
Copy link

Title

Fix UnicodeDecodeError on non-English OS by specifying UTF-8 encoding when opening files

Relevant issues

Fixes #10264

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

Type

🐛 Bug Fix

Changes

  • Changed all occurrences of open("r") to open("r", encoding="utf-8") to ensure files are read as UTF-8 rather than the platform default, preventing UnicodeDecodeError on non-English OSes.
  • Added a unit test at tests/litellm_utils_tests/test_utils.py to verify that anthropic_tokenizer.json is read correctly with UTF-8 encoding.

screenshot

image

Copy link

vercel bot commented Apr 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 27, 2025 2:42am

@CLAassistant
Copy link

CLAassistant commented Apr 27, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: UnicodeDecodeError
2 participants