@@ -2050,18 +2050,20 @@ def http_error_default(self, url, fp, errcode, errmsg, headers):
20502050 def http_error_302 (self , url , fp , errcode , errmsg , headers , data = None ):
20512051 """Error 302 -- relocated (temporarily)."""
20522052 self .tries += 1
2053- if self .maxtries and self .tries >= self .maxtries :
2054- if hasattr (self , "http_error_500" ):
2055- meth = self .http_error_500
2056- else :
2057- meth = self .http_error_default
2053+ try :
2054+ if self .maxtries and self .tries >= self .maxtries :
2055+ if hasattr (self , "http_error_500" ):
2056+ meth = self .http_error_500
2057+ else :
2058+ meth = self .http_error_default
2059+ return meth (url , fp , 500 ,
2060+ "Internal Server Error: Redirect Recursion" ,
2061+ headers )
2062+ result = self .redirect_internal (url , fp , errcode , errmsg ,
2063+ headers , data )
2064+ return result
2065+ finally :
20582066 self .tries = 0
2059- return meth (url , fp , 500 ,
2060- "Internal Server Error: Redirect Recursion" , headers )
2061- result = self .redirect_internal (url , fp , errcode , errmsg , headers ,
2062- data )
2063- self .tries = 0
2064- return result
20652067
20662068 def redirect_internal (self , url , fp , errcode , errmsg , headers , data ):
20672069 if 'location' in headers :
0 commit comments