Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32978
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: int.__init__ incompatible in Python 3.3 |
| Date | 2012-11-08 15:29 -0500 |
| References | <481tm9-k6i.ln1@satorlaser.homedns.org> <CALwzid=bQXfhPz6mT30YOA+gJZKGHs--4XEPjPLDPEFvMM-T+Q@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3463.1352406597.27098.python-list@python.org> (permalink) |
On 11/8/2012 12:13 PM, Ian Kelly wrote: > On Thu, Nov 8, 2012 at 8:55 AM, Ulrich Eckhardt > <ulrich.eckhardt@dominolaser.com> wrote: >> 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) This is a bug. Subclasses of immutables should not define __init__. >>> int.__init__ is object.__init__ True object.__init__(self) is a dummy placeholder function that takes no args and does nothing. >> X(42) >> >> On 2.7 and 3.2, the above code works. That is a bug. It is documented that calling with the wrong number of args is an error. >> 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. Just drop the do-nothing call. >> breaking backward compatibility is another issue, so I wonder if that should >> be considered as a bug. Every bug fix breaks backward compatibility with code that depends on the bug. Such breakage is not a bug, but, as in this case, some fixes are not put in bugfix releases because of such breakage. >> Bug? Feature? Other suggestions? Intentional bugfix. http://bugs.python.org/issue1683368 There was additional discussion on pydev or python-ideas lists before the final commit. This fix was not back-ported to 2.7 or 3.2. > A similar change was made to object.__init__ in 2.6, so this could > just be bringing the behavior of int into line with object. There's > nothing about it in the whatsnew document, though. What's New is a summary of *new* features. It does not list bug fixes. At the top it says " For full details, see the Misc/NEWS file." The last patch on the issue added this entry. ''' Core and Builtins ----------------- - Issue #1683368: object.__new__ and object.__init__ raise a TypeError if they are passed arguments and their complementary method is not overridden. ''' > I say open a bug report and let the devs sort it out. Please do not. The current situation is the result of 'sorting it out' over several years. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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