Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes from compiling with warnings #17

Open
wants to merge 9 commits into
base: graal-team/hpy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/core/include/numpy/ndarraytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ typedef struct PyArrayFlagsObject {
int flags;
} PyArrayFlagsObject;

HPyType_HELPERS(PyArrayFlagsObject);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know from the top of your head if PyArrayFlagsObject still needs to be legacy? It looks like it could be a pure HPy type but we just forgot to remove PyObject_HEAD.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't know. We could check it in a follow-up PR

HPyType_LEGACY_HELPERS(PyArrayFlagsObject);

/* Mirrors buffer object to ptr */

Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/common/npy_hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ PyArrayIdentityHash_SetItem(PyArrayIdentityHash *tb, PyObject *cache_owner,


NPY_NO_EXPORT PyObject *
PyArrayIdentityHash_GetItem(PyObject *cache_owner, PyArrayIdentityHash const *tb, PyObject *const *key)
PyArrayIdentityHash_GetItem(PyArrayIdentityHash const *tb, PyObject *cache_owner, PyObject *const *key)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong? The argument order should be the same as PyArrayIdentityHash_SetItem

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, makes sense. Seems that I was just not consistent in adding the cache_owner argument.

{
HPyContext *ctx = npy_get_context();
HPy h_cache_owner = HPy_FromPyObject(ctx, cache_owner);
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/src/common/npy_hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ PyArrayIdentityHash_SetItem(PyArrayIdentityHash *tb, PyObject *cache_owner,
PyObject *const *key, PyObject *value, int replace);

NPY_NO_EXPORT PyObject *
PyArrayIdentityHash_GetItem(PyObject *cache_owner,
PyArrayIdentityHash const *tb, PyObject *const *key);
PyArrayIdentityHash_GetItem(PyArrayIdentityHash const *tb, PyObject *cache_owner,
PyObject *const *key);

NPY_NO_EXPORT PyArrayIdentityHash *
PyArrayIdentityHash_New(int key_len);
Expand Down
3 changes: 3 additions & 0 deletions numpy/core/src/multiarray/abstractdtypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,21 @@ NPY_NO_EXPORT HPyType_Spec HPyArray_PyIntAbstractDType_spec = {
.name = "numpy._IntegerAbstractDType",
.basicsize = sizeof(PyArray_Descr),
.flags = Py_TPFLAGS_DEFAULT,
.builtin_shape = HPyType_BuiltinShape_Legacy

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a HPyType(_LEGACY)_HELPERS(PyArray_Descr), we should use SHAPE(PyArray_Descr) here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but as far as I can tell there is no such use of the HEPLERS.

};

NPY_NO_EXPORT HPyType_Spec HPyArray_PyFloatAbstractDType_spec = {
.name = "numpy._FloatAbstractDType",
.basicsize = sizeof(PyArray_Descr),
.flags = HPy_TPFLAGS_DEFAULT,
.builtin_shape = HPyType_BuiltinShape_Legacy
};

NPY_NO_EXPORT HPyType_Spec HPyArray_PyComplexAbstractDType_spec = {
.name = "numpy._ComplexAbstractDType",
.basicsize = sizeof(PyArray_Descr),
.flags = HPy_TPFLAGS_DEFAULT,
.builtin_shape = HPyType_BuiltinShape_Legacy
};

// "forward" declarations:
Expand Down
1 change: 1 addition & 0 deletions numpy/core/src/multiarray/array_method.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,4 +1154,5 @@ NPY_NO_EXPORT HPyType_Spec PyBoundArrayMethod_Type_Spec = {
.basicsize = sizeof(PyBoundArrayMethodObject),
.flags = HPy_TPFLAGS_DEFAULT,
.defines = boundarraymethod_defines,
.builtin_shape = SHAPE(PyBoundArrayMethodObject),
};
3 changes: 2 additions & 1 deletion numpy/core/src/multiarray/array_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,13 @@ HPyType_LEGACY_HELPERS(PyArrayMethodObject)
* on the `ArrayMethod` itself.
*/
typedef struct {
PyObject_HEAD
HPyField *dtypes; /* PyArray_DTypeMeta **dtypes */
HPyField method; /* PyArrayMethodObject *method */
int nargs; /* method->nin + method->nout */
} PyBoundArrayMethodObject;

HPyType_HELPERS(PyBoundArrayMethodObject)
HPyType_LEGACY_HELPERS(PyBoundArrayMethodObject)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this had to become a legacy type so that someone could call HPy_AsPyObject on it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 good point. I don't think we ever specified that.
It is not required on CPython because any object is a PyObject anyway. So, it is always possible to convert.
It is not required for GraalPy because we would return a wrapper that emulates the PyObject.
Is it required for PyPy? If so, we should discuss that and maybe properly specify (and enforce spec in debug mode).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyPy works around it but it would be more efficient if the HELPER was correct.



extern NPY_NO_EXPORT PyTypeObject *PyArrayMethod_Type;
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/arraytypes.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ static NPY_INLINE npy_longdouble
hpy_string_to_long_double(HPyContext *ctx, HPy op)
{
const char *s;
const char *end;
char *end;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this caused many warnings, so either my change or all the uses of end must be const char

npy_longdouble temp;
HPy b;

Expand Down
4 changes: 2 additions & 2 deletions numpy/core/src/multiarray/ctors.c
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ HPyArray_FromAny(HPyContext *ctx, HPy op, HPy newtype, int min_depth,
}

// TODO HPY LABS PORT
PyArrayObject *py_ret = HPy_AsPyObject(ctx, ret);
PyArrayObject *py_ret = (PyArrayObject *)HPy_AsPyObject(ctx, ret);
PyObject *py_op = HPy_AsPyObject(ctx, op);
if (setArrayFromSequence(py_ret, py_op, 0, NULL) < 0) {
Py_DECREF(py_ret);
Expand Down Expand Up @@ -4986,7 +4986,7 @@ HPyArray_ArangeObj(HPyContext *ctx, HPy start, HPy stop, HPy step, HPy /* PyArra
PyObject *new;
PyObject *py_range = HPy_AsPyObject(ctx, range);
CAPI_WARN("calling PyArray_Byteswap");
new = PyArray_Byteswap(py_range, 1);
new = PyArray_Byteswap((PyArrayObject *)py_range, 1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we perhaps do PyArrayObject *py_range = (PyArrayObject *) HPy_AsPyObject(ctx, range) where pyrange is defined?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was has fewer casts, since most places this is used prefer a PyObject*

Py_DECREF(py_range);
Py_DECREF(new);
_hpy_set_descr(ctx, range, range_struct, dtype);
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/datetime_strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ datetime_as_string_impl(HPyContext *ctx, HPy NPY_UNUSED(ignored), const HPy *arg
op_flags[1] = NPY_ITER_WRITEONLY|
NPY_ITER_ALLOCATE;

iter = NpyIter_MultiNew(2, op, flags, NPY_KEEPORDER, NPY_UNSAFE_CASTING,
iter = HNpyIter_MultiNew(ctx, 2, op, flags, NPY_KEEPORDER, NPY_UNSAFE_CASTING,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since op seems to contain handles, calling the new function seems to make sense.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we probably just overlooked that.

op_flags, op_dtypes);
if (iter == NULL) {
goto fail;
Expand Down
10 changes: 5 additions & 5 deletions numpy/core/src/multiarray/descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ _hpy_convert_from_tuple(HPyContext *ctx, HPy obj, int align)
}
newdescr_struct->flags = type_struct->flags;
newdescr_struct->alignment = type_struct->alignment;
newdescr_struct->subarray->base = HPy_AsPyObject(ctx, type);
newdescr_struct->subarray->base = (PyArray_Descr*)HPy_AsPyObject(ctx, type);
HPy_Close(ctx, type);
Py_XDECREF(newdescr_struct->fields);
HPyField_Store(ctx, newdescr, &newdescr_struct->names, HPy_NULL);
Expand Down Expand Up @@ -2230,7 +2230,7 @@ arraydescr_base_get(HPyContext *ctx, HPy /* PyArray_Descr * */ self, void *NPY_U
return HPy_Dup(ctx, self);
}
// Py_INCREF(self->subarray->base);
return HPy_FromPyObject(ctx, self_struct->subarray->base);
return HPy_FromPyObject(ctx, (PyObject*)self_struct->subarray->base);
}

HPyDef_GET(arraydescr_shape, "shape")
Expand Down Expand Up @@ -2585,7 +2585,7 @@ arraydescr_new_impl(HPyContext *ctx, HPy subtype, const HPy *args,
if (!HPyGlobal_Is(ctx, subtype, HPyArrayDescr_Type)) {
HPy subtype_type = HPy_Type(ctx, subtype);
PyArray_DTypeMeta *DType = PyArray_DTypeMeta_AsStruct(ctx, subtype);
PyTypeObject *subtype_typeobj = HPy_AsPyObject(ctx, subtype);
PyTypeObject *subtype_typeobj = (PyTypeObject*)HPy_AsPyObject(ctx, subtype);
if (HPyGlobal_Is(ctx, subtype_type, HPyArrayDTypeMeta_Type) &&
(HNPY_DT_SLOTS(ctx, subtype)) != NULL &&
!NPY_DT_is_legacy(DType) &&
Expand Down Expand Up @@ -3626,10 +3626,10 @@ HPyArray_DescrNewByteorder(HPyContext *ctx, HPy /* PyArray_Descr * */ self, char
Py_DECREF(new_data->subarray->base);
PyArray_Descr *self_data = PyArray_Descr_AsStruct(ctx, self);
CAPI_WARN("using subarray->base");
HPy base = HPy_FromPyObject(ctx, self_data->subarray->base);
HPy base = HPy_FromPyObject(ctx, (PyObject*)(self_data->subarray->base));
HPy byteorder = HPyArray_DescrNewByteorder(ctx, base, newendian);
HPy_Close(ctx, base);
new_data->subarray->base = HPy_AsPyObject(ctx, byteorder);
new_data->subarray->base = (PyArray_Descr*)HPy_AsPyObject(ctx, byteorder);
if (new_data->subarray->base == NULL) {
HPy_Close(ctx, new);
return HPy_NULL;
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/src/multiarray/dlpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ hpy_array_get_dl_device(HPyContext *ctx, HPy /* PyArrayObject * */ self) {
static DLDevice
array_get_dl_device(PyArrayObject *self) {
HPyContext *ctx = npy_get_context();
HPy h_self = HPy_FromPyObject(ctx, self);
HPy h_self = HPy_FromPyObject(ctx, (PyObject *)self);
DLDevice ret = hpy_array_get_dl_device(ctx, h_self);
HPy_Close(ctx, h_self);
return ret;
Expand Down Expand Up @@ -419,7 +419,7 @@ _from_dlpack_impl(HPyContext *ctx, HPy NPY_UNUSED(self), HPy obj) {

HPy new_capsule = HPyCapsule_New(ctx, managed,
NPY_DLPACK_INTERNAL_CAPSULE_NAME,
array_dlpack_internal_capsule_deleter);
(HPyCapsule_Destructor*)array_dlpack_internal_capsule_deleter);
if (HPy_IsNull(new_capsule)) {
HPy_Close(ctx, capsule);
HPy_Close(ctx, ret);
Expand Down
6 changes: 3 additions & 3 deletions numpy/core/src/multiarray/dtype_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2920,7 +2920,7 @@ hpy_get_decref_transfer_function(HPyContext *ctx, int aligned,
}
src_size = PyArray_MultiplyList(src_shape.ptr, src_shape.len);
npy_free_cache_dim_obj(src_shape);
HPy h_base = HPy_FromPyObject(ctx, src_dtype_data->subarray->base);
HPy h_base = HPy_FromPyObject(ctx, (PyObject *)(src_dtype_data->subarray->base));
PyArray_Descr *base_data = src_dtype_data->subarray->base;
if (get_n_to_n_transfer_function(ctx, aligned,
src_stride, 0,
Expand Down Expand Up @@ -3669,13 +3669,13 @@ wrap_aligned_transferfunction(
HPyContext *ctx = npy_get_context();
/* These are always legacy casts that only support native-byte-order: */
// Py_INCREF(src_wrapped_dtype); // HPy_FromPyObject will incref
castdata.main.descriptors[0] = HPy_FromPyObject(ctx, src_wrapped_dtype);
castdata.main.descriptors[0] = HPy_FromPyObject(ctx, (PyObject *)src_wrapped_dtype);
if (HPy_IsNull(castdata.main.descriptors[0])) {
castdata.main.descriptors[1] = HPy_NULL;
goto fail;
}
// Py_INCREF(dst_wrapped_dtype); // HPy_FromPyObject will incref
castdata.main.descriptors[1] = HPy_FromPyObject(ctx, dst_wrapped_dtype);
castdata.main.descriptors[1] = HPy_FromPyObject(ctx, (PyObject *)dst_wrapped_dtype);
if (HPy_IsNull(castdata.main.descriptors[1])) {
goto fail;
}
Expand Down
10 changes: 10 additions & 0 deletions numpy/core/src/multiarray/dtypemeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ legacy_dtype_default_new_impl(HPyContext *ctx, HPy h_self,
return HPyField_Load(ctx, h_self, self->singleton);
}

HPyDef_SLOT(legacy_dtype_tp_traverse, HPy_tp_traverse)
static int legacy_dtype_tp_traverse_impl(void *self_p, HPyFunc_visitproc visit, void *arg) {
PyArray_Descr *self = (PyArray_Descr*) self_p;
if (&self->typeobj)
HPy_VISIT(&self->typeobj);
if (&self->names)
HPy_VISIT(&self->names);
return 0;
}

//static PyArray_Descr *
//nonparametric_discover_descr_from_pyobject(
Expand Down Expand Up @@ -599,6 +608,7 @@ hpy_object_common_dtype(HPyContext *ctx, HPy /* PyArray_DTypeMeta * */ cls,

static HPyDef *new_dtype_legacy_defines[] = {
&legacy_dtype_default_new,
&legacy_dtype_tp_traverse,
NULL
};
static HPyType_Spec New_PyArrayDescr_spec_prototype = {
Expand Down
13 changes: 12 additions & 1 deletion numpy/core/src/multiarray/flagsobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ static int
arrayflags_setitem_impl(HPyContext *ctx, HPy self, HPy ind, HPy item)
{
const char *key;
const char buf[16];
char buf[16];
int n;
if (HPyUnicode_Check(ctx, ind)) {
HPy tmp_str;
Expand Down Expand Up @@ -900,6 +900,15 @@ arrayflags_new_impl(HPyContext *ctx, HPy self, const HPy *args, HPy_ssize_t narg
return HPyArray_NewFlagsObject(ctx, self, arg);
}

HPyDef_SLOT(arrayflags_traverse, HPy_tp_traverse)
static int
arrayflags_traverse_impl(void *self, HPyFunc_visitproc visit, void *arg)
{
PyArrayFlagsObject *flags = (PyArrayFlagsObject *)self;
HPy_VISIT(&flags->arr);
return 0;
}

/*
static PyType_Slot arrayflags_slots[] = {
//{Py_tp_str, arrayflags_print},
Expand Down Expand Up @@ -929,6 +938,7 @@ static HPyDef *arrayflags_defines[] = {
&arrayflags_carray,
&arrayflags_farray,
&arrayflags_num,
&arrayflags_traverse,
NULL
};

Expand All @@ -937,6 +947,7 @@ NPY_NO_EXPORT HPyType_Spec PyArrayFlags_Type_Spec = {
.basicsize = sizeof(PyArrayFlagsObject),
.flags = HPy_TPFLAGS_DEFAULT,
.defines = arrayflags_defines,
.builtin_shape = HPyType_BuiltinShape_Legacy,
};

NPY_NO_EXPORT PyTypeObject *_PyArrayFlags_Type_p;
4 changes: 2 additions & 2 deletions numpy/core/src/multiarray/item_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ _new_sortlike(PyArrayObject *op, int axis, PyArray_SortFunc *sort,
size = it->size;

HPyContext *ctx = npy_get_context();
HPy h_op = HPy_FromPyObject(ctx, op);
HPy h_op = HPy_FromPyObject(ctx, (PyObject *)op);

if (needcopy) {
buffer = PyDataMem_UserNEW(N * elsize, mem_handler);
Expand Down Expand Up @@ -1205,7 +1205,7 @@ _new_sortlike(PyArrayObject *op, int axis, PyArray_SortFunc *sort,
if (needcopy) {
if (hasrefs) {
if (swap) {
HPy h_op = HPy_FromPyObject(ctx, op);
HPy h_op = HPy_FromPyObject(ctx, (PyObject *)op);
copyswapn(ctx, buffer, elsize, NULL, 0, N, swap, h_op);
}
_unaligned_strided_byte_copy(it->dataptr, astride,
Expand Down
18 changes: 11 additions & 7 deletions numpy/core/src/multiarray/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,11 +1414,12 @@ hpy_prepare_index(HPyContext *ctx, HPy h_self, PyArrayObject *self, HPy h_index,
}
}
else if (used_ndim > PyArray_NDIM(self)) {
HPyErr_SetString(ctx, ctx->h_IndexError,
// HPyErr_SetString does not take extra arguments
mattip marked this conversation as resolved.
Show resolved Hide resolved
HPyErr_Format(ctx, ctx->h_IndexError,
"too many indices for array: "
"array is %d-dimensional, but %d were indexed"
/*,PyArray_NDIM(self),
used_ndim*/);
"array is %d-dimensional, but %d were indexed",
PyArray_NDIM(self),
used_ndim);
goto failed_building_indices;
}
else if (index_ndim == 0) {
Expand Down Expand Up @@ -2641,6 +2642,7 @@ NPY_NO_EXPORT int
array_assign_item_slot_impl(HPyContext *ctx, HPy /* PyArrayObject * */ self, HPy_ssize_t i, HPy op)
{
npy_index_info indices[2];
hpy_npy_index_info hpy_indices[2];

if (HPy_IsNull(op)) {
HPyErr_SetString(ctx, ctx->h_ValueError,
Expand All @@ -2664,6 +2666,8 @@ array_assign_item_slot_impl(HPyContext *ctx, HPy /* PyArrayObject * */ self, HPy

indices[0].value = i;
indices[0].type = HAS_INTEGER;
hpy_indices[0].value = i;
hpy_indices[0].type = HAS_INTEGER;
if (PyArray_NDIM(self_struct) == 1) {
char *item;
if (get_item_pointer(self_struct, &item, indices, 1) < 0) {
Expand All @@ -2677,9 +2681,9 @@ array_assign_item_slot_impl(HPyContext *ctx, HPy /* PyArrayObject * */ self, HPy
else {
HPy view; // PyArrayObject *

indices[1].value = PyArray_NDIM(self_struct) - 1;
indices[1].type = HAS_ELLIPSIS;
if (hpy_get_view_from_index(ctx, self, self_struct, &view, indices, 2, 0) < 0) {
hpy_indices[1].value = PyArray_NDIM(self_struct) - 1;
hpy_indices[1].type = HAS_ELLIPSIS;
if (hpy_get_view_from_index(ctx, self, self_struct, &view, hpy_indices, 2, 0) < 0) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to duplicate the indices struct, since there is a call to legacy get_item_pointer for struct dtypes on line 2672 above

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should indices be updated here too since both are being maintained?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Only hpy_indices is being maintained. indices is used only in get_item_pointer in a read-only fashion.

return -1;
}
PyArrayObject *view_struct = PyArrayObject_AsStruct(ctx, view);
Expand Down
8 changes: 4 additions & 4 deletions numpy/core/src/multiarray/multiarraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4226,13 +4226,13 @@ array_einsum_impl(HPyContext *ctx, HPy NPY_UNUSED(dummy), const HPy *args, size_
}
}
CAPI_WARN("calling PyArray_EinsteinSum");
PyArrayObject **py_op_in = HPy_AsPyObjectArray(ctx, op, nop);
PyArray_Descr *py_dtype = HPy_AsPyObject(ctx, dtype);
PyArrayObject *py_out = HPy_AsPyObject(ctx, out);
PyArrayObject **py_op_in = (PyArrayObject **)HPy_AsPyObjectArray(ctx, op, nop);
PyArray_Descr *py_dtype = (PyArray_Descr *)HPy_AsPyObject(ctx, dtype);
PyArrayObject *py_out = (PyArrayObject *)HPy_AsPyObject(ctx, out);
PyObject *py_ret = (PyObject *)PyArray_EinsteinSum(subscripts, nop, py_op_in, py_dtype,
order, casting, py_out);
ret = HPy_FromPyObject(ctx, py_ret);
HPy_DecrefAndFreeArray(ctx, py_op_in, nop);
HPy_DecrefAndFreeArray(ctx, (PyObject**)py_op_in, nop);
Py_XDECREF(py_dtype);
Py_XDECREF(py_out);
Py_XDECREF(py_ret);
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/nditer_pywrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,7 @@ static PyObject *
npyiter_next(NewNpyArrayIterObject *self)
{
HPyContext *ctx = npy_get_context();
HPy h_self = HPy_FromPyObject(ctx, self);
HPy h_self = HPy_FromPyObject(ctx, (PyObject *)self);
HPy h_ret = hpy_npyiter_next(ctx, h_self);
PyObject *ret = HPy_AsPyObject(ctx, h_ret);
HPy_Close(ctx, h_ret);
Expand Down
6 changes: 3 additions & 3 deletions numpy/core/src/multiarray/number.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,11 @@ is_scalar_with_conversion(HPyContext *ctx, HPy h_o2, double* out_exponent)
// NOTE: do partial porting approach, this looked small, but it isn't!
else if (PyArray_IsScalar(o2, Integer) ||
(optimize_fpexps && PyArray_IsScalar(o2, Floating))) {
temp = Py_TYPE(o2)->tp_as_number->nb_float(o2);
temp = Py_TYPE(o2)->tp_as_number->nb_float((PyObject *)o2);
if (temp == NULL) {
return NPY_NOSCALAR;
}
*out_exponent = PyFloat_AsDouble(o2);
*out_exponent = PyFloat_AsDouble((PyObject *)o2);
Py_DECREF(temp);

if (PyArray_IsScalar(o2, Integer)) {
Expand All @@ -520,7 +520,7 @@ is_scalar_with_conversion(HPyContext *ctx, HPy h_o2, double* out_exponent)
}
}
else if (PyIndex_Check((PyObject*) o2)) {
PyObject* value = PyNumber_Index(o2);
PyObject* value = PyNumber_Index((PyObject *)o2);
Py_ssize_t val;
if (value == NULL) {
if (PyErr_Occurred()) {
Expand Down
Loading