summaryrefslogtreecommitdiff
path: root/sqlparse/lexer.py
diff options
context:
space:
mode:
authorVik <vmuriart@users.noreply.github.com>2016-06-11 05:29:39 -0700
committerGitHub <noreply@github.com>2016-06-11 05:29:39 -0700
commit751933d3abdce2234bd869ee65a1ebc7ccbf6b53 (patch)
tree77fd5be087ae64c4416c0bd775f6c1843b45a007 /sqlparse/lexer.py
parent00304afc15a554f2ac8decca1d916ba66c143b45 (diff)
parent1fd3da42bd55bfc1e916e3c3f301f0364b0ded21 (diff)
downloadsqlparse-751933d3abdce2234bd869ee65a1ebc7ccbf6b53.tar.gz
Merge pull request #254 from vmuriart/tests_str-format
Add various tests and change to new style str-format
Diffstat (limited to 'sqlparse/lexer.py')
-rw-r--r--sqlparse/lexer.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py
index dd15212..0fb8936 100644
--- a/sqlparse/lexer.py
+++ b/sqlparse/lexer.py
@@ -14,7 +14,7 @@
from sqlparse import tokens
from sqlparse.keywords import SQL_REGEX
-from sqlparse.compat import StringIO, string_types, text_type
+from sqlparse.compat import StringIO, string_types, u
from sqlparse.utils import consume
@@ -37,17 +37,10 @@ class Lexer(object):
``stack`` is the inital stack (default: ``['root']``)
"""
- encoding = encoding or 'utf-8'
-
if isinstance(text, string_types):
- text = StringIO(text)
-
- text = text.read()
- if not isinstance(text, text_type):
- try:
- text = text.decode(encoding)
- except UnicodeDecodeError:
- text = text.decode('unicode-escape')
+ text = u(text, encoding)
+ elif isinstance(text, StringIO):
+ text = u(text.read(), encoding)
iterable = enumerate(text)
for pos, char in iterable: