En Thu, 18 Sep 2008 23:12:22 -0300, Gabriel Genellina <[EMAIL PROTECTED]> escribió:

En Wed, 17 Sep 2008 22:48:27 -0300, Steven D'Aprano <[EMAIL PROTECTED]> escribió:

Under what circumstances do HTTPError objects not have a valid file
object? How common is this? Does anyone have an example of a URL that
fails in that fashion?

Well, there is at least one case (AbstractDigestAuthHandler at line 864 in urllib2.py) where HTTPError is raised explicitely with fp=None. It's not a common case, I think. If you rely on the exception having a read() method, add it a fake one yourself:

try: ...
except urllib2.HTTPError, e:
     if not hasattr(e, 'read'):
         e.read = e.readline = lambda self: '' # or perhaps e.msg
     conn = e

Oops, that should have been e.read = lambda: ''

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to