blob: fd20cb7906b731b04d82692936a9e632edfa113f [file] [log] [blame]
Mark Slee89e2bb82007-03-01 00:20:36 +00001#
David Reissea2cba82009-03-30 21:35:00 +00002# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
Mark Slee89e2bb82007-03-01 00:20:36 +000019
Nobuaki Sukegawae841b3d2015-11-17 11:01:17 +090020from thrift.Thrift import TException, TType, TFrozenDict
Nobuaki Sukegawa7b545b52016-01-11 13:46:04 +090021from thrift.transport.TTransport import TTransportException
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +090022from ..compat import binary_to_str, str_to_binary
Mark Sleecde2b612006-09-03 21:13:07 +000023
Nobuaki Sukegawa299255a2016-01-06 14:52:50 +090024import six
25import sys
26from itertools import islice
27from six.moves import zip
28
Mark Slee92195ae2007-02-21 05:16:30 +000029
Bryan Duxbury69720412012-01-03 17:32:30 +000030class TProtocolException(TException):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090031 """Custom Protocol Exception class"""
Mark Slee92195ae2007-02-21 05:16:30 +000032
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090033 UNKNOWN = 0
34 INVALID_DATA = 1
35 NEGATIVE_SIZE = 2
36 SIZE_LIMIT = 3
37 BAD_VERSION = 4
38 NOT_IMPLEMENTED = 5
39 DEPTH_LIMIT = 6
Mark Slee92195ae2007-02-21 05:16:30 +000040
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090041 def __init__(self, type=UNKNOWN, message=None):
42 TException.__init__(self, message)
43 self.type = type
Mark Slee92195ae2007-02-21 05:16:30 +000044
Mark Sleecde2b612006-09-03 21:13:07 +000045
Nobuaki Sukegawab9c859a2015-12-21 01:10:25 +090046class TProtocolBase(object):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090047 """Base class for Thrift protocol driver."""
Mark Sleecde2b612006-09-03 21:13:07 +000048
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090049 def __init__(self, trans):
50 self.trans = trans
Nobuaki Sukegawa6525f6a2016-02-11 13:58:39 +090051 self._fast_decode = None
52 self._fast_encode = None
Mark Slee4ac459f2006-10-25 21:39:01 +000053
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090054 @staticmethod
55 def _check_length(limit, length):
56 if length < 0:
57 raise TTransportException(TTransportException.NEGATIVE_SIZE,
58 'Negative length: %d' % length)
59 if limit is not None and length > limit:
60 raise TTransportException(TTransportException.SIZE_LIMIT,
61 'Length exceeded max allowed: %d' % limit)
Nobuaki Sukegawa7b545b52016-01-11 13:46:04 +090062
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090063 def writeMessageBegin(self, name, ttype, seqid):
64 pass
Mark Sleecde2b612006-09-03 21:13:07 +000065
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090066 def writeMessageEnd(self):
67 pass
Mark Sleecde2b612006-09-03 21:13:07 +000068
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090069 def writeStructBegin(self, name):
70 pass
Mark Sleecde2b612006-09-03 21:13:07 +000071
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090072 def writeStructEnd(self):
73 pass
Mark Sleecde2b612006-09-03 21:13:07 +000074
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090075 def writeFieldBegin(self, name, ttype, fid):
76 pass
Mark Sleecde2b612006-09-03 21:13:07 +000077
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090078 def writeFieldEnd(self):
79 pass
Mark Sleecde2b612006-09-03 21:13:07 +000080
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090081 def writeFieldStop(self):
82 pass
Mark Sleecde2b612006-09-03 21:13:07 +000083
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090084 def writeMapBegin(self, ktype, vtype, size):
85 pass
Mark Sleecde2b612006-09-03 21:13:07 +000086
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090087 def writeMapEnd(self):
88 pass
Mark Sleecde2b612006-09-03 21:13:07 +000089
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090090 def writeListBegin(self, etype, size):
91 pass
Mark Sleecde2b612006-09-03 21:13:07 +000092
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090093 def writeListEnd(self):
94 pass
Mark Sleecde2b612006-09-03 21:13:07 +000095
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090096 def writeSetBegin(self, etype, size):
97 pass
Mark Sleecde2b612006-09-03 21:13:07 +000098
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090099 def writeSetEnd(self):
100 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000101
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900102 def writeBool(self, bool_val):
103 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000104
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900105 def writeByte(self, byte):
106 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000107
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900108 def writeI16(self, i16):
109 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000110
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900111 def writeI32(self, i32):
112 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000113
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900114 def writeI64(self, i64):
115 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000116
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900117 def writeDouble(self, dub):
118 pass
Mark Sleec98d0502006-09-06 02:42:25 +0000119
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900120 def writeString(self, str_val):
121 self.writeBinary(str_to_binary(str_val))
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900122
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900123 def writeBinary(self, str_val):
124 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000125
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900126 def writeUtf8(self, str_val):
127 self.writeString(str_val.encode('utf8'))
Nobuaki Sukegawa397bd512016-01-06 14:43:15 +0900128
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900129 def readMessageBegin(self):
130 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000131
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900132 def readMessageEnd(self):
133 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000134
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900135 def readStructBegin(self):
136 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000137
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900138 def readStructEnd(self):
139 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000140
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900141 def readFieldBegin(self):
142 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000143
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900144 def readFieldEnd(self):
145 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000146
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900147 def readMapBegin(self):
148 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000149
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900150 def readMapEnd(self):
151 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000152
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900153 def readListBegin(self):
154 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000155
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900156 def readListEnd(self):
157 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000158
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900159 def readSetBegin(self):
160 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000161
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900162 def readSetEnd(self):
163 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000164
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900165 def readBool(self):
166 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000167
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900168 def readByte(self):
169 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000170
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900171 def readI16(self):
172 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000173
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900174 def readI32(self):
175 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000176
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900177 def readI64(self):
178 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000179
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900180 def readDouble(self):
181 pass
Mark Sleec98d0502006-09-06 02:42:25 +0000182
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900183 def readString(self):
184 return binary_to_str(self.readBinary())
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900185
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900186 def readBinary(self):
187 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000188
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900189 def readUtf8(self):
190 return self.readString().decode('utf8')
Nobuaki Sukegawa397bd512016-01-06 14:43:15 +0900191
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900192 def skip(self, ttype):
Roger Meierad8154a2012-12-18 21:02:16 +0100193 if ttype == TType.STOP:
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900194 return
195 elif ttype == TType.BOOL:
196 self.readBool()
197 elif ttype == TType.BYTE:
198 self.readByte()
199 elif ttype == TType.I16:
200 self.readI16()
201 elif ttype == TType.I32:
202 self.readI32()
203 elif ttype == TType.I64:
204 self.readI64()
205 elif ttype == TType.DOUBLE:
206 self.readDouble()
207 elif ttype == TType.STRING:
208 self.readString()
209 elif ttype == TType.STRUCT:
210 name = self.readStructBegin()
211 while True:
212 (name, ttype, id) = self.readFieldBegin()
213 if ttype == TType.STOP:
214 break
215 self.skip(ttype)
216 self.readFieldEnd()
217 self.readStructEnd()
218 elif ttype == TType.MAP:
219 (ktype, vtype, size) = self.readMapBegin()
220 for i in range(size):
221 self.skip(ktype)
222 self.skip(vtype)
223 self.readMapEnd()
224 elif ttype == TType.SET:
225 (etype, size) = self.readSetBegin()
226 for i in range(size):
227 self.skip(etype)
228 self.readSetEnd()
229 elif ttype == TType.LIST:
230 (etype, size) = self.readListBegin()
231 for i in range(size):
232 self.skip(etype)
233 self.readListEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000234
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900235 # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name )
236 _TTYPE_HANDLERS = (
237 (None, None, False), # 0 TType.STOP
238 (None, None, False), # 1 TType.VOID # TODO: handle void?
239 ('readBool', 'writeBool', False), # 2 TType.BOOL
240 ('readByte', 'writeByte', False), # 3 TType.BYTE and I08
241 ('readDouble', 'writeDouble', False), # 4 TType.DOUBLE
242 (None, None, False), # 5 undefined
243 ('readI16', 'writeI16', False), # 6 TType.I16
244 (None, None, False), # 7 undefined
245 ('readI32', 'writeI32', False), # 8 TType.I32
246 (None, None, False), # 9 undefined
247 ('readI64', 'writeI64', False), # 10 TType.I64
248 ('readString', 'writeString', False), # 11 TType.STRING and UTF7
249 ('readContainerStruct', 'writeContainerStruct', True), # 12 *.STRUCT
250 ('readContainerMap', 'writeContainerMap', True), # 13 TType.MAP
251 ('readContainerSet', 'writeContainerSet', True), # 14 TType.SET
252 ('readContainerList', 'writeContainerList', True), # 15 TType.LIST
253 (None, None, False), # 16 TType.UTF8 # TODO: handle utf8 types?
254 (None, None, False) # 17 TType.UTF16 # TODO: handle utf16 types?
255 )
Roger Meierf4eec7a2011-09-11 18:16:21 +0000256
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900257 def _ttype_handlers(self, ttype, spec):
258 if spec == 'BINARY':
259 if ttype != TType.STRING:
260 raise TProtocolException(type=TProtocolException.INVALID_DATA,
261 message='Invalid binary field type %d' % ttype)
262 return ('readBinary', 'writeBinary', False)
263 if sys.version_info[0] == 2 and spec == 'UTF8':
264 if ttype != TType.STRING:
265 raise TProtocolException(type=TProtocolException.INVALID_DATA,
266 message='Invalid string field type %d' % ttype)
267 return ('readUtf8', 'writeUtf8', False)
268 return self._TTYPE_HANDLERS[ttype] if ttype < len(self._TTYPE_HANDLERS) else (None, None, False)
Nobuaki Sukegawa299255a2016-01-06 14:52:50 +0900269
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900270 def _read_by_ttype(self, ttype, spec, espec):
Elvis Pranskevichus2d1fe882017-05-23 11:36:23 -0400271 reader_name, _, is_container = self._ttype_handlers(ttype, espec)
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900272 if reader_name is None:
273 raise TProtocolException(type=TProtocolException.INVALID_DATA,
274 message='Invalid type %d' % (ttype))
275 reader_func = getattr(self, reader_name)
276 read = (lambda: reader_func(espec)) if is_container else reader_func
277 while True:
278 yield read()
Nobuaki Sukegawabc7e4802015-11-14 19:23:27 +0900279
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900280 def readFieldByTType(self, ttype, spec):
Nobuaki Sukegawa6525f6a2016-02-11 13:58:39 +0900281 return next(self._read_by_ttype(ttype, spec, spec))
Roger Meierf4eec7a2011-09-11 18:16:21 +0000282
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900283 def readContainerList(self, spec):
284 ttype, tspec, is_immutable = spec
285 (list_type, list_len) = self.readListBegin()
286 # TODO: compare types we just decoded with thrift_spec
287 elems = islice(self._read_by_ttype(ttype, spec, tspec), list_len)
288 results = (tuple if is_immutable else list)(elems)
289 self.readListEnd()
290 return results
Roger Meierf4eec7a2011-09-11 18:16:21 +0000291
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900292 def readContainerSet(self, spec):
293 ttype, tspec, is_immutable = spec
294 (set_type, set_len) = self.readSetBegin()
295 # TODO: compare types we just decoded with thrift_spec
296 elems = islice(self._read_by_ttype(ttype, spec, tspec), set_len)
297 results = (frozenset if is_immutable else set)(elems)
298 self.readSetEnd()
299 return results
Roger Meierf4eec7a2011-09-11 18:16:21 +0000300
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900301 def readContainerStruct(self, spec):
302 (obj_class, obj_spec) = spec
303 obj = obj_class()
304 obj.read(self)
305 return obj
Bryan Duxbury69720412012-01-03 17:32:30 +0000306
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900307 def readContainerMap(self, spec):
308 ktype, kspec, vtype, vspec, is_immutable = spec
309 (map_ktype, map_vtype, map_len) = self.readMapBegin()
310 # TODO: compare types we just decoded with thrift_spec and
311 # abort/skip if types disagree
312 keys = self._read_by_ttype(ktype, spec, kspec)
313 vals = self._read_by_ttype(vtype, spec, vspec)
314 keyvals = islice(zip(keys, vals), map_len)
315 results = (TFrozenDict if is_immutable else dict)(keyvals)
316 self.readMapEnd()
317 return results
Roger Meierf4eec7a2011-09-11 18:16:21 +0000318
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900319 def readStruct(self, obj, thrift_spec, is_immutable=False):
320 if is_immutable:
321 fields = {}
322 self.readStructBegin()
323 while True:
324 (fname, ftype, fid) = self.readFieldBegin()
325 if ftype == TType.STOP:
326 break
327 try:
328 field = thrift_spec[fid]
329 except IndexError:
330 self.skip(ftype)
331 else:
332 if field is not None and ftype == field[1]:
333 fname = field[2]
334 fspec = field[3]
335 val = self.readFieldByTType(ftype, fspec)
336 if is_immutable:
337 fields[fname] = val
338 else:
339 setattr(obj, fname, val)
340 else:
341 self.skip(ftype)
342 self.readFieldEnd()
343 self.readStructEnd()
344 if is_immutable:
345 return obj(**fields)
Roger Meierf4eec7a2011-09-11 18:16:21 +0000346
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900347 def writeContainerStruct(self, val, spec):
348 val.write(self)
Roger Meierf4eec7a2011-09-11 18:16:21 +0000349
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900350 def writeContainerList(self, val, spec):
351 ttype, tspec, _ = spec
352 self.writeListBegin(ttype, len(val))
353 for _ in self._write_by_ttype(ttype, val, spec, tspec):
354 pass
355 self.writeListEnd()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000356
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900357 def writeContainerSet(self, val, spec):
358 ttype, tspec, _ = spec
359 self.writeSetBegin(ttype, len(val))
360 for _ in self._write_by_ttype(ttype, val, spec, tspec):
361 pass
362 self.writeSetEnd()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000363
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900364 def writeContainerMap(self, val, spec):
365 ktype, kspec, vtype, vspec, _ = spec
366 self.writeMapBegin(ktype, vtype, len(val))
367 for _ in zip(self._write_by_ttype(ktype, six.iterkeys(val), spec, kspec),
368 self._write_by_ttype(vtype, six.itervalues(val), spec, vspec)):
369 pass
370 self.writeMapEnd()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000371
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900372 def writeStruct(self, obj, thrift_spec):
373 self.writeStructBegin(obj.__class__.__name__)
374 for field in thrift_spec:
375 if field is None:
376 continue
377 fname = field[2]
378 val = getattr(obj, fname)
379 if val is None:
380 # skip writing out unset fields
381 continue
382 fid = field[0]
383 ftype = field[1]
384 fspec = field[3]
385 self.writeFieldBegin(fname, ftype, fid)
386 self.writeFieldByTType(ftype, val, fspec)
387 self.writeFieldEnd()
388 self.writeFieldStop()
389 self.writeStructEnd()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000390
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900391 def _write_by_ttype(self, ttype, vals, spec, espec):
Elvis Pranskevichus2d1fe882017-05-23 11:36:23 -0400392 _, writer_name, is_container = self._ttype_handlers(ttype, espec)
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900393 writer_func = getattr(self, writer_name)
394 write = (lambda v: writer_func(v, espec)) if is_container else writer_func
395 for v in vals:
396 yield write(v)
Nobuaki Sukegawa299255a2016-01-06 14:52:50 +0900397
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900398 def writeFieldByTType(self, ttype, val, spec):
Nobuaki Sukegawa6525f6a2016-02-11 13:58:39 +0900399 next(self._write_by_ttype(ttype, [val], spec, spec))
Roger Meierf4eec7a2011-09-11 18:16:21 +0000400
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900401
Konrad Grochowski93fea152014-10-02 16:29:14 +0200402def checkIntegerLimits(i, bits):
Konrad Grochowski07218672014-10-09 12:18:25 +0200403 if bits == 8 and (i < -128 or i > 127):
Konrad Grochowski93fea152014-10-02 16:29:14 +0200404 raise TProtocolException(TProtocolException.INVALID_DATA,
Konrad Grochowskid5f3be52014-10-08 15:32:21 +0200405 "i8 requires -128 <= number <= 127")
Konrad Grochowski07218672014-10-09 12:18:25 +0200406 elif bits == 16 and (i < -32768 or i > 32767):
Konrad Grochowskid5f3be52014-10-08 15:32:21 +0200407 raise TProtocolException(TProtocolException.INVALID_DATA,
408 "i16 requires -32768 <= number <= 32767")
Konrad Grochowski07218672014-10-09 12:18:25 +0200409 elif bits == 32 and (i < -2147483648 or i > 2147483647):
Konrad Grochowskid5f3be52014-10-08 15:32:21 +0200410 raise TProtocolException(TProtocolException.INVALID_DATA,
411 "i32 requires -2147483648 <= number <= 2147483647")
Konrad Grochowski07218672014-10-09 12:18:25 +0200412 elif bits == 64 and (i < -9223372036854775808 or i > 9223372036854775807):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900413 raise TProtocolException(TProtocolException.INVALID_DATA,
414 "i64 requires -9223372036854775808 <= number <= 9223372036854775807")
Bryan Duxbury69720412012-01-03 17:32:30 +0000415
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900416
Nobuaki Sukegawab9c859a2015-12-21 01:10:25 +0900417class TProtocolFactory(object):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900418 def getProtocol(self, trans):
419 pass