Mailing List Archive

Python C API: how to mark a type as subclass of another type
I have two types declared as

PyTypeObject PyX_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)

etc.

How can I mark one of the types as subclass of the other one? I tried
to use tp_base but it didn't work.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python C API: how to mark a type as subclass of another type [ In reply to ]
Marco Sulla wrote at 2021-10-31 23:59 +0100:
>I have two types declared as
>
>PyTypeObject PyX_Type = {
> PyVarObject_HEAD_INIT(&PyType_Type, 0)
>
>etc.
>
>How can I mark one of the types as subclass of the other one? I tried
>to use tp_base but it didn't work.

Read the "Python/C Api" documentation. Watch out for `tp_base`.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python C API: how to mark a type as subclass of another type [ In reply to ]
I already added the address of the type to tp_base, but it does not work.

On Mon, 1 Nov 2021 at 17:18, Dieter Maurer <dieter@handshake.de> wrote:
>
> Marco Sulla wrote at 2021-10-31 23:59 +0100:
> >I have two types declared as
> >
> >PyTypeObject PyX_Type = {
> > PyVarObject_HEAD_INIT(&PyType_Type, 0)
> >
> >etc.
> >
> >How can I mark one of the types as subclass of the other one? I tried
> >to use tp_base but it didn't work.
>
> Read the "Python/C Api" documentation. Watch out for `tp_base`.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python C API: how to mark a type as subclass of another type [ In reply to ]
*ahem* evidently I didn't check the right package..... it works like a charme :D

On Tue, 2 Nov 2021 at 13:43, Marco Sulla <elbarbun@gmail.com> wrote:
>
> I already added the address of the type to tp_base, but it does not work.
>
> On Mon, 1 Nov 2021 at 17:18, Dieter Maurer <dieter@handshake.de> wrote:
> >
> > Marco Sulla wrote at 2021-10-31 23:59 +0100:
> > >I have two types declared as
> > >
> > >PyTypeObject PyX_Type = {
> > > PyVarObject_HEAD_INIT(&PyType_Type, 0)
> > >
> > >etc.
> > >
> > >How can I mark one of the types as subclass of the other one? I tried
> > >to use tp_base but it didn't work.
> >
> > Read the "Python/C Api" documentation. Watch out for `tp_base`.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python C API: how to mark a type as subclass of another type [ In reply to ]
Marco Sulla wrote at 2021-11-2 13:43 +0100:
>I already added the address of the type to tp_base, but it does not work.

It worked for me in `dm.incrementalsearch`.

Maybe, you need a special value for `tp_flags`.

Look at the examples.
--
https://mail.python.org/mailman/listinfo/python-list