diff options
author | Mark Roberts <wizzat@fb.com> | 2014-09-03 19:21:35 -0700 |
---|---|---|
committer | Mark Roberts <wizzat@fb.com> | 2014-09-03 19:21:35 -0700 |
commit | be23042ecd9ab330886745ccc9ec9e3a0039836f (patch) | |
tree | 1a1fb969c4f5ace0441ba092e4c86b5ea6b53783 /kafka/util.py | |
parent | 84a7add6da7d1e319c03e0f9758e15e8680c6c69 (diff) | |
download | kafka-python-be23042ecd9ab330886745ccc9ec9e3a0039836f.tar.gz |
Update kafka.util.crc32 to unsigned everywhere
Diffstat (limited to 'kafka/util.py')
-rw-r--r-- | kafka/util.py | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/kafka/util.py b/kafka/util.py index a4a0174..1e03cf1 100644 --- a/kafka/util.py +++ b/kafka/util.py @@ -1,7 +1,7 @@ +import binascii import collections import struct import sys -import zlib from threading import Thread, Event import six @@ -10,16 +10,7 @@ from kafka.common import BufferUnderflowError def crc32(data): - """ - Python 2 returns a value in the range [-2**31, 2**31-1]. - Python 3 returns a value in the range [0, 2**32-1]. - - We want a consistent behavior so let's use python2's. - """ - crc = zlib.crc32(data) - if six.PY3 and crc > 2**31: - crc -= 2 ** 32 - return crc + return binascii.crc32(data) & 0xffffffff def write_int_string(s): |