Skip to content

Commit a6536b6

Browse files
committed
default value fix
1 parent a8ca6d9 commit a6536b6

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

cstruct/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

105105
import re
@@ -270,8 +270,13 @@ def size(cls):
270270

271271
if 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')
273277
else:
274278
EMPTY_BYTES_STRING = bytes()
279+
CHAR_ZERO = bytes('\0', 'ascii')
275280

276281
class 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

Comments
 (0)