forked from ipython/ipython
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use bundled argparse if system argparse is < 1.1
- Loading branch information
Showing
1 changed file
with
7 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |