From e928698121440a0e72c7a86f01737b8408eedc73 Mon Sep 17 00:00:00 2001 From: Martin Sucha Date: Wed, 16 Feb 2022 15:56:42 +0100 Subject: [PATCH] Fix printing help on Python 3.10 Python 3.10 uses "options:" instead of "optional arguments:". See https://bugs.python.org/issue9694 This commit tries the new string and falls back to printing the whole usage instead of crashing if the text ever changes again. --- ccmlib/remote.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ccmlib/remote.py b/ccmlib/remote.py index e54a79f4..90db3271 100644 --- a/ccmlib/remote.py +++ b/ccmlib/remote.py @@ -494,7 +494,15 @@ def usage(self): :return Usage for the remote execution options """ # Retrieve the text for just the arguments - usage = self.parser.format_help().split("optional arguments:")[1] + formatted = self.parser.format_help() + try: + usage = formatted.split("optional arguments:")[1] + except IndexError: + try: + usage = formatted.split("options:")[1] + except IndexError: + # fallback to print the whole string + usage = formatted # Remove any blank lines and return return "Remote Options:" + os.linesep + \