Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions 4 Lib/test/test_audioop.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ def test_ratecv(self):
self.assertEqual(audioop.ratecv(datas[w], w, 1, 8000, 8000, None, 30, 10)[0],
expected[w])

self.assertRaises(TypeError, audioop.ratecv, b'', 1, 1, 8000, 8000, 42)
self.assertRaises(TypeError, audioop.ratecv,
b'', 1, 1, 8000, 8000, (1, (42,)))

def test_reverse(self):
for w in 1, 2, 4:
self.assertEqual(audioop.reverse(b'', w), b'')
Expand Down
14 changes: 12 additions & 2 deletions 14 Modules/audioop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ audioop_ratecv(PyObject *self, PyObject *args)
char *cp, *ncp;
int len, size, nchannels, inrate, outrate, weightA, weightB;
int chan, d, *prev_i, *cur_i, cur_o;
PyObject *state, *samps, *str, *rv = NULL;
PyObject *state, *samps, *str, *rv = NULL, *channel;
int bytes_per_frame;

weightA = 1;
Expand Down Expand Up @@ -1152,6 +1152,10 @@ audioop_ratecv(PyObject *self, PyObject *args)
prev_i[chan] = cur_i[chan] = 0;
}
else {
if (!PyTuple_Check(state)) {
PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
goto exit;
}
if (!PyArg_ParseTuple(state,
"iO!;audioop.ratecv: illegal state argument",
&d, &PyTuple_Type, &samps))
Expand All @@ -1162,7 +1166,13 @@ audioop_ratecv(PyObject *self, PyObject *args)
goto exit;
}
for (chan = 0; chan < nchannels; chan++) {
if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan),
channel = PyTuple_GetItem(samps, chan);
if (!PyTuple_Check(channel)) {
PyErr_SetString(PyExc_TypeError,
"ratecv(): illegal state argument");
goto exit;
}
if (!PyArg_ParseTuple(channel,
"ii:ratecv", &prev_i[chan],
&cur_i[chan]))
goto exit;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.