From: Christian Heimes Date: Wed, 19 Mar 2008 22:42:51 +0000 (+0000) Subject: Create a signed CRC32 hash. I'm not absolutely sure it's correct. At least it fixes... X-Git-Tag: v3.0a4~107 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=453e08c3bfa334bd8e12f521e4f768abdd9997a4;p=thirdparty%2FPython%2Fcpython.git 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 --- diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index d2fd504e864a..9cd5434ad609 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -42,7 +42,7 @@ class ChecksumTestCase(unittest.TestCase): 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) diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index a9783707039a..551fd3e0a76b 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -940,7 +940,7 @@ PyZlib_crc32(PyObject *self, PyObject *args) 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); }