[C++-sig] Re: Can anybody tell me the other difference between these 2 little programs?

David Abrahams dave at boost-consulting.com
Thu Sep 11 18:43:38 CEST 2003


yakumoklesk at yahoo.es writes:

>
> The first difference I have found is that the first version exits with an error
>
> Fatal Python error: PyThreadState_Get: no current thread
>
> while the second version works OK.

$ diff bu1.cpp bu2.cpp
--- c:/tmp/bu1.cpp	2003-09-11 12:40:06.000000000 -0400
+++ c:/tmp/bu2.cpp	2003-09-11 12:39:55.000000000 -0400
@@ -1,4 +1,4 @@
-int main( int argc, char** argv )
+void test()
 {
 	Py_Initialize();
 
@@ -16,6 +16,10 @@
 	handle<> resNoneResult( PyEval_CallObject( funcPrintTree.get(), argFuncArgs 
 ) );
 	Py_DECREF( argFuncArgs );
+}
+int main( int argc, char** argv )
+{
+	test();
 
 	Py_Finalize();
 

...but seriously, folks:
http://www.boost-consulting.com/boost/libs/python/todo.html#pyfinalize-safety

HTH,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list