Hello,
thanks for your nice project which helped my a lot reading raw data.
I have one improvement request regarding the _read_field_value function.
For me it was necessary to add at line 628 the check
if sub_type_code == TermincalCode.TC_NULL:
return None
because there where some null entries in the file.
def _read_field_value(self, field_type):
# type: (FieldType) -> Any
"""
Reads the value of an instance field
"""
if field_type == FieldType.BYTE:
return self.__reader.read_byte()
if field_type == FieldType.CHAR:
return self.__reader.read_char()
if field_type == FieldType.DOUBLE:
return self.__reader.read_double()
if field_type == FieldType.FLOAT:
return self.__reader.read_float()
if field_type == FieldType.INTEGER:
return self.__reader.read_int()
if field_type == FieldType.LONG:
return self.__reader.read_long()
if field_type == FieldType.SHORT:
return self.__reader.read_short()
if field_type == FieldType.BOOLEAN:
return self.__reader.read_bool()
if field_type in (FieldType.OBJECT, FieldType.ARRAY):
sub_type_code = self.__reader.read_byte()
if field_type == FieldType.ARRAY:
**if sub_type_code == TerminalCode.TC_NULL:
return None**
if sub_type_code == TerminalCode.TC_REFERENCE:
return self._do_classdesc(sub_type_code)
if sub_type_code != TerminalCode.TC_ARRAY:
raise ValueError(
"Array type listed, but type code != TC_ARRAY"
)
content = self._read_content(sub_type_code, False)
if content is not None and content.is_exception:
raise ExceptionRead(content)
return content
Reactions are currently unavailable
Hello,
thanks for your nice project which helped my a lot reading raw data.
I have one improvement request regarding the _read_field_value function.
For me it was necessary to add at line 628 the check
if sub_type_code == TermincalCode.TC_NULL: return Nonebecause there where some null entries in the file.
def _read_field_value(self, field_type): # type: (FieldType) -> Any """ Reads the value of an instance field """ if field_type == FieldType.BYTE: return self.__reader.read_byte() if field_type == FieldType.CHAR: return self.__reader.read_char() if field_type == FieldType.DOUBLE: return self.__reader.read_double() if field_type == FieldType.FLOAT: return self.__reader.read_float() if field_type == FieldType.INTEGER: return self.__reader.read_int() if field_type == FieldType.LONG: return self.__reader.read_long() if field_type == FieldType.SHORT: return self.__reader.read_short() if field_type == FieldType.BOOLEAN: return self.__reader.read_bool() if field_type in (FieldType.OBJECT, FieldType.ARRAY): sub_type_code = self.__reader.read_byte() if field_type == FieldType.ARRAY: **if sub_type_code == TerminalCode.TC_NULL: return None** if sub_type_code == TerminalCode.TC_REFERENCE: return self._do_classdesc(sub_type_code) if sub_type_code != TerminalCode.TC_ARRAY: raise ValueError( "Array type listed, but type code != TC_ARRAY" ) content = self._read_content(sub_type_code, False) if content is not None and content.is_exception: raise ExceptionRead(content) return content