diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index b488a11..459ae84 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -296,9 +296,7 @@ class Tracer: if name not in old_local_reprs: self.write('{indent}{newish_string}{name} = {value_repr}'.format( **locals())) - - for name, value_repr in local_reprs.items(): - if name in old_local_reprs and old_local_reprs[name] != value_repr: + elif old_local_reprs[name] != value_repr: self.write('{indent}Modified var:.. {name} = {value_repr}'.format( **locals())) diff --git a/tests/test_pysnooper.py b/tests/test_pysnooper.py index 4e31f14..d3882e4 100644 --- a/tests/test_pysnooper.py +++ b/tests/test_pysnooper.py @@ -276,8 +276,8 @@ def test_watch_explode(): VariableEntry('(lst + [])[2]', '9'), VariableEntry('lst + []'), LineEntry(), - VariableEntry('(lst + [])[3]', '10'), VariableEntry('lst'), + VariableEntry('(lst + [])[3]', '10'), VariableEntry('lst + []'), ReturnEntry(), ReturnValueEntry('None')