mirror of
https://github.com/holub/mame
synced 2025-05-30 17:41:47 +03:00
Update file2str.py
Sorry about my previous recommendation that broke Python 2. It's been so long that I forgot that Python 2 open 'rb' returns a string representation of bytes. The above code will properly handle type conversion for Python 2.
This commit is contained in:
parent
0fcb2b9ecb
commit
4b3a5f4f94
@ -40,7 +40,10 @@ try:
|
||||
chunk = src.read(16)
|
||||
if chunk:
|
||||
for b in chunk:
|
||||
dst.write('0x%02x' % ord(b))
|
||||
# For Python 2.x compatibility.
|
||||
if isinstance(b, str):
|
||||
b = ord(b)
|
||||
dst.write('0x%02x' % b)
|
||||
offs = offs + 1
|
||||
if offs != byteCount:
|
||||
dst.write(',')
|
||||
|
Loading…
Reference in New Issue
Block a user