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
| 276 | |
| 277 | |
| 278 | class FrameSummary: |
| 279 | """Information about a single frame from a traceback. |
| 280 | |
| 281 | - :attr:`filename` The filename for the frame. |
| 282 | - :attr:`lineno` The line within filename for the frame that was |
| 283 | active when the frame was captured. |
| 284 | - :attr:`name` The name of the function or method that was executing |
| 285 | when the frame was captured. |
| 286 | - :attr:`line` The text from the linecache module for the |
| 287 | of code that was running when the frame was captured. |
| 288 | - :attr:`locals` Either None if locals were not supplied, or a dict |
| 289 | mapping the name to the repr() of the variable. |
| 290 | """ |
| 291 | |
| 292 | __slots__ = ('filename', 'lineno', 'end_lineno', 'colno', 'end_colno', |
| 293 | 'name', '_lines', '_lines_dedented', 'locals', '_code') |
| 294 | |
| 295 | def __init__(self, filename, lineno, name, *, lookup_line=True, |
| 296 | locals=None, line=None, |
| 297 | end_lineno=None, colno=None, end_colno=None, **kwargs): |
| 298 | """Construct a FrameSummary. |
| 299 | |
| 300 | :param lookup_line: If True, `linecache` is consulted for the source |
| 301 | code line. Otherwise, the line will be looked up when first needed. |
| 302 | :param locals: If supplied the frame locals, which will be captured as |
| 303 | object representations. |
| 304 | :param line: If provided, use this instead of looking up the line in |
| 305 | the linecache. |
| 306 | """ |
| 307 | self.filename = filename |
| 308 | self.lineno = lineno |
| 309 | self.end_lineno = lineno if end_lineno is None else end_lineno |
| 310 | self.colno = colno |
| 311 | self.end_colno = end_colno |
| 312 | self.name = name |
| 313 | self._code = kwargs.get("_code") |
| 314 | self._lines = line |
| 315 | self._lines_dedented = None |
| 316 | if lookup_line: |
| 317 | self.line |
| 318 | self.locals = {k: _safe_string(v, 'local', func=repr) |
| 319 | for k, v in locals.items()} if locals else None |
| 320 | |
| 321 | def __eq__(self, other): |
| 322 | if isinstance(other, FrameSummary): |
| 323 | return (self.filename == other.filename and |
| 324 | self.lineno == other.lineno and |
| 325 | self.name == other.name and |
| 326 | self.locals == other.locals) |
| 327 | if isinstance(other, tuple): |
| 328 | return (self.filename, self.lineno, self.name, self.line) == other |
| 329 | return NotImplemented |
| 330 | |
| 331 | def __getitem__(self, pos): |
| 332 | return (self.filename, self.lineno, self.name, self.line)[pos] |
| 333 | |
| 334 | def __iter__(self): |
| 335 | return iter([self.filename, self.lineno, self.name, self.line]) |
no outgoing calls
no test coverage detected