Uh oh!
There was an error while loading. Please reload this page.
gh-96348: Deprecate the 3-arg signature of coroutine.throw, generator.throw and agen.athrow - #96428
Conversation
bedevere-bot
commented
Aug 30, 2022
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
ofey404
commented
Aug 30, 2022
There is a problem: raise Eg: Lines 154 to 155 in 22ed523 |
gvanrossum
left a comment
There was a problem hiding this comment.
One nit. Too bad about the failing tests, let's brainstorm what to do about them:
- We could just fix them, replacing
.throw(A, B, C)with.throw(B). - We could add
filterwarnings()calls to the offending tests (I don't recall how to do that but there are probable plenty of examples). - We could report a
SilentDeprecationWarning, then gradually fix the tests, and then later change it into aDeprecationWarning. - We could first fix the tests, in batches, and then land this PR.
Uh oh!
There was an error while loading. Please reload this page.
gvanrossum
commented
Aug 30, 2022
Whoops, there's no such thing. Maybe it once existed, but it doesn't now, so ignore this option. :-) |
ofey404
commented
Aug 31, 2022
Let's estimate the problem size, by finding with regex There are 51 results in 12 files.
I prefer fixing them in this PR, for the fix need to be verified by raising an error. Otherwise the batch fix might miss something.
|
gvanrossum
commented
Aug 31, 2022
Okay, make sure you consider this. Also, some of the hits may be tests for this very feature, those should not be "fixed" but you may have to add a |
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
bedevere-bot
commented
Aug 31, 2022
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
I run However, there are still some 1. Generator's doc testI think we should filter the cpython/Lib/test/test_generators.py Lines 2116 to 2130 in 0cd33e1 2. Lib |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
iritkatriel
commented
Sep 1, 2022
Look at the code in Lib/unittest/case.py. This is part of the assertRaises mechanism. The callable_obj and the args passed to it are defined by the test, so this should be dealt with in the particular test and not here in the test framework. |
iritkatriel
commented
Sep 1, 2022
The test is this one. It's testing the types of the triplet, so we need to keep it and suppress the deprecation warning. |
…e-96348.xzCoTP.rst Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
ofey404
commented
Sep 3, 2022
Okay, handled the remaining warnings. Tested with those scripts: ./python -m test -j16 > test.log; cat test.log | grep "DeprecationWarning: the (type, val, tb) exception representation is deprecated"# Come out with nothing
./python -Werror -m unittest -v test.test_asyncio.test_futures.PyFutureTests.test_future_iter_throw test.test_generators
# OKBesides, should I squash all commits into one, when all the reviews are done? |
gvanrossum
commented
Sep 3, 2022
Don’t squash please! It makes review harder. We will squash upon merge. |
kumaraditya303
left a comment
There was a problem hiding this comment.
This is a significant change, it should be properly documented in 3.12 What's New.
Uh oh!
There was an error while loading. Please reload this page.
…e-96348.xzCoTP.rst Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
…an supress them." This reverts commit 8738273.
assert that deprecation warning is emitted
bedevere-bot
commented
Sep 28, 2022
🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit 8b701d6 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Uh oh!
There was an error while loading. Please reload this page.
iritkatriel
commented
Sep 28, 2022
It seems that my tests exposed some problem - there are 3 versions of futures, and only one of them is emitting the deprecation warning? |
iritkatriel
commented
Sep 28, 2022
Looking at the code, if futures._CFuture is fixed (made to raise the deprecation warning) then that will fix CSubFuture as well. |
iritkatriel
commented
Sep 28, 2022
So I think we need one more deprecation warning from FutureIter_throw in |
ofey404
commented
Sep 29, 2022
The warning is added. But I still feel a little dizzy about it - How do you know that we should add a test in test_futures.py? Is python future implemented by coroutine object or async generator?
|
iritkatriel
commented
Sep 29, 2022
@kumaraditya303 How does it look now? (I'm a little dizzy by now as well). |
kumaraditya303
commented
Sep 30, 2022
You only need to add deprecation warning in cpython/Lib/asyncio/futures.py Lines 290 to 298 in 9a11ed8 |
| .. versionchanged:: 3.12 | ||
| The second signature \(type\[, value\[, traceback\]\]\) is deprecated and |
There was a problem hiding this comment.
For future PRs, not that code should generally be marked up like
The second signature `(type[, value[, traceback]])` is deprecated and
Add an deprecation warning, when
nargs > 1inObjects/genobject.c:gen_throw.gen.throw(typ, val, tb)#96348