Open
Conversation
# Conflicts: # frontera/contrib/messagebus/kafkabus.py
38ff145 to
63e108d
Compare
|
Hi @sibiryakov, is there any reason this was not merged yet? I'm dealing with a case where this should fix my problem. Thanks! |
Prometheus3375
suggested changes
Jul 2, 2020
Comment on lines
+11
to
+12
| def random_bytes(): | ||
| return pack("L", randint(0, MAXSIZE)) |
There was a problem hiding this comment.
You have an error here. Look at six sources
if PY3:
string_types = str,
integer_types = int,
class_types = type,
text_type = str
binary_type = bytes
MAXSIZE = sys.maxsize
else:
string_types = basestring,
integer_types = (int, long)
class_types = (type, types.ClassType)
text_type = unicode
binary_type = str
if sys.platform.startswith("java"):
# Jython always uses 32 bits.
MAXSIZE = int((1 << 31) - 1)
else:
# It's possible to have sizeof(long) != sizeof(Py_ssize_t).
class X(object):
def __len__(self):
return 1 << 31
try:
len(X())
except OverflowError:
# 32-bit
MAXSIZE = int((1 << 31) - 1)
else:
# 64-bit
MAXSIZE = int((1 << 63) - 1)
del Xsys.maxsize is 64 bit in Python 3 (9223372036854775807). As you can see from six, MAXSIZE can be 64 bit both for Python 2 and 3. According to documentation (Python 2 and 3), packing symbol L is used to pack 32 bit uint. You should change it to Q which is used to pack 64 bit uint.
Suggested change
| def random_bytes(): | |
| return pack("L", randint(0, MAXSIZE)) | |
| def random_bytes(): | |
| return pack('Q', randint(0, MAXSIZE)) |
There was a problem hiding this comment.
Another option is to change MAXSIZE variable to literal 4_294_967_295.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allows to transfer messages larger than Kafka maximum message size.