Fix spying on objects with a custom __setattr__.

Review Request #10073 — Created July 9, 2018 and submitted

Information

kgb
master
2e7b1c1...

Reviewers

kgb

Objects with a custom __setattr__ could impact spies, if they don't
fall back to the default behavior. In some cases, we attempt to set a
cloned method on an instance, and this triggered __setattr__,
sometimes losing that spy and leading to various sorts of failures.

We now explicitly call the default object.__setattr__() for instances,
which ensures we're setting the value in the instance's dictionary
instead of triggering the subclass. This is effectively what setattr()
would do by default.

Ran unit tests on all supported Python versions. They failed prior to the
fix, but ran successfully after.

Hit this issue during development on another project. Verified that the
problems went away after the fix.

Description From Last Updated

Typo: boudn

daviddavid
david
  1. 
      
  2. kgb/tests/test_function_spy.py (Diff revision 1)
     
     
    Show all issues

    Typo: boudn

  3. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (dfe42ff)