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/requests/_internal_utils.py
+++ b/requests/_internal_utils.py
@@ -14,9 +14,11 @@ _VALID_HEADER_NAME_RE_STR = re.compile(r"^[^:\s][^:\r\n]*$")
_VALID_HEADER_VALUE_RE_BYTE = re.compile(rb"^\S[^\r\n]*$|^$")
_VALID_HEADER_VALUE_RE_STR = re.compile(r"^\S[^\r\n]*$|^$")
+_HEADER_VALIDATORS_STR = (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR)
+_HEADER_VALIDATORS_BYTE = (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE)
HEADER_VALIDATORS = {
- bytes: (_VALID_HEADER_NAME_RE_BYTE, _VALID_HEADER_VALUE_RE_BYTE),
- str: (_VALID_HEADER_NAME_RE_STR, _VALID_HEADER_VALUE_RE_STR),
+ bytes: _HEADER_VALIDATORS_BYTE,
+ str: _HEADER_VALIDATORS_STR,
}
--- a/requests/utils.py
+++ b/requests/utils.py
@@ -25,7 +25,12 @@ from . import certs
from .__version__ import __version__
# to_native_string is unused here, but imported here for backwards compatibility
-from ._internal_utils import HEADER_VALIDATORS, to_native_string # noqa: F401
+from ._internal_utils import ( # noqa: F401
+ _HEADER_VALIDATORS_BYTE,
+ _HEADER_VALIDATORS_STR,
+ HEADER_VALIDATORS,
+ to_native_string,
+)
from .compat import (
Mapping,
basestring,
@@ -1031,20 +1036,23 @@ def check_header_validity(header):
:param header: tuple, in the format (name, value).
"""
name, value = header
+ _validate_header_part(header, name, 0)
+ _validate_header_part(header, value, 1)
- for part in header:
- if type(part) not in HEADER_VALIDATORS:
- raise InvalidHeader(
- f"Header part ({part!r}) from {{{name!r}: {value!r}}} must be "
- f"of type str or bytes, not {type(part)}"
- )
-
- _validate_header_part(name, "name", HEADER_VALIDATORS[type(name)][0])
- _validate_header_part(value, "value", HEADER_VALIDATORS[type(value)][1])
+def _validate_header_part(header, header_part, header_validator_index):
+ if isinstance(header_part, str):
+ validator = _HEADER_VALIDATORS_STR[header_validator_index]
+ elif isinstance(header_part, bytes):
+ validator = _HEADER_VALIDATORS_BYTE[header_validator_index]
+ else:
+ raise InvalidHeader(
+ f"Header part ({header_part!r}) from {header} "
+ f"must be of type str or bytes, not {type(header_part)}"
+ )
-def _validate_header_part(header_part, header_kind, validator):
if not validator.match(header_part):
+ header_kind = "name" if header_validator_index == 0 else "value"
raise InvalidHeader(
f"Invalid leading whitespace, reserved character(s), or return"
f"character(s) in header {header_kind}: {header_part!r}"
alhost:-1-InvalidURL] _
self = <tests.test_requests.TestPreparingURLs object at 0x106ac7120>
httpbin = <function prepare_url.<locals>.inner at 0x1069985e0>
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:2700: 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:42] "GET /redirect-to?url=http%3A%2F%2Flocalhost%3A-1 HTTP/1.1" 500 59
=============================== warnings summary ===============================
requests/__init__.py:109
/private/tmp/swe_work/mined_oracle/requests_6356/b/workspace/requests/__init__.py:109: RequestsDependencyWarning: urllib3 (2.8.0) or chardet (None)/charset_normalizer (3.5.1) doesn't match a supported version!
warnings.warn(
../../../../../../../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: 119 warnings
/Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/urllib3/poolmanager.py:331: FutureWarning: The 'strict' parameter is no longer needed on Python 3+. This will raise an error in urllib3 v3.0.
warnings.warn(
tests/test_requests.py::TestRequests::test_set_basicauth[42-42]
tests/test_requests.py::TestRequests::test_set_basicauth[42-42]
/private/tmp/swe_work/mined_oracle/requests_6356/b/workspace/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]
/private/tmp/swe_work/mined_oracle/requests_6356/b/workspace/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]
/private/tmp/swe_work/mined_oracle/requests_6356/b/workspace/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]
/private/tmp/swe_work/mined_oracle/requests_6356/b/workspace/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, 304 passed, 1 skipped, 1 xfailed, 129 warnings in 31.69s
[2026-09-23 20:55:11,605] 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 /digest-auth/auth/user/pass/SHA-512 HTTP/1.1" 401 0
127.0.0.1 - - [23/Sep/2026 20:55:12] "GET /get HTTP/1.1" 200 272