Skip to content

Commit 4eddb84

Browse files
authored
Fix GBK codec error when reading pyproject.toml
Added encoding="utf-8" to file read/write operations in bump_version.py to handle pyproject.toml with UTF-8 encoding, resolving 'gbk' codec can't decode byte 0xbf error at position 1779.
1 parent 82bc896 commit 4eddb84

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/bump_version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
def get_current_version():
1818
"""Extract current version from pyproject.toml."""
1919
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
20-
content = pyproject_path.read_text()
20+
content = pyproject_path.read_text(encoding="utf-8")
2121
match = re.search(r'version = "(\d+\.\d+\.\d+)"', content)
2222
if not match:
2323
raise ValueError("Could not find version in pyproject.toml")
@@ -41,14 +41,14 @@ def bump_version(current_version, bump_type):
4141
def update_version(new_version):
4242
"""Update version in pyproject.toml."""
4343
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
44-
content = pyproject_path.read_text()
44+
content = pyproject_path.read_text(encoding="utf-8")
4545

4646
# Update version
4747
new_content = re.sub(
4848
r'version = "\d+\.\d+\.\d+"', f'version = "{new_version}"', content
4949
)
5050

51-
pyproject_path.write_text(new_content)
51+
pyproject_path.write_text(new_content,encoding="utf-8")
5252

5353
# run uv sync
5454
subprocess.run(["uv", "sync"])

0 commit comments

Comments
 (0)