[Zodb-checkins] CVS: ZODB3/ZEO/zrpc - connection.py:1.35
Guido van Rossum
guido@python.org
Wed, 25 Sep 2002 18:12:08 -0400
Update of /cvs-repository/ZODB3/ZEO/zrpc
In directory cvs.zope.org:/tmp/cvs-serv13660
Modified Files:
connection.py
Log Message:
send_reply(): catch errors in encode() and send a ZRPCError exception
instead.
return_error(): be more careful calling repr() on err_value.
=== ZODB3/ZEO/zrpc/connection.py 1.34 => 1.35 ===
--- ZODB3/ZEO/zrpc/connection.py:1.34 Tue Sep 24 08:48:01 2002
+++ ZODB3/ZEO/zrpc/connection.py Wed Sep 25 18:12:08 2002
@@ -263,7 +263,15 @@
return hasattr(self.obj, name)
def send_reply(self, msgid, ret):
- msg = self.marshal.encode(msgid, 0, REPLY, ret)
+ try:
+ msg = self.marshal.encode(msgid, 0, REPLY, ret)
+ except self.marshal.errors:
+ try:
+ r = repr(ret)
+ except:
+ r = "<unreprable>"
+ err = ZRPCError("Couldn't pickle return %.100s" % r)
+ msg = self.marshal.encode(msgid, 0, REPLY, (ZRPCError, err))
self.message_output(msg)
self.poll()
@@ -280,7 +288,11 @@
try:
msg = self.marshal.encode(msgid, 0, REPLY, (err_type, err_value))
except self.marshal.errors:
- err = ZRPCError("Couldn't pickle error %s" % `err_value`)
+ try:
+ r = repr(err_value)
+ except:
+ r = "<unreprable>"
+ err = ZRPCError("Couldn't pickle error %.100s" % r)
msg = self.marshal.encode(msgid, 0, REPLY, (ZRPCError, err))
self.message_output(msg)
self.poll()