Re: PyObject_New

2005-10-07 Thread Jeremy Moles
I just noticed this response right as I sent my other message. For some reason my news reader didn't thread it, so it was all by itself... Please disregard the rant concerning creation of objects in C. :) /me hugs Martin /me ducks and hides! On Fri, 2005-10-07 at 09:57 +0200, "Martin v. Löwis" wr

Re: PyObject_New

2005-10-07 Thread Martin v. Löwis
Jeremy Moles wrote: > PyObject* obj = _PyObject_New(&PyType_MyType); > obj = PyObject_Init(obj, &PyType_MyType); > > ... > > return obj; The call to PyObject_Init is redundant: _PyObject_New is malloc+init. However, this shouldn't cause any crashes (except in the de

Re: PyObject_New

2005-10-06 Thread Gerhard Häring
Jeremy Moles wrote: > [...] What I'm trying > now is the following: > > PyObject* obj = _PyObject_New(&PyType_MyType); > obj = PyObject_Init(obj, &PyType_MyType); > > ... > > return obj; > > When "obj" gets back to the interpreter, Python sees it (or rather, it's >

Re: PyObject_New not running tp_new for iterators?

2005-04-21 Thread Gregory Bond
I wrote: [snip] > What am I missing? The fundamental problem is that this: if (!(ro = PyObject_New(MyIter, &MyIterType))) return NULL; is really only a malloc() - it doesn't call the tp_new function at all. This is not really clear in the 2.3 version of the C API document that I was con