Opened 5 years ago

Closed 2 years ago

Last modified 2 years ago

#7679 defect closed duplicate (duplicate)

__traceback__ for spread.pb.CopyableFailure received by a Python3 process

Reported by: Wolfgang Rohdewald Owned by:
Priority: normal Milestone: Python-3.x
Component: core Keywords:
Cc: Branch:


I have one process raising a UnicodeDecodeError. This is sent over the wire to a Python3 process. That one calls Failure.cleanFailure (traceback see below) which says self.value.__traceback__ = None. But when receiving a UnicodeDecodeError packed into CopyableFailure, self.value is a string, and setting __traceback__ raises AttributeError. The fix in cleanFailure() is simple:

@@ -495,7 +498,7 @@ class Failure:
         exception instance to C{None}.
         self.__dict__ = self.__getstate__()
-        if _PY3:
+        if _PY3 and getattr(self.value, '__traceback__', None):
             self.value.__traceback__ = None

But the first problem is the docstring of cleanFailure() which implies that self.value must always be an exception instance. Is that docstring correct?

This code in cleanFailure() was added with svn r35620 (Port twisted.internet.defer to Python 3).

My traceback:

Unhandled Error
Traceback (most recent call last):
  File "/home/wr/vpn/kajongg/src/twisted/python/", line 102, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/wr/vpn/kajongg/src/twisted/python/", line 85, in callWithContext
    return{ILogContext: newCtx}, func, *args, **kw)
  File "/home/wr/vpn/kajongg/src/twisted/python/", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/wr/vpn/kajongg/src/twisted/python/", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/home/wr/vpn/kajongg/src/twisted/internet/", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/home/wr/vpn/kajongg/src/twisted/internet/", line 215, in doRead
    return self._dataReceived(data)
  File "/home/wr/vpn/kajongg/src/twisted/internet/", line 221, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/wr/vpn/kajongg/src/twisted/spread/", line 266, in dataReceived
  File "/home/wr/vpn/kajongg/src/twisted/spread/", line 187, in gotItem
  File "/home/wr/vpn/kajongg/src/twisted/spread/", line 150, in callExpressionReceived
  File "/home/wr/vpn/kajongg/src/twisted/spread/", line 591, in expressionReceived
  File "/home/wr/vpn/kajongg/src/twisted/spread/", line 1016, in proto_error
  File "/home/wr/vpn/kajongg/src/twisted/internet/", line 426, in errback
  File "/home/wr/vpn/kajongg/src/twisted/internet/", line 493, in _startRunCallbacks
  File "/home/wr/vpn/kajongg/src/twisted/internet/", line 625, in _runCallbacks
  File "/home/wr/vpn/kajongg/src/twisted/python/", line 502, in cleanFailure
    self.value.__traceback__ = None
builtins.AttributeError: 'str' object has no attribute '__traceback__'

where proto_error() calls unserialize with those arguments:

[b'twisted.spread.pb.CopyableFailure', [b'dictionary', [b'count', 8], [b'captureVars', [b'boolean', b'false']], [b'type', b'exceptions.UnicodeDecodeError'], [b'traceback', b'Traceback unavailable\n'], [b'value', b"'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)"], [b'unsafeTracebacks', [b'boolean', b'false']], [b'parents', [b'list', b'exceptions.UnicodeDecodeError', b'exceptions.UnicodeError', b'exceptions.ValueError', b'exceptions.StandardError', b'exceptions.Exception', b'exceptions.BaseException', b'__builtin__.object']], [b'frames', [b'list']], [b'tb', [b'None']], [b'stack', [b'list']]]]}}}

Change History (4)

comment:1 Changed 5 years ago by Glyph

Keywords: review removed

Thanks for the bug report.

This ticket does not appear to have a patch or branch attached though, so it's not ready for review yet.

Perhaps by the "review" keyword you meant you'd like someone to review and discuss it? In that case, please raise it on the mailing list.

comment:2 Changed 2 years ago by Craig Rodrigues

Keywords: py3k removed
Milestone: Python-3.x

comment:3 Changed 2 years ago by Craig Rodrigues

Resolution: duplicate
Status: newclosed

Duplicate of ticket:9057

comment:4 Changed 2 years ago by Glyph

Thanks for finding this and closing this, cleaning up extra open bugs is great.

However, by default, the ticket closed when a duplicate is found should be the higher-numbered ticket. There's generally an exception to this if the higher-numbered one already has a PR (or patch) attached, so it's always nice to note that explicitly if that's the case.

Note: See TracTickets for help on using tickets.