Skip to content

Commit d158083

Browse files
committed
Fix UnicodeDecodeError in gitreport on Windows with UTF-8 commit messages
1 parent 939099d commit d158083

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog #
22

3+
## Version 3.13.3 ##
4+
5+
🛠️ Bug fixes:
6+
7+
* **Git report utility**: Fixed UnicodeDecodeError on Windows when commit messages contain non-ASCII characters
8+
* The `guidata.utils.gitreport` module now explicitly uses UTF-8 encoding when reading Git command output
9+
* Previously, on Windows systems with cp1252 default encoding, Git commit messages containing Unicode characters (emoji, accented characters, etc.) would cause a `UnicodeDecodeError`
10+
* Fixed by adding `encoding="utf-8"` parameter to all `subprocess.check_output()` calls in `_extract_git_information()`
11+
* This ensures proper decoding of Git output which is always UTF-8 encoded, regardless of the system's default encoding
12+
313
## Version 3.13.2 ##
414

515
✨ New features:

guidata/utils/gitreport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,17 @@ def _extract_git_information(repo_path: str) -> tuple[str, str, str] | None:
163163

164164
# Get branch name
165165
branch = subprocess.check_output(
166-
["git", "rev-parse", "--abbrev-ref", "HEAD"], text=True
166+
["git", "rev-parse", "--abbrev-ref", "HEAD"], text=True, encoding="utf-8"
167167
).strip()
168168

169169
# Get short commit hash
170170
commit = subprocess.check_output(
171-
["git", "rev-parse", "--short", "HEAD"], text=True
171+
["git", "rev-parse", "--short", "HEAD"], text=True, encoding="utf-8"
172172
).strip()
173173

174174
# Get commit message (first line only, truncated if needed)
175175
message = subprocess.check_output(
176-
["git", "log", "-1", "--pretty=%B"], text=True
176+
["git", "log", "-1", "--pretty=%B"], text=True, encoding="utf-8"
177177
).strip()
178178

179179
if len(message.splitlines()) > 1:

0 commit comments

Comments
 (0)