Change in vdsm[ovirt-3.4]: MonkeyPatch: fix applying and reverting (static|class)methods.

danken at redhat.com danken at redhat.com
Wed Feb 26 15:03:00 UTC 2014


Dan Kenigsberg has submitted this change and it was merged.

Change subject: MonkeyPatch: fix applying and reverting (static|class)methods.
......................................................................


MonkeyPatch: fix applying and reverting (static|class)methods.

When applying a patch to a class we should cast the method we are
patching with to be of the same kind (staticmethod, instancemethod
or classmethod) as the original method that we are replacing. (Note
that by default setattr sets those methods as instancemethods).

In Python2, setattr(Class, name, func) automatically converts func
into an instancemethod. To keep type(Class.func) as function,
staticmethod(func) must be applied explicitly when reverting.

Credit goes to Nir Soffer or the final version of the patch and tests.

Change-Id: Ie3100455ab761481f57a93ab8aacc34ac4ab91eb
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/23378
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/25058
---
M tests/monkeypatch.py
M tests/monkeypatchTests.py
2 files changed, 76 insertions(+), 2 deletions(-)

Approvals:
  Antoni Segura Puimedon: Verified
  Dan Kenigsberg: Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/25058
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3100455ab761481f57a93ab8aacc34ac4ab91eb
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.4
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list