[PyQt] Monkey-patcing virtual methods with functions: change in
rasky at develer.com
Thu Oct 29 20:35:40 GMT 2009
On Thu, 29 Oct 2009 21:40:06 +0200, "Hans-Peter Jansen" <hpj at urpla.net>
> On Thursday 29 October 2009, 18:07:33 Giovanni Bajo wrote:
>> Hi Phil,
>> it looks like SIP 4.9 changed behaviour wrt monkey-patching of virtual
>> methods. If you use a regular Python function (or a lambda) to do the
>> monkey patching, the function is passed 'self' when it's invoked.
>> This change in behaviour is undocumented among the incompatibilities
>> with earlier versions. Moreover, it break existing code in a way that it
>> is hard to fix (there is no easy way to grep all occurrences); it is
>> also hard to debug because the resulting exception (eg: "function takes
>> no argument (1 given)") does not usually have any traceback attached.
>> Lastly, it does not match what Python itself does when monkey-patching a
>> method with a function; with regular Python objects, the function is not
>> passed 'self' when it's invoked as a method.
>> What's your position on this? Was this change in behaviour a rationale
>> choice or just an unwanted regression?
> Giovanni, did you really tested sip 4.9? Then you might want to test
> since it has _a_couple_of_fixes_ with respect of monkey patching.
Yes, I was using SIP 4.9.1. I actually noticed a couple of improvements
(eg: you can now change a previous monkeypatch with a new one), but the
above change/regression basically broke every program of mine that is using
More information about the PyQt