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 barry
Recipients Arfrever, barry, benjamin.peterson, bethard, chris.jerdonek, georg.brandl, python-dev, r.david.murray
Date 2012-09-12.14:04:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
On Sep 12, 2012, at 10:39 AM, R. David Murray wrote:

>diff --git a/Lib/ b/Lib/
>--- a/Lib/
>+++ b/Lib/
>@@ -1962,7 +1962,8 @@
>                     # only if it was defined already in the namespace
>                     if (action.default is not None and
>                         hasattr(namespace, action.dest) and
>-                        action.default is getattr(namespace, action.dest)):
>+                        action.default is getattr(namespace, action.dest) and
>+                        isinstance(action.default, str)):
>                         setattr(namespace, action.dest,
>                                 self._get_value(action, action.default))

For me, this results in the following failure.

[307/371/1] test_argparse
test test_argparse failed -- Traceback (most recent call last):
  File "/home/barry/projects/python/cpython/Lib/test/", line 4608, in test_type_function_call_with_non_string_default
    self.assertEqual(NS(foo='foo_converted'), args)
  File "/home/barry/projects/python/cpython/Lib/test/", line 29, in assertEqual
    super(TestCase, self).assertEqual(obj1, obj2)
AssertionError: NS(foo='foo_converted') != Namespace(foo=0)

This test was added for the issue #12776 and #11839 fix, and it's pretty
obvious why it fails.  In the test, default=0 (i.e. a non-string).

Do you think test_type_function_call_with_non_string_default() is a valid test
of expected semantics?  If not, then the test should be removed, and the
changeset for #12667 and #11839 should be re-evaluated, at least to determine
whether accurate tests of those bugs were applied.

If that test is removed, then the above suggested change can be made to fix
Date User Action Args
2012-09-12 14:04:32barrysetrecipients: + barry, georg.brandl, bethard, benjamin.peterson, Arfrever, r.david.murray, chris.jerdonek, python-dev
2012-09-12 14:04:30barrylinkissue15906 messages
2012-09-12 14:04:28barrycreate