[PR #856] [MERGED] fix: UnicodeError for non-ascii headers #772

Closed
opened 2026-02-27 23:02:20 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/sigma67/ytmusicapi/pull/856
Author: @mokurin000
Created: 1/24/2026
Status: Merged
Merged: 1/31/2026
Merged by: @sigma67

Base: mainHead: fix/unicode-error


📝 Commits (3)

  • b520103 fix: UnicodeError for non-ascii headers
  • 3123cb2 test: remove useless encoding for temporary file creation
  • 9b982b5 test: fix listenAgainFeedbackTokens KeyError

📊 Changes

4 files changed (+30 additions, -10 deletions)

View changed files

📝 tests/auth/test_oauth.py (+4 -5)
📝 tests/mixins/test_library.py (+5 -1)
📝 ytmusicapi/auth/auth_parse.py (+20 -3)
📝 ytmusicapi/auth/oauth/token.py (+1 -1)

📄 Description

solve #855

Changes

All file open are forced to use 'utf-8' encoding, regardless on what platform, on python it was likely utf-8 on Linux and MacOS, and ANSI for Windows.

Also, this ensures headers to be encoded in URLEncode, thus, unicode characters are encoded as %E7%E6%F7, e.g.

from string import printable
from urllib.parse import quote

# '__Sec=%E4%BD%A0%E5%A5%BD,Hello; __Sec1=%E4%B8%96%E7%95%8C,World'
quote("__Sec=你好,Hello; __Sec1=世界,World", safe=printable)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/sigma67/ytmusicapi/pull/856 **Author:** [@mokurin000](https://github.com/mokurin000) **Created:** 1/24/2026 **Status:** ✅ Merged **Merged:** 1/31/2026 **Merged by:** [@sigma67](https://github.com/sigma67) **Base:** `main` ← **Head:** `fix/unicode-error` --- ### 📝 Commits (3) - [`b520103`](https://github.com/sigma67/ytmusicapi/commit/b520103dffa76a5388e039750b8e12035d171373) fix: UnicodeError for non-ascii headers - [`3123cb2`](https://github.com/sigma67/ytmusicapi/commit/3123cb25afb76a9783e617d7f3cb5f5903c9f4f2) test: remove useless `encoding` for temporary file creation - [`9b982b5`](https://github.com/sigma67/ytmusicapi/commit/9b982b5489888cae44a82493727610606a3e12fc) test: fix `listenAgainFeedbackTokens` KeyError ### 📊 Changes **4 files changed** (+30 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `tests/auth/test_oauth.py` (+4 -5) 📝 `tests/mixins/test_library.py` (+5 -1) 📝 `ytmusicapi/auth/auth_parse.py` (+20 -3) 📝 `ytmusicapi/auth/oauth/token.py` (+1 -1) </details> ### 📄 Description solve #855 ## Changes All file open are forced to use 'utf-8' encoding, regardless on what platform, on python it was likely utf-8 on Linux and MacOS, and ANSI for Windows. Also, this ensures headers to be encoded in URLEncode, thus, unicode characters are encoded as `%E7%E6%F7`, e.g. ```python from string import printable from urllib.parse import quote # '__Sec=%E4%BD%A0%E5%A5%BD,Hello; __Sec1=%E4%B8%96%E7%95%8C,World' quote("__Sec=你好,Hello; __Sec1=世界,World", safe=printable) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 23:02:20 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#772
No description provided.