Fix spying on unbound methods defined in a parent class of an owner.

Review Request #10343 — Created Dec. 3, 2018 and submitted — Latest diff uploaded

Information

kgb
master
b84ad50...

Reviewers

kgb

When spying on bound methods that were really defined on a parent of an
owning class, we cloned the method so that the underlying bytecode
wouldn't be shared between the spied method and other subclasses of the
parent. The same needs to be done for unbound methods as well.

This updates our cloning logic to properly clone unbound methods,
keeping the state separate. This works on all supported versions of
Python.

Unit tests pass on all supported Python versions.

Tested against broken behavior in tests being written in Review Board.