[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] Re: Monkey-patcing virtual methods with functions: change
From: Phil Thompson <phil () riverbankcomputing ! com>
Date: 2009-10-30 18:04:44
Message-ID: 9be4d20654b5d738944cdd6a84086bd3 () localhost
[Download RAW message or body]
On Fri, 30 Oct 2009 17:11:28 +0000, Phil Thompson
<phil@riverbankcomputing.com> wrote:
> On Fri, 30 Oct 2009 16:43:16 +0000, Phil Thompson
> <phil@riverbankcomputing.co.uk> wrote:
>> On Thu, 29 Oct 2009 18:07:33 +0100, Giovanni Bajo <rasky@develer.com>
>> 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?
>>
>> It should behave in the same way as regular Python classes do - which it
>> does (both for Python v2 and v3) in my tests.
>>
>> Can you provide me with a test which shows different behavior?
>
> Ahh - hang on, just realised my test is broken...
Fixed in tonight's SIP snapshot. It was fine when patching classes but
behaved differently to Python when patching instances.
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic