Skip to content

Commit b193c80

Browse files
Support compiling with Python 3.13
1 parent 98f96e7 commit b193c80

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

dpctl/_host_task_util.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ DPCTLSyclEventRef async_dec_ref(DPCTLSyclQueueRef QRef,
5858
cgh.depends_on(*(unwrap<sycl::event>(depERefs[ev_id])));
5959
}
6060
cgh.host_task([obj_array_size, obj_vec]() {
61+
const bool initialized = Py_IsInitialized();
62+
#if PY_VERSION_HEX < 0x30d0000
63+
const bool finalizing = _Py_IsFinalizing();
64+
#else
65+
const bool finalizing = Py_IsFinalizing();
66+
#endif
6167
// if the main thread has not finilized the interpreter yet
62-
if (Py_IsInitialized() && !_Py_IsFinalizing()) {
68+
if (initialized && !finalizing) {
6369
PyGILState_STATE gstate;
6470
gstate = PyGILState_Ensure();
6571
for (size_t i = 0; i < obj_array_size; ++i) {

dpctl/apis/include/dpctl4pybind11.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,13 @@ class dpctl_capi
198198
{
199199
void operator()(py::object *p) const
200200
{
201-
bool guard = (Py_IsInitialized() && !_Py_IsFinalizing());
201+
const bool initialized = Py_IsInitialized();
202+
#if PY_VERSION_HEX < 0x30d0000
203+
const bool finilizing = _Py_IsFinalizing();
204+
#else
205+
const bool finilizing = Py_IsFinalizing();
206+
#endif
207+
const bool guard = initialized && !finilizing;
202208

203209
if (guard) {
204210
delete p;

0 commit comments

Comments
 (0)