Skip to content

Commit 43080cc

Browse files
committed
Check ufunc's dict on creation
1 parent 058ea0f commit 43080cc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

numpy/_core/src/umath/ufunc_object.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4687,6 +4687,7 @@ PyUFunc_FromFuncAndDataAndSignatureAndIdentity(PyUFuncGenericFunction *func, voi
46874687
ufunc->core_signature = NULL;
46884688
ufunc->core_enabled = 0;
46894689
ufunc->obj = NULL;
4690+
ufunc->dict = NULL;
46904691
ufunc->core_num_dims = NULL;
46914692
ufunc->core_num_dim_ix = 0;
46924693
ufunc->core_offsets = NULL;
@@ -4772,6 +4773,10 @@ PyUFunc_FromFuncAndDataAndSignatureAndIdentity(PyUFuncGenericFunction *func, voi
47724773
}
47734774
}
47744775
ufunc->dict = PyDict_New();
4776+
if (ufunc->dict == NULL) {
4777+
Py_DECREF(ufunc);
4778+
return NULL;
4779+
}
47754780
/*
47764781
* TODO: I tried adding a default promoter here (either all object for
47774782
* some special cases, or all homogeneous). Those are reasonable
@@ -5199,7 +5204,7 @@ ufunc_traverse(PyUFuncObject *self, visitproc visit, void *arg)
51995204
if (self->identity == PyUFunc_IdentityValue) {
52005205
Py_VISIT(self->identity_value);
52015206
}
5202-
Py_VISIT(self->dict);
5207+
//Py_VISIT(self->dict);
52035208
return 0;
52045209
}
52055210

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy