Re: [Python-Dev] buglet in long("123\0", 10)

2007-01-18 Thread Calvin Spealman
On 1/18/07, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Calvin Spealman wrote: > > Added a check in test_long.LongTest.test_misc() that long("123\0", 10) > > fails properly and adapted the patch to int_new to long_new. I get > > this weird feeling that if its impossible for the function > > (PyLong_F

Re: [Python-Dev] buglet in long("123\0", 10)

2007-01-18 Thread Nick Coghlan
Calvin Spealman wrote: > Added a check in test_long.LongTest.test_misc() that long("123\0", 10) > fails properly and adapted the patch to int_new to long_new. I get > this weird feeling that if its impossible for the function > (PyLong_FromString) to know if its being given bad data, having know >

Re: [Python-Dev] buglet in long("123\0", 10)

2007-01-16 Thread Calvin Spealman
Added a check in test_long.LongTest.test_misc() that long("123\0", 10) fails properly and adapted the patch to int_new to long_new. I get this weird feeling that if its impossible for the function (PyLong_FromString) to know if its being given bad data, having know way to know if the string is supp

Re: [Python-Dev] buglet in long("123\0", 10)

2007-01-14 Thread Guido van Rossum
On 1/14/07, Calvin Spealman <[EMAIL PROTECTED]> wrote: > Is it a more general problem that null-terminated strings are used > with data from strings we specifically allow to contain null bytes? > Perhaps a migration of *FromString() to *FromStringAndSize() > functions, or taking Python string objec

Re: [Python-Dev] buglet in long("123\0", 10)

2007-01-14 Thread Calvin Spealman
Is it a more general problem that null-terminated strings are used with data from strings we specifically allow to contain null bytes? Perhaps a migration of *FromString() to *FromStringAndSize() functions, or taking Python string object pointers, would be a more general solution to set as a goal,

Re: [Python-Dev] buglet in long("123\0", 10)

2007-01-14 Thread Neal Norwitz
SVN rev 52305 resolved Bug #1545497: when given an explicit base, int() did ignore NULs embedded in the string to convert. However, the same fix wasn't applied for long(). n On 1/13/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > What's wrong with this session? :-) > > Python 2.6a0 (trunk:5341

Re: [Python-Dev] buglet in long("123\0", 10)

2007-01-14 Thread skip
Nick> With an explicit base, however, PyLong_FromString is called Nick> directly. Since that API takes a char* string, it stops at the Nick> first embedded NULL: long('123\0003', 10) Nick> 123L long('123\00032', 10) Nick> 123L Nick> So 'long_from_string

Re: [Python-Dev] buglet in long("123\0", 10)

2007-01-13 Thread Nick Coghlan
Guido van Rossum wrote: >>> long('123\0', 10) > 123L Interesting - long_new goes through PyNumber_Long if no explicit base is provided. That does a pre-check for embedded NULLs in the input string. With an explicit base, however, PyLong_FromString is called directly. Since that API takes a char

[Python-Dev] buglet in long("123\0", 10)

2007-01-13 Thread Guido van Rossum
What's wrong with this session? :-) Python 2.6a0 (trunk:53416, Jan 13 2007, 15:24:17) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> int('123\0') Traceback (most recent call last): File "", line 1, in ValueError