|
From: William S F. <ws...@fu...> - 2025-11-10 20:08:06
|
On Thu, 6 Nov 2025 at 14:41, Alexander Moibenko <anm...@gm...> wrote:
> Hello,
> call of PyList_New causes coredump if called from inline function.
> Environment:
> OS: Ubuntu, or Alma Linux 9 (give same result)
> swig:
> SWIG Version 4.0.2
> Compiled with g++ [x86_64-pc-linux-gnu]
> Configured options: +pcre
>
> python: Python 3.12.7
>
> Code:
> swig:
> =====================================
> %module test_PyList_New
>
> %inline %{
> PyObject * test_PyList_New(const int buf_len)
> {
> PyObject * out_list;
>
> printf("test_PyList_New requested buffer length %d\n", buf_len);
> out_list = PyList_New(buf_len);
> return NULL;
>
A python error needs to be set if you want to return NULL. Maybe you meant
to return out_list? Also, the latest SWIG version, swig-4.4.0 returns
immediately to the interpreter for the PyObject* typemaps, as it should as
NULL indicates an error.
William
|