failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(None) · None tool calls · 0 s · psf/requests
(not found in data/tasks.jsonl)
| # | Tool | Arguments | Result |
|---|---|---|---|
| No trace captured. | |||
--- a/src/requests/adapters.py
+++ b/src/requests/adapters.py
@@ -8,6 +8,7 @@ and maintain connections.
import os.path
import socket # noqa: F401
+import typing
from urllib3.exceptions import ClosedPoolError, ConnectTimeoutError
from urllib3.exceptions import HTTPError as _HTTPError
@@ -61,12 +62,38 @@ except ImportError:
raise InvalidSchema("Missing dependencies for SOCKS support.")
+if typing.TYPE_CHECKING:
+ from .models import PreparedRequest
+
+
DEFAULT_POOLBLOCK = False
DEFAULT_POOLSIZE = 10
DEFAULT_RETRIES = 0
DEFAULT_POOL_TIMEOUT = None
+def _urllib3_request_context(
+ request: "PreparedRequest", verify: "bool | str | None"
+) -> "(typing.Dict[str, typing.Any], typing.Dict[str, typing.Any])":
+ host_params = {}
+ pool_kwargs = {}
+ parsed_request_url = urlparse(request.url)
+ scheme = parsed_request_url.scheme.lower()
+ port = parsed_request_url.port
+ cert_reqs = "CERT_REQUIRED"
+ if verify is False:
+ cert_reqs = "CERT_NONE"
+ if isinstance(verify, str):
+ pool_kwargs["ca_certs"] = verify
+ pool_kwargs["cert_reqs"] = cert_reqs
+ host_params = {
+ "scheme": scheme,
+ "host": parsed_request_url.hostname,
+ "port": port,
+ }
+ return host_params, pool_kwargs
+
+
class BaseAdapter:
"""The Base Transport Adapter"""
@@ -327,6 +354,35 @@ class HTTPAdapter(BaseAdapter):
return response
+ def _get_connection(self, request, verify, proxies=None):
+ # Replace the existing get_connection without breaking things and
+ # ensure that TLS settings are considered when we interact with
+ # urllib3 HTTP Pools
+ proxy = select_proxy(request.url, proxies)
+ try:
+ host_params, pool_kwargs = _urllib3_request_context(request, verify)
+ except ValueError as e:
+ raise InvalidURL(e, request=request)
+ if proxy:
+ proxy = prepend_scheme_if_needed(proxy, "http")
+ proxy_url = parse_url(proxy)
+ if not proxy_url.host:
+ raise InvalidProxyURL(
+ "Please check proxy URL. It is malformed "
+ "and could be missing the host."
+ )
+ proxy_manager = self.proxy_manager_for(proxy)
+ conn = proxy_manager.connection_from_host(
+ **host_params, pool_kwargs=pool_kwargs
+ )
+ else:
+ # Only scheme should be lower case
+ conn = self.poolmanager.connection_from_host(
+ **host_params, pool_kwargs=pool_kwargs
+ )
+
+ return conn
+
def get_connection(self, url, proxies=None):
"""Returns a urllib3 connection for the given URL. This should not be
called from user code, and is only exposed for use when subclassing the
@@ -453,7 +509,7 @@ class HTTPAdapter(BaseAdapter):
"""
try:
- conn = self.get_connection(request.url, proxies)
+ conn = self._get_connection(request, verify, proxies)
except LocationValueError as e:
raise InvalidURL(e, request=request)
--- a/tox.ini
+++ b/tox.ini
@@ -7,7 +7,7 @@ extras =
security
socks
commands =
- pytest tests
+ pytest {posargs:tests}
[testenv:default]
...........x....................................................... [ 88%]
......................F
=================================== FAILURES ===================================
_ TestPreparingURLs.test_redirecting_to_bad_url[http://localhost:-1-InvalidURL] _
self = <tests.test_requests.TestPreparingURLs object at 0x106b7f490>
httpbin = <function prepare_url.<locals>.inner at 0x105cc4a40>
url = 'http://localhost:-1'
exception = <class 'requests.exceptions.InvalidURL'>
@pytest.mark.parametrize("url, exception", (("http://localhost:-1", InvalidURL),))
def test_redirecting_to_bad_url(self, httpbin, url, exception):
> with pytest.raises(exception):
^^^^^^^^^^^^^^^^^^^^^^^^
E Failed: DID NOT RAISE InvalidURL
tests/test_requests.py:2724: Failed
----------------------------- Captured stderr call -----------------------------
Traceback (most recent call last):
File "/Users/jp/.local/share/uv/python/cpython-3.13.15-macos-aarch64-none/lib/python3.13/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/flask/app.py", line 1536, in __call__
return self.wsgi_app(environ, start_response)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/flask/app.py", line 1518, in wsgi_app
return response(environ, start_response)
File "/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/werkzeug/wrappers/response.py", line 576, in __call__
app_iter, status, headers = self.get_wsgi_response(environ)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/werkzeug/wrappers/response.py", line 562, in get_wsgi_response
headers = self.get_wsgi_headers(environ)
File "/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/werkzeug/wrappers/response.py", line 481, in get_wsgi_headers
location = iri_to_uri(location)
File "/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/werkzeug/urls.py", line 153, in iri_to_uri
if parts.port:
^^^^^^^^^^
File "/Users/jp/.local/share/uv/python/cpython-3.13.15-macos-aarch64-none/lib/python3.13/urllib/parse.py", line 182, in port
raise ValueError(f"Port could not be cast to integer value as {port!r}")
ValueError: Port could not be cast to integer value as '-1'
127.0.0.1 - - [23/Sep/2026 20:55:43] "GET /redirect-to?url=http%3A%2F%2Flocalhost%3A-1 HTTP/1.1" 500 59
=============================== 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/mined_oracle/requests_6655/b/workspace/src/requests/auth.py:36: 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/mined_oracle/requests_6655/b/workspace/src/requests/auth.py:46: 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/mined_oracle/requests_6655/b/workspace/src/requests/auth.py:36: 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/mined_oracle/requests_6655/b/workspace/src/requests/auth.py:46: 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, 308 passed, 1 skipped, 1 xfailed, 9 warnings in 31.49s
[2026-09-23 20:55:11,895] 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:55:12] "GET /response-headers?Set-Cookie=foo%3Ddeleted%3B+expires%3DThu%2C+01-Jan-1970+00%3A00%3A01+GMT HTTP/1.1" 200 138
127.0.0.1 - - [23/Sep/2026 20:55:12] "POST /post HTTP/1.1" 200 361
127.0.0.1 - - [23/Sep/2026 20:55:12] "POST /post HTTP/1.1" 200 438
127.0.0.1 - - [23/Sep/2026 20:55:12] "GET /status/500 HTTP/1.1" 500 0
127.0.0.1 - - [23/Sep/2026 20:55:12] "GET /stream/4 HTTP/1.1" 200 1008
127.0.0.1 - - [23/Sep/2026 20:55:12] "GET /stream/4 HTTP/1.1" 200 1008