def load(fp, fmt=None, use_builtin_types=None, dict_type=dict):
    if _check_py3():
        use_builtin_types = (True if (use_builtin_types == None) else use_builtin_types)
        if (fmt is None):
            header = fp.read(32)
            fp.seek(0)
            for info in plistlib._FORMATS.values():
                if info['detect'](header):
                    P = info['parser']
                    break
            else:
                raise plistlib.InvalidFileException()
        else:
            P = plistlib._FORMATS[fmt]['parser']
        p = P(use_builtin_types=use_builtin_types, dict_type=dict_type)
        if isinstance(p, plistlib._PlistParser):

            def end_integer():
                d = p.get_data()
                p.add_object((int(d, 16) if d.lower().startswith('0x') else int(d)))
            p.end_integer = end_integer
        return p.parse(fp)
    elif (not _is_binary(fp)):
        from xml.parsers.expat import ParserCreate
        p = plistlib.PlistParser()

        def begin_dict(attrs):
            d = dict_type()
            p.addObject(d)
            p.stack.append(d)

        def end_integer():
            d = p.getData()
            p.addObject((int(d, 16) if d.lower().startswith('0x') else int(d)))
        p.begin_dict = begin_dict
        p.end_integer = end_integer
        parser = ParserCreate()
        parser.StartElementHandler = p.handleBeginElement
        parser.EndElementHandler = p.handleEndElement
        parser.CharacterDataHandler = p.handleData
        if isinstance(fp, unicode):
            fp = fp.encode('utf-8')
        if isinstance(fp, _get_inst()):
            fp = StringIO(fp)
        parser.ParseFile(fp)
        return p.root
    else:
        use_builtin_types = (False if (use_builtin_types == None) else use_builtin_types)
        p = _BinaryPlistParser(use_builtin_types=use_builtin_types, dict_type=dict_type)
        return p.parse(fp)
def load(fp, fmt=None, use_builtin_types=None, dict_type=dict):
    if _check_py3():
        use_builtin_types = (True if (use_builtin_types == None) else use_builtin_types)
        if (fmt is None):
            header = fp.read(32)
            fp.seek(0)
            for info in plistlib._FORMATS.values():
                if info['detect'](header):
                    P = info['parser']
                    break
            else:
                raise plistlib.InvalidFileException()
        else:
            P = plistlib._FORMATS[fmt]['parser']
        p = P(use_builtin_types=use_builtin_types, dict_type=dict_type)
        if isinstance(p, plistlib._PlistParser):

            def end_integer():
                d = p.get_data()
                p.add_object((int(d, 16) if d.lower().startswith('0x') else int(d)))
            p.end_integer = end_integer
        return p.parse(fp)
    elif (not _is_binary(fp)):
        from xml.parsers.expat import ParserCreate
        p = plistlib.PlistParser()

        def begin_dict(attrs):
            d = dict_type()
            p.addObject(d)
            p.stack.append(d)

        def end_integer():
            d = p.getData()
            p.addObject((int(d, 16) if d.lower().startswith('0x') else int(d)))
        p.begin_dict = begin_dict
        p.end_integer = end_integer
        parser = ParserCreate()
        parser.StartElementHandler = p.handleBeginElement
        parser.EndElementHandler = p.handleEndElement
        parser.CharacterDataHandler = p.handleData
        if isinstance(fp, unicode):
            fp = fp.encode('utf-8')
        if isinstance(fp, _get_inst()):
            fp = StringIO(fp)
        parser.ParseFile(fp)
        return p.root
    else:
        use_builtin_types = (False if (use_builtin_types == None) else use_builtin_types)
        p = _BinaryPlistParser(use_builtin_types=use_builtin_types, dict_type=dict_type)
        return p.parse(fp)