[issue12353] argparse cannot handle empty arguments
Torsten Landschoff
report at bugs.python.org
Fri Jun 24 08:21:30 CEST 2011
Torsten Landschoff <t.landschoff at gmx.net> added the comment:
> Your unit test isn't consistent with the other unit tests in that set, which makes me suspicious that it isn't testing what we need to test.
That is because I did not try to understand the machinery behind the argparse unit tests completely. I did not want to create an extra unit test class just for this one test.
> Also, there are unit tests for this case further up in the test file (TestEmptyAndSpaceContainingArguments). I haven't been able to reproduce the bug.
Did you run the unit tests from my patch?
> Can you post a short program that reproduces the failure?
Here you go:
from argparse import ArgumentParser
parser = ArgumentParser(fromfile_prefix_chars="@")
parser.parse_args([""])
This gives me
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/python3/lib/python3.3/argparse.py", line 1726, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/opt/python3/lib/python3.3/argparse.py", line 1758, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/opt/python3/lib/python3.3/argparse.py", line 1770, in _parse_known_args
arg_strings = self._read_args_from_files(arg_strings)
File "/opt/python3/lib/python3.3/argparse.py", line 2003, in _read_args_from_files
if arg_string[0] not in self.fromfile_prefix_chars:
IndexError: string index out of range
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12353>
_______________________________________
More information about the Python-bugs-list
mailing list