From d38c910e24f1cda0583eccc19a816d3bee36f956 Mon Sep 17 00:00:00 2001 From: freemansw1 Date: Thu, 21 Apr 2016 12:08:33 -0600 Subject: [PATCH] Fixing more weird python 2/3 string issues --- awips/ThriftClient.py | 1 + dynamicserialize/ThriftSerializationContext.py | 6 +++--- .../uf/common/serialization/SerializableExceptionWrapper.py | 4 ++-- dynamicserialize/dstypes/java/lang/StackTraceElement.py | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/awips/ThriftClient.py b/awips/ThriftClient.py index c2908a1..87f584d 100644 --- a/awips/ThriftClient.py +++ b/awips/ThriftClient.py @@ -79,6 +79,7 @@ class ThriftClient: rval = self.__dsm.deserializeBytes(response.read()) self.__httpConn.close() + # let's verify we have an instance of ServerErrorResponse # IF we do, through an exception up to the caller along # with the original Java stack trace diff --git a/dynamicserialize/ThriftSerializationContext.py b/dynamicserialize/ThriftSerializationContext.py index d7de565..a2992c4 100644 --- a/dynamicserialize/ThriftSerializationContext.py +++ b/dynamicserialize/ThriftSerializationContext.py @@ -152,8 +152,8 @@ class ThriftSerializationContext(object): def deserializeMessage(self): name = self.protocol.readStructBegin() - name = name.replace(b'_', b'.') name = name.decode('cp437') + name = name.replace('_', '.') if name.isdigit(): obj = self._deserializeType(int(name)) return obj @@ -162,8 +162,8 @@ class ThriftSerializationContext(object): elif name.find('$') > -1: # it's an inner class, we're going to hope it's an enum, treat it special fieldName, fieldType, fieldId = self.protocol.readFieldBegin() - if fieldName != b'__enumValue__': - raise dynamiceserialize.SerializationException("Expected to find enum payload. Found: " + fieldName) + if fieldName != '__enumValue__': + raise dynamiceserialize.SerializationException(b"Expected to find enum payload. Found: " + fieldName) obj = self.protocol.readString() self.protocol.readFieldEnd() return obj diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/serialization/SerializableExceptionWrapper.py b/dynamicserialize/dstypes/com/raytheon/uf/common/serialization/SerializableExceptionWrapper.py index 1ebdbff..d26712e 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/serialization/SerializableExceptionWrapper.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/serialization/SerializableExceptionWrapper.py @@ -39,8 +39,8 @@ class SerializableExceptionWrapper(object): def __repr__(self): if not self.message: - self.message = '' - retVal = "" + self.exceptionClass + " exception thrown: " + self.message + "\n" + self.message = b'' + retVal = b"" + self.exceptionClass + b" exception thrown: " + self.message + b"\n" for element in self.stackTrace: retVal += "\tat " + str(element) + "\n" diff --git a/dynamicserialize/dstypes/java/lang/StackTraceElement.py b/dynamicserialize/dstypes/java/lang/StackTraceElement.py index 26236fb..352d2eb 100644 --- a/dynamicserialize/dstypes/java/lang/StackTraceElement.py +++ b/dynamicserialize/dstypes/java/lang/StackTraceElement.py @@ -59,13 +59,13 @@ class StackTraceElement(object): return self.__repr__() def __repr__(self): - msg = self.declaringClass + "." + self.methodName + msg = self.declaringClass.decode('cp437') + "." + self.methodName.decode('cp437') if self.isNativeMethod(): msg += "(Native Method)" elif self.fileName is not None and self.lineNumber >= 0: - msg += "(" + self.fileName + ":" + str(self.lineNumber) + ")" + msg += "(" + self.fileName.decode('cp437') + ":" + str(self.lineNumber) + ")" elif self.fileName is not None: - msg += "(" + self.fileName + ")" + msg += "(" + self.fileName.decode('cp437') + ")" else: msg += "(Unknown Source)" return msg