473,378 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

TR: embeded python progam into visual C++ application crash



-----Message d'origine-----
De : fabien.lyon [mailto:fa*********@isismpp.fr]
Envoyé : mercredi 30 mai 2007 20:16
À : 'p**********@python.org'
Objet : RE: embeded python progam into visual C++ application crash

hello,
The C++ application uses a python module which wraps commands set for CVS
management:
checkout, checkin and tag.
We used python2.5.1 and Visual C++ 6.0
2.5.1 is compiled with Visual Studio 2005 - I hope you had no problems
with VC++ 6.0?
The problem we get is:
After a good import and definition of python functions we have a random
unhandled exception (from python25.dll) when calling python interface
function several times.
All the python module has been tested using the python IDLE.
This the C++ sequence code we used:

Py_initialize()
Py_Import("moduleName")
cvs_init() // cvs view initialisation handled
by
python script init()
cvs_set_tag() // cvs commit and tag handled by python
script settag()
// the exception occured here
>Neither Py_initialize nor Py_Import functions exist - so please post
actual code.
>--
Gabriel Genellina
Ho sorry you are right (this pb disturbs me too much).
Investigation and efforts has been helpfull, so we have found the problem.
This is the following description :

void InterfaceTestConfigPython_C::InitCVS(CString path_vue_bench_p, CString
path_vue_test_p)
{
PyObject *pArgs= NULL, *pValue= NULL;
PyObject *pPathVueBench= NULL, *pPathVueTest= NULL ;

//python objects for each python function argument
pPathVueBench = PyString_FromString((LPCTSTR)path_vue_bench_p);
pPathVueTest = PyString_FromString((LPCTSTR)path_vue_test_p);

//python object to collect all arguments
pArgs = PyTuple_New(2);
PyTuple_SetItem(pArgs, 0, pPathVueBench);
PyTuple_SetItem(pArgs, 1, pPathVueTest);

// python function call
pValue = PyObject_CallObject(pFuncInit_m, pArgs);

// clean up memory
Py_DECREF(pArgs);

// process return value
if (pValue != NULL)
{
....
// clean up memory
Py_DECREF(pValue);
}

// clean up memory
Py_DECREF(pPathVueBench );
Py_DECREF(pPathVueTest);
}

The problem we get come from a wrong code. The last two lines, calling
Py_DECREF, are not mandatory and make the python interpreter in a bad day.
When the InitCVS() function call Py_DECREF(pArgs) the memory allocated for
pPathVueBench and pPathVueTest is free (i guess) because the
PyTuple_SetItem(pArgs, 0, pPathVueBench) steals the reference of the python
object you add into the tuple pArgs like the python documentation tells. So
we have suppressed the last clean up memory
in the InitCVS() function and now the program is running as expected.

I join the C++ object code if this can help someone.


May 31 '07 #1
0 1330

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office...
0
by: fabien.lyon | last post by:
hello, The C++ application uses a python module which wraps commands set for CVS management: checkout, checkin and tag. We used python2.5.1 and Visual C++ 6.0 The problem we get is: After a...
3
by: Johnson | last post by:
I'm not sure if this is an IIS 5.1 issue or ASP.NET issue, or Visual Studio 2008 issue -- thus posting to 3 groups. Please don't be offended. The problem I'm encountering is that Visual Studio...
1
by: NitinSawant | last post by:
Is there any Visual sourcesafe like application which is web based (can be installed on a remote website) and can be integrated with visual studio .net? Regards, Nitin
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.