Skip to content

Commit

Permalink
twisted#12026 Adjust to deprecation of 3-arg generator.throw()
Browse files Browse the repository at this point in the history
In Python 3.12, the 3-arg signature of generator.throw() is
deprecated, you're only supposed to use the 1-arg signature
where you pass only an exception instance. I *think* this is the
right thing to pass in this case.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
  • Loading branch information
AdamWill committed Dec 27, 2023
1 parent 68f112f commit 2280e5f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/twisted/newsfragments/12026.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
twisted.python.failure.Failure now throws exception for generators without triggering a deprecation warnings on Python 3.12.
2 changes: 1 addition & 1 deletion src/twisted/python/failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def throwExceptionIntoGenerator(self, g):
"""
# Note that the actual magic to find the traceback information
# is done in _findFailure.
return g.throw(self.type, self.value, self.tb)
return g.throw(self.value.with_traceback(self.tb))

@classmethod
def _findFailure(cls):
Expand Down

0 comments on commit 2280e5f

Please sign in to comment.