@@ -264,10 +264,14 @@ def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
264264 except :
265265 # report exception back to server
266266 exc_type , exc_value , exc_tb = sys .exc_info ()
267- response = dumps (
268- Fault (1 , "%s:%s" % (exc_type , exc_value )),
269- encoding = self .encoding , allow_none = self .allow_none ,
270- )
267+ try :
268+ response = dumps (
269+ Fault (1 , "%s:%s" % (exc_type , exc_value )),
270+ encoding = self .encoding , allow_none = self .allow_none ,
271+ )
272+ finally :
273+ # Break reference cycle
274+ exc_type = exc_value = exc_tb = None
271275
272276 return response .encode (self .encoding , 'xmlcharrefreplace' )
273277
@@ -359,10 +363,14 @@ def system_multicall(self, call_list):
359363 )
360364 except :
361365 exc_type , exc_value , exc_tb = sys .exc_info ()
362- results .append (
363- {'faultCode' : 1 ,
364- 'faultString' : "%s:%s" % (exc_type , exc_value )}
365- )
366+ try :
367+ results .append (
368+ {'faultCode' : 1 ,
369+ 'faultString' : "%s:%s" % (exc_type , exc_value )}
370+ )
371+ finally :
372+ # Break reference cycle
373+ exc_type = exc_value = exc_tb = None
366374 return results
367375
368376 def _dispatch (self , method , params ):
@@ -624,10 +632,14 @@ def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
624632 # (each dispatcher should have handled their own
625633 # exceptions)
626634 exc_type , exc_value = sys .exc_info ()[:2 ]
627- response = dumps (
628- Fault (1 , "%s:%s" % (exc_type , exc_value )),
629- encoding = self .encoding , allow_none = self .allow_none )
630- response = response .encode (self .encoding , 'xmlcharrefreplace' )
635+ try :
636+ response = dumps (
637+ Fault (1 , "%s:%s" % (exc_type , exc_value )),
638+ encoding = self .encoding , allow_none = self .allow_none )
639+ response = response .encode (self .encoding , 'xmlcharrefreplace' )
640+ finally :
641+ # Break reference cycle
642+ exc_type = exc_value = None
631643 return response
632644
633645class CGIXMLRPCRequestHandler (SimpleXMLRPCDispatcher ):
0 commit comments