[Python-Dev] PyObject_New vs PyObject_NEW
David Abrahams
dave@boost-consulting.com
Wed, 12 Mar 2003 14:08:00 -0500
Tim Peters <tim.one@comcast.net> writes:
> Question: I don't have VC7 and don't know what it does. The traceback
> ended in MSVCRTD.DLL, which I recognize as MS's debug-mode C runtime DLL for
> VC6. Does VC7 use the same DLL name, or some other DLL name?
The same one.
> If the latter, my theory is that PyObject_New used the MSVC6 malloc,
> but that PyObject_NEW used the MSCV7 malloc (due to macro expansion
> in your code).
Brilliant theory!
> In both cases the MSVC6 free() gets called.
Ah, correct. I misread "someone's" code; the delete function just
calls PyObject_Del(). I think "someone" probably ought to do
something more explicit to control where things are allocated/freed.
But for now, I think using PyObject_New/PyObject_Del is reasonable.
> But the MSVC6 and MSVC7 heaps are distinct, so the debug-mode MSVC6
> free() complains because it wasn't the source of the memory getting
> freed. A missing piece of the puzzle: what was the error msg at the
> time this thing died?
unhandled exception at 0x10213638 (MSVCRTD.DLL) in python_d.exe: User
breakpoint.
It seems to me that in light of all this, it's probably worth noting
this difference between PyObject_New and PyObject_NEW in the docs.
People *will* develop extension modules with different compilers from
the one Python was compiled with... I know, submit a patch.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com