Message 56393 - Python tracker

Message56393

Author gvanrossum
Recipients alexandre.vassalotti, christian.heimes, gvanrossum
Date 2007-10-14.00:35:52
SpamBayes Score 0.00023885765
Marked as misclassified No
Message-id <ca471dc20710131735x70611e6fx75c05c94e1d15ef6@mail.gmail.com>
In-reply-to <4711545C.7080408@cheimes.de>
Content
On 10/13/07, Christian Heimes <report@bugs.python.org> wrote:
> Guido van Rossum wrote:
> > - Why add an 'errors' argument to the function when it's a fatal error
> > to use it?
>
> I wanted the signature of the method be equal to the other methods
> PyUnicode_Decode*. I copied the FatalError from
> *_PyUnicode_AsDefaultEncodedString().

But that function is a terrible example; it was done that way because
an earlier version of the function *did* allow using the errors
argument and I wanted to make sure to catch all calls that were still
passing an errors value. This doesn't apply here, we're creating a
brand new API.

> > - Using 0 to autodetect the length is scary.  Normally we have two APIs
> > for that, one ..._FromString and one ...FromStringAndSize.  If you
> > really don't want that, please use -1, which is at least an illegal value.
>
> Oh right, -1 is *much* better for autodetect than 0. What do you prefer,
> a second method or -1 as auto detect?

Even better is Alexandre's version: always autodetect. I think we can
assume that filenames are always available as 0-terminated byte
arrays, since that's how all system calls need them.

Anyway, let me know if you want to change something in Alexandre's
version or if you want him to check it in.

Oh. Hm. I still wish that PyCode_New() could just insist that the
filename argument is a PyUnicode instance. Why can't it? Perhaps the
caller should be fixed instead?
History
Date User Action Args
2007-10-14 00:35:55gvanrossumsetspambayes_score: 0.000238858 -> 0.00023885765
recipients: + gvanrossum, christian.heimes, alexandre.vassalotti
2007-10-14 00:35:54gvanrossumlinkissue1272 messages
2007-10-14 00:35:52gvanrossumcreate