676 if filename not in Breakpoint.breakInFile: |
676 if filename not in Breakpoint.breakInFile: |
677 Breakpoint.breakInFrameCache[ |
677 Breakpoint.breakInFrameCache[ |
678 frame.f_globals.get("__file__"), frame.f_code.co_firstlineno |
678 frame.f_globals.get("__file__"), frame.f_code.co_firstlineno |
679 ] = False |
679 ] = False |
680 return False |
680 return False |
681 lineNo = frame.f_code.co_firstlineno |
681 |
682 lineNumbers = [lineNo] |
682 try: |
683 |
683 lineNumbers = [ |
684 co_lnotab = frame.f_code.co_lnotab[1::2] |
684 l for _, _, l in frame.f_code.co_lines() if l is not None |
685 |
685 ] |
686 # No need to handle special case if a lot of lines between |
686 except AttributeError: |
687 # (e.g. closure), because the additional lines won't cause a bp |
687 # backward compatibility code for Python 3.10 and below |
688 for co_lno in co_lnotab: |
688 lineNo = frame.f_code.co_firstlineno |
689 if co_lno >= 0x80: |
689 lineNumbers = [lineNo] |
690 lineNo -= 0x100 |
690 |
691 lineNo += co_lno |
691 co_lnotab = frame.f_code.co_lnotab[1::2] |
692 lineNumbers.append(lineNo) |
692 |
|
693 # No need to handle special case if a lot of lines between |
|
694 # (e.g. closure), because the additional lines won't cause a bp |
|
695 for co_lno in co_lnotab: |
|
696 if co_lno >= 0x80: |
|
697 lineNo -= 0x100 |
|
698 lineNo += co_lno |
|
699 lineNumbers.append(lineNo) |
693 |
700 |
694 for bp in Breakpoint.breakInFile[filename]: |
701 for bp in Breakpoint.breakInFile[filename]: |
695 if bp in lineNumbers: |
702 if bp in lineNumbers: |
696 Breakpoint.breakInFrameCache[ |
703 Breakpoint.breakInFrameCache[ |
697 frame.f_globals.get("__file__"), frame.f_code.co_firstlineno |
704 frame.f_globals.get("__file__"), frame.f_code.co_firstlineno |