[pypy-dev] behaviour difference int-subclasses pypy 1.5 to cpython 2.6.6.

Michael Foord fuzzyman at gmail.com
Tue Aug 16 14:06:23 CEST 2011


On 16 August 2011 12:32, Massa, Harald Armin <chef at ghum.de> wrote:

> On Tue, Aug 16, 2011 at 11:59 AM, Massa, Harald Armin <chef at ghum.de>
>> wrote:
>> >>>> class fisch(int):
>> > ...     def __init__(self, value):
>> > ...         int.__init__(value)
>>
>> You probably mean "int.__init__(self, value)" here.  Your code is buggy
>> :-)
>>
>
> just submitted the fix to the pyPdf author :)  my workaround was
>
> def __init__(self, value):
>        int.__init__(int(value))
> .. so that I could run it under PyPy :)
>
>
Given that int doesn't *have* an __init__ method, just omitting that call
altogether is a better fix. (int objects use __new__ for construction and
have no post construction initialisation.)



> so, I understand that the cPython behaviour is rather buggy. Good to have
> another Python implementation :)
>

Well, it isn't buggy. The call is equivalent to:

   object.__init__("12")

This just does nothing as "12" is a valid instance of object...

I assume the difference is that int has an __init__ method on pypy.

Michael


> Thanks for the fast response,
>
> Harald
>
> --
> GHUM GmbH
> Harald Armin Massa
> Spielberger Straße 49
> 70435 Stuttgart
> 0173/9409607
>
> Amtsgericht Stuttgart, HRB 734971
> -
> persuadere.
> et programmare
>
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> http://mail.python.org/mailman/listinfo/pypy-dev
>
>


-- 

http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20110816/928c0af4/attachment-0001.html>


More information about the pypy-dev mailing list