diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-11-20 22:17:44 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-11-20 22:17:44 (GMT) |
commit | 7d6e9232b142cd85a683a195f614bc2f09751934 (patch) | |
tree | 96937a5367a436b223b9a2610c7c963760560cd5 /Modules | |
parent | a57890e5ecb164c17b79aa2713758307787eb74b (diff) | |
parent | 04b35753f7a6bcf50f4a3676aca54cc961b93c83 (diff) | |
download | cpython-7d6e9232b142cd85a683a195f614bc2f09751934.zip cpython-7d6e9232b142cd85a683a195f614bc2f09751934.tar.gz cpython-7d6e9232b142cd85a683a195f614bc2f09751934.tar.bz2 |
Issue #25659: Merge ctypes fix from 3.6
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 de1ae3d..0a9201e 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -463,7 +463,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; @@ -531,9 +534,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) { |