summaryrefslogtreecommitdiff
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-11-20 09:35:06 +0000
committerMartin Panter <vadmium+py@gmail.com>2016-11-20 09:35:06 +0000
commitfd08fdc7bea38eeecf4838999114d6b490794ad6 (patch)
treec5b3c61597b1111e7c28442892c8a816f65d6c04 /Modules/_ctypes
parentf75a2ebbac3ab4a93856452d5ad843f7d50daaba (diff)
downloadcpython-git-fd08fdc7bea38eeecf4838999114d6b490794ad6.tar.gz
Issue #25659: Change assert to TypeError in from_buffer/_copy()
Based on suggestion by Eryk Sun.
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/_ctypes.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 5b4ac47a3b..f301b13858 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -501,7 +501,10 @@ CDataType_from_buffer(PyObject *type, PyObject *args)
Py_ssize_t offset = 0;
PyObject *obj, *result;
StgDictObject *dict = PyType_stgdict(type);
- assert (dict);
+ if (!dict) {
+ PyErr_SetString(PyExc_TypeError, "abstract class");
+ return NULL;
+ }
if (!PyArg_ParseTuple(args,
#if (PY_VERSION_HEX < 0x02050000)
@@ -557,13 +560,16 @@ CDataType_from_buffer_copy(PyObject *type, PyObject *args)
Py_ssize_t offset = 0;
PyObject *obj, *result;
StgDictObject *dict = PyType_stgdict(type);
- assert (dict);
+ if (!dict) {
+ PyErr_SetString(PyExc_TypeError, "abstract class");
+ return NULL;
+ }
if (!PyArg_ParseTuple(args,
#if (PY_VERSION_HEX < 0x02050000)
- "O|i:from_buffer",
+ "O|i:from_buffer_copy",
#else
- "O|n:from_buffer",
+ "O|n:from_buffer_copy",
#endif
&obj, &offset))
return NULL;