summaryrefslogtreecommitdiff
path: root/sqlparse
diff options
context:
space:
mode:
authorVictor Uriarte <vmuriart@gmail.com>2017-01-10 21:18:08 -0500
committerGitHub <noreply@github.com>2017-01-10 21:18:08 -0500
commit58fae0db7c38382a9a96187213169f7b474d62ff (patch)
tree595e8a0949a7b65cf041b4d72cdf4752222c4d74 /sqlparse
parentf776dde633acfd846e209b209fcef55051849c1a (diff)
parent66b36af84fbe6d546b73a207e687234f28bb00a0 (diff)
downloadsqlparse-58fae0db7c38382a9a96187213169f7b474d62ff.tar.gz
Merge pull request #316 from twang2218/fix-issue-315-utf8-support
Fix #315 support utf-8 by default
Diffstat (limited to 'sqlparse')
-rw-r--r--sqlparse/lexer.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py
index 914b520..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()
- 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)))