Show More
@@ -179,6 +179,22 b' def _file_lines(fname):' | |||
|
179 | 179 | return out |
|
180 | 180 | |
|
181 | 181 | |
|
182 | def _readline(x): | |
|
183 | """helper to pop elements off list of string | |
|
184 | ||
|
185 | call with list of strings, return readline function that will pop | |
|
186 | one line off the beginning of a copy of the list with each call. | |
|
187 | raise StopIteration when empty or on third call | |
|
188 | """ | |
|
189 | x = x[:2] | |
|
190 | def readline(): | |
|
191 | if x: | |
|
192 | return x.pop(0) | |
|
193 | else: | |
|
194 | raise StopIteration | |
|
195 | return readline | |
|
196 | ||
|
197 | ||
|
182 | 198 | class Pdb(OldPdb): |
|
183 | 199 | """Modified Pdb class, does not load readline.""" |
|
184 | 200 | |
@@ -353,15 +369,7 b' class Pdb(OldPdb):' | |||
|
353 | 369 | start = lineno - 1 - context//2 |
|
354 | 370 | lines = linecache.getlines(filename) |
|
355 | 371 | try: |
|
356 | def readline(x): | |
|
357 | x = x[:2] | |
|
358 | def _readline(): | |
|
359 | if x: | |
|
360 | return x.pop(0) | |
|
361 | else: | |
|
362 | raise StopIteration | |
|
363 | return _readline | |
|
364 | encoding, _ = openpy.detect_encoding(readline(lines)) | |
|
372 | encoding, _ = openpy.detect_encoding(_readline(lines)) | |
|
365 | 373 | except SyntaxError: |
|
366 | 374 | encoding = "ascii" |
|
367 | 375 | start = max(start, 0) |
@@ -435,7 +443,7 b' class Pdb(OldPdb):' | |||
|
435 | 443 | src = [] |
|
436 | 444 | lines = linecache.getlines(filename) |
|
437 | 445 | try: |
|
438 |
encoding, _ = openpy.detect_encoding( |
|
|
446 | encoding, _ = openpy.detect_encoding(_readline(lines)) | |
|
439 | 447 | except SyntaxError: |
|
440 | 448 | encoding = "ascii" |
|
441 | 449 | for lineno in range(first, last+1): |
General Comments 0
You need to be logged in to leave comments.
Login now