Re: Basic misunderstanding on object creation

2015-05-13 Thread Steven D'Aprano
On Thu, 14 May 2015 06:33 am, Ned Batchelder wrote: > On Wednesday, May 13, 2015 at 3:46:16 PM UTC-4, Mark Lawrence wrote: >> On 13/05/2015 19:42, andrew cooke wrote: >> > On Wednesday, 13 May 2015 13:37:23 UTC-3, Terry Reedy wrote: >> >> On 5/13/2015 9:25 AM, andrew cooke wrote: [...] >> >> >

Re: Basic misunderstanding on object creation

2015-05-13 Thread Ned Batchelder
On Wednesday, May 13, 2015 at 3:46:16 PM UTC-4, Mark Lawrence wrote: > On 13/05/2015 19:42, andrew cooke wrote: > > On Wednesday, 13 May 2015 13:37:23 UTC-3, Terry Reedy wrote: > >> On 5/13/2015 9:25 AM, andrew cooke wrote: > >> > >>> The following code worked on Python 3.2, but no longer works in

Re: Basic misunderstanding on object creation

2015-05-13 Thread Mark Lawrence
On 13/05/2015 19:42, andrew cooke wrote: On Wednesday, 13 May 2015 13:37:23 UTC-3, Terry Reedy wrote: On 5/13/2015 9:25 AM, andrew cooke wrote: The following code worked on Python 3.2, but no longer works in 3.4. Bugfixes break code that depends on buggy behavior. See https://bugs.python.or

Re: Basic misunderstanding on object creation

2015-05-13 Thread Terry Reedy
On 5/13/2015 2:42 PM, andrew cooke wrote: On Wednesday, 13 May 2015 13:37:23 UTC-3, Terry Reedy wrote: On 5/13/2015 9:25 AM, andrew cooke wrote: The following code worked on Python 3.2, but no longer works in 3.4. Bugfixes break code that depends on buggy behavior. See https://bugs.python.o

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
On Wednesday, 13 May 2015 13:37:23 UTC-3, Terry Reedy wrote: > On 5/13/2015 9:25 AM, andrew cooke wrote: > > > The following code worked on Python 3.2, but no longer works in 3.4. > > Bugfixes break code that depends on buggy behavior. See > https://bugs.python.org/issue1683368 > Your code also

Re: Basic misunderstanding on object creation

2015-05-13 Thread Mark Lawrence
On 13/05/2015 18:05, Terry Reedy wrote: On 5/13/2015 12:38 PM, Mark Lawrence wrote: I'm completely convinced that I've seen a change go through on the bug tracker that impacts on this area, but many months if not years ago. Unfortunately searching the bug tracker for super, __new__, __init__ an

Re: Basic misunderstanding on object creation

2015-05-13 Thread Terry Reedy
On 5/13/2015 12:36 PM, Terry Reedy wrote: On 5/13/2015 9:25 AM, andrew cooke wrote: The following code worked on Python 3.2, but no longer works in 3.4. Bugfixes break code that depends on buggy behavior. See https://bugs.python.org/issue1683368 Your code also fails in 2.7.9 if you inherit Fo

Re: Basic misunderstanding on object creation

2015-05-13 Thread Terry Reedy
On 5/13/2015 12:38 PM, Mark Lawrence wrote: I'm completely convinced that I've seen a change go through on the bug tracker that impacts on this area, but many months if not years ago. Unfortunately searching the bug tracker for super, __new__, __init__ and so on gets a lot of hits, leaving my Mk

Re: Basic misunderstanding on object creation

2015-05-13 Thread Mark Lawrence
On 13/05/2015 14:25, andrew cooke wrote: Hi, The following code worked on Python 3.2, but no longer works in 3.4. Did something change, or have I always been doing something dumb? (I realise the code is pointless as is - it's the simplest example I can give of a problem I am seeing with mor

Re: Basic misunderstanding on object creation

2015-05-13 Thread Terry Reedy
On 5/13/2015 9:25 AM, andrew cooke wrote: The following code worked on Python 3.2, but no longer works in 3.4. Bugfixes break code that depends on buggy behavior. See https://bugs.python.org/issue1683368 Your code also fails in 2.7.9 if you inherit Foo from object. The exact error messages cha

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
On Wednesday, 13 May 2015 11:56:21 UTC-3, Ian wrote: > On Wed, May 13, 2015 at 8:45 AM, andrew cooke wrote: > class Foo: > > ... def __new__(cls, *args, **kargs): > > ... print('new', args, kargs) > > ... super().__new__(cls) > > ... > class Bar(Foo): > > ... def

Re: Basic misunderstanding on object creation

2015-05-13 Thread Ian Kelly
On Wed, May 13, 2015 at 8:45 AM, andrew cooke wrote: class Foo: > ... def __new__(cls, *args, **kargs): > ... print('new', args, kargs) > ... super().__new__(cls) > ... class Bar(Foo): > ... def __init__(self, a): > ... print('init', a) > ... Bar(1) >

Re: Basic misunderstanding on object creation

2015-05-13 Thread Ian Kelly
On Wed, May 13, 2015 at 8:42 AM, andrew cooke wrote: > On Wednesday, 13 May 2015 11:36:12 UTC-3, Thomas Rachel wrote: >> Am 13.05.2015 um 15:25 schrieb andrew cooke: >> >> class Foo: >> > ... def __new__(cls, *args, **kargs): >> > ... print('new', args, kargs) >> > ... su

Re: Basic misunderstanding on object creation

2015-05-13 Thread Peter Otten
andrew cooke wrote: >> But then nothing will be passed to __init__ on the subclass. >> >> Andrew > class Foo: > ... def __new__(cls, *args, **kargs): > ... print('new', args, kargs) > ... super().__new__(cls) > ... class Bar(Foo): > ... def __init__(self, a): >

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
> But then nothing will be passed to __init__ on the subclass. > > Andrew >>> class Foo: ... def __new__(cls, *args, **kargs): ... print('new', args, kargs) ... super().__new__(cls) ... >>> class Bar(Foo): ... def __init__(self, a): ... print('init', a) ... >>> B

Re: Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
On Wednesday, 13 May 2015 11:36:12 UTC-3, Thomas Rachel wrote: > Am 13.05.2015 um 15:25 schrieb andrew cooke: > > class Foo: > > ... def __new__(cls, *args, **kargs): > > ... print('new', args, kargs) > > ... super().__new__(cls, *args, **kargs) > > > new (1,) {} > > Tra

Re: Basic misunderstanding on object creation

2015-05-13 Thread Thomas Rachel
Am 13.05.2015 um 15:25 schrieb andrew cooke: class Foo: ... def __new__(cls, *args, **kargs): ... print('new', args, kargs) ... super().__new__(cls, *args, **kargs) new (1,) {} Traceback (most recent call last): File "", line 1, in File "", line 4, in __new__ TypeE

Basic misunderstanding on object creation

2015-05-13 Thread andrew cooke
Hi, The following code worked on Python 3.2, but no longer works in 3.4. Did something change, or have I always been doing something dumb? (I realise the code is pointless as is - it's the simplest example I can give of a problem I am seeing with more complex code). >>> class Foo: ... de