From 45cf1867685563b9b2644dc3734c4a01f6798289 2011-08-23 23:08:00 From: MinRK Date: 2011-08-23 23:08:00 Subject: [PATCH] use bundled argparse if system argparse is < 1.1 --- diff --git a/IPython/external/argparse/__init__.py b/IPython/external/argparse/__init__.py index 7865da3..778b1fe 100644 --- a/IPython/external/argparse/__init__.py +++ b/IPython/external/argparse/__init__.py @@ -1,13 +1,11 @@ try: import argparse - # Workaround an argparse bug, FIXED in argparse 1.1.0 - if 'RawTextHelpFormatterArgumentDefaultsHelpFormatter' in argparse.__all__: - import itertools - argparse.__all__ = list(itertools.chain( [i for i in argparse.__all__ - if i != 'RawTextHelpFormatterArgumentDefaultsHelpFormatter'], - ['RawTextHelpFormatter', 'ArgumentDefaultsHelpFormatter'])) - argparse.__all__.append('SUPPRESS') - from argparse import * -except ImportError: + # don't use system argparse if older than 1.1: + if argparse.__version__ < '1.1': + raise ImportError + else: + from argparse import * + from argparse import SUPPRESS +except (ImportError, AttributeError): from _argparse import * from _argparse import SUPPRESS