From d7cad3a7c337a4adcabfa577070b9f715d69e30b Mon Sep 17 00:00:00 2001 From: Zhiqiang Fan Date: Sun, 27 Sep 2015 10:06:59 -0600 Subject: [PATCH] print usage when no argument is specified for python3 When running just sahara' under python3, we will get the error: ERROR: b"'Namespace' object has no attribute 'func'" This is because map() is used to decode sys.argv, but under Python3 it returns a map object which is an iterable. Some code later tries to use this in a boolean context and it will always return True, even if it's empty. Change-Id: I508b093e30814645b2bd4c32cf469204bb696207 Closes-Bug: #1295356 --- saharaclient/shell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/saharaclient/shell.py b/saharaclient/shell.py index 49e885e4..67bcd5b6 100644 --- a/saharaclient/shell.py +++ b/saharaclient/shell.py @@ -711,8 +711,8 @@ class OpenStackHelpFormatter(argparse.HelpFormatter): def main(): try: - OpenStackSaharaShell().main(map(encodeutils.safe_decode, - sys.argv[1:])) + argv = [encodeutils.safe_decode(a) for a in sys.argv[1:]] + OpenStackSaharaShell().main(argv) except Exception as e: logger.debug(e, exc_info=1)