[C++-sig] Quiz about Extending Python

技術研發部-Kule Lin(林子淵) kylelin at gamania.com
Mon Mar 3 08:01:52 CET 2003


Hi all,
 
 Sorry to interrupt you a little bit, I have a question about extending python problem, could anyone please help me to get some idea about it?
 
My question is that, I've created my Python own module ("pyArea"), a script file to call to the object and an application to call to the script file. Ok, let me show you the coding part~
 
 1. Python Script:
        import pyArea
        area = pyArea.CreateObject() # create a new object
 
        def Zoom()
                area.Zoom()
 
 2. Application:
        Inside the Message Loop:
                if (g_pDict)
                        pFunc = PyDict_GetItemString(g_pDict, "Zoom");
                if (PyCallable_Check(pFunc))
                {
                        PyObject *objResult = PyObject_CallFunction(pFunc, NULL);
                }
 
 Well, my question is that, after I call the function PyObject_CallFunction for “217” times the program just crash instantly( crashed in Python_d.dll : debug DLL “Msg: First-chance exception in rwtest.exe (PYTHON22_D.DLL): 0xC0000005: Access Violation.” ), I've try to make my own module as simple as possible but the result would be somehow the same as before. Have you ever encounter the same problem as I do? Or I didn't release the memory properly, so the Python Interpreter may still trap some memory inside? However, if I discard of using my module in Python Script(without calling pyArea.Zoom()), the function call seems working alright.
 
If you have any idea about it could you please help me~ thank you. =)
 
Ps. My OS is Windows 2000, Python version: 2.2.2
 
Kyle Lin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20030303/85bac707/attachment.htm>


More information about the Cplusplus-sig mailing list