(klass, frame_gen, *, limit=None,
lookup_lines=True, capture_locals=False)
| 474 | |
| 475 | @classmethod |
| 476 | def _extract_from_extended_frame_gen(klass, frame_gen, *, limit=None, |
| 477 | lookup_lines=True, capture_locals=False): |
| 478 | # Same as extract but operates on a frame generator that yields |
| 479 | # (frame, (lineno, end_lineno, colno, end_colno)) in the stack. |
| 480 | # Only lineno is required, the remaining fields can be None if the |
| 481 | # information is not available. |
| 482 | builtin_limit = limit is BUILTIN_EXCEPTION_LIMIT |
| 483 | if limit is None or builtin_limit: |
| 484 | limit = getattr(sys, 'tracebacklimit', None) |
| 485 | if limit is not None and limit < 0: |
| 486 | limit = 0 |
| 487 | if limit is not None: |
| 488 | if builtin_limit: |
| 489 | frame_gen = tuple(frame_gen) |
| 490 | frame_gen = frame_gen[len(frame_gen) - limit:] |
| 491 | elif limit >= 0: |
| 492 | frame_gen = itertools.islice(frame_gen, limit) |
| 493 | else: |
| 494 | frame_gen = collections.deque(frame_gen, maxlen=-limit) |
| 495 | |
| 496 | result = klass() |
| 497 | fnames = set() |
| 498 | for f, (lineno, end_lineno, colno, end_colno) in frame_gen: |
| 499 | co = f.f_code |
| 500 | filename = co.co_filename |
| 501 | name = co.co_name |
| 502 | fnames.add(filename) |
| 503 | linecache.lazycache(filename, f.f_globals) |
| 504 | # Must defer line lookups until we have called checkcache. |
| 505 | if capture_locals: |
| 506 | f_locals = f.f_locals |
| 507 | else: |
| 508 | f_locals = None |
| 509 | result.append( |
| 510 | FrameSummary(filename, lineno, name, |
| 511 | lookup_line=False, locals=f_locals, |
| 512 | end_lineno=end_lineno, colno=colno, end_colno=end_colno, |
| 513 | _code=f.f_code, |
| 514 | ) |
| 515 | ) |
| 516 | for filename in fnames: |
| 517 | linecache.checkcache(filename) |
| 518 | |
| 519 | # If immediate lookup was desired, trigger lookups now. |
| 520 | if lookup_lines: |
| 521 | for f in result: |
| 522 | f.line |
| 523 | return result |
| 524 | |
| 525 | @classmethod |
| 526 | def from_list(klass, a_list): |
no test coverage detected