summaryrefslogtreecommitdiff
path: root/sqlparse/lexer.py
diff options
context:
space:
mode:
authorquest <quest@wonky.windwards.net>2012-04-22 00:27:15 +0200
committerquest <quest@wonky.windwards.net>2012-04-22 00:27:15 +0200
commit1f8dfd8723dd7aa9610fd9249775dc3b403d7e77 (patch)
treed664bd88c2b694ba889d9675a1c73fca09743793 /sqlparse/lexer.py
parent1e3fbade7c80d917b4d727e9cef781b21be2fdf6 (diff)
downloadsqlparse-1f8dfd8723dd7aa9610fd9249775dc3b403d7e77.tar.gz
Oops; doesnt handle UTF-8 correctly when reading from stream
Diffstat (limited to 'sqlparse/lexer.py')
-rw-r--r--sqlparse/lexer.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/sqlparse/lexer.py b/sqlparse/lexer.py
index a0ce5d2..dc794ab 100644
--- a/sqlparse/lexer.py
+++ b/sqlparse/lexer.py
@@ -271,8 +271,9 @@ class Lexer(object):
statetokens = tokendefs[statestack[-1]]
known_names = {}
- text = self._decode(stream.read(self.bufsize))
+ text = stream.read(self.bufsize)
hasmore = len(text) == self.bufsize
+ text = self._decode(text)
while 1:
for rexmatch, action, new_state in statetokens:
@@ -317,9 +318,9 @@ class Lexer(object):
break
else:
if hasmore:
- buf = self._decode(stream.read(self.bufsize))
+ buf = stream.read(self.bufsize)
hasmore = len(buf) == self.bufsize
- text = text[pos:] + buf
+ text = text[pos:] + self._decode(buf)
pos = 0
continue