Show More
@@ -179,6 +179,22 b' def _file_lines(fname):' | |||||
179 | return out |
|
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 | class Pdb(OldPdb): |
|
198 | class Pdb(OldPdb): | |
183 | """Modified Pdb class, does not load readline.""" |
|
199 | """Modified Pdb class, does not load readline.""" | |
184 |
|
200 | |||
@@ -353,15 +369,7 b' class Pdb(OldPdb):' | |||||
353 | start = lineno - 1 - context//2 |
|
369 | start = lineno - 1 - context//2 | |
354 | lines = linecache.getlines(filename) |
|
370 | lines = linecache.getlines(filename) | |
355 | try: |
|
371 | try: | |
356 | def readline(x): |
|
372 | encoding, _ = openpy.detect_encoding(_readline(lines)) | |
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)) |
|
|||
365 | except SyntaxError: |
|
373 | except SyntaxError: | |
366 | encoding = "ascii" |
|
374 | encoding = "ascii" | |
367 | start = max(start, 0) |
|
375 | start = max(start, 0) | |
@@ -435,7 +443,7 b' class Pdb(OldPdb):' | |||||
435 | src = [] |
|
443 | src = [] | |
436 | lines = linecache.getlines(filename) |
|
444 | lines = linecache.getlines(filename) | |
437 | try: |
|
445 | try: | |
438 |
encoding, _ = openpy.detect_encoding( |
|
446 | encoding, _ = openpy.detect_encoding(_readline(lines)) | |
439 | except SyntaxError: |
|
447 | except SyntaxError: | |
440 | encoding = "ascii" |
|
448 | encoding = "ascii" | |
441 | for lineno in range(first, last+1): |
|
449 | for lineno in range(first, last+1): |
General Comments 0
You need to be logged in to leave comments.
Login now