Skip to content

explain_output_differences escape unicode is needlessly restrictive #29

Open
@insou22

Description

@insou22

https://github.com/COMP1511UNSW/autotest/blob/main/explain_output_differences.py#L379

# ...
        if len(line) > max_line_length_shown:
            line = line[0:max_line_length_shown] + " ..."
        line = line.encode("unicode_escape").decode("ascii")
        if leave_colorization:
            line = line.replace(r"\x1b", "\x1b")
        if leave_tabs:
            line = line.replace(r"\t", "\t")
            line = line.replace(r"\\", "\\")
# ...

I would like to see the line line = line.encode("unicode_escape").decode("ascii") removed ideally,
but @hexDoor has pointed out that this may be necessary to escape things away such as ANSI colour codes.

Unfortunately it escapes normal characters that are of multi-byte width (eg. other language codepoints, emojis, etc.)

Can we make it less restrictive, i.e. normally render displayable characters, and just escape dangerous/non-displayable bytes away?

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