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

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
Pipeline #17318 failed with stage
in 3 minutes and 33 seconds
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment