FIX: pseudo-terminal returning width=0 causes crash in rbsite

Review Request #12464 — Created July 12, 2022 and submitted

Information

Review Board
release-4.0.x

Reviewers

When running on a pseudo-terminal (such as in a NAS), get_terminal_size() could return (0,0).

In rbsite.py, line 2527 the terminal width is retrieved, then subtracted by 4, resulting in a negative wrap_width which causes a crash in line 2535, in textwrap.fill().

By hand, on a Synology DiskStation DS220+, with RB 4.0.7 running in a Docker container.

Summary ID
FIX: pseudo-terminal returning width=0 causes crash in rbsite
When running on a pseudo-terminal (such as in a NAS), get_terminal_size() can return (0,0) which is not handled correctly.
d49a46402ab154a388c7d4932702e0bd71132979
Refactored, avoid duplicating magic number
25eb9e578b83b7bc588de0c104a7034059a2e76f
Description From Last Updated

Rather than re-introduce the magic number of 79, this can be: term_width = shutil.get_terminal_size()[0] or term_width

chipx86chipx86
chipx86
  1. Thanks for the contribution!

  2. reviewboard/cmdline/utils/console.py (Diff revision 1)
     
     
     
     
    Show all issues

    Rather than re-introduce the magic number of 79, this can be:

    term_width = shutil.get_terminal_size()[0] or term_width
    
  3. 
      
Werner
chipx86
  1. Ship It!
  2. 
      
Werner
Review request changed
Status:
Completed
Change Summary:
Pushed to release-4.0.x (f0984e4)