Re: Two questions

William S Fulton <[email protected]> Fri, 20 May 2022 21:43:59 +0100
Newsgroups gmane.comp.programming.swig
Message-ID <CANGqftAts2Bef-CB5mpG9k-bm9gW1OfvEXHSCbu4jSLKE4waKw@mail.gmail.com>
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.

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
>

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