Connecting Tech Pros Worldwide Help | Site Map

Embedding Python - Freeing Python Objects Not Using Py_DECREF

Newbie
 
Join Date: Jan 2008
Posts: 2
#1: Jan 17 '08
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,

Junkode
Newbie
 
Join Date: Jan 2008
Posts: 2
#2: Jan 17 '08

re: Embedding Python - Freeing Python Objects Not Using Py_DECREF


I've been already answered on another forum:
There's also a Py_DecRef function in the API.

Sincerely,
Junkode.
Reply