diff options
author | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-04 15:08:40 -0700 |
---|---|---|
committer | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-11 04:35:16 -0700 |
commit | 954f48431a0fe8ea1749ba0236da23a705bf3b75 (patch) | |
tree | a7b5f91fb81609dc04efae6f82d3aca032d1772e /sqlparse/lexer.py | |
parent | 29e3df5c2c0a62f16668f89f4a5e738156c276a7 (diff) | |
download | sqlparse-954f48431a0fe8ea1749ba0236da23a705bf3b75.tar.gz |
Redo unicode-encoding on lexer.py
Diffstat (limited to 'sqlparse/lexer.py')
-rw-r--r-- | sqlparse/lexer.py | 15 |
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: |