Skip to content
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

gh-96348: Deprecate the 3-arg signature of coroutine.throw, generator.throw and agen.athrow #96428

Merged
merged 30 commits into from
Sep 30, 2022
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b388f9a
feat: Deprecate gen.throw(typ, val, tb)
ofey404 Aug 30, 2022
713d77a
Update Objects/genobject.c
ofey404 Aug 31, 2022
fcfb65e
fix clear cases
ofey404 Sep 1, 2022
073aa62
Update Misc/NEWS.d/next/Core and Builtins/2022-08-31-18-46-13.gh-issu…
ofey404 Sep 3, 2022
1c6ed30
Filter remaining warnings.
ofey404 Sep 3, 2022
4881855
Add deprecated info in documentation.
ofey404 Sep 6, 2022
0158816
Use versionchanged instead of deprecated.
ofey404 Sep 7, 2022
8152b7c
Update Doc/reference/expressions.rst
ofey404 Sep 9, 2022
670d8f8
more docs and what's new entry
ofey404 Sep 9, 2022
0c20b35
Edit what's new.
ofey404 Sep 10, 2022
ba9a87c
Update Objects/genobject.c
ofey404 Sep 13, 2022
7f1dd7f
Update Objects/genobject.c
ofey404 Sep 13, 2022
0b16455
Update Lib/test/test_generators.py
ofey404 Sep 13, 2022
e204cc6
Update Objects/genobject.c
ofey404 Sep 13, 2022
0873dc3
Reversed agen.athrow() documentation, and what's new with method link.
ofey404 Sep 20, 2022
4a1539c
Apply suggestions from code review
ofey404 Sep 22, 2022
85b67cb
Add DeprecationWarning, doc and what's new to agen.athrow
ofey404 Sep 22, 2022
22bb65b
Update acks, and doc of anextawaitable_throw
ofey404 Sep 22, 2022
7b786e4
Add test_async_gen_3_arg_deprecation_warning.
ofey404 Sep 24, 2022
198645a
Apply formatting suggestions from code review
ofey404 Sep 25, 2022
528031c
patchcheck.py passed
ofey404 Sep 25, 2022
53c74db
Merge branch 'main' into ofey404/deprecate-get-throw
ofey404 Sep 25, 2022
93db966
Update Misc/NEWS.d/next/Core and Builtins/2022-08-31-18-46-13.gh-issu…
ofey404 Sep 25, 2022
0e56eb9
assert that deprecation warning is emitted
iritkatriel Sep 25, 2022
8738273
stage, exploring how to capture deprecation warning rather than supre…
ofey404 Sep 28, 2022
31b2e9f
Revert "stage, exploring how to capture deprecation warning rather th…
ofey404 Sep 28, 2022
8b701d6
Merge pull request #6 from iritkatriel/pr96428
ofey404 Sep 28, 2022
70e1f28
Merge branch 'main' into ofey404/deprecate-get-throw
iritkatriel Sep 28, 2022
ed2e83a
fix test
iritkatriel Sep 28, 2022
03fc6e0
Add a warning in FutureIter_throw
ofey404 Sep 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ PyDoc_STRVAR(throw_doc,
throw(type[,value[,tb]])\n\
\n\
Raise exception in generator, return next yielded value or raise\n\
StopIteration.");
StopIteration.\n\
the (type, val, tb) exception representation is deprecated, \n\
ofey404 marked this conversation as resolved.
Show resolved Hide resolved
and may be removed in a future version of Python.");
iritkatriel marked this conversation as resolved.
Show resolved Hide resolved

static PyObject *
_gen_throw(PyGenObject *gen, int close_on_genexit,
Expand Down Expand Up @@ -559,6 +561,14 @@ gen_throw(PyGenObject *gen, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("throw", nargs, 1, 3)) {
return NULL;
}
if (nargs > 1) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"the (type, val, tb) exception representation"
"is deprecated, and may be removed in a future version of Python.",
ofey404 marked this conversation as resolved.
Show resolved Hide resolved
1) < 0) {
return NULL;
}
}
typ = args[0];
if (nargs == 3) {
val = args[1];
Expand Down Expand Up @@ -1147,7 +1157,10 @@ PyDoc_STRVAR(coro_throw_doc,
throw(type[,value[,traceback]])\n\
\n\
Raise exception in coroutine, return next iterated value or raise\n\
StopIteration.");
StopIteration.\n\
the (type, val, tb) exception representation is deprecated, \n\
ofey404 marked this conversation as resolved.
Show resolved Hide resolved
and may be removed in a future version of Python.");


PyDoc_STRVAR(coro_close_doc,
"close() -> raise GeneratorExit inside coroutine.");
Expand Down