{
    "file_diffs": [
        {
            "old_file_content": "",
            "new_file_content": "Added ``default_to_multipart`` parameter to ``FormData``.\n",
            "header": {
                "file": {
                    "path": "CHANGES/9335.feature.rst"
                },
                "misc_line": "new file mode 100644"
            },
            "index_line": {
                "old_commit_hash": "00000000",
                "new_commit_hash": "9a2e0684",
                "mode": ""
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "/dev/null"
            },
            "plus_file": {
                "path": "b/CHANGES/9335.feature.rst"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 0,
                            "length": 0
                        },
                        "new_range": {
                            "start": 1,
                            "length": null
                        },
                        "section": ""
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "Added ``default_to_multipart`` parameter to ``FormData``.",
                                "type": "added"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import io\nfrom typing import Any, Iterable, List, Optional\nfrom urllib.parse import urlencode\n\nfrom multidict import MultiDict, MultiDictProxy\n\nfrom . import hdrs, multipart, payload\nfrom .helpers import guess_filename\nfrom .payload import Payload\n\n__all__ = (\"FormData\",)\n\n\nclass FormData:\n    \"\"\"Helper class for form body generation.\n\n    Supports multipart/form-data and application/x-www-form-urlencoded.\n    \"\"\"\n\n    def __init__(\n        self,\n        fields: Iterable[Any] = (),\n        quote_fields: bool = True,\n        charset: Optional[str] = None,\n        boundary: Optional[str] = None,\n    ) -> None:\n        self._boundary = boundary\n        self._writer = multipart.MultipartWriter(\"form-data\", boundary=self._boundary)\n        self._fields: List[Any] = []\n        self._is_multipart = False\n        self._is_processed = False\n        self._quote_fields = quote_fields\n        self._charset = charset\n\n        if isinstance(fields, dict):\n            fields = list(fields.items())\n        elif not isinstance(fields, (list, tuple)):\n            fields = (fields,)\n        self.add_fields(*fields)\n\n    @property\n    def is_multipart(self) -> bool:\n        return self._is_multipart\n\n    def add_field(\n        self,\n        name: str,\n        value: Any,\n        *,\n        content_type: Optional[str] = None,\n        filename: Optional[str] = None,\n    ) -> None:\n        if isinstance(value, (io.IOBase, bytes, bytearray, memoryview)):\n            self._is_multipart = True\n\n        type_options: MultiDict[str] = MultiDict({\"name\": name})\n        if filename is not None and not isinstance(filename, str):\n            raise TypeError(\"filename must be an instance of str. Got: %s\" % filename)\n        if filename is None and isinstance(value, io.IOBase):\n            filename = guess_filename(value, name)\n        if filename is not None:\n            type_options[\"filename\"] = filename\n            self._is_multipart = True\n\n        headers = {}\n        if content_type is not None:\n            if not isinstance(content_type, str):\n                raise TypeError(\n                    \"content_type must be an instance of str. Got: %s\" % content_type\n                )\n            headers[hdrs.CONTENT_TYPE] = content_type\n            self._is_multipart = True\n\n        self._fields.append((type_options, headers, value))\n\n    def add_fields(self, *fields: Any) -> None:\n        to_add = list(fields)\n\n        while to_add:\n            rec = to_add.pop(0)\n\n            if isinstance(rec, io.IOBase):\n                k = guess_filename(rec, \"unknown\")\n                self.add_field(k, rec)  # type: ignore[arg-type]\n\n            elif isinstance(rec, (MultiDictProxy, MultiDict)):\n                to_add.extend(rec.items())\n\n            elif isinstance(rec, (list, tuple)) and len(rec) == 2:\n                k, fp = rec\n                self.add_field(k, fp)  # type: ignore[arg-type]\n\n            else:\n                raise TypeError(\n                    \"Only io.IOBase, multidict and (name, file) \"\n                    \"pairs allowed, use .add_field() for passing \"\n                    \"more complex parameters, got {!r}\".format(rec)\n                )\n\n    def _gen_form_urlencoded(self) -> payload.BytesPayload:\n        # form data (x-www-form-urlencoded)\n        data = []\n        for type_options, _, value in self._fields:\n            if not isinstance(value, str):\n                raise TypeError(f\"expected str, got {value!r}\")\n            data.append((type_options[\"name\"], value))\n\n        charset = self._charset if self._charset is not None else \"utf-8\"\n\n        if charset == \"utf-8\":\n            content_type = \"application/x-www-form-urlencoded\"\n        else:\n            content_type = \"application/x-www-form-urlencoded; charset=%s\" % charset\n\n        return payload.BytesPayload(\n            urlencode(data, doseq=True, encoding=charset).encode(),\n            content_type=content_type,\n        )\n\n    def _gen_form_data(self) -> multipart.MultipartWriter:\n        \"\"\"Encode a list of fields using the multipart/form-data MIME format\"\"\"\n        if self._is_processed:\n            raise RuntimeError(\"Form data has been processed already\")\n        for dispparams, headers, value in self._fields:\n            try:\n                if hdrs.CONTENT_TYPE in headers:\n                    part = payload.get_payload(\n                        value,\n                        content_type=headers[hdrs.CONTENT_TYPE],\n                        headers=headers,\n                        encoding=self._charset,\n                    )\n                else:\n                    part = payload.get_payload(\n                        value, headers=headers, encoding=self._charset\n                    )\n            except Exception as exc:\n                raise TypeError(\n                    \"Can not serialize value type: %r\\n \"\n                    \"headers: %r\\n value: %r\" % (type(value), headers, value)\n                ) from exc\n\n            if dispparams:\n                part.set_content_disposition(\n                    \"form-data\", quote_fields=self._quote_fields, **dispparams\n                )\n                # FIXME cgi.FieldStorage doesn't likes body parts with\n                # Content-Length which were sent via chunked transfer encoding\n                assert part.headers is not None\n                part.headers.popall(hdrs.CONTENT_LENGTH, None)\n\n            self._writer.append_payload(part)\n\n        self._is_processed = True\n        return self._writer\n\n    def __call__(self) -> Payload:\n        if self._is_multipart:\n            return self._gen_form_data()\n        else:\n            return self._gen_form_urlencoded()\n",
            "new_file_content": "import io\nfrom typing import Any, Iterable, List, Optional\nfrom urllib.parse import urlencode\n\nfrom multidict import MultiDict, MultiDictProxy\n\nfrom . import hdrs, multipart, payload\nfrom .helpers import guess_filename\nfrom .payload import Payload\n\n__all__ = (\"FormData\",)\n\n\nclass FormData:\n    \"\"\"Helper class for form body generation.\n\n    Supports multipart/form-data and application/x-www-form-urlencoded.\n    \"\"\"\n\n    def __init__(\n        self,\n        fields: Iterable[Any] = (),\n        quote_fields: bool = True,\n        charset: Optional[str] = None,\n        boundary: Optional[str] = None,\n        *,\n        default_to_multipart: bool = False,\n    ) -> None:\n        self._boundary = boundary\n        self._writer = multipart.MultipartWriter(\"form-data\", boundary=self._boundary)\n        self._fields: List[Any] = []\n        self._is_multipart = default_to_multipart\n        self._is_processed = False\n        self._quote_fields = quote_fields\n        self._charset = charset\n\n        if isinstance(fields, dict):\n            fields = list(fields.items())\n        elif not isinstance(fields, (list, tuple)):\n            fields = (fields,)\n        self.add_fields(*fields)\n\n    @property\n    def is_multipart(self) -> bool:\n        return self._is_multipart\n\n    def add_field(\n        self,\n        name: str,\n        value: Any,\n        *,\n        content_type: Optional[str] = None,\n        filename: Optional[str] = None,\n    ) -> None:\n        if isinstance(value, (io.IOBase, bytes, bytearray, memoryview)):\n            self._is_multipart = True\n\n        type_options: MultiDict[str] = MultiDict({\"name\": name})\n        if filename is not None and not isinstance(filename, str):\n            raise TypeError(\"filename must be an instance of str. Got: %s\" % filename)\n        if filename is None and isinstance(value, io.IOBase):\n            filename = guess_filename(value, name)\n        if filename is not None:\n            type_options[\"filename\"] = filename\n            self._is_multipart = True\n\n        headers = {}\n        if content_type is not None:\n            if not isinstance(content_type, str):\n                raise TypeError(\n                    \"content_type must be an instance of str. Got: %s\" % content_type\n                )\n            headers[hdrs.CONTENT_TYPE] = content_type\n            self._is_multipart = True\n\n        self._fields.append((type_options, headers, value))\n\n    def add_fields(self, *fields: Any) -> None:\n        to_add = list(fields)\n\n        while to_add:\n            rec = to_add.pop(0)\n\n            if isinstance(rec, io.IOBase):\n                k = guess_filename(rec, \"unknown\")\n                self.add_field(k, rec)  # type: ignore[arg-type]\n\n            elif isinstance(rec, (MultiDictProxy, MultiDict)):\n                to_add.extend(rec.items())\n\n            elif isinstance(rec, (list, tuple)) and len(rec) == 2:\n                k, fp = rec\n                self.add_field(k, fp)  # type: ignore[arg-type]\n\n            else:\n                raise TypeError(\n                    \"Only io.IOBase, multidict and (name, file) \"\n                    \"pairs allowed, use .add_field() for passing \"\n                    \"more complex parameters, got {!r}\".format(rec)\n                )\n\n    def _gen_form_urlencoded(self) -> payload.BytesPayload:\n        # form data (x-www-form-urlencoded)\n        data = []\n        for type_options, _, value in self._fields:\n            if not isinstance(value, str):\n                raise TypeError(f\"expected str, got {value!r}\")\n            data.append((type_options[\"name\"], value))\n\n        charset = self._charset if self._charset is not None else \"utf-8\"\n\n        if charset == \"utf-8\":\n            content_type = \"application/x-www-form-urlencoded\"\n        else:\n            content_type = \"application/x-www-form-urlencoded; charset=%s\" % charset\n\n        return payload.BytesPayload(\n            urlencode(data, doseq=True, encoding=charset).encode(),\n            content_type=content_type,\n        )\n\n    def _gen_form_data(self) -> multipart.MultipartWriter:\n        \"\"\"Encode a list of fields using the multipart/form-data MIME format\"\"\"\n        if self._is_processed:\n            raise RuntimeError(\"Form data has been processed already\")\n        for dispparams, headers, value in self._fields:\n            try:\n                if hdrs.CONTENT_TYPE in headers:\n                    part = payload.get_payload(\n                        value,\n                        content_type=headers[hdrs.CONTENT_TYPE],\n                        headers=headers,\n                        encoding=self._charset,\n                    )\n                else:\n                    part = payload.get_payload(\n                        value, headers=headers, encoding=self._charset\n                    )\n            except Exception as exc:\n                raise TypeError(\n                    \"Can not serialize value type: %r\\n \"\n                    \"headers: %r\\n value: %r\" % (type(value), headers, value)\n                ) from exc\n\n            if dispparams:\n                part.set_content_disposition(\n                    \"form-data\", quote_fields=self._quote_fields, **dispparams\n                )\n                # FIXME cgi.FieldStorage doesn't likes body parts with\n                # Content-Length which were sent via chunked transfer encoding\n                assert part.headers is not None\n                part.headers.popall(hdrs.CONTENT_LENGTH, None)\n\n            self._writer.append_payload(part)\n\n        self._is_processed = True\n        return self._writer\n\n    def __call__(self) -> Payload:\n        if self._is_multipart:\n            return self._gen_form_data()\n        else:\n            return self._gen_form_urlencoded()\n",
            "header": {
                "file": {
                    "path": "aiohttp/formdata.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "017a5192",
                "new_commit_hash": "994df482",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/aiohttp/formdata.py"
            },
            "plus_file": {
                "path": "b/aiohttp/formdata.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 23,
                            "length": 11
                        },
                        "new_range": {
                            "start": 23,
                            "length": 13
                        },
                        "section": "class FormData:"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        quote_fields: bool = True,",
                                "type": "context"
                            },
                            {
                                "content": "        charset: Optional[str] = None,",
                                "type": "context"
                            },
                            {
                                "content": "        boundary: Optional[str] = None,",
                                "type": "context"
                            },
                            {
                                "content": "        *,",
                                "type": "added"
                            },
                            {
                                "content": "        default_to_multipart: bool = False,",
                                "type": "added"
                            },
                            {
                                "content": "    ) -> None:",
                                "type": "context"
                            },
                            {
                                "content": "        self._boundary = boundary",
                                "type": "context"
                            },
                            {
                                "content": "        self._writer = multipart.MultipartWriter(\"form-data\", boundary=self._boundary)",
                                "type": "context"
                            },
                            {
                                "content": "        self._fields: List[Any] = []",
                                "type": "context"
                            },
                            {
                                "content": "        self._is_multipart = False",
                                "type": "deleted"
                            },
                            {
                                "content": "        self._is_multipart = default_to_multipart",
                                "type": "added"
                            },
                            {
                                "content": "        self._is_processed = False",
                                "type": "context"
                            },
                            {
                                "content": "        self._quote_fields = quote_fields",
                                "type": "context"
                            },
                            {
                                "content": "        self._charset = charset",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "aiohttp/formdata.py",
                            "type": "method",
                            "name": "FormData.__init__",
                            "content": "class FormData:\n    \"\"\"Helper class for form body generation.\n\n    Supports multipart/form-data and application/x-www-form-urlencoded.\n    \"\"\"\n\n    def __init__(\n        self,\n        fields: Iterable[Any] = (),\n        quote_fields: bool = True,\n        charset: Optional[str] = None,\n        boundary: Optional[str] = None,\n    ) -> None:\n        self._boundary = boundary\n        self._writer = multipart.MultipartWriter(\"form-data\", boundary=self._boundary)\n        self._fields: List[Any] = []\n        self._is_multipart = False\n        self._is_processed = False\n        self._quote_fields = quote_fields\n        self._charset = charset\n\n        if isinstance(fields, dict):\n            fields = list(fields.items())\n        elif not isinstance(fields, (list, tuple)):\n            fields = (fields,)\n        self.add_fields(*fields)\n\n    @property\n    def is_multipart(self) -> bool:\n        return self._is_multipart\n\n    def add_field(\n        self,\n        name: str,\n        value: Any,\n        *,\n        content_type: Optional[str] = None,\n        filename: Optional[str] = None,\n    ) -> None:\n        if isinstance(value, (io.IOBase, bytes, bytearray, memoryview)):\n            self._is_multipart = True\n\n        type_options: MultiDict[str] = MultiDict({\"name\": name})\n        if filename is not None and not isinstance(filename, str):\n            raise TypeError(\"filename must be an instance of str. Got: %s\" % filename)\n        if filename is None and isinstance(value, io.IOBase):\n            filename = guess_filename(value, name)\n        if filename is not None:\n            type_options[\"filename\"] = filename\n            self._is_multipart = True\n\n        headers = {}\n        if content_type is not None:\n            if not isinstance(content_type, str):\n                raise TypeError(\n                    \"content_type must be an instance of str. Got: %s\" % content_type\n                )\n            headers[hdrs.CONTENT_TYPE] = content_type\n            self._is_multipart = True\n\n        self._fields.append((type_options, headers, value))\n\n    def add_fields(self, *fields: Any) -> None:\n        to_add = list(fields)\n\n        while to_add:\n            rec = to_add.pop(0)\n\n            if isinstance(rec, io.IOBase):\n                k = guess_filename(rec, \"unknown\")\n                self.add_field(k, rec)  # type: ignore[arg-type]\n\n            elif isinstance(rec, (MultiDictProxy, MultiDict)):\n                to_add.extend(rec.items())\n\n            elif isinstance(rec, (list, tuple)) and len(rec) == 2:\n                k, fp = rec\n                self.add_field(k, fp)  # type: ignore[arg-type]\n\n            else:\n                raise TypeError(\n                    \"Only io.IOBase, multidict and (name, file) \"\n                    \"pairs allowed, use .add_field() for passing \"\n                    \"more complex parameters, got {!r}\".format(rec)\n                )\n\n    def _gen_form_urlencoded(self) -> payload.BytesPayload:\n        # form data (x-www-form-urlencoded)\n        data = []\n        for type_options, _, value in self._fields:\n            if not isinstance(value, str):\n                raise TypeError(f\"expected str, got {value!r}\")\n            data.append((type_options[\"name\"], value))\n\n        charset = self._charset if self._charset is not None else \"utf-8\"\n\n        if charset == \"utf-8\":\n            content_type = \"application/x-www-form-urlencoded\"\n        else:\n            content_type = \"application/x-www-form-urlencoded; charset=%s\" % charset\n\n        return payload.BytesPayload(\n            urlencode(data, doseq=True, encoding=charset).encode(),\n            content_type=content_type,\n        )\n\n    def _gen_form_data(self) -> multipart.MultipartWriter:\n        \"\"\"Encode a list of fields using the multipart/form-data MIME format\"\"\"\n        if self._is_processed:\n            raise RuntimeError(\"Form data has been processed already\")\n        for dispparams, headers, value in self._fields:\n            try:\n                if hdrs.CONTENT_TYPE in headers:\n                    part = payload.get_payload(\n                        value,\n                        content_type=headers[hdrs.CONTENT_TYPE],\n                        headers=headers,\n                        encoding=self._charset,\n                    )\n                else:\n                    part = payload.get_payload(\n                        value, headers=headers, encoding=self._charset\n                    )\n            except Exception as exc:\n                raise TypeError(\n                    \"Can not serialize value type: %r\\n \"\n                    \"headers: %r\\n value: %r\" % (type(value), headers, value)\n                ) from exc\n\n            if dispparams:\n                part.set_content_disposition(\n                    \"form-data\", quote_fields=self._quote_fields, **dispparams\n                )\n                # FIXME cgi.FieldStorage doesn't likes body parts with\n                # Content-Length which were sent via chunked transfer encoding\n                assert part.headers is not None\n                part.headers.popall(hdrs.CONTENT_LENGTH, None)\n\n            self._writer.append_payload(part)\n\n        self._is_processed = True\n        return self._writer\n\n    def __call__(self) -> Payload:\n        if self._is_multipart:\n            return self._gen_form_data()\n        else:\n            return self._gen_form_urlencoded()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 20,
                            "end_lineno": 39,
                            "parent": {
                                "file_name": "aiohttp/formdata.py",
                                "type": "class",
                                "name": "FormData",
                                "content": "class FormData:\n    \"\"\"Helper class for form body generation.\n\n    Supports multipart/form-data and application/x-www-form-urlencoded.\n    \"\"\"\n\n    def __init__(\n        self,\n        fields: Iterable[Any] = (),\n        quote_fields: bool = True,\n        charset: Optional[str] = None,\n        boundary: Optional[str] = None,\n    ) -> None:\n        self._boundary = boundary\n        self._writer = multipart.MultipartWriter(\"form-data\", boundary=self._boundary)\n        self._fields: List[Any] = []\n        self._is_multipart = False\n        self._is_processed = False\n        self._quote_fields = quote_fields\n        self._charset = charset\n\n        if isinstance(fields, dict):\n            fields = list(fields.items())\n        elif not isinstance(fields, (list, tuple)):\n            fields = (fields,)\n        self.add_fields(*fields)\n\n    @property\n    def is_multipart(self) -> bool:\n        return self._is_multipart\n\n    def add_field(\n        self,\n        name: str,\n        value: Any,\n        *,\n        content_type: Optional[str] = None,\n        filename: Optional[str] = None,\n    ) -> None:\n        if isinstance(value, (io.IOBase, bytes, bytearray, memoryview)):\n            self._is_multipart = True\n\n        type_options: MultiDict[str] = MultiDict({\"name\": name})\n        if filename is not None and not isinstance(filename, str):\n            raise TypeError(\"filename must be an instance of str. Got: %s\" % filename)\n        if filename is None and isinstance(value, io.IOBase):\n            filename = guess_filename(value, name)\n        if filename is not None:\n            type_options[\"filename\"] = filename\n            self._is_multipart = True\n\n        headers = {}\n        if content_type is not None:\n            if not isinstance(content_type, str):\n                raise TypeError(\n                    \"content_type must be an instance of str. Got: %s\" % content_type\n                )\n            headers[hdrs.CONTENT_TYPE] = content_type\n            self._is_multipart = True\n\n        self._fields.append((type_options, headers, value))\n\n    def add_fields(self, *fields: Any) -> None:\n        to_add = list(fields)\n\n        while to_add:\n            rec = to_add.pop(0)\n\n            if isinstance(rec, io.IOBase):\n                k = guess_filename(rec, \"unknown\")\n                self.add_field(k, rec)  # type: ignore[arg-type]\n\n            elif isinstance(rec, (MultiDictProxy, MultiDict)):\n                to_add.extend(rec.items())\n\n            elif isinstance(rec, (list, tuple)) and len(rec) == 2:\n                k, fp = rec\n                self.add_field(k, fp)  # type: ignore[arg-type]\n\n            else:\n                raise TypeError(\n                    \"Only io.IOBase, multidict and (name, file) \"\n                    \"pairs allowed, use .add_field() for passing \"\n                    \"more complex parameters, got {!r}\".format(rec)\n                )\n\n    def _gen_form_urlencoded(self) -> payload.BytesPayload:\n        # form data (x-www-form-urlencoded)\n        data = []\n        for type_options, _, value in self._fields:\n            if not isinstance(value, str):\n                raise TypeError(f\"expected str, got {value!r}\")\n            data.append((type_options[\"name\"], value))\n\n        charset = self._charset if self._charset is not None else \"utf-8\"\n\n        if charset == \"utf-8\":\n            content_type = \"application/x-www-form-urlencoded\"\n        else:\n            content_type = \"application/x-www-form-urlencoded; charset=%s\" % charset\n\n        return payload.BytesPayload(\n            urlencode(data, doseq=True, encoding=charset).encode(),\n            content_type=content_type,\n        )\n\n    def _gen_form_data(self) -> multipart.MultipartWriter:\n        \"\"\"Encode a list of fields using the multipart/form-data MIME format\"\"\"\n        if self._is_processed:\n            raise RuntimeError(\"Form data has been processed already\")\n        for dispparams, headers, value in self._fields:\n            try:\n                if hdrs.CONTENT_TYPE in headers:\n                    part = payload.get_payload(\n                        value,\n                        content_type=headers[hdrs.CONTENT_TYPE],\n                        headers=headers,\n                        encoding=self._charset,\n                    )\n                else:\n                    part = payload.get_payload(\n                        value, headers=headers, encoding=self._charset\n                    )\n            except Exception as exc:\n                raise TypeError(\n                    \"Can not serialize value type: %r\\n \"\n                    \"headers: %r\\n value: %r\" % (type(value), headers, value)\n                ) from exc\n\n            if dispparams:\n                part.set_content_disposition(\n                    \"form-data\", quote_fields=self._quote_fields, **dispparams\n                )\n                # FIXME cgi.FieldStorage doesn't likes body parts with\n                # Content-Length which were sent via chunked transfer encoding\n                assert part.headers is not None\n                part.headers.popall(hdrs.CONTENT_LENGTH, None)\n\n            self._writer.append_payload(part)\n\n        self._is_processed = True\n        return self._writer\n\n    def __call__(self) -> Payload:\n        if self._is_multipart:\n            return self._gen_form_data()\n        else:\n            return self._gen_form_urlencoded()",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 14,
                                "end_lineno": 161,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "aiohttp/formdata.py",
                            "type": "class",
                            "name": "FormData",
                            "content": "class FormData:\n    \"\"\"Helper class for form body generation.\n\n    Supports multipart/form-data and application/x-www-form-urlencoded.\n    \"\"\"\n\n    def __init__(\n        self,\n        fields: Iterable[Any] = (),\n        quote_fields: bool = True,\n        charset: Optional[str] = None,\n        boundary: Optional[str] = None,\n    ) -> None:\n        self._boundary = boundary\n        self._writer = multipart.MultipartWriter(\"form-data\", boundary=self._boundary)\n        self._fields: List[Any] = []\n        self._is_multipart = False\n        self._is_processed = False\n        self._quote_fields = quote_fields\n        self._charset = charset\n\n        if isinstance(fields, dict):\n            fields = list(fields.items())\n        elif not isinstance(fields, (list, tuple)):\n            fields = (fields,)\n        self.add_fields(*fields)\n\n    @property\n    def is_multipart(self) -> bool:\n        return self._is_multipart\n\n    def add_field(\n        self,\n        name: str,\n        value: Any,\n        *,\n        content_type: Optional[str] = None,\n        filename: Optional[str] = None,\n    ) -> None:\n        if isinstance(value, (io.IOBase, bytes, bytearray, memoryview)):\n            self._is_multipart = True\n\n        type_options: MultiDict[str] = MultiDict({\"name\": name})\n        if filename is not None and not isinstance(filename, str):\n            raise TypeError(\"filename must be an instance of str. Got: %s\" % filename)\n        if filename is None and isinstance(value, io.IOBase):\n            filename = guess_filename(value, name)\n        if filename is not None:\n            type_options[\"filename\"] = filename\n            self._is_multipart = True\n\n        headers = {}\n        if content_type is not None:\n            if not isinstance(content_type, str):\n                raise TypeError(\n                    \"content_type must be an instance of str. Got: %s\" % content_type\n                )\n            headers[hdrs.CONTENT_TYPE] = content_type\n            self._is_multipart = True\n\n        self._fields.append((type_options, headers, value))\n\n    def add_fields(self, *fields: Any) -> None:\n        to_add = list(fields)\n\n        while to_add:\n            rec = to_add.pop(0)\n\n            if isinstance(rec, io.IOBase):\n                k = guess_filename(rec, \"unknown\")\n                self.add_field(k, rec)  # type: ignore[arg-type]\n\n            elif isinstance(rec, (MultiDictProxy, MultiDict)):\n                to_add.extend(rec.items())\n\n            elif isinstance(rec, (list, tuple)) and len(rec) == 2:\n                k, fp = rec\n                self.add_field(k, fp)  # type: ignore[arg-type]\n\n            else:\n                raise TypeError(\n                    \"Only io.IOBase, multidict and (name, file) \"\n                    \"pairs allowed, use .add_field() for passing \"\n                    \"more complex parameters, got {!r}\".format(rec)\n                )\n\n    def _gen_form_urlencoded(self) -> payload.BytesPayload:\n        # form data (x-www-form-urlencoded)\n        data = []\n        for type_options, _, value in self._fields:\n            if not isinstance(value, str):\n                raise TypeError(f\"expected str, got {value!r}\")\n            data.append((type_options[\"name\"], value))\n\n        charset = self._charset if self._charset is not None else \"utf-8\"\n\n        if charset == \"utf-8\":\n            content_type = \"application/x-www-form-urlencoded\"\n        else:\n            content_type = \"application/x-www-form-urlencoded; charset=%s\" % charset\n\n        return payload.BytesPayload(\n            urlencode(data, doseq=True, encoding=charset).encode(),\n            content_type=content_type,\n        )\n\n    def _gen_form_data(self) -> multipart.MultipartWriter:\n        \"\"\"Encode a list of fields using the multipart/form-data MIME format\"\"\"\n        if self._is_processed:\n            raise RuntimeError(\"Form data has been processed already\")\n        for dispparams, headers, value in self._fields:\n            try:\n                if hdrs.CONTENT_TYPE in headers:\n                    part = payload.get_payload(\n                        value,\n                        content_type=headers[hdrs.CONTENT_TYPE],\n                        headers=headers,\n                        encoding=self._charset,\n                    )\n                else:\n                    part = payload.get_payload(\n                        value, headers=headers, encoding=self._charset\n                    )\n            except Exception as exc:\n                raise TypeError(\n                    \"Can not serialize value type: %r\\n \"\n                    \"headers: %r\\n value: %r\" % (type(value), headers, value)\n                ) from exc\n\n            if dispparams:\n                part.set_content_disposition(\n                    \"form-data\", quote_fields=self._quote_fields, **dispparams\n                )\n                # FIXME cgi.FieldStorage doesn't likes body parts with\n                # Content-Length which were sent via chunked transfer encoding\n                assert part.headers is not None\n                part.headers.popall(hdrs.CONTENT_LENGTH, None)\n\n            self._writer.append_payload(part)\n\n        self._is_processed = True\n        return self._writer\n\n    def __call__(self) -> Payload:\n        if self._is_multipart:\n            return self._gen_form_data()\n        else:\n            return self._gen_form_urlencoded()",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 14,
                            "end_lineno": 161,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import io\nfrom unittest import mock\n\nimport pytest\n\nfrom aiohttp import FormData, web\nfrom aiohttp.http_writer import StreamWriter\nfrom aiohttp.pytest_plugin import AiohttpClient\n\n\n@pytest.fixture\ndef buf() -> bytearray:\n    return bytearray()\n\n\n@pytest.fixture\ndef writer(buf: bytearray) -> StreamWriter:\n    writer = mock.create_autospec(StreamWriter, spec_set=True)\n\n    async def write(chunk: bytes) -> None:\n        buf.extend(chunk)\n\n    writer.write.side_effect = write\n    return writer  # type: ignore[no-any-return]\n\n\ndef test_formdata_multipart(buf: bytearray) -> None:\n    form = FormData()\n    assert not form.is_multipart\n\n    form.add_field(\"test\", b\"test\", filename=\"test.txt\")\n    assert form.is_multipart\n\n\n@pytest.mark.parametrize(\"obj\", (object(), None))\ndef test_invalid_formdata_payload_multipart(obj: object) -> None:\n    form = FormData()\n    form.add_field(\"test\", obj, filename=\"test.txt\")\n    with pytest.raises(TypeError, match=\"Can not serialize value\"):\n        form()\n\n\n@pytest.mark.parametrize(\"obj\", (object(), None))\ndef test_invalid_formdata_payload_urlencoded(obj: object) -> None:\n    form = FormData({\"test\": obj})\n    with pytest.raises(TypeError, match=\"expected str\"):\n        form()\n\n\ndef test_invalid_formdata_params() -> None:\n    with pytest.raises(TypeError):\n        FormData(\"asdasf\")\n\n\ndef test_invalid_formdata_params2() -> None:\n    with pytest.raises(TypeError):\n        FormData(\"as\")  # 2-char str is not allowed\n\n\nasync def test_formdata_textio_charset(buf: bytearray, writer: StreamWriter) -> None:\n    form = FormData()\n    body = io.TextIOWrapper(io.BytesIO(b\"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\"), encoding=\"utf-8\")\n    form.add_field(\"foo\", body, content_type=\"text/plain; charset=shift-jis\")\n    payload = form()\n    await payload.write(writer)\n    assert b\"charset=shift-jis\" in buf\n    assert b\"\\x93\\xfa\\x96{\" in buf\n\n\ndef test_invalid_formdata_content_type() -> None:\n    form = FormData()\n    invalid_vals = [0, 0.1, {}, [], b\"foo\"]\n    for invalid_val in invalid_vals:\n        with pytest.raises(TypeError):\n            form.add_field(\"foo\", \"bar\", content_type=invalid_val)  # type: ignore[arg-type]\n\n\ndef test_invalid_formdata_filename() -> None:\n    form = FormData()\n    invalid_vals = [0, 0.1, {}, [], b\"foo\"]\n    for invalid_val in invalid_vals:\n        with pytest.raises(TypeError):\n            form.add_field(\"foo\", \"bar\", filename=invalid_val)  # type: ignore[arg-type]\n\n\nasync def test_formdata_field_name_is_quoted(\n    buf: bytearray, writer: StreamWriter\n) -> None:\n    form = FormData(charset=\"ascii\")\n    form.add_field(\"email 1\", \"xxx@x.co\", content_type=\"multipart/form-data\")\n    payload = form()\n    await payload.write(writer)\n    assert b'name=\"email\\\\ 1\"' in buf\n\n\nasync def test_formdata_field_name_is_not_quoted(\n    buf: bytearray, writer: StreamWriter\n) -> None:\n    form = FormData(quote_fields=False, charset=\"ascii\")\n    form.add_field(\"email 1\", \"xxx@x.co\", content_type=\"multipart/form-data\")\n    payload = form()\n    await payload.write(writer)\n    assert b'name=\"email 1\"' in buf\n\n\nasync def test_mark_formdata_as_processed(aiohttp_client: AiohttpClient) -> None:\n    async def handler(request: web.Request) -> web.Response:\n        return web.Response()\n\n    app = web.Application()\n    app.add_routes([web.post(\"/\", handler)])\n\n    client = await aiohttp_client(app)\n\n    data = FormData()\n    data.add_field(\"test\", \"test_value\", content_type=\"application/json\")\n\n    resp = await client.post(\"/\", data=data)\n    assert len(data._writer._parts) == 1\n\n    with pytest.raises(RuntimeError):\n        await client.post(\"/\", data=data)\n\n    resp.release()\n\n\nasync def test_formdata_boundary_param() -> None:\n    boundary = \"some_boundary\"\n    form = FormData(boundary=boundary)\n    assert form._writer.boundary == boundary\n",
            "new_file_content": "import io\nfrom unittest import mock\n\nimport pytest\n\nfrom aiohttp import FormData, web\nfrom aiohttp.http_writer import StreamWriter\nfrom aiohttp.pytest_plugin import AiohttpClient\n\n\n@pytest.fixture\ndef buf() -> bytearray:\n    return bytearray()\n\n\n@pytest.fixture\ndef writer(buf: bytearray) -> StreamWriter:\n    writer = mock.create_autospec(StreamWriter, spec_set=True)\n\n    async def write(chunk: bytes) -> None:\n        buf.extend(chunk)\n\n    writer.write.side_effect = write\n    return writer  # type: ignore[no-any-return]\n\n\ndef test_formdata_multipart(buf: bytearray) -> None:\n    form = FormData(default_to_multipart=False)\n    assert not form.is_multipart\n\n    form.add_field(\"test\", b\"test\", filename=\"test.txt\")\n    assert form.is_multipart\n\n\ndef test_form_data_is_multipart_param(buf: bytearray) -> None:\n    form = FormData(default_to_multipart=True)\n    assert form.is_multipart\n\n    form.add_field(\"test\", \"test\")\n    assert form.is_multipart\n\n\n@pytest.mark.parametrize(\"obj\", (object(), None))\ndef test_invalid_formdata_payload_multipart(obj: object) -> None:\n    form = FormData()\n    form.add_field(\"test\", obj, filename=\"test.txt\")\n    with pytest.raises(TypeError, match=\"Can not serialize value\"):\n        form()\n\n\n@pytest.mark.parametrize(\"obj\", (object(), None))\ndef test_invalid_formdata_payload_urlencoded(obj: object) -> None:\n    form = FormData({\"test\": obj})\n    with pytest.raises(TypeError, match=\"expected str\"):\n        form()\n\n\ndef test_invalid_formdata_params() -> None:\n    with pytest.raises(TypeError):\n        FormData(\"asdasf\")\n\n\ndef test_invalid_formdata_params2() -> None:\n    with pytest.raises(TypeError):\n        FormData(\"as\")  # 2-char str is not allowed\n\n\nasync def test_formdata_textio_charset(buf: bytearray, writer: StreamWriter) -> None:\n    form = FormData()\n    body = io.TextIOWrapper(io.BytesIO(b\"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\"), encoding=\"utf-8\")\n    form.add_field(\"foo\", body, content_type=\"text/plain; charset=shift-jis\")\n    payload = form()\n    await payload.write(writer)\n    assert b\"charset=shift-jis\" in buf\n    assert b\"\\x93\\xfa\\x96{\" in buf\n\n\ndef test_invalid_formdata_content_type() -> None:\n    form = FormData()\n    invalid_vals = [0, 0.1, {}, [], b\"foo\"]\n    for invalid_val in invalid_vals:\n        with pytest.raises(TypeError):\n            form.add_field(\"foo\", \"bar\", content_type=invalid_val)  # type: ignore[arg-type]\n\n\ndef test_invalid_formdata_filename() -> None:\n    form = FormData()\n    invalid_vals = [0, 0.1, {}, [], b\"foo\"]\n    for invalid_val in invalid_vals:\n        with pytest.raises(TypeError):\n            form.add_field(\"foo\", \"bar\", filename=invalid_val)  # type: ignore[arg-type]\n\n\nasync def test_formdata_field_name_is_quoted(\n    buf: bytearray, writer: StreamWriter\n) -> None:\n    form = FormData(charset=\"ascii\")\n    form.add_field(\"email 1\", \"xxx@x.co\", content_type=\"multipart/form-data\")\n    payload = form()\n    await payload.write(writer)\n    assert b'name=\"email\\\\ 1\"' in buf\n\n\nasync def test_formdata_field_name_is_not_quoted(\n    buf: bytearray, writer: StreamWriter\n) -> None:\n    form = FormData(quote_fields=False, charset=\"ascii\")\n    form.add_field(\"email 1\", \"xxx@x.co\", content_type=\"multipart/form-data\")\n    payload = form()\n    await payload.write(writer)\n    assert b'name=\"email 1\"' in buf\n\n\nasync def test_mark_formdata_as_processed(aiohttp_client: AiohttpClient) -> None:\n    async def handler(request: web.Request) -> web.Response:\n        return web.Response()\n\n    app = web.Application()\n    app.add_routes([web.post(\"/\", handler)])\n\n    client = await aiohttp_client(app)\n\n    data = FormData()\n    data.add_field(\"test\", \"test_value\", content_type=\"application/json\")\n\n    resp = await client.post(\"/\", data=data)\n    assert len(data._writer._parts) == 1\n\n    with pytest.raises(RuntimeError):\n        await client.post(\"/\", data=data)\n\n    resp.release()\n\n\nasync def test_formdata_boundary_param() -> None:\n    boundary = \"some_boundary\"\n    form = FormData(boundary=boundary)\n    assert form._writer.boundary == boundary\n",
            "header": {
                "file": {
                    "path": "tests/test_formdata.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "ac9b3447",
                "new_commit_hash": "73977f44",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/tests/test_formdata.py"
            },
            "plus_file": {
                "path": "b/tests/test_formdata.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 25,
                            "length": 13
                        },
                        "new_range": {
                            "start": 25,
                            "length": 21
                        },
                        "section": "def writer(buf: bytearray) -> StreamWriter:"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def test_formdata_multipart(buf: bytearray) -> None:",
                                "type": "context"
                            },
                            {
                                "content": "    form = FormData()",
                                "type": "deleted"
                            },
                            {
                                "content": "    form = FormData(default_to_multipart=False)",
                                "type": "added"
                            },
                            {
                                "content": "    assert not form.is_multipart",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    form.add_field(\"test\", b\"test\", filename=\"test.txt\")",
                                "type": "context"
                            },
                            {
                                "content": "    assert form.is_multipart",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def test_form_data_is_multipart_param(buf: bytearray) -> None:",
                                "type": "added"
                            },
                            {
                                "content": "    form = FormData(default_to_multipart=True)",
                                "type": "added"
                            },
                            {
                                "content": "    assert form.is_multipart",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    form.add_field(\"test\", \"test\")",
                                "type": "added"
                            },
                            {
                                "content": "    assert form.is_multipart",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "@pytest.mark.parametrize(\"obj\", (object(), None))",
                                "type": "context"
                            },
                            {
                                "content": "def test_invalid_formdata_payload_multipart(obj: object) -> None:",
                                "type": "context"
                            },
                            {
                                "content": "    form = FormData()",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "tests/test_formdata.py",
                            "type": "function",
                            "name": "test_formdata_multipart",
                            "content": "def test_formdata_multipart(buf: bytearray) -> None:\n    form = FormData()\n    assert not form.is_multipart\n\n    form.add_field(\"test\", b\"test\", filename=\"test.txt\")\n    assert form.is_multipart",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 27,
                            "end_lineno": 32,
                            "parent": null
                        }
                    ],
                    "added_entities": [
                        {
                            "file_name": "tests/test_formdata.py",
                            "type": "function",
                            "name": "test_form_data_is_multipart_param",
                            "content": "def test_form_data_is_multipart_param(buf: bytearray) -> None:\n    form = FormData(default_to_multipart=True)\n    assert form.is_multipart\n\n    form.add_field(\"test\", \"test\")\n    assert form.is_multipart",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 35,
                            "end_lineno": 40,
                            "parent": null
                        }
                    ],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "d9a9368f0923e1447231880075271e7fe38683d8^",
    "new_commit_hash": "d9a9368f0923e1447231880075271e7fe38683d8",
    "commit_message": "Add default_to_mulitpart parameter (#9335)\n\nCo-authored-by: Yevhenii Hyzyla <hyzyla@gmail.com>",
    "commit_date": "2024-09-29T13:59:21+01:00",
    "metadata": {}
}
{
    "repo_name": "aiohttp",
    "new_commit_hash": "d9a9368f0923e1447231880075271e7fe38683d8",
    "test_file_codes": [
        "import io\nfrom unittest import mock\n\nimport pytest\n\nfrom aiohttp import FormData, web\nfrom aiohttp.http_writer import StreamWriter\nfrom aiohttp.pytest_plugin import AiohttpClient\n\n\n@pytest.fixture\ndef buf() -> bytearray:\n    return bytearray()\n\n\n@pytest.fixture\ndef writer(buf: bytearray) -> StreamWriter:\n    writer = mock.create_autospec(StreamWriter, spec_set=True)\n\n    async def write(chunk: bytes) -> None:\n        buf.extend(chunk)\n\n    writer.write.side_effect = write\n    return writer  # type: ignore[no-any-return]\n\n\ndef test_formdata_multipart(buf: bytearray) -> None:\n    form = FormData(default_to_multipart=False)\n    assert not form.is_multipart\n\n    form.add_field(\"test\", b\"test\", filename=\"test.txt\")\n    assert form.is_multipart\n\n\ndef test_form_data_is_multipart_param(buf: bytearray) -> None:\n    form = FormData(default_to_multipart=True)\n    assert form.is_multipart\n\n    form.add_field(\"test\", \"test\")\n    assert form.is_multipart\n\n\n@pytest.mark.parametrize(\"obj\", (object(), None))\ndef test_invalid_formdata_payload_multipart(obj: object) -> None:\n    form = FormData()\n    form.add_field(\"test\", obj, filename=\"test.txt\")\n    with pytest.raises(TypeError, match=\"Can not serialize value\"):\n        form()\n\n\n@pytest.mark.parametrize(\"obj\", (object(), None))\ndef test_invalid_formdata_payload_urlencoded(obj: object) -> None:\n    form = FormData({\"test\": obj})\n    with pytest.raises(TypeError, match=\"expected str\"):\n        form()\n\n\ndef test_invalid_formdata_params() -> None:\n    with pytest.raises(TypeError):\n        FormData(\"asdasf\")\n\n\ndef test_invalid_formdata_params2() -> None:\n    with pytest.raises(TypeError):\n        FormData(\"as\")  # 2-char str is not allowed\n\n\nasync def test_formdata_textio_charset(buf: bytearray, writer: StreamWriter) -> None:\n    form = FormData()\n    body = io.TextIOWrapper(io.BytesIO(b\"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\"), encoding=\"utf-8\")\n    form.add_field(\"foo\", body, content_type=\"text/plain; charset=shift-jis\")\n    payload = form()\n    await payload.write(writer)\n    assert b\"charset=shift-jis\" in buf\n    assert b\"\\x93\\xfa\\x96{\" in buf\n\n\ndef test_invalid_formdata_content_type() -> None:\n    form = FormData()\n    invalid_vals = [0, 0.1, {}, [], b\"foo\"]\n    for invalid_val in invalid_vals:\n        with pytest.raises(TypeError):\n            form.add_field(\"foo\", \"bar\", content_type=invalid_val)  # type: ignore[arg-type]\n\n\ndef test_invalid_formdata_filename() -> None:\n    form = FormData()\n    invalid_vals = [0, 0.1, {}, [], b\"foo\"]\n    for invalid_val in invalid_vals:\n        with pytest.raises(TypeError):\n            form.add_field(\"foo\", \"bar\", filename=invalid_val)  # type: ignore[arg-type]\n\n\nasync def test_formdata_field_name_is_quoted(\n    buf: bytearray, writer: StreamWriter\n) -> None:\n    form = FormData(charset=\"ascii\")\n    form.add_field(\"email 1\", \"xxx@x.co\", content_type=\"multipart/form-data\")\n    payload = form()\n    await payload.write(writer)\n    assert b'name=\"email\\\\ 1\"' in buf\n\n\nasync def test_formdata_field_name_is_not_quoted(\n    buf: bytearray, writer: StreamWriter\n) -> None:\n    form = FormData(quote_fields=False, charset=\"ascii\")\n    form.add_field(\"email 1\", \"xxx@x.co\", content_type=\"multipart/form-data\")\n    payload = form()\n    await payload.write(writer)\n    assert b'name=\"email 1\"' in buf\n\n\nasync def test_mark_formdata_as_processed(aiohttp_client: AiohttpClient) -> None:\n    async def handler(request: web.Request) -> web.Response:\n        return web.Response()\n\n    app = web.Application()\n    app.add_routes([web.post(\"/\", handler)])\n\n    client = await aiohttp_client(app)\n\n    data = FormData()\n    data.add_field(\"test\", \"test_value\", content_type=\"application/json\")\n\n    resp = await client.post(\"/\", data=data)\n    assert len(data._writer._parts) == 1\n\n    with pytest.raises(RuntimeError):\n        await client.post(\"/\", data=data)\n\n    resp.release()\n\n\nasync def test_formdata_boundary_param() -> None:\n    boundary = \"some_boundary\"\n    form = FormData(boundary=boundary)\n    assert form._writer.boundary == boundary\n",
        "# type: ignore\nimport asyncio\nimport base64\nimport os\nimport socket\nimport ssl\nimport sys\nfrom hashlib import md5, sha1, sha256\nfrom pathlib import Path\nfrom tempfile import TemporaryDirectory\nfrom typing import Any, List\nfrom unittest import mock\nfrom uuid import uuid4\n\nimport pytest\n\nfrom aiohttp.client_proto import ResponseHandler\nfrom aiohttp.http import WS_KEY\nfrom aiohttp.test_utils import loop_context\n\ntry:\n    import trustme\n\n    # Check if the CA is available in runtime, MacOS on Py3.10 fails somehow\n    trustme.CA()\n\n    TRUSTME: bool = True\nexcept ImportError:\n    TRUSTME = False\n\npytest_plugins: List[str] = [\"aiohttp.pytest_plugin\", \"pytester\"]\n\nIS_HPUX = sys.platform.startswith(\"hp-ux\")\nIS_LINUX = sys.platform.startswith(\"linux\")\n\n\n@pytest.fixture\ndef tls_certificate_authority() -> trustme.CA:\n    if not TRUSTME:\n        pytest.xfail(\"trustme is not supported\")\n    return trustme.CA()\n\n\n@pytest.fixture\ndef tls_certificate(tls_certificate_authority: Any) -> Any:\n    return tls_certificate_authority.issue_cert(\n        \"localhost\",\n        \"xn--prklad-4va.localhost\",\n        \"127.0.0.1\",\n        \"::1\",\n    )\n\n\n@pytest.fixture\ndef ssl_ctx(tls_certificate: Any) -> ssl.SSLContext:\n    ssl_ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)\n    tls_certificate.configure_cert(ssl_ctx)\n    return ssl_ctx\n\n\n@pytest.fixture\ndef client_ssl_ctx(tls_certificate_authority: Any) -> ssl.SSLContext:\n    ssl_ctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)\n    tls_certificate_authority.configure_trust(ssl_ctx)\n    return ssl_ctx\n\n\n@pytest.fixture\ndef tls_ca_certificate_pem_path(tls_certificate_authority: Any) -> None:\n    with tls_certificate_authority.cert_pem.tempfile() as ca_cert_pem:\n        yield ca_cert_pem\n\n\n@pytest.fixture\ndef tls_certificate_pem_path(tls_certificate: Any) -> None:\n    with tls_certificate.private_key_and_cert_chain_pem.tempfile() as cert_pem:\n        yield cert_pem\n\n\n@pytest.fixture\ndef tls_certificate_pem_bytes(tls_certificate: Any) -> bytes:\n    return tls_certificate.cert_chain_pems[0].bytes()\n\n\n@pytest.fixture\ndef tls_certificate_fingerprint_sha256(tls_certificate_pem_bytes: Any) -> bytes:\n    tls_cert_der = ssl.PEM_cert_to_DER_cert(tls_certificate_pem_bytes.decode())\n    return sha256(tls_cert_der).digest()\n\n\n@pytest.fixture\ndef pipe_name() -> str:\n    name = rf\"\\\\.\\pipe\\{uuid4().hex}\"\n    return name\n\n\n@pytest.fixture\ndef create_mocked_conn(loop: Any):\n    def _proto_factory(conn_closing_result=None, **kwargs) -> ResponseHandler:\n        proto = mock.create_autospec(ResponseHandler, **kwargs)\n        proto.closed = loop.create_future()\n        proto.closed.set_result(conn_closing_result)\n        return proto\n\n    yield _proto_factory\n\n\n@pytest.fixture\ndef unix_sockname(tmp_path: Any, tmp_path_factory: Any):\n    # Generate an fs path to the UNIX domain socket for testing.\n\n    # N.B. Different OS kernels have different fs path length limitations\n    # for it. For Linux, it's 108, for HP-UX it's 92 (or higher) depending\n    # on its version. For most of the BSDs (Open, Free, macOS) it's\n    # mostly 104 but sometimes it can be down to 100.\n\n    # Ref: https://github.com/aio-libs/aiohttp/issues/3572\n    if not hasattr(socket, \"AF_UNIX\"):\n        pytest.skip(\"requires UNIX sockets\")\n\n    max_sock_len = 92 if IS_HPUX else 108 if IS_LINUX else 100\n    # Amount of bytes allocated for the UNIX socket path by OS kernel.\n    # Ref: https://unix.stackexchange.com/a/367012/27133\n\n    sock_file_name = \"unix.sock\"\n    unique_prefix = f\"{uuid4()!s}-\"\n    unique_prefix_len = len(unique_prefix.encode())\n\n    root_tmp_dir = Path(\"/tmp\").resolve()\n    os_tmp_dir = Path(os.getenv(\"TMPDIR\", \"/tmp\")).resolve()\n    original_base_tmp_path = Path(\n        str(tmp_path_factory.getbasetemp()),\n    ).resolve()\n\n    original_base_tmp_path_hash = md5(\n        str(original_base_tmp_path).encode(),\n    ).hexdigest()\n\n    def make_tmp_dir(base_tmp_dir):\n        return TemporaryDirectory(\n            dir=str(base_tmp_dir),\n            prefix=\"pt-\",\n            suffix=f\"-{original_base_tmp_path_hash!s}\",\n        )\n\n    def assert_sock_fits(sock_path):\n        sock_path_len = len(sock_path.encode())\n        # exit-check to verify that it's correct and simplify debugging\n        # in the future\n        assert sock_path_len <= max_sock_len, (\n            \"Suggested UNIX socket ({sock_path}) is {sock_path_len} bytes \"\n            \"long but the current kernel only has {max_sock_len} bytes \"\n            \"allocated to hold it so it must be shorter. \"\n            \"See https://github.com/aio-libs/aiohttp/issues/3572 \"\n            \"for more info.\"\n        ).format_map(locals())\n\n    paths = original_base_tmp_path, os_tmp_dir, root_tmp_dir\n    unique_paths = [p for n, p in enumerate(paths) if p not in paths[:n]]\n    paths_num = len(unique_paths)\n\n    for num, tmp_dir_path in enumerate(paths, 1):\n        with make_tmp_dir(tmp_dir_path) as tmpd:\n            tmpd = Path(tmpd).resolve()\n            sock_path = str(tmpd / sock_file_name)\n            sock_path_len = len(sock_path.encode())\n\n            if num >= paths_num:\n                # exit-check to verify that it's correct and simplify\n                # debugging in the future\n                assert_sock_fits(sock_path)\n\n            if sock_path_len <= max_sock_len:\n                if max_sock_len - sock_path_len >= unique_prefix_len:\n                    # If we're lucky to have extra space in the path,\n                    # let's also make it more unique\n                    sock_path = str(tmpd / \"\".join((unique_prefix, sock_file_name)))\n                    # Double-checking it:\n                    assert_sock_fits(sock_path)\n                yield sock_path\n                return\n\n\n@pytest.fixture\ndef selector_loop() -> None:\n    policy = asyncio.WindowsSelectorEventLoopPolicy()\n    asyncio.set_event_loop_policy(policy)\n\n    with loop_context(policy.new_event_loop) as _loop:\n        asyncio.set_event_loop(_loop)\n        yield _loop\n\n\n@pytest.fixture\ndef netrc_contents(\n    tmp_path: Path,\n    monkeypatch: pytest.MonkeyPatch,\n    request: pytest.FixtureRequest,\n):\n    \"\"\"\n    Prepare :file:`.netrc` with given contents.\n\n    Monkey-patches :envvar:`NETRC` to point to created file.\n    \"\"\"\n    netrc_contents = getattr(request, \"param\", None)\n\n    netrc_file_path = tmp_path / \".netrc\"\n    if netrc_contents is not None:\n        netrc_file_path.write_text(netrc_contents)\n\n    monkeypatch.setenv(\"NETRC\", str(netrc_file_path))\n\n    return netrc_file_path\n\n\n@pytest.fixture\ndef start_connection():\n    with mock.patch(\n        \"aiohttp.connector.aiohappyeyeballs.start_connection\",\n        autospec=True,\n        spec_set=True,\n    ) as start_connection_mock:\n        yield start_connection_mock\n\n\n@pytest.fixture\ndef key_data() -> bytes:\n    return os.urandom(16)\n\n\n@pytest.fixture\ndef key(key_data: bytes) -> bytes:\n    return base64.b64encode(key_data)\n\n\n@pytest.fixture\ndef ws_key(key: bytes) -> bytes:\n    return base64.b64encode(sha1(key + WS_KEY).digest()).decode()\n"
    ],
    "test_file_names": [
        "test_1.py",
        "conftest.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "re-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/requirements/cython.txt\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/hdrs.py\n./tools/gen.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/_helpers.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/_http_parser.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/_http_writer.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/_websocket.pyx\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/_helpers.pyi\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/_cparser.pxd\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/_find_header.pxd\ncython -3 -o aiohttp/_helpers.c aiohttp/_helpers.pyx -I aiohttp -Werror\ncython -3 -o aiohttp/_http_parser.c aiohttp/_http_parser.pyx -I aiohttp -Werror\ncython -3 -o aiohttp/_http_writer.c aiohttp/_http_writer.pyx -I aiohttp -Werror\ncython -3 -o aiohttp/_websocket.c aiohttp/_websocket.pyx -I aiohttp -Werror\ncd vendor/llhttp; npm ci\n\n> llhttp@9.2.1 prepare\n> npm run clean && npm run build-ts\n\n\n> llhttp@9.2.1 clean\n> rm -rf lib && rm -rf test/tmp\n\n\n> llhttp@9.2.1 build-ts\n> tsc\n\n\nadded 213 packages, and audited 214 packages in 5s\n\n41 packages are looking for funding\n  run `npm fund` for details\n\n5 vulnerabilities (3 moderate, 2 high)\n\nTo address issues that do not require attention, run:\n  npm audit fix\n\nSome issues need review, and may require choosing\na different dependency.\n\nRun `npm audit` for details.\nmake -C vendor/llhttp generate\nmake[1]: Entering directory '/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/vendor/llhttp'\nnpx ts-node bin/generate.ts\nmake[1]: Leaving directory '/home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/vendor/llhttp'\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/__init__.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/abc.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/base_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/client.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/client_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/client_proto.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/client_reqrep.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/client_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/compression_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/connector.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/cookiejar.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/formdata.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/http.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/http_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/http_parser.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/http_websocket.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/http_writer.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/locks.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/multipart.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/payload.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/pytest_plugin.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/resolver.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/streams.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/tcp_helpers.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/test_utils.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/tracing.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/typedefs.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_app.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_exceptions.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_fileresponse.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_log.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_middlewares.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_protocol.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_request.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_response.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_routedef.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_runner.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_server.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_urldispatcher.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/web_ws.py\nre-hash /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/aiohttp/worker.py\nuv pip install -e . -c requirements/runtime-deps.txt\n",
    "setup_res_stderr": "Using CPython 3.9.21\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 1 package in 2ms\nPrepared 1 package in 0.31ms\nInstalled 1 package in 20ms\n + pip==24.3.1\nResolved 3 packages in 11ms\nInstalled 3 packages in 15ms\n + cython==3.0.11\n + multidict==6.1.0\n + typing-extensions==4.12.2\nResolved 97 packages in 50ms\nUninstalled 1 package in 17ms\nInstalled 95 packages in 476ms\n + aiodns==3.2.0\n + aiohappyeyeballs==2.4.2\n + aiohttp-theme==0.1.7\n + aiosignal==1.3.1\n + alabaster==0.7.13\n + annotated-types==0.7.0\n + async-timeout==4.0.3\n + babel==2.16.0\n + blockdiag==3.0.0\n + brotli==1.1.0\n + build==1.2.2\n + certifi==2024.8.30\n + cffi==1.17.1\n + cfgv==3.4.0\n + charset-normalizer==3.3.2\n + cherry-picker==2.2.0\n + click==8.1.7\n + coverage==7.6.1\n + cryptography==43.0.1\n + distlib==0.3.8\n + docutils==0.20.1\n + exceptiongroup==1.2.2\n + filelock==3.16.1\n + freezegun==1.5.1\n + frozenlist==1.4.1\n + funcparserlib==1.0.1\n + gidgethub==5.3.0\n + gunicorn==23.0.0\n + identify==2.6.1\n + idna==3.6\n + imagesize==1.4.1\n + importlib-metadata==8.5.0\n + importlib-resources==6.4.5\n + incremental==24.7.2\n + iniconfig==2.0.0\n + jinja2==3.1.4\n + markdown-it-py==3.0.0\n + markupsafe==2.1.5\n + mdurl==0.1.2\n + mypy==1.11.2\n + mypy-extensions==1.0.0\n + nodeenv==1.9.1\n + packaging==24.1\n + pillow==9.5.0\n - pip==24.3.1\n + pip==24.2\n + pip-tools==7.4.1\n + platformdirs==4.3.6\n + pluggy==1.5.0\n + pre-commit==3.5.0\n + proxy-py==2.4.8\n + pycares==4.4.0\n + pycparser==2.22\n + pydantic==2.9.2\n + pydantic-core==2.23.4\n + pygments==2.18.0\n + pyjwt==2.8.0\n + pyproject-hooks==1.1.0\n + pytest==8.1.1\n + pytest-cov==5.0.0\n + pytest-mock==3.14.0\n + python-dateutil==2.9.0.post0\n + python-on-whales==0.73.0\n + pyyaml==6.0.2\n + requests==2.32.3\n + rich==13.8.1\n + setuptools==75.1.0\n + setuptools-git==1.2\n + shellingham==1.5.4\n + six==1.16.0\n + slotscheck==0.19.0\n + snowballstemmer==2.2.0\n + sphinx==7.1.2\n + sphinxcontrib-applehelp==1.0.4\n + sphinxcontrib-blockdiag==3.0.0\n + sphinxcontrib-devhelp==1.0.2\n + sphinxcontrib-htmlhelp==2.0.1\n + sphinxcontrib-jsmath==1.0.1\n + sphinxcontrib-qthelp==1.0.3\n + sphinxcontrib-serializinghtml==1.1.5\n + sphinxcontrib-towncrier==0.4.0a0\n + tomli==2.0.1\n + towncrier==23.11.0\n + tqdm==4.66.5\n + trustme==1.1.0\n + typer==0.12.5\n + uritemplate==4.1.1\n + urllib3==2.2.3\n + uvloop==0.21.0b1\n + valkey==6.0.2\n + virtualenv==20.26.5\n + wait-for-it==2.2.2\n + webcolors==24.8.0\n + wheel==0.44.0\n + yarl==1.13.0\n + zipp==3.20.2\nwarning: `aiohappyeyeballs==2.4.2` is yanked (reason: \"Regression: https://github.com/aio-libs/aiohappyeyeballs/issues/100\")\nResolved 9 packages in 1.71s\nPrepared 1 package in 17.10s\nInstalled 1 package in 0.76ms\n + aiohttp==4.0.0a2.dev0 (from file:///home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8)\nResolved 25 packages in 16ms\nInstalled 5 packages in 5ms\n + async-generator==1.10\n + brotlipy==0.7.0\n + chardet==5.2.0\n + multdict==0.0.5\n + pytest-asyncio==0.23.8\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.1.1, pluggy-1.5.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8\nconfigfile: setup.cfg\nplugins: cov-5.0.0, mock-3.14.0, asyncio-0.23.8\nasyncio: mode=strict\ncollecting ... collected 15 items\n\nr2e_tests/test_1.py::test_formdata_multipart PASSED                      [  6%]\nr2e_tests/test_1.py::test_form_data_is_multipart_param PASSED            [ 13%]\nr2e_tests/test_1.py::test_invalid_formdata_payload_multipart[obj0] PASSED [ 20%]\nr2e_tests/test_1.py::test_invalid_formdata_payload_multipart[None] PASSED [ 26%]\nr2e_tests/test_1.py::test_invalid_formdata_payload_urlencoded[obj0] PASSED [ 33%]\nr2e_tests/test_1.py::test_invalid_formdata_payload_urlencoded[None] PASSED [ 40%]\nr2e_tests/test_1.py::test_invalid_formdata_params PASSED                 [ 46%]\nr2e_tests/test_1.py::test_invalid_formdata_params2 PASSED                [ 53%]\nr2e_tests/test_1.py::test_formdata_textio_charset PASSED                 [ 60%]\nr2e_tests/test_1.py::test_invalid_formdata_content_type PASSED           [ 66%]\nr2e_tests/test_1.py::test_invalid_formdata_filename PASSED               [ 73%]\nr2e_tests/test_1.py::test_formdata_field_name_is_quoted PASSED           [ 80%]\nr2e_tests/test_1.py::test_formdata_field_name_is_not_quoted PASSED       [ 86%]\nr2e_tests/test_1.py::test_mark_formdata_as_processed[pyloop] PASSED      [ 93%]\nr2e_tests/test_1.py::test_formdata_boundary_param PASSED                 [100%]\n\n==================================== PASSES ====================================\n\n---------- coverage: platform linux, python 3.9.21-final-0 -----------\nName                                     Stmts   Miss Branch BrPart  Cover\n--------------------------------------------------------------------------\naiohttp/__init__.py                         26     10      2      0    57%\naiohttp/abc.py                              98      2      0      0    98%\naiohttp/base_protocol.py                    68     36     22      3    39%\naiohttp/client.py                          521    238    190     52    48%\naiohttp/client_exceptions.py               139     55     14      1    56%\naiohttp/client_proto.py                    169     58     58     19    58%\naiohttp/client_reqrep.py                   660    268    276     73    51%\naiohttp/client_ws.py                       269    213     82      1    17%\naiohttp/compression_utils.py                70     36     14      0    40%\naiohttp/connector.py                       714    387    305     51    38%\naiohttp/cookiejar.py                       272    195    132      7    21%\naiohttp/formdata.py                         88      9     40      5    88%\naiohttp/hdrs.py                             90      0      0      0   100%\naiohttp/helpers.py                         559    263    212     32    46%\naiohttp/http.py                              8      0      0      0   100%\naiohttp/http_exceptions.py                  48     18      2      0    60%\naiohttp/http_parser.py                     496    397    208      1    14%\naiohttp/http_websocket.py                  382    283    148      0    19%\naiohttp/http_writer.py                     119     44     50     16    54%\naiohttp/locks.py                            24     16      4      0    29%\naiohttp/log.py                               7      0      0      0   100%\naiohttp/multipart.py                       625    474    268      9    19%\naiohttp/payload.py                         237     63     58     12    68%\naiohttp/pytest_plugin.py                   161     58     42      6    62%\naiohttp/resolver.py                         62     40     18      1    29%\naiohttp/streams.py                         395    243    142     14    31%\naiohttp/tcp_helpers.py                      19      2      6      3    80%\naiohttp/test_utils.py                      302    112     52     14    58%\naiohttp/tracing.py                         193     69     32      0    69%\naiohttp/typedefs.py                         24      0      0      0   100%\naiohttp/web.py                             128     90     54      0    22%\naiohttp/web_app.py                         237     88     50     11    56%\naiohttp/web_exceptions.py                  216     39     28      6    77%\naiohttp/web_fileresponse.py                160    126     52      0    18%\naiohttp/web_log.py                          96     31     14      2    65%\naiohttp/web_middlewares.py                  58     42     22      0    20%\naiohttp/web_protocol.py                    376    150    158     47    50%\naiohttp/web_request.py                     444    258    142      9    34%\naiohttp/web_response.py                    441    223    198     32    40%\naiohttp/web_routedef.py                    100     39     10      1    60%\naiohttp/web_runner.py                      222     71     40     12    63%\naiohttp/web_server.py                       49      7     14      3    81%\naiohttp/web_urldispatcher.py               719    366    155     21    43%\naiohttp/web_ws.py                          383    311    132      1    15%\naiohttp/worker.py                          123    123     30      0     0%\ntests/conftest.py                          131    131     16      0     0%\ntests/test_base_protocol.py                198    198      2      0     0%\ntests/test_circular_imports.py              29     29     13      0     0%\ntests/test_classbasedview.py                39     39      0      0     0%\ntests/test_client_connection.py             93     93      2      0     0%\ntests/test_client_exceptions.py            182    182     14      0     0%\ntests/test_client_fingerprint.py            24     24      0      0     0%\ntests/test_client_functional.py           2600   2600     72      0     0%\ntests/test_client_proto.py                 103    103      0      0     0%\ntests/test_client_request.py               790    790     18      0     0%\ntests/test_client_response.py              502    502      6      0     0%\ntests/test_client_session.py               572    572     29      0     0%\ntests/test_client_ws.py                    486    486      2      0     0%\ntests/test_client_ws_functional.py         782    782     22      0     0%\ntests/test_connector.py                   1699   1699     84      0     0%\ntests/test_cookiejar.py                    469    469     28      0     0%\ntests/test_flowcontrol_streams.py           98     98      0      0     0%\ntests/test_formdata.py                      92     92      4      0     0%\ntests/test_helpers.py                      604    604     22      0     0%\ntests/test_http_exceptions.py              110    110     10      0     0%\ntests/test_http_parser.py                 1091   1091     44      0     0%\ntests/test_http_writer.py                  178    178     10      0     0%\ntests/test_imports.py                       34     34      6      0     0%\ntests/test_locks.py                         40     40      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    869    869     34      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       80     80      0      0     0%\ntests/test_proxy.py                        336    336      0      0     0%\ntests/test_proxy_functional.py             465    465     20      0     0%\ntests/test_pytest_plugin.py                 47     47      0      0     0%\ntests/test_resolver.py                     183    183     18      0     0%\ntests/test_route_def.py                    191    191      0      0     0%\ntests/test_run_app.py                      576    576     30      0     0%\ntests/test_streams.py                     1061   1061     38      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   244    244     12      0     0%\ntests/test_tracing.py                       49     49      0      0     0%\ntests/test_urldispatch.py                  862    862     24      0     0%\ntests/test_web_app.py                      383    383      6      0     0%\ntests/test_web_cli.py                       94     94      0      0     0%\ntests/test_web_exceptions.py               277    277     30      0     0%\ntests/test_web_functional.py              1557   1557     24      0     0%\ntests/test_web_log.py                      145    145      4      0     0%\ntests/test_web_middleware.py               245    245      6      0     0%\ntests/test_web_request.py                  544    544      0      0     0%\ntests/test_web_request_handler.py           42     42      0      0     0%\ntests/test_web_response.py                 872    872      6      0     0%\ntests/test_web_runner.py                   179    179      4      0     0%\ntests/test_web_sendfile.py                  85     85      0      0     0%\ntests/test_web_sendfile_functional.py      681    681     18      0     0%\ntests/test_web_server.py                   179    179      0      0     0%\ntests/test_web_urldispatcher.py            511    511     24      0     0%\ntests/test_web_websocket.py                407    407      8      0     0%\ntests/test_web_websocket_functional.py     828    828     24      0     0%\ntests/test_websocket_handshake.py          153    153     12      0     0%\ntests/test_websocket_parser.py             290    290     12      0     0%\ntests/test_websocket_writer.py              96     96      6      0     0%\ntests/test_worker.py                       190    190      2      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    34798  29754   4244    465    15%\n\n============================= slowest 10 durations =============================\n0.02s call     r2e_tests/test_1.py::test_formdata_textio_charset\n0.02s call     r2e_tests/test_1.py::test_formdata_field_name_is_quoted\n0.02s setup    r2e_tests/test_1.py::test_formdata_textio_charset\n0.02s call     r2e_tests/test_1.py::test_formdata_field_name_is_not_quoted\n0.01s teardown r2e_tests/test_1.py::test_mark_formdata_as_processed[pyloop]\n0.01s setup    r2e_tests/test_1.py::test_formdata_field_name_is_quoted\n0.01s setup    r2e_tests/test_1.py::test_formdata_field_name_is_not_quoted\n0.01s call     r2e_tests/test_1.py::test_formdata_boundary_param\n\n(2 durations < 0.005s hidden.  Use -vv to show these durations.)\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_formdata_multipart\nPASSED r2e_tests/test_1.py::test_form_data_is_multipart_param\nPASSED r2e_tests/test_1.py::test_invalid_formdata_payload_multipart[obj0]\nPASSED r2e_tests/test_1.py::test_invalid_formdata_payload_multipart[None]\nPASSED r2e_tests/test_1.py::test_invalid_formdata_payload_urlencoded[obj0]\nPASSED r2e_tests/test_1.py::test_invalid_formdata_payload_urlencoded[None]\nPASSED r2e_tests/test_1.py::test_invalid_formdata_params\nPASSED r2e_tests/test_1.py::test_invalid_formdata_params2\nPASSED r2e_tests/test_1.py::test_formdata_textio_charset\nPASSED r2e_tests/test_1.py::test_invalid_formdata_content_type\nPASSED r2e_tests/test_1.py::test_invalid_formdata_filename\nPASSED r2e_tests/test_1.py::test_formdata_field_name_is_quoted\nPASSED r2e_tests/test_1.py::test_formdata_field_name_is_not_quoted\nPASSED r2e_tests/test_1.py::test_mark_formdata_as_processed[pyloop]\nPASSED r2e_tests/test_1.py::test_formdata_boundary_param\n============================== 15 passed in 5.03s ==============================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.9.21, pytest-8.1.1, pluggy-1.5.0 -- /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/aiohttp_d9a9368f0923e1447231880075271e7fe38683d8\nconfigfile: setup.cfg\nplugins: cov-5.0.0, mock-3.14.0, asyncio-0.23.8\nasyncio: mode=strict\ncollecting ... collected 15 items\n\nr2e_tests/test_1.py::test_formdata_multipart FAILED                      [  6%]\nr2e_tests/test_1.py::test_form_data_is_multipart_param FAILED            [ 13%]\nr2e_tests/test_1.py::test_invalid_formdata_payload_multipart[obj0] PASSED [ 20%]\nr2e_tests/test_1.py::test_invalid_formdata_payload_multipart[None] PASSED [ 26%]\nr2e_tests/test_1.py::test_invalid_formdata_payload_urlencoded[obj0] PASSED [ 33%]\nr2e_tests/test_1.py::test_invalid_formdata_payload_urlencoded[None] PASSED [ 40%]\nr2e_tests/test_1.py::test_invalid_formdata_params PASSED                 [ 46%]\nr2e_tests/test_1.py::test_invalid_formdata_params2 PASSED                [ 53%]\nr2e_tests/test_1.py::test_formdata_textio_charset PASSED                 [ 60%]\nr2e_tests/test_1.py::test_invalid_formdata_content_type PASSED           [ 66%]\nr2e_tests/test_1.py::test_invalid_formdata_filename PASSED               [ 73%]\nr2e_tests/test_1.py::test_formdata_field_name_is_quoted PASSED           [ 80%]\nr2e_tests/test_1.py::test_formdata_field_name_is_not_quoted PASSED       [ 86%]\nr2e_tests/test_1.py::test_mark_formdata_as_processed[pyloop] PASSED      [ 93%]\nr2e_tests/test_1.py::test_formdata_boundary_param PASSED                 [100%]\n\n=================================== FAILURES ===================================\n___________________________ test_formdata_multipart ____________________________\n\nbuf = bytearray(b'')\n\n    def test_formdata_multipart(buf: bytearray) -> None:\n>       form = FormData(default_to_multipart=False)\nE       TypeError: __init__() got an unexpected keyword argument 'default_to_multipart'\n\nbuf        = bytearray(b'')\n\nr2e_tests/test_1.py:28: TypeError\n______________________ test_form_data_is_multipart_param _______________________\n\nbuf = bytearray(b'')\n\n    def test_form_data_is_multipart_param(buf: bytearray) -> None:\n>       form = FormData(default_to_multipart=True)\nE       TypeError: __init__() got an unexpected keyword argument 'default_to_multipart'\n\nbuf        = bytearray(b'')\n\nr2e_tests/test_1.py:36: TypeError\n==================================== PASSES ====================================\n\n---------- coverage: platform linux, python 3.9.21-final-0 -----------\nName                                     Stmts   Miss Branch BrPart  Cover\n--------------------------------------------------------------------------\naiohttp/__init__.py                         26     10      2      0    57%\naiohttp/abc.py                              98      2      0      0    98%\naiohttp/base_protocol.py                    68     36     22      3    39%\naiohttp/client.py                          521    238    190     52    48%\naiohttp/client_exceptions.py               139     55     14      1    56%\naiohttp/client_proto.py                    169     58     58     19    58%\naiohttp/client_reqrep.py                   660    268    276     73    51%\naiohttp/client_ws.py                       269    213     82      1    17%\naiohttp/compression_utils.py                70     36     14      0    40%\naiohttp/connector.py                       714    387    305     51    38%\naiohttp/cookiejar.py                       272    195    132      7    21%\naiohttp/formdata.py                         88     10     40      5    87%\naiohttp/hdrs.py                             90      0      0      0   100%\naiohttp/helpers.py                         559    263    212     32    46%\naiohttp/http.py                              8      0      0      0   100%\naiohttp/http_exceptions.py                  48     18      2      0    60%\naiohttp/http_parser.py                     496    397    208      1    14%\naiohttp/http_websocket.py                  382    283    148      0    19%\naiohttp/http_writer.py                     119     44     50     16    54%\naiohttp/locks.py                            24     16      4      0    29%\naiohttp/log.py                               7      0      0      0   100%\naiohttp/multipart.py                       625    474    268      9    19%\naiohttp/payload.py                         237     63     58     12    68%\naiohttp/pytest_plugin.py                   161     58     42      6    62%\naiohttp/resolver.py                         62     40     18      1    29%\naiohttp/streams.py                         395    243    142     14    31%\naiohttp/tcp_helpers.py                      19      2      6      3    80%\naiohttp/test_utils.py                      302    112     52     14    58%\naiohttp/tracing.py                         193     69     32      0    69%\naiohttp/typedefs.py                         24      0      0      0   100%\naiohttp/web.py                             128     90     54      0    22%\naiohttp/web_app.py                         237     88     50     11    56%\naiohttp/web_exceptions.py                  216     39     28      6    77%\naiohttp/web_fileresponse.py                160    126     52      0    18%\naiohttp/web_log.py                          96     31     14      2    65%\naiohttp/web_middlewares.py                  58     42     22      0    20%\naiohttp/web_protocol.py                    376    150    158     47    50%\naiohttp/web_request.py                     444    258    142      9    34%\naiohttp/web_response.py                    441    223    198     32    40%\naiohttp/web_routedef.py                    100     39     10      1    60%\naiohttp/web_runner.py                      222     71     40     12    63%\naiohttp/web_server.py                       49      7     14      3    81%\naiohttp/web_urldispatcher.py               719    366    155     21    43%\naiohttp/web_ws.py                          383    311    132      1    15%\naiohttp/worker.py                          123    123     30      0     0%\ntests/conftest.py                          131    131     16      0     0%\ntests/test_base_protocol.py                198    198      2      0     0%\ntests/test_circular_imports.py              29     29     13      0     0%\ntests/test_classbasedview.py                39     39      0      0     0%\ntests/test_client_connection.py             93     93      2      0     0%\ntests/test_client_exceptions.py            182    182     14      0     0%\ntests/test_client_fingerprint.py            24     24      0      0     0%\ntests/test_client_functional.py           2600   2600     72      0     0%\ntests/test_client_proto.py                 103    103      0      0     0%\ntests/test_client_request.py               790    790     18      0     0%\ntests/test_client_response.py              502    502      6      0     0%\ntests/test_client_session.py               572    572     29      0     0%\ntests/test_client_ws.py                    486    486      2      0     0%\ntests/test_client_ws_functional.py         782    782     22      0     0%\ntests/test_connector.py                   1699   1699     84      0     0%\ntests/test_cookiejar.py                    469    469     28      0     0%\ntests/test_flowcontrol_streams.py           98     98      0      0     0%\ntests/test_formdata.py                      87     87      4      0     0%\ntests/test_helpers.py                      604    604     22      0     0%\ntests/test_http_exceptions.py              110    110     10      0     0%\ntests/test_http_parser.py                 1091   1091     44      0     0%\ntests/test_http_writer.py                  178    178     10      0     0%\ntests/test_imports.py                       34     34      6      0     0%\ntests/test_locks.py                         40     40      0      0     0%\ntests/test_loop.py                          36     36      0      0     0%\ntests/test_multipart.py                    869    869     34      0     0%\ntests/test_multipart_helpers.py            446    446      0      0     0%\ntests/test_payload.py                       80     80      0      0     0%\ntests/test_proxy.py                        336    336      0      0     0%\ntests/test_proxy_functional.py             465    465     20      0     0%\ntests/test_pytest_plugin.py                 47     47      0      0     0%\ntests/test_resolver.py                     183    183     18      0     0%\ntests/test_route_def.py                    191    191      0      0     0%\ntests/test_run_app.py                      576    576     30      0     0%\ntests/test_streams.py                     1061   1061     38      0     0%\ntests/test_tcp_helpers.py                   52     52      2      0     0%\ntests/test_test_utils.py                   244    244     12      0     0%\ntests/test_tracing.py                       49     49      0      0     0%\ntests/test_urldispatch.py                  862    862     24      0     0%\ntests/test_web_app.py                      383    383      6      0     0%\ntests/test_web_cli.py                       94     94      0      0     0%\ntests/test_web_exceptions.py               277    277     30      0     0%\ntests/test_web_functional.py              1557   1557     24      0     0%\ntests/test_web_log.py                      145    145      4      0     0%\ntests/test_web_middleware.py               245    245      6      0     0%\ntests/test_web_request.py                  544    544      0      0     0%\ntests/test_web_request_handler.py           42     42      0      0     0%\ntests/test_web_response.py                 872    872      6      0     0%\ntests/test_web_runner.py                   179    179      4      0     0%\ntests/test_web_sendfile.py                  85     85      0      0     0%\ntests/test_web_sendfile_functional.py      681    681     18      0     0%\ntests/test_web_server.py                   179    179      0      0     0%\ntests/test_web_urldispatcher.py            511    511     24      0     0%\ntests/test_web_websocket.py                407    407      8      0     0%\ntests/test_web_websocket_functional.py     828    828     24      0     0%\ntests/test_websocket_handshake.py          153    153     12      0     0%\ntests/test_websocket_parser.py             290    290     12      0     0%\ntests/test_websocket_writer.py              96     96      6      0     0%\ntests/test_worker.py                       190    190      2      0     0%\n--------------------------------------------------------------------------\nTOTAL                                    34793  29750   4244    465    15%\n\n============================= slowest 10 durations =============================\n0.04s setup    r2e_tests/test_1.py::test_formdata_textio_charset\n0.03s call     r2e_tests/test_1.py::test_formdata_textio_charset\n0.03s call     r2e_tests/test_1.py::test_formdata_field_name_is_quoted\n0.03s call     r2e_tests/test_1.py::test_formdata_field_name_is_not_quoted\n0.03s teardown r2e_tests/test_1.py::test_mark_formdata_as_processed[pyloop]\n0.02s setup    r2e_tests/test_1.py::test_formdata_field_name_is_not_quoted\n0.02s call     r2e_tests/test_1.py::test_formdata_boundary_param\n0.02s setup    r2e_tests/test_1.py::test_formdata_field_name_is_quoted\n0.01s call     r2e_tests/test_1.py::test_mark_formdata_as_processed[pyloop]\n\n(1 durations < 0.005s hidden.  Use -vv to show these durations.)\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::test_invalid_formdata_payload_multipart[obj0]\nPASSED r2e_tests/test_1.py::test_invalid_formdata_payload_multipart[None]\nPASSED r2e_tests/test_1.py::test_invalid_formdata_payload_urlencoded[obj0]\nPASSED r2e_tests/test_1.py::test_invalid_formdata_payload_urlencoded[None]\nPASSED r2e_tests/test_1.py::test_invalid_formdata_params\nPASSED r2e_tests/test_1.py::test_invalid_formdata_params2\nPASSED r2e_tests/test_1.py::test_formdata_textio_charset\nPASSED r2e_tests/test_1.py::test_invalid_formdata_content_type\nPASSED r2e_tests/test_1.py::test_invalid_formdata_filename\nPASSED r2e_tests/test_1.py::test_formdata_field_name_is_quoted\nPASSED r2e_tests/test_1.py::test_formdata_field_name_is_not_quoted\nPASSED r2e_tests/test_1.py::test_mark_formdata_as_processed[pyloop]\nPASSED r2e_tests/test_1.py::test_formdata_boundary_param\nFAILED r2e_tests/test_1.py::test_formdata_multipart - TypeError: __init__() g...\nFAILED r2e_tests/test_1.py::test_form_data_is_multipart_param - TypeError: __...\n========================= 2 failed, 13 passed in 6.22s =========================\n",
    "old_commit_res_stderr": ""
}
CHANGES/9335.feature.rst aiohttp/formdata.py tests/test_formdata.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** FormData Constructor Raises TypeError When Using `default_to_multipart` Parameter

**Description:**
When attempting to initialize a `FormData` object with the `default_to_multipart` parameter, a `TypeError` is raised because the constructor does not recognize this argument.

**Example Code:**
```python
form = FormData(default_to_multipart=False)
```

**Expected Behavior:**
The `FormData` object should be created successfully with the `default_to_multipart` parameter set to `False`, allowing control over whether the form defaults to multipart encoding.

**Actual Behavior:**
A `TypeError` is thrown, indicating that the `default_to_multipart` argument is unexpected:
```
TypeError: __init__() got an unexpected keyword argument 'default_to_multipart'
```
[/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/formdata.py
import io
from typing import Any, Iterable, List, Optional
from urllib.parse import urlencode

from multidict import MultiDict, MultiDictProxy

from . import hdrs, multipart, payload
from .helpers import guess_filename
from .payload import Payload

__all__ = ("FormData",)


class FormData:
    """Helper class for form body generation.

    Supports multipart/form-data and application/x-www-form-urlencoded.
    """

    def __init__(
        self,
        fields: Iterable[Any] = (),
        quote_fields: bool = True,
        charset: Optional[str] = None,
        boundary: Optional[str] = None,
    ) -> None:
        self._boundary = boundary
        self._writer = multipart.MultipartWriter("form-data", boundary=self._boundary)
        self._fields: List[Any] = []
        self._is_multipart = False
        self._is_processed = False
        self._quote_fields = quote_fields
        self._charset = charset

        if isinstance(fields, dict):
            fields = list(fields.items())
        elif not isinstance(fields, (list, tuple)):
            fields = (fields,)
        self.add_fields(*fields)

    @property
    def is_multipart(self) -> bool:
        return self._is_multipart

    def add_field(
        self,
        name: str,
        value: Any,
        *,
        content_type: Optional[str] = None,
        filename: Optional[str] = None,
    ) -> None:
        if isinstance(value, (io.IOBase, bytes, bytearray, memoryview)):
            self._is_multipart = True

        type_options: MultiDict[str] = MultiDict({"name": name})
        if filename is not None and not isinstance(filename, str):
            raise TypeError("filename must be an instance of str. Got: %s" % filename)
        if filename is None and isinstance(value, io.IOBase):
            filename = guess_filename(value, name)
        if filename is not None:
            type_options["filename"] = filename
            self._is_multipart = True

        headers = {}
        if content_type is not None:
            if not isinstance(content_type, str):
                raise TypeError(
                    "content_type must be an instance of str. Got: %s" % content_type
                )
            headers[hdrs.CONTENT_TYPE] = content_type
            self._is_multipart = True

        self._fields.append((type_options, headers, value))

    def add_fields(self, *fields: Any) -> None:
        to_add = list(fields)

        while to_add:
            rec = to_add.pop(0)

            if isinstance(rec, io.IOBase):
                k = guess_filename(rec, "unknown")
                self.add_field(k, rec)  # type: ignore[arg-type]

            elif isinstance(rec, (MultiDictProxy, MultiDict)):
                to_add.extend(rec.items())

            elif isinstance(rec, (list, tuple)) and len(rec) == 2:
                k, fp = rec
                self.add_field(k, fp)  # type: ignore[arg-type]

            else:
                raise TypeError(
                    "Only io.IOBase, multidict and (name, file) "
                    "pairs allowed, use .add_field() for passing "
                    "more complex parameters, got {!r}".format(rec)
                )

    def _gen_form_urlencoded(self) -> payload.BytesPayload:
        # form data (x-www-form-urlencoded)
        data = []
        for type_options, _, value in self._fields:
            if not isinstance(value, str):
                raise TypeError(f"expected str, got {value!r}")
            data.append((type_options["name"], value))

        charset = self._charset if self._charset is not None else "utf-8"

        if charset == "utf-8":
            content_type = "application/x-www-form-urlencoded"
        else:
            content_type = "application/x-www-form-urlencoded; charset=%s" % charset

        return payload.BytesPayload(
            urlencode(data, doseq=True, encoding=charset).encode(),
            content_type=content_type,
        )

    def _gen_form_data(self) -> multipart.MultipartWriter:
        """Encode a list of fields using the multipart/form-data MIME format"""
        if self._is_processed:
            raise RuntimeError("Form data has been processed already")
        for dispparams, headers, value in self._fields:
            try:
                if hdrs.CONTENT_TYPE in headers:
                    part = payload.get_payload(
                        value,
                        content_type=headers[hdrs.CONTENT_TYPE],
                        headers=headers,
                        encoding=self._charset,
                    )
                else:
                    part = payload.get_payload(
                        value, headers=headers, encoding=self._charset
                    )
            except Exception as exc:
                raise TypeError(
                    "Can not serialize value type: %r\n "
                    "headers: %r\n value: %r" % (type(value), headers, value)
                ) from exc

            if dispparams:
                part.set_content_disposition(
                    "form-data", quote_fields=self._quote_fields, **dispparams
                )
                # FIXME cgi.FieldStorage doesn't likes body parts with
                # Content-Length which were sent via chunked transfer encoding
                assert part.headers is not None
                part.headers.popall(hdrs.CONTENT_LENGTH, None)

            self._writer.append_payload(part)

        self._is_processed = True
        return self._writer

    def __call__(self) -> Payload:
        if self._is_multipart:
            return self._gen_form_data()
        else:
            return self._gen_form_urlencoded()

```
--- 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:** FormData Constructor Raises TypeError When Using `default_to_multipart` Parameter

**Description:**
When attempting to initialize a `FormData` object with the `default_to_multipart` parameter, a `TypeError` is raised because the constructor does not recognize this argument.

**Example Code:**
```python
form = FormData(default_to_multipart=False)
```

**Expected Behavior:**
The `FormData` object should be created successfully with the `default_to_multipart` parameter set to `False`, allowing control over whether the form defaults to multipart encoding.

**Actual Behavior:**
A `TypeError` is thrown, indicating that the `default_to_multipart` argument is unexpected:
```
TypeError: __init__() got an unexpected keyword argument 'default_to_multipart'
```
[/ISSUE]
{
    "test_formdata_multipart": "PASSED",
    "test_form_data_is_multipart_param": "PASSED",
    "test_invalid_formdata_payload_multipart[obj0]": "PASSED",
    "test_invalid_formdata_payload_multipart[None]": "PASSED",
    "test_invalid_formdata_payload_urlencoded[obj0]": "PASSED",
    "test_invalid_formdata_payload_urlencoded[None]": "PASSED",
    "test_invalid_formdata_params": "PASSED",
    "test_invalid_formdata_params2": "PASSED",
    "test_formdata_textio_charset": "PASSED",
    "test_invalid_formdata_content_type": "PASSED",
    "test_invalid_formdata_filename": "PASSED",
    "test_formdata_field_name_is_quoted": "PASSED",
    "test_formdata_field_name_is_not_quoted": "PASSED",
    "test_mark_formdata_as_processed[pyloop]": "PASSED",
    "test_formdata_boundary_param": "PASSED"
}
diff --git a/aiohttp/formdata.py b/aiohttp/formdata.py
index 017a5192..994df482 100644
--- a/aiohttp/formdata.py
+++ b/aiohttp/formdata.py
@@ -23,11 +23,13 @@ class FormData:
         quote_fields: bool = True,
         charset: Optional[str] = None,
         boundary: Optional[str] = None,
+        *,
+        default_to_multipart: bool = False,
     ) -> None:
         self._boundary = boundary
         self._writer = multipart.MultipartWriter("form-data", boundary=self._boundary)
         self._fields: List[Any] = []
-        self._is_multipart = False
+        self._is_multipart = default_to_multipart
         self._is_processed = False
         self._quote_fields = quote_fields
         self._charset = charset

{"aiohttp/formdata.py": "import io\nfrom typing import Any, Iterable, List, Optional\nfrom urllib.parse import urlencode\n\nfrom multidict import MultiDict, MultiDictProxy\n\nfrom . import hdrs, multipart, payload\nfrom .helpers import guess_filename\nfrom .payload import Payload\n\n__all__ = (\"FormData\",)\n\n\nclass FormData:\n    \"\"\"Helper class for form body generation.\n\n    Supports multipart/form-data and application/x-www-form-urlencoded.\n    \"\"\"\n\n    def __init__(\n        self,\n        fields: Iterable[Any] = (),\n        quote_fields: bool = True,\n        charset: Optional[str] = None,\n        boundary: Optional[str] = None,\n    ) -> None:\n        self._boundary = boundary\n        self._writer = multipart.MultipartWriter(\"form-data\", boundary=self._boundary)\n        self._fields: List[Any] = []\n        self._is_multipart = False\n        self._is_processed = False\n        self._quote_fields = quote_fields\n        self._charset = charset\n\n        if isinstance(fields, dict):\n            fields = list(fields.items())\n        elif not isinstance(fields, (list, tuple)):\n            fields = (fields,)\n        self.add_fields(*fields)\n\n    @property\n    def is_multipart(self) -> bool:\n        return self._is_multipart\n\n    def add_field(\n        self,\n        name: str,\n        value: Any,\n        *,\n        content_type: Optional[str] = None,\n        filename: Optional[str] = None,\n    ) -> None:\n        if isinstance(value, (io.IOBase, bytes, bytearray, memoryview)):\n            self._is_multipart = True\n\n        type_options: MultiDict[str] = MultiDict({\"name\": name})\n        if filename is not None and not isinstance(filename, str):\n            raise TypeError(\"filename must be an instance of str. Got: %s\" % filename)\n        if filename is None and isinstance(value, io.IOBase):\n            filename = guess_filename(value, name)\n        if filename is not None:\n            type_options[\"filename\"] = filename\n            self._is_multipart = True\n\n        headers = {}\n        if content_type is not None:\n            if not isinstance(content_type, str):\n                raise TypeError(\n                    \"content_type must be an instance of str. Got: %s\" % content_type\n                )\n            headers[hdrs.CONTENT_TYPE] = content_type\n            self._is_multipart = True\n\n        self._fields.append((type_options, headers, value))\n\n    def add_fields(self, *fields: Any) -> None:\n        to_add = list(fields)\n\n        while to_add:\n            rec = to_add.pop(0)\n\n            if isinstance(rec, io.IOBase):\n                k = guess_filename(rec, \"unknown\")\n                self.add_field(k, rec)  # type: ignore[arg-type]\n\n            elif isinstance(rec, (MultiDictProxy, MultiDict)):\n                to_add.extend(rec.items())\n\n            elif isinstance(rec, (list, tuple)) and len(rec) == 2:\n                k, fp = rec\n                self.add_field(k, fp)  # type: ignore[arg-type]\n\n            else:\n                raise TypeError(\n                    \"Only io.IOBase, multidict and (name, file) \"\n                    \"pairs allowed, use .add_field() for passing \"\n                    \"more complex parameters, got {!r}\".format(rec)\n                )\n\n    def _gen_form_urlencoded(self) -> payload.BytesPayload:\n        # form data (x-www-form-urlencoded)\n        data = []\n        for type_options, _, value in self._fields:\n            if not isinstance(value, str):\n                raise TypeError(f\"expected str, got {value!r}\")\n            data.append((type_options[\"name\"], value))\n\n        charset = self._charset if self._charset is not None else \"utf-8\"\n\n        if charset == \"utf-8\":\n            content_type = \"application/x-www-form-urlencoded\"\n        else:\n            content_type = \"application/x-www-form-urlencoded; charset=%s\" % charset\n\n        return payload.BytesPayload(\n            urlencode(data, doseq=True, encoding=charset).encode(),\n            content_type=content_type,\n        )\n\n    def _gen_form_data(self) -> multipart.MultipartWriter:\n        \"\"\"Encode a list of fields using the multipart/form-data MIME format\"\"\"\n        if self._is_processed:\n            raise RuntimeError(\"Form data has been processed already\")\n        for dispparams, headers, value in self._fields:\n            try:\n                if hdrs.CONTENT_TYPE in headers:\n                    part = payload.get_payload(\n                        value,\n                        content_type=headers[hdrs.CONTENT_TYPE],\n                        headers=headers,\n                        encoding=self._charset,\n                    )\n                else:\n                    part = payload.get_payload(\n                        value, headers=headers, encoding=self._charset\n                    )\n            except Exception as exc:\n                raise TypeError(\n                    \"Can not serialize value type: %r\\n \"\n                    \"headers: %r\\n value: %r\" % (type(value), headers, value)\n                ) from exc\n\n            if dispparams:\n                part.set_content_disposition(\n                    \"form-data\", quote_fields=self._quote_fields, **dispparams\n                )\n                # FIXME cgi.FieldStorage doesn't likes body parts with\n                # Content-Length which were sent via chunked transfer encoding\n                assert part.headers is not None\n                part.headers.popall(hdrs.CONTENT_LENGTH, None)\n\n            self._writer.append_payload(part)\n\n        self._is_processed = True\n        return self._writer\n\n    def __call__(self) -> Payload:\n        if self._is_multipart:\n            return self._gen_form_data()\n        else:\n            return self._gen_form_urlencoded()\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:** FormData Constructor Raises TypeError When Using `default_to_multipart` Parameter

**Description:**
When attempting to initialize a `FormData` object with the `default_to_multipart` parameter, a `TypeError` is raised because the constructor does not recognize this argument.

**Example Code:**
```python
form = FormData(default_to_multipart=False)
```

**Expected Behavior:**
The `FormData` object should be created successfully with the `default_to_multipart` parameter set to `False`, allowing control over whether the form defaults to multipart encoding.

**Actual Behavior:**
A `TypeError` is thrown, indicating that the `default_to_multipart` argument is unexpected:
```
TypeError: __init__() got an unexpected keyword argument 'default_to_multipart'
```
[/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/formdata.py
import io
from typing import Any, Iterable, List, Optional
from urllib.parse import urlencode

from multidict import MultiDict, MultiDictProxy

from . import hdrs, multipart, payload
from .helpers import guess_filename
from .payload import Payload

__all__ = ("FormData",)


class FormData:
    """Helper class for form body generation.

    Supports multipart/form-data and application/x-www-form-urlencoded.
    """

    def __init__(
        self,
        fields: Iterable[Any] = (),
        quote_fields: bool = True,
        charset: Optional[str] = None,
        boundary: Optional[str] = None,
    ) -> None:
        self._boundary = boundary
        self._writer = multipart.MultipartWriter("form-data", boundary=self._boundary)
        self._fields: List[Any] = []
        self._is_multipart = False
        self._is_processed = False
        self._quote_fields = quote_fields
        self._charset = charset

        if isinstance(fields, dict):
            fields = list(fields.items())
        elif not isinstance(fields, (list, tuple)):
            fields = (fields,)
        self.add_fields(*fields)

    @property
    def is_multipart(self) -> bool:
        return self._is_multipart

    def add_field(
        self,
        name: str,
        value: Any,
        *,
        content_type: Optional[str] = None,
        filename: Optional[str] = None,
    ) -> None:
        if isinstance(value, (io.IOBase, bytes, bytearray, memoryview)):
            self._is_multipart = True

        type_options: MultiDict[str] = MultiDict({"name": name})
        if filename is not None and not isinstance(filename, str):
            raise TypeError("filename must be an instance of str. Got: %s" % filename)
        if filename is None and isinstance(value, io.IOBase):
            filename = guess_filename(value, name)
        if filename is not None:
            type_options["filename"] = filename
            self._is_multipart = True

        headers = {}
        if content_type is not None:
            if not isinstance(content_type, str):
                raise TypeError(
                    "content_type must be an instance of str. Got: %s" % content_type
                )
            headers[hdrs.CONTENT_TYPE] = content_type
            self._is_multipart = True

        self._fields.append((type_options, headers, value))

    def add_fields(self, *fields: Any) -> None:
        to_add = list(fields)

        while to_add:
            rec = to_add.pop(0)

            if isinstance(rec, io.IOBase):
                k = guess_filename(rec, "unknown")
                self.add_field(k, rec)  # type: ignore[arg-type]

            elif isinstance(rec, (MultiDictProxy, MultiDict)):
                to_add.extend(rec.items())

            elif isinstance(rec, (list, tuple)) and len(rec) == 2:
                k, fp = rec
                self.add_field(k, fp)  # type: ignore[arg-type]

            else:
                raise TypeError(
                    "Only io.IOBase, multidict and (name, file) "
                    "pairs allowed, use .add_field() for passing "
                    "more complex parameters, got {!r}".format(rec)
                )

    def _gen_form_urlencoded(self) -> payload.BytesPayload:
        # form data (x-www-form-urlencoded)
        data = []
        for type_options, _, value in self._fields:
            if not isinstance(value, str):
                raise TypeError(f"expected str, got {value!r}")
            data.append((type_options["name"], value))

        charset = self._charset if self._charset is not None else "utf-8"

        if charset == "utf-8":
            content_type = "application/x-www-form-urlencoded"
        else:
            content_type = "application/x-www-form-urlencoded; charset=%s" % charset

        return payload.BytesPayload(
            urlencode(data, doseq=True, encoding=charset).encode(),
            content_type=content_type,
        )

    def _gen_form_data(self) -> multipart.MultipartWriter:
        """Encode a list of fields using the multipart/form-data MIME format"""
        if self._is_processed:
            raise RuntimeError("Form data has been processed already")
        for dispparams, headers, value in self._fields:
            try:
                if hdrs.CONTENT_TYPE in headers:
                    part = payload.get_payload(
                        value,
                        content_type=headers[hdrs.CONTENT_TYPE],
                        headers=headers,
                        encoding=self._charset,
                    )
                else:
                    part = payload.get_payload(
                        value, headers=headers, encoding=self._charset
                    )
            except Exception as exc:
                raise TypeError(
                    "Can not serialize value type: %r\n "
                    "headers: %r\n value: %r" % (type(value), headers, value)
                ) from exc

            if dispparams:
                part.set_content_disposition(
                    "form-data", quote_fields=self._quote_fields, **dispparams
                )
                # FIXME cgi.FieldStorage doesn't likes body parts with
                # Content-Length which were sent via chunked transfer encoding
                assert part.headers is not None
                part.headers.popall(hdrs.CONTENT_LENGTH, None)

            self._writer.append_payload(part)

        self._is_processed = True
        return self._writer

    def __call__(self) -> Payload:
        if self._is_multipart:
            return self._gen_form_data()
        else:
            return self._gen_form_urlencoded()

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