This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bjacobs
Recipients bjacobs
Date 2011-06-17.15:40:05
SpamBayes Score 0.0002918932
Marked as misclassified No
Message-id <1308325206.77.0.428682614263.issue12353@psf.upfronthosting.co.za>
In-reply-to
Content
Parsing arguments with argparse fails with an IndexError when one of the arguments is the empty string (''). This is caused by an access to the zero'th element of the argument value, without a preceding length check.

Fixed by the below patch:

Index: Lib/argparse.py
===================================================================
--- Lib/argparse.py
+++ Lib/argparse.py
@@ -1967,7 +1967,7 @@ class ArgumentParser(_AttributeHolder, _
         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 len(arg_string) == 0 or arg_string[0] not in self.fromfile_prefix_chars:
                 new_arg_strings.append(arg_string)
 
             # replace arguments referencing files with the file content
History
Date User Action Args
2011-06-17 15:40:06bjacobssetrecipients: + bjacobs
2011-06-17 15:40:06bjacobssetmessageid: <1308325206.77.0.428682614263.issue12353@psf.upfronthosting.co.za>
2011-06-17 15:40:06bjacobslinkissue12353 messages
2011-06-17 15:40:05bjacobscreate