diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-21 15:22:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-21 15:22:13 -0400 |
commit | 6515ec4c97d116de72d134d84f24578019e6b6d8 (patch) | |
tree | 7e1307fe0a69ed5b9de4a0cad826c4c7bbcd4617 /cmd2.py | |
parent | 450466e560b312034d4a4cf0a256e6051954d1f4 (diff) | |
parent | 7b22a8754badd99c625cd9d97b2d6d7b48ecda69 (diff) | |
download | cmd2-git-6515ec4c97d116de72d134d84f24578019e6b6d8.tar.gz |
Merge pull request #325 from python-cmd2/macOS_gnureadline
Added preference for gnureadline Python module when available
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -88,13 +88,17 @@ try: except ImportError: ipython_available = False -# Try to import readline, but allow failure for convenience in Windows unit testing -# Note: If this actually fails, you should install readline on Linux or Mac or pyreadline on Windows +# Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: - # noinspection PyUnresolvedReferences - import readline + import gnureadline as readline except ImportError: - pass + # Try to import readline, but allow failure for convenience in Windows unit testing + # Note: If this actually fails, you should install readline on Linux or Mac or pyreadline on Windows + try: + # noinspection PyUnresolvedReferences + import readline + except ImportError: + pass # BrokenPipeError and FileNotFoundError exist only in Python 3. Use IOError for Python 2. if six.PY3: @@ -1377,7 +1381,6 @@ class Cmd(cmd.Cmd): :param state: int - non-negative integer """ if state == 0: - import readline origline = readline.get_line_buffer() line = origline.lstrip() stripped = len(origline) - len(line) |