File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1428,6 +1428,12 @@ class PyDenseIntElementsAttribute
14281428 }
14291429};
14301430
1431+ // Check if the python version is less than 3.13. Py_IsFinalizing is a part
1432+ // of stable ABI since 3.13 and before it was available as _Py_IsFinalizing.
1433+ #if PY_VERSION_HEX < 0x030d0000
1434+ #define Py_IsFinalizing _Py_IsFinalizing
1435+ #endif
1436+
14311437class PyDenseResourceElementsAttribute
14321438 : public PyConcreteAttribute<PyDenseResourceElementsAttribute> {
14331439public:
@@ -1474,7 +1480,7 @@ class PyDenseResourceElementsAttribute
14741480 // The userData is a Py_buffer* that the deleter owns.
14751481 auto deleter = [](void *userData, const void *data, size_t size,
14761482 size_t align) {
1477- if (!Py_IsInitialized ())
1483+ if (!Py_IsFinalizing () && ! Py_IsInitialized ())
14781484 Py_Initialize ();
14791485 Py_buffer *ownedView = static_cast <Py_buffer *>(userData);
14801486 nb::gil_scoped_acquire gil;
You can’t perform that action at this time.
0 commit comments