@@ -73,7 +73,7 @@ def print_info(self):
7373
7474#*****************************************************************************
7575#
76- # Copyright (c) 2013 Andrea Bonomi <andrea.bonomi@gmail.com>
76+ # Copyright (c) 2013-2017 Andrea Bonomi <andrea.bonomi@gmail.com>
7777#
7878# Published under the terms of the MIT license.
7979#
@@ -99,7 +99,7 @@ def print_info(self):
9999
100100__author__ = 'Andrea Bonomi <andrea.bonomi@gmail.com>'
101101__license__ = 'MIT'
102- __version__ = '1.2 '
102+ __version__ = '1.3 '
103103__date__ = '15 August 2013'
104104
105105import re
@@ -270,8 +270,13 @@ def size(cls):
270270
271271if sys .version_info < (2 , 6 ):
272272 EMPTY_BYTES_STRING = str ()
273+ CHAR_ZERO = '\0 '
274+ if sys .version_info < (3 , 0 ):
275+ EMPTY_BYTES_STRING = bytes ()
276+ CHAR_ZERO = bytes ('\0 ' )
273277else :
274278 EMPTY_BYTES_STRING = bytes ()
279+ CHAR_ZERO = bytes ('\0 ' , 'ascii' )
275280
276281class CStruct (_CStructParent ):
277282 """
@@ -293,7 +298,7 @@ def __init__(self, string=None, **kargs):
293298 if string is not None :
294299 self .unpack (string )
295300 else :
296- self .unpack (b'0x00' * self .__size__ )
301+ self .unpack (CHAR_ZERO * self .__size__ )
297302 for key , value in kargs .items ():
298303 setattr (self , key , value )
299304
0 commit comments