diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-11-20 07:58:35 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-11-20 07:58:35 (GMT) |
commit | 6e723d2d11c9a154c301a231788981a9b087aec5 (patch) | |
tree | 614e436f74dcc758e47d9084b23608e453c582ba /Modules | |
parent | 395733d46bbc23d2f559eba4e5f75783f9bca6f1 (diff) | |
download | cpython-6e723d2d11c9a154c301a231788981a9b087aec5.zip cpython-6e723d2d11c9a154c301a231788981a9b087aec5.tar.gz cpython-6e723d2d11c9a154c301a231788981a9b087aec5.tar.bz2 |
Issue #25659: Change assert to TypeError in from_buffer/_copy()
Based on suggestion by Eryk Sun.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 2f3495e..b32a0ce 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -469,7 +469,10 @@ CDataType_from_buffer(PyObject *type, PyObject *args) Py_ssize_t offset = 0; StgDictObject *dict = PyType_stgdict(type); - assert (dict); + if (!dict) { + PyErr_SetString(PyExc_TypeError, "abstract class"); + return NULL; + } if (!PyArg_ParseTuple(args, "O|n:from_buffer", &obj, &offset)) return NULL; @@ -537,9 +540,12 @@ CDataType_from_buffer_copy(PyObject *type, PyObject *args) Py_ssize_t offset = 0; PyObject *result; StgDictObject *dict = PyType_stgdict(type); - assert (dict); + if (!dict) { + PyErr_SetString(PyExc_TypeError, "abstract class"); + return NULL; + } - if (!PyArg_ParseTuple(args, "y*|n:from_buffer", &buffer, &offset)) + if (!PyArg_ParseTuple(args, "y*|n:from_buffer_copy", &buffer, &offset)) return NULL; if (offset < 0) { |