This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2009年01月10日 02:57 by beazley, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (10) | |||
|---|---|---|---|
| msg79524 - (view) | Author: David M. Beazley (beazley) | Date: 2009年01月10日 02:57 | |
The result of binascii.crc32() is different on the same input in Python
2.6/3.0. For example:
Python 2.6:
>>> binascii.crc32('Hello')
-137262718
Python 3.0:
>>> binascii.crc32(b'Hello')
4157704578
|
|||
| msg79526 - (view) | Author: Gregory P. Smith (gregory.p.smith) * (Python committer) | Date: 2009年01月10日 03:06 | |
When treated as an unsigned 32bit value those are identical. Guido prefers to keep Python 2.x always having signed values for the scattered crc functions. We changed it for 3.0 because it makes more sense given that python these days no real fixed-bits numeric type. See also http://bugs.python.org/issue1202 I posted a workaround in there. Always & the crc32() or adler32() return value with 0xFFFFFFFF. |
|||
| msg79529 - (view) | Author: David M. Beazley (beazley) | Date: 2009年01月10日 03:16 | |
Can someone PLEASE make sure this gets documented someplace. |
|||
| msg79534 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2009年01月10日 09:24 | |
What is "this" that you want to get documented? Can you propose a specific wording? |
|||
| msg79542 - (view) | Author: David M. Beazley (beazley) | Date: 2009年01月10日 12:12 | |
Placing a note in the standard library documentation would be a start. Just say in Python 3.0 it always returns the result as an unsigned integer whereas in Python 2.6 a 32-bit signed integer is returned. Although the numerical value may differ between versions, the underlying bits are the same. Use crc32() & 0xffffffff to get a consistent value (already noted). Note: Not everyone uses checksums in only a packed-binary format. Having the integer value just change across Python versions like that is a real subtle compatibility problem to point out. |
|||
| msg79591 - (view) | Author: Gregory P. Smith (gregory.p.smith) * (Python committer) | Date: 2009年01月11日 07:22 | |
Agreed, we failed to mention the behavior change in the docs. I'll take care of that. (if its mentioned at all, its mentioned in a note buried in the Misc/NEWS file somewhere) 2to3 could presumably be made to notice crc32 and adler32 calls and warn about this problem. I wouldn't have 2to3 add code to re-sign the return value by default as not everything needs that but it is worthy of a warning. |
|||
| msg79606 - (view) | Author: Gregory P. Smith (gregory.p.smith) * (Python committer) | Date: 2009年01月11日 18:00 | |
binascii and zlib documentation updated in trunk r68535. I'll close the issue after I've merged it into release26-maint, release30-maint and py3k. Any objections to the wording? http://svn.python.org/view/python/trunk/Doc/library/binascii.rst? rev=68535&view=diff&r1=68535&r2=68534&p1=python/trunk/Doc/library/binasc ii.rst&p2=/python/trunk/Doc/library/binascii.rst |
|||
| msg79715 - (view) | Author: Gabriel Genellina (ggenellina) | Date: 2009年01月13日 02:21 | |
Just a small note on the wording: "will have" and "will always be" look too strong to me. I'd just use is, are. Present tense seems to be --in general-- the preferred style in the documentation. |
|||
| msg80893 - (view) | Author: Gregory P. Smith (gregory.p.smith) * (Python committer) | Date: 2009年02月01日 00:16 | |
wording updated in r69159, thanks. |
|||
| msg80894 - (view) | Author: Gregory P. Smith (gregory.p.smith) * (Python committer) | Date: 2009年02月01日 00:31 | |
and r69161, r69160, r69162, r69163, r69164. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:44 | admin | set | github: 49153 |
| 2009年02月01日 00:31:24 | gregory.p.smith | set | status: open -> closed resolution: fixed messages: + msg80894 versions: + Python 3.1, Python 2.7 |
| 2009年02月01日 00:16:22 | gregory.p.smith | set | messages: + msg80893 |
| 2009年01月13日 02:21:27 | ggenellina | set | nosy:
+ ggenellina messages: + msg79715 |
| 2009年01月11日 18:00:22 | gregory.p.smith | set | messages: + msg79606 |
| 2009年01月11日 07:22:48 | gregory.p.smith | set | status: closed -> open title: binascii.crc32() -> binascii.crc32() - document signed vs unsigned results messages: + msg79591 priority: normal assignee: gregory.p.smith components: + Documentation resolution: duplicate -> (no value) |
| 2009年01月10日 12:12:02 | beazley | set | messages: + msg79542 |
| 2009年01月10日 09:24:27 | loewis | set | nosy:
+ loewis messages: + msg79534 |
| 2009年01月10日 03:16:22 | beazley | set | messages: + msg79529 |
| 2009年01月10日 03:06:59 | gregory.p.smith | set | status: open -> closed resolution: duplicate dependencies: + zlib.crc32() and adler32() return value messages: + msg79526 nosy: + gregory.p.smith |
| 2009年01月10日 02:57:57 | beazley | create | |