From 4b3a5f4f94e2e2a322badd2e686729ddedac6d27 Mon Sep 17 00:00:00 2001 From: Reed Date: Tue, 3 Mar 2015 08:12:30 -0800 Subject: 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/build/file2str.py b/src/build/file2str.py index 18045560226..4be154a1ead 100644 --- a/src/build/file2str.py +++ b/src/build/file2str.py @@ -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(',') -- cgit v1.2.3