From 1d7f2b3ed075c51c4c280bf6d9340ee2aadc4b02 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 28 Aug 2020 14:40:26 -0400 Subject: [PATCH] Use PY_VERSION_HEX for a cleaner CVE-2008-5983 mode check. --- include/pybind11/embed.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/pybind11/embed.h b/include/pybind11/embed.h index 064b002a3c..a8b366b816 100644 --- a/include/pybind11/embed.h +++ b/include/pybind11/embed.h @@ -152,9 +152,8 @@ inline void set_interpreter_argv(int argc, char** argv, bool add_current_dir_to_ auto pysys_argv = safe_argv; #endif -#if PY_MAJOR_VERSION == 2 && (PY_MINOR_VERSION < 6 || (PY_MINOR_VERSION == 6 && PY_MICRO_VERSION < 6)) || \ - PY_MAJOR_VERSION == 3 && (PY_MINOR_VERSION < 1 || (PY_MINOR_VERSION == 1 && PY_MICRO_VERSION < 3)) - // These python versions don't have PySys_SetArgvEx, so we have to use the workaround +#if PY_VERSION_HEX < 0x020606f0 || (PY_MAJOR_VERSION == 3 && PY_VERSION_HEX < 0x030103f0 + // These python versions don't have PySys_SetArgvEx, so we have to use the approach // recommended by https://docs.python.org/3.5/c-api/init.html#c.PySys_SetArgvEx // to work around CVE-2008-5983 PySys_SetArgv(argc, pysys_argv);