Re: Two questions

William S Fulton <[email protected]> Sat, 28 May 2022 09:37:55 +0100
Newsgroups gmane.comp.programming.swig
Message-ID <CANGqftBzY5Y2U-bfbN6RXOAuoC5K8XD9XD+veJWYL0nANEqiPw@mail.gmail.com>
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) <
[email protected]> 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" <[email protected]> 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 <
> [email protected]> 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
> [email protected]
> 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>
>
>

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user