From f4d081953b775940f5a517a5810c2c7bbe6f2556 Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Fri, 17 Jan 2014 04:44:58 +0000 Subject: [PATCH 1/2] OleFileIO: Port to Python 3 --- PIL/OleFileIO.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PIL/OleFileIO.py b/PIL/OleFileIO.py index b7c984169..93a00e875 100644 --- a/PIL/OleFileIO.py +++ b/PIL/OleFileIO.py @@ -368,7 +368,7 @@ class OleFileIO: self.root.dump() def _clsid(self, clsid): - if clsid == "\0" * len(clsid): + if not clsid.strip(b"\0"): return "" return (("%08X-%04X-%04X-%02X%02X-" + "%02X" * 6) % ((i32(clsid, 0), i16(clsid, 4), i16(clsid, 6)) + @@ -454,7 +454,7 @@ class OleFileIO: fp.seek(i32(s, 16)) # get section - s = "****" + fp.read(i32(fp.read(4))-4) + s = b"****" + fp.read(i32(fp.read(4))-4) for i in range(i32(s, 4)): From d78f7e82ec72a706cf41e2bda09cafb6360adcad Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Fri, 17 Jan 2014 04:46:19 +0000 Subject: [PATCH 2/2] Port some commented-out print() calls --- PIL/OleFileIO.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PIL/OleFileIO.py b/PIL/OleFileIO.py index 93a00e875..8416554bd 100644 --- a/PIL/OleFileIO.py +++ b/PIL/OleFileIO.py @@ -112,7 +112,7 @@ class _OleStream(io.BytesIO): data = b"".join(data) - # print len(data), size + # print(len(data), size) io.BytesIO.__init__(self, data[:size]) @@ -501,8 +501,8 @@ class OleFileIO: # FIXME: add support for VT_VECTOR - #print "%08x" % id, repr(value), - #print "(%s)" % VT[i32(s, offset) & 0xFFF] + #print("%08x" % id, repr(value), end=" ") + #print("(%s)" % VT[i32(s, offset) & 0xFFF]) data[id] = value