logilab-common #79268 python3: monkeypatch failure with bound method [validation pending]

Arfrever Frehtes Taifersar Arahesis
Wed, 19 Oct 2011 12:56:08 +0200

Fix added in :changeset:a5fc783ebbfb isn't sufficient.

method_type() cannot support bound method monkeypatching (only class will be used by constructor).

--- a/compat.py
+++ b/compat.py
@@ -61,11 +61,11 @@ except AttributeError:

 # See also http://bugs.python.org/issue11776
 if sys.version_info[0] == 3:
   def method_type(callable, instance, klass):
-        return types.MethodType(callable, klass)
+        return types.MethodType(callable, instance or klass())
     # alias types otherwise
     method_type = types.MethodType


unhandled exception occurred while testing unittest_ureports_html
Traceback (most recent call last):
  File "/tmp/logilab-common-0.57.0/usr/lib64/python3.2/site-packages/logilab/common/pytest.py", line 11
29, in _ts_wrapped_run
  test._wrapped_run(result, debug, runcondition=runcondition, options=options)
  File "/tmp/logilab-common-0.57.0/usr/lib64/python3.2/site-packages/logilab/common/pytest.py", line 11
20, in _ts_wrapped_run
  self._handleModuleFixture(test, result)
  File "/tmp/logilab-common-0.57.0/usr/lib64/python3.2/site-packages/logilab/common/testlib.py", line 3
75, in _handleModuleFixture
  previousModule = self._get_previous_module(result)
TypeError: _get_previous_module() takes exactly 2 arguments (1 given)
done in0.57.1
load left0.000
closed by#091a372460a9 [compat] use instance of the class to have a real instance method (closes: #79268)