Skip to content

gh-111881: Import lazily linecache in traceback #111886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/traceback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import collections.abc
import itertools
import linecache
import sys
import textwrap
from contextlib import suppress
Expand Down Expand Up @@ -333,6 +332,7 @@ def line(self):
if self._line is None:
if self.lineno is None:
return None
import linecache
self._line = linecache.getline(self.filename, self.lineno)
return self._line.strip()

Expand Down Expand Up @@ -430,6 +430,8 @@ def _extract_from_extended_frame_gen(klass, frame_gen, *, limit=None,
else:
frame_gen = collections.deque(frame_gen, maxlen=-limit)

import linecache

result = klass()
fnames = set()
for f, (lineno, end_lineno, colno, end_colno) in frame_gen:
Expand Down