[C++-sig] strange sideeffect or bug of boost.python

Lutz Paelike lutz_p at gmx.net
Wed Oct 29 15:32:30 CET 2003


Hi David,

that solved the problem indeed. I isolated some code for debugging in an extra project and forgot to include the 
BOOST_DEBUG_PYTHON definition. Thank you.

Cheers,

Lutz

yakumoklesk at yahoo.es schrieb:

> Something like this happened to me. Maybe youo are compiling a Debug version of your 
> application. As boost python makes a wrap include of "python.h" in order to avoid 
> compilin with the python_d debug library, you are compiling a debug version without a 
> debug python library. To avoid this, in your precompiler definitions in the project in 
> visual C just define: BOOST_DEBUG_PYTHON. With this definition you can include the 
> necessary bost/python.hpp include file in order to work with bost::python namespace 
> objects.
> 
> I hope this helped you.
> 
> David.
> 
> On 29 Oct 2003 at 12:33, Lutz Paelike wrote:
> 
> 
>>Hi,
>>
>>i encountered a strange thing when i wanted to create a dictionary object from c++.
>>The error is after creating the dict with no errors (result!=NULL) a simple PyDict_Check fails with no reason.
>>I tracked this down through the Python Sources and extracted the essential source of PyDict_Check and inserted
>>it into the example code below. In the Debugger i see that the ob_type of the new object is somehow screwed up.
>>And now the strange thing: This error goes away and the code works like expected if i remove the boost include.
>>
>>Am I missing something or is this a strange side effect ?
>>
>>I'm using Visual Studio 6 SP5 and a recent boost cvs checkout (about 1-2 weeks old)
>>
>>Thanks for your help,
>>
>>Lutz
>>
>>Here is the code:
>>
>>///////////////////////////snip//////////////////////////////////////
>>#include <boost/python.hpp> // comment this out to make it work
>>
>>#include <string>
>>#include <iostream>
>>#include <fstream>
>>#include <exception>
>>#include <stdexcept>
>>
>>#include <Python.h>
>>#include <compile.h>
>>#include <eval.h>
>>#include <dictobject.h>
>>
>>
>>int main()
>>{
>>     Py_Initialize();
>>
>>	PyObject *the_dict = PyDict_New ();
>>
>>	if (NULL!=the_dict){
>>
>>		Py_INCREF(the_dict);
>>
>>		_typeobject  * dt = &PyDict_Type;
>>
>>		// PyDict_Check does this. Why isn't this working here?
>>		bool isT  = ((the_dict)->ob_type == (&PyDict_Type));
>>		bool isST = PyType_IsSubtype((the_dict)->ob_type, (&PyDict_Type));
>>
>>		if (isT) printf("the_dict is of type PyDict_Type\n");
>>		else printf("the_dict is not of type PyDict_Type! Boost.Python Bug?\n");
>>		
>>		if (isST) printf("the_dict is of subtype PyDict_Type\n");
>>		else printf("the_dict is not of subtype PyDict_Type! Boost.Python Bug?\n");
>>
>>		Py_DECREF(the_dict);
>>
>>	} else printf("Error creating new dict\n");
>>
>>	Py_Finalize();
>>
>>     return 0;
>>}
>>
>>///////////////////////////snip//////////////////////////////////////
>>
>>
>>
>>_______________________________________________
>>C++-sig mailing list
>>C++-sig at python.org
>>http://mail.python.org/mailman/listinfo/c++-sig
> 
> 
> 
> 
> 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 
> 







More information about the Cplusplus-sig mailing list