Embedding Python - Freeing Python Objects Not Using Py_DECREF

yuri.feldman at gmail.com yuri.feldman at gmail.com
Thu Jan 17 07:14:38 EST 2008


Hello,

I'm embedding Python interpreter in a Win32 console application. I use
C++.

I would like to use the WinAPI LoadLibrary function to load the python
dll at runtime (followed by GetProcAddress calls), so that I have to
make no assumptions about the location of the dll.

However I can't use the macro Py_DECREF if I load the dll this way.

Is there a way to properly free python objects (specifically -
dictionaries created by PyDict_New() and the object returned by
PyRun_String()) not using Py_DECREF?

Alternatively, is there a way to include the python header - to make
the macro Py_DECREF available, but to be able to locate the python dll
whenever python is installed?

(The problem is that python may be installed anywhere, and the python
dll does not always appear in system folders - sometimes it is in the
python installation directory, thus it is unclear which targets to
specify to the linker to search for the dll).

I'd appreciate any help.
Thanks in advance,



More information about the Python-list mailing list