|
From: Langer, S. A. (Fed) <ste...@ni...> - 2022-05-31 15:24:02
|
Hi William --
I'm using an iMac running macOS Big Sur 11.6.6. All dependencies were installed with MacPorts. I just figured out that the problem doesn't occur on Ubuntu 20.04. I don't have access to other OS's.
I've attached a swig file and a cmake file, and the output from running cmake and make, with both swig 4.0.2 and 4.1.0 (from github). The swig file just uses %inline to declare a simple function. The same warning appears in both cases.
-- Steve
On 5/28/22, 4:39 AM, "William S Fulton" <ws...@fu...<mailto:ws...@fu...>> wrote:
For the pending 4.1.0 release we do have one change:
[Python] Fix "too many initializers for 'PyHeapTypeObject'" errors
using PyPy 3.8 and later.
but that is for PyPy not CPython. Try out master and if you still see the tp_print warnings, please put together a small testcase to demonstrate.
William
On Tue, 24 May 2022 at 23:23, Langer, Stephen A. (Fed) <ste...@ni...<mailto:ste...@ni...>> wrote:
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%7C20da5d4baa634781d41708da40859886%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637893239791612972%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=EjXKcEltlUqhQfty2sojmo9wrTvfUIEv9cdDcj3BeEA%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%7C20da5d4baa634781d41708da40859886%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637893239791612972%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rGX%2Bxyk2zvewkCw9jyTFwIdrpM9g%2B6JwCjjdL77fDKQ%3D&reserved=0>
|