From lukaszjagielski at gmail.com Tue Oct 3 11:04:13 2017 From: lukaszjagielski at gmail.com (=?UTF-8?Q?=C5=81ukasz_Jagielski?=) Date: Tue, 3 Oct 2017 17:04:13 +0200 Subject: [capi-sig] Is it ok to call PyBaseType_Object.tp_new from external code? Message-ID: Hi, I've noticed that when calling PyBaseObject_Type.tp_new ( https://github.com/python/cpython/blob/master/Objects/typeobject.c#L3608), function excess_args is immediately called which assumes its first parameter is a tuple. Problem is that tuple struct is bigger that Py_None, correct me if I'm wrong. I've noticed code in swig which calls object_new with both args and kwds being Py_None and reported an issue for it (https://github.com/swig/swig/issues/1109). The question is whether it's ok to call tp_new on a given PyTypeObject but the second and third param should always be a tuple and a dict or should some other api function be called instead? Thanks, ?ukasz From storchaka at gmail.com Thu Oct 19 13:09:59 2017 From: storchaka at gmail.com (Serhiy Storchaka) Date: Thu, 19 Oct 2017 20:09:59 +0300 Subject: [capi-sig] Is it ok to call PyBaseType_Object.tp_new from external code? In-Reply-To: References: Message-ID: 03.10.17 18:04, ?ukasz Jagielski ????: > I've noticed that when calling PyBaseObject_Type.tp_new ( > https://github.com/python/cpython/blob/master/Objects/typeobject.c#L3608), > function excess_args is immediately called which assumes its first > parameter is a tuple. Problem is that tuple struct is bigger that Py_None, > correct me if I'm wrong. I've noticed code in swig which calls object_new > with both args and kwds being Py_None and reported an issue > for it (https://github.com/swig/swig/issues/1109). The question is whether > it's ok to call tp_new on a given PyTypeObject but the second > and third param should always be a tuple and a dict or should some other > api function be called instead? args should be a tuple, kwds should be NULL or a dict.