@@ -924,6 +924,7 @@ PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
924924 if (proto ) {
925925 StgDictObject * itemdict = PyType_stgdict (proto );
926926 const char * current_format ;
927+ /* PyCPointerType_SetProto has verified proto has a stgdict. */
927928 assert (itemdict );
928929 /* If itemdict->format is NULL, then this is a pointer to an
929930 incomplete type. We create a generic format string
@@ -970,7 +971,11 @@ PyCPointerType_set_type(PyTypeObject *self, PyObject *type)
970971 StgDictObject * dict ;
971972
972973 dict = PyType_stgdict ((PyObject * )self );
973- assert (dict );
974+ if (!dict ) {
975+ PyErr_SetString (PyExc_TypeError ,
976+ "abstract class" );
977+ return NULL ;
978+ }
974979
975980 if (-1 == PyCPointerType_SetProto (dict , type ))
976981 return NULL ;
@@ -995,7 +1000,11 @@ PyCPointerType_from_param(PyObject *type, PyObject *value)
9951000 }
9961001
9971002 typedict = PyType_stgdict (type );
998- assert (typedict ); /* Cannot be NULL for pointer types */
1003+ if (!typedict ) {
1004+ PyErr_SetString (PyExc_TypeError ,
1005+ "abstract class" );
1006+ return NULL ;
1007+ }
9991008
10001009 /* If we expect POINTER(<type>), but receive a <type> instance, accept
10011010 it by calling byref(<type>).
@@ -2057,7 +2066,11 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
20572066 }
20582067
20592068 dict = PyType_stgdict (type );
2060- assert (dict );
2069+ if (!dict ) {
2070+ PyErr_SetString (PyExc_TypeError ,
2071+ "abstract class" );
2072+ return NULL ;
2073+ }
20612074
20622075 /* I think we can rely on this being a one-character string */
20632076 fmt = PyUnicode_AsUTF8 (dict -> proto );
@@ -3146,7 +3159,11 @@ _validate_paramflags(PyTypeObject *type, PyObject *paramflags)
31463159 PyObject * argtypes ;
31473160
31483161 dict = PyType_stgdict ((PyObject * )type );
3149- assert (dict ); /* Cannot be NULL. 'type' is a PyCFuncPtr type. */
3162+ if (!dict ) {
3163+ PyErr_SetString (PyExc_TypeError ,
3164+ "abstract class" );
3165+ return 0 ;
3166+ }
31503167 argtypes = dict -> argtypes ;
31513168
31523169 if (paramflags == NULL || dict -> argtypes == NULL )
@@ -4779,7 +4796,7 @@ Pointer_ass_item(PyObject *myself, Py_ssize_t index, PyObject *value)
47794796 }
47804797
47814798 stgdict = PyObject_stgdict ((PyObject * )self );
4782- assert (stgdict ); /* Cannot be NULL fr pointer instances */
4799+ assert (stgdict ); /* Cannot be NULL for pointer instances */
47834800
47844801 proto = stgdict -> proto ;
47854802 assert (proto );
@@ -4807,7 +4824,7 @@ Pointer_get_contents(CDataObject *self, void *closure)
48074824 }
48084825
48094826 stgdict = PyObject_stgdict ((PyObject * )self );
4810- assert (stgdict ); /* Cannot be NULL fr pointer instances */
4827+ assert (stgdict ); /* Cannot be NULL for pointer instances */
48114828 return PyCData_FromBaseObj (stgdict -> proto ,
48124829 (PyObject * )self , 0 ,
48134830 * (void * * )self -> b_ptr );
@@ -4826,7 +4843,7 @@ Pointer_set_contents(CDataObject *self, PyObject *value, void *closure)
48264843 return -1 ;
48274844 }
48284845 stgdict = PyObject_stgdict ((PyObject * )self );
4829- assert (stgdict ); /* Cannot be NULL fr pointer instances */
4846+ assert (stgdict ); /* Cannot be NULL for pointer instances */
48304847 assert (stgdict -> proto );
48314848 if (!CDataObject_Check (value )) {
48324849 int res = PyObject_IsInstance (value , stgdict -> proto );
0 commit comments