mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
Fix 32-bit Python encoding integer issue
Summary: Python on 32-bit platforms 2.4+ wants to keep hexconstants positive, therefore converting 0x800000000 to a (long) type to keep that. This causes issues when performing comparison with a signed negative integer. Reviewed By: dreiss Test Plan: Python on 32 bit 2.4+ system making Thrift calls git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665287 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
780e4ecac9
commit
9b36ef3575
@ -13,8 +13,17 @@ class TBinaryProtocol(TProtocolBase):
|
||||
|
||||
"""Binary implementation of the Thrift protocol driver."""
|
||||
|
||||
VERSION_MASK = 0xffff0000
|
||||
VERSION_1 = 0x80010000
|
||||
# NastyHaxx. Python 2.4+ on 32-bit machines forces hex constants to be
|
||||
# positive, converting this into a long. If we hardcode the int value
|
||||
# instead it'll stay in 32 bit-land.
|
||||
|
||||
# VERSION_MASK = 0xffff0000
|
||||
VERSION_MASK = -65536
|
||||
|
||||
# VERSION_1 = 0x80010000
|
||||
VERSION_1 = -2147418112
|
||||
|
||||
TYPE_MASK = 0x000000ff
|
||||
|
||||
def __init__(self, trans, strictRead=False, strictWrite=True):
|
||||
TProtocolBase.__init__(self, trans)
|
||||
@ -108,7 +117,7 @@ class TBinaryProtocol(TProtocolBase):
|
||||
version = sz & TBinaryProtocol.VERSION_MASK
|
||||
if version != TBinaryProtocol.VERSION_1:
|
||||
raise TProtocolException(TProtocolException.BAD_VERSION, 'Bad version in readMessageBegin: %d' % (sz))
|
||||
type = version & 0x000000ff
|
||||
type = sz & TBinaryProtocol.TYPE_MASK
|
||||
name = self.readString()
|
||||
seqid = self.readI32()
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user