{"action":"created","issue":{"url":"https://api.github.com/repos/shazow/urllib3/issues/682","labels_url":"https://api.github.com/repos/shazow/urllib3/issues/682/labels{/name}","comments_url":"https://api.github.com/repos/shazow/urllib3/issues/682/comments","events_url":"https://api.github.com/repos/shazow/urllib3/issues/682/events","html_url":"https://github.com/shazow/urllib3/issues/682","id":96288246,"number":682,"title":"A socket timeout exception in Python 3 shows also a TypeError","user":{"login":"xZise","id":417478,"avatar_url":"https://avatars.githubusercontent.com/u/417478?v=3","gravatar_id":"","url":"https://api.github.com/users/xZise","html_url":"https://github.com/xZise","followers_url":"https://api.github.com/users/xZise/followers","following_url":"https://api.github.com/users/xZise/following{/other_user}","gists_url":"https://api.github.com/users/xZise/gists{/gist_id}","starred_url":"https://api.github.com/users/xZise/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xZise/subscriptions","organizations_url":"https://api.github.com/users/xZise/orgs","repos_url":"https://api.github.com/users/xZise/repos","events_url":"https://api.github.com/users/xZise/events{/privacy}","received_events_url":"https://api.github.com/users/xZise/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-21T11:06:46Z","updated_at":"2015-07-21T16:37:57Z","closed_at":"2015-07-21T11:18:11Z","body":"When a timout occurs it also shows the TypeError because you first try to call it with a `buffering` keyword argument, which does not exist in Python 3. I'm not sure if there is a good way in Python 3 to clear that TypeError exception. See also #537.\r\n\r\n```\r\nERROR: Traceback (most recent call last):\r\n  File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 331, in _make_request\r\n    httplib_response = conn.getresponse(buffering=True)\r\nTypeError: getresponse() got an unexpected keyword argument 'buffering'\r\n \r\nDuring handling of the above exception, another exception occurred:\r\n \r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 333, in _make_request\r\n    httplib_response = conn.getresponse()\r\n  File \"/usr/lib/python3.4/http/client.py\", line 1172, in getresponse\r\n    response.begin()\r\n  File \"/usr/lib/python3.4/http/client.py\", line 351, in begin\r\n    version, status, reason = self._read_status()\r\n  File \"/usr/lib/python3.4/http/client.py\", line 313, in _read_status\r\n    line = str(self.fp.readline(_MAXLINE + 1), \"iso-8859-1\")\r\n  File \"/usr/lib/python3.4/socket.py\", line 371, in readinto\r\n    return self._sock.recv_into(b)\r\n  File \"/usr/lib/python3.4/ssl.py\", line 745, in recv_into\r\n    return self.read(nbytes, buffer)\r\n  File \"/usr/lib/python3.4/ssl.py\", line 617, in read\r\n    v = self._sslobj.read(len, buffer)\r\nsocket.timeout: The read operation timed out\r\n \r\nDuring handling of the above exception, another exception occurred:\r\n \r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3/dist-packages/requests/adapters.py\", line 362, in send\r\n    timeout=timeout\r\n  File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 559, in urlopen\r\n    _pool=self, _stacktrace=stacktrace)\r\n  File \"/usr/lib/python3/dist-packages/urllib3/util/retry.py\", line 245, in increment\r\n    raise six.reraise(type(error), error, _stacktrace)\r\n  File \"/usr/lib/python3/dist-packages/six.py\", line 625, in reraise\r\n    raise value\r\n  File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 516, in urlopen\r\n    body=body, headers=headers)\r\n  File \"/usr/lib/python3/dist-packages/urllib3/connectionpool.py\", line 336, in _make_request\r\n    self, url, \"Read timed out. (read timeout=%s)\" % read_timeout)\r\nurllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='commons.wikimedia.org', port=443): Read timed out. (read timeout=30)\r\n \r\nDuring handling of the above exception, another exception occurred:\r\n \r\nTraceback (most recent call last):\r\n  File \"/home/matanya/core/pywikibot/data/api.py\", line 1911, in submit\r\n    body=body, headers=headers)\r\n  File \"/home/matanya/core/pywikibot/tools/__init__.py\", line 1227, in wrapper\r\n    return obj(*__args, **__kw)\r\n  File \"/home/matanya/core/pywikibot/comms/http.py\", line 240, in request\r\n    r = fetch(baseuri, method, body, headers, **kwargs)\r\n  File \"/home/matanya/core/pywikibot/comms/http.py\", line 359, in fetch\r\n    error_handling_callback(request)\r\n  File \"/home/matanya/core/pywikibot/comms/http.py\", line 276, in error_handling_callback\r\n    raise request.data\r\n  File \"/home/matanya/core/pywikibot/comms/http.py\", line 255, in _http_process\r\n    auth=auth, timeout=timeout, verify=True)\r\n  File \"/usr/lib/python3/dist-packages/requests/sessions.py\", line 457, in request\r\n    resp = self.send(prep, **send_kwargs)\r\n  File \"/usr/lib/python3/dist-packages/requests/sessions.py\", line 569, in send\r\n    r = adapter.send(request, **kwargs)\r\n  File \"/usr/lib/python3/dist-packages/requests/adapters.py\", line 422, in send\r\n    raise ReadTimeout(e, request=request)\r\nrequests.exceptions.ReadTimeout: HTTPSConnectionPool(host='commons.wikimedia.org', port=443): Read timed out. (read timeout=30)\r\n```"},"comment":{"url":"https://api.github.com/repos/shazow/urllib3/issues/comments/123395683","html_url":"https://github.com/shazow/urllib3/issues/682#issuecomment-123395683","issue_url":"https://api.github.com/repos/shazow/urllib3/issues/682","id":123395683,"user":{"login":"xZise","id":417478,"avatar_url":"https://avatars.githubusercontent.com/u/417478?v=3","gravatar_id":"","url":"https://api.github.com/users/xZise","html_url":"https://github.com/xZise","followers_url":"https://api.github.com/users/xZise/followers","following_url":"https://api.github.com/users/xZise/following{/other_user}","gists_url":"https://api.github.com/users/xZise/gists{/gist_id}","starred_url":"https://api.github.com/users/xZise/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xZise/subscriptions","organizations_url":"https://api.github.com/users/xZise/orgs","repos_url":"https://api.github.com/users/xZise/repos","events_url":"https://api.github.com/users/xZise/events{/privacy}","received_events_url":"https://api.github.com/users/xZise/received_events","type":"User","site_admin":false},"created_at":"2015-07-21T16:37:57Z","updated_at":"2015-07-21T16:37:57Z","body":"Hmm that is unfortunate. Now in theory there is one (relatively) ugly workaround:\r\n\r\n```\r\n>>> def div(a, b):\r\n...   try:\r\n...     r = a / b\r\n...   except TypeError:\r\n...     r = None\r\n...   if r is None:\r\n...     r = a / int(b)\r\n...   return r\r\n... \r\n>>> div(42, 0)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"<stdin>\", line 3, in div\r\nZeroDivisionError: division by zero\r\n>>> div(42, '0')\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"<stdin>\", line 7, in div\r\nZeroDivisionError: division by zero\r\n```"}}