Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Side by Side Diff: Modules/audioop.c

Issue 28261: wrong error messages when using PyArg_ParseTuple to parse normal tuples
Patch Set: Created 3 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Modules/_ctypes/_ctypes.c » ('j') | Modules/_ctypes/_ctypes.c » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* audioopmodule - Module to detect peak values in arrays */ 2 /* audioopmodule - Module to detect peak values in arrays */
3 3
4 #define PY_SSIZE_T_CLEAN 4 #define PY_SSIZE_T_CLEAN
5 5
6 #include "Python.h" 6 #include "Python.h"
7 7
8 #if defined(__CHAR_UNSIGNED__) 8 #if defined(__CHAR_UNSIGNED__)
9 #if defined(signed) 9 #if defined(signed)
10 /* This module currently does not work on systems where only unsigned 10 /* This module currently does not work on systems where only unsigned
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 "iO!;audioop.ratecv: illegal state argument", 1358 "iO!;audioop.ratecv: illegal state argument",
1359 &d, &PyTuple_Type, &samps)) 1359 &d, &PyTuple_Type, &samps))
1360 goto exit; 1360 goto exit;
1361 if (PyTuple_Size(samps) != nchannels) { 1361 if (PyTuple_Size(samps) != nchannels) {
1362 PyErr_SetString(AudioopError, 1362 PyErr_SetString(AudioopError,
1363 "illegal state argument"); 1363 "illegal state argument");
1364 goto exit; 1364 goto exit;
1365 } 1365 }
1366 for (chan = 0; chan < nchannels; chan++) { 1366 for (chan = 0; chan < nchannels; chan++) {
1367 if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan), 1367 if (!PyArg_ParseTuple(PyTuple_GetItem(samps, chan),
1368 "ii:ratecv", &prev_i[chan], 1368 "ii;audioop.ratecv: illegal state argument",
storchaka 2017/03/03 08:34:36 Seems other error messages don't contain the name
Oren Milman 2017/08/16 16:09:26 I agree.
1369 &cur_i[chan])) 1369 &prev_i[chan], &cur_i[chan])) {
1370 goto exit; 1370 goto exit;
1371 }
1371 } 1372 }
1372 } 1373 }
1373 1374
1374 /* str <- Space for the output buffer. */ 1375 /* str <- Space for the output buffer. */
1375 if (len == 0) 1376 if (len == 0)
1376 str = PyBytes_FromStringAndSize(NULL, 0); 1377 str = PyBytes_FromStringAndSize(NULL, 0);
1377 else { 1378 else {
1378 /* There are len input frames, so we need (mathematically) 1379 /* There are len input frames, so we need (mathematically)
1379 ceiling(len*outrate/inrate) output frames, and each frame 1380 ceiling(len*outrate/inrate) output frames, and each frame
1380 requires bytes_per_frame bytes. Computing this 1381 requires bytes_per_frame bytes. Computing this
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 /* Decode state, should have (value, step) */ 1632 /* Decode state, should have (value, step) */
1632 if ( state == Py_None ) { 1633 if ( state == Py_None ) {
1633 /* First time, it seems. Set defaults */ 1634 /* First time, it seems. Set defaults */
1634 valpred = 0; 1635 valpred = 0;
1635 index = 0; 1636 index = 0;
1636 } 1637 }
1637 else if (!PyTuple_Check(state)) { 1638 else if (!PyTuple_Check(state)) {
1638 PyErr_SetString(PyExc_TypeError, "state must be a tuple or None"); 1639 PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
1639 return NULL; 1640 return NULL;
1640 } 1641 }
1641 else if (!PyArg_ParseTuple(state, "ii", &valpred, &index)) { 1642 else if (!PyArg_ParseTuple(state,
1643 "ii;audioop.lin2adpcm: illegal state argument",
1644 &valpred, &index)) {
1642 return NULL; 1645 return NULL;
1643 } 1646 }
1644 else if (valpred >= 0x8000 || valpred < -0x8000 || 1647 else if (valpred >= 0x8000 || valpred < -0x8000 ||
1645 (size_t)index >= Py_ARRAY_LENGTH(stepsizeTable)) { 1648 (size_t)index >= Py_ARRAY_LENGTH(stepsizeTable)) {
1646 PyErr_SetString(PyExc_ValueError, "bad state"); 1649 PyErr_SetString(PyExc_ValueError, "bad state");
1647 return NULL; 1650 return NULL;
1648 } 1651 }
1649 1652
1650 str = PyBytes_FromStringAndSize(NULL, fragment->len/(width*2)); 1653 str = PyBytes_FromStringAndSize(NULL, fragment->len/(width*2));
1651 if (str == NULL) 1654 if (str == NULL)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 /* Decode state, should have (value, step) */ 1762 /* Decode state, should have (value, step) */
1760 if ( state == Py_None ) { 1763 if ( state == Py_None ) {
1761 /* First time, it seems. Set defaults */ 1764 /* First time, it seems. Set defaults */
1762 valpred = 0; 1765 valpred = 0;
1763 index = 0; 1766 index = 0;
1764 } 1767 }
1765 else if (!PyTuple_Check(state)) { 1768 else if (!PyTuple_Check(state)) {
1766 PyErr_SetString(PyExc_TypeError, "state must be a tuple or None"); 1769 PyErr_SetString(PyExc_TypeError, "state must be a tuple or None");
1767 return NULL; 1770 return NULL;
1768 } 1771 }
1769 else if (!PyArg_ParseTuple(state, "ii", &valpred, &index)) { 1772 else if (!PyArg_ParseTuple(state,
1773 "ii;audioop.adpcm2lin: illegal state argument",
1774 &valpred, &index)) {
1770 return NULL; 1775 return NULL;
1771 } 1776 }
1772 else if (valpred >= 0x8000 || valpred < -0x8000 || 1777 else if (valpred >= 0x8000 || valpred < -0x8000 ||
1773 (size_t)index >= Py_ARRAY_LENGTH(stepsizeTable)) { 1778 (size_t)index >= Py_ARRAY_LENGTH(stepsizeTable)) {
1774 PyErr_SetString(PyExc_ValueError, "bad state"); 1779 PyErr_SetString(PyExc_ValueError, "bad state");
1775 return NULL; 1780 return NULL;
1776 } 1781 }
1777 1782
1778 if (fragment->len > (PY_SSIZE_T_MAX/2)/width) { 1783 if (fragment->len > (PY_SSIZE_T_MAX/2)/width) {
1779 PyErr_SetString(PyExc_MemoryError, 1784 PyErr_SetString(PyExc_MemoryError,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 if (m == NULL) 1901 if (m == NULL)
1897 return NULL; 1902 return NULL;
1898 d = PyModule_GetDict(m); 1903 d = PyModule_GetDict(m);
1899 if (d == NULL) 1904 if (d == NULL)
1900 return NULL; 1905 return NULL;
1901 AudioopError = PyErr_NewException("audioop.error", NULL, NULL); 1906 AudioopError = PyErr_NewException("audioop.error", NULL, NULL);
1902 if (AudioopError != NULL) 1907 if (AudioopError != NULL)
1903 PyDict_SetItemString(d,"error",AudioopError); 1908 PyDict_SetItemString(d,"error",AudioopError);
1904 return m; 1909 return m;
1905 } 1910 }
OLDNEW
« no previous file with comments | « no previous file | Modules/_ctypes/_ctypes.c » ('j') | Modules/_ctypes/_ctypes.c » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+