Skip to content

Commit

Permalink
Fix regression in CopiedFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonspeed authored and adiroiban committed Aug 6, 2024
1 parent b51c186 commit 4814526
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/twisted/newsfragments/12279.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed unreleased regression caused by PR 12109.
4 changes: 4 additions & 0 deletions src/twisted/python/failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ def parents(self):
self._parents = [self.type]
return self._parents

@parents.setter
def parents(self, parents):
self._parents = parents

def _extrapolate(self, otherFailure):
"""
Extrapolate from one failure into another, copying its stack frames.
Expand Down
11 changes: 11 additions & 0 deletions src/twisted/test/test_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,17 @@ def test_failurePicklingIncludesParents(self) -> None:
f = failure.Failure(ComparableException("hello"))
self.assertEqual(f.__getstate__()["parents"], f.parents)

def test_settableParents(self) -> None:
"""
C{Failure.parents} can be set, both before and after pickling.
This is used by Perspective Broker.
"""
original_failure = failure.Failure(ComparableException("hello"))
original_failure.parents = original_failure.parents[:]
failure2 = pickle.loads(pickle.dumps(original_failure))
failure2.parents = failure2.parents[:]


class BrokenStr(Exception):
"""
Expand Down

0 comments on commit 4814526

Please sign in to comment.