pyramid_debugtoolbar icon indicating copy to clipboard operation
pyramid_debugtoolbar copied to clipboard

Don't fail on non-str, non-bytes __traceback_info__

Open adrian-zon opened this issue 11 months ago • 0 comments

In 1c050afa8c839ac73f9d96fbb1034a7910ce8a74,

            info = text_(info, errors='replace')

was replaced by

            info = str(info, errors='replace')

with _text being:

if PY3:  # pragma: no cover
    # […]
    binary_type = bytes
    # […]
else:
    # […]
    binary_type = str
    # […]

# […]

def text_(s, encoding='latin-1', errors='strict'):
    if isinstance(s, binary_type):
        return s.decode(encoding, errors)
    return s  # pragma: no cover

This broke all cases of __traceback_info__ being something else than a str or a bytes, given that

If at least one of encoding or errors is given, object should be a bytes-like object (e.g. bytes or bytearray).

adrian-zon avatar Feb 14 '25 13:02 adrian-zon