utils/web.py: Only try catching socket.sslerror if built with SSL support

Closes: Sf#2998820

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2010-05-24 15:44:25 -04:00
parent 57e894de58
commit f03a3f6c85

View File

@ -37,6 +37,12 @@ import sgmllib
import urlparse import urlparse
import htmlentitydefs import htmlentitydefs
sockerrors = (socket.error,)
try:
sockerrors += (socket.sslerror,)
except AttributeError:
pass
from str import normalizeWhitespace from str import normalizeWhitespace
Request = urllib2.Request Request = urllib2.Request
@ -112,7 +118,7 @@ def getUrlFd(url, headers=None, data=None):
return fd return fd
except socket.timeout, e: except socket.timeout, e:
raise Error, TIMED_OUT raise Error, TIMED_OUT
except (socket.error, socket.sslerror), e: except sockerrors, e:
raise Error, strError(e) raise Error, strError(e)
except httplib.InvalidURL, e: except httplib.InvalidURL, e:
raise Error, 'Invalid URL: %s' % e raise Error, 'Invalid URL: %s' % e