From fe0a9f208e04c6250dbab2d878c51a39f04883e4 Mon Sep 17 00:00:00 2001 From: Jean-Michel Picod Date: Wed, 9 Jun 2021 22:52:52 +0200 Subject: [PATCH] Fix broken parsing. (#317) (#323) * Fix broken parsing. By setting the default value before pre-parsing we ensure that the item can't be None. As an extra safety the custom action also checks for None. Co-authored-by: kaczmarczyck <43844792+kaczmarczyck@users.noreply.github.com> --- deploy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/deploy.py b/deploy.py index 0c8d998..78ddfe1 100755 --- a/deploy.py +++ b/deploy.py @@ -243,6 +243,8 @@ class RemoveConstAction(argparse.Action): # https://github.com/python/cpython/blob/master/Lib/argparse.py#L138-L147 # https://github.com/python/cpython/blob/master/Lib/argparse.py#L1028-L1052 items = getattr(namespace, self.dest, []) + if items is None: + items = [] if isinstance(items, list): items = items[:] else: @@ -914,6 +916,8 @@ if __name__ == "__main__": help=("When set, the output of elf2tab is appended to this file."), ) + main_parser.set_defaults(features=["with_ctap1"]) + # Start parsing to know if we're going to list things or not. partial_args, _ = main_parser.parse_known_args() @@ -984,6 +988,4 @@ if __name__ == "__main__": help=("Compiles and installs the nfct_test example that tests the " "NFC driver.")) - main_parser.set_defaults(features=["with_ctap1"]) - main(main_parser.parse_args())