Skip to content

Commit 85084e7

Browse files
committed
Fix python bindings build with Swig-4.3.0.
1 parent 6531d3e commit 85084e7

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

bindings/python/time64.i

+8-3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@
132132
$1 = &secs;
133133
}
134134

135+
#ifdef HAVE_SWIG_APPENDOUTPUT
136+
#define SWIG_APPENDOUTPUT(res, func) SWIG_AppendOutput(res, func)
137+
#else
138+
#define SWIG_APPENDOUTPUT(res, func) SWIG_Python_AppendOutput(res, func)
139+
#endif
140+
135141
%typemap(argout) time64 *date (time64 secs) {
136142
PyDateTime_IMPORT;
137143
PyObject *tp;
@@ -148,9 +154,8 @@
148154
tp = PyDateTime_FromDateAndTime(t.tm_year + 1900, t.tm_mon + 1,
149155
t.tm_mday, t.tm_hour, t.tm_min,
150156
t.tm_sec, 0);
151-
152-
$result = SWIG_Python_AppendOutput($result, tp);
153-
} else $result = SWIG_Python_AppendOutput($result, Py_None);
157+
$result = SWIG_APPENDOUTPUT($result, tp);
158+
} else $result = SWIG_APPENDOUTPUT($result, Py_None);
154159
}
155160

156161
%apply time64 *date { time64 *last_date };

common/cmake_modules/GncAddSwigCommand.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ macro (gnc_add_swig_python_command _target _out_var _py_out_var _output _py_outp
8686
)
8787

8888
set (PYTHON_SWIG_FLAGS ${DEFAULT_SWIG_PYTHON_FLAGS})
89+
90+
if (SWIG_VERSION VERSION_GREATER_EQUAL "4.3.0")
91+
list(APPEND PYTHON_SWIG_FLAGS
92+
-DHAVE_SWIG_APPENDOUTPUT=1)
93+
endif()
94+
8995
foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES} ${_include_dirs})
9096
list (APPEND PYTHON_SWIG_FLAGS "-I${dir}")
9197
endforeach (dir)

0 commit comments

Comments
 (0)