changeset: 78230:c4ad8a6eb0df parent: 78227:3d1ea33611c1 parent: 78229:ac53876d1cc8 user: R David Murray date: Sat Jul 21 22:28:08 2012 -0400 files: Lib/argparse.py Lib/test/test_argparse.py Misc/NEWS description: Merge #12353: argparse now correctly handles null argument values. Patch by Torsten Landschoff. diff -r 3d1ea33611c1 -r c4ad8a6eb0df Lib/argparse.py --- a/Lib/argparse.py Sat Jul 21 17:05:24 2012 -0400 +++ b/Lib/argparse.py Sat Jul 21 22:28:08 2012 -0400 @@ -1979,7 +1979,7 @@ for arg_string in arg_strings: # for regular arguments, just add them back into the list - if arg_string[0] not in self.fromfile_prefix_chars: + if not arg_string or arg_string[0] not in self.fromfile_prefix_chars: new_arg_strings.append(arg_string) # replace arguments referencing files with the file content diff -r 3d1ea33611c1 -r c4ad8a6eb0df Lib/test/test_argparse.py --- a/Lib/test/test_argparse.py Sat Jul 21 17:05:24 2012 -0400 +++ b/Lib/test/test_argparse.py Sat Jul 21 22:28:08 2012 -0400 @@ -1372,6 +1372,7 @@ ('X @hello', NS(a=None, x='X', y=['hello world!'])), ('-a B @recursive Y Z', NS(a='A', x='hello world!', y=['Y', 'Z'])), ('X @recursive Z -a B', NS(a='B', x='X', y=['hello world!', 'Z'])), + (["-a", "", "X", "Y"], NS(a='', x='X', y=['Y'])), ] diff -r 3d1ea33611c1 -r c4ad8a6eb0df Misc/NEWS --- a/Misc/NEWS Sat Jul 21 17:05:24 2012 -0400 +++ b/Misc/NEWS Sat Jul 21 22:28:08 2012 -0400 @@ -52,6 +52,8 @@ Library ------- +- Issue #12353: argparse now correctly handles null argument values. + - Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with user-defined types as keys or other unorderable keys.