Fix segmentation fault with python 3.10

f38
Mattias Ellert 4 years ago
parent e471d49e64
commit 0fa34c0704

@ -1,12 +0,0 @@
diff -up Inline-Python-0.56/Makefile.PL.orig Inline-Python-0.56/Makefile.PL
--- Inline-Python-0.56/Makefile.PL.orig 2018-07-09 12:54:47.605495856 +0200
+++ Inline-Python-0.56/Makefile.PL 2018-07-09 12:55:15.919418183 +0200
@@ -22,7 +22,7 @@ unless ($sel) {
my $sep = $^O eq 'MSWin32' ? ";" : ":";
for $p (split /$sep/, $ENV{PATH}) {
$p =~ s/^~/$ENV{HOME}/;
- $p .= "/python";
+ $p .= "/python3";
next unless -f $p and -x $p;
next if $pythons{abs_path($p)}++; # filter symlinked duplicates
push @pythons, { path => $p };

@ -0,0 +1,47 @@
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

@ -1,11 +1,14 @@
Name: perl-Inline-Python
Version: 0.56
Release: 18%{?dist}
Release: 19%{?dist}
Summary: Write Perl subs and classes in Python
License: GPL+ or Artistic
URL: https://metacpan.org/release/Inline-Python
Source0: https://cpan.metacpan.org/authors/id/N/NI/NINE/Inline-Python-%{version}.tar.gz
Patch0: Inline-Python-0.56-Use-python3.patch
# Call Py_Initialize() before calling PyBytes_FromString()
# Fixes segmentation fault with python 3.10
# https://github.com/niner/inline-python-pm/pull/33
Patch0: %{name}-pyinit.patch
BuildRequires: gcc
BuildRequires: findutils
BuildRequires: make
@ -59,7 +62,7 @@ name-space is cached, and subsequent calls use the cached version.
%patch0 -p1
%build
%{__perl} Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS" NO_PACKLIST=1
INLINE_PYTHON_EXECUTABLE=/usr/bin/python3 %{__perl} Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS" NO_PACKLIST=1
make %{?_smp_mflags}
%install
@ -79,6 +82,9 @@ make test
%{_mandir}/man3/*
%changelog
* Thu Aug 19 2021 Mattias Ellert <mattias.ellert@physics.uu.se> - 0.56-19
- Fix segmentation fault with python 3.10
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.56-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

Loading…
Cancel
Save