:3: EncodingWarning: "))
def _get_test_grp_name():
diff --git a/Lib/traceback.py b/Lib/traceback.py
index 31c73efcef5a52..dd9e88d24a0606 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -288,11 +288,11 @@ class FrameSummary:
"""
__slots__ = ('filename', 'lineno', 'end_lineno', 'colno', 'end_colno',
- 'name', '_lines', '_lines_dedented', 'locals')
+ 'name', '_lines', '_lines_dedented', 'locals', '_code')
def __init__(self, filename, lineno, name, *, lookup_line=True,
locals=None, line=None,
- end_lineno=None, colno=None, end_colno=None):
+ end_lineno=None, colno=None, end_colno=None, **kwargs):
"""Construct a FrameSummary.
:param lookup_line: If True, `linecache` is consulted for the source
@@ -308,6 +308,7 @@ def __init__(self, filename, lineno, name, *, lookup_line=True,
self.colno = colno
self.end_colno = end_colno
self.name = name
+ self._code = kwargs.get("_code")
self._lines = line
self._lines_dedented = None
if lookup_line:
@@ -347,7 +348,10 @@ def _set_lines(self):
lines = []
for lineno in range(self.lineno, self.end_lineno + 1):
# treat errors (empty string) and empty lines (newline) as the same
- lines.append(linecache.getline(self.filename, lineno).rstrip())
+ line = linecache.getline(self.filename, lineno).rstrip()
+ if not line and self._code is not None and self.filename.startswith("<"):
+ line = linecache._getline_from_code(self._code, lineno).rstrip()
+ lines.append(line)
self._lines = "\n".join(lines) + "\n"
@property
@@ -480,9 +484,13 @@ def _extract_from_extended_frame_gen(klass, frame_gen, *, limit=None,
f_locals = f.f_locals
else:
f_locals = None
- result.append(FrameSummary(
- filename, lineno, name, lookup_line=False, locals=f_locals,
- end_lineno=end_lineno, colno=colno, end_colno=end_colno))
+ result.append(
+ FrameSummary(filename, lineno, name,
+ lookup_line=False, locals=f_locals,
+ end_lineno=end_lineno, colno=colno, end_colno=end_colno,
+ _code=f.f_code,
+ )
+ )
for filename in fnames:
linecache.checkcache(filename)
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index ae0df9685ac159..59edbe12dee9a4 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1383,7 +1383,7 @@ run_mod(mod_ty mod, PyObject *filename, PyObject *globals, PyObject *locals,
PyObject* result = PyObject_CallFunction(
print_tb_func, "OOO",
- interactive_filename,
+ co,
interactive_src,
filename
);
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy