diff -r befd752a3218 Lib/argparse.py --- a/Lib/argparse.py Tue Sep 11 22:16:58 2012 -0700 +++ b/Lib/argparse.py Wed Sep 12 11:42:33 2012 -0400 @@ -1948,7 +1948,7 @@ # twice (which may fail) if the argument was given, but # only if it was defined already in the namespace if (action.default is not None and - isinstance(action, _StoreAction) and + isinstance(action.default, str) and hasattr(namespace, action.dest) and action.default is getattr(namespace, action.dest)): setattr(namespace, action.dest, diff -r befd752a3218 Lib/test/test_argparse.py --- a/Lib/test/test_argparse.py Tue Sep 11 22:16:58 2012 -0700 +++ b/Lib/test/test_argparse.py Wed Sep 12 11:42:33 2012 -0400 @@ -4478,7 +4478,8 @@ parser = argparse.ArgumentParser() parser.add_argument('--foo', type=spam, default=0) args = parser.parse_args([]) - self.assertEqual(NS(foo='foo_converted'), args) + # foo should *not* be converted because its default is not a string. + self.assertEqual(NS(foo=0), args) def test_issue_15906(self): # Issue #15906: When action='append', type=str, default=[] are