##// END OF EJS Templates
Merge pull request #10141 from srinivasreddy/uline_cache...
Matthias Bussonnier -
r23121:ff9d2381 merge
parent child Browse files
Show More
@@ -28,11 +28,12 b' http://www.python.org/2.2.3/license.html"""'
28 import bdb
28 import bdb
29 import functools
29 import functools
30 import inspect
30 import inspect
31 import linecache
31 import sys
32 import sys
32 import warnings
33 import warnings
33
34
34 from IPython import get_ipython
35 from IPython import get_ipython
35 from IPython.utils import PyColorize, ulinecache
36 from IPython.utils import PyColorize
36 from IPython.utils import coloransi, py3compat
37 from IPython.utils import coloransi, py3compat
37 from IPython.core.excolors import exception_colors
38 from IPython.core.excolors import exception_colors
38 from IPython.testing.skipdoctest import skip_doctest
39 from IPython.testing.skipdoctest import skip_doctest
@@ -407,7 +408,7 b' class Pdb(OldPdb):'
407 ret.append(u'%s(%s)%s\n' % (link,lineno,call))
408 ret.append(u'%s(%s)%s\n' % (link,lineno,call))
408
409
409 start = lineno - 1 - context//2
410 start = lineno - 1 - context//2
410 lines = ulinecache.getlines(filename)
411 lines = linecache.getlines(filename)
411 start = min(start, len(lines) - context)
412 start = min(start, len(lines) - context)
412 start = max(start, 0)
413 start = max(start, 0)
413 lines = lines[start : start + context]
414 lines = lines[start : start + context]
@@ -466,7 +467,7 b' class Pdb(OldPdb):'
466 filename = self._exec_filename
467 filename = self._exec_filename
467
468
468 for lineno in range(first, last+1):
469 for lineno in range(first, last+1):
469 line = ulinecache.getline(filename, lineno)
470 line = linecache.getline(filename, lineno)
470 if not line:
471 if not line:
471 break
472 break
472
473
@@ -120,7 +120,6 b' from IPython.utils import PyColorize'
120 from IPython.utils import openpy
120 from IPython.utils import openpy
121 from IPython.utils import path as util_path
121 from IPython.utils import path as util_path
122 from IPython.utils import py3compat
122 from IPython.utils import py3compat
123 from IPython.utils import ulinecache
124 from IPython.utils.data import uniq_stable
123 from IPython.utils.data import uniq_stable
125 from IPython.utils.terminal import get_terminal_size
124 from IPython.utils.terminal import get_terminal_size
126 from logging import info, error
125 from logging import info, error
@@ -370,7 +369,7 b' def _fixed_getinnerframes(etb, context=1, tb_offset=0):'
370 maybeStart = lnum - 1 - context // 2
369 maybeStart = lnum - 1 - context // 2
371 start = max(maybeStart, 0)
370 start = max(maybeStart, 0)
372 end = start + context
371 end = start + context
373 lines = ulinecache.getlines(file)[start:end]
372 lines = linecache.getlines(file)[start:end]
374 buf = list(records[i])
373 buf = list(records[i])
375 buf[LNUM_POS] = lnum
374 buf[LNUM_POS] = lnum
376 buf[INDEX_POS] = lnum - 1 - start
375 buf[INDEX_POS] = lnum - 1 - start
@@ -706,7 +705,7 b' class ListTB(TBTools):'
706 if not value.filename: value.filename = "<string>"
705 if not value.filename: value.filename = "<string>"
707 if value.lineno:
706 if value.lineno:
708 lineno = value.lineno
707 lineno = value.lineno
709 textline = ulinecache.getline(value.filename, value.lineno)
708 textline = linecache.getline(value.filename, value.lineno)
710 else:
709 else:
711 lineno = 'unknown'
710 lineno = 'unknown'
712 textline = ''
711 textline = ''
@@ -922,7 +921,7 b' class VerboseTB(TBTools):'
922 # E.g. https://github.com/ipython/ipython/issues/9486
921 # E.g. https://github.com/ipython/ipython/issues/9486
923 return '%s %s\n' % (link, call)
922 return '%s %s\n' % (link, call)
924
923
925 def linereader(file=file, lnum=[lnum], getline=ulinecache.getline):
924 def linereader(file=file, lnum=[lnum], getline=linecache.getline):
926 line = getline(file, lnum[0])
925 line = getline(file, lnum[0])
927 lnum[0] += 1
926 lnum[0] += 1
928 return line
927 return line
@@ -1413,7 +1412,7 b' class SyntaxTB(ListTB):'
1413 and isinstance(value.filename, str) \
1412 and isinstance(value.filename, str) \
1414 and isinstance(value.lineno, int):
1413 and isinstance(value.lineno, int):
1415 linecache.checkcache(value.filename)
1414 linecache.checkcache(value.filename)
1416 newtext = ulinecache.getline(value.filename, value.lineno)
1415 newtext = linecache.getline(value.filename, value.lineno)
1417 if newtext:
1416 if newtext:
1418 value.text = newtext
1417 value.text = newtext
1419 self.last_syntax_error = value
1418 self.last_syntax_error = value
General Comments 0
You need to be logged in to leave comments. Login now