Guido van Rossum added the comment: On 10/13/07, Christian Heimes <[EMAIL PROTECTED]> 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? __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1272> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com