From 4bcedc8fbd6b97e3b7057ab0971253dda1509dd4 Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 2 Apr 2015 07:53:00 +0300 Subject: [PATCH] Revert changes from PR #1121, for #1163 --- PIL/_binary.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/PIL/_binary.py b/PIL/_binary.py index 89a05a46f97..51ce45a79bd 100644 --- a/PIL/_binary.py +++ b/PIL/_binary.py @@ -11,8 +11,6 @@ # See the README file for information on usage and redistribution. # -from struct import unpack, pack - if bytes is str: def i8(c): return ord(c) @@ -36,7 +34,7 @@ def i16le(c, o=0): c: string containing bytes to convert o: offset of bytes to convert in string """ - return unpack("H", c[o:o+2]) + return (i8(c[o]) << 8) | i8(c[o+1]) def i32be(c, o=0): - return unpack(">I", c[o:o+4]) + return ((i8(c[o]) << 24) | (i8(c[o+1]) << 16) | + (i8(c[o+2]) << 8) | i8(c[o+3])) # Output, le = little endian, be = big endian def o16le(i): - return pack("> 8) def o32le(i): - return pack("> 8) + o8(i >> 16) + o8(i >> 24) def o16be(i): - return pack(">H", i) + return o8(i >> 8) + o8(i) def o32be(i): - return pack(">I", i) + return o8(i >> 24) + o8(i >> 16) + o8(i >> 8) + o8(i) # End of file