Go with the default error message used by BaseHTTPServer.BaseHTTPRequestHandler.send_error rather than the one thrown by socket.error which, I think, is some kind of object which, when passed to send_error, results in another exception.
Exception happened during processing of request from ('127.0.0.1', 35444)
Traceback (most recent call last):
File "/usr/lib/python2.5/SocketServer.py", line 222, in handle_request
self.process_request(request, client_address)
File "/usr/lib/python2.5/SocketServer.py", line 241, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.5/SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.5/SocketServer.py", line 522, in __init__
self.handle()
File "/usr/lib/python2.5/BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
File "/usr/lib/python2.5/BaseHTTPServer.py", line 310, in handle_one_request
method()
File "cheatproxy.py", line 44, in do_GET
if self._connect_to(netloc, soc):
File "cheatproxy.py", line 75, in _connect_to
self.send_error(502, msg)
File "/usr/lib/python2.5/BaseHTTPServer.py", line 343, in send_error
{'code': code, 'message': _quote_html(message), 'explain': explain})
File "/usr/lib/python2.5/BaseHTTPServer.py", line 93, in _quote_html
return html.replace("&", "&").replace("<", "<").replace(">", ">")
AttributeError: 'gaierror' object has no attribute 'replace'