Whole file
gaogaotiantian/watchpoints
The author described this change as “Fix comparing with None bug”. It counts as a record because the check below fails on the code as it stood at 961533916 and passes on e75bd1b11, with nothing else changed between the two runs.
Projectgaogaotiantian/watchpoints
Fix saved2020-12-07
Sharing licenceApache-2.0 · LICENSE
Change size+4 −6
What the code was meant to do, written into the code itself as a save note
Fix comparing with None bug
The change
| 32 | 32 | """ | |
| 33 | 33 | :return (changed, exist): | |
| 34 | 34 | """ | |
| 35 | - | if frame is self.frame and self.localvar: | |
| 35 | + | if frame is self.frame and self.localvar is not None: | |
| 36 | 36 | if self.localvar in frame.f_locals: | |
| 37 | 37 | if frame.f_locals[self.localvar] != self.obj: | |
| 38 | - | self.prev_obj = self.obj | |
| 39 | 38 | self.obj = frame.f_locals[self.localvar] | |
| 40 | 39 | return True, True | |
| 41 | 40 | else: | |
| 42 | 41 | return True, False | |
| 43 | 42 | ||
| 44 | - | if self.parent and self.subscr: | |
| 43 | + | if self.parent is not None and self.subscr is not None: | |
| 45 | 44 | try: | |
| 46 | 45 | if self.parent[self.subscr] != self.obj: | |
| 47 | - | self.prev_obj = self.obj | |
| 48 | 46 | self.obj = self.parent[self.subscr] | |
| 49 | 47 | return True, True | |
| 50 | 48 | except (IndexError, KeyError): | |
| 51 | 49 | return True, False | |
| 52 | - | elif self.parent and self.attr: | |
| 50 | + | elif self.parent is not None and self.attr is not None: | |
| 53 | 51 | try: | |
| 54 | 52 | if getattr(self.parent, self.attr) != self.obj: | |
| 55 | - | self.prev_obj = self.obj | |
| 56 | 53 | self.obj = getattr(self.parent, self.attr) | |
| 54 | + | return True, True | |
| 57 | 55 | except AttributeError: | |
| 58 | 56 | return True, False | |
| 59 | 57 |
The check that tells the two apart
fail→pass·tests/test_watch_element.py::TestWatchElement::test_changed
Check file tests/test_watch_element.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it961533916e94dc232d1833a3ba66610b99afba43
Broken version dated2020-12-07
Modulewatchpoints.watch_element
Units changedWatchElement
Fingerprint58463fef154744c0
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.