bpo-28261: Fixed err msgs where PyArg_ParseTuple is used to parse nor… · python/cpython@1d1d3e9 (original) (raw)
`@@ -1293,7 +1293,7 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
`
1293
1293
`char *cp, *ncp;
`
1294
1294
`Py_ssize_t len;
`
1295
1295
`int chan, d, *prev_i, *cur_i, cur_o;
`
1296
``
`-
PyObject *samps, *str, *rv = NULL;
`
``
1296
`+
PyObject *samps, *str, *rv = NULL, *channel;
`
1297
1297
`int bytes_per_frame;
`
1298
1298
``
1299
1299
`if (!audioop_check_size(width))
`
`@@ -1354,8 +1354,12 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
`
1354
1354
`prev_i[chan] = cur_i[chan] = 0;
`
1355
1355
` }
`
1356
1356
`else {
`
``
1357
`+
if (!PyTuple_Check(state)) {
`
``
1358
`+
PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
`
``
1359
`+
goto exit;
`
``
1360
`+
}
`
1357
1361
`if (!PyArg_ParseTuple(state,
`
1358
``
`-
"iO!;audioop.ratecv: illegal state argument",
`
``
1362
`+
"iO!;ratecv(): illegal state argument",
`
1359
1363
`&d, &PyTuple_Type, &samps))
`
1360
1364
` goto exit;
`
1361
1365
`if (PyTuple_Size(samps) != nchannels) {
`
`@@ -1364,10 +1368,18 @@ audioop_ratecv_impl(PyObject *module, Py_buffer *fragment, int width,
`
1364
1368
` goto exit;
`
1365
1369
` }
`
1366
1370
`for (chan = 0; chan < nchannels; chan++) {
`
1367
``
`-
if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan),
`
1368
``
`-
"ii:ratecv", &prev_i[chan],
`
1369
``
`-
&cur_i[chan]))
`
``
1371
`+
channel = PyTuple_GetItem(samps, chan);
`
``
1372
`+
if (!PyTuple_Check(channel)) {
`
``
1373
`+
PyErr_SetString(PyExc_TypeError,
`
``
1374
`+
"ratecv(): illegal state argument");
`
1370
1375
` goto exit;
`
``
1376
`+
}
`
``
1377
`+
if (!PyArg_ParseTuple(channel,
`
``
1378
`+
"ii;ratecv(): illegal state argument",
`
``
1379
`+
&prev_i[chan], &cur_i[chan]))
`
``
1380
`+
{
`
``
1381
`+
goto exit;
`
``
1382
`+
}
`
1371
1383
` }
`
1372
1384
` }
`
1373
1385
``
`@@ -1638,7 +1650,9 @@ audioop_lin2adpcm_impl(PyObject *module, Py_buffer *fragment, int width,
`
1638
1650
`PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
`
1639
1651
`return NULL;
`
1640
1652
` }
`
1641
``
`-
else if (!PyArg_ParseTuple(state, "ii", &valpred, &index)) {
`
``
1653
`+
else if (!PyArg_ParseTuple(state, "ii;lin2adpcm(): illegal state argument",
`
``
1654
`+
&valpred, &index))
`
``
1655
`+
{
`
1642
1656
`return NULL;
`
1643
1657
` }
`
1644
1658
`else if (valpred >= 0x8000 || valpred < -0x8000 ||
`
`@@ -1766,7 +1780,9 @@ audioop_adpcm2lin_impl(PyObject *module, Py_buffer *fragment, int width,
`
1766
1780
`PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
`
1767
1781
`return NULL;
`
1768
1782
` }
`
1769
``
`-
else if (!PyArg_ParseTuple(state, "ii", &valpred, &index)) {
`
``
1783
`+
else if (!PyArg_ParseTuple(state, "ii;adpcm2lin(): illegal state argument",
`
``
1784
`+
&valpred, &index))
`
``
1785
`+
{
`
1770
1786
`return NULL;
`
1771
1787
` }
`
1772
1788
`else if (valpred >= 0x8000 || valpred < -0x8000 ||
`