@@ -10,19 +10,20 @@ PyObject *NA_OBJ = NULL;
10
10
/*
11
11
* Internal helper to create new instances
12
12
*/
13
- StringDTypeObject *
14
- new_stringdtype_instance (void )
13
+ PyObject *
14
+ new_stringdtype_instance (PyTypeObject * cls )
15
15
{
16
- StringDTypeObject * new = (StringDTypeObject * )PyArrayDescr_Type .tp_new (
17
- (PyTypeObject * )& StringDType , NULL , NULL );
16
+ PyObject * new = PyArrayDescr_Type .tp_new ((PyTypeObject * )cls , NULL , NULL );
18
17
if (new == NULL ) {
19
18
return NULL ;
20
19
}
21
- new -> base .elsize = sizeof (ss );
22
- new -> base .alignment = _Alignof(ss );
23
- new -> base .flags |= NPY_NEEDS_INIT ;
24
- new -> base .flags |= NPY_LIST_PICKLE ;
25
- new -> base .flags |= NPY_ITEM_REFCOUNT ;
20
+
21
+ PyArray_Descr * base = & ((StringDTypeObject * )new )-> base ;
22
+ base -> elsize = sizeof (ss );
23
+ base -> alignment = _Alignof(ss );
24
+ base -> flags |= NPY_NEEDS_INIT ;
25
+ base -> flags |= NPY_LIST_PICKLE ;
26
+ base -> flags |= NPY_ITEM_REFCOUNT ;
26
27
27
28
return new ;
28
29
}
@@ -63,16 +64,15 @@ common_dtype(PyArray_DTypeMeta *cls, PyArray_DTypeMeta *other)
63
64
// For a given python object, this function returns a borrowed reference
64
65
// to the dtype property of the array
65
66
static PyArray_Descr *
66
- string_discover_descriptor_from_pyobject (PyArray_DTypeMeta * NPY_UNUSED (cls ),
67
- PyObject * obj )
67
+ string_discover_descriptor_from_pyobject (PyTypeObject * cls , PyObject * obj )
68
68
{
69
69
if (Py_TYPE (obj ) != StringScalar_Type ) {
70
70
PyErr_SetString (PyExc_TypeError ,
71
71
"Can only store StringScalar in a StringDType array." );
72
72
return NULL ;
73
73
}
74
74
75
- PyArray_Descr * ret = (PyArray_Descr * )new_stringdtype_instance ();
75
+ PyArray_Descr * ret = (PyArray_Descr * )new_stringdtype_instance (cls );
76
76
if (ret == NULL ) {
77
77
return NULL ;
78
78
}
@@ -354,7 +354,7 @@ static PyType_Slot StringDType_Slots[] = {
354
354
{0 , NULL }};
355
355
356
356
static PyObject *
357
- stringdtype_new (PyTypeObject * NPY_UNUSED ( cls ) , PyObject * args , PyObject * kwds )
357
+ stringdtype_new (PyTypeObject * cls , PyObject * args , PyObject * kwds )
358
358
{
359
359
static char * kwargs_strs [] = {"size" , NULL };
360
360
@@ -365,7 +365,7 @@ stringdtype_new(PyTypeObject *NPY_UNUSED(cls), PyObject *args, PyObject *kwds)
365
365
return NULL ;
366
366
}
367
367
368
- PyObject * ret = ( PyObject * ) new_stringdtype_instance ();
368
+ PyObject * ret = new_stringdtype_instance (cls );
369
369
370
370
return ret ;
371
371
}
@@ -494,7 +494,6 @@ init_string_dtype(void)
494
494
PyArrayMethod_Spec * * casts = get_casts ();
495
495
496
496
PyArrayDTypeMeta_Spec StringDType_DTypeSpec = {
497
- .flags = NPY_DT_PARAMETRIC ,
498
497
.typeobj = StringScalar_Type ,
499
498
.slots = StringDType_Slots ,
500
499
.casts = casts ,
0 commit comments