@@ -161,9 +161,6 @@ class Lexer(object):
161161 stripnl = False
162162 tabsize = 0
163163 flags = re .IGNORECASE | re .UNICODE
164- DEFAULT_BUFSIZE = 4096
165- MAX_BUFSIZE = 2 ** 31
166- bufsize = DEFAULT_BUFSIZE
167164
168165 tokens = {
169166 'root' : [
@@ -286,18 +283,13 @@ def get_tokens_unprocessed(self, stream, stack=('root',)):
286283 statetokens = tokendefs [statestack [- 1 ]]
287284 known_names = {}
288285
289- text = stream .read (self .bufsize )
290- hasmore = len (text ) == self .bufsize
286+ text = stream .read ()
291287 text = self ._decode (text )
292288
293289 while 1 :
294290 for rexmatch , action , new_state in statetokens :
295291 m = rexmatch (text , pos )
296292 if m :
297- if hasmore and m .end () == len (text ):
298- # Since this is end, token may be truncated
299- continue
300-
301293 # print rex.pattern
302294 value = m .group ()
303295 if value in known_names :
@@ -330,20 +322,8 @@ def get_tokens_unprocessed(self, stream, stack=('root',)):
330322 else :
331323 assert False , "wrong state def: %r" % new_state
332324 statetokens = tokendefs [statestack [- 1 ]]
333- # reset bufsize
334- self .bufsize = self .DEFAULT_BUFSIZE
335325 break
336326 else :
337- if hasmore :
338- # we have no match, increase bufsize to parse lengthy
339- # tokens faster (see #86).
340- self .bufsize = min (self .bufsize * 2 , self .MAX_BUFSIZE )
341- buf = stream .read (self .bufsize )
342- hasmore = len (buf ) == self .bufsize
343- text = text [pos :] + self ._decode (buf )
344- pos = 0
345- continue
346-
347327 try :
348328 if text [pos ] == '\n ' :
349329 # at EOL, reset state to "root"
0 commit comments