diff options
-rw-r--r-- | argparse.py | 11 | ||||
-rw-r--r-- | test/test_argparse.py | 3 |
2 files changed, 12 insertions, 2 deletions
diff --git a/argparse.py b/argparse.py index 9837432..36e54c4 100644 --- a/argparse.py +++ b/argparse.py @@ -90,6 +90,12 @@ import textwrap as _textwrap from gettext import gettext as _ +try: + set +except NameError: + # for python < 2.5 compatibility (sets module is there since 2.3): + from sets import Set as set + def _callable(obj): return hasattr(obj, '__call__') or hasattr(obj, '__bases__') @@ -1582,7 +1588,10 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): # add help and version arguments if necessary # (using explicit default to override global argument_default) - default_prefix = '-' if '-' in prefix_chars else prefix_chars[0] + if '-' in prefix_chars: + default_prefix = '-' + else: + default_prefix = prefix_chars[0] if self.add_help: self.add_argument( default_prefix+'h', default_prefix*2+'help', diff --git a/test/test_argparse.py b/test/test_argparse.py index dde6d16..3b163c2 100644 --- a/test/test_argparse.py +++ b/test/test_argparse.py @@ -2221,7 +2221,8 @@ class TestMutuallyExclusiveGroupErrors(TestCase): --soup --nuts ''' - self.assertEqual(parser.format_help(), textwrap.dedent(expected)) + # note: .rstrip(' ') fixes different behaviour of py 2.4 textwrap.dedent + self.assertEqual(parser.format_help(), textwrap.dedent(expected).rstrip(' ')) class MEMixin(object): |