File: set-progname.patch

package info (click to toggle)
v-sim 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,188 kB
  • sloc: ansic: 115,451; f90: 19,861; python: 2,120; makefile: 1,002; xml: 719; cpp: 688; sh: 23
file content (26 lines) | stat: -rw-r--r-- 933 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Description: Set program_name using PyConfig to fix FTBFS

Bug-Debian: https://bugs.debian.org/1075614
Last-Update: 2025-02-18
--

--- a/lib/plug-ins/python-gi/pythongi.c
+++ b/lib/plug-ins/python-gi/pythongi.c
@@ -232,8 +232,15 @@ static void initialisePython()
     return;
 
   DBG_fprintf(stderr, "Panel PythonGI: initialise Python.\n");
-  Py_SetProgramName((char*)commandLineGet_programName());
-  Py_Initialize();
+
+  /* Py_SetProgramName deprecated by python 3.11 */
+  /* https://docs.python.org/3/c-api/init_config.html#preinitialize-python-with-pypreconfig */
+
+  PyConfig config;
+  PyConfig_InitPythonConfig(&config);
+  PyConfig_SetBytesString(&config, &config.program_name, (char *)commandLineGet_programName());
+
+  Py_InitializeFromConfig(&config);
   DBG_fprintf(stderr, "Panel PythonGI: import sys.\n"
               "import os;\n"
               "os.putenv(\"GI_TYPELIB_PATH\", \"" VISU_TYPELIBS_DIR "\")\n");