diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-12 15:03:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-12 15:03:33 -0400 |
commit | ece4ab4e8c02421efd467eebaa6b36d8b7dead00 (patch) | |
tree | 1edc27e9f567965534a0b210bef6a6317dcde1b2 /cmd2.py | |
parent | d278b62c9109a1e91342cbf7119d0578ace11304 (diff) | |
parent | 583effc931f50208c949f55ce4fed90cc01e57f8 (diff) | |
download | cmd2-git-ece4ab4e8c02421efd467eebaa6b36d8b7dead00.tar.gz |
Merge pull request #302 from albertored/fix/FileNotFoundError-py2
FileNotFoundError does not exists on python 2
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -95,11 +95,12 @@ try: except ImportError: pass -# BrokenPipeError is only in Python 3. Use IOError for Python 2. +# BrokenPipeError and FileNotFoundError exist only in Python 3. Use IOError for Python 2. if six.PY3: BROKEN_PIPE_ERROR = BrokenPipeError + FILE_NOT_FOUND_ERROR = FileNotFoundError else: - BROKEN_PIPE_ERROR = IOError + BROKEN_PIPE_ERROR = FILE_NOT_FOUND_ERROR = IOError # On some systems, pyperclip will import gtk for its clipboard functionality. # The following code is a workaround for gtk interfering with printing from a background @@ -1075,7 +1076,7 @@ class Cmd(cmd.Cmd): readline.read_history_file(persistent_history_file) # default history len is -1 (infinite), which may grow unruly readline.set_history_length(persistent_history_length) - except FileNotFoundError: + except FILE_NOT_FOUND_ERROR: pass atexit.register(readline.write_history_file, persistent_history_file) |