Skip to content

Commit 11419bf

Browse files
committed
Fixed the V1 parsing after use of constants
The parsing and writing done in the V1 package now works as in the previous javaobj version (0.3.0) Fixes #32
1 parent 2689fae commit 11419bf

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

javaobj/v1/core.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def do_classdesc(self, parent=None, ident=0):
437437
)
438438
else:
439439
# Convert the TypeCode to its char value
440-
field_type = chr(base_field_type.value)
440+
field_type = JavaString(str(chr(base_field_type.value)))
441441

442442
log_debug(
443443
"< FieldName: 0x{0:X} Name:{1} Type:{2} ID:{3}".format(
@@ -848,7 +848,10 @@ def _read_value(self, raw_field_type, ident, name=""):
848848
else:
849849
raise RuntimeError("Unknown typecode: {0}".format(field_type))
850850

851-
log_debug("* {0} {1}: {2}".format(field_type, name, repr(res)), ident)
851+
log_debug(
852+
"* {0} {1}: {2}".format(chr(field_type.value), name, repr(res)),
853+
ident,
854+
)
852855
return res
853856

854857
def _convert_char_to_type(self, type_char):
@@ -1248,7 +1251,10 @@ def write_classdesc(self, obj, parent=None):
12481251
">B", 1, (self._convert_type_to_char(field_type),)
12491252
)
12501253
self._writeString(field_name)
1251-
if field_type[0] in (TypeCode.TYPE_OBJECT, TypeCode.TYPE_ARRAY):
1254+
if ord(field_type[0]) in (
1255+
TypeCode.TYPE_OBJECT,
1256+
TypeCode.TYPE_ARRAY,
1257+
):
12521258
try:
12531259
idx = self.references.index(field_type)
12541260
except ValueError:
@@ -1325,7 +1331,7 @@ def write_array(self, obj):
13251331
for a in obj:
13261332
self.write_array(a)
13271333
else:
1328-
log_debug("Write array of type %s" % type_code)
1334+
log_debug("Write array of type {0}".format(chr(type_code.value)))
13291335
for v in obj:
13301336
log_debug("Writing: %s" % v)
13311337
self._write_value(type_code, v)

0 commit comments

Comments
 (0)