Return (active breakpoint, delete temporary flag) or (None, None) as breakpoint to act upon. The "active breakpoint" is the first entry in bplist[line, file] (which must exist) that is enabled, for which checkfuncname is True, and that has neither a False condition
(file, line, frame)
| 809 | |
| 810 | |
| 811 | def effective(file, line, frame): |
| 812 | """Return (active breakpoint, delete temporary flag) or (None, None) as |
| 813 | breakpoint to act upon. |
| 814 | |
| 815 | The "active breakpoint" is the first entry in bplist[line, file] (which |
| 816 | must exist) that is enabled, for which checkfuncname is True, and that |
| 817 | has neither a False condition nor a positive ignore count. The flag, |
| 818 | meaning that a temporary breakpoint should be deleted, is False only |
| 819 | when the condiion cannot be evaluated (in which case, ignore count is |
| 820 | ignored). |
| 821 | |
| 822 | If no such entry exists, then (None, None) is returned. |
| 823 | """ |
| 824 | possibles = Breakpoint.bplist[file, line] |
| 825 | for b in possibles: |
| 826 | if not b.enabled: |
| 827 | continue |
| 828 | if not checkfuncname(b, frame): |
| 829 | continue |
| 830 | # Count every hit when bp is enabled |
| 831 | b.hits += 1 |
| 832 | if not b.cond: |
| 833 | # If unconditional, and ignoring go on to next, else break |
| 834 | if b.ignore > 0: |
| 835 | b.ignore -= 1 |
| 836 | continue |
| 837 | else: |
| 838 | # breakpoint and marker that it's ok to delete if temporary |
| 839 | return (b, True) |
| 840 | else: |
| 841 | # Conditional bp. |
| 842 | # Ignore count applies only to those bpt hits where the |
| 843 | # condition evaluates to true. |
| 844 | try: |
| 845 | val = eval(b.cond, frame.f_globals, frame.f_locals) |
| 846 | if val: |
| 847 | if b.ignore > 0: |
| 848 | b.ignore -= 1 |
| 849 | # continue |
| 850 | else: |
| 851 | return (b, True) |
| 852 | # else: |
| 853 | # continue |
| 854 | except: |
| 855 | # if eval fails, most conservative thing is to stop on |
| 856 | # breakpoint regardless of ignore count. Don't delete |
| 857 | # temporary, as another hint to user. |
| 858 | return (b, False) |
| 859 | return (None, None) |
| 860 | |
| 861 | |
| 862 | # -------------------- testing -------------------- |
no test coverage detected