Author arnau
Recipients arnau
Date 2011-08-18.08:57:56
SpamBayes Score 7.92416e-11
Marked as misclassified No
Message-id <1313657878.1.0.958946060112.issue12776@psf.upfronthosting.co.za>
In-reply-to
Content
When specifying a function to be called in type keyword argument of add_argument(), the function is actually called twice (when a default value is set and then when the argument is given).

While this may not be a problem in most cases (such as converting to an int for example), it is an issue for example when trying to open a file whose filename is given as a default value but is not accessible for whatever reason because the first call will fail whereas only the second should be done. I know this may sound like a twisted example but the type function should not be called twice anyhow IMHO.

I tested with Python 2.7 and 3.2 from Debian packages only but the bug seems to be present in py3k and 2.7 hg branches as well.

I have attached a small script showing the issue and two patches (for 2.7 and tip (py3k) hg branches), including an additional test case. All argparse tests pass well with 2.7 and 3.2. Hope that's ok.
History
Date User Action Args
2011-08-18 08:57:58arnausetrecipients: + arnau
2011-08-18 08:57:58arnausetmessageid: <1313657878.1.0.958946060112.issue12776@psf.upfronthosting.co.za>
2011-08-18 08:57:57arnaulinkissue12776 messages
2011-08-18 08:57:57arnaucreate