[Python-3000-checkins] r61648 - in python/branches/py3k: Lib/test/test_zlib.py Modules/zlibmodule.c

christian.heimes python-3000-checkins at python.org
Wed Mar 19 23:42:52 CET 2008


Author: christian.heimes
Date: Wed Mar 19 23:42:51 2008
New Revision: 61648

Modified:
   python/branches/py3k/Lib/test/test_zlib.py
   python/branches/py3k/Modules/zlibmodule.c
Log:
Create a signed CRC32 hash. I'm not absolutely sure it's correct. At least it fixes the unit tests and doesn't create a different hash than Python 2.x

Modified: python/branches/py3k/Lib/test/test_zlib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_zlib.py	(original)
+++ python/branches/py3k/Lib/test/test_zlib.py	Wed Mar 19 23:42:51 2008
@@ -42,7 +42,7 @@
     def test_crc32_adler32_unsigned(self):
         foo = 'abcdefghijklmnop'
         # explicitly test signed behavior
-        self.assertEqual(zlib.crc32(foo), 2486878355)
+        self.assertEqual(zlib.crc32(foo), -1808088941)
         self.assertEqual(zlib.crc32('spam'), 1138425661)
         self.assertEqual(zlib.adler32(foo+foo), 3573550353)
         self.assertEqual(zlib.adler32('spam'), 72286642)

Modified: python/branches/py3k/Modules/zlibmodule.c
==============================================================================
--- python/branches/py3k/Modules/zlibmodule.c	(original)
+++ python/branches/py3k/Modules/zlibmodule.c	Wed Mar 19 23:42:51 2008
@@ -940,7 +940,7 @@
     if (!PyArg_ParseTuple(args, "s#|k:crc32", &buf, &len, &crc32val))
 	return NULL;
     crc32val = crc32(crc32val, buf, len);
-    return PyLong_FromUnsignedLong(crc32val & 0xffffffff);
+    return PyLong_FromLong(crc32val & 0xffffffff);
 }
 
 


More information about the Python-3000-checkins mailing list