mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #25659: Change assert to TypeError in from_buffer/_copy()
Based on suggestion by Eryk Sun.
This commit is contained in:
parent
395733d46b
commit
6e723d2d11
3 changed files with 20 additions and 3 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue