@@ -270,10 +270,14 @@ def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
270270 except :
271271 # report exception back to server
272272 exc_type , exc_value , exc_tb = sys .exc_info ()
273- response = dumps (
274- Fault (1 , "%s:%s" % (exc_type , exc_value )),
275- encoding = self .encoding , allow_none = self .allow_none ,
276- )
273+ try :
274+ response = dumps (
275+ Fault (1 , "%s:%s" % (exc_type , exc_value )),
276+ encoding = self .encoding , allow_none = self .allow_none ,
277+ )
278+ finally :
279+ # Break reference cycle
280+ exc_type = exc_value = exc_tb = None
277281
278282 return response .encode (self .encoding , 'xmlcharrefreplace' )
279283
@@ -365,10 +369,14 @@ def system_multicall(self, call_list):
365369 )
366370 except :
367371 exc_type , exc_value , exc_tb = sys .exc_info ()
368- results .append (
369- {'faultCode' : 1 ,
370- 'faultString' : "%s:%s" % (exc_type , exc_value )}
371- )
372+ try :
373+ results .append (
374+ {'faultCode' : 1 ,
375+ 'faultString' : "%s:%s" % (exc_type , exc_value )}
376+ )
377+ finally :
378+ # Break reference cycle
379+ exc_type = exc_value = exc_tb = None
372380 return results
373381
374382 def _dispatch (self , method , params ):
@@ -630,10 +638,14 @@ def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
630638 # (each dispatcher should have handled their own
631639 # exceptions)
632640 exc_type , exc_value = sys .exc_info ()[:2 ]
633- response = dumps (
634- Fault (1 , "%s:%s" % (exc_type , exc_value )),
635- encoding = self .encoding , allow_none = self .allow_none )
636- response = response .encode (self .encoding , 'xmlcharrefreplace' )
641+ try :
642+ response = dumps (
643+ Fault (1 , "%s:%s" % (exc_type , exc_value )),
644+ encoding = self .encoding , allow_none = self .allow_none )
645+ response = response .encode (self .encoding , 'xmlcharrefreplace' )
646+ finally :
647+ # Break reference cycle
648+ exc_type = exc_value = None
637649 return response
638650
639651class CGIXMLRPCRequestHandler (SimpleXMLRPCDispatcher ):
0 commit comments