Commit 3b4362db authored by oroulet's avatar oroulet

remove debug line and reorder class definition

parent 6581f2c5
......@@ -45,6 +45,22 @@ class _DateTime(object):
return ua.win_epoch_to_datetime(epch)
class _Bytes(object):
@staticmethod
def pack(data):
if data is None:
return Primitives.Int32.pack(-1)
length = len(data)
return Primitives.Int32.pack(length) + data
@staticmethod
def unpack(data):
length = Primitives.Int32.unpack(data)
if length == -1:
return None
return data.read(length)
class _String(object):
@staticmethod
def pack(string):
......@@ -61,7 +77,7 @@ class _String(object):
def unpack(data):
b = _Bytes.unpack(data)
if sys.version_info.major < 3:
# return unicode(b)
# return unicode(b) #might be correct for python2 but would complicate tests for python3
return b
else:
if b is None:
......@@ -69,24 +85,6 @@ class _String(object):
return b.decode("utf-8")
class _Bytes(object):
@staticmethod
def pack(data):
if data is None:
return Primitives.Int32.pack(-1)
length = len(data)
if not isinstance(data, bytes):
print("BYTES EXPECTED", type(Primitives.Int32.pack(length)), type(data), data)
return Primitives.Int32.pack(length) + data
@staticmethod
def unpack(data):
length = Primitives.Int32.unpack(data)
if length == -1:
return None
return data.read(length)
class _Null(object):
@staticmethod
def pack(data):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment