diff options
author | Vik <vmuriart@gmail.com> | 2016-08-05 17:28:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-05 17:28:49 -0700 |
commit | d999cde37af2353595b6e103f04eecc65aff280a (patch) | |
tree | 811a84532a0914d28a428e5026366d5c288944b7 /sqlparse/lexer.py | |
parent | dcd7cff503fdf420455a2c1806ff31f9b40695c4 (diff) | |
parent | 44e66710fb2222b0aa60c21a834c46831166f44c (diff) | |
download | sqlparse-d999cde37af2353595b6e103f04eecc65aff280a.tar.gz |
Merge pull request #279 from phdru/issue-190
closes #190
Diffstat (limited to 'sqlparse/lexer.py')
-rw-r--r-- | sqlparse/lexer.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index 3cf2be4..06318c6 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -20,6 +20,12 @@ from sqlparse.compat import StringIO, string_types, u from sqlparse.utils import consume +try: + file_types = (file, StringIO, TextIOBase) +except NameError: # Python 3 + file_types = (StringIO, TextIOBase) + + class Lexer(object): """Lexer Empty class. Leaving for backwards-compatibility @@ -41,7 +47,7 @@ class Lexer(object): """ if isinstance(text, string_types): text = u(text, encoding) - elif isinstance(text, (StringIO, TextIOBase)): + elif isinstance(text, file_types): text = u(text.read(), encoding) iterable = enumerate(text) |