@@ -508,7 +508,7 @@ def unpack_binary(self, offset, length=False):
508508 return ""
509509 o = self ._offset + offset
510510 try :
511- return struct .unpack_from ("<{}s" .format (length ), self ._buf , o )[0 ]
511+ return bytes ( struct .unpack_from ("<{}s" .format (length ), self ._buf , o )[0 ])
512512 except struct .error :
513513 raise OverrunBufferException (o , len (self ._buf ))
514514
@@ -521,7 +521,7 @@ def unpack_string(self, offset, length):
521521 Throws:
522522 - `OverrunBufferException`
523523 """
524- return self .unpack_binary (offset , length )
524+ return self .unpack_binary (offset , length ). decode ( 'ascii' )
525525
526526 def unpack_wstring (self , offset , length ):
527527 """
@@ -534,11 +534,14 @@ def unpack_wstring(self, offset, length):
534534 - `UnicodeDecodeError`
535535 """
536536 try :
537- return self ._buf [self ._offset + offset :self ._offset + offset + \
538- 2 * length ]. tostring ( ).decode ("utf16" )
537+ return bytes ( self ._buf [self ._offset + offset :self ._offset + offset + \
538+ 2 * length ]).decode ("utf16" )
539539 except AttributeError : # already a 'str' ?
540- return self ._buf [self ._offset + offset :self ._offset + offset + \
541- 2 * length ].decode ("utf16" )
540+ return bytes (self ._buf [self ._offset + offset :self ._offset + offset + \
541+ 2 * length ]).decode ("utf16" )
542+ except :
543+ from IPython import embed ; embed ()
544+ import sys ; sys .exit ()
542545
543546 def unpack_dosdate (self , offset ):
544547 """
0 commit comments