fixed silly bytes/string error.

This commit is contained in:
freemansw1 2016-04-18 23:01:56 -06:00
parent aae0d15bc0
commit 35f3568d24

View file

@ -152,15 +152,17 @@ class ThriftSerializationContext(object):
def deserializeMessage(self): def deserializeMessage(self):
name = self.protocol.readStructBegin() name = self.protocol.readStructBegin()
#print(name)
name = name.replace(b'_', b'.') name = name.replace(b'_', b'.')
bytes(name) name = name.decode('cp437')
print(name, name in adapters.classAdapterRegistry)
if name.isdigit(): if name.isdigit():
print("before deserialize", name)
obj = self._deserializeType(int(name)) obj = self._deserializeType(int(name))
print("Object", obj, name)
return obj return obj
elif name in adapters.classAdapterRegistry: elif name in adapters.classAdapterRegistry:
return adapters.classAdapterRegistry[name].deserialize(self) return adapters.classAdapterRegistry[name].deserialize(self)
elif name.find(b'$') > -1: elif name.find('$') > -1:
# it's an inner class, we're going to hope it's an enum, treat it special # it's an inner class, we're going to hope it's an enum, treat it special
fieldName, fieldType, fieldId = self.protocol.readFieldBegin() fieldName, fieldType, fieldId = self.protocol.readFieldBegin()
if fieldName != '__enumValue__': if fieldName != '__enumValue__':
@ -169,7 +171,7 @@ class ThriftSerializationContext(object):
self.protocol.readFieldEnd() self.protocol.readFieldEnd()
return obj return obj
else: else:
clz = dsObjTypes[bytes.decode(name)] clz = dsObjTypes[name]
obj = clz() obj = clz()
while self._deserializeField(name, obj): while self._deserializeField(name, obj):