From 20cc5c9c5b48261e5c56a5a2089b8e154f011443 Mon Sep 17 00:00:00 2001 From: icanhasmath Date: Wed, 3 Apr 2024 11:14:02 -0500 Subject: [PATCH] Revert Py_SET_TYPE to earlier implementation https://github.com/python/steering-council/issues/79 --- numpy/core/src/multiarray/_multiarray_tests.c.src | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/numpy/core/src/multiarray/_multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src index 112e2c9aa71a..9dfbdefab22f 100644 --- a/numpy/core/src/multiarray/_multiarray_tests.c.src +++ b/numpy/core/src/multiarray/_multiarray_tests.c.src @@ -659,7 +659,8 @@ create_custom_field_dtype(PyObject *NPY_UNUSED(mod), PyObject *args) * Test that we reject this if the type is not set to something that * we are pretty sure can be safely replaced. */ - Py_SET_TYPE(dtype, scalar_type); + Py_TYPE(dtype) = scalar_type; + dtype->ob_type = scalar_type; } else if (error_path != 0) { PyErr_SetString(PyExc_ValueError, @@ -667,7 +668,8 @@ create_custom_field_dtype(PyObject *NPY_UNUSED(mod), PyObject *args) } if (PyArray_RegisterDataType(dtype) < 0) { /* Fix original type in the error_path == 2 case and delete it */ - Py_SET_TYPE(dtype, original_type); + Py_TYPE(dtype) = original_type; + dtype->ob_type = original_type; Py_DECREF(dtype); return NULL; }