Skip to content
This repository

use bundled argparse if system argparse is < 1.1 #726

Merged
merged 1 commit into from over 2 years ago

2 participants

Min RK Fernando Perez
Min RK
Owner

argparse 1.0.1 has issues and is super old, but might be installed on some systems. external.argparse should use the bundled version if system argparse is older than 1.1.

Fernando Perez
Owner

+1, safe thing to do esp. given how weird the error message is. Merge away.

Min RK minrk merged commit 0d3b074 into from August 23, 2011
Min RK minrk closed this August 23, 2011
Brian E. Granger ellisonbg referenced this pull request from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 23, 2011
Min RK use bundled argparse if system argparse is < 1.1 45cf186
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 7 additions and 9 deletions. Show diff stats Hide diff stats

  1. 16  IPython/external/argparse/__init__.py
16  IPython/external/argparse/__init__.py
... ...
@@ -1,13 +1,11 @@
1 1
 try:
2 2
     import argparse
3  
-    # Workaround an argparse bug, FIXED in argparse 1.1.0
4  
-    if 'RawTextHelpFormatterArgumentDefaultsHelpFormatter' in argparse.__all__:
5  
-        import itertools
6  
-        argparse.__all__ = list(itertools.chain( [i for i in argparse.__all__
7  
-            if i != 'RawTextHelpFormatterArgumentDefaultsHelpFormatter'],
8  
-            ['RawTextHelpFormatter', 'ArgumentDefaultsHelpFormatter']))
9  
-    argparse.__all__.append('SUPPRESS')
10  
-    from argparse import *
11  
-except ImportError:
  3
+    # don't use system argparse if older than 1.1:
  4
+    if argparse.__version__ < '1.1':
  5
+        raise ImportError
  6
+    else:
  7
+        from argparse import *
  8
+        from argparse import SUPPRESS
  9
+except (ImportError, AttributeError):
12 10
     from _argparse import *
13 11
     from _argparse import SUPPRESS
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.