poml
poml copied to clipboard
[Bug] UnicodeDecodeError when reading poml file on Windows Chinese environment
UnicodeDecodeError when reading poml file on Windows Chinese environment
Description
When using poml to read a .poml file (utf-8) on Windows with Chinese locale, a UnicodeDecodeError occurs because the system tries to decode the file with GBK codec instead of UTF-8.
Error
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 61: illegal multibyte sequence
Environment
- poml 0.0.8
- Windows Chinese environment
- Python 3.13.2
- utf-8 python & poml file
Log
File "test\test.py", line 50, in main
prompt: str = poml.poml(
~~~~~~~~~^
Path(__file__).parent / "data.poml",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
context=context_dict,
^^^^^^^^^^^^^^^^^^^^^
format="raw",
^^^^^^^^^^^^^
) # pyright: ignore[reportAssignmentType]
^
File ".venv\Lib\site-packages\poml\api.py", line 601, in poml
result = temp_output_file.read()
File "\uv\python\cpython-3.13.2-windows-x86_64-none\Lib\tempfile.py", line 499, in func_wrapper
return func(*args, **kwargs)
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 61: illegal multibyte sequence
@EcoleKeine Now it has already fixed #140.
@icelinks the pr is merged but no new version released