|
From: Langer, S. A. (Fed) <ste...@ni...> - 2022-05-24 22:23:13
|
Thanks for the response. Using the tp_repr slot did just what I needed.
I still don't understand what's going on with the tp_print warnings, but I'm content to ignore them if that's what's recommended. I am using swig 4.0.2, so shouldn't it be compatible with python 3.8?
-- Steve
On 5/20/22, 4:45 PM, "William S Fulton" <ws...@fu...<mailto:ws...@fu...>> wrote:
1. From the CHANGES file for swig-4.0.2:
2020-01-05: jschueller shadchin
[Python] #1670 #1696 Add missing field initializers introduced in python 3.8:
tp_vectorcall and tp_print.
2. Customise using slots with the "python:tp_repr" feature, see https://www.swig.org/Doc4.0/Python.html#Python_builtin_overloads<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.swig.org%2FDoc4.0%2FPython.html%23Python_builtin_overloads&data=05%7C01%7Cstephen.langer%40nist.gov%7C60f4a48441764770d09b08da3aa1b981%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637886763524648944%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=dL875F3VMpavP2MjFiObW3BkJwgHxz%2B9tKcncl6eArI%3D&reserved=0>.
William
On Fri, 29 Apr 2022 at 22:13, Langer, Stephen A. (Fed) via Swig-user <swi...@li...<mailto:swi...@li...>> wrote:
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
_______________________________________________
Swig-user mailing list
Swi...@li...<mailto:Swi...@li...>
https://lists.sourceforge.net/lists/listinfo/swig-user<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cstephen.langer%40nist.gov%7C60f4a48441764770d09b08da3aa1b981%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637886763524648944%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=zJvXa0I0lTdzdT%2FUwDpfritk7JKUc7deFjQfrKBRmxY%3D&reserved=0>
|