argparse-no-shutil
authorMatthias Klose <doko@debian.org>
Fri, 3 Sep 2021 06:18:44 +0000 (07:18 +0100)
committerMatthias Klose <doko@debian.org>
Fri, 3 Sep 2021 06:18:44 +0000 (07:18 +0100)
Gbp-Pq: Name argparse-no-shutil.diff

Lib/argparse.py

index b8011ce1c764c240d4c3dae742ae3fda55ddea45..a907aa534034689041ce157e2b0e32c05dc478ca 100644 (file)
@@ -175,9 +175,12 @@ class HelpFormatter(object):
 
         # default setting for width
         if width is None:
-            import shutil
-            width = shutil.get_terminal_size().columns
-            width -= 2
+            try:
+                import shutil as _shutil
+                width = _shutil.get_terminal_size().columns
+                width -= 2
+            except ImportError:
+                width = 70
 
         self._prog = prog
         self._indent_increment = indent_increment