Skip to content

UnicodeEncodeError on Windows with emoji in logging output #55

@jensens

Description

@jensens

Description

mxdev fails on Windows CI with a UnicodeEncodeError when logging a message containing an emoji (🎂) on line 81 of main.py.

Error Message

--- Logging error ---
Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\logging\__init__.py", line 1086, in emit
    stream.write(msg + self.terminator)
  File "C:\hostedtoolcache\windows\Python\3.9.13\x64\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 '\U0001f382' in position 0: character maps to <undefined>
Message: '🎂 You are now ready for: pip install -r requirements-mxdev.txt'

Root Cause

Windows console uses cp1252 encoding by default, which cannot represent Unicode emojis. The emoji on main.py:81 causes this error when Python's logging module attempts to write to stdout.

Impact

  • Logging errors appear in Windows CI output
  • Does not fail tests but creates noise in CI logs
  • Violates project code style: "Only use emojis if the user explicitly requests it"

Reproduction

A test has been added in tests/test_logging.py::test_emoji_logging_with_cp1252_encoding() that reproduces this issue on Linux by simulating the Windows cp1252 encoding environment.

pytest tests/test_logging.py::test_emoji_logging_with_cp1252_encoding -v

Solution

Remove the emoji from line 81 in src/mxdev/main.py and replace with plain text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions