summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2016-12-11 12:14:00 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2016-12-11 12:14:00 -0500
commitba9a846ee910e6d8d64a7062e3936f48037a7aaf (patch)
tree7fdf2419ba0089eff36e6f2b0dc45c8a338c3a3e
parent12507cf535bf5fcc4ddfc99df6228c7938090369 (diff)
downloadcmd2-git-ba9a846ee910e6d8d64a7062e3936f48037a7aaf.tar.gz
Safer work-around for Python 3 removing the built-in file() function
-rw-r--r--.gitignore2
-rwxr-xr-xcmd2.py4
2 files changed, 4 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 43f3b2b5..24c540b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,6 @@ __pycache__
build
dist
cmd2.egg-info
+.idea
+.cache
diff --git a/cmd2.py b/cmd2.py
index 8b94c3e2..237d1bfd 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -52,10 +52,10 @@ except NameError:
# Python 3 compatability hack due to no built-in file keyword in Python 3
# Due to two occurences of isinstance(<foo>, file) checking to see if something is of file type
try:
+ file
+except NameError:
import io
file = io.TextIOWrapper
-except ImportError:
- pass # Python2
if sys.version_info[0] == 2:
pyparsing.ParserElement.enablePackrat()