summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorAlberto Sartori <alberto.sartori.as@gmail.com>2018-03-12 18:19:28 +0100
committerAlberto Sartori <alberto.sartori.as@gmail.com>2018-03-12 18:19:28 +0100
commit583effc931f50208c949f55ce4fed90cc01e57f8 (patch)
tree1edc27e9f567965534a0b210bef6a6317dcde1b2 /cmd2.py
parentd278b62c9109a1e91342cbf7119d0578ace11304 (diff)
downloadcmd2-git-583effc931f50208c949f55ce4fed90cc01e57f8.tar.gz
FileNotFoundError does not exists on python 2
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/cmd2.py b/cmd2.py
index aa851344..e1fa7369 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -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)