@@ -71,8 +71,7 @@ extern "C" PyObject *PyInit__lldb(void);
7171#define LLDB_USE_PYTHON_SET_INTERRUPT 0
7272#else
7373// PyErr_SetInterrupt was introduced in 3.2.
74- #define LLDB_USE_PYTHON_SET_INTERRUPT \
75- (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2 ) || (PY_MAJOR_VERSION > 3 )
74+ #define LLDB_USE_PYTHON_SET_INTERRUPT PY_VERSION_HEX >= 0x03020000
7675#endif
7776
7877static ScriptInterpreterPythonImpl *GetPythonInterpreter (Debugger &debugger) {
@@ -92,7 +91,7 @@ namespace {
9291struct InitializePythonRAII {
9392public:
9493 InitializePythonRAII () {
95- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8) || (PY_MAJOR_VERSION > 3)
94+ #if PY_VERSION_HEX >= 0x03080000
9695 PyConfig config;
9796 PyConfig_InitPythonConfig (&config);
9897#endif
@@ -109,7 +108,7 @@ struct InitializePythonRAII {
109108 return spec.GetPath ();
110109 }();
111110 if (!g_python_home.empty ()) {
112- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8) || (PY_MAJOR_VERSION > 3)
111+ #if PY_VERSION_HEX >= 0x03080000
113112 PyConfig_SetBytesString (&config, &config.home , g_python_home.c_str ());
114113#else
115114 size_t size = 0 ;
@@ -143,7 +142,7 @@ struct InitializePythonRAII {
143142 PyImport_AppendInittab (" _lldb" , LLDBSwigPyInit);
144143 }
145144
146- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8) || (PY_MAJOR_VERSION > 3)
145+ #if PY_VERSION_HEX >= 0x03080000
147146 config.install_signal_handlers = 0 ;
148147 Py_InitializeFromConfig (&config);
149148 PyConfig_Clear (&config);
@@ -152,7 +151,7 @@ struct InitializePythonRAII {
152151// Python < 3.2 and Python >= 3.2 reversed the ordering requirements for
153152// calling `Py_Initialize` and `PyEval_InitThreads`. < 3.2 requires that you
154153// call `PyEval_InitThreads` first, and >= 3.2 requires that you call it last.
155- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 2)
154+ #if PY_VERSION_HEX >= 0x03020000
156155 Py_InitializeEx (0 );
157156 InitializeThreadsPrivate ();
158157#else
@@ -182,15 +181,15 @@ struct InitializePythonRAII {
182181// would always return `true` and `PyGILState_Ensure/Release` flow would be
183182// executed instead of unlocking GIL with `PyEval_SaveThread`. When
184183// an another thread calls `PyGILState_Ensure` it would get stuck in deadlock.
185- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7) || (PY_MAJOR_VERSION > 3)
184+ #if PY_VERSION_HEX >= 0x03070000
186185 // The only case we should go further and acquire the GIL: it is unlocked.
187186 if (PyGILState_Check ())
188187 return ;
189188#endif
190189
191190// `PyEval_ThreadsInitialized` was deprecated in Python 3.9 and removed in
192191// Python 3.13. It has been returning `true` always since Python 3.7.
193- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
192+ #if PY_VERSION_HEX < 0x03090000
194193 if (PyEval_ThreadsInitialized ()) {
195194#else
196195 if (true ) {
@@ -204,7 +203,7 @@ struct InitializePythonRAII {
204203
205204// `PyEval_InitThreads` was deprecated in Python 3.9 and removed in
206205// Python 3.13.
207- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 9) || (PY_MAJOR_VERSION < 3)
206+ #if PY_VERSION_HEX < 0x03090000
208207 return ;
209208 }
210209
0 commit comments