mirror of
https://github.com/python/cpython.git
synced 2025-10-04 06:06:44 +00:00
xmlrpc.server now explicitly breaks reference cycles when using
sys.exc_info() in code handling exceptions.
(cherry picked from commit 84524454d0
)
This commit is contained in:
parent
24c0c5b48c
commit
12a3e343e1
2 changed files with 26 additions and 12 deletions
|
@ -264,10 +264,14 @@ class SimpleXMLRPCDispatcher:
|
||||||
except:
|
except:
|
||||||
# report exception back to server
|
# report exception back to server
|
||||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||||
response = dumps(
|
try:
|
||||||
Fault(1, "%s:%s" % (exc_type, exc_value)),
|
response = dumps(
|
||||||
encoding=self.encoding, allow_none=self.allow_none,
|
Fault(1, "%s:%s" % (exc_type, exc_value)),
|
||||||
)
|
encoding=self.encoding, allow_none=self.allow_none,
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
# Break reference cycle
|
||||||
|
exc_type = exc_value = exc_tb = None
|
||||||
|
|
||||||
return response.encode(self.encoding, 'xmlcharrefreplace')
|
return response.encode(self.encoding, 'xmlcharrefreplace')
|
||||||
|
|
||||||
|
@ -359,10 +363,14 @@ class SimpleXMLRPCDispatcher:
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||||
results.append(
|
try:
|
||||||
{'faultCode' : 1,
|
results.append(
|
||||||
'faultString' : "%s:%s" % (exc_type, exc_value)}
|
{'faultCode' : 1,
|
||||||
)
|
'faultString' : "%s:%s" % (exc_type, exc_value)}
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
# Break reference cycle
|
||||||
|
exc_type = exc_value = exc_tb = None
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def _dispatch(self, method, params):
|
def _dispatch(self, method, params):
|
||||||
|
@ -624,10 +632,14 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer):
|
||||||
# (each dispatcher should have handled their own
|
# (each dispatcher should have handled their own
|
||||||
# exceptions)
|
# exceptions)
|
||||||
exc_type, exc_value = sys.exc_info()[:2]
|
exc_type, exc_value = sys.exc_info()[:2]
|
||||||
response = dumps(
|
try:
|
||||||
Fault(1, "%s:%s" % (exc_type, exc_value)),
|
response = dumps(
|
||||||
encoding=self.encoding, allow_none=self.allow_none)
|
Fault(1, "%s:%s" % (exc_type, exc_value)),
|
||||||
response = response.encode(self.encoding, 'xmlcharrefreplace')
|
encoding=self.encoding, allow_none=self.allow_none)
|
||||||
|
response = response.encode(self.encoding, 'xmlcharrefreplace')
|
||||||
|
finally:
|
||||||
|
# Break reference cycle
|
||||||
|
exc_type = exc_value = None
|
||||||
return response
|
return response
|
||||||
|
|
||||||
class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
|
class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
xmlrpc.server now explicitly breaks reference cycles when using
|
||||||
|
sys.exc_info() in code handling exceptions.
|
Loading…
Add table
Add a link
Reference in a new issue