Gustaf Liljegren gustafl at
Fri Feb 16 18:02:50 EST 2001

I'm using 1.5.2 in Windows 98.

When running the httplib module I get the following error when using a non-
existing host name:

Traceback (innermost last):
  File "", line 28, in ?
    h = httplib.HTTP(domain)
  File "d:\python\Lib\", line 51, in __init__
    if host: self.connect(host, port)
  File "d:\python\Lib\", 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('')

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 mailing list