diff options
| author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-03-18 22:41:30 -0400 |
|---|---|---|
| committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-03-18 22:41:30 -0400 |
| commit | c15a3fc51061402aaaf67428f7ea08d8ae165d69 (patch) | |
| tree | 182f79dcdd298e600fbeec63cbf093594ed4ec56 /cmd2.py | |
| parent | 51b9056e5edfe3419873562948739dee339cf888 (diff) | |
| download | cmd2-git-c15a3fc51061402aaaf67428f7ea08d8ae165d69.tar.gz | |
Fixed Pycharm warnings
Diffstat (limited to 'cmd2.py')
| -rwxr-xr-x | cmd2.py | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -92,21 +92,23 @@ except ImportError: try: # noinspection PyUnresolvedReferences import readline +except ImportError: + pass - if not sys.platform.startswith('win'): - import ctypes - from ctypes.util import find_library +# Make some changes to GNU readline +readline_lib = None +if not sys.platform.startswith('win'): + import ctypes + from ctypes.util import find_library - libname = find_library("readline") - readline_lib = ctypes.CDLL(libname) + readline_lib_name = find_library("readline") + if readline_lib_name is not None and readline_lib_name: + readline_lib = ctypes.CDLL(readline_lib_name) # Set GNU readline's rl_basic_quote_characters to NULL so it won't automatically add a closing quote rl_basic_quote_characters = ctypes.c_char_p.in_dll(readline_lib, "rl_basic_quote_characters") rl_basic_quote_characters.value = None -except ImportError: - pass - # BrokenPipeError and FileNotFoundError exist only in Python 3. Use IOError for Python 2. if six.PY3: BROKEN_PIPE_ERROR = BrokenPipeError @@ -1459,13 +1461,7 @@ class Cmd(cmd.Cmd): if state == 0: import readline - if not sys.platform.startswith('win'): - import ctypes - from ctypes.util import find_library - - libname = find_library("readline") - readline_lib = ctypes.CDLL(libname) - + if readline_lib is not None: # Set GNU readline's rl_completion_suppress_quote to 1 so it won't automatically add a closing quote # This gets reset before complete() is called, so we have to set it each time suppress_quote = ctypes.c_int.in_dll(readline_lib, "rl_completion_suppress_quote") |
