From f14e3ef63dddcf0451ad36faeba78e4edf791022 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Oct 24 2023 16:27:27 +0000 Subject: Patch "python313" for Python 3.13 compatibility. https://bugzilla.redhat.com/show_bug.cgi?id=2245835 --- diff --git a/insight-13.0-gdb-python313.patch b/insight-13.0-gdb-python313.patch new file mode 100644 index 0000000..3ad1da5 --- /dev/null +++ b/insight-13.0-gdb-python313.patch @@ -0,0 +1,187 @@ +diff -Naurp insight-13.0.50.20220502.orig/gdb/python/py-gdb-readline.c insight-13.0.50.20220502.new/gdb/python/py-gdb-readline.c +--- insight-13.0.50.20220502.orig/gdb/python/py-gdb-readline.c 2022-01-07 13:47:42.000000000 +0100 ++++ insight-13.0.50.20220502.new/gdb/python/py-gdb-readline.c 2023-10-24 17:41:26.221256014 +0200 +@@ -22,6 +22,10 @@ + #include "top.h" + #include "cli/cli-utils.h" + ++#if PY_VERSION_HEX >= 0x030d0000 ++extern PyThreadState* _PyOS_ReadlineTState; ++#endif ++ + /* Readline function suitable for PyOS_ReadlineFunctionPointer, which + is used for Python's interactive parser and raw_input. In both + cases, sys_stdin and sys_stdout are always stdin and stdout +diff -Naurp insight-13.0.50.20220502.orig/gdb/python/python.c insight-13.0.50.20220502.new/gdb/python/python.c +--- insight-13.0.50.20220502.orig/gdb/python/python.c 2022-04-22 14:01:57.000000000 +0200 ++++ insight-13.0.50.20220502.new/gdb/python/python.c 2023-10-24 15:10:56.017951714 +0200 +@@ -1810,8 +1810,14 @@ set_python_ignore_environment (const cha + struct cmd_list_element *c) + { + #ifdef HAVE_PYTHON ++ /* Py_IgnoreEnvironmentFlag is deprecated in Python 3.12. Disable ++ its usage in Python 3.10 and above since the PyConfig mechanism ++ is now (also) used in 3.10 and higher. See do_start_initialization() ++ in this file. */ ++#if PY_VERSION_HEX < 0x030a0000 + Py_IgnoreEnvironmentFlag = python_ignore_environment ? 1 : 0; + #endif ++#endif + } + + /* When this is turned on before Python is initialised then Python will +@@ -1839,6 +1845,24 @@ show_python_dont_write_bytecode (struct + value); + } + ++/* Return value to assign to PyConfig.write_bytecode or, when ++ negated (via !), Py_DontWriteBytecodeFlag. Py_DontWriteBytecodeFlag ++ is deprecated in Python 3.12. */ ++ ++static int ++python_write_bytecode () ++{ ++ int wbc = 0; ++ ++ if (python_dont_write_bytecode == AUTO_BOOLEAN_AUTO) ++ wbc = (!python_ignore_environment ++ && getenv ("PYTHONDONTWRITEBYTECODE") != nullptr) ? 0 : 1; ++ else ++ wbc = python_dont_write_bytecode == AUTO_BOOLEAN_TRUE ? 0 : 1; ++ ++ return wbc; ++} ++ + /* Implement 'set python dont-write-bytecode'. This sets Python's internal + flag no matter when the command is issued, however, if this is used + after Py_Initialize has been called then many modules could already +@@ -1849,13 +1873,13 @@ set_python_dont_write_bytecode (const ch + struct cmd_list_element *c) + { + #ifdef HAVE_PYTHON +- if (python_dont_write_bytecode == AUTO_BOOLEAN_AUTO) +- Py_DontWriteBytecodeFlag +- = (!python_ignore_environment +- && getenv ("PYTHONDONTWRITEBYTECODE") != nullptr) ? 1 : 0; +- else +- Py_DontWriteBytecodeFlag +- = python_dont_write_bytecode == AUTO_BOOLEAN_TRUE ? 1 : 0; ++ /* Py_DontWriteBytecodeFlag is deprecated in Python 3.12. Disable ++ its usage in Python 3.10 and above since the PyConfig mechanism ++ is now (also) used in 3.10 and higher. See do_start_initialization() ++ in this file. */ ++#if PY_VERSION_HEX < 0x030a0000 ++ Py_DontWriteBytecodeFlag = !python_write_bytecode (); ++#endif + #endif /* HAVE_PYTHON */ + } + +@@ -1957,6 +1981,17 @@ gdbpy_gdb_exiting (int exit_code) + static bool + do_start_initialization () + { ++ /* Define all internal modules. These are all imported (and thus ++ created) during initialization. */ ++ struct _inittab mods[] = ++ { ++ { "_gdb", init__gdb_module }, ++ { nullptr, nullptr } ++ }; ++ ++ if (PyImport_ExtendInittab (mods) < 0) ++ return false; ++ + #ifdef WITH_PYTHON_PATH + /* Work around problem where python gets confused about where it is, + and then can't find its libraries, etc. +@@ -1988,16 +2023,41 @@ do_start_initialization () + } + setlocale (LC_ALL, oldloc.c_str ()); + ++ /* Py_SetProgramName was deprecated in Python 3.11. Use PyConfig ++ mechanisms for Python 3.10 and newer. */ ++#if PY_VERSION_HEX < 0x030a0000 + /* Note that Py_SetProgramName expects the string it is passed to + remain alive for the duration of the program's execution, so + it is not freed after this call. */ + Py_SetProgramName (progname_copy); ++ Py_Initialize (); ++#else ++ PyConfig config; + +- /* Define _gdb as a built-in module. */ +- PyImport_AppendInittab ("_gdb", init__gdb_module); ++ PyConfig_InitPythonConfig (&config); ++ PyStatus status = PyConfig_SetString (&config, &config.program_name, ++ progname_copy); ++ if (PyStatus_Exception (status)) ++ goto init_done; ++ ++ config.write_bytecode = python_write_bytecode (); ++ config.use_environment = !python_ignore_environment; ++ ++ status = PyConfig_Read (&config); ++ if (PyStatus_Exception (status)) ++ goto init_done; ++ ++ status = Py_InitializeFromConfig (&config); ++ ++init_done: ++ PyConfig_Clear (&config); ++ if (PyStatus_Exception (status)) ++ return false; + #endif +- ++#else + Py_Initialize (); ++#endif ++ + #if PY_VERSION_HEX < 0x03090000 + /* PyEval_InitThreads became deprecated in Python 3.9 and will + be removed in Python 3.11. Prior to Python 3.7, this call was +@@ -2303,12 +2363,23 @@ do_initialize (const struct extension_la + + sys_path = PySys_GetObject ("path"); + ++ /* PySys_SetPath was deprecated in Python 3.11. Disable this ++ deprecated code for Python 3.10 and newer. Also note that this ++ ifdef eliminates potential initialization of sys.path via ++ PySys_SetPath. My (kevinb's) understanding of PEP 587 suggests ++ that it's not necessary due to module_search_paths being ++ initialized to an empty list following any of the PyConfig ++ initialization functions. If it does turn out that some kind of ++ initialization is still needed, it should be added to the ++ PyConfig-based initialization in do_start_initialize(). */ ++#if PY_VERSION_HEX < 0x030a0000 + /* If sys.path is not defined yet, define it first. */ + if (!(sys_path && PyList_Check (sys_path))) + { + PySys_SetPath (L""); + sys_path = PySys_GetObject ("path"); + } ++#endif + if (sys_path && PyList_Check (sys_path)) + { + gdbpy_ref<> pythondir (PyUnicode_FromString (gdb_pythondir.c_str ())); +diff -Naurp insight-13.0.50.20220502.orig/gdb/python/python-internal.h insight-13.0.50.20220502.new/gdb/python/python-internal.h +--- insight-13.0.50.20220502.orig/gdb/python/python-internal.h 2022-03-25 11:54:04.000000000 +0100 ++++ insight-13.0.50.20220502.new/gdb/python/python-internal.h 2023-10-24 13:37:29.560852168 +0200 +@@ -177,6 +177,10 @@ gdb_PySys_GetObject (const char *name) + + #define PySys_GetObject gdb_PySys_GetObject + ++/* PySys_SetPath was deprecated in Python 3.11. Disable the deprecated ++ code for Python 3.10 and newer. */ ++#if PY_VERSION_HEX < 0x030a0000 ++ + /* PySys_SetPath's 'path' parameter was missing the 'const' qualifier + before Python 3.6. Hence, we wrap it in a function to avoid errors + when compiled with -Werror. */ +@@ -190,6 +194,7 @@ gdb_PySys_SetPath (const GDB_PYSYS_SETPA + } + + #define PySys_SetPath gdb_PySys_SetPath ++#endif + + /* Wrap PyGetSetDef to allow convenient construction with string + literals. Unfortunately, PyGetSetDef's 'name' and 'doc' members diff --git a/insight.spec b/insight.spec index b185e14..582d371 100644 --- a/insight.spec +++ b/insight.spec @@ -18,7 +18,7 @@ Name: insight Version: %(echo %{ver} | tr - .)%{?snap:.%{snap}} -Release: 11%{?dist} +Release: 12%{?dist} Summary: Graphical debugger based on GDB License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain and GFDL Url: https://www.sourceware.org/insight/ @@ -92,6 +92,7 @@ Patch204: insight-13.0-distutils.patch Patch205: insight-13.0-noselfmove.patch Patch206: insight-configure-c99.patch Patch207: insight-13.0-bfd-CVE-2023-1972.patch +Patch208: insight-13.0-gdb-python313.patch %description @@ -107,28 +108,29 @@ the latest GDB version. %setup -q -n insight-%{version} -%patch1 -p1 -b .relocate - -%patch101 -p1 -%patch102 -p1 -%patch103 -p1 -%patch104 -p1 -%patch105 -p1 -%patch106 -p1 -%patch107 -p1 -%patch108 -p1 -%patch109 -p1 -%patch110 -p1 -%patch111 -p1 -%patch112 -p1 - -%patch201 -p1 -%patch202 -p1 -%patch203 -p1 -%patch204 -p1 -%patch205 -p1 -%patch206 -p1 -%patch207 -p1 +%patch 1 -p1 -b .relocate + +%patch 101 -p1 +%patch 102 -p1 +%patch 103 -p1 +%patch 104 -p1 +%patch 105 -p1 +%patch 106 -p1 +%patch 107 -p1 +%patch 108 -p1 +%patch 109 -p1 +%patch 110 -p1 +%patch 111 -p1 +%patch 112 -p1 + +%patch 201 -p1 +%patch 202 -p1 +%patch 203 -p1 +%patch 204 -p1 +%patch 205 -p1 +%patch 206 -p1 +%patch 207 -p1 +%patch 208 -p1 #------------------------------------------------------------------------------- @@ -324,14 +326,18 @@ ${INSTALL} -m 644 gdb/gdbtk/insight_icon.svg \ #------------------------------------------------------------------------------- %changelog +#------------------------------------------------------------------------------- + +* Tue Oct 24 2023 Patrick Monnerat 13.0.50.20220502-12 +- Patch "python313" for Python 3.13 compatibility. + https://bugzilla.redhat.com/show_bug.cgi?id=2245835 + * Thu Jul 20 2023 Fedora Release Engineering - 13.0.50.20220502-11 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild * Tue Jun 13 2023 Python Maint - 13.0.50.20220502-10 - Rebuilt for Python 3.12 -#------------------------------------------------------------------------------- - * Fri Apr 14 2023 Patrick Monnerat 13.0.50.20220502-9 - Disable stringop-overflow warnings. - Patch "bfd-CVE-2023-1972" fixes a security issue in bfd library.