Skip to content

Commit 1d1e24d

Browse files
committed
Handle invalid data in COLUMNS env var when determining console width
1 parent ee43699 commit 1d1e24d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/tools/patching.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,13 @@
444444
from rich.syntax import Syntax
445445

446446
# console width is COLUMNS env var minus 12, or just 160 if GITHUB_ACTIONS env is not empty
447-
console_width = (int(os.environ.get("COLUMNS", 160)) - 12) if os.environ.get("GITHUB_ACTIONS", "") == "" else 160
447+
if os.environ.get("GITHUB_ACTIONS", "") == "":
448+
try:
449+
console_width = int(os.environ.get("COLUMNS", 160)) - 12
450+
except ValueError:
451+
console_width = 160
452+
else:
453+
console_width = 160
448454
console = Console(color_system="standard", width=console_width, highlight=False)
449455

450456
# Use Rich to print a summary of the patches

0 commit comments

Comments
 (0)