summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-07-22 02:35:00 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-07-22 02:35:00 (GMT)
commit056c31f9cc10a8697a40c817eae42f7e38a1cf80 (patch)
treee8d441ef0f7d29458e98689559e54f4507a7fc77 /Lib
parent1a2c1fbfd2208407e1af365b161276b6f103c1ad (diff)
downloadcpython-056c31f9cc10a8697a40c817eae42f7e38a1cf80.zip
cpython-056c31f9cc10a8697a40c817eae42f7e38a1cf80.tar.gz
cpython-056c31f9cc10a8697a40c817eae42f7e38a1cf80.tar.bz2
#12353: argparse now correctly handles null argument values.
Patch by Torsten Landschoff.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/argparse.py2
-rw-r--r--Lib/test/test_argparse.py1
2 files changed, 2 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index d867611..f365385 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -1967,7 +1967,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 1a5f05e..a7a4b00 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -1374,6 +1374,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'])),
]