@@ -418,7 +418,9 @@ PyDoc_STRVAR(throw_doc,
418
418
throw(type[,value[,tb]])\n\
419
419
\n\
420
420
Raise exception in generator, return next yielded value or raise\n\
421
- StopIteration." );
421
+ StopIteration.\n\
422
+ the (type, val, tb) signature is deprecated, \n\
423
+ and may be removed in a future version of Python." );
422
424
423
425
static PyObject *
424
426
_gen_throw (PyGenObject * gen , int close_on_genexit ,
@@ -559,6 +561,14 @@ gen_throw(PyGenObject *gen, PyObject *const *args, Py_ssize_t nargs)
559
561
if (!_PyArg_CheckPositional ("throw" , nargs , 1 , 3 )) {
560
562
return NULL ;
561
563
}
564
+ if (nargs > 1 ) {
565
+ if (PyErr_WarnEx (PyExc_DeprecationWarning ,
566
+ "the (type, exc, tb) signature of throw() is deprecated, "
567
+ "use the single-arg signature instead." ,
568
+ 1 ) < 0 ) {
569
+ return NULL ;
570
+ }
571
+ }
562
572
typ = args [0 ];
563
573
if (nargs == 3 ) {
564
574
val = args [1 ];
@@ -1147,7 +1157,10 @@ PyDoc_STRVAR(coro_throw_doc,
1147
1157
throw(type[,value[,traceback]])\n\
1148
1158
\n\
1149
1159
Raise exception in coroutine, return next iterated value or raise\n\
1150
- StopIteration." );
1160
+ StopIteration.\n\
1161
+ the (type, val, tb) signature is deprecated, \n\
1162
+ and may be removed in a future version of Python." );
1163
+
1151
1164
1152
1165
PyDoc_STRVAR (coro_close_doc ,
1153
1166
"close() -> raise GeneratorExit inside coroutine." );
@@ -1500,6 +1513,14 @@ async_gen_aclose(PyAsyncGenObject *o, PyObject *arg)
1500
1513
static PyObject *
1501
1514
async_gen_athrow (PyAsyncGenObject * o , PyObject * args )
1502
1515
{
1516
+ if (PyTuple_GET_SIZE (args ) > 1 ) {
1517
+ if (PyErr_WarnEx (PyExc_DeprecationWarning ,
1518
+ "the (type, exc, tb) signature of athrow() is deprecated, "
1519
+ "use the single-arg signature instead." ,
1520
+ 1 ) < 0 ) {
1521
+ return NULL ;
1522
+ }
1523
+ }
1503
1524
if (async_gen_init_hooks (o )) {
1504
1525
return NULL ;
1505
1526
}
@@ -1537,7 +1558,12 @@ PyDoc_STRVAR(async_asend_doc,
1537
1558
"asend(v) -> send 'v' in generator." );
1538
1559
1539
1560
PyDoc_STRVAR (async_athrow_doc ,
1540
- "athrow(typ[,val[,tb]]) -> raise exception in generator." );
1561
+ "athrow(value)\n\
1562
+ athrow(type[,value[,tb]])\n\
1563
+ \n\
1564
+ raise exception in generator.\n\
1565
+ the (type, val, tb) signature is deprecated, \n\
1566
+ and may be removed in a future version of Python." );
1541
1567
1542
1568
static PyMethodDef async_gen_methods [] = {
1543
1569
{"asend" , (PyCFunction )async_gen_asend , METH_O , async_asend_doc },
0 commit comments