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

danken at redhat.com danken at redhat.com
Mon Jan 20 21:17:48 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>
---
M tests/monkeypatch.py
M tests/monkeypatchTests.py
2 files changed, 76 insertions(+), 2 deletions(-)

Approvals:
  Nir Soffer: Looks good to me, but someone else must approve
  Antoni Segura Puimedon: Verified
  Dan Kenigsberg: Looks good to me, approved



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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3100455ab761481f57a93ab8aacc34ac4ab91eb
Gerrit-PatchSet: 6
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alonbl at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list