Commit 038ac847 authored by Daniel Kahn Gillmor's avatar Daniel Kahn Gillmor Committed by Chris Lamb
Browse files

Avoid line eraser error on dumb terminals. (Closes: #906967)



Try the following:

    touch a b
    TERM=dumb diffoscope a b

The result is some nasty warnings about:

    AttributeError: 'bytes' object has no attribute 'format'

This patch fixes the problem.

Signed-off-by: Chris Lamb's avatarChris Lamb <lamby@debian.org>
parent 35224764
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -30,10 +30,10 @@ def line_eraser(fd=sys.stderr) -> bytes:
        eraser = tigetstr('el')

    if not eraser and fd.isatty():
        # is a tty, but doesn't support the proper scape code, so let's fake it
        # is a tty, but doesn't support the proper escape code, so let's fake it
        from shutil import get_terminal_size
        width = get_terminal_size().columns
        eraser = b'\r{}\r'.format(b' ' * width)
        eraser = b'\r' + (b' ' * width) + b'\r'

    return eraser