summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/argparse.py2
-rw-r--r--Lib/test/test_argparse.py1
-rw-r--r--Misc/NEWS2
3 files changed, 4 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 7fa3712..74c456f 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -1979,7 +1979,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
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 --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index e69cc40..76271a3 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -1372,6 +1372,7 @@ class TestArgumentsFromFile(TempDirMixin, ParserTestCase):
('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 --git a/Misc/NEWS b/Misc/NEWS
index a7db9cf..9d0e72e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -52,6 +52,8 @@ Core and Builtins
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.