diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2016-08-10 10:43:40 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2016-08-10 10:43:40 +0200 |
| commit | 907d36a7b8909addfffdf172b39fa52df0288ae4 (patch) | |
| tree | 2f942b590a71eb8541a5950a6fab67a6ea614f78 /sqlparse | |
| parent | 867908021479495499df6ae708d0c9d3b45b02b9 (diff) | |
| download | sqlparse-907d36a7b8909addfffdf172b39fa52df0288ae4.tar.gz | |
Move file_types list to compat module.
Diffstat (limited to 'sqlparse')
| -rw-r--r-- | sqlparse/compat.py | 5 | ||||
| -rw-r--r-- | sqlparse/lexer.py | 10 |
2 files changed, 6 insertions, 9 deletions
diff --git a/sqlparse/compat.py b/sqlparse/compat.py index a41b18b..d6a9144 100644 --- a/sqlparse/compat.py +++ b/sqlparse/compat.py @@ -16,10 +16,12 @@ https://bitbucket.org/gutworth/six """ import sys +from io import TextIOBase PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 + if PY3: def u(s, encoding=None): return str(s) @@ -32,6 +34,7 @@ if PY3: text_type = str string_types = (str,) from io import StringIO + file_types = (StringIO, TextIOBase) elif PY2: @@ -52,3 +55,5 @@ elif PY2: text_type = unicode string_types = (str, unicode,) from StringIO import StringIO + file_types = (file, StringIO, TextIOBase) + from StringIO import StringIO diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py index 06318c6..e7996b2 100644 --- a/sqlparse/lexer.py +++ b/sqlparse/lexer.py @@ -12,20 +12,12 @@ # It's separated from the rest of pygments to increase performance # and to allow some customizations. -from io import TextIOBase - from sqlparse import tokens from sqlparse.keywords import SQL_REGEX -from sqlparse.compat import StringIO, string_types, u +from sqlparse.compat import file_types, 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 |
