Skip to content

Conversation

@yuxiaoli
Copy link

This PR forces UTF-8 encoding when running git subprocess commands to prevent UnicodeDecodeError on systems with different default encodings (e.g., GBK on Windows).

@tomice
Copy link
Collaborator

tomice commented Dec 16, 2025

Thank you for your contribution! It looks like the unit tests fail because of the new args you are adding not matching up with the expected args in the tests:

AssertionError: expected call not found.
Expected: run(['git', 'status'], stdout=-1, stderr=-1, text=True, check=True)
Actual: run(['git', 'status'], stdout=-1, stderr=-1, text=True, check=True, encoding='utf-8', errors='replace')

https://github.com/git-quick-stats/git-py-stats/blob/main/git_py_stats/tests/test_git_operations.py

Should we be doing errors=replace here, or do we look towards PEP323 for guidance and instead use errors=surrogateescape? I am fine with either/or, but the argument for surrogateescape seems compelling: https://docs.python.org/3/library/codecs.html

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.

2 participants