Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107460

Re: How are you supposed to define subclasses in C?

From Zachary Ware <zachary.ware+pylist@gmail.com>
Newsgroups comp.lang.python
Subject Re: How are you supposed to define subclasses in C?
Date 2016-04-21 11:39 -0500
Message-ID <mailman.21.1461256772.23626.python-list@python.org> (permalink)
References <1461256556.38223.585724489.051B2155@webmail.messagingengine.com> <CAKJDb-M6G9hW-XO+7am_Em+45cavgJV_b8ZkYjDEV7GuZMryeg@mail.gmail.com>

Show all headers | View raw


On Thu, Apr 21, 2016 at 11:35 AM, Random832 <random832@fastmail.com> wrote:
> I was trying to write a proof of concept on including descriptors (e.g.
> a "sys.recursionlimit" instead of set/get methods) in the sys module,
> and couldn't figure out how to "properly" define a type using
> PyType_FromSpecWithBases. Everything I tried just segfaulted. I ended up
> just calling PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, ...)
> but I assume there's a better way to do it. I couldn't find any examples
> or tutorial.

Have a look at https://hg.python.org/cpython/file/default/Modules/xxsubtype.c

-- 
Zach

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How are you supposed to define subclasses in C? Zachary Ware <zachary.ware+pylist@gmail.com> - 2016-04-21 11:39 -0500

csiph-web