Previous 199869 Revisions Next

r36218 Tuesday 3rd March, 2015 at 16:12:30 UTC by Reed
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.
[src/build]file2str.py

trunk/src/build/file2str.py
r244729r244730
4040            chunk = src.read(16)
4141            if chunk:
4242                for b in chunk:
43                    dst.write('0x%02x' % ord(b))
43                    # For Python 2.x compatibility.
44                    if isinstance(b, str):
45                        b = ord(b)
46                    dst.write('0x%02x' % b)
4447                    offs = offs + 1
4548                    if offs != byteCount:
4649                        dst.write(',')


Previous 199869 Revisions Next


© 1997-2024 The MAME Team