@@ -990,6 +990,7 @@ PyCPointerType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
990990 if (proto ) {
991991 StgDictObject * itemdict = PyType_stgdict (proto );
992992 const char * current_format ;
993+ /* PyCPointerType_SetProto has verified proto has a stgdict. */
993994 assert (itemdict );
994995 /* If itemdict->format is NULL, then this is a pointer to an
995996 incomplete type. We create a generic format string
@@ -1036,7 +1037,11 @@ PyCPointerType_set_type(PyTypeObject *self, PyObject *type)
10361037 StgDictObject * dict ;
10371038
10381039 dict = PyType_stgdict ((PyObject * )self );
1039- assert (dict );
1040+ if (!dict ) {
1041+ PyErr_SetString (PyExc_TypeError ,
1042+ "abstract class" );
1043+ return NULL ;
1044+ }
10401045
10411046 if (-1 == PyCPointerType_SetProto (dict , type ))
10421047 return NULL ;
@@ -1062,7 +1067,11 @@ PyCPointerType_from_param(PyObject *type, PyObject *value)
10621067 }
10631068
10641069 typedict = PyType_stgdict (type );
1065- assert (typedict ); /* Cannot be NULL for pointer types */
1070+ if (!typedict ) {
1071+ PyErr_SetString (PyExc_TypeError ,
1072+ "abstract class" );
1073+ return NULL ;
1074+ }
10661075
10671076 /* If we expect POINTER(<type>), but receive a <type> instance, accept
10681077 it by calling byref(<type>).
@@ -2127,7 +2136,11 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
21272136 }
21282137
21292138 dict = PyType_stgdict (type );
2130- assert (dict );
2139+ if (!dict ) {
2140+ PyErr_SetString (PyExc_TypeError ,
2141+ "abstract class" );
2142+ return NULL ;
2143+ }
21312144
21322145 /* I think we can rely on this being a one-character string */
21332146 fmt = PyUnicode_AsUTF8 (dict -> proto );
@@ -3231,7 +3244,11 @@ _validate_paramflags(PyTypeObject *type, PyObject *paramflags)
32313244 PyObject * argtypes ;
32323245
32333246 dict = PyType_stgdict ((PyObject * )type );
3234- assert (dict ); /* Cannot be NULL. 'type' is a PyCFuncPtr type. */
3247+ if (!dict ) {
3248+ PyErr_SetString (PyExc_TypeError ,
3249+ "abstract class" );
3250+ return 0 ;
3251+ }
32353252 argtypes = dict -> argtypes ;
32363253
32373254 if (paramflags == NULL || dict -> argtypes == NULL )
@@ -4862,7 +4879,7 @@ Pointer_ass_item(PyObject *myself, Py_ssize_t index, PyObject *value)
48624879 }
48634880
48644881 stgdict = PyObject_stgdict ((PyObject * )self );
4865- assert (stgdict ); /* Cannot be NULL fr pointer instances */
4882+ assert (stgdict ); /* Cannot be NULL for pointer instances */
48664883
48674884 proto = stgdict -> proto ;
48684885 assert (proto );
@@ -4890,7 +4907,7 @@ Pointer_get_contents(CDataObject *self, void *closure)
48904907 }
48914908
48924909 stgdict = PyObject_stgdict ((PyObject * )self );
4893- assert (stgdict ); /* Cannot be NULL fr pointer instances */
4910+ assert (stgdict ); /* Cannot be NULL for pointer instances */
48944911 return PyCData_FromBaseObj (stgdict -> proto ,
48954912 (PyObject * )self , 0 ,
48964913 * (void * * )self -> b_ptr );
@@ -4909,7 +4926,7 @@ Pointer_set_contents(CDataObject *self, PyObject *value, void *closure)
49094926 return -1 ;
49104927 }
49114928 stgdict = PyObject_stgdict ((PyObject * )self );
4912- assert (stgdict ); /* Cannot be NULL fr pointer instances */
4929+ assert (stgdict ); /* Cannot be NULL for pointer instances */
49134930 assert (stgdict -> proto );
49144931 if (!CDataObject_Check (value )) {
49154932 int res = PyObject_IsInstance (value , stgdict -> proto );
0 commit comments