Re: [Python-Dev] Converting crc32 functions to use unsigned
[Bob Ippolito] > It seems that we should convert the crc32 functions in binascii, > zlib, etc. to deal with unsigned integers. Currently it seems that 32- > bit and 64-bit platforms are going to have different results for > these functions. binascii.crc32 very deliberately intends to return the same signed integer values on all platforms. That's what this section at the end is trying to do: #if SIZEOF_LONG > 4 /* Extend the sign bit. This is one way to ensure the result is the * same across platforms. The other way would be to return an * unbounded unsigned long, but the evidence suggests that lots of * code outside this treats the result as if it were a signed 4-byte * integer. */ result |= -(result & (1L << 31)); #endif return PyInt_FromLong(result); I wouldn't try to fight that, unless that code is buggy (it looks correct to me). I don't remember "the evidence" now, but Barry & I found "lots of code" relying on it at the time ;-) > Should we do the same as the struct module, and do DeprecationWarning > when the input value is < 0? If the _result_ is going to change from sometimes-negative to always-positive, then FutureWarning is most appropriate. > ... > None of the unit tests seem to exercise values where 32-bit and 64- > bit platforms would have differing results, but that's easy enough to > fix... As above, it shouldn't be possible to concoct a case where binascii.crc32's result differ across boxes. That function also intends to treat negative inputs the same way across boxes. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Converting crc32 functions to use unsigned
On May 30, 2006, at 11:19 AM, Guido van Rossum wrote: > On 5/30/06, Giovanni Bajo <[EMAIL PROTECTED]> wrote: >> Bob Ippolito wrote: >> >> > It seems that we should convert the crc32 functions in binascii, >> > zlib, etc. to deal with unsigned integers. >> >> +1!! > > Seems ok, except I don't know what the backwards incompatibilities > would be... > I think the only compatibility issues we're going to run into are with the struct module in the way of DeprecationWarning. If people are depending on specific negative values for these, then their code should already be broken on 64-bit platforms. The only potential breakage I can see is if they're passing these values to other functions written in C that expect PyInt_AsLong(n) to work with the values (on 32-bit platforms). I can't think of a use case for that beyond the functions themselves and the struct module. -bob ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Converting crc32 functions to use unsigned
Seems ok, except I don't know what the backwards incompatibilities would be... On 5/30/06, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > Bob Ippolito wrote: > > > It seems that we should convert the crc32 functions in binascii, > > zlib, etc. to deal with unsigned integers. > > +1!! -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Converting crc32 functions to use unsigned
Bob Ippolito wrote: > It seems that we should convert the crc32 functions in binascii, > zlib, etc. to deal with unsigned integers. +1!! -- Giovanni Bajo ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Converting crc32 functions to use unsigned
It seems that we should convert the crc32 functions in binascii, zlib, etc. to deal with unsigned integers. Currently it seems that 32- bit and 64-bit platforms are going to have different results for these functions. Should we do the same as the struct module, and do DeprecationWarning when the input value is < 0? Do we have a PyArg_ParseTuple format code or a converter that would be suitable for this purpose? None of the unit tests seem to exercise values where 32-bit and 64- bit platforms would have differing results, but that's easy enough to fix... -bob ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com