GTNewHorizons/DreamAssemblerXXL

issue with the locale on windows

Opened this issue · 1 comments

ran this in the root of the project:

poetry install
poetry run python -m gtnh.cli.update_check
poetry run python -m gtnh.cli.generate_nightly
poetry run python -m gtnh.cli.download_release nightly

got this crash:

Traceback (most recent call last):
  File "C:\Users\Alexis\Desktop\gtnh modpack\DreamAssemblerXXL\src\gtnh\cli\download_release.py", line 17, in do_download_release
    await m.download_release(release=release)
  File "C:\Users\Alexis\Desktop\gtnh modpack\DreamAssemblerXXL\src\gtnh\modpack_manager.py", line 519, in download_release
    downloaded = [d for d in await asyncio.gather(*downloaders) if d is not None]
  File "C:\Users\Alexis\Desktop\gtnh modpack\DreamAssemblerXXL\src\gtnh\modpack_manager.py", line 446, in download_github_mod
    log.info(f"{GREEN_CHECK} Download successful `{mod_filename}`")
  File "C:\Users\Alexis\Desktop\gtnh modpack\DreamAssemblerXXL\.venv\lib\site-packages\structlog\_log_levels.py", line 124, in meth
    return self._proxy_to_logger(name, event, **kw)
  File "C:\Users\Alexis\Desktop\gtnh modpack\DreamAssemblerXXL\.venv\lib\site-packages\structlog\_base.py", line 204, in _proxy_to_logger
    return getattr(self._logger, method_name)(*args, **kw)
  File "C:\Users\Alexis\Desktop\gtnh modpack\DreamAssemblerXXL\.venv\lib\site-packages\structlog\_loggers.py", line 111, in msg
    until_not_interrupted(self._write, message + "\n")
  File "C:\Users\Alexis\Desktop\gtnh modpack\DreamAssemblerXXL\.venv\lib\site-packages\structlog\_utils.py", line 26, in until_not_interrupted
    return f(*args, **kw)
  File "C:\Program Files\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2705' in position 32: character maps to <undefined>

using chcp 65001 before running poetry run python -m gtnh.cli.download_release nightly fixes the issue

Potential workarounds:

If it is enough to replace all unencodable characters with ? in your case then you could set [PYTHONIOENCODING envvar](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONIOENCODING):

T:\> set PYTHONIOENCODING=:replace
T:\> python3 -c "print(u'[\N{EURO SIGN}]')"
[?]

In Python 3.6+, the encoding specified by PYTHONIOENCODING envvar is ignored for interactive console buffers unless PYTHONLEGACYWINDOWSIOENCODING envvar is set to a non-empty string.