summaryrefslogtreecommitdiffstatshomepage
path: root/src/build
diff options
context:
space:
mode:
author Reed <reedlove@users.noreply.github.com>2015-03-03 08:12:30 -0800
committer Reed <reedlove@users.noreply.github.com>2015-03-03 08:12:30 -0800
commit4b3a5f4f94e2e2a322badd2e686729ddedac6d27 (patch)
tree9ae80b63fff967579b5b65e7f69cceafe5d71c06 /src/build
parent0fcb2b9ecb9976d447b4bd2d31c29fface99717f (diff)
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.
Diffstat (limited to 'src/build')
-rw-r--r--src/build/file2str.py5
1 files changed, 4 insertions, 1 deletions
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(',')