Fix memory leak on slices when converting a gexpr back to python

This commit is contained in:
dongjiao_joan 2024-05-21 04:24:34 +08:00
parent ae5e920ca5
commit dfb6c2e474
2 changed files with 31 additions and 2 deletions

View File

@ -0,0 +1,25 @@
From b65ff8f51b710a8496f3b2d7fc1fcbe7bc68ac53 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
Date: Tue, 23 Apr 2024 23:26:02 +0200
Subject: [PATCH] FIx leak on slices when converting a gexpr back to python
Fix https://github.com/serge-sans-paille/pythran/issues/2200
---
pythran/pythonic/types/ndarray.hpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/pythran/pythonic/types/ndarray.hpp b/pythran/pythonic/types/ndarray.hpp
index d0aa75925..191933ccd 100644
--- a/pythran/pythonic/types/ndarray.hpp
+++ b/pythran/pythonic/types/ndarray.hpp
@@ -1531,6 +1531,7 @@ PyObject *to_python<types::numpy_gexpr<Arg, S...>>::convert(
: ::to_python(v.slices);
PyObject *base = ::to_python(v.arg);
PyObject *res = PyObject_GetItem(base, slices);
+ Py_DECREF(slices);
Py_DECREF(base);
if (transpose) {
PyObject *Transposed =
--
2.43.0

View File

@ -1,11 +1,12 @@
%global _empty_manifest_terminate_build 0
Name: python-pythran
Version: 0.14.0
Release: 1
Release: 2
Summary: An ahead of time compiler for a subset of the Python language.
License: BSD-3-Clause
URL: https://github.com/serge-sans-paille/pythran
Source0: https://files.pythonhosted.org/packages/2c/ab/a647b8cc3ac1aa07cde06875157696e4522958fb8363474bce21c302d4d8/pythran-0.14.0.tar.gz
Patch0: backport-fix-leak-on-slices-when-converting-a-gexpr-back-to-python.patch
BuildArch: noarch
%description
An ahead of time compiler for a subset of the Python language, with a focus on scientific computing.
@ -30,7 +31,7 @@ Provides: python3-pythran-doc
Development documents and examples for pythran.
%prep
%autosetup -n pythran-%{version}
%autosetup -p1 -n pythran-%{version}
sed -i 's/\~=/\>=/g' requirements.txt
%build
@ -73,5 +74,8 @@ mv %{buildroot}/doclist.lst .
%{_docdir}/*
%changelog
* Tue May 21 2024 dongjiao <dongjiao@kylinos.cn> - 0.14.0-2
- Fix memory leak on slices when converting a gexpr back to python
* Thu Nov 30 2023 Dongxing Wang <dongxing.wang_a@thundersoft.com> - 0.14.0-1
- Init package