dougfort at downright.com
Sat Feb 17 03:29:33 CET 2001
Here's how we do it. Note that you must 'import socket'. The 'message'
object is usually a tuple.
except socket.error, message:
self._message = "Socket Error: %s" % (str(message))
Senior Meat Manager
Downright Software LLC
"Gustaf Liljegren" <gustafl at algonet.se> wrote in message
news:Xns904B3C674D9gustaflalgonetse at 188.8.131.52...
> I'm using 1.5.2 in Windows 98.
> When running the httplib module I get the following error when using a
> existing host name:
> Traceback (innermost last):
> File "httptest.py", line 28, in ?
> h = httplib.HTTP(domain)
> File "d:\python\Lib\httplib.py", line 51, in __init__
> if host: self.connect(host, port)
> File "d:\python\Lib\httplib.py", line 79, in connect
> self.sock.connect(host, port)
> File "<string>", line 1, in connect
> socket.error: host not found
> The code to produce this error is simply:
> import httplib
> h = httplib.HTTP('www.nonvalidhost.com')
> Python doesn't seem to like when I write "except socket.error:", so I
> wonder how to handle it properly.
> Gustaf Liljegren
More information about the Python-list