{"action":"opened","issue":{"url":"https://api.github.com/repos/requests/requests/issues/4737","repository_url":"https://api.github.com/repos/requests/requests","labels_url":"https://api.github.com/repos/requests/requests/issues/4737/labels{/name}","comments_url":"https://api.github.com/repos/requests/requests/issues/4737/comments","events_url":"https://api.github.com/repos/requests/requests/issues/4737/events","html_url":"https://github.com/requests/requests/issues/4737","id":340689787,"node_id":"MDU6SXNzdWUzNDA2ODk3ODc=","number":4737,"title":"no_proxy is not compatible with urls without hostname","user":{"login":"vxgmichel","id":7490006,"node_id":"MDQ6VXNlcjc0OTAwMDY=","avatar_url":"https://avatars1.githubusercontent.com/u/7490006?v=4","gravatar_id":"","url":"https://api.github.com/users/vxgmichel","html_url":"https://github.com/vxgmichel","followers_url":"https://api.github.com/users/vxgmichel/followers","following_url":"https://api.github.com/users/vxgmichel/following{/other_user}","gists_url":"https://api.github.com/users/vxgmichel/gists{/gist_id}","starred_url":"https://api.github.com/users/vxgmichel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vxgmichel/subscriptions","organizations_url":"https://api.github.com/users/vxgmichel/orgs","repos_url":"https://api.github.com/users/vxgmichel/repos","events_url":"https://api.github.com/users/vxgmichel/events{/privacy}","received_events_url":"https://api.github.com/users/vxgmichel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-12T15:32:05Z","updated_at":"2018-07-12T15:32:05Z","closed_at":null,"author_association":"NONE","body":"The `no_proxy` environment variable causes an exception when a url without a hostname is used.\r\nThis happens with conda local file system adapter for instance. \r\n\r\n## Reproduction Steps\r\n\r\nConsider the following example:\r\n\r\n```python\r\nimport requests\r\nfrom requests.models import Response\r\nfrom requests.adapters import BaseAdapter\r\n\r\n\r\nclass LocalFSAdapter(BaseAdapter):\r\n    \"\"\"Simplified version of\r\n    'conda.gateways.connection.adapters.localfs.LocalFSAdapter'.\r\n    \"\"\"\r\n\r\n    def send(self, request, **kwargs):\r\n        _, pathname = request.url.split('file://')\r\n        resp = Response()\r\n        resp.raw = open(pathname, \"rb\")\r\n        return resp\r\n\r\n    def close(self):\r\n        pass\r\n\r\n\r\nwith requests.Session() as s:\r\n    s.mount(\"file://\", LocalFSAdapter())\r\n    print(s.get('file:///tmp/test').text)\r\n```\r\n\r\nRunning with the `no_proxy` environment variable set:\r\n```bash\r\n$ no_proxy=nope python test.py\r\n```\r\n\r\n## Expected Result\r\n\r\n```\r\n<the content of '/tmp/test'>\r\n```\r\n\r\n## Actual Result\r\n\r\n```python\r\nTraceback (most recent call last):\r\n  File \"test.py\", line 23, in <module>\r\n    print(s.get('file:///tmp/test').text)\r\n  File \"/home/vimiche/miniconda/lib/python3.6/site-packages/requests/sessions.py\", line 525, in get\r\n    return self.request('GET', url, **kwargs)\r\n  File \"/home/vimiche/miniconda/lib/python3.6/site-packages/requests/sessions.py\", line 503, in request\r\n    prep.url, proxies, stream, verify, cert\r\n  File \"/home/vimiche/miniconda/lib/python3.6/site-packages/requests/sessions.py\", line 676, in merge_environment_settings\r\n    env_proxies = get_environ_proxies(url, no_proxy=no_proxy)\r\n  File \"/home/vimiche/miniconda/lib/python3.6/site-packages/requests/utils.py\", line 760, in get_environ_proxies\r\n    if should_bypass_proxies(url, no_proxy=no_proxy):\r\n  File \"/home/vimiche/miniconda/lib/python3.6/site-packages/requests/utils.py\", line 716, in should_bypass_proxies\r\n    if is_ipv4_address(parsed.hostname):\r\n  File \"/home/vimiche/miniconda/lib/python3.6/site-packages/requests/utils.py\", line 640, in is_ipv4_address\r\n    socket.inet_aton(string_ip)\r\nTypeError: inet_aton() argument 1 must be str, not None\r\n```\r\n\r\n## System Information\r\n\r\n    $ python -m requests.help\r\n\r\n```json\r\n{\r\n  \"chardet\": {\r\n    \"version\": \"3.0.4\"\r\n  },\r\n  \"cryptography\": {\r\n    \"version\": \"2.2.2\"\r\n  },\r\n  \"idna\": {\r\n    \"version\": \"2.7\"\r\n  },\r\n  \"implementation\": {\r\n    \"name\": \"CPython\",\r\n    \"version\": \"3.6.6\"\r\n  },\r\n  \"platform\": {\r\n    \"release\": \"4.15.0-24-generic\",\r\n    \"system\": \"Linux\"\r\n  },\r\n  \"pyOpenSSL\": {\r\n    \"openssl_version\": \"100020ff\",\r\n    \"version\": \"18.0.0\"\r\n  },\r\n  \"requests\": {\r\n    \"version\": \"2.19.1\"\r\n  },\r\n  \"system_ssl\": {\r\n    \"version\": \"100020ff\"\r\n  },\r\n  \"urllib3\": {\r\n    \"version\": \"1.23\"\r\n  },\r\n  \"using_pyopenssl\": true\r\n}\r\n```"}}
{"actor":{"display_login":"vxgmichel"}}