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

BUG: Fix refcounting errors found using pytest-leaks #22832

Merged
merged 1 commit into from Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions numpy/core/src/multiarray/convert.c
Expand Up @@ -393,6 +393,9 @@ PyArray_FillWithScalar(PyArrayObject *arr, PyObject *obj)
PyArray_BYTES(arr), PyArray_STRIDES(arr),
descr, value);

if (PyDataType_REFCHK(descr)) {
PyArray_Item_XDECREF(value, descr);
}
PyMem_FREE(value_buffer_heap);
return retcode;
}
Expand Down
3 changes: 0 additions & 3 deletions numpy/core/src/umath/ufunc_object.c
Expand Up @@ -6456,7 +6456,6 @@ py_resolve_dtypes_generic(PyUFuncObject *ufunc, npy_bool return_context,
/* Explicitly allow int, float, and complex for the "weak" types. */
else if (descr_obj == (PyObject *)&PyLong_Type) {
descr = PyArray_DescrFromType(NPY_LONG);
Py_INCREF(descr);
dummy_arrays[i] = (PyArrayObject *)PyArray_Empty(0, NULL, descr, 0);
if (dummy_arrays[i] == NULL) {
goto finish;
Expand All @@ -6468,7 +6467,6 @@ py_resolve_dtypes_generic(PyUFuncObject *ufunc, npy_bool return_context,
}
else if (descr_obj == (PyObject *)&PyFloat_Type) {
descr = PyArray_DescrFromType(NPY_DOUBLE);
Py_INCREF(descr);
dummy_arrays[i] = (PyArrayObject *)PyArray_Empty(0, NULL, descr, 0);
if (dummy_arrays[i] == NULL) {
goto finish;
Expand All @@ -6480,7 +6478,6 @@ py_resolve_dtypes_generic(PyUFuncObject *ufunc, npy_bool return_context,
}
else if (descr_obj == (PyObject *)&PyComplex_Type) {
descr = PyArray_DescrFromType(NPY_CDOUBLE);
Py_INCREF(descr);
dummy_arrays[i] = (PyArrayObject *)PyArray_Empty(0, NULL, descr, 0);
if (dummy_arrays[i] == NULL) {
goto finish;
Expand Down