Information about a single frame from a traceback. - :attr:`filename` The filename for the frame. - :attr:`lineno` The line within filename for the frame that was active when the frame was captured. - :attr:`name` The name of the function or method that was executing when th
| 286 | |
| 287 | |
| 288 | class FrameSummary: |
| 289 | """Information about a single frame from a traceback. |
| 290 | |
| 291 | - :attr:`filename` The filename for the frame. |
| 292 | - :attr:`lineno` The line within filename for the frame that was |
| 293 | active when the frame was captured. |
| 294 | - :attr:`name` The name of the function or method that was executing |
| 295 | when the frame was captured. |
| 296 | - :attr:`line` The text from the linecache module for the |
| 297 | of code that was running when the frame was captured. |
| 298 | - :attr:`locals` Either None if locals were not supplied, or a dict |
| 299 | mapping the name to the repr() of the variable. |
| 300 | - :attr:`end_lineno` The last line number of the source code for this frame. |
| 301 | By default, it is set to lineno and indexation starts from 1. |
| 302 | - :attr:`colno` The column number of the source code for this frame. |
| 303 | By default, it is None and indexation starts from 0. |
| 304 | - :attr:`end_colno` The last column number of the source code for this frame. |
| 305 | By default, it is None and indexation starts from 0. |
| 306 | """ |
| 307 | |
| 308 | __slots__ = ('filename', 'lineno', 'end_lineno', 'colno', 'end_colno', |
| 309 | 'name', '_lines', '_lines_dedented', 'locals', '_code') |
| 310 | |
| 311 | def __init__(self, filename, lineno, name, *, lookup_line=True, |
| 312 | locals=None, line=None, |
| 313 | end_lineno=None, colno=None, end_colno=None, **kwargs): |
| 314 | """Construct a FrameSummary. |
| 315 | |
| 316 | :param lookup_line: If True, `linecache` is consulted for the source |
| 317 | code line. Otherwise, the line will be looked up when first needed. |
| 318 | :param locals: If supplied the frame locals, which will be captured as |
| 319 | object representations. |
| 320 | :param line: If provided, use this instead of looking up the line in |
| 321 | the linecache. |
| 322 | """ |
| 323 | self.filename = filename |
| 324 | self.lineno = lineno |
| 325 | self.end_lineno = lineno if end_lineno is None else end_lineno |
| 326 | self.colno = colno |
| 327 | self.end_colno = end_colno |
| 328 | self.name = name |
| 329 | self._code = kwargs.get("_code") |
| 330 | self._lines = line |
| 331 | self._lines_dedented = None |
| 332 | if lookup_line: |
| 333 | self.line |
| 334 | self.locals = {k: _safe_string(v, 'local', func=repr) |
| 335 | for k, v in locals.items()} if locals else None |
| 336 | |
| 337 | def __eq__(self, other): |
| 338 | if isinstance(other, FrameSummary): |
| 339 | return (self.filename == other.filename and |
| 340 | self.lineno == other.lineno and |
| 341 | self.name == other.name and |
| 342 | self.locals == other.locals) |
| 343 | if isinstance(other, tuple): |
| 344 | return (self.filename, self.lineno, self.name, self.line) == other |
| 345 | return NotImplemented |
no outgoing calls
no test coverage detected
searching dependent graphs…