Skip to content

Commit c8116a9

Browse files
committed
Use if constexpr for a few PY_VERSION_HEX checks
These don't need to be preprocessor directives.
1 parent 95846d0 commit c8116a9

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

cinderx/Jit/generators_core.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ PyObject* JitCoro_GetAwaitableIter(PyObject* o) {
9292
return res;
9393
}
9494

95-
PyErr_Format(
96-
PyExc_TypeError,
97-
#if PY_VERSION_HEX >= 0x030E0000
98-
"'%.100s' object can't be awaited",
99-
#else
100-
"object %.100s can't be used in 'await' expression",
101-
#endif
102-
ot->tp_name);
95+
if constexpr (PY_VERSION_HEX >= 0x030E0000) {
96+
PyErr_Format(PyExc_TypeError, "'%.100s' object can't be awaited", ot->tp_name);
97+
} else {
98+
PyErr_Format(
99+
PyExc_TypeError,
100+
"object %.100s can't be used in 'await' expression",
101+
ot->tp_name);
102+
}
103103
return nullptr;
104104
}
105105
}

cinderx/Jit/jit_rt.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,9 @@ JITRT_LoadGlobal(PyObject* globals, PyObject* builtins, PyObject* name) {
912912
name);
913913
}
914914
// PyDict_LoadGlobal returns a new reference on 3.14+
915-
#if PY_VERSION_HEX < 0x030E0000
916-
Py_XINCREF(result);
917-
#endif
915+
if constexpr (PY_VERSION_HEX < 0x030E0000) {
916+
Py_XINCREF(result);
917+
}
918918
return result;
919919
}
920920

0 commit comments

Comments
 (0)