-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#12026 Adjust to deprecation of 3-arg generator.throw() #12027
Conversation
gah. stupid comment cleanup. just a sec. |
2b83240
to
7f8e34b
Compare
#12028 is an alternative that just suppresses the warning. |
oh, note I think this is the right thing to pass, but possibly it should just be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes looks good.
There were some CI failures, but I don't think they are related.
Retrying the CI.
It would be nice to have an automated test, to make sure we don't regress.
Thanks for the PR.
@@ -0,0 +1 @@ | |||
adjust generator `throw()` call to avoid triggering deprecation warnings on Python 3.12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like this ?
adjust generator `throw()` call to avoid triggering deprecation warnings on Python 3.12 | |
twisted.python.failure.Failure now throws exception for generators without triggering a deprecation warnings on Python 3.12. |
@@ -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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were already using this code in CI with Python 3.12
I guess that the warning was raised, but there was no check for it.
It would be nice to have an explicit test that no warnings are raised, on any Python version.
well, I'm not an expert on twisted, just a distro guy who noticed this problem, so I don't know for sure how extensive the test suite is. if you're happy with the test suite's coverage, then I guess this one should be fine. |
The suite is unfortunately kinda hit-and-miss in some areas, but in core abstractions like Given how close to the core this change is, it might not be amiss to ping the mailing list and see if anyone could run their own test suites, just to be sure we haven't missed something before the next release. But that's really just belt-and-suspenders checking. |
Email sent https://mail.python.org/archives/list/twisted@python.org/thread/MJFZT7AC4CTA54U5KNSWP2CZQDBIFQZK/ We can wait 1 week and after that we can merge this. Thanks Adam and Glyph for your feedback |
I didn't see any complaints, shall we merge? |
My only minor complain about the merge is the text if the release notes. |
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>
7f8e34b
to
2280e5f
Compare
Rebased and updated the changelog text as requested by @adiroiban . |
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.
Scope and purpose
Fixes #12026 (use of a deprecated form of
generator.throw()
causes deprecation warnings on Python 3.12). Note we are not totally sure yet whether this is safe on Python 3.8: see here.Contributor Checklist: (done)