{
    "file_diffs": [
        {
            "old_file_content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# Binary input/output support routines.\n#\n# Copyright (c) 1997-2003 by Secret Labs AB\n# Copyright (c) 1995-2003 by Fredrik Lundh\n# Copyright (c) 2012 by Brian Crowell\n#\n# See the README file for information on usage and redistribution.\n#\n\nfrom struct import unpack, pack\n\nif bytes is str:\n    def i8(c):\n        return ord(c)\n\n    def o8(i):\n        return chr(i & 255)\nelse:\n    def i8(c):\n        return c if c.__class__ is int else c[0]\n\n    def o8(i):\n        return bytes((i & 255,))\n\n\n# Input, le = little endian, be = big endian\n# TODO: replace with more readable struct.unpack equivalent\ndef i16le(c, o=0):\n    \"\"\"\n    Converts a 2-bytes (16 bits) string to an integer.\n\n    c: string containing bytes to convert\n    o: offset of bytes to convert in string\n    \"\"\"\n    return unpack(\"<H\", c[o:o+2])\n\n\ndef i32le(c, o=0):\n    \"\"\"\n    Converts a 4-bytes (32 bits) string to an integer.\n\n    c: string containing bytes to convert\n    o: offset of bytes to convert in string\n    \"\"\"\n    return unpack(\"<I\", c[o:o+4])\n\n\ndef i16be(c, o=0):\n    return unpack(\">H\", c[o:o+2])\n\n\ndef i32be(c, o=0):\n    return unpack(\">I\", c[o:o+4])\n\n\n# Output, le = little endian, be = big endian\ndef o16le(i):\n    return pack(\"<H\", i)\n\n\ndef o32le(i):\n    return pack(\"<I\", i)\n\n\ndef o16be(i):\n    return pack(\">H\", i)\n\n\ndef o32be(i):\n    return pack(\">I\", i)\n\n# End of file\n",
            "new_file_content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# Binary input/output support routines.\n#\n# Copyright (c) 1997-2003 by Secret Labs AB\n# Copyright (c) 1995-2003 by Fredrik Lundh\n# Copyright (c) 2012 by Brian Crowell\n#\n# See the README file for information on usage and redistribution.\n#\n\nfrom struct import unpack, pack\n\nif bytes is str:\n    def i8(c):\n        return ord(c)\n\n    def o8(i):\n        return chr(i & 255)\nelse:\n    def i8(c):\n        return c if c.__class__ is int else c[0]\n\n    def o8(i):\n        return bytes((i & 255,))\n\n\n# Input, le = little endian, be = big endian\n# TODO: replace with more readable struct.unpack equivalent\ndef i16le(c, o=0):\n    \"\"\"\n    Converts a 2-bytes (16 bits) string to an integer.\n\n    c: string containing bytes to convert\n    o: offset of bytes to convert in string\n    \"\"\"\n    return unpack(\"<H\", c[o:o+2])[0]\n\n\ndef i32le(c, o=0):\n    \"\"\"\n    Converts a 4-bytes (32 bits) string to an integer.\n\n    c: string containing bytes to convert\n    o: offset of bytes to convert in string\n    \"\"\"\n    return unpack(\"<I\", c[o:o+4])[0]\n\n\ndef i16be(c, o=0):\n    return unpack(\">H\", c[o:o+2])[0]\n\n\ndef i32be(c, o=0):\n    return unpack(\">I\", c[o:o+4])[0]\n\n\n# Output, le = little endian, be = big endian\ndef o16le(i):\n    return pack(\"<H\", i)\n\n\ndef o32le(i):\n    return pack(\"<I\", i)\n\n\ndef o16be(i):\n    return pack(\">H\", i)\n\n\ndef o32be(i):\n    return pack(\">I\", i)\n\n# End of file\n",
            "header": {
                "file": {
                    "path": "PIL/_binary.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "89a05a46f",
                "new_commit_hash": "2f5e8ffd4",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/PIL/_binary.py"
            },
            "plus_file": {
                "path": "b/PIL/_binary.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 36,
                            "length": 7
                        },
                        "new_range": {
                            "start": 36,
                            "length": 7
                        },
                        "section": "def i16le(c, o=0):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "    c: string containing bytes to convert",
                                "type": "context"
                            },
                            {
                                "content": "    o: offset of bytes to convert in string",
                                "type": "context"
                            },
                            {
                                "content": "    \"\"\"",
                                "type": "context"
                            },
                            {
                                "content": "    return unpack(\"<H\", c[o:o+2])",
                                "type": "deleted"
                            },
                            {
                                "content": "    return unpack(\"<H\", c[o:o+2])[0]",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def i32le(c, o=0):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "PIL/_binary.py",
                            "type": "function",
                            "name": "i16le",
                            "content": "def i16le(c, o=0):\n    \"\"\"\n    Converts a 2-bytes (16 bits) string to an integer.\n\n    c: string containing bytes to convert\n    o: offset of bytes to convert in string\n    \"\"\"\n    return unpack(\"<H\", c[o:o+2])",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 32,
                            "end_lineno": 39,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 46,
                            "length": 15
                        },
                        "new_range": {
                            "start": 46,
                            "length": 15
                        },
                        "section": "def i32le(c, o=0):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "    c: string containing bytes to convert",
                                "type": "context"
                            },
                            {
                                "content": "    o: offset of bytes to convert in string",
                                "type": "context"
                            },
                            {
                                "content": "    \"\"\"",
                                "type": "context"
                            },
                            {
                                "content": "    return unpack(\"<I\", c[o:o+4])",
                                "type": "deleted"
                            },
                            {
                                "content": "    return unpack(\"<I\", c[o:o+4])[0]",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def i16be(c, o=0):",
                                "type": "context"
                            },
                            {
                                "content": "    return unpack(\">H\", c[o:o+2])",
                                "type": "deleted"
                            },
                            {
                                "content": "    return unpack(\">H\", c[o:o+2])[0]",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def i32be(c, o=0):",
                                "type": "context"
                            },
                            {
                                "content": "    return unpack(\">I\", c[o:o+4])",
                                "type": "deleted"
                            },
                            {
                                "content": "    return unpack(\">I\", c[o:o+4])[0]",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "# Output, le = little endian, be = big endian",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "PIL/_binary.py",
                            "type": "function",
                            "name": "i16be",
                            "content": "def i16be(c, o=0):\n    return unpack(\">H\", c[o:o+2])",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 52,
                            "end_lineno": 53,
                            "parent": null
                        },
                        {
                            "file_name": "PIL/_binary.py",
                            "type": "function",
                            "name": "i32le",
                            "content": "def i32le(c, o=0):\n    \"\"\"\n    Converts a 4-bytes (32 bits) string to an integer.\n\n    c: string containing bytes to convert\n    o: offset of bytes to convert in string\n    \"\"\"\n    return unpack(\"<I\", c[o:o+4])",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 42,
                            "end_lineno": 49,
                            "parent": null
                        },
                        {
                            "file_name": "PIL/_binary.py",
                            "type": "function",
                            "name": "i32be",
                            "content": "def i32be(c, o=0):\n    return unpack(\">I\", c[o:o+4])",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 56,
                            "end_lineno": 57,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "",
            "new_file_content": "from helper import unittest, PillowTestCase\n\nfrom PIL import _binary\n\nclass TestBinary(PillowTestCase):\n\n    def test_standard(self):\n        self.assertEqual(_binary.i8(b'*'), 42)\n        self.assertEqual(_binary.o8(42), b'*')\n\n    def test_little_endian(self):\n        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\n        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)\n        \n        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')\n\n    def test_big_endian(self):\n        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\n        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)\n        \n        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')\n\nif __name__ == '__main__':\n    unittest.main()\n\n# End of file",
            "header": {
                "file": {
                    "path": "Tests/test_binary.py"
                },
                "misc_line": "new file mode 100644"
            },
            "index_line": {
                "old_commit_hash": "000000000",
                "new_commit_hash": "4d3fb5914",
                "mode": ""
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "/dev/null"
            },
            "plus_file": {
                "path": "b/Tests/test_binary.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 0,
                            "length": 0
                        },
                        "new_range": {
                            "start": 1,
                            "length": 28
                        },
                        "section": ""
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "from helper import unittest, PillowTestCase",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "from PIL import _binary",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "class TestBinary(PillowTestCase):",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    def test_standard(self):",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.i8(b'*'), 42)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.o8(42), b'*')",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    def test_little_endian(self):",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)",
                                "type": "added"
                            },
                            {
                                "content": "        ",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    def test_big_endian(self):",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)",
                                "type": "added"
                            },
                            {
                                "content": "        ",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "if __name__ == '__main__':",
                                "type": "added"
                            },
                            {
                                "content": "    unittest.main()",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "# End of file",
                                "type": "added"
                            },
                            {
                                "content": "No newline at end of file",
                                "type": "note"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [
                        {
                            "file_name": "Tests/test_binary.py",
                            "type": "method",
                            "name": "TestBinary.test_standard",
                            "content": "class TestBinary(PillowTestCase):\n\n    def test_standard(self):\n        self.assertEqual(_binary.i8(b'*'), 42)\n        self.assertEqual(_binary.o8(42), b'*')\n\n    def test_little_endian(self):\n        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\n        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)\n        \n        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')\n\n    def test_big_endian(self):\n        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\n        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)\n        \n        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 7,
                            "end_lineno": 9,
                            "parent": {
                                "file_name": "Tests/test_binary.py",
                                "type": "class",
                                "name": "TestBinary",
                                "content": "class TestBinary(PillowTestCase):\n\n    def test_standard(self):\n        self.assertEqual(_binary.i8(b'*'), 42)\n        self.assertEqual(_binary.o8(42), b'*')\n\n    def test_little_endian(self):\n        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\n        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)\n        \n        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')\n\n    def test_big_endian(self):\n        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\n        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)\n        \n        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 5,
                                "end_lineno": 23,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Tests/test_binary.py",
                            "type": "class",
                            "name": "TestBinary",
                            "content": "class TestBinary(PillowTestCase):\n\n    def test_standard(self):\n        self.assertEqual(_binary.i8(b'*'), 42)\n        self.assertEqual(_binary.o8(42), b'*')\n\n    def test_little_endian(self):\n        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\n        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)\n        \n        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')\n\n    def test_big_endian(self):\n        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\n        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)\n        \n        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 5,
                            "end_lineno": 23,
                            "parent": null
                        },
                        {
                            "file_name": "Tests/test_binary.py",
                            "type": "method",
                            "name": "TestBinary.test_little_endian",
                            "content": "class TestBinary(PillowTestCase):\n\n    def test_standard(self):\n        self.assertEqual(_binary.i8(b'*'), 42)\n        self.assertEqual(_binary.o8(42), b'*')\n\n    def test_little_endian(self):\n        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\n        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)\n        \n        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')\n\n    def test_big_endian(self):\n        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\n        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)\n        \n        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 11,
                            "end_lineno": 16,
                            "parent": {
                                "file_name": "Tests/test_binary.py",
                                "type": "class",
                                "name": "TestBinary",
                                "content": "class TestBinary(PillowTestCase):\n\n    def test_standard(self):\n        self.assertEqual(_binary.i8(b'*'), 42)\n        self.assertEqual(_binary.o8(42), b'*')\n\n    def test_little_endian(self):\n        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\n        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)\n        \n        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')\n\n    def test_big_endian(self):\n        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\n        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)\n        \n        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 5,
                                "end_lineno": 23,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Tests/test_binary.py",
                            "type": "statement",
                            "name": "",
                            "content": "if __name__ == '__main__':\n    unittest.main()",
                            "ast_type_str": "If",
                            "start_lineno": 25,
                            "end_lineno": 26,
                            "parent": null
                        },
                        {
                            "file_name": "Tests/test_binary.py",
                            "type": "statement",
                            "name": "",
                            "content": "from helper import unittest, PillowTestCase",
                            "ast_type_str": "ImportFrom",
                            "start_lineno": 1,
                            "end_lineno": 1,
                            "parent": null
                        },
                        {
                            "file_name": "Tests/test_binary.py",
                            "type": "statement",
                            "name": "",
                            "content": "from PIL import _binary",
                            "ast_type_str": "ImportFrom",
                            "start_lineno": 3,
                            "end_lineno": 3,
                            "parent": null
                        },
                        {
                            "file_name": "Tests/test_binary.py",
                            "type": "method",
                            "name": "TestBinary.test_big_endian",
                            "content": "class TestBinary(PillowTestCase):\n\n    def test_standard(self):\n        self.assertEqual(_binary.i8(b'*'), 42)\n        self.assertEqual(_binary.o8(42), b'*')\n\n    def test_little_endian(self):\n        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\n        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)\n        \n        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')\n\n    def test_big_endian(self):\n        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\n        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)\n        \n        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 18,
                            "end_lineno": 23,
                            "parent": {
                                "file_name": "Tests/test_binary.py",
                                "type": "class",
                                "name": "TestBinary",
                                "content": "class TestBinary(PillowTestCase):\n\n    def test_standard(self):\n        self.assertEqual(_binary.i8(b'*'), 42)\n        self.assertEqual(_binary.o8(42), b'*')\n\n    def test_little_endian(self):\n        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\n        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)\n        \n        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')\n\n    def test_big_endian(self):\n        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\n        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)\n        \n        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 5,
                                "end_lineno": 23,
                                "parent": null
                            }
                        }
                    ],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "f644adbb05d615a9902ef3643714d5fe8049cea3^",
    "new_commit_hash": "f644adbb05d615a9902ef3643714d5fe8049cea3",
    "commit_message": "Fixed binary conversion bug, and added corresponding tests",
    "commit_date": "2015-03-02T09:56:47+11:00",
    "metadata": {}
}
{
    "repo_name": "pillow",
    "new_commit_hash": "f644adbb05d615a9902ef3643714d5fe8049cea3",
    "test_file_codes": [
        "from helper import unittest, PillowTestCase\n\nfrom PIL import _binary\n\nclass TestBinary(PillowTestCase):\n\n    def test_standard(self):\n        self.assertEqual(_binary.i8(b'*'), 42)\n        self.assertEqual(_binary.o8(42), b'*')\n\n    def test_little_endian(self):\n        self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\n        self.assertEqual(_binary.i32le(b'\\xff\\xff\\x00\\x00'), 65535)\n        \n        self.assertEqual(_binary.o16le(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32le(65535), b'\\xff\\xff\\x00\\x00')\n\n    def test_big_endian(self):\n        self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\n        self.assertEqual(_binary.i32be(b'\\x00\\x00\\xff\\xff'), 65535)\n        \n        self.assertEqual(_binary.o16be(65535), b'\\xff\\xff')\n        self.assertEqual(_binary.o32be(65535), b'\\x00\\x00\\xff\\xff')\n\nif __name__ == '__main__':\n    unittest.main()\n\n# End of file",
        "#!/usr/bin/env python\nimport unittest\nimport sys\nimport time\nimport traceback\nimport platform\nimport os\n\n\nclass PytestLikeResult(unittest.TestResult):\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.start_time = None\n        # Store (test, outcome, info) for each test:\n        #   outcome ∈ { \"passed\", \"failed\", \"error\", \"skipped\" }\n        #   info can hold the exception or skip reason, etc.\n        self.results = []\n\n    def startTestRun(self):\n        \"\"\"Called once before all tests.\"\"\"\n        self.start_time = time.time()\n        # Print a header similar to pytest\n        print(\"=\" * 29 + \" test session starts \" + \"=\" * 29)\n        # You can customize the platform/versions/paths as you like:\n        print(\n            f\"platform {platform.system().lower()} -- Python {platform.python_version()}\"\n        )\n        print(f\"rootdir: {os.path.abspath(os.curdir)}\")\n\n    def stopTestRun(self):\n        \"\"\"Called once after all tests are done.\"\"\"\n        elapsed = time.time() - self.start_time\n        print()  # blank line after final dot\n\n        # Summarize\n        ntests = len(self.results)\n        print(f\"collected {ntests} items\")\n\n        # Show details of failures/errors\n        failures = [r for r in self.results if r[1] == \"failed\"]\n        errors = [r for r in self.results if r[1] == \"error\"]\n\n        if failures:\n            print(\"\\n\" + \"=\" * 35 + \" FAILURES \" + \"=\" * 35)\n            for test, outcome, err_info in failures:\n                test = test.split(\"::\")\n                if len(test) == 3:\n                    test = f\"{test[1]}.{test[2]}\"\n                else:\n                    test = f\"{test[1]}\"\n                print(f\"__________ {test} __________\")\n                self._print_traceback(err_info)\n        if errors:\n            print(\"\\n\" + \"=\" * 35 + \" ERRORS \" + \"=\" * 37)\n            for test, outcome, err_info in errors:\n                test = test.split(\"::\")\n                if len(test) == 3:\n                    test = f\"{test[1]}.{test[2]}\"\n                else:\n                    test = f\"{test[1]}\"\n                print(f\"__________ {test} __________\")\n                self._print_traceback(err_info)\n\n        # Optional short summary lines for passes/fails/skips\n        print(\"\\n==================== short test summary info ====================\")\n        for test, outcome, info in self.results:\n            if outcome in (\"passed\", \"failed\", \"error\", \"skipped\"):\n                print(f\"{outcome.upper()} {test}\")\n\n        # Final one-line summary: “1 failed, 1 errors, 10 passed in 2.04s”\n        passed_count = sum(1 for r in self.results if r[1] == \"passed\")\n        failed_count = len(failures)\n        error_count = len(errors)\n        skipped_count = sum(1 for r in self.results if r[1] == \"skipped\")\n\n        summary_bits = []\n        if failed_count:\n            summary_bits.append(f\"{failed_count} failed\")\n        if error_count:\n            summary_bits.append(f\"{error_count} error{'s' if error_count != 1 else ''}\")\n        if passed_count:\n            summary_bits.append(f\"{passed_count} passed\")\n        if skipped_count:\n            summary_bits.append(f\"{skipped_count} skipped\")\n\n        summary_str = \", \".join(summary_bits) if summary_bits else \"no tests run\"\n        print(\n            f\"=================== {summary_str} in {elapsed:.2f}s ===================\"\n        )\n\n    def startTest(self, test):\n        \"\"\"Called right before each test method.\"\"\"\n        super().startTest(test)\n        # Print a dot or some indicator\n        print(\".\", end=\"\", flush=True)\n\n    def addSuccess(self, test):\n        super().addSuccess(test)\n        self.results.append((self._test_id(test), \"passed\", None))\n\n    def addFailure(self, test, err):\n        super().addFailure(test, err)\n        self.results.append((self._test_id(test), \"failed\", err))\n\n    def addError(self, test, err):\n        super().addError(test, err)\n        self.results.append((self._test_id(test), \"error\", err))\n\n    def addSkip(self, test, reason):\n        super().addSkip(test, reason)\n        self.results.append((self._test_id(test), \"skipped\", reason))\n\n    def _print_traceback(self, err_info):\n        \"\"\"Helper to print the traceback like pytest does.\"\"\"\n        if isinstance(err_info, tuple) and len(err_info) == 3:\n            exc_type, exc_value, tb = err_info\n            traceback.print_exception(exc_type, exc_value, tb, file=sys.stdout)\n        else:\n            print(str(err_info))\n\n    def _test_id(self, test):\n        try:\n            return f\"{test.__class__.__module__}::{test.__class__.__name__}::{test._testMethodName}\"\n        except AttributeError:\n            # Fallback for _ErrorHolder objects\n            return f\"{test.__class__.__module__}::{test.__class__.__name__}\"\n\n\nclass PytestLikeRunner(unittest.TextTestRunner):\n    \"\"\"A custom TextTestRunner that uses the PytestLikeResult.\"\"\"\n\n    resultclass = PytestLikeResult\n\n    def run(self, test):\n        result = self._makeResult()\n        # Overriding run to ensure we call startTestRun/stopTestRun\n        result.startTestRun()\n        test(result)\n        result.stopTestRun()\n        return result\n\n\ndef main():\n    loader = unittest.TestLoader()\n    suite = loader.discover(\"r2e_tests\")  # discover tests in r2e_tests/\n    runner = PytestLikeRunner(verbosity=0)\n    result = runner.run(suite)\n    # Exit with code 0 if all tests passed/skipped, 1 if there were fails/errors\n    sys.exit(not result.wasSuccessful())\n\n\nif __name__ == \"__main__\":\n    main()\n"
    ],
    "test_file_names": [
        "test_1.py",
        "unittest_custom_runner.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Starting Pillow installation attempts...\nVerifying Pillow installation...\n✅ Pillow installation successful!\nSuccessfully installed Pillow\n",
    "setup_res_stderr": "Using CPython 3.9.21\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 12 packages in 14ms\nInstalled 12 packages in 196ms\n + coverage==7.6.10\n + exceptiongroup==1.2.2\n + iniconfig==2.0.0\n + packaging==24.2\n + pluggy==1.5.0\n + pyqt5==5.15.11\n + pyqt5-qt5==5.15.16\n + pyqt5-sip==12.16.1\n + pytest==8.3.4\n + pytest-cov==6.0.0\n + setuptools==75.8.0\n + tomli==2.2.1\nResolved 1 package in 1.26s\nPrepared 1 package in 15.71s\nInstalled 1 package in 2ms\n + pillow==2.7.0 (from file:///home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f644adbb05d615a9902ef3643714d5fe8049cea3)\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts =============================\nplatform linux -- Python 3.9.21\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f644adbb05d615a9902ef3643714d5fe8049cea3\n...\ncollected 3 items\n\n==================== short test summary info ====================\nPASSED test_1::TestBinary::test_big_endian\nPASSED test_1::TestBinary::test_little_endian\nPASSED test_1::TestBinary::test_standard\n=================== 3 passed in 0.00s ===================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts =============================\nplatform linux -- Python 3.9.21\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f644adbb05d615a9902ef3643714d5fe8049cea3\n...\ncollected 3 items\n\n=================================== FAILURES ===================================\n__________ TestBinary.test_big_endian __________\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 59, in testPartExecutor\n    yield\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 592, in run\n    self._callTestMethod(testMethod)\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 550, in _callTestMethod\n    method()\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f644adbb05d615a9902ef3643714d5fe8049cea3/r2e_tests/test_1.py\", line 19, in test_big_endian\n    self.assertEqual(_binary.i16be(b'\\x00\\x00\\xff\\xff'), 0)\nAssertionError: (0,) != 0\n__________ TestBinary.test_little_endian __________\nTraceback (most recent call last):\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 59, in testPartExecutor\n    yield\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 592, in run\n    self._callTestMethod(testMethod)\n  File \"/home/gcpuser/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/unittest/case.py\", line 550, in _callTestMethod\n    method()\n  File \"/home/gcpuser/buckets/local_repoeval_bucket/repos/pillow_f644adbb05d615a9902ef3643714d5fe8049cea3/r2e_tests/test_1.py\", line 12, in test_little_endian\n    self.assertEqual(_binary.i16le(b'\\xff\\xff\\x00\\x00'), 65535)\nAssertionError: (65535,) != 65535\n\n==================== short test summary info ====================\nFAILED test_1::TestBinary::test_big_endian\nFAILED test_1::TestBinary::test_little_endian\nPASSED test_1::TestBinary::test_standard\n=================== 2 failed, 1 passed in 0.00s ===================\n",
    "old_commit_res_stderr": ""
}
PIL/_binary.py Tests/test_binary.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** Binary Conversion Functions Return Tuples Instead of Integers

**Description:**
When using the binary conversion functions `i16le` and `i16be`, the functions return a tuple containing the integer value instead of the integer itself. This causes discrepancies when the returned value is compared to an expected integer.

**Example Buggy Code:**
```python
from PIL import _binary

# Attempting to convert bytes to a 16-bit little endian integer
result = _binary.i16le(b'\xff\xff\x00\x00')
print(result)  # Output: (65535,)
```

**Expected Behavior:**
The function `i16le` should return the integer `65535` directly, not a tuple containing the integer.

**Actual Behavior:**
The function returns a tuple `(65535,)`, leading to assertion failures when the result is compared to the expected integer value.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### PIL/_binary.py
#
# The Python Imaging Library.
# $Id$
#
# Binary input/output support routines.
#
# Copyright (c) 1997-2003 by Secret Labs AB
# Copyright (c) 1995-2003 by Fredrik Lundh
# Copyright (c) 2012 by Brian Crowell
#
# 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)

    def o8(i):
        return chr(i & 255)
else:
    def i8(c):
        return c if c.__class__ is int else c[0]

    def o8(i):
        return bytes((i & 255,))


# Input, le = little endian, be = big endian
# TODO: replace with more readable struct.unpack equivalent
def i16le(c, o=0):
    """
    Converts a 2-bytes (16 bits) string to an integer.

    c: string containing bytes to convert
    o: offset of bytes to convert in string
    """
    return unpack("<H", c[o:o+2])


def i32le(c, o=0):
    """
    Converts a 4-bytes (32 bits) string to an integer.

    c: string containing bytes to convert
    o: offset of bytes to convert in string
    """
    return unpack("<I", c[o:o+4])


def i16be(c, o=0):
    return unpack(">H", c[o:o+2])


def i32be(c, o=0):
    return unpack(">I", c[o:o+4])


# Output, le = little endian, be = big endian
def o16le(i):
    return pack("<H", i)


def o32le(i):
    return pack("<I", i)


def o16be(i):
    return pack(">H", i)


def o32be(i):
    return pack(">I", i)

# End of file

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]
**Title:** Binary Conversion Functions Return Tuples Instead of Integers

**Description:**
When using the binary conversion functions `i16le` and `i16be`, the functions return a tuple containing the integer value instead of the integer itself. This causes discrepancies when the returned value is compared to an expected integer.

**Example Buggy Code:**
```python
from PIL import _binary

# Attempting to convert bytes to a 16-bit little endian integer
result = _binary.i16le(b'\xff\xff\x00\x00')
print(result)  # Output: (65535,)
```

**Expected Behavior:**
The function `i16le` should return the integer `65535` directly, not a tuple containing the integer.

**Actual Behavior:**
The function returns a tuple `(65535,)`, leading to assertion failures when the result is compared to the expected integer value.

[/ISSUE]
{
    "TestBinary.test_big_endian": "PASSED",
    "TestBinary.test_little_endian": "PASSED",
    "TestBinary.test_standard": "PASSED"
}
diff --git a/PIL/_binary.py b/PIL/_binary.py
index 89a05a46f..2f5e8ffd4 100644
--- a/PIL/_binary.py
+++ b/PIL/_binary.py
@@ -36,7 +36,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 unpack("<H", c[o:o+2])[0]
 
 
 def i32le(c, o=0):
@@ -46,15 +46,15 @@ def i32le(c, o=0):
     c: string containing bytes to convert
     o: offset of bytes to convert in string
     """
-    return unpack("<I", c[o:o+4])
+    return unpack("<I", c[o:o+4])[0]
 
 
 def i16be(c, o=0):
-    return unpack(">H", c[o:o+2])
+    return unpack(">H", c[o:o+2])[0]
 
 
 def i32be(c, o=0):
-    return unpack(">I", c[o:o+4])
+    return unpack(">I", c[o:o+4])[0]
 
 
 # Output, le = little endian, be = big endian

{"PIL/_binary.py": "#\n# The Python Imaging Library.\n# $Id$\n#\n# Binary input/output support routines.\n#\n# Copyright (c) 1997-2003 by Secret Labs AB\n# Copyright (c) 1995-2003 by Fredrik Lundh\n# Copyright (c) 2012 by Brian Crowell\n#\n# See the README file for information on usage and redistribution.\n#\n\nfrom struct import unpack, pack\n\nif bytes is str:\n    def i8(c):\n        return ord(c)\n\n    def o8(i):\n        return chr(i & 255)\nelse:\n    def i8(c):\n        return c if c.__class__ is int else c[0]\n\n    def o8(i):\n        return bytes((i & 255,))\n\n\n# Input, le = little endian, be = big endian\n# TODO: replace with more readable struct.unpack equivalent\ndef i16le(c, o=0):\n    \"\"\"\n    Converts a 2-bytes (16 bits) string to an integer.\n\n    c: string containing bytes to convert\n    o: offset of bytes to convert in string\n    \"\"\"\n    return unpack(\"<H\", c[o:o+2])\n\n\ndef i32le(c, o=0):\n    \"\"\"\n    Converts a 4-bytes (32 bits) string to an integer.\n\n    c: string containing bytes to convert\n    o: offset of bytes to convert in string\n    \"\"\"\n    return unpack(\"<I\", c[o:o+4])\n\n\ndef i16be(c, o=0):\n    return unpack(\">H\", c[o:o+2])\n\n\ndef i32be(c, o=0):\n    return unpack(\">I\", c[o:o+4])\n\n\n# Output, le = little endian, be = big endian\ndef o16le(i):\n    return pack(\"<H\", i)\n\n\ndef o32le(i):\n    return pack(\"<I\", i)\n\n\ndef o16be(i):\n    return pack(\">H\", i)\n\n\ndef o32be(i):\n    return pack(\">I\", i)\n\n# End of file\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** Binary Conversion Functions Return Tuples Instead of Integers

**Description:**
When using the binary conversion functions `i16le` and `i16be`, the functions return a tuple containing the integer value instead of the integer itself. This causes discrepancies when the returned value is compared to an expected integer.

**Example Buggy Code:**
```python
from PIL import _binary

# Attempting to convert bytes to a 16-bit little endian integer
result = _binary.i16le(b'\xff\xff\x00\x00')
print(result)  # Output: (65535,)
```

**Expected Behavior:**
The function `i16le` should return the integer `65535` directly, not a tuple containing the integer.

**Actual Behavior:**
The function returns a tuple `(65535,)`, leading to assertion failures when the result is compared to the expected integer value.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### PIL/_binary.py
#
# The Python Imaging Library.
# $Id$
#
# Binary input/output support routines.
#
# Copyright (c) 1997-2003 by Secret Labs AB
# Copyright (c) 1995-2003 by Fredrik Lundh
# Copyright (c) 2012 by Brian Crowell
#
# 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)

    def o8(i):
        return chr(i & 255)
else:
    def i8(c):
        return c if c.__class__ is int else c[0]

    def o8(i):
        return bytes((i & 255,))


# Input, le = little endian, be = big endian
# TODO: replace with more readable struct.unpack equivalent
def i16le(c, o=0):
    """
    Converts a 2-bytes (16 bits) string to an integer.

    c: string containing bytes to convert
    o: offset of bytes to convert in string
    """
    return unpack("<H", c[o:o+2])


def i32le(c, o=0):
    """
    Converts a 4-bytes (32 bits) string to an integer.

    c: string containing bytes to convert
    o: offset of bytes to convert in string
    """
    return unpack("<I", c[o:o+4])


def i16be(c, o=0):
    return unpack(">H", c[o:o+2])


def i32be(c, o=0):
    return unpack(">I", c[o:o+4])


# Output, le = little endian, be = big endian
def o16le(i):
    return pack("<H", i)


def o32le(i):
    return pack("<I", i)


def o16be(i):
    return pack(">H", i)


def o32be(i):
    return pack(">I", i)

# End of file

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user