Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32958

int.__init__ incompatible in Python 3.3

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
Newsgroups comp.lang.python
Subject int.__init__ incompatible in Python 3.3
Date Thu, 08 Nov 2012 16:55:16 +0100
Lines 23
Message-ID <481tm9-k6i.ln1@satorlaser.homedns.org> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de Q+lALauB8AtIsGxRTweJIQ2psdpQ4qFjGSEbx8UTKBp1pKFxStDP0AwxSI+g==
X-Orig-Path satorlaser.homedns.org!not-for-mail
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
Xref csiph.com comp.lang.python:32958

Show key headers only | View raw


Hi!

Preparing for an upgrade from 2.7 to 3, I stumbled across an 
incompatibility between 2.7 and 3.2 on one hand and 3.3 on the other:

class X(int):
     def __init__(self, value):
         super(X, self).__init__(value)
X(42)

On 2.7 and 3.2, the above code works. On 3.3, it gives me a "TypeError: 
object.__init__() takes no parameters". To some extent, this makes sense 
to me, because the int subobject is not initialized in __init__ but in 
__new__. As a workaround, I can simple drop the parameter from the call. 
However, breaking backward compatibility is another issue, so I wonder 
if that should be considered as a bug.

Bug? Feature? Other suggestions?


Uli

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

int.__init__ incompatible in Python 3.3 Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-11-08 16:55 +0100
  Re: int.__init__ incompatible in Python 3.3 Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-08 10:13 -0700
  Re: int.__init__ incompatible in Python 3.3 Terry Reedy <tjreedy@udel.edu> - 2012-11-08 15:29 -0500
    Re: int.__init__ incompatible in Python 3.3 Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-11-09 08:56 +0100
      Re: int.__init__ incompatible in Python 3.3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-09 11:37 +0000
        Re: int.__init__ incompatible in Python 3.3 Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-11-09 13:52 +0100
        Re: int.__init__ incompatible in Python 3.3 Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-09 09:30 -0700
        Re: int.__init__ incompatible in Python 3.3 Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-11-12 14:48 +0100

csiph-web