Alexandre Vassalotti wrote:
But what if PyType_GenericAlloc is used for tp_alloc? As far as I
know, the memory block allocated with PyType_GenericAlloc is zeroed.
Oh, you are right. The generic allocator uses memset to initialize the
block with \0.
Christian
_
[oops, I forgot to cc the list]
On Thu, Oct 30, 2008 at 7:43 PM, Christian Heimes <[EMAIL PROTECTED]> wrote:
> Alexandre Vassalotti wrote:
>>
>> And that is exactly the reason why, the _pickle module doesn't use
>> __new__ for initialization. Doing any kind of argument parsing in
>> __new__ preve
On Thu, Oct 30, 2008 at 6:36 PM, Nick Coghlan <[EMAIL PROTECTED]> wrote:
> Alexandre Vassalotti wrote:
>> And that is exactly the reason why, the _pickle module doesn't use
>> __new__ for initialization. Doing any kind of argument parsing in
>> __new__ prevents subclasses from customizing the argu
Alexandre Vassalotti wrote:
And that is exactly the reason why, the _pickle module doesn't use
__new__ for initialization. Doing any kind of argument parsing in
__new__ prevents subclasses from customizing the arguments for their
__init__.
Although, I agree that __new__ should be used, whenever
Alexandre Vassalotti wrote:
> On Thu, Oct 30, 2008 at 1:00 PM, Fred Drake <[EMAIL PROTECTED]> wrote:
>> It's good to move work into __init__ where reasonable, so that it can be
>> avoided if a subclass wants it done in a completely different way, but new
>> can't work that way.
>>
>
> And that is
On Thu, Oct 30, 2008 at 1:00 PM, Fred Drake <[EMAIL PROTECTED]> wrote:
> It's good to move work into __init__ where reasonable, so that it can be
> avoided if a subclass wants it done in a completely different way, but new
> can't work that way.
>
And that is exactly the reason why, the _pickle mo
On Oct 30, 2008, at 10:20 AM, Christian Heimes wrote:
I like to establish a rule that *all* struct members must be
initialized properly in the type's tp_new function.
I think this has always been a requirement. The result of the "new"
operation must conform to all the requirements that the
Yes, that's what __new__ / tp_new is for! Thanks for finding this.
On Thu, Oct 30, 2008 at 7:20 AM, Christian Heimes <[EMAIL PROTECTED]> wrote:
> I like to raise attention for a problem revealed by
> http://bugs.python.org/issue4237
>
> ---
> The bug was caused by a design flaw -- which was partly
I like to raise attention for a problem revealed by
http://bugs.python.org/issue4237
---
The bug was caused by a design flaw -- which was partly my fault. Some
elements of the PyFileIOObject struct were initialized in __new__ while
other parts were initialized in __init__. I've moved the initial