@@ -4592,7 +4592,7 @@ PyArray_DescrFromType(int type)
4592
4592
NPY_NO_EXPORT int
4593
4593
set_typeinfo (HPyContext * ctx , HPy h_dict )
4594
4594
{
4595
- HPy h_s , h_infodict , h_max , h_min ;
4595
+ HPy h_s , h_infodict , h_max , h_min , h_type ;
4596
4596
int i ;
4597
4597
4598
4598
PyArray_Descr * dtype ;
@@ -4762,14 +4762,16 @@ set_typeinfo(HPyContext *ctx, HPy h_dict)
4762
4762
@minType @ min @Name @ = @min @;
4763
4763
h_max = HPy_BuildValue (ctx , "@cx@" , max @Name @);
4764
4764
h_min = HPy_BuildValue (ctx , "@cn@" , min @Name @);
4765
+ h_type = HPy_FromPyObject (ctx , (PyObject * )& Py @Name @ArrType_Type );
4765
4766
h_s = PyArray_typeinforanged (ctx ,
4766
4767
NPY_ @name @LTR , NPY_ @name @, NPY_BITSOF_ @uname @, _ALIGN (@type @),
4767
4768
h_max ,
4768
4769
h_min ,
4769
- HPy_FromPyObject ( ctx , ( PyObject * ) & Py @ Name @ ArrType_Type )
4770
+ h_type
4770
4771
);
4771
4772
HPy_Close (ctx , h_max );
4772
4773
HPy_Close (ctx , h_min );
4774
+ HPy_Close (ctx , h_type );
4773
4775
@maxClose @ max @Name @);
4774
4776
@minClose @ min @Name @);
4775
4777
if (HPy_IsNull (h_s )) {
@@ -4796,10 +4798,12 @@ set_typeinfo(HPyContext *ctx, HPy h_dict)
4796
4798
* #Name = Half, Float, Double, LongDouble,
4797
4799
* CFloat, CDouble, CLongDouble#
4798
4800
*/
4801
+ h_type = HPy_FromPyObject (ctx , (PyObject * )_Py @Name @ArrType_Type_p );
4799
4802
h_s = PyArray_typeinfo (ctx ,
4800
4803
NPY_ @name @LTR , NPY_ @name @, NPY_BITSOF_ @name @,
4801
- _ALIGN (@type @), HPy_FromPyObject ( ctx , ( PyObject * ) _Py @ Name @ ArrType_Type_p )
4804
+ _ALIGN (@type @), h_type
4802
4805
);
4806
+ HPy_Close (ctx , h_type );
4803
4807
if (HPy_IsNull (h_s )) {
4804
4808
HPy_Close (ctx , h_infodict );
4805
4809
return -1 ;
@@ -4812,12 +4816,13 @@ set_typeinfo(HPyContext *ctx, HPy h_dict)
4812
4816
}
4813
4817
4814
4818
/**end repeat**/
4815
-
4819
+ h_type = HPy_FromPyObject ( ctx , ( PyObject * ) _PyObjectArrType_Type_p );
4816
4820
h_s = PyArray_typeinfo (ctx ,
4817
4821
NPY_OBJECTLTR , NPY_OBJECT , sizeof (PyObject * ) * CHAR_BIT ,
4818
4822
_ALIGN (PyObject * ),
4819
- HPy_FromPyObject ( ctx , ( PyObject * ) _PyObjectArrType_Type_p )
4823
+ h_type
4820
4824
);
4825
+ HPy_Close (ctx , h_type );
4821
4826
if (HPy_IsNull (h_s )) {
4822
4827
HPy_Close (ctx , h_infodict );
4823
4828
return -1 ;
@@ -4828,10 +4833,12 @@ set_typeinfo(HPyContext *ctx, HPy h_dict)
4828
4833
HPy_Close (ctx , h_infodict );
4829
4834
return -1 ;
4830
4835
}
4836
+ h_type = HPy_FromPyObject (ctx , (PyObject * )_PyStringArrType_Type_p );
4831
4837
h_s = PyArray_typeinfo (ctx ,
4832
4838
NPY_STRINGLTR , NPY_STRING , 0 , _ALIGN (char ),
4833
- HPy_FromPyObject ( ctx , ( PyObject * ) _PyStringArrType_Type_p )
4839
+ h_type
4834
4840
);
4841
+ HPy_Close (ctx , h_type );
4835
4842
if (HPy_IsNull (h_s )) {
4836
4843
HPy_Close (ctx , h_infodict );
4837
4844
return -1 ;
@@ -4842,10 +4849,12 @@ set_typeinfo(HPyContext *ctx, HPy h_dict)
4842
4849
HPy_Close (ctx , h_infodict );
4843
4850
return -1 ;
4844
4851
}
4852
+ h_type = HPy_FromPyObject (ctx , (PyObject * )_PyUnicodeArrType_Type_p );
4845
4853
h_s = PyArray_typeinfo (ctx ,
4846
4854
NPY_UNICODELTR , NPY_UNICODE , 0 , _ALIGN (npy_ucs4 ),
4847
- HPy_FromPyObject ( ctx , ( PyObject * ) _PyUnicodeArrType_Type_p )
4855
+ h_type
4848
4856
);
4857
+ HPy_Close (ctx , h_type );
4849
4858
if (HPy_IsNull (h_s )) {
4850
4859
HPy_Close (ctx , h_infodict );
4851
4860
return -1 ;
@@ -4856,10 +4865,12 @@ set_typeinfo(HPyContext *ctx, HPy h_dict)
4856
4865
HPy_Close (ctx , h_infodict );
4857
4866
return -1 ;
4858
4867
}
4868
+ h_type = HPy_FromPyObject (ctx , (PyObject * )_PyVoidArrType_Type_p );
4859
4869
h_s = PyArray_typeinfo (ctx ,
4860
4870
NPY_VOIDLTR , NPY_VOID , 0 , _ALIGN (char ),
4861
- HPy_FromPyObject ( ctx , ( PyObject * ) _PyVoidArrType_Type_p )
4871
+ h_type
4862
4872
);
4873
+ HPy_Close (ctx , h_type );
4863
4874
if (HPy_IsNull (h_s )) {
4864
4875
HPy_Close (ctx , h_infodict );
4865
4876
return -1 ;
@@ -4872,15 +4883,17 @@ set_typeinfo(HPyContext *ctx, HPy h_dict)
4872
4883
}
4873
4884
h_max = HPyLong_FromLong (ctx , NPY_MAX_DATETIME );
4874
4885
h_min = HPyLong_FromLong (ctx , NPY_MIN_DATETIME );
4886
+ h_type = HPy_FromPyObject (ctx , (PyObject * )_PyDatetimeArrType_Type_p );
4875
4887
h_s = PyArray_typeinforanged (ctx ,
4876
4888
NPY_DATETIMELTR , NPY_DATETIME , NPY_BITSOF_DATETIME ,
4877
4889
_ALIGN (npy_datetime ),
4878
4890
h_max ,
4879
4891
h_min ,
4880
- HPy_FromPyObject ( ctx , ( PyObject * ) _PyDatetimeArrType_Type_p )
4892
+ h_type
4881
4893
);
4882
4894
HPy_Close (ctx , h_max );
4883
4895
HPy_Close (ctx , h_min );
4896
+ HPy_Close (ctx , h_type );
4884
4897
if (HPy_IsNull (h_s )) {
4885
4898
HPy_Close (ctx , h_infodict );
4886
4899
return -1 ;
@@ -4893,15 +4906,17 @@ set_typeinfo(HPyContext *ctx, HPy h_dict)
4893
4906
}
4894
4907
h_max = HPyLong_FromLong (ctx , NPY_MAX_TIMEDELTA );
4895
4908
h_min = HPyLong_FromLong (ctx , NPY_MIN_TIMEDELTA );
4909
+ h_type = HPy_FromPyObject (ctx , (PyObject * )_PyTimedeltaArrType_Type_p );
4896
4910
h_s = PyArray_typeinforanged (ctx ,
4897
4911
NPY_TIMEDELTALTR , NPY_TIMEDELTA , NPY_BITSOF_TIMEDELTA ,
4898
4912
_ALIGN (npy_timedelta ),
4899
4913
h_max ,
4900
4914
h_min ,
4901
- HPy_FromPyObject ( ctx , ( PyObject * ) _PyTimedeltaArrType_Type_p )
4915
+ h_type
4902
4916
);
4903
4917
HPy_Close (ctx , h_max );
4904
4918
HPy_Close (ctx , h_min );
4919
+ HPy_Close (ctx , h_type );
4905
4920
if (HPy_IsNull (h_s )) {
4906
4921
HPy_Close (ctx , h_infodict );
4907
4922
return -1 ;
@@ -4915,11 +4930,14 @@ set_typeinfo(HPyContext *ctx, HPy h_dict)
4915
4930
4916
4931
#define SETTYPE (name ) \
4917
4932
Py_INCREF(&Py##name##ArrType_Type); \
4933
+ h_type = HPy_FromPyObject(ctx, (PyObject *)&Py##name##ArrType_Type); \
4918
4934
if (HPy_SetItem_s(ctx, h_infodict, #name, \
4919
- HPy_FromPyObject(ctx, (PyObject *)&Py##name##ArrType_Type) ) < 0) { \
4935
+ h_type ) < 0) { \
4920
4936
HPy_Close(ctx, h_infodict); \
4937
+ HPy_Close(ctx, h_type); \
4921
4938
return -1; \
4922
- }
4939
+ } \
4940
+ HPy_Close(ctx, h_type);
4923
4941
4924
4942
SETTYPE (Generic );
4925
4943
SETTYPE (Number );
0 commit comments