You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running cz init on Windows, the command fails with a UnicodeDecodeError due to the default file encoding being 'gbk' instead of 'utf-8'.
Steps to Reproduce
Create a new Python project on Windows with Chinese system locale
Install commitizen
Run cz init
Select pyproject.toml as config file
Select commit rule
Error Message
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 52: illegal multibyte sequence
Technical Details
The error occurs in commitizen/commands/init.py when checking for poetry configuration:
@propertydefis_python_poetry(self) ->bool:
ifnotself.has_pyproject:
returnFalsewithopen("pyproject.toml") asf:
return"[tool.poetry]"inf.read()) # Here the file is opened without specifying encoding
Expected Behavior
The file should be opened with UTF-8 encoding explicitly to ensure consistent behavior across different system locales.
Suggested Fix
# In commitizen/commands/init.py@propertydefis_python_poetry(self) ->bool:
ifnotself.has_pyproject:
returnFalsewithopen("pyproject.toml", encoding=self.settings["encoding"]) asf: # self.settings["encoding"] default is utf-8return"[tool.poetry]"inf.read())
Environment
OS: Windows
Python Version: 3.12
Commitizen Version: latest
System Locale: Chinese (Simplified)
ScreenShot
The text was updated successfully, but these errors were encountered:
Description
When running
cz init
on Windows, the command fails with a UnicodeDecodeError due to the default file encoding being 'gbk' instead of 'utf-8'.Steps to Reproduce
cz init
pyproject.toml
as config fileError Message
Technical Details
The error occurs in
commitizen/commands/init.py
when checking for poetry configuration:Expected Behavior
The file should be opened with UTF-8 encoding explicitly to ensure consistent behavior across different system locales.
Suggested Fix
Environment
ScreenShot
The text was updated successfully, but these errors were encountered: