summaryrefslogtreecommitdiff
path: root/sqlparse/lexer.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlparse/lexer.py')
-rw-r--r--sqlparse/lexer.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py
index 82d4380..60e43da 100644
--- a/sqlparse/lexer.py
+++ b/sqlparse/lexer.py
@@ -43,12 +43,13 @@ class Lexer(object):
if isinstance(text, text_type):
pass
elif isinstance(text, bytes_type):
- try:
- text = text.decode('utf-8')
- except UnicodeDecodeError:
- if not encoding:
- encoding = 'unicode-escape'
+ if encoding:
text = text.decode(encoding)
+ else:
+ try:
+ text = text.decode('utf-8')
+ except UnicodeDecodeError:
+ text = text.decode('unicode-escape')
else:
raise TypeError(u"Expected text or file-like object, got {!r}".
format(type(text)))