You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
perl-Inline-Python/perl-Inline-Python-pyinit.p...

48 lines
1.4 KiB

From 90b68bdf370c07b1d3fdd46bbdf1b154ed74b91b Mon Sep 17 00:00:00 2001
From: Mattias Ellert <mattias.ellert@physics.uu.se>
Date: Wed, 18 Aug 2021 16:41:10 +0200
Subject: [PATCH] Call Py_Initialize() before calling PyBytes_FromString()
Not doing this gives a segmentation fault with Python 3.10
---
Python.xs | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/Python.xs b/Python.xs
index 11d5033..7a3c793 100644
--- a/Python.xs
+++ b/Python.xs
@@ -25,14 +25,6 @@ void do_pyinit() {
#ifdef EXPOSE_PERL
PyObject *main_dict;
PyObject *perl_obj;
-
-#if PY_MAJOR_VERSION >= 3
- PyObject *dummy1 = PyBytes_FromString(""),
- *dummy2 = PyBytes_FromString("main");
-#else
- PyObject *dummy1 = PyString_FromString(""),
- *dummy2 = PyString_FromString("main");
-#endif
#endif
/* sometimes Python needs to know about argc and argv to be happy */
int _python_argc = 1;
@@ -48,6 +40,14 @@ void do_pyinit() {
PySys_SetArgv(_python_argc, _python_argv); /* Tk needs this */
#ifdef EXPOSE_PERL
+#if PY_MAJOR_VERSION >= 3
+ PyObject *dummy1 = PyBytes_FromString(""),
+ *dummy2 = PyBytes_FromString("main");
+#else
+ PyObject *dummy1 = PyString_FromString(""),
+ *dummy2 = PyString_FromString("main");
+#endif
+
/* create the perl module and add functions */
initperl();
--
2.31.1