[Twisted-Python] CopyableFailure fails

Hi, with twisted 11.0.0 and python 2.7, my error fails here: File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux- x86_64.egg/twisted/spread/pb.py", line 407, in getStateToCopy state['value'] = str(self.value) # Exception instance exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u201e' in position 10: ordinal not in range(128) this bug hides my own bug, giving me no useful backtrace. simple fix: --- x 2012-02-06 21:05:33.907228573 +0100 +++ pb.py 2012-02-06 21:05:36.923228461 +0100 @@ -404,7 +404,7 @@ if isinstance(self.value, failure.Failure): state['value'] = failure2Copyable(self.value, self.unsafeTracebacks) else: - state['value'] = str(self.value) # Exception instance + state['value'] = repr(self.value) # Exception instance if isinstance(self.type, str): state['type'] = self.type else: -- Wolfgang

On 08:07 pm, wolfgang@rohdewald.de wrote:
Hi,
with twisted 11.0.0 and python 2.7, my error fails here:
Hello, Please provide a minimal example reproducing the problem so we can discuss it. See http://sscce.org/ for more details. Thanks, Jean-Paul

Am Montag, 6. Februar 2012, 23:12:29 schrieb exarkun@twistedmatrix.com:
I was hoping it would be self-evident. Trimming this to a short example could be rather much work. I hope the full backtrace will help. anyway I overlooked the fact that two backtraces are printed where the first on gives me my own calling stack. But the second one (UnicodeEncodeError) should not happen IMHO, and it does not with my patch. Unhandled Error Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 1348, in remote_respond d = self.portal.login(self, mind, IPerspective) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/cred/portal.py", line 116, in login ).addCallback(self.realm.requestAvatar, mind, *interfaces File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 297, in addCallback callbackKeywords=kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 286, in addCallbacks self._runCallbacks() --- <exception caught here> --- File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 542, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/hdd/pub/src/gitgames/kajongg/src/server.py", line 956, in requestAvatar avatar.attached(mind) File "/hdd/pub/src/gitgames/kajongg/src/server.py", line 908, in attached self.server.login(self) File "/hdd/pub/src/gitgames/kajongg/src/server.py", line 717, in login self.loadSuspendedTables(user) File "/hdd/pub/src/gitgames/kajongg/src/server.py", line 889, in loadSuspendedTables table = Table(self, None, Ruleset.cached(ruleset, used=True), playOpen, autoPlay=False, seed=seed) File "/hdd/pub/src/gitgames/kajongg/src/scoringengine.py", line 77, in cached result = Ruleset(name, used) File "/hdd/pub/src/gitgames/kajongg/src/scoringengine.py", line 110, in __init__ self.initRuleset() File "/hdd/pub/src/gitgames/kajongg/src/scoringengine.py", line 167, in initRuleset raise Exception(u'just one unicode char:ä') exceptions.Exception: Exception(u'just one unicode char:\xe4',) fail: <twisted.spread.pb.CopyableFailure <type 'exceptions.Exception'>> Unhandled error in Deferred: Unhandled Error Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 515, in expressionReceived method(*sexp[1:]) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 827, in proto_message self._recvMessage(self.localObjectForID, requestID, objectID, message, answerRequired, netArgs, netKw) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 865, in _recvMessage callbackArgs=args, errbackArgs=args) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 286, in addCallbacks self._runCallbacks() --- <exception caught here> --- File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 542, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 896, in _sendFailureOrError self._sendFailure(fail, requestID) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 905, in _sendFailure self._sendError(fail, requestID) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 921, in _sendError self.sendCall("error", requestID, self.serialize(fail)) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 764, in serialize return jelly(object, self.security, None, self) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/jelly.py", line 1122, in jelly return _Jellier(taster, persistentStore, invoker).jelly(object) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/jelly.py", line 475, in jelly return obj.jellyFor(self) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/flavors.py", line 299, in jellyFor state = self.getStateToCopyFor(p) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/flavors.py", line 267, in getStateToCopyFor return self.getStateToCopy() File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 407, in getStateToCopy state['value'] = str(self.value) # Exception instance exceptions.UnicodeEncodeError: UnicodeEncodeError('ascii', u'just one unicode char:\xe4', 22, 23, 'ordinal not in range(128)') -- Wolfgang

On 7 Feb, 12:41 am, wolfgang@rohdewald.de wrote:
Would anyone else like to try to construct a minimal example for this and file a ticket for it? The problem *appears* to be due to the fact that `Exception` does not support conversion to a string when it is wrapped around unicode. eg, position 0: ordinal not in range(128)
Jean-Paul

On 08:07 pm, wolfgang@rohdewald.de wrote:
Hi,
with twisted 11.0.0 and python 2.7, my error fails here:
Hello, Please provide a minimal example reproducing the problem so we can discuss it. See http://sscce.org/ for more details. Thanks, Jean-Paul

Am Montag, 6. Februar 2012, 23:12:29 schrieb exarkun@twistedmatrix.com:
I was hoping it would be self-evident. Trimming this to a short example could be rather much work. I hope the full backtrace will help. anyway I overlooked the fact that two backtraces are printed where the first on gives me my own calling stack. But the second one (UnicodeEncodeError) should not happen IMHO, and it does not with my patch. Unhandled Error Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 1348, in remote_respond d = self.portal.login(self, mind, IPerspective) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/cred/portal.py", line 116, in login ).addCallback(self.realm.requestAvatar, mind, *interfaces File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 297, in addCallback callbackKeywords=kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 286, in addCallbacks self._runCallbacks() --- <exception caught here> --- File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 542, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/hdd/pub/src/gitgames/kajongg/src/server.py", line 956, in requestAvatar avatar.attached(mind) File "/hdd/pub/src/gitgames/kajongg/src/server.py", line 908, in attached self.server.login(self) File "/hdd/pub/src/gitgames/kajongg/src/server.py", line 717, in login self.loadSuspendedTables(user) File "/hdd/pub/src/gitgames/kajongg/src/server.py", line 889, in loadSuspendedTables table = Table(self, None, Ruleset.cached(ruleset, used=True), playOpen, autoPlay=False, seed=seed) File "/hdd/pub/src/gitgames/kajongg/src/scoringengine.py", line 77, in cached result = Ruleset(name, used) File "/hdd/pub/src/gitgames/kajongg/src/scoringengine.py", line 110, in __init__ self.initRuleset() File "/hdd/pub/src/gitgames/kajongg/src/scoringengine.py", line 167, in initRuleset raise Exception(u'just one unicode char:ä') exceptions.Exception: Exception(u'just one unicode char:\xe4',) fail: <twisted.spread.pb.CopyableFailure <type 'exceptions.Exception'>> Unhandled error in Deferred: Unhandled Error Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 515, in expressionReceived method(*sexp[1:]) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 827, in proto_message self._recvMessage(self.localObjectForID, requestID, objectID, message, answerRequired, netArgs, netKw) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 865, in _recvMessage callbackArgs=args, errbackArgs=args) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 286, in addCallbacks self._runCallbacks() --- <exception caught here> --- File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py", line 542, in _runCallbacks current.result = callback(current.result, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 896, in _sendFailureOrError self._sendFailure(fail, requestID) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 905, in _sendFailure self._sendError(fail, requestID) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 921, in _sendError self.sendCall("error", requestID, self.serialize(fail)) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 764, in serialize return jelly(object, self.security, None, self) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/jelly.py", line 1122, in jelly return _Jellier(taster, persistentStore, invoker).jelly(object) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/jelly.py", line 475, in jelly return obj.jellyFor(self) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/flavors.py", line 299, in jellyFor state = self.getStateToCopyFor(p) File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/flavors.py", line 267, in getStateToCopyFor return self.getStateToCopy() File "/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg/twisted/spread/pb.py", line 407, in getStateToCopy state['value'] = str(self.value) # Exception instance exceptions.UnicodeEncodeError: UnicodeEncodeError('ascii', u'just one unicode char:\xe4', 22, 23, 'ordinal not in range(128)') -- Wolfgang

On 7 Feb, 12:41 am, wolfgang@rohdewald.de wrote:
Would anyone else like to try to construct a minimal example for this and file a ticket for it? The problem *appears* to be due to the fact that `Exception` does not support conversion to a string when it is wrapped around unicode. eg, position 0: ordinal not in range(128)
Jean-Paul
participants (2)
-
exarkun@twistedmatrix.com
-
Wolfgang Rohdewald