Skip to content

Commit

Permalink
Use is instead of == for variable compare (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaogaotiantian authored Feb 3, 2021
1 parent cd0cea7 commit c787751
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/watchpoints/watch_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ def changed(self, frame):
if "variable" in self.track:
if frame is self.frame and self.localvar is not None:
if self.localvar in frame.f_locals:
if frame.f_locals[self.localvar] != self.obj:
if frame.f_locals[self.localvar] is not self.obj:
self.obj = frame.f_locals[self.localvar]
return True, True
else:
return True, False

if self.parent is not None and self.subscr is not None:
try:
if self.parent[self.subscr] != self.obj:
if self.parent[self.subscr] is not self.obj:
self.obj = self.parent[self.subscr]
return True, True
except (IndexError, KeyError):
return True, False
elif self.parent is not None and self.attr is not None:
try:
if getattr(self.parent, self.attr) != self.obj:
if getattr(self.parent, self.attr) is not self.obj:
self.obj = getattr(self.parent, self.attr)
return True, True
except AttributeError:
Expand Down

0 comments on commit c787751

Please sign in to comment.