Skip to content

Logging a unicode character to a file fails on Windows #5941

@lyovushka

Description

@lyovushka

Have you checked closed issues? (https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed) Yes

Have you checked against the most recent version of Textual? (https://pypi.org/search/?q=textual) Yes

Here is an example to reproduce the issue:

import os
os.environ["TEXTUAL_LOG"] = "log"

import textual

textual.log(":")

On Windows this crashes with:
UnicodeEncodeError: 'charmap' codec can't encode character '\uff1a' in position 0: character maps to <undefined>

It would be relatively easily fixed by specifing encoding="utf-8" when opening the log file in src/textual/__init__.py. But to be honest I am not completely sure what is the recommended way of dealing with encoding issues in python. Maybe it is up to the user to make sure the encodings match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions