|
From: Langer, S. A. (Fed) <ste...@ni...> - 2022-04-29 21:13:01
|
Hi -- I'm beginning to use Swig 4 on a project. My previous experience was with Swig 1.1, so I have some catching up to do. I'm generating python3 wrappers for C++. The Swig web site says that Swig 4.0.1 added support for Python 3.8. When I use Python 3.8, I get a lot of warnings that 'tp_print' is deprecated when compiling the _wrap.cxx files (using cmake on a Mac). If I use Python 3.10, I don't get the warnings. As far as I can tell, both versions work, but I'm confused. Is 3.10 supported? It looks like it's supported better than 3.8. Or is the lack of warnings in 3.10 misleading? My second question is how to override the default __repr__ for swigged classes. With Swig 1.1 and Python 2.7, I could just monkey patch a new __repr__ in the python wrapper for the class. With Swig 4, defining __repr__ in C++ or monkey patching it works only if I don't use -builtin. If I do use -builtin, then monkey patching is forbidden and __repr__ defined in C++ is replaced by the generic SwigPyObject_repr. Is it possible to redefine __repr__ for a swigged class when using -builtin? Thanks. -- Steve |