{
    "file_diffs": [
        {
            "old_file_content": "import pprint\nfrom itertools import chain\nfrom collections import abc\n\n_marker = object()\n\n\nclass MultiDict(abc.Mapping):\n    \"\"\"Read-only ordered dictionary that can have multiple values for each key.\n\n    This type of MultiDict must be used for request headers and query args.\n    \"\"\"\n\n    __slots__ = ('_items',)\n\n    def __init__(self, *args, **kwargs):\n        if len(args) > 1:\n            raise TypeError(\"MultiDict takes at most 2 positional \"\n                            \"arguments ({} given)\".format(len(args) + 1))\n        self._items = []\n        if args:\n            if hasattr(args[0], 'items'):\n                args = list(args[0].items())\n            else:\n                args = list(args[0])\n                for arg in args:\n                    if not len(arg) == 2:\n                        raise TypeError(\n                            \"MultiDict takes either dict or list of \\\n                            (key, value) tuples\"\n                        )\n\n        self._fill(chain(args, kwargs.items()))\n\n    def _fill(self, ipairs):\n        self._items.extend(ipairs)\n\n    def getall(self, key, default=_marker):\n        \"\"\"\n        Return a list of all values matching the key (may be an empty list)\n        \"\"\"\n        res = tuple([v for k, v in self._items if k == key])\n        if res:\n            return res\n        if not res and default != _marker:\n            return default\n        raise KeyError('Key not found: %r' % key)\n\n    def getone(self, key, default=_marker):\n        \"\"\"\n        Get one value matching the key, raising a KeyError if multiple\n        values were found.\n        \"\"\"\n        v = self.getall(key, default=_marker)\n        if len(v) > 1 and v != default:\n            raise KeyError('Multiple values match %r: %r' % (key, v))\n        return v[0]\n\n    # extra methods #\n\n    def copy(self):\n        \"\"\"Returns a copy itself.\"\"\"\n        cls = self.__class__\n        return cls(self.items(getall=True))\n\n    # Mapping interface #\n\n    def __getitem__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return v\n        raise KeyError(key)\n\n    def __iter__(self):\n        return iter(self._items)\n\n    def __len__(self):\n        return len(self._items)\n\n    def keys(self, *, getall=False):\n        return _KeysView(self._items, getall=getall)\n\n    def items(self, *, getall=False):\n        return _ItemsView(self._items, getall=getall)\n\n    def values(self, *, getall=False):\n        return _ValuesView(self._items, getall=getall)\n\n    def __eq__(self, other):\n        if not isinstance(other, abc.Mapping):\n            return NotImplemented\n        if isinstance(other, MultiDict):\n            return self._items == other._items\n        return dict(self.items()) == dict(other.items())\n\n    def __contains__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return True\n        return False\n\n    def __repr__(self):\n        return '<{}>\\n{}'.format(\n            self.__class__.__name__, pprint.pformat(\n                list(self.items(getall=True)))\n        )\n\n\nclass CaseInsensitiveMultiDict(MultiDict):\n    \"\"\"Case insensitive multi dict.\"\"\"\n\n    @classmethod\n    def _from_uppercase_multidict(cls, dct):\n        # NB: doesn't check for uppercase keys!\n        ret = cls.__new__(cls)\n        ret._items = dct._items\n        return ret\n\n    def _fill(self, ipairs):\n        for key, value in ipairs:\n            uppkey = key.upper()\n            self._items.append((uppkey, value))\n\n    def getall(self, key, default=_marker):\n        return super().getall(key.upper(), default)\n\n    def getone(self, key, default=_marker):\n        return super().getone(key.upper(), default)\n\n    def __getitem__(self, key):\n        return super().__getitem__(key.upper())\n\n    def __contains__(self, key):\n        return super().__contains__(key.upper())\n\n\nclass MutableMultiDictMixin(abc.MutableMapping):\n\n    def add(self, key, value):\n        \"\"\"\n        Add the key and value, not overwriting any previous value.\n        \"\"\"\n        self._items.append((key, value))\n\n    def extend(self, *args, **kwargs):\n        \"\"\"Extends current MutableMultiDict with more values.\n\n        This method must be used instead of update.\n        \"\"\"\n        if len(args) > 1:\n            raise TypeError(\"extend takes at most 2 positional arguments\"\n                            \" ({} given)\".format(len(args) + 1))\n        if args:\n            if isinstance(args[0], MultiDict):\n                items = args[0].items(getall=True)\n            elif hasattr(args[0], 'items'):\n                items = args[0].items()\n            else:\n                items = args[0]\n        else:\n            items = []\n        for key, value in chain(items, kwargs.items()):\n            self.add(key, value)\n\n    def clear(self):\n        \"\"\"Remove all items from MutableMultiDict\"\"\"\n        self._items.clear()\n\n    # MutableMapping interface #\n\n    def __setitem__(self, key, value):\n        try:\n            del self[key]\n        except KeyError:\n            pass\n        self._items.append((key, value))\n\n    def __delitem__(self, key):\n        items = self._items\n        found = False\n        for i in range(len(items)-1, -1, -1):\n            if items[i][0] == key:\n                del items[i]\n                found = True\n        if not found:\n            raise KeyError(key)\n\n    def pop(self, key, default=None):\n        \"\"\"Method not allowed.\"\"\"\n        raise NotImplementedError\n\n    def popitem(self):\n        \"\"\"Method not allowed.\"\"\"\n        raise NotImplementedError\n\n    def update(self, *args, **kw):\n        \"\"\"Method not allowed.\"\"\"\n        raise NotImplementedError(\"Use extend method instead\")\n\n\nclass MutableMultiDict(MutableMultiDictMixin, MultiDict):\n    \"\"\"An ordered dictionary that can have multiple values for each key.\"\"\"\n\n\nclass CaseInsensitiveMutableMultiDict(\n        MutableMultiDictMixin, CaseInsensitiveMultiDict):\n    \"\"\"An ordered dictionary that can have multiple values for each key.\"\"\"\n\n    def add(self, key, value):\n        super().add(key.upper(), value)\n\n    def __setitem__(self, key, value):\n        super().__setitem__(key.upper(), value)\n\n    def __delitem__(self, key):\n        super().__delitem__(key.upper())\n\n\nclass _ItemsView(abc.ItemsView):\n\n    def __init__(self, items, *, getall=False):\n        self._getall = getall\n        self._keys = [item[0] for item in items]\n        if not getall:\n            self._keys = set(self._keys)\n\n        items_to_use = []\n        if getall:\n            items_to_use = items\n        else:\n            for key in self._keys:\n                for k, v in items:\n                    if k == key:\n                        items_to_use.append((k, v))\n                        break\n        assert len(items_to_use) == len(self._keys)\n\n        super().__init__(items_to_use)\n\n    def __contains__(self, item):\n        assert isinstance(item, tuple) or isinstance(item, list)\n        assert len(item) == 2\n        return item in self._mapping\n\n    def __iter__(self):\n        yield from self._mapping\n\n\nclass _ValuesView(abc.ValuesView):\n\n    def __init__(self, items, *, getall=False):\n        self._getall = getall\n        self._keys = [item[0] for item in items]\n        if not getall:\n            self._keys = set(self._keys)\n\n        items_to_use = []\n        if getall:\n            items_to_use = items\n        else:\n            for key in self._keys:\n                for k, v in items:\n                    if k == key:\n                        items_to_use.append((k, v))\n                        break\n\n        assert len(items_to_use) == len(self._keys)\n\n        super().__init__(items_to_use)\n\n    def __contains__(self, value):\n        values = [item[1] for item in self._mapping]\n        return value in values\n\n    def __iter__(self):\n        values = (item[1] for item in self._mapping)\n        yield from values\n\n\nclass _KeysView(abc.KeysView):\n\n    def __init__(self, items, *, getall=False):\n        self._getall = getall\n        self._keys = [item[0] for item in items]\n        if not getall:\n            self._keys = set(self._keys)\n\n        items_to_use = []\n        if getall:\n            items_to_use = items\n        else:\n            for key in self._keys:\n                for k, v in items:\n                    if k == key:\n                        items_to_use.append((k, v))\n                        break\n        assert len(items_to_use) == len(self._keys)\n\n        super().__init__(items_to_use)\n\n    def __contains__(self, key):\n        return key in self._keys\n\n    def __iter__(self):\n        yield from self._keys\n",
            "new_file_content": "import pprint\nfrom itertools import chain\nfrom collections import abc\n\n_marker = object()\n\n\nclass MultiDict(abc.Mapping):\n    \"\"\"Read-only ordered dictionary that can have multiple values for each key.\n\n    This type of MultiDict must be used for request headers and query args.\n    \"\"\"\n\n    __slots__ = ('_items',)\n\n    def __init__(self, *args, **kwargs):\n        if len(args) > 1:\n            raise TypeError(\"MultiDict takes at most 1 positional \"\n                            \"argument ({} given)\".format(len(args)))\n        self._items = []\n        if args:\n            if hasattr(args[0], 'items'):\n                args = list(args[0].items())\n            else:\n                args = list(args[0])\n                for arg in args:\n                    if not len(arg) == 2:\n                        raise TypeError(\n                            \"MultiDict takes either dict or list of \\\n                            (key, value) tuples\"\n                        )\n\n        self._fill(chain(args, kwargs.items()))\n\n    def _fill(self, ipairs):\n        self._items.extend(ipairs)\n\n    def getall(self, key, default=_marker):\n        \"\"\"\n        Return a list of all values matching the key (may be an empty list)\n        \"\"\"\n        res = tuple([v for k, v in self._items if k == key])\n        if res:\n            return res\n        if not res and default != _marker:\n            return default\n        raise KeyError('Key not found: %r' % key)\n\n    def getone(self, key, default=_marker):\n        \"\"\"\n        Get one value matching the key, raising a KeyError if multiple\n        values were found.\n        \"\"\"\n        v = self.getall(key, default=_marker)\n        if len(v) > 1 and v != default:\n            raise KeyError('Multiple values match %r: %r' % (key, v))\n        return v[0]\n\n    # extra methods #\n\n    def copy(self):\n        \"\"\"Returns a copy itself.\"\"\"\n        cls = self.__class__\n        return cls(self.items(getall=True))\n\n    # Mapping interface #\n\n    def __getitem__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return v\n        raise KeyError(key)\n\n    def __iter__(self):\n        return iter(self._items)\n\n    def __len__(self):\n        return len(self._items)\n\n    def keys(self, *, getall=False):\n        return _KeysView(self._items, getall=getall)\n\n    def items(self, *, getall=False):\n        return _ItemsView(self._items, getall=getall)\n\n    def values(self, *, getall=False):\n        return _ValuesView(self._items, getall=getall)\n\n    def __eq__(self, other):\n        if not isinstance(other, abc.Mapping):\n            return NotImplemented\n        if isinstance(other, MultiDict):\n            return self._items == other._items\n        return dict(self.items()) == dict(other.items())\n\n    def __contains__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return True\n        return False\n\n    def __repr__(self):\n        return '<{}>\\n{}'.format(\n            self.__class__.__name__, pprint.pformat(\n                list(self.items(getall=True)))\n        )\n\n\nclass CaseInsensitiveMultiDict(MultiDict):\n    \"\"\"Case insensitive multi dict.\"\"\"\n\n    @classmethod\n    def _from_uppercase_multidict(cls, dct):\n        # NB: doesn't check for uppercase keys!\n        ret = cls.__new__(cls)\n        ret._items = dct._items\n        return ret\n\n    def _fill(self, ipairs):\n        for key, value in ipairs:\n            uppkey = key.upper()\n            self._items.append((uppkey, value))\n\n    def getall(self, key, default=_marker):\n        return super().getall(key.upper(), default)\n\n    def getone(self, key, default=_marker):\n        return super().getone(key.upper(), default)\n\n    def __getitem__(self, key):\n        return super().__getitem__(key.upper())\n\n    def __contains__(self, key):\n        return super().__contains__(key.upper())\n\n\nclass MutableMultiDictMixin(abc.MutableMapping):\n\n    def add(self, key, value):\n        \"\"\"\n        Add the key and value, not overwriting any previous value.\n        \"\"\"\n        self._items.append((key, value))\n\n    def extend(self, *args, **kwargs):\n        \"\"\"Extends current MutableMultiDict with more values.\n\n        This method must be used instead of update.\n        \"\"\"\n        if len(args) > 1:\n            raise TypeError(\"extend takes at most 2 positional arguments\"\n                            \" ({} given)\".format(len(args) + 1))\n        if args:\n            if isinstance(args[0], MultiDict):\n                items = args[0].items(getall=True)\n            elif hasattr(args[0], 'items'):\n                items = args[0].items()\n            else:\n                items = args[0]\n        else:\n            items = []\n        for key, value in chain(items, kwargs.items()):\n            self.add(key, value)\n\n    def clear(self):\n        \"\"\"Remove all items from MutableMultiDict\"\"\"\n        self._items.clear()\n\n    # MutableMapping interface #\n\n    def __setitem__(self, key, value):\n        try:\n            del self[key]\n        except KeyError:\n            pass\n        self._items.append((key, value))\n\n    def __delitem__(self, key):\n        items = self._items\n        found = False\n        for i in range(len(items)-1, -1, -1):\n            if items[i][0] == key:\n                del items[i]\n                found = True\n        if not found:\n            raise KeyError(key)\n\n    def pop(self, key, default=None):\n        \"\"\"Method not allowed.\"\"\"\n        raise NotImplementedError\n\n    def popitem(self):\n        \"\"\"Method not allowed.\"\"\"\n        raise NotImplementedError\n\n    def update(self, *args, **kw):\n        \"\"\"Method not allowed.\"\"\"\n        raise NotImplementedError(\"Use extend method instead\")\n\n\nclass MutableMultiDict(MutableMultiDictMixin, MultiDict):\n    \"\"\"An ordered dictionary that can have multiple values for each key.\"\"\"\n\n\nclass CaseInsensitiveMutableMultiDict(\n        MutableMultiDictMixin, CaseInsensitiveMultiDict):\n    \"\"\"An ordered dictionary that can have multiple values for each key.\"\"\"\n\n    def add(self, key, value):\n        super().add(key.upper(), value)\n\n    def __setitem__(self, key, value):\n        super().__setitem__(key.upper(), value)\n\n    def __delitem__(self, key):\n        super().__delitem__(key.upper())\n\n\nclass _ItemsView(abc.ItemsView):\n\n    def __init__(self, items, *, getall=False):\n        self._getall = getall\n        self._keys = [item[0] for item in items]\n        if not getall:\n            self._keys = set(self._keys)\n\n        items_to_use = []\n        if getall:\n            items_to_use = items\n        else:\n            for key in self._keys:\n                for k, v in items:\n                    if k == key:\n                        items_to_use.append((k, v))\n                        break\n        assert len(items_to_use) == len(self._keys)\n\n        super().__init__(items_to_use)\n\n    def __contains__(self, item):\n        assert isinstance(item, tuple) or isinstance(item, list)\n        assert len(item) == 2\n        return item in self._mapping\n\n    def __iter__(self):\n        yield from self._mapping\n\n\nclass _ValuesView(abc.ValuesView):\n\n    def __init__(self, items, *, getall=False):\n        self._getall = getall\n        self._keys = [item[0] for item in items]\n        if not getall:\n            self._keys = set(self._keys)\n\n        items_to_use = []\n        if getall:\n            items_to_use = items\n        else:\n            for key in self._keys:\n                for k, v in items:\n                    if k == key:\n                        items_to_use.append((k, v))\n                        break\n\n        assert len(items_to_use) == len(self._keys)\n\n        super().__init__(items_to_use)\n\n    def __contains__(self, value):\n        values = [item[1] for item in self._mapping]\n        return value in values\n\n    def __iter__(self):\n        values = (item[1] for item in self._mapping)\n        yield from values\n\n\nclass _KeysView(abc.KeysView):\n\n    def __init__(self, items, *, getall=False):\n        self._getall = getall\n        self._keys = [item[0] for item in items]\n        if not getall:\n            self._keys = set(self._keys)\n\n        items_to_use = []\n        if getall:\n            items_to_use = items\n        else:\n            for key in self._keys:\n                for k, v in items:\n                    if k == key:\n                        items_to_use.append((k, v))\n                        break\n        assert len(items_to_use) == len(self._keys)\n\n        super().__init__(items_to_use)\n\n    def __contains__(self, key):\n        return key in self._keys\n\n    def __iter__(self):\n        yield from self._keys\n",
            "header": {
                "file": {
                    "path": "aiohttp/multidict.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "584ae1db",
                "new_commit_hash": "43d19204",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/aiohttp/multidict.py"
            },
            "plus_file": {
                "path": "b/aiohttp/multidict.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 15,
                            "length": 8
                        },
                        "new_range": {
                            "start": 15,
                            "length": 8
                        },
                        "section": "class MultiDict(abc.Mapping):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def __init__(self, *args, **kwargs):",
                                "type": "context"
                            },
                            {
                                "content": "        if len(args) > 1:",
                                "type": "context"
                            },
                            {
                                "content": "            raise TypeError(\"MultiDict takes at most 2 positional \"",
                                "type": "deleted"
                            },
                            {
                                "content": "                            \"arguments ({} given)\".format(len(args) + 1))",
                                "type": "deleted"
                            },
                            {
                                "content": "            raise TypeError(\"MultiDict takes at most 1 positional \"",
                                "type": "added"
                            },
                            {
                                "content": "                            \"argument ({} given)\".format(len(args)))",
                                "type": "added"
                            },
                            {
                                "content": "        self._items = []",
                                "type": "context"
                            },
                            {
                                "content": "        if args:",
                                "type": "context"
                            },
                            {
                                "content": "            if hasattr(args[0], 'items'):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "aiohttp/multidict.py",
                            "type": "method",
                            "name": "MultiDict.__init__",
                            "content": "class MultiDict(abc.Mapping):\n    \"\"\"Read-only ordered dictionary that can have multiple values for each key.\n\n    This type of MultiDict must be used for request headers and query args.\n    \"\"\"\n\n    __slots__ = ('_items',)\n\n    def __init__(self, *args, **kwargs):\n        if len(args) > 1:\n            raise TypeError(\"MultiDict takes at most 2 positional \"\n                            \"arguments ({} given)\".format(len(args) + 1))\n        self._items = []\n        if args:\n            if hasattr(args[0], 'items'):\n                args = list(args[0].items())\n            else:\n                args = list(args[0])\n                for arg in args:\n                    if not len(arg) == 2:\n                        raise TypeError(\n                            \"MultiDict takes either dict or list of \\\n                            (key, value) tuples\"\n                        )\n\n        self._fill(chain(args, kwargs.items()))\n\n    def _fill(self, ipairs):\n        self._items.extend(ipairs)\n\n    def getall(self, key, default=_marker):\n        \"\"\"\n        Return a list of all values matching the key (may be an empty list)\n        \"\"\"\n        res = tuple([v for k, v in self._items if k == key])\n        if res:\n            return res\n        if not res and default != _marker:\n            return default\n        raise KeyError('Key not found: %r' % key)\n\n    def getone(self, key, default=_marker):\n        \"\"\"\n        Get one value matching the key, raising a KeyError if multiple\n        values were found.\n        \"\"\"\n        v = self.getall(key, default=_marker)\n        if len(v) > 1 and v != default:\n            raise KeyError('Multiple values match %r: %r' % (key, v))\n        return v[0]\n\n    # extra methods #\n\n    def copy(self):\n        \"\"\"Returns a copy itself.\"\"\"\n        cls = self.__class__\n        return cls(self.items(getall=True))\n\n    # Mapping interface #\n\n    def __getitem__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return v\n        raise KeyError(key)\n\n    def __iter__(self):\n        return iter(self._items)\n\n    def __len__(self):\n        return len(self._items)\n\n    def keys(self, *, getall=False):\n        return _KeysView(self._items, getall=getall)\n\n    def items(self, *, getall=False):\n        return _ItemsView(self._items, getall=getall)\n\n    def values(self, *, getall=False):\n        return _ValuesView(self._items, getall=getall)\n\n    def __eq__(self, other):\n        if not isinstance(other, abc.Mapping):\n            return NotImplemented\n        if isinstance(other, MultiDict):\n            return self._items == other._items\n        return dict(self.items()) == dict(other.items())\n\n    def __contains__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return True\n        return False\n\n    def __repr__(self):\n        return '<{}>\\n{}'.format(\n            self.__class__.__name__, pprint.pformat(\n                list(self.items(getall=True)))\n        )",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 16,
                            "end_lineno": 33,
                            "parent": {
                                "file_name": "aiohttp/multidict.py",
                                "type": "class",
                                "name": "MultiDict",
                                "content": "class MultiDict(abc.Mapping):\n    \"\"\"Read-only ordered dictionary that can have multiple values for each key.\n\n    This type of MultiDict must be used for request headers and query args.\n    \"\"\"\n\n    __slots__ = ('_items',)\n\n    def __init__(self, *args, **kwargs):\n        if len(args) > 1:\n            raise TypeError(\"MultiDict takes at most 2 positional \"\n                            \"arguments ({} given)\".format(len(args) + 1))\n        self._items = []\n        if args:\n            if hasattr(args[0], 'items'):\n                args = list(args[0].items())\n            else:\n                args = list(args[0])\n                for arg in args:\n                    if not len(arg) == 2:\n                        raise TypeError(\n                            \"MultiDict takes either dict or list of \\\n                            (key, value) tuples\"\n                        )\n\n        self._fill(chain(args, kwargs.items()))\n\n    def _fill(self, ipairs):\n        self._items.extend(ipairs)\n\n    def getall(self, key, default=_marker):\n        \"\"\"\n        Return a list of all values matching the key (may be an empty list)\n        \"\"\"\n        res = tuple([v for k, v in self._items if k == key])\n        if res:\n            return res\n        if not res and default != _marker:\n            return default\n        raise KeyError('Key not found: %r' % key)\n\n    def getone(self, key, default=_marker):\n        \"\"\"\n        Get one value matching the key, raising a KeyError if multiple\n        values were found.\n        \"\"\"\n        v = self.getall(key, default=_marker)\n        if len(v) > 1 and v != default:\n            raise KeyError('Multiple values match %r: %r' % (key, v))\n        return v[0]\n\n    # extra methods #\n\n    def copy(self):\n        \"\"\"Returns a copy itself.\"\"\"\n        cls = self.__class__\n        return cls(self.items(getall=True))\n\n    # Mapping interface #\n\n    def __getitem__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return v\n        raise KeyError(key)\n\n    def __iter__(self):\n        return iter(self._items)\n\n    def __len__(self):\n        return len(self._items)\n\n    def keys(self, *, getall=False):\n        return _KeysView(self._items, getall=getall)\n\n    def items(self, *, getall=False):\n        return _ItemsView(self._items, getall=getall)\n\n    def values(self, *, getall=False):\n        return _ValuesView(self._items, getall=getall)\n\n    def __eq__(self, other):\n        if not isinstance(other, abc.Mapping):\n            return NotImplemented\n        if isinstance(other, MultiDict):\n            return self._items == other._items\n        return dict(self.items()) == dict(other.items())\n\n    def __contains__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return True\n        return False\n\n    def __repr__(self):\n        return '<{}>\\n{}'.format(\n            self.__class__.__name__, pprint.pformat(\n                list(self.items(getall=True)))\n        )",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 8,
                                "end_lineno": 106,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "aiohttp/multidict.py",
                            "type": "class",
                            "name": "MultiDict",
                            "content": "class MultiDict(abc.Mapping):\n    \"\"\"Read-only ordered dictionary that can have multiple values for each key.\n\n    This type of MultiDict must be used for request headers and query args.\n    \"\"\"\n\n    __slots__ = ('_items',)\n\n    def __init__(self, *args, **kwargs):\n        if len(args) > 1:\n            raise TypeError(\"MultiDict takes at most 2 positional \"\n                            \"arguments ({} given)\".format(len(args) + 1))\n        self._items = []\n        if args:\n            if hasattr(args[0], 'items'):\n                args = list(args[0].items())\n            else:\n                args = list(args[0])\n                for arg in args:\n                    if not len(arg) == 2:\n                        raise TypeError(\n                            \"MultiDict takes either dict or list of \\\n                            (key, value) tuples\"\n                        )\n\n        self._fill(chain(args, kwargs.items()))\n\n    def _fill(self, ipairs):\n        self._items.extend(ipairs)\n\n    def getall(self, key, default=_marker):\n        \"\"\"\n        Return a list of all values matching the key (may be an empty list)\n        \"\"\"\n        res = tuple([v for k, v in self._items if k == key])\n        if res:\n            return res\n        if not res and default != _marker:\n            return default\n        raise KeyError('Key not found: %r' % key)\n\n    def getone(self, key, default=_marker):\n        \"\"\"\n        Get one value matching the key, raising a KeyError if multiple\n        values were found.\n        \"\"\"\n        v = self.getall(key, default=_marker)\n        if len(v) > 1 and v != default:\n            raise KeyError('Multiple values match %r: %r' % (key, v))\n        return v[0]\n\n    # extra methods #\n\n    def copy(self):\n        \"\"\"Returns a copy itself.\"\"\"\n        cls = self.__class__\n        return cls(self.items(getall=True))\n\n    # Mapping interface #\n\n    def __getitem__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return v\n        raise KeyError(key)\n\n    def __iter__(self):\n        return iter(self._items)\n\n    def __len__(self):\n        return len(self._items)\n\n    def keys(self, *, getall=False):\n        return _KeysView(self._items, getall=getall)\n\n    def items(self, *, getall=False):\n        return _ItemsView(self._items, getall=getall)\n\n    def values(self, *, getall=False):\n        return _ValuesView(self._items, getall=getall)\n\n    def __eq__(self, other):\n        if not isinstance(other, abc.Mapping):\n            return NotImplemented\n        if isinstance(other, MultiDict):\n            return self._items == other._items\n        return dict(self.items()) == dict(other.items())\n\n    def __contains__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return True\n        return False\n\n    def __repr__(self):\n        return '<{}>\\n{}'.format(\n            self.__class__.__name__, pprint.pformat(\n                list(self.items(getall=True)))\n        )",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 8,
                            "end_lineno": 106,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import unittest\n\nfrom aiohttp.multidict import \\\n    MultiDict, MutableMultiDict, \\\n    CaseInsensitiveMultiDict, CaseInsensitiveMutableMultiDict\n\n\nclass _BaseTest:\n\n    def make_dict(self, *args, **kwargs):\n        raise NotImplementedError\n\n    def test_instantiate__empty(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n        self.assertEqual(len(d), 0)\n        self.assertEqual(list(d.keys()), [])\n        self.assertEqual(list(d.values()), [])\n        self.assertEqual(list(d.values(getall=True)), [])\n        self.assertEqual(list(d.items()), [])\n        self.assertEqual(list(d.items(getall=True)), [])\n\n        self.assertNotEqual(self.make_dict(), list())\n        with self.assertRaisesRegex(TypeError, \"\\(3 given\\)\"):\n            self.make_dict(('key1', 'value1'), ('key2', 'value2'))\n\n    def test_instantiate__from_arg0(self):\n        d = self.make_dict([('key', 'value1')])\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__from_arg0_dict(self):\n        d = self.make_dict({'key': 'value1'})\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__with_kwargs(self):\n        d = self.make_dict([('key', 'value1')], key2='value2')\n\n        self.assertEqual(d, {'key': 'value1', 'key2': 'value2'})\n        self.assertEqual(len(d), 2)\n        self.assertEqual(sorted(d.keys()), ['key', 'key2'])\n        self.assertEqual(sorted(d.values()), ['value1', 'value2'])\n        self.assertEqual(sorted(d.items()), [('key', 'value1'),\n                                             ('key2', 'value2')])\n\n    def test_getone(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n        with self.assertRaises(KeyError):\n            self.assertEqual(d.getone('key'), 'value1')\n        self.assertEqual(d.get('key'), 'value1')\n        self.assertEqual(d['key'], 'value1')\n\n        with self.assertRaises(KeyError):\n            d['key2']\n        with self.assertRaises(KeyError):\n            d.getone('key2')\n\n    def test_copy(self):\n        d1 = self.make_dict(key='value', a='b')\n\n        d2 = d1.copy()\n        self.assertEqual(d1, d2)\n        self.assertIsNot(d1, d2)\n\n    def test_values__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.values()), ['one'])\n        self.assertEqual(list(d.values(getall=True)), ['one', 'two', 3])\n\n        self.assertIn('one', d.values())\n        self.assertNotIn('two', d.values())\n        self.assertNotIn(3, d.values())\n\n        self.assertIn('one', d.values(getall=True))\n        self.assertIn('two', d.values(getall=True))\n        self.assertIn(3, d.values(getall=True))\n\n        self.assertNotIn('foo', d.values())\n        self.assertNotIn('foo', d.values(getall=True))\n\n    def test_items__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.items()), [('key', 'one')])\n        self.assertEqual(list(d.items(getall=True)),\n                         [('key', 'one'), ('key', 'two'), ('key', 3)])\n\n        self.assertIn(('key', 'one'), d.items())\n        self.assertNotIn(('key', 'two'), d.items())\n        self.assertNotIn(('key', 3), d.items())\n\n        self.assertIn(('key', 'one'), d.items(getall=True))\n        self.assertIn(('key', 'two'), d.items(getall=True))\n        self.assertIn(('key', 3), d.items(getall=True))\n\n        self.assertNotIn(('foo', 'bar'), d.items())\n        self.assertNotIn(('foo', 'bar'), d.items(getall=True))\n\n\nclass MultiDictTests(_BaseTest, unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return MultiDict(*args, **kwargs)\n\n    def test__repr__(self):\n        d = self.make_dict()\n        self.assertEqual(str(d), \"<MultiDict>\\n[]\")\n        d = self.make_dict([('key', 'one'), ('key', 'two')])\n        self.assertEqual(str(d),\n                         \"<MultiDict>\\n[('key', 'one'), ('key', 'two')]\")\n\n    def test_getall(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"some_key\"):\n            d.getall('some_key')\n\n        default = object()\n        self.assertIs(d.getall('some_key', default), default)\n\n\nclass CaseInsensitiveMultiDictTests(unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return CaseInsensitiveMultiDict(*args, **kwargs)\n\n    def test_basics(self):\n        d = self.make_dict([('KEY', 'value1')], KEY='value2')\n        with self.assertRaises(KeyError):\n            self.assertEqual(d.getone('key'), 'value1')\n        self.assertEqual(d.get('key'), 'value1')\n        self.assertEqual(d.get('key2', 'val'), 'val')\n        self.assertEqual(d['key'], 'value1')\n        self.assertIn('key', d)\n\n        with self.assertRaises(KeyError):\n            d['key2']\n        with self.assertRaises(KeyError):\n            d.getone('key2')\n\n    def test_getall(self):\n        d = self.make_dict([('KEY', 'value1')], KEY='value2')\n\n        self.assertEqual(d, {'KEY': 'value1'})\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"SOME_KEY\"):\n            d.getall('some_key')\n\n\nclass _BaseMutableMultiDictTests(_BaseTest):\n\n    def test__repr__(self):\n        d = self.make_dict()\n        self.assertEqual(str(d), \"<MutableMultiDict>\\n[]\")\n\n        d = self.make_dict([('key', 'one'), ('key', 'two')])\n\n        self.assertEqual(\n            str(d),\n            \"<MutableMultiDict>\\n[('key', 'one'), ('key', 'two')]\")\n\n    def test_getall(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"some_key\"):\n            d.getall('some_key')\n\n        default = object()\n        self.assertIs(d.getall('some_key', default), default)\n\n    def test_add(self):\n        d = self.make_dict()\n\n        self.assertEqual(d, {})\n        d['key'] = 'one'\n        self.assertEqual(d, {'key': 'one'})\n        self.assertEqual(d.getall('key'), ('one',))\n\n        d['key'] = 'two'\n        self.assertEqual(d, {'key': 'two'})\n        self.assertEqual(d.getall('key'), ('two',))\n\n        d.add('key', 'one')\n        self.assertEqual(d, {'key': 'two'})\n        self.assertEqual(d.getall('key'), ('two', 'one'))\n\n        d.add('foo', 'bar')\n        self.assertEqual(d, {'key': 'two', 'foo': 'bar'})\n        self.assertEqual(d.getall('foo'), ('bar',))\n\n    def test_extend(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n\n        d.extend([('key', 'one'), ('key', 'two')], key=3, foo='bar')\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar'})\n        itms = d.items(getall=True)\n        # we can't guarantee order of kwargs\n        self.assertTrue(('key', 'one') in itms)\n        self.assertTrue(('key', 'two') in itms)\n        self.assertTrue(('key', 3) in itms)\n        self.assertTrue(('foo', 'bar') in itms)\n\n        other = self.make_dict(bar='baz')\n        self.assertEqual(other, {'bar': 'baz'})\n\n        d.extend(other)\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar', 'bar': 'baz'})\n        self.assertIn(('bar', 'baz'), d.items(getall=True))\n\n        d.extend({'foo': 'moo'})\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar', 'bar': 'baz'})\n        self.assertIn(('foo', 'moo'), d.items(getall=True))\n\n        d.extend()\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar', 'bar': 'baz'})\n\n        with self.assertRaises(TypeError):\n            d.extend('foo', 'bar')\n\n    def test_clear(self):\n        d = self.make_dict([('key', 'one')], key='two', foo='bar')\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar'})\n\n        d.clear()\n        self.assertEqual(d, {})\n        self.assertEqual(list(d.items(getall=True)), [])\n\n    def test_del(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two')], foo='bar')\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar'})\n\n        del d['key']\n        self.assertEqual(d, {'foo': 'bar'})\n        self.assertEqual(list(d.items(getall=True)), [('foo', 'bar')])\n\n        with self.assertRaises(KeyError):\n            del d['key']\n\n    def test_not_implemented_methods(self):\n        d = self.make_dict()\n\n        with self.assertRaises(NotImplementedError):\n            d.pop('foo')\n        with self.assertRaises(NotImplementedError):\n            d.popitem()\n        with self.assertRaises(NotImplementedError):\n            d.update(bar='baz')\n\n\nclass MutableMultiDictTests(_BaseMutableMultiDictTests, unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return MutableMultiDict(*args, **kwargs)\n\n\nclass CaseInsensitiveMutableMultiDictTests(unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return CaseInsensitiveMutableMultiDict(*args, **kwargs)\n\n    def test_getall(self):\n        d = self.make_dict([('KEY', 'value1')], KEY='value2')\n\n        self.assertEqual(d, {'KEY': 'value1'})\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"SOME_KEY\"):\n            d.getall('some_key')\n\n    def test_ctor(self):\n        d = self.make_dict(k1='v1')\n        self.assertEqual('v1', d['K1'])\n\n    def test_add(self):\n        d = self.make_dict()\n        d.add('k1', 'v1')\n        self.assertEqual('v1', d['K1'])\n\n    def test_setitem(self):\n        d = self.make_dict()\n        d['k1'] = 'v1'\n        self.assertEqual('v1', d['K1'])\n\n    def test_delitem(self):\n        d = self.make_dict()\n        d['k1'] = 'v1'\n        self.assertIn('K1', d)\n        del d['k1']\n        self.assertNotIn('K1', d)\n",
            "new_file_content": "import unittest\n\nfrom aiohttp.multidict import \\\n    MultiDict, MutableMultiDict, \\\n    CaseInsensitiveMultiDict, CaseInsensitiveMutableMultiDict\n\n\nclass _BaseTest:\n\n    def make_dict(self, *args, **kwargs):\n        raise NotImplementedError\n\n    def test_instantiate__empty(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n        self.assertEqual(len(d), 0)\n        self.assertEqual(list(d.keys()), [])\n        self.assertEqual(list(d.values()), [])\n        self.assertEqual(list(d.values(getall=True)), [])\n        self.assertEqual(list(d.items()), [])\n        self.assertEqual(list(d.items(getall=True)), [])\n\n        self.assertNotEqual(self.make_dict(), list())\n        with self.assertRaisesRegex(TypeError, \"\\(2 given\\)\"):\n            self.make_dict(('key1', 'value1'), ('key2', 'value2'))\n\n    def test_instantiate__from_arg0(self):\n        d = self.make_dict([('key', 'value1')])\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__from_arg0_dict(self):\n        d = self.make_dict({'key': 'value1'})\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__with_kwargs(self):\n        d = self.make_dict([('key', 'value1')], key2='value2')\n\n        self.assertEqual(d, {'key': 'value1', 'key2': 'value2'})\n        self.assertEqual(len(d), 2)\n        self.assertEqual(sorted(d.keys()), ['key', 'key2'])\n        self.assertEqual(sorted(d.values()), ['value1', 'value2'])\n        self.assertEqual(sorted(d.items()), [('key', 'value1'),\n                                             ('key2', 'value2')])\n\n    def test_getone(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n        with self.assertRaises(KeyError):\n            self.assertEqual(d.getone('key'), 'value1')\n        self.assertEqual(d.get('key'), 'value1')\n        self.assertEqual(d['key'], 'value1')\n\n        with self.assertRaises(KeyError):\n            d['key2']\n        with self.assertRaises(KeyError):\n            d.getone('key2')\n\n    def test_copy(self):\n        d1 = self.make_dict(key='value', a='b')\n\n        d2 = d1.copy()\n        self.assertEqual(d1, d2)\n        self.assertIsNot(d1, d2)\n\n    def test_values__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.values()), ['one'])\n        self.assertEqual(list(d.values(getall=True)), ['one', 'two', 3])\n\n        self.assertIn('one', d.values())\n        self.assertNotIn('two', d.values())\n        self.assertNotIn(3, d.values())\n\n        self.assertIn('one', d.values(getall=True))\n        self.assertIn('two', d.values(getall=True))\n        self.assertIn(3, d.values(getall=True))\n\n        self.assertNotIn('foo', d.values())\n        self.assertNotIn('foo', d.values(getall=True))\n\n    def test_items__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.items()), [('key', 'one')])\n        self.assertEqual(list(d.items(getall=True)),\n                         [('key', 'one'), ('key', 'two'), ('key', 3)])\n\n        self.assertIn(('key', 'one'), d.items())\n        self.assertNotIn(('key', 'two'), d.items())\n        self.assertNotIn(('key', 3), d.items())\n\n        self.assertIn(('key', 'one'), d.items(getall=True))\n        self.assertIn(('key', 'two'), d.items(getall=True))\n        self.assertIn(('key', 3), d.items(getall=True))\n\n        self.assertNotIn(('foo', 'bar'), d.items())\n        self.assertNotIn(('foo', 'bar'), d.items(getall=True))\n\n\nclass MultiDictTests(_BaseTest, unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return MultiDict(*args, **kwargs)\n\n    def test__repr__(self):\n        d = self.make_dict()\n        self.assertEqual(str(d), \"<MultiDict>\\n[]\")\n        d = self.make_dict([('key', 'one'), ('key', 'two')])\n        self.assertEqual(str(d),\n                         \"<MultiDict>\\n[('key', 'one'), ('key', 'two')]\")\n\n    def test_getall(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"some_key\"):\n            d.getall('some_key')\n\n        default = object()\n        self.assertIs(d.getall('some_key', default), default)\n\n\nclass CaseInsensitiveMultiDictTests(unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return CaseInsensitiveMultiDict(*args, **kwargs)\n\n    def test_basics(self):\n        d = self.make_dict([('KEY', 'value1')], KEY='value2')\n        with self.assertRaises(KeyError):\n            self.assertEqual(d.getone('key'), 'value1')\n        self.assertEqual(d.get('key'), 'value1')\n        self.assertEqual(d.get('key2', 'val'), 'val')\n        self.assertEqual(d['key'], 'value1')\n        self.assertIn('key', d)\n\n        with self.assertRaises(KeyError):\n            d['key2']\n        with self.assertRaises(KeyError):\n            d.getone('key2')\n\n    def test_getall(self):\n        d = self.make_dict([('KEY', 'value1')], KEY='value2')\n\n        self.assertEqual(d, {'KEY': 'value1'})\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"SOME_KEY\"):\n            d.getall('some_key')\n\n\nclass _BaseMutableMultiDictTests(_BaseTest):\n\n    def test__repr__(self):\n        d = self.make_dict()\n        self.assertEqual(str(d), \"<MutableMultiDict>\\n[]\")\n\n        d = self.make_dict([('key', 'one'), ('key', 'two')])\n\n        self.assertEqual(\n            str(d),\n            \"<MutableMultiDict>\\n[('key', 'one'), ('key', 'two')]\")\n\n    def test_getall(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"some_key\"):\n            d.getall('some_key')\n\n        default = object()\n        self.assertIs(d.getall('some_key', default), default)\n\n    def test_add(self):\n        d = self.make_dict()\n\n        self.assertEqual(d, {})\n        d['key'] = 'one'\n        self.assertEqual(d, {'key': 'one'})\n        self.assertEqual(d.getall('key'), ('one',))\n\n        d['key'] = 'two'\n        self.assertEqual(d, {'key': 'two'})\n        self.assertEqual(d.getall('key'), ('two',))\n\n        d.add('key', 'one')\n        self.assertEqual(d, {'key': 'two'})\n        self.assertEqual(d.getall('key'), ('two', 'one'))\n\n        d.add('foo', 'bar')\n        self.assertEqual(d, {'key': 'two', 'foo': 'bar'})\n        self.assertEqual(d.getall('foo'), ('bar',))\n\n    def test_extend(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n\n        d.extend([('key', 'one'), ('key', 'two')], key=3, foo='bar')\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar'})\n        itms = d.items(getall=True)\n        # we can't guarantee order of kwargs\n        self.assertTrue(('key', 'one') in itms)\n        self.assertTrue(('key', 'two') in itms)\n        self.assertTrue(('key', 3) in itms)\n        self.assertTrue(('foo', 'bar') in itms)\n\n        other = self.make_dict(bar='baz')\n        self.assertEqual(other, {'bar': 'baz'})\n\n        d.extend(other)\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar', 'bar': 'baz'})\n        self.assertIn(('bar', 'baz'), d.items(getall=True))\n\n        d.extend({'foo': 'moo'})\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar', 'bar': 'baz'})\n        self.assertIn(('foo', 'moo'), d.items(getall=True))\n\n        d.extend()\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar', 'bar': 'baz'})\n\n        with self.assertRaises(TypeError):\n            d.extend('foo', 'bar')\n\n    def test_clear(self):\n        d = self.make_dict([('key', 'one')], key='two', foo='bar')\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar'})\n\n        d.clear()\n        self.assertEqual(d, {})\n        self.assertEqual(list(d.items(getall=True)), [])\n\n    def test_del(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two')], foo='bar')\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar'})\n\n        del d['key']\n        self.assertEqual(d, {'foo': 'bar'})\n        self.assertEqual(list(d.items(getall=True)), [('foo', 'bar')])\n\n        with self.assertRaises(KeyError):\n            del d['key']\n\n    def test_not_implemented_methods(self):\n        d = self.make_dict()\n\n        with self.assertRaises(NotImplementedError):\n            d.pop('foo')\n        with self.assertRaises(NotImplementedError):\n            d.popitem()\n        with self.assertRaises(NotImplementedError):\n            d.update(bar='baz')\n\n\nclass MutableMultiDictTests(_BaseMutableMultiDictTests, unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return MutableMultiDict(*args, **kwargs)\n\n\nclass CaseInsensitiveMutableMultiDictTests(unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return CaseInsensitiveMutableMultiDict(*args, **kwargs)\n\n    def test_getall(self):\n        d = self.make_dict([('KEY', 'value1')], KEY='value2')\n\n        self.assertEqual(d, {'KEY': 'value1'})\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"SOME_KEY\"):\n            d.getall('some_key')\n\n    def test_ctor(self):\n        d = self.make_dict(k1='v1')\n        self.assertEqual('v1', d['K1'])\n\n    def test_add(self):\n        d = self.make_dict()\n        d.add('k1', 'v1')\n        self.assertEqual('v1', d['K1'])\n\n    def test_setitem(self):\n        d = self.make_dict()\n        d['k1'] = 'v1'\n        self.assertEqual('v1', d['K1'])\n\n    def test_delitem(self):\n        d = self.make_dict()\n        d['k1'] = 'v1'\n        self.assertIn('K1', d)\n        del d['k1']\n        self.assertNotIn('K1', d)\n",
            "header": {
                "file": {
                    "path": "tests/test_multidict.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "cc81ed84",
                "new_commit_hash": "ec3d898b",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/tests/test_multidict.py"
            },
            "plus_file": {
                "path": "b/tests/test_multidict.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 21,
                            "length": 7
                        },
                        "new_range": {
                            "start": 21,
                            "length": 7
                        },
                        "section": "class _BaseTest:"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        self.assertEqual(list(d.items(getall=True)), [])",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertNotEqual(self.make_dict(), list())",
                                "type": "context"
                            },
                            {
                                "content": "        with self.assertRaisesRegex(TypeError, \"\\(3 given\\)\"):",
                                "type": "deleted"
                            },
                            {
                                "content": "        with self.assertRaisesRegex(TypeError, \"\\(2 given\\)\"):",
                                "type": "added"
                            },
                            {
                                "content": "            self.make_dict(('key1', 'value1'), ('key2', 'value2'))",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_instantiate__from_arg0(self):",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "tests/test_multidict.py",
                            "type": "method",
                            "name": "_BaseTest.test_instantiate__empty",
                            "content": "class _BaseTest:\n\n    def make_dict(self, *args, **kwargs):\n        raise NotImplementedError\n\n    def test_instantiate__empty(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n        self.assertEqual(len(d), 0)\n        self.assertEqual(list(d.keys()), [])\n        self.assertEqual(list(d.values()), [])\n        self.assertEqual(list(d.values(getall=True)), [])\n        self.assertEqual(list(d.items()), [])\n        self.assertEqual(list(d.items(getall=True)), [])\n\n        self.assertNotEqual(self.make_dict(), list())\n        with self.assertRaisesRegex(TypeError, \"\\(3 given\\)\"):\n            self.make_dict(('key1', 'value1'), ('key2', 'value2'))\n\n    def test_instantiate__from_arg0(self):\n        d = self.make_dict([('key', 'value1')])\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__from_arg0_dict(self):\n        d = self.make_dict({'key': 'value1'})\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__with_kwargs(self):\n        d = self.make_dict([('key', 'value1')], key2='value2')\n\n        self.assertEqual(d, {'key': 'value1', 'key2': 'value2'})\n        self.assertEqual(len(d), 2)\n        self.assertEqual(sorted(d.keys()), ['key', 'key2'])\n        self.assertEqual(sorted(d.values()), ['value1', 'value2'])\n        self.assertEqual(sorted(d.items()), [('key', 'value1'),\n                                             ('key2', 'value2')])\n\n    def test_getone(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n        with self.assertRaises(KeyError):\n            self.assertEqual(d.getone('key'), 'value1')\n        self.assertEqual(d.get('key'), 'value1')\n        self.assertEqual(d['key'], 'value1')\n\n        with self.assertRaises(KeyError):\n            d['key2']\n        with self.assertRaises(KeyError):\n            d.getone('key2')\n\n    def test_copy(self):\n        d1 = self.make_dict(key='value', a='b')\n\n        d2 = d1.copy()\n        self.assertEqual(d1, d2)\n        self.assertIsNot(d1, d2)\n\n    def test_values__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.values()), ['one'])\n        self.assertEqual(list(d.values(getall=True)), ['one', 'two', 3])\n\n        self.assertIn('one', d.values())\n        self.assertNotIn('two', d.values())\n        self.assertNotIn(3, d.values())\n\n        self.assertIn('one', d.values(getall=True))\n        self.assertIn('two', d.values(getall=True))\n        self.assertIn(3, d.values(getall=True))\n\n        self.assertNotIn('foo', d.values())\n        self.assertNotIn('foo', d.values(getall=True))\n\n    def test_items__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.items()), [('key', 'one')])\n        self.assertEqual(list(d.items(getall=True)),\n                         [('key', 'one'), ('key', 'two'), ('key', 3)])\n\n        self.assertIn(('key', 'one'), d.items())\n        self.assertNotIn(('key', 'two'), d.items())\n        self.assertNotIn(('key', 3), d.items())\n\n        self.assertIn(('key', 'one'), d.items(getall=True))\n        self.assertIn(('key', 'two'), d.items(getall=True))\n        self.assertIn(('key', 3), d.items(getall=True))\n\n        self.assertNotIn(('foo', 'bar'), d.items())\n        self.assertNotIn(('foo', 'bar'), d.items(getall=True))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 13,
                            "end_lineno": 25,
                            "parent": {
                                "file_name": "tests/test_multidict.py",
                                "type": "class",
                                "name": "_BaseTest",
                                "content": "class _BaseTest:\n\n    def make_dict(self, *args, **kwargs):\n        raise NotImplementedError\n\n    def test_instantiate__empty(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n        self.assertEqual(len(d), 0)\n        self.assertEqual(list(d.keys()), [])\n        self.assertEqual(list(d.values()), [])\n        self.assertEqual(list(d.values(getall=True)), [])\n        self.assertEqual(list(d.items()), [])\n        self.assertEqual(list(d.items(getall=True)), [])\n\n        self.assertNotEqual(self.make_dict(), list())\n        with self.assertRaisesRegex(TypeError, \"\\(3 given\\)\"):\n            self.make_dict(('key1', 'value1'), ('key2', 'value2'))\n\n    def test_instantiate__from_arg0(self):\n        d = self.make_dict([('key', 'value1')])\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__from_arg0_dict(self):\n        d = self.make_dict({'key': 'value1'})\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__with_kwargs(self):\n        d = self.make_dict([('key', 'value1')], key2='value2')\n\n        self.assertEqual(d, {'key': 'value1', 'key2': 'value2'})\n        self.assertEqual(len(d), 2)\n        self.assertEqual(sorted(d.keys()), ['key', 'key2'])\n        self.assertEqual(sorted(d.values()), ['value1', 'value2'])\n        self.assertEqual(sorted(d.items()), [('key', 'value1'),\n                                             ('key2', 'value2')])\n\n    def test_getone(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n        with self.assertRaises(KeyError):\n            self.assertEqual(d.getone('key'), 'value1')\n        self.assertEqual(d.get('key'), 'value1')\n        self.assertEqual(d['key'], 'value1')\n\n        with self.assertRaises(KeyError):\n            d['key2']\n        with self.assertRaises(KeyError):\n            d.getone('key2')\n\n    def test_copy(self):\n        d1 = self.make_dict(key='value', a='b')\n\n        d2 = d1.copy()\n        self.assertEqual(d1, d2)\n        self.assertIsNot(d1, d2)\n\n    def test_values__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.values()), ['one'])\n        self.assertEqual(list(d.values(getall=True)), ['one', 'two', 3])\n\n        self.assertIn('one', d.values())\n        self.assertNotIn('two', d.values())\n        self.assertNotIn(3, d.values())\n\n        self.assertIn('one', d.values(getall=True))\n        self.assertIn('two', d.values(getall=True))\n        self.assertIn(3, d.values(getall=True))\n\n        self.assertNotIn('foo', d.values())\n        self.assertNotIn('foo', d.values(getall=True))\n\n    def test_items__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.items()), [('key', 'one')])\n        self.assertEqual(list(d.items(getall=True)),\n                         [('key', 'one'), ('key', 'two'), ('key', 3)])\n\n        self.assertIn(('key', 'one'), d.items())\n        self.assertNotIn(('key', 'two'), d.items())\n        self.assertNotIn(('key', 3), d.items())\n\n        self.assertIn(('key', 'one'), d.items(getall=True))\n        self.assertIn(('key', 'two'), d.items(getall=True))\n        self.assertIn(('key', 3), d.items(getall=True))\n\n        self.assertNotIn(('foo', 'bar'), d.items())\n        self.assertNotIn(('foo', 'bar'), d.items(getall=True))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 8,
                                "end_lineno": 109,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "tests/test_multidict.py",
                            "type": "class",
                            "name": "_BaseTest",
                            "content": "class _BaseTest:\n\n    def make_dict(self, *args, **kwargs):\n        raise NotImplementedError\n\n    def test_instantiate__empty(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n        self.assertEqual(len(d), 0)\n        self.assertEqual(list(d.keys()), [])\n        self.assertEqual(list(d.values()), [])\n        self.assertEqual(list(d.values(getall=True)), [])\n        self.assertEqual(list(d.items()), [])\n        self.assertEqual(list(d.items(getall=True)), [])\n\n        self.assertNotEqual(self.make_dict(), list())\n        with self.assertRaisesRegex(TypeError, \"\\(3 given\\)\"):\n            self.make_dict(('key1', 'value1'), ('key2', 'value2'))\n\n    def test_instantiate__from_arg0(self):\n        d = self.make_dict([('key', 'value1')])\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__from_arg0_dict(self):\n        d = self.make_dict({'key': 'value1'})\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__with_kwargs(self):\n        d = self.make_dict([('key', 'value1')], key2='value2')\n\n        self.assertEqual(d, {'key': 'value1', 'key2': 'value2'})\n        self.assertEqual(len(d), 2)\n        self.assertEqual(sorted(d.keys()), ['key', 'key2'])\n        self.assertEqual(sorted(d.values()), ['value1', 'value2'])\n        self.assertEqual(sorted(d.items()), [('key', 'value1'),\n                                             ('key2', 'value2')])\n\n    def test_getone(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n        with self.assertRaises(KeyError):\n            self.assertEqual(d.getone('key'), 'value1')\n        self.assertEqual(d.get('key'), 'value1')\n        self.assertEqual(d['key'], 'value1')\n\n        with self.assertRaises(KeyError):\n            d['key2']\n        with self.assertRaises(KeyError):\n            d.getone('key2')\n\n    def test_copy(self):\n        d1 = self.make_dict(key='value', a='b')\n\n        d2 = d1.copy()\n        self.assertEqual(d1, d2)\n        self.assertIsNot(d1, d2)\n\n    def test_values__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.values()), ['one'])\n        self.assertEqual(list(d.values(getall=True)), ['one', 'two', 3])\n\n        self.assertIn('one', d.values())\n        self.assertNotIn('two', d.values())\n        self.assertNotIn(3, d.values())\n\n        self.assertIn('one', d.values(getall=True))\n        self.assertIn('two', d.values(getall=True))\n        self.assertIn(3, d.values(getall=True))\n\n        self.assertNotIn('foo', d.values())\n        self.assertNotIn('foo', d.values(getall=True))\n\n    def test_items__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.items()), [('key', 'one')])\n        self.assertEqual(list(d.items(getall=True)),\n                         [('key', 'one'), ('key', 'two'), ('key', 3)])\n\n        self.assertIn(('key', 'one'), d.items())\n        self.assertNotIn(('key', 'two'), d.items())\n        self.assertNotIn(('key', 3), d.items())\n\n        self.assertIn(('key', 'one'), d.items(getall=True))\n        self.assertIn(('key', 'two'), d.items(getall=True))\n        self.assertIn(('key', 3), d.items(getall=True))\n\n        self.assertNotIn(('foo', 'bar'), d.items())\n        self.assertNotIn(('foo', 'bar'), d.items(getall=True))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 8,
                            "end_lineno": 109,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "a076bea6894928c2b91d8547d5e9a77e1715985d^",
    "new_commit_hash": "a076bea6894928c2b91d8547d5e9a77e1715985d",
    "commit_message": "Fix error message",
    "commit_date": "2014-11-04T18:48:43+02:00",
    "metadata": {}
}
{
    "repo_name": "aiohttp",
    "new_commit_hash": "a076bea6894928c2b91d8547d5e9a77e1715985d",
    "test_file_codes": [
        "import unittest\n\nfrom aiohttp.multidict import \\\n    MultiDict, MutableMultiDict, \\\n    CaseInsensitiveMultiDict, CaseInsensitiveMutableMultiDict\n\n\nclass _BaseTest:\n\n    def make_dict(self, *args, **kwargs):\n        raise NotImplementedError\n\n    def test_instantiate__empty(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n        self.assertEqual(len(d), 0)\n        self.assertEqual(list(d.keys()), [])\n        self.assertEqual(list(d.values()), [])\n        self.assertEqual(list(d.values(getall=True)), [])\n        self.assertEqual(list(d.items()), [])\n        self.assertEqual(list(d.items(getall=True)), [])\n\n        self.assertNotEqual(self.make_dict(), list())\n        with self.assertRaisesRegex(TypeError, \"\\(2 given\\)\"):\n            self.make_dict(('key1', 'value1'), ('key2', 'value2'))\n\n    def test_instantiate__from_arg0(self):\n        d = self.make_dict([('key', 'value1')])\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__from_arg0_dict(self):\n        d = self.make_dict({'key': 'value1'})\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 1)\n        self.assertEqual(list(d.keys()), ['key'])\n        self.assertEqual(list(d.values()), ['value1'])\n        self.assertEqual(list(d.values(getall=True)), ['value1'])\n        self.assertEqual(list(d.items()), [('key', 'value1')])\n        self.assertEqual(list(d.items(getall=True)), [('key', 'value1')])\n\n    def test_instantiate__with_kwargs(self):\n        d = self.make_dict([('key', 'value1')], key2='value2')\n\n        self.assertEqual(d, {'key': 'value1', 'key2': 'value2'})\n        self.assertEqual(len(d), 2)\n        self.assertEqual(sorted(d.keys()), ['key', 'key2'])\n        self.assertEqual(sorted(d.values()), ['value1', 'value2'])\n        self.assertEqual(sorted(d.items()), [('key', 'value1'),\n                                             ('key2', 'value2')])\n\n    def test_getone(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n        with self.assertRaises(KeyError):\n            self.assertEqual(d.getone('key'), 'value1')\n        self.assertEqual(d.get('key'), 'value1')\n        self.assertEqual(d['key'], 'value1')\n\n        with self.assertRaises(KeyError):\n            d['key2']\n        with self.assertRaises(KeyError):\n            d.getone('key2')\n\n    def test_copy(self):\n        d1 = self.make_dict(key='value', a='b')\n\n        d2 = d1.copy()\n        self.assertEqual(d1, d2)\n        self.assertIsNot(d1, d2)\n\n    def test_values__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.values()), ['one'])\n        self.assertEqual(list(d.values(getall=True)), ['one', 'two', 3])\n\n        self.assertIn('one', d.values())\n        self.assertNotIn('two', d.values())\n        self.assertNotIn(3, d.values())\n\n        self.assertIn('one', d.values(getall=True))\n        self.assertIn('two', d.values(getall=True))\n        self.assertIn(3, d.values(getall=True))\n\n        self.assertNotIn('foo', d.values())\n        self.assertNotIn('foo', d.values(getall=True))\n\n    def test_items__contains(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two'), ('key', 3)])\n        self.assertEqual(list(d.items()), [('key', 'one')])\n        self.assertEqual(list(d.items(getall=True)),\n                         [('key', 'one'), ('key', 'two'), ('key', 3)])\n\n        self.assertIn(('key', 'one'), d.items())\n        self.assertNotIn(('key', 'two'), d.items())\n        self.assertNotIn(('key', 3), d.items())\n\n        self.assertIn(('key', 'one'), d.items(getall=True))\n        self.assertIn(('key', 'two'), d.items(getall=True))\n        self.assertIn(('key', 3), d.items(getall=True))\n\n        self.assertNotIn(('foo', 'bar'), d.items())\n        self.assertNotIn(('foo', 'bar'), d.items(getall=True))\n\n\nclass MultiDictTests(_BaseTest, unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return MultiDict(*args, **kwargs)\n\n    def test__repr__(self):\n        d = self.make_dict()\n        self.assertEqual(str(d), \"<MultiDict>\\n[]\")\n        d = self.make_dict([('key', 'one'), ('key', 'two')])\n        self.assertEqual(str(d),\n                         \"<MultiDict>\\n[('key', 'one'), ('key', 'two')]\")\n\n    def test_getall(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n\n        self.assertEqual(d, {'key': 'value1'})\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"some_key\"):\n            d.getall('some_key')\n\n        default = object()\n        self.assertIs(d.getall('some_key', default), default)\n\n\nclass CaseInsensitiveMultiDictTests(unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return CaseInsensitiveMultiDict(*args, **kwargs)\n\n    def test_basics(self):\n        d = self.make_dict([('KEY', 'value1')], KEY='value2')\n        with self.assertRaises(KeyError):\n            self.assertEqual(d.getone('key'), 'value1')\n        self.assertEqual(d.get('key'), 'value1')\n        self.assertEqual(d.get('key2', 'val'), 'val')\n        self.assertEqual(d['key'], 'value1')\n        self.assertIn('key', d)\n\n        with self.assertRaises(KeyError):\n            d['key2']\n        with self.assertRaises(KeyError):\n            d.getone('key2')\n\n    def test_getall(self):\n        d = self.make_dict([('KEY', 'value1')], KEY='value2')\n\n        self.assertEqual(d, {'KEY': 'value1'})\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"SOME_KEY\"):\n            d.getall('some_key')\n\n\nclass _BaseMutableMultiDictTests(_BaseTest):\n\n    def test__repr__(self):\n        d = self.make_dict()\n        self.assertEqual(str(d), \"<MutableMultiDict>\\n[]\")\n\n        d = self.make_dict([('key', 'one'), ('key', 'two')])\n\n        self.assertEqual(\n            str(d),\n            \"<MutableMultiDict>\\n[('key', 'one'), ('key', 'two')]\")\n\n    def test_getall(self):\n        d = self.make_dict([('key', 'value1')], key='value2')\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"some_key\"):\n            d.getall('some_key')\n\n        default = object()\n        self.assertIs(d.getall('some_key', default), default)\n\n    def test_add(self):\n        d = self.make_dict()\n\n        self.assertEqual(d, {})\n        d['key'] = 'one'\n        self.assertEqual(d, {'key': 'one'})\n        self.assertEqual(d.getall('key'), ('one',))\n\n        d['key'] = 'two'\n        self.assertEqual(d, {'key': 'two'})\n        self.assertEqual(d.getall('key'), ('two',))\n\n        d.add('key', 'one')\n        self.assertEqual(d, {'key': 'two'})\n        self.assertEqual(d.getall('key'), ('two', 'one'))\n\n        d.add('foo', 'bar')\n        self.assertEqual(d, {'key': 'two', 'foo': 'bar'})\n        self.assertEqual(d.getall('foo'), ('bar',))\n\n    def test_extend(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n\n        d.extend([('key', 'one'), ('key', 'two')], key=3, foo='bar')\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar'})\n        itms = d.items(getall=True)\n        # we can't guarantee order of kwargs\n        self.assertTrue(('key', 'one') in itms)\n        self.assertTrue(('key', 'two') in itms)\n        self.assertTrue(('key', 3) in itms)\n        self.assertTrue(('foo', 'bar') in itms)\n\n        other = self.make_dict(bar='baz')\n        self.assertEqual(other, {'bar': 'baz'})\n\n        d.extend(other)\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar', 'bar': 'baz'})\n        self.assertIn(('bar', 'baz'), d.items(getall=True))\n\n        d.extend({'foo': 'moo'})\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar', 'bar': 'baz'})\n        self.assertIn(('foo', 'moo'), d.items(getall=True))\n\n        d.extend()\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar', 'bar': 'baz'})\n\n        with self.assertRaises(TypeError):\n            d.extend('foo', 'bar')\n\n    def test_clear(self):\n        d = self.make_dict([('key', 'one')], key='two', foo='bar')\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar'})\n\n        d.clear()\n        self.assertEqual(d, {})\n        self.assertEqual(list(d.items(getall=True)), [])\n\n    def test_del(self):\n        d = self.make_dict([('key', 'one'), ('key', 'two')], foo='bar')\n        self.assertEqual(d, {'key': 'one', 'foo': 'bar'})\n\n        del d['key']\n        self.assertEqual(d, {'foo': 'bar'})\n        self.assertEqual(list(d.items(getall=True)), [('foo', 'bar')])\n\n        with self.assertRaises(KeyError):\n            del d['key']\n\n    def test_not_implemented_methods(self):\n        d = self.make_dict()\n\n        with self.assertRaises(NotImplementedError):\n            d.pop('foo')\n        with self.assertRaises(NotImplementedError):\n            d.popitem()\n        with self.assertRaises(NotImplementedError):\n            d.update(bar='baz')\n\n\nclass MutableMultiDictTests(_BaseMutableMultiDictTests, unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return MutableMultiDict(*args, **kwargs)\n\n\nclass CaseInsensitiveMutableMultiDictTests(unittest.TestCase):\n\n    def make_dict(self, *args, **kwargs):\n        return CaseInsensitiveMutableMultiDict(*args, **kwargs)\n\n    def test_getall(self):\n        d = self.make_dict([('KEY', 'value1')], KEY='value2')\n\n        self.assertEqual(d, {'KEY': 'value1'})\n        self.assertEqual(len(d), 2)\n\n        self.assertEqual(d.getall('key'), ('value1', 'value2'))\n\n        with self.assertRaisesRegex(KeyError, \"SOME_KEY\"):\n            d.getall('some_key')\n\n    def test_ctor(self):\n        d = self.make_dict(k1='v1')\n        self.assertEqual('v1', d['K1'])\n\n    def test_add(self):\n        d = self.make_dict()\n        d.add('k1', 'v1')\n        self.assertEqual('v1', d['K1'])\n\n    def test_setitem(self):\n        d = self.make_dict()\n        d['k1'] = 'v1'\n        self.assertEqual('v1', d['K1'])\n\n    def test_delitem(self):\n        d = self.make_dict()\n        d['k1'] = 'v1'\n        self.assertIn('K1', d)\n        del d['k1']\n        self.assertNotIn('K1', d)\n"
    ],
    "test_file_names": [
        "test_1.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Transforming aiohttp/worker.py\nTransforming aiohttp/server.py\nTransforming aiohttp/client.py\n",
    "setup_res_stderr": "Using CPython 3.9.21\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nmake: *** No rule to make target '.develop'.  Stop.\nResolved 26 packages in 25ms\nInstalled 26 packages in 31ms\n + async-generator==1.10\n + async-timeout==5.0.1\n + brotlipy==0.7.0\n + cffi==1.17.1\n + chardet==5.2.0\n + coverage==7.6.10\n + cryptography==44.0.0\n + cython==3.0.11\n + exceptiongroup==1.2.2\n + gunicorn==23.0.0\n + idna==3.10\n + iniconfig==2.0.0\n + multdict==0.0.5\n + multidict==6.1.0\n + packaging==24.2\n + pluggy==1.5.0\n + propcache==0.2.1\n + pycparser==2.22\n + pytest==8.3.4\n + pytest-asyncio==0.25.0\n + pytest-cov==6.0.0\n + pytest-mock==3.14.0\n + tomli==2.2.1\n + trustme==1.2.1\n + typing-extensions==4.12.2\n + yarl==1.18.3\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.3.4, pluggy-1.5.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_a076bea6894928c2b91d8547d5e9a77e1715985d\nplugins: asyncio-0.25.0, mock-3.14.0, cov-6.0.0\nasyncio: mode=strict, asyncio_default_fixture_loop_scope=None\ncollected 32 items\n\nr2e_tests/test_1.py ................................                     [100%]\n\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::MultiDictTests::test__repr__\nPASSED r2e_tests/test_1.py::MultiDictTests::test_copy\nPASSED r2e_tests/test_1.py::MultiDictTests::test_getall\nPASSED r2e_tests/test_1.py::MultiDictTests::test_getone\nPASSED r2e_tests/test_1.py::MultiDictTests::test_instantiate__empty\nPASSED r2e_tests/test_1.py::MultiDictTests::test_instantiate__from_arg0\nPASSED r2e_tests/test_1.py::MultiDictTests::test_instantiate__from_arg0_dict\nPASSED r2e_tests/test_1.py::MultiDictTests::test_instantiate__with_kwargs\nPASSED r2e_tests/test_1.py::MultiDictTests::test_items__contains\nPASSED r2e_tests/test_1.py::MultiDictTests::test_values__contains\nPASSED r2e_tests/test_1.py::CaseInsensitiveMultiDictTests::test_basics\nPASSED r2e_tests/test_1.py::CaseInsensitiveMultiDictTests::test_getall\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test__repr__\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_add\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_clear\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_copy\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_del\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_extend\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_getall\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_getone\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_instantiate__empty\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_instantiate__from_arg0\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_instantiate__from_arg0_dict\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_instantiate__with_kwargs\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_items__contains\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_not_implemented_methods\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_values__contains\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_add\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_ctor\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_delitem\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_getall\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_setitem\n============================== 32 passed in 0.41s ==============================\n",
    "new_commit_res_stderr": "/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_a076bea6894928c2b91d8547d5e9a77e1715985d/.venv/lib/python3.9/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option \"asyncio_default_fixture_loop_scope\" is unset.\nThe event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: \"function\", \"class\", \"module\", \"package\", \"session\"\n\n  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))\n",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.3.4, pluggy-1.5.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_a076bea6894928c2b91d8547d5e9a77e1715985d\nplugins: asyncio-0.25.0, mock-3.14.0, cov-6.0.0\nasyncio: mode=strict, asyncio_default_fixture_loop_scope=None\ncollected 32 items\n\nr2e_tests/test_1.py ....F...............F...........                     [100%]\n\n=================================== FAILURES ===================================\n____________________ MultiDictTests.test_instantiate__empty ____________________\nTypeError: MultiDict takes at most 2 positional arguments (3 given)\n\nDuring handling of the above exception, another exception occurred:\n\nself = <r2e_tests.test_1.MultiDictTests testMethod=test_instantiate__empty>\n\n    def test_instantiate__empty(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n        self.assertEqual(len(d), 0)\n        self.assertEqual(list(d.keys()), [])\n        self.assertEqual(list(d.values()), [])\n        self.assertEqual(list(d.values(getall=True)), [])\n        self.assertEqual(list(d.items()), [])\n        self.assertEqual(list(d.items(getall=True)), [])\n    \n        self.assertNotEqual(self.make_dict(), list())\n        with self.assertRaisesRegex(TypeError, \"\\(2 given\\)\"):\n>           self.make_dict(('key1', 'value1'), ('key2', 'value2'))\nE           AssertionError: \"\\(2 given\\)\" does not match \"MultiDict takes at most 2 positional arguments (3 given)\"\n\nr2e_tests/test_1.py:25: AssertionError\n________________ MutableMultiDictTests.test_instantiate__empty _________________\nTypeError: MultiDict takes at most 2 positional arguments (3 given)\n\nDuring handling of the above exception, another exception occurred:\n\nself = <r2e_tests.test_1.MutableMultiDictTests testMethod=test_instantiate__empty>\n\n    def test_instantiate__empty(self):\n        d = self.make_dict()\n        self.assertEqual(d, {})\n        self.assertEqual(len(d), 0)\n        self.assertEqual(list(d.keys()), [])\n        self.assertEqual(list(d.values()), [])\n        self.assertEqual(list(d.values(getall=True)), [])\n        self.assertEqual(list(d.items()), [])\n        self.assertEqual(list(d.items(getall=True)), [])\n    \n        self.assertNotEqual(self.make_dict(), list())\n        with self.assertRaisesRegex(TypeError, \"\\(2 given\\)\"):\n>           self.make_dict(('key1', 'value1'), ('key2', 'value2'))\nE           AssertionError: \"\\(2 given\\)\" does not match \"MultiDict takes at most 2 positional arguments (3 given)\"\n\nr2e_tests/test_1.py:25: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::MultiDictTests::test__repr__\nPASSED r2e_tests/test_1.py::MultiDictTests::test_copy\nPASSED r2e_tests/test_1.py::MultiDictTests::test_getall\nPASSED r2e_tests/test_1.py::MultiDictTests::test_getone\nPASSED r2e_tests/test_1.py::MultiDictTests::test_instantiate__from_arg0\nPASSED r2e_tests/test_1.py::MultiDictTests::test_instantiate__from_arg0_dict\nPASSED r2e_tests/test_1.py::MultiDictTests::test_instantiate__with_kwargs\nPASSED r2e_tests/test_1.py::MultiDictTests::test_items__contains\nPASSED r2e_tests/test_1.py::MultiDictTests::test_values__contains\nPASSED r2e_tests/test_1.py::CaseInsensitiveMultiDictTests::test_basics\nPASSED r2e_tests/test_1.py::CaseInsensitiveMultiDictTests::test_getall\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test__repr__\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_add\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_clear\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_copy\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_del\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_extend\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_getall\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_getone\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_instantiate__from_arg0\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_instantiate__from_arg0_dict\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_instantiate__with_kwargs\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_items__contains\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_not_implemented_methods\nPASSED r2e_tests/test_1.py::MutableMultiDictTests::test_values__contains\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_add\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_ctor\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_delitem\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_getall\nPASSED r2e_tests/test_1.py::CaseInsensitiveMutableMultiDictTests::test_setitem\nFAILED r2e_tests/test_1.py::MultiDictTests::test_instantiate__empty - Asserti...\nFAILED r2e_tests/test_1.py::MutableMultiDictTests::test_instantiate__empty - ...\n========================= 2 failed, 30 passed in 0.16s =========================\n",
    "old_commit_res_stderr": "/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_a076bea6894928c2b91d8547d5e9a77e1715985d/.venv/lib/python3.9/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option \"asyncio_default_fixture_loop_scope\" is unset.\nThe event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: \"function\", \"class\", \"module\", \"package\", \"session\"\n\n  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))\n"
}
aiohttp/multidict.py tests/test_multidict.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** Incorrect TypeError Message When Initializing MultiDict with Multiple Arguments

**Description:**
When creating an instance of `MultiDict` with multiple positional arguments, the raised `TypeError` incorrectly reports the number of arguments provided. This misleading error message can confuse developers about the actual number of arguments passed.

**Example Code:**
```python
from aiohttp.multidict import MultiDict

# Attempting to initialize MultiDict with two positional arguments
d = MultiDict(('key1', 'value1'), ('key2', 'value2'))
```

**Expected Behavior:**
A `TypeError` should be raised with a message indicating that only 2 positional arguments were given, matching the number of arguments actually passed.

**Actual Behavior:**
A `TypeError` is raised with the message:
```
TypeError: MultiDict takes at most 2 positional arguments (3 given)
```
This incorrectly suggests that three arguments were provided when only two were passed.

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

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

--- BEGIN FILE ---
```
### aiohttp/multidict.py
import pprint
from itertools import chain
from collections import abc

_marker = object()


class MultiDict(abc.Mapping):
    """Read-only ordered dictionary that can have multiple values for each key.

    This type of MultiDict must be used for request headers and query args.
    """

    __slots__ = ('_items',)

    def __init__(self, *args, **kwargs):
        if len(args) > 1:
            raise TypeError("MultiDict takes at most 2 positional "
                            "arguments ({} given)".format(len(args) + 1))
        self._items = []
        if args:
            if hasattr(args[0], 'items'):
                args = list(args[0].items())
            else:
                args = list(args[0])
                for arg in args:
                    if not len(arg) == 2:
                        raise TypeError(
                            "MultiDict takes either dict or list of \
                            (key, value) tuples"
                        )

        self._fill(chain(args, kwargs.items()))

    def _fill(self, ipairs):
        self._items.extend(ipairs)

    def getall(self, key, default=_marker):
        """
        Return a list of all values matching the key (may be an empty list)
        """
        res = tuple([v for k, v in self._items if k == key])
        if res:
            return res
        if not res and default != _marker:
            return default
        raise KeyError('Key not found: %r' % key)

    def getone(self, key, default=_marker):
        """
        Get one value matching the key, raising a KeyError if multiple
        values were found.
        """
        v = self.getall(key, default=_marker)
        if len(v) > 1 and v != default:
            raise KeyError('Multiple values match %r: %r' % (key, v))
        return v[0]

    # extra methods #

    def copy(self):
        """Returns a copy itself."""
        cls = self.__class__
        return cls(self.items(getall=True))

    # Mapping interface #

    def __getitem__(self, key):
        for k, v in self._items:
            if k == key:
                return v
        raise KeyError(key)

    def __iter__(self):
        return iter(self._items)

    def __len__(self):
        return len(self._items)

    def keys(self, *, getall=False):
        return _KeysView(self._items, getall=getall)

    def items(self, *, getall=False):
        return _ItemsView(self._items, getall=getall)

    def values(self, *, getall=False):
        return _ValuesView(self._items, getall=getall)

    def __eq__(self, other):
        if not isinstance(other, abc.Mapping):
            return NotImplemented
        if isinstance(other, MultiDict):
            return self._items == other._items
        return dict(self.items()) == dict(other.items())

    def __contains__(self, key):
        for k, v in self._items:
            if k == key:
                return True
        return False

    def __repr__(self):
        return '<{}>\n{}'.format(
            self.__class__.__name__, pprint.pformat(
                list(self.items(getall=True)))
        )


class CaseInsensitiveMultiDict(MultiDict):
    """Case insensitive multi dict."""

    @classmethod
    def _from_uppercase_multidict(cls, dct):
        # NB: doesn't check for uppercase keys!
        ret = cls.__new__(cls)
        ret._items = dct._items
        return ret

    def _fill(self, ipairs):
        for key, value in ipairs:
            uppkey = key.upper()
            self._items.append((uppkey, value))

    def getall(self, key, default=_marker):
        return super().getall(key.upper(), default)

    def getone(self, key, default=_marker):
        return super().getone(key.upper(), default)

    def __getitem__(self, key):
        return super().__getitem__(key.upper())

    def __contains__(self, key):
        return super().__contains__(key.upper())


class MutableMultiDictMixin(abc.MutableMapping):

    def add(self, key, value):
        """
        Add the key and value, not overwriting any previous value.
        """
        self._items.append((key, value))

    def extend(self, *args, **kwargs):
        """Extends current MutableMultiDict with more values.

        This method must be used instead of update.
        """
        if len(args) > 1:
            raise TypeError("extend takes at most 2 positional arguments"
                            " ({} given)".format(len(args) + 1))
        if args:
            if isinstance(args[0], MultiDict):
                items = args[0].items(getall=True)
            elif hasattr(args[0], 'items'):
                items = args[0].items()
            else:
                items = args[0]
        else:
            items = []
        for key, value in chain(items, kwargs.items()):
            self.add(key, value)

    def clear(self):
        """Remove all items from MutableMultiDict"""
        self._items.clear()

    # MutableMapping interface #

    def __setitem__(self, key, value):
        try:
            del self[key]
        except KeyError:
            pass
        self._items.append((key, value))

    def __delitem__(self, key):
        items = self._items
        found = False
        for i in range(len(items)-1, -1, -1):
            if items[i][0] == key:
                del items[i]
                found = True
        if not found:
            raise KeyError(key)

    def pop(self, key, default=None):
        """Method not allowed."""
        raise NotImplementedError

    def popitem(self):
        """Method not allowed."""
        raise NotImplementedError

    def update(self, *args, **kw):
        """Method not allowed."""
        raise NotImplementedError("Use extend method instead")


class MutableMultiDict(MutableMultiDictMixin, MultiDict):
    """An ordered dictionary that can have multiple values for each key."""


class CaseInsensitiveMutableMultiDict(
        MutableMultiDictMixin, CaseInsensitiveMultiDict):
    """An ordered dictionary that can have multiple values for each key."""

    def add(self, key, value):
        super().add(key.upper(), value)

    def __setitem__(self, key, value):
        super().__setitem__(key.upper(), value)

    def __delitem__(self, key):
        super().__delitem__(key.upper())


class _ItemsView(abc.ItemsView):

    def __init__(self, items, *, getall=False):
        self._getall = getall
        self._keys = [item[0] for item in items]
        if not getall:
            self._keys = set(self._keys)

        items_to_use = []
        if getall:
            items_to_use = items
        else:
            for key in self._keys:
                for k, v in items:
                    if k == key:
                        items_to_use.append((k, v))
                        break
        assert len(items_to_use) == len(self._keys)

        super().__init__(items_to_use)

    def __contains__(self, item):
        assert isinstance(item, tuple) or isinstance(item, list)
        assert len(item) == 2
        return item in self._mapping

    def __iter__(self):
        yield from self._mapping


class _ValuesView(abc.ValuesView):

    def __init__(self, items, *, getall=False):
        self._getall = getall
        self._keys = [item[0] for item in items]
        if not getall:
            self._keys = set(self._keys)

        items_to_use = []
        if getall:
            items_to_use = items
        else:
            for key in self._keys:
                for k, v in items:
                    if k == key:
                        items_to_use.append((k, v))
                        break

        assert len(items_to_use) == len(self._keys)

        super().__init__(items_to_use)

    def __contains__(self, value):
        values = [item[1] for item in self._mapping]
        return value in values

    def __iter__(self):
        values = (item[1] for item in self._mapping)
        yield from values


class _KeysView(abc.KeysView):

    def __init__(self, items, *, getall=False):
        self._getall = getall
        self._keys = [item[0] for item in items]
        if not getall:
            self._keys = set(self._keys)

        items_to_use = []
        if getall:
            items_to_use = items
        else:
            for key in self._keys:
                for k, v in items:
                    if k == key:
                        items_to_use.append((k, v))
                        break
        assert len(items_to_use) == len(self._keys)

        super().__init__(items_to_use)

    def __contains__(self, key):
        return key in self._keys

    def __iter__(self):
        yield from self._keys

```
--- 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:** Incorrect TypeError Message When Initializing MultiDict with Multiple Arguments

**Description:**
When creating an instance of `MultiDict` with multiple positional arguments, the raised `TypeError` incorrectly reports the number of arguments provided. This misleading error message can confuse developers about the actual number of arguments passed.

**Example Code:**
```python
from aiohttp.multidict import MultiDict

# Attempting to initialize MultiDict with two positional arguments
d = MultiDict(('key1', 'value1'), ('key2', 'value2'))
```

**Expected Behavior:**
A `TypeError` should be raised with a message indicating that only 2 positional arguments were given, matching the number of arguments actually passed.

**Actual Behavior:**
A `TypeError` is raised with the message:
```
TypeError: MultiDict takes at most 2 positional arguments (3 given)
```
This incorrectly suggests that three arguments were provided when only two were passed.

[/ISSUE]
{
    "MultiDictTests.test__repr__": "PASSED",
    "MultiDictTests.test_copy": "PASSED",
    "MultiDictTests.test_getall": "PASSED",
    "MultiDictTests.test_getone": "PASSED",
    "MultiDictTests.test_instantiate__empty": "PASSED",
    "MultiDictTests.test_instantiate__from_arg0": "PASSED",
    "MultiDictTests.test_instantiate__from_arg0_dict": "PASSED",
    "MultiDictTests.test_instantiate__with_kwargs": "PASSED",
    "MultiDictTests.test_items__contains": "PASSED",
    "MultiDictTests.test_values__contains": "PASSED",
    "CaseInsensitiveMultiDictTests.test_basics": "PASSED",
    "CaseInsensitiveMultiDictTests.test_getall": "PASSED",
    "MutableMultiDictTests.test__repr__": "PASSED",
    "MutableMultiDictTests.test_add": "PASSED",
    "MutableMultiDictTests.test_clear": "PASSED",
    "MutableMultiDictTests.test_copy": "PASSED",
    "MutableMultiDictTests.test_del": "PASSED",
    "MutableMultiDictTests.test_extend": "PASSED",
    "MutableMultiDictTests.test_getall": "PASSED",
    "MutableMultiDictTests.test_getone": "PASSED",
    "MutableMultiDictTests.test_instantiate__empty": "PASSED",
    "MutableMultiDictTests.test_instantiate__from_arg0": "PASSED",
    "MutableMultiDictTests.test_instantiate__from_arg0_dict": "PASSED",
    "MutableMultiDictTests.test_instantiate__with_kwargs": "PASSED",
    "MutableMultiDictTests.test_items__contains": "PASSED",
    "MutableMultiDictTests.test_not_implemented_methods": "PASSED",
    "MutableMultiDictTests.test_values__contains": "PASSED",
    "CaseInsensitiveMutableMultiDictTests.test_add": "PASSED",
    "CaseInsensitiveMutableMultiDictTests.test_ctor": "PASSED",
    "CaseInsensitiveMutableMultiDictTests.test_delitem": "PASSED",
    "CaseInsensitiveMutableMultiDictTests.test_getall": "PASSED",
    "CaseInsensitiveMutableMultiDictTests.test_setitem": "PASSED"
}
diff --git a/aiohttp/multidict.py b/aiohttp/multidict.py
index 584ae1db..43d19204 100644
--- a/aiohttp/multidict.py
+++ b/aiohttp/multidict.py
@@ -15,8 +15,8 @@ class MultiDict(abc.Mapping):
 
     def __init__(self, *args, **kwargs):
         if len(args) > 1:
-            raise TypeError("MultiDict takes at most 2 positional "
-                            "arguments ({} given)".format(len(args) + 1))
+            raise TypeError("MultiDict takes at most 1 positional "
+                            "argument ({} given)".format(len(args)))
         self._items = []
         if args:
             if hasattr(args[0], 'items'):

{"aiohttp/multidict.py": "import pprint\nfrom itertools import chain\nfrom collections import abc\n\n_marker = object()\n\n\nclass MultiDict(abc.Mapping):\n    \"\"\"Read-only ordered dictionary that can have multiple values for each key.\n\n    This type of MultiDict must be used for request headers and query args.\n    \"\"\"\n\n    __slots__ = ('_items',)\n\n    def __init__(self, *args, **kwargs):\n        if len(args) > 1:\n            raise TypeError(\"MultiDict takes at most 2 positional \"\n                            \"arguments ({} given)\".format(len(args) + 1))\n        self._items = []\n        if args:\n            if hasattr(args[0], 'items'):\n                args = list(args[0].items())\n            else:\n                args = list(args[0])\n                for arg in args:\n                    if not len(arg) == 2:\n                        raise TypeError(\n                            \"MultiDict takes either dict or list of \\\n                            (key, value) tuples\"\n                        )\n\n        self._fill(chain(args, kwargs.items()))\n\n    def _fill(self, ipairs):\n        self._items.extend(ipairs)\n\n    def getall(self, key, default=_marker):\n        \"\"\"\n        Return a list of all values matching the key (may be an empty list)\n        \"\"\"\n        res = tuple([v for k, v in self._items if k == key])\n        if res:\n            return res\n        if not res and default != _marker:\n            return default\n        raise KeyError('Key not found: %r' % key)\n\n    def getone(self, key, default=_marker):\n        \"\"\"\n        Get one value matching the key, raising a KeyError if multiple\n        values were found.\n        \"\"\"\n        v = self.getall(key, default=_marker)\n        if len(v) > 1 and v != default:\n            raise KeyError('Multiple values match %r: %r' % (key, v))\n        return v[0]\n\n    # extra methods #\n\n    def copy(self):\n        \"\"\"Returns a copy itself.\"\"\"\n        cls = self.__class__\n        return cls(self.items(getall=True))\n\n    # Mapping interface #\n\n    def __getitem__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return v\n        raise KeyError(key)\n\n    def __iter__(self):\n        return iter(self._items)\n\n    def __len__(self):\n        return len(self._items)\n\n    def keys(self, *, getall=False):\n        return _KeysView(self._items, getall=getall)\n\n    def items(self, *, getall=False):\n        return _ItemsView(self._items, getall=getall)\n\n    def values(self, *, getall=False):\n        return _ValuesView(self._items, getall=getall)\n\n    def __eq__(self, other):\n        if not isinstance(other, abc.Mapping):\n            return NotImplemented\n        if isinstance(other, MultiDict):\n            return self._items == other._items\n        return dict(self.items()) == dict(other.items())\n\n    def __contains__(self, key):\n        for k, v in self._items:\n            if k == key:\n                return True\n        return False\n\n    def __repr__(self):\n        return '<{}>\\n{}'.format(\n            self.__class__.__name__, pprint.pformat(\n                list(self.items(getall=True)))\n        )\n\n\nclass CaseInsensitiveMultiDict(MultiDict):\n    \"\"\"Case insensitive multi dict.\"\"\"\n\n    @classmethod\n    def _from_uppercase_multidict(cls, dct):\n        # NB: doesn't check for uppercase keys!\n        ret = cls.__new__(cls)\n        ret._items = dct._items\n        return ret\n\n    def _fill(self, ipairs):\n        for key, value in ipairs:\n            uppkey = key.upper()\n            self._items.append((uppkey, value))\n\n    def getall(self, key, default=_marker):\n        return super().getall(key.upper(), default)\n\n    def getone(self, key, default=_marker):\n        return super().getone(key.upper(), default)\n\n    def __getitem__(self, key):\n        return super().__getitem__(key.upper())\n\n    def __contains__(self, key):\n        return super().__contains__(key.upper())\n\n\nclass MutableMultiDictMixin(abc.MutableMapping):\n\n    def add(self, key, value):\n        \"\"\"\n        Add the key and value, not overwriting any previous value.\n        \"\"\"\n        self._items.append((key, value))\n\n    def extend(self, *args, **kwargs):\n        \"\"\"Extends current MutableMultiDict with more values.\n\n        This method must be used instead of update.\n        \"\"\"\n        if len(args) > 1:\n            raise TypeError(\"extend takes at most 2 positional arguments\"\n                            \" ({} given)\".format(len(args) + 1))\n        if args:\n            if isinstance(args[0], MultiDict):\n                items = args[0].items(getall=True)\n            elif hasattr(args[0], 'items'):\n                items = args[0].items()\n            else:\n                items = args[0]\n        else:\n            items = []\n        for key, value in chain(items, kwargs.items()):\n            self.add(key, value)\n\n    def clear(self):\n        \"\"\"Remove all items from MutableMultiDict\"\"\"\n        self._items.clear()\n\n    # MutableMapping interface #\n\n    def __setitem__(self, key, value):\n        try:\n            del self[key]\n        except KeyError:\n            pass\n        self._items.append((key, value))\n\n    def __delitem__(self, key):\n        items = self._items\n        found = False\n        for i in range(len(items)-1, -1, -1):\n            if items[i][0] == key:\n                del items[i]\n                found = True\n        if not found:\n            raise KeyError(key)\n\n    def pop(self, key, default=None):\n        \"\"\"Method not allowed.\"\"\"\n        raise NotImplementedError\n\n    def popitem(self):\n        \"\"\"Method not allowed.\"\"\"\n        raise NotImplementedError\n\n    def update(self, *args, **kw):\n        \"\"\"Method not allowed.\"\"\"\n        raise NotImplementedError(\"Use extend method instead\")\n\n\nclass MutableMultiDict(MutableMultiDictMixin, MultiDict):\n    \"\"\"An ordered dictionary that can have multiple values for each key.\"\"\"\n\n\nclass CaseInsensitiveMutableMultiDict(\n        MutableMultiDictMixin, CaseInsensitiveMultiDict):\n    \"\"\"An ordered dictionary that can have multiple values for each key.\"\"\"\n\n    def add(self, key, value):\n        super().add(key.upper(), value)\n\n    def __setitem__(self, key, value):\n        super().__setitem__(key.upper(), value)\n\n    def __delitem__(self, key):\n        super().__delitem__(key.upper())\n\n\nclass _ItemsView(abc.ItemsView):\n\n    def __init__(self, items, *, getall=False):\n        self._getall = getall\n        self._keys = [item[0] for item in items]\n        if not getall:\n            self._keys = set(self._keys)\n\n        items_to_use = []\n        if getall:\n            items_to_use = items\n        else:\n            for key in self._keys:\n                for k, v in items:\n                    if k == key:\n                        items_to_use.append((k, v))\n                        break\n        assert len(items_to_use) == len(self._keys)\n\n        super().__init__(items_to_use)\n\n    def __contains__(self, item):\n        assert isinstance(item, tuple) or isinstance(item, list)\n        assert len(item) == 2\n        return item in self._mapping\n\n    def __iter__(self):\n        yield from self._mapping\n\n\nclass _ValuesView(abc.ValuesView):\n\n    def __init__(self, items, *, getall=False):\n        self._getall = getall\n        self._keys = [item[0] for item in items]\n        if not getall:\n            self._keys = set(self._keys)\n\n        items_to_use = []\n        if getall:\n            items_to_use = items\n        else:\n            for key in self._keys:\n                for k, v in items:\n                    if k == key:\n                        items_to_use.append((k, v))\n                        break\n\n        assert len(items_to_use) == len(self._keys)\n\n        super().__init__(items_to_use)\n\n    def __contains__(self, value):\n        values = [item[1] for item in self._mapping]\n        return value in values\n\n    def __iter__(self):\n        values = (item[1] for item in self._mapping)\n        yield from values\n\n\nclass _KeysView(abc.KeysView):\n\n    def __init__(self, items, *, getall=False):\n        self._getall = getall\n        self._keys = [item[0] for item in items]\n        if not getall:\n            self._keys = set(self._keys)\n\n        items_to_use = []\n        if getall:\n            items_to_use = items\n        else:\n            for key in self._keys:\n                for k, v in items:\n                    if k == key:\n                        items_to_use.append((k, v))\n                        break\n        assert len(items_to_use) == len(self._keys)\n\n        super().__init__(items_to_use)\n\n    def __contains__(self, key):\n        return key in self._keys\n\n    def __iter__(self):\n        yield from self._keys\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:** Incorrect TypeError Message When Initializing MultiDict with Multiple Arguments

**Description:**
When creating an instance of `MultiDict` with multiple positional arguments, the raised `TypeError` incorrectly reports the number of arguments provided. This misleading error message can confuse developers about the actual number of arguments passed.

**Example Code:**
```python
from aiohttp.multidict import MultiDict

# Attempting to initialize MultiDict with two positional arguments
d = MultiDict(('key1', 'value1'), ('key2', 'value2'))
```

**Expected Behavior:**
A `TypeError` should be raised with a message indicating that only 2 positional arguments were given, matching the number of arguments actually passed.

**Actual Behavior:**
A `TypeError` is raised with the message:
```
TypeError: MultiDict takes at most 2 positional arguments (3 given)
```
This incorrectly suggests that three arguments were provided when only two were passed.

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

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

--- BEGIN FILE ---
```
### aiohttp/multidict.py
import pprint
from itertools import chain
from collections import abc

_marker = object()


class MultiDict(abc.Mapping):
    """Read-only ordered dictionary that can have multiple values for each key.

    This type of MultiDict must be used for request headers and query args.
    """

    __slots__ = ('_items',)

    def __init__(self, *args, **kwargs):
        if len(args) > 1:
            raise TypeError("MultiDict takes at most 2 positional "
                            "arguments ({} given)".format(len(args) + 1))
        self._items = []
        if args:
            if hasattr(args[0], 'items'):
                args = list(args[0].items())
            else:
                args = list(args[0])
                for arg in args:
                    if not len(arg) == 2:
                        raise TypeError(
                            "MultiDict takes either dict or list of \
                            (key, value) tuples"
                        )

        self._fill(chain(args, kwargs.items()))

    def _fill(self, ipairs):
        self._items.extend(ipairs)

    def getall(self, key, default=_marker):
        """
        Return a list of all values matching the key (may be an empty list)
        """
        res = tuple([v for k, v in self._items if k == key])
        if res:
            return res
        if not res and default != _marker:
            return default
        raise KeyError('Key not found: %r' % key)

    def getone(self, key, default=_marker):
        """
        Get one value matching the key, raising a KeyError if multiple
        values were found.
        """
        v = self.getall(key, default=_marker)
        if len(v) > 1 and v != default:
            raise KeyError('Multiple values match %r: %r' % (key, v))
        return v[0]

    # extra methods #

    def copy(self):
        """Returns a copy itself."""
        cls = self.__class__
        return cls(self.items(getall=True))

    # Mapping interface #

    def __getitem__(self, key):
        for k, v in self._items:
            if k == key:
                return v
        raise KeyError(key)

    def __iter__(self):
        return iter(self._items)

    def __len__(self):
        return len(self._items)

    def keys(self, *, getall=False):
        return _KeysView(self._items, getall=getall)

    def items(self, *, getall=False):
        return _ItemsView(self._items, getall=getall)

    def values(self, *, getall=False):
        return _ValuesView(self._items, getall=getall)

    def __eq__(self, other):
        if not isinstance(other, abc.Mapping):
            return NotImplemented
        if isinstance(other, MultiDict):
            return self._items == other._items
        return dict(self.items()) == dict(other.items())

    def __contains__(self, key):
        for k, v in self._items:
            if k == key:
                return True
        return False

    def __repr__(self):
        return '<{}>\n{}'.format(
            self.__class__.__name__, pprint.pformat(
                list(self.items(getall=True)))
        )


class CaseInsensitiveMultiDict(MultiDict):
    """Case insensitive multi dict."""

    @classmethod
    def _from_uppercase_multidict(cls, dct):
        # NB: doesn't check for uppercase keys!
        ret = cls.__new__(cls)
        ret._items = dct._items
        return ret

    def _fill(self, ipairs):
        for key, value in ipairs:
            uppkey = key.upper()
            self._items.append((uppkey, value))

    def getall(self, key, default=_marker):
        return super().getall(key.upper(), default)

    def getone(self, key, default=_marker):
        return super().getone(key.upper(), default)

    def __getitem__(self, key):
        return super().__getitem__(key.upper())

    def __contains__(self, key):
        return super().__contains__(key.upper())


class MutableMultiDictMixin(abc.MutableMapping):

    def add(self, key, value):
        """
        Add the key and value, not overwriting any previous value.
        """
        self._items.append((key, value))

    def extend(self, *args, **kwargs):
        """Extends current MutableMultiDict with more values.

        This method must be used instead of update.
        """
        if len(args) > 1:
            raise TypeError("extend takes at most 2 positional arguments"
                            " ({} given)".format(len(args) + 1))
        if args:
            if isinstance(args[0], MultiDict):
                items = args[0].items(getall=True)
            elif hasattr(args[0], 'items'):
                items = args[0].items()
            else:
                items = args[0]
        else:
            items = []
        for key, value in chain(items, kwargs.items()):
            self.add(key, value)

    def clear(self):
        """Remove all items from MutableMultiDict"""
        self._items.clear()

    # MutableMapping interface #

    def __setitem__(self, key, value):
        try:
            del self[key]
        except KeyError:
            pass
        self._items.append((key, value))

    def __delitem__(self, key):
        items = self._items
        found = False
        for i in range(len(items)-1, -1, -1):
            if items[i][0] == key:
                del items[i]
                found = True
        if not found:
            raise KeyError(key)

    def pop(self, key, default=None):
        """Method not allowed."""
        raise NotImplementedError

    def popitem(self):
        """Method not allowed."""
        raise NotImplementedError

    def update(self, *args, **kw):
        """Method not allowed."""
        raise NotImplementedError("Use extend method instead")


class MutableMultiDict(MutableMultiDictMixin, MultiDict):
    """An ordered dictionary that can have multiple values for each key."""


class CaseInsensitiveMutableMultiDict(
        MutableMultiDictMixin, CaseInsensitiveMultiDict):
    """An ordered dictionary that can have multiple values for each key."""

    def add(self, key, value):
        super().add(key.upper(), value)

    def __setitem__(self, key, value):
        super().__setitem__(key.upper(), value)

    def __delitem__(self, key):
        super().__delitem__(key.upper())


class _ItemsView(abc.ItemsView):

    def __init__(self, items, *, getall=False):
        self._getall = getall
        self._keys = [item[0] for item in items]
        if not getall:
            self._keys = set(self._keys)

        items_to_use = []
        if getall:
            items_to_use = items
        else:
            for key in self._keys:
                for k, v in items:
                    if k == key:
                        items_to_use.append((k, v))
                        break
        assert len(items_to_use) == len(self._keys)

        super().__init__(items_to_use)

    def __contains__(self, item):
        assert isinstance(item, tuple) or isinstance(item, list)
        assert len(item) == 2
        return item in self._mapping

    def __iter__(self):
        yield from self._mapping


class _ValuesView(abc.ValuesView):

    def __init__(self, items, *, getall=False):
        self._getall = getall
        self._keys = [item[0] for item in items]
        if not getall:
            self._keys = set(self._keys)

        items_to_use = []
        if getall:
            items_to_use = items
        else:
            for key in self._keys:
                for k, v in items:
                    if k == key:
                        items_to_use.append((k, v))
                        break

        assert len(items_to_use) == len(self._keys)

        super().__init__(items_to_use)

    def __contains__(self, value):
        values = [item[1] for item in self._mapping]
        return value in values

    def __iter__(self):
        values = (item[1] for item in self._mapping)
        yield from values


class _KeysView(abc.KeysView):

    def __init__(self, items, *, getall=False):
        self._getall = getall
        self._keys = [item[0] for item in items]
        if not getall:
            self._keys = set(self._keys)

        items_to_use = []
        if getall:
            items_to_use = items
        else:
            for key in self._keys:
                for k, v in items:
                    if k == key:
                        items_to_use.append((k, v))
                        break
        assert len(items_to_use) == len(self._keys)

        super().__init__(items_to_use)

    def __contains__(self, key):
        return key in self._keys

    def __iter__(self):
        yield from self._keys

```
--- 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