Skip to content

Commit 4814526

Browse files
pythonspeedadiroiban
authored andcommitted
Fix regression in CopiedFailure
1 parent b51c186 commit 4814526

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed unreleased regression caused by PR 12109.

src/twisted/python/failure.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ def parents(self):
429429
self._parents = [self.type]
430430
return self._parents
431431

432+
@parents.setter
433+
def parents(self, parents):
434+
self._parents = parents
435+
432436
def _extrapolate(self, otherFailure):
433437
"""
434438
Extrapolate from one failure into another, copying its stack frames.

src/twisted/test/test_failure.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,17 @@ def test_failurePicklingIncludesParents(self) -> None:
568568
f = failure.Failure(ComparableException("hello"))
569569
self.assertEqual(f.__getstate__()["parents"], f.parents)
570570

571+
def test_settableParents(self) -> None:
572+
"""
573+
C{Failure.parents} can be set, both before and after pickling.
574+
575+
This is used by Perspective Broker.
576+
"""
577+
original_failure = failure.Failure(ComparableException("hello"))
578+
original_failure.parents = original_failure.parents[:]
579+
failure2 = pickle.loads(pickle.dumps(original_failure))
580+
failure2.parents = failure2.parents[:]
581+
571582

572583
class BrokenStr(Exception):
573584
"""

0 commit comments

Comments
 (0)