Fix chunk() output when given zero-length data

This commit is contained in:
Jack Grigg 2018-08-23 14:25:41 +01:00
parent 60db123206
commit a44f9f6c90
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
1 changed files with 2 additions and 1 deletions

View File

@ -8,7 +8,8 @@ import json
def chunk(h):
hstr = str(h, 'utf-8')
return '0x' + ', 0x'.join([hstr[i:i+2] for i in range(0, len(hstr), 2)])
hstr = ', 0x'.join([hstr[i:i+2] for i in range(0, len(hstr), 2)])
return '0x' + hstr if hstr else ''
class Some(object):
def __init__(self, thing):