Error Codes From a URLError

Christopher T King squirrel at WPI.EDU
Fri Jul 23 18:08:48 CEST 2004


On 23 Jul 2004, Fuzzyman wrote:

> *However*, when I use it to try to fetch a non-existent page
> (expecting a 404 error) - it falls at the first raise statement.
> Evidently the exception *is* an IOError, but doesn't have the code
> attribute.

For the "non-existent page", are you using a url of the form
'http://fake.server/some/file' or 'http://real.server/fake/file'?  
Because if the host is nonexistent (and therefore a connection can't be
opened), then I'd expect urllib2 to raise an IOError.  I'd expect an
HTTPError only if the server exists and explicitly returns a 404.




More information about the Python-list mailing list