yaocaigen / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

httplib.HTTPException not declared in Python 3 variant (should be http.client.HTTPException?) #118

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
* What steps will reproduce the problem?

I'm not sure of the exact steps, but the french message of the first traceback 
translate into "an existing connection was closed by the remote host."

* What is the expected output? What do you see instead?

Below is the traceback I run into. The last traceback show that there is either 
a missing import or a Python 3 port issue.

Traceback (most recent call last):
  File "E:\prg\py\App\books24x7crawler\src\httplib2\__init__.py", line 847, in _conn_request
    conn.request(method, request_uri, body, headers)
  File "C:\Python31\lib\http\client.py", line 932, in request
    self._send_request(method, url, body, headers)
  File "C:\Python31\lib\http\client.py", line 970, in _send_request
    self.endheaders(body)
  File "C:\Python31\lib\http\client.py", line 928, in endheaders
    self._send_output(message_body)
  File "C:\Python31\lib\http\client.py", line 782, in _send_output
    self.send(msg)
  File "C:\Python31\lib\http\client.py", line 758, in send
    self.sock.sendall(str)
socket.error: [Errno 10054] Une connexion existante a d\xfb \xeatre ferm\xe9e 
par l'h\xf4te distant

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "src\b24x7.py", line 397, in <module>
    main()
  File "src\b24x7.py", line 394, in main
    crawler.check()
  File "src\b24x7.py", line 159, in check
    process_section( entry[1] )
  File "src\b24x7.py", line 156, in process_section
    self.retrieve_section( chunk_id )
  File "src\b24x7.py", line 199, in retrieve_section
    caching=True, average_sleep=30, min_sleep=3.0 )
  File "src\b24x7.py", line 70, in fetch_html
    headers=request_headers, method=method, body=body )
  File "E:\prg\py\App\books24x7crawler\src\httplib2\__init__.py", line 1116, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cac
hekey)
  File "E:\prg\py\App\books24x7crawler\src\httplib2\__init__.py", line 887, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "E:\prg\py\App\books24x7crawler\src\httplib2\__init__.py", line 851, in _conn_request
    except (socket.error, httplib.HTTPException):
NameError: global name 'httplib' is not defined

* What version of the product are you using? On what operating system?
I'm using httplib2-0.6.0 with Python 3.1.2 on Windows XP SP3.

* My analysis

The exception triggers in the following code of method Http._conn_request:

---
try:
    conn.request(method, request_uri, body, headers)
except socket.gaierror:
    conn.close()
    raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
except (socket.error, httplib.HTTPException):
    # Just because the server closed the connection doesn't apparently mean
    # that the server didn't send a response.
    pass
try:
    response = conn.getresponse()
except (socket.error, http.client.HTTPException):
...

---

I believe httplib.HTTPException should replaced by http.client.HTTPException as 
was done for the second except statement, but I'm no expert.

Original issue reported on code.google.com by baptiste...@gmail.com on 5 Oct 2010 at 2:14

GoogleCodeExporter commented 9 years ago
I confirm, the bug is still here and can be fixed by the change you pointed out.

Original comment by quaero.galileo@gmail.com on 26 Dec 2010 at 6:24

GoogleCodeExporter commented 9 years ago

Original comment by joe.gregorio@gmail.com on 13 Feb 2011 at 5:04