failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(timeout) · 9 tool calls · 0 s · psf/requests
Port bpo-39057 to Requests This PR ports a [fix](https://bugs.python.org/issue39057) from CPython to constrain no_proxy behavior to domain boundaries. This was originally undefined behavior when Requests implemented `no_proxy` support but has since had bug fixes released in both CPython and Curl. We'll follow suit to conform with ecosystem expectations and resolve long standing issue #4795.
| # | Tool | Arguments | Result |
|---|---|---|---|
| 1 | run_command | {
"command": "grep -rn \"no_proxy\" --include=*.py /workspace/src /workspace/tests | head -40"
} | {"status": "ok", "stdout": "", "exit_code": 0}full{"status": "ok", "stdout": "", "exit_code": 0} |
| 2 | run_command | {
"command": "grep -rn \"proxy_bypass\" --include=*.py /workspace/src | head -20"
} | {"status": "ok", "stdout": "", "exit_code": 0}full{"status": "ok", "stdout": "", "exit_code": 0} |
| 3 | run_command | {
"command": "cd /workspace && ls src/requests/ && grep -rn \"proxy\" src/requests/utils.py | head -30"
} | {"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "/bin/bash: line 0: cdfull{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "/bin/bash: line 0: cd: /tmp/swe_work/or20_qwen27b_v2/requests_7427/a/workspace: No such file or directory\n", "exit_code": 1}} |
| 4 | run_command | {
"command": "pwd; ls /workspace 2>/dev/null || ls /"
} | {"status": "ok", "stdout": "/private/workspace\nApplications\nbin\ncores\ndev\netc\nhome\nLibrary\nopt\nprivate\nsbin\nSystem\ntmp\nUsers\nusr\nvar\nVolumes\n",full{"status": "ok", "stdout": "/private/workspace\nApplications\nbin\ncores\ndev\netc\nhome\nLibrary\nopt\nprivate\nsbin\nSystem\ntmp\nUsers\nusr\nvar\nVolumes\n", "exit_code": 0} |
| 5 | run_command | {
"command": "ls /private/workspace && grep -rn \"no_proxy\\|proxy_bypass\" /private/workspace/src/requests/*.py | head -30"
} | {"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "ls: /private/workspacfull{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "ls: /private/workspace: No such file or directory\n", "exit_code": 1}} |
| 6 | run_command | {
"command": "ls -la /private/ 2>/dev/null; find / -maxdepth 3 -name \"requests\" -type d 2>/dev/null | head"
} | {"status": "ok", "stdout": "total 0\ndrwxr-xr-x 6 root wheel 192 Sep 9 20:31 .\ndrwxr-xr-x 22 root wheel 704 Aug 1 09:31 ..\ndrwxr-xr-x 77 root wheel 2464 Sep 9full{"status": "ok", "stdout": "total 0\ndrwxr-xr-x 6 root wheel 192 Sep 9 20:31 .\ndrwxr-xr-x 22 root wheel 704 Aug 1 09:31 ..\ndrwxr-xr-x 77 root wheel 2464 Sep 9 20:31 etc\ndrwxr-xr-x 2 root wheel 64 Aug 1 09:31 tftpboot\ndrwxrwxrwt 28 root wheel 896 Sep 23 22:51 tmp\ndrwxr-xr-x 35 root wheel 1120 Sep 9 20:31 var\n", "exit_code": 0} |
| 7 | run_command | {
"command": "ls -la; find / -maxdepth 4 -name \"utils.py\" -path \"*requests*\" 2>/dev/null | head"
} | {"status": "ok", "stdout": "total 280\ndrwx------@ 25 jp wheel 800 Sep 23 22:51 .\ndrwxr-xr-x@ 4 jp wheel 128 Sep 23 22:51 ..\n-rw-r--r--@ 1 jp wheel 33 Jul 15 full{"status": "ok", "stdout": "total 280\ndrwx------@ 25 jp wheel 800 Sep 23 22:51 .\ndrwxr-xr-x@ 4 jp wheel 128 Sep 23 22:51 ..\n-rw-r--r--@ 1 jp wheel 33 Jul 15 08:35 .coveragerc\ndrwxr-xr-x@ 12 jp wheel 384 Sep 23 22:51 .git\n-rw-r--r--@ 1 jp wheel 234 Jul 15 08:35 .git-blame-ignore-revs\ndrwxr-xr-x@ 11 jp wheel 352 Jul 15 08:35 .github\n-rw-r--r--@ 1 jp wheel 321 Jul 15 08:35 .gitignore\n-rw-r--r--@ 1 jp wheel 485 Jul 15 08:35 .pre-commit-config.yaml\n-rw-r--r--@ 1 jp wheel 738 Jul 15 08:35 .readthedocs.yaml\n-rw-r--r--@ 1 jp wheel 8025 Jul 15 08:35 AUTHORS.rst\ndrwxr-xr-x@ 15 jp wheel 480 Jul 15 08:35 docs\ndrwxr-xr-x@ 9 jp wheel 288 Jul 15 08:35 ext\n-rw-r--r--@ 1 jp wheel 62968 Jul 15 08:35 HISTORY.md\n-rw-r--r--@ 1 jp wheel 10142 Jul 15 08:35 LICENSE\n-rw-r--r--@ 1 jp wheel 834 Jul 15 08:35 Makefile\n-rw-r--r--@ 1 jp wheel 126 Jul 15 08:35 MANIFEST.in\n-rw-r--r--@ 1 jp wheel 38 Jul 15 08:35 NOTICE\n-rw-r--r--@ 1 jp wheel 3153 Jul 15 08:35 pyproject.toml\n-rw-r--r--@ 1 jp wheel 109 Sep 23 22:51 pytest.ini\n-rw-r--r--@ 1 jp wheel 2906 Jul 15 08:35 README.md\n-rw-r--r--@ 1 jp wheel 93 Jul 15 08:35 requirements-dev.txt\n-rwxr-xr-x@ 1 jp wheel 179 Jul 15 08:35 setup.py\ndrwxr-xr-x@ 3 jp wheel 96 Jul 15 08:35 src\ndrwxr-xr-x@ 17 jp wheel 544 Jul 15 08:35 tests\n-rw-r--r--@ 1 jp wheel 285 Jul 15 08:35 tox.ini\n", "exit_code": 0} |
| 8 | run_command | {
"command": "grep -rn \"no_proxy\\|proxy_bypass\" src/requests/*.py | head -30"
} | {"status": "ok", "stdout": "src/requests/compat.py:104: proxy_bypass,\nsrc/requests/compat.py:105: proxy_bypass_environment, # type: ignore[attr-defined] # httpfull{"status": "ok", "stdout": "src/requests/compat.py:104: proxy_bypass,\nsrc/requests/compat.py:105: proxy_bypass_environment, # type: ignore[attr-defined] # https://github.com/python/cpython/issues/145331\nsrc/requests/sessions.py:840: no_proxy = proxies.get(\"no_proxy\") if proxies is not None else None\nsrc/requests/sessions.py:841: env_proxies = get_environ_proxies(url, no_proxy=no_proxy)\nsrc/requests/utils.py:53: proxy_bypass,\nsrc/requests/utils.py:54: proxy_bypass_environment, # type: ignore[attr-defined] # https://github.com/python/cpython/issues/145331\nsrc/requests/utils.py:97: # provide a proxy_bypass version on Windows without DNS lookups\nsrc/requests/utils.py:99: def proxy_bypass_registry(host: str) -> bool:\nsrc/requests/utils.py:137: def proxy_bypass(host: str) -> bool: # noqa\nsrc/requests/utils.py:144: return proxy_bypass_environment(host)\nsrc/requests/utils.py:146: return proxy_bypass_registry(host)\nsrc/requests/utils.py:765: Very simple check of the cidr format in no_proxy variable.\nsrc/requests/utils.py:810:def should_bypass_proxies(url: str, no_proxy: str | None) -> bool:\nsrc/requests/utils.py:822: # First check whether no_proxy is defined. If it is, check that the URL\nsrc/requests/utils.py:823: # we're getting isn't in the no_proxy list.\nsrc/requests/utils.py:824: no_proxy_arg = no_proxy\nsrc/requests/utils.py:825: if no_proxy is None:\nsrc/requests/utils.py:826: no_proxy = get_proxy(\"no_proxy\")\nsrc/requests/utils.py:834: if no_proxy:\nsrc/requests/utils.py:837: no_proxy_hosts = (host for host in no_proxy.replace(\" \", \"\").split(\",\") if host)\nsrc/requests/utils.py:840: for proxy_ip in no_proxy_hosts:\nsrc/requests/utils.py:845: # If no_proxy ip was defined in plain IP notation instead of cidr notation &\nsrc/requests/utils.py:853: for host in no_proxy_hosts:\nsrc/requests/utils.py:855: |
| 9 | read_file | {
"filepath": "src/requests/utils.py",
"start_line": 740,
"end_line": 880
} | {"status": "ok", "filepath": "src/requests/utils.py", "content": "\ndef dotted_netmask(mask: int) -> str:\n \"\"\"Converts mask from /xx format to xxx.xxx.xxx.xfull{"status": "ok", "filepath": "src/requests/utils.py", "content": "\ndef dotted_netmask(mask: int) -> str:\n \"\"\"Converts mask from /xx format to xxx.xxx.xxx.xxx\n\n Example: if mask is 24 function returns 255.255.255.0\n\n :rtype: str\n \"\"\"\n bits = 0xFFFFFFFF ^ (1 << 32 - mask) - 1\n return socket.inet_ntoa(struct.pack(\">I\", bits))\n\n\ndef is_ipv4_address(string_ip: str) -> bool:\n \"\"\"\n :rtype: bool\n \"\"\"\n try:\n socket.inet_aton(string_ip)\n except OSError:\n return False\n return True\n\n\ndef is_valid_cidr(string_network: str) -> bool:\n \"\"\"\n Very simple check of the cidr format in no_proxy variable.\n\n :rtype: bool\n \"\"\"\n if string_network.count(\"/\") == 1:\n try:\n mask = int(string_network.split(\"/\")[1])\n except ValueError:\n return False\n\n if mask < 1 or mask > 32:\n return False\n\n try:\n socket.inet_aton(string_network.split(\"/\")[0])\n except OSError:\n return False\n else:\n return False\n return True\n\n\n@contextlib.contextmanager\ndef set_environ(env_name: str, value: str | None) -> Generator[None, None, None]:\n \"\"\"Set the environment variable 'env_name' to 'value'\n\n Save previous value, yield, and then restore the previous value stored in\n the environment variable 'env_name'.\n\n If 'value' is None, do nothing\"\"\"\n value_changed = value is not None\n old_value: str | None = None\n if value_changed:\n old_value = os.environ.get(env_name)\n os.environ[env_name] = value\n try:\n yield\n finally:\n if value_changed:\n if old_value is None:\n del os.environ[env_name]\n else:\n os.environ[env_name] = old_value\n\n\ndef should_bypass_proxies(url: str, no_proxy: str | None) -> bool:\n \"\"\"\n Returns whether we should bypass proxies or not |