Fix spying on objects with a custom __setattr__.
Review Request #10073 — Created July 9, 2018 and submitted — Latest diff uploaded
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 whatsetattr()
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.