File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
numpy/_core/src/multiarray Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -4222,6 +4222,7 @@ NPY_NO_EXPORT PyArray_Descr *
4222
4222
PyArray_DescrFromType (int type )
4223
4223
{
4224
4224
PyArray_Descr * ret = NULL ;
4225
+ npy_bool is_stringdtype = (type == NPY_VSTRING || type == NPY_VSTRINGLTR );
4225
4226
4226
4227
if (type < 0 ) {
4227
4228
/*
@@ -4233,7 +4234,7 @@ PyArray_DescrFromType(int type)
4233
4234
*/
4234
4235
ret = NULL ;
4235
4236
}
4236
- else if ( type == NPY_VSTRING || type == NPY_VSTRINGLTR ) {
4237
+ else if ( is_stringdtype ) {
4237
4238
ret = (PyArray_Descr * )new_stringdtype_instance (NULL , 1 );
4238
4239
}
4239
4240
// builtin legacy dtypes
@@ -4280,7 +4281,7 @@ PyArray_DescrFromType(int type)
4280
4281
PyErr_SetString (PyExc_ValueError ,
4281
4282
"Invalid data-type for array" );
4282
4283
}
4283
- else {
4284
+ else if (! is_stringdtype ) {
4284
4285
Py_INCREF (ret );
4285
4286
}
4286
4287
Original file line number Diff line number Diff line change @@ -2025,6 +2025,7 @@ arraydescr_dealloc(PyArray_Descr *self)
2025
2025
{
2026
2026
Py_XDECREF (self -> typeobj );
2027
2027
if (!PyDataType_ISLEGACY (self )) {
2028
+ Py_TYPE (self )-> tp_free ((PyObject * )self );
2028
2029
return ;
2029
2030
}
2030
2031
_PyArray_LegacyDescr * lself = (_PyArray_LegacyDescr * )self ;
You can’t perform that action at this time.
0 commit comments