failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · psf/requests
Fix `_encode_files` detection for `__getattr__`-based file wrappers
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
locals>.inner at 0x10b409580>
def test_post_named_tempfile(self, httpbin):
with tempfile.NamedTemporaryFile(mode="w+") as f:
f.write("named temp file contents\n")
f.seek(0)
> r = requests.post(
httpbin("post"),
files={"file": f},
)
tests/test_requests.py:1094:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/api.py:134: in post
return request("post", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/api.py:71: in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/sessions.py:635: in request
prep = self.prepare_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/sessions.py:541: in prepare_request
p.prepare(
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/models.py:445: in prepare
self.prepare_body(data, files, json)
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/models.py:638: in prepare_body
(body, content_type) = self._encode_files(files, raw_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/models.py:250: in _encode_files
body, content_type = encode_multipart_formdata(new_fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fields = [<urllib3.fields.RequestField object at 0x109c9f570>]
boundary = '0118fa046f46b84d61d286a03f34e854'
def encode_multipart_formdata(
fields: _TYPE_FIELDS, boundary: str | None = None
) -> tuple[bytes, str]:
"""
Encode a dictionary of ``fields`` using the multipart/form-data MIME format.
:param fields:
Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`).
Values are processed by :func:`urllib3.fields.RequestField.from_tuples`.
:param boundary:
If not specified, then a random boundary will be generated using
:func:`urllib3.filepost.choose_boundary`.
"""
body = BytesIO()
if boundary is None:
boundary = choose_boundary()
for field in iter_field_objects(fields):
body.write(f"--{boundary}\r\n".encode("latin-1"))
writer(body).write(field.render_headers())
data = field.data
if isinstance(data, int):
data = str(data) # Backwards compatibility
if isinstance(data, str):
writer(body).write(data)
else:
> body.write(data)
E TypeError: a bytes-like object is required, not '_TemporaryFileWrapper'
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/urllib3/filepost.py:81: TypeError
=============================== warnings summary ===============================
../../../../../../../Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/_pytest/config/__init__.py:1464
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/_pytest/config/__init__.py:1464: PytestConfigWarning: Unknown config option: timeout
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
tests/test_requests.py::TestRequests::test_set_basicauth[42-42]
tests/test_requests.py::TestRequests::test_set_basicauth[42-42]
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/auth.py:45: DeprecationWarning: Non-string usernames will no longer be supported in Requests 3.0.0. Please convert the object you've passed in (42) to a string or bytes object in the near future to avoid problems.
warnings.warn(
tests/test_requests.py::TestRequests::test_set_basicauth[42-42]
tests/test_requests.py::TestRequests::test_set_basicauth[42-42]
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/auth.py:55: DeprecationWarning: Non-string passwords will no longer be supported in Requests 3.0.0. Please convert the object you've passed in (<class 'int'>) to a string or bytes object in the near future to avoid problems.
warnings.warn(
tests/test_requests.py::TestRequests::test_set_basicauth[None-None]
tests/test_requests.py::TestRequests::test_set_basicauth[None-None]
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/auth.py:45: DeprecationWarning: Non-string usernames will no longer be supported in Requests 3.0.0. Please convert the object you've passed in (None) to a string or bytes object in the near future to avoid problems.
warnings.warn(
tests/test_requests.py::TestRequests::test_set_basicauth[None-None]
tests/test_requests.py::TestRequests::test_set_basicauth[None-None]
/tmp/swe_work/baseline_full_v2/requests_7502/b/workspace/src/requests/auth.py:55: DeprecationWarning: Non-string passwords will no longer be supported in Requests 3.0.0. Please convert the object you've passed in (<class 'NoneType'>) to a string or bytes object in the near future to avoid problems.
warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 125 passed, 1 skipped, 9 warnings in 1.05s
[2026-09-23 20:58:08,134] WARNING in core: flasgger is not installed; serving the static landing page at / and skipping the Swagger UI and /spec.json.
127.0.0.1 - - [23/Sep/2026 20:58:08] "POST /post HTTP/1.1" 200 438