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


Groups > comp.lang.python > #32978

Re: int.__init__ incompatible in Python 3.3

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'args': 0.04; 'subject:Python': 0.05; 'fixes': 0.05; 'arguments': 0.07; 'bug.': 0.07; 'parameter': 0.07; 'works.': 0.07; "'''": 0.09; '__init__': 0.09; 'builtins': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subclasses': 0.09; 'terry': 0.09; 'bug': 0.10; 'def': 0.10; '2.7': 0.13; '3.2,': 0.16; '3.2.': 0.16; '3.3,': 0.16; 'backward': 0.16; 'bug,': 0.16; 'devs': 0.16; 'dummy': 0.16; 'eckhardt': 0.16; 'entry.': 0.16; 'feature?': 0.16; 'fixes.': 0.16; 'other:': 0.16; 'placeholder': 0.16; 'preparing': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'stumbled': 0.16; 'subject:3.3': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'documented': 0.17; 'issue,': 0.17; 'thu,': 0.17; 'jan': 0.18; '>>>': 0.18; 'discussion': 0.20; 'define': 0.20; 'sort': 0.21; 'error.': 0.21; '3.2': 0.22; 'bug?': 0.22; 'object.': 0.22; 'patch': 0.24; 'raise': 0.24; 'url:bugs': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'wonder': 0.27; 'core': 0.27; 'header:X-Complaints- To:1': 0.28; 'document,': 0.29; 'initialized': 0.29; 'though.': 0.29; 'case,': 0.29; 'summary': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'call.': 0.30; 'function': 0.30; 'sense': 0.31; 'lists': 0.31; 'code': 0.31; 'url:python': 0.32; 'not.': 0.32; 'skip:- 10': 0.32; 'could': 0.32; 'says': 0.33; 'int': 0.33; 'to:addr:python- list': 0.33; 'another': 0.33; 'wrong': 0.34; 'list': 0.35; 'nov': 0.35; 'open': 0.35; 'pm,': 0.35; 'similar': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'url:org': 0.36; 'depends': 0.36; 'method': 0.36; 'should': 0.36; 'does': 0.37; 'drop': 0.37; 'passed': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'nothing': 0.38; 'several': 0.39; 'gives': 0.39; 'to:addr:python.org': 0.39; 'takes': 0.39; 'header:Received:5': 0.40; 'situation': 0.62; 'between': 0.63; 'behavior': 0.64; 'details,': 0.65; 'hand': 0.82; 'received:fios.verizon.net': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: int.__init__ incompatible in Python 3.3
Date Thu, 08 Nov 2012 15:29:38 -0500
References <481tm9-k6i.ln1@satorlaser.homedns.org> <CALwzid=bQXfhPz6mT30YOA+gJZKGHs--4XEPjPLDPEFvMM-T+Q@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0
In-Reply-To <CALwzid=bQXfhPz6mT30YOA+gJZKGHs--4XEPjPLDPEFvMM-T+Q@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3463.1352406597.27098.python-list@python.org> (permalink)
Lines 71
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352406597 news.xs4all.nl 6906 [2001:888:2000:d::a6]:38680
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32978

Show key headers only | View raw


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 | NextPrevious in thread | Next 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