For Python < 3.9 the tp_as_buffer member is set explicitly if the
interface has a bf_getbuffer slot defined. This fixes#3211.
Enabled buffer interface for non-builtin test.
This only works with Python >= 3.12, where methods __buffer__ and
__release_buffer__ were added. Unfortunately it's not practical for
these methods to reuse the slot methods (or vice versa).
Disable Py_LIMITED_API if below 3.11. The Py_buffer struct and
associated functions are not defined in earlier stable API versions.
Closes#3211
Correct SwigPyObject_richcompare and SwigPyObject_compare signatures
and avoid potential read beyond object memory.
Squashed commit of #3216 plus changes file entry and whitespace fixes.
Closes#3217
Implements https://peps.python.org/pep-0489/
Bumps minimal python3 version from 3.4 to 3.5.
The idea is to move the initialization of the module into a new SWIG_mod_exec function.
Closes#3168
Add bool output parameter to Swig_overload_dispatch to say when it has
generated code that will use the typecheck typemap code to help Lua and
Octave to not emit unused argv[] arrays.
Alas, resorted to warning suppression for deficient cpp11_initializer_list
typecheck typemap in cpp11_std_initializer_list testcase.
Only generate slots if provided by SWIG or if they are provided by users via a %feature.
So stop generating large tables of slots containing "0".
Issue #3196
structmember.h inclusion moved for external runtime to work without
requiring users to include structmember.h and the Py_READONLY and
Py_ST_PYSSIZE_T definitions. Including Python.h remains the requirement
for using the external runtime (Examples/python/external_runtime).
Note that stddef.h is not always included by structmember.h
Rename dict to swigdict in PySwigObject for easier identification.
SWIG_HEAPTYPES definition is moved to support both external runtime
and Python Stable ABI.
Issue #3196
Fixes "TypeError: multiple bases have instance lay-out conflict"
for python-3.11 and earlier for multiple inheritance, see 22d9fda0 and 4908133e.
Fix is achieved by moving __dictoffset__ to the single common base class SwigPyObject.
* builtin-heap-types:
Changes entry for python -builtin and heap types
Revert previous commit as it breaks setting arbitrary attributes on builtin wrapped types
Fix TypeError: multiple bases have instance lay-out conflict
Py_LIMITED_API support in SwigPyObject_Check for -builtin
Py_LIMITED_API support in SwigPyBuiltin_SetMetaType for -builtin
Remove pyname_compat.i
Python type creation functions refactor
Small move towards Py_LIMITED_API for -builtin
Add SwigPyObjectType and SwigPyStaticVar to the swig runtime module
SWIG_HEAPTYPES for SwigPyStaticVar and add it to the runtime module
Cosmetic whitespace formatting around PY_VERSION_HEX
SWIG_HEAPTYPES for SwigPyObjectType and add it to the runtime module
Better error handling creating types with python -builtin
Gracefully handle errors in PyType_FromSpecWithBases for -builtin
Gracefully handle errors in PyModule_AddObject for -builtin
More graceful error in failures calling back_reference
Show ref count before final decrement when using SWIG_REFCNT_DEBUG
When using -builtin and -DSWIG_HEAPTYPES.
Otherwise there are two testcase failures when trying to set arbitrary
attributes onto the wrapped Python types:
Traceback (most recent call last):
File "/home/william/swig/github/swig/Examples/test-suite/python/./li_std_vector_back_reference_runme.py", line 8, in <module>
size = first_element().size
^^^^^^^^^^^^^^^
File "/home/william/swig/github/swig/Examples/test-suite/python/./li_std_vector_back_reference_runme.py", line 6, in first_element
return v[0]
~^^^
AttributeError: 'li_std_vector_back_reference.Wheel' object has no attribute '__swig_container'
make[1]: *** [Makefile:143: li_std_vector_back_reference.cpptest] Error 1
Traceback (most recent call last):
File "/home/william/swig/github/swig/Examples/test-suite/python/./struct_value_runme.py", line 15, in <module>
b.added = 123
^^^^^^^
AttributeError: 'struct_value.Bar' object has no attribute 'added'
make[1]: *** [Makefile:141: struct_value.cpptest] Error 1
Fix when using -builtin and -DSWIG_HEAPTYPES in these tests:
constructor_copy_non_const
contract
default_constructor
director_basic
minherit
using_composition
using_extend
using_member_multiple_inherit
cpp11_variadic_templates
Fix required for python <= 3.11.
Python 3.12 does not have the TypeError due to
https://github.com/python/cpython/pull/96028.
The $function variable in %exception/feature:except typemaps is
no longer recognised. It was marked as deprecated in 2008.
Use $action (added in 2001) instead which has exactly the same
value.
SWIG/D has an unrelated $function variable which is substituted in
%pragma(d) wrapperloaderbindcommand - this is still supported.
Fix -external-runtime to generate a header which works with Tcl 8.x.
Regression introduced in SWIG 4.2.1. As a bonus the generated header
no longer requires the user to include tcl.h and various standard C
library headers before including it.
Fixes#2887
Add workaround for missing __dictoffset__ support prior to python-3.9 -
fixes struct_value and li_std_vector_back_reference testcases which failed
when attempting to set attributes on a class's dict.
Also surfaces Python error 'TypeError: multiple bases have instance lay-out conflict'
in a few testcases < python-3.12 with SWIG_HEAPTYPES defined with -builtin, for example
constructor_copy_non_const testcase.
SWIG_NOEXCEPT is generated instead of throw() which is deprecated in
c++11. If c++11 or later is being used, then this macro expands to
noexcept instead of throw().
Affects director code only.
Also fix up some testcase to not use throw() when using c++11 or later.
Tested with clang and -Wdeprecated-dynamic-exception-spec as gcc
doesn't seem to warn for this deprecation.
Closes#3027
GHA - python-3.14 testing changed to "can fail" as 3.14 is still in alpha status.
Restore __package__ fallback check as it was.
Correct docs given the import changes.
Issue #3159
Issue #2967
more
We need to strip qualifiers before checking the type is `bool`.
This mainly affects Python. In Ruby there's equivalent code, but
it is only use to generate documentation comments.
Fixes#3052
Documentation comments now use `true` and `false` for bool parameter
default values, instead of `True` and `False` (which are the Python
names and wrong for Ruby!)
Previously the parse tree contained the forward class declaration for
nested classes, the <classforward> XML element as nested class
support had not been turned on during parsing for -xml. The nested
class support has now been turned on so that the nested classes appear
in the parse tree in a <class> XML element.
Closes#874