Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add types.FileType shim compat for 3.xx

  • Loading branch information...
commit 189eaa59f1060d9e9476b277abf0b4e1f116b46d 1 parent ed60164
@rtyler rtyler authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 cheetah/Template.py
View
12 cheetah/Template.py
@@ -30,6 +30,14 @@ def acquire(self):
def release(self):
pass
+filetype = None
+try:
+ # Python3
+ import io
+ filetype = io.IOBase
+except ImportError:
+ filetype = types.FileType
+
try:
x = set()
except NameError:
@@ -580,7 +588,7 @@ def __str__(self): return self.respond()
if not isinstance(source, (types.NoneType, basestring)):
raise TypeError(errmsg % ('source', 'string or None'))
- if not isinstance(file, (types.NoneType, basestring, types.FileType)):
+ if not isinstance(file, (types.NoneType, basestring, filetype)):
raise TypeError(errmsg %
('file', 'string, file-like object, or None'))
@@ -1162,7 +1170,7 @@ def __init__(self, source=None,
if not isinstance(source, (types.NoneType, basestring)):
raise TypeError(errmsg % ('source', 'string or None'))
- if not isinstance(source, (types.NoneType, basestring, types.FileType)):
+ if not isinstance(source, (types.NoneType, basestring, filetype)):
raise TypeError(errmsg %
('file', 'string, file open for reading, or None'))
Please sign in to comment.
Something went wrong with that request. Please try again.