Skip to content

Fix issue 10264 unicode docode error #10350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

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