@@ -238,7 +238,7 @@ def do_open(self, req):
238238 self ._cm .add (host , h , 0 )
239239 self ._start_transaction (h , req )
240240 r = h .getresponse ()
241- except (socket .error , httplib .HTTPException ), err :
241+ except (socket .error , httplib .HTTPException ) as err :
242242 raise urllib2 .URLError (err )
243243
244244 if DEBUG : DEBUG .info ("STATUS: %s, %s" , r .status , r .reason )
@@ -323,7 +323,7 @@ def _start_transaction(self, h, req):
323323 h .putrequest (req .get_method () or 'GET' , req .selector , skip_host = req .has_header ("Host" ), skip_accept_encoding = req .has_header ("Accept-encoding" ))
324324 else :
325325 h .putrequest (req .get_method () or 'GET' , req .get_selector (), skip_host = req .has_header ("Host" ), skip_accept_encoding = req .has_header ("Accept-encoding" ))
326- except (socket .error , httplib .HTTPException ), err :
326+ except (socket .error , httplib .HTTPException ) as err :
327327 raise urllib2 .URLError (err )
328328
329329 if not req .headers .has_key ('Connection' ):
@@ -495,7 +495,7 @@ def error_handler(url):
495495 fo .close ()
496496 try : status , reason = fo .status , fo .reason
497497 except AttributeError : status , reason = None , None
498- except IOError , e :
498+ except IOError as e :
499499 print " EXCEPTION: %s" % e
500500 raise
501501 else :
@@ -613,7 +613,7 @@ def debug(self, msg, *args): print msg % args
613613def test (url , N = 10 ):
614614 print "checking error hander (do this on a non-200)"
615615 try : error_handler (url )
616- except IOError , e :
616+ except IOError as e :
617617 print "exiting - exception will prevent further tests"
618618 sys .exit ()
619619 print
0 commit comments