[Python.NET] Decref in RunString

Nils Becker nilsc.becker at gmail.com
Mon Jun 8 08:52:00 CEST 2015


Hello there,

I have a quick question concerning the "RunString(string code, IntPtr
globals, IntPtr locals)" routine. In it the parameter "locals" is
decref'ed. Maybe I am missing something (could be, I do not know much about
reference counting), but should something which the user passes be
decref'ed?

My use case is the following: I embed python into C# and have a stateful
wrapper around PythonEngine which manages a global and local dictionary.
Therefore, I need the local dictionary I pass to RunString to be accessable
(and sane) after the call.
I noticed that locals contained random content after I called RunString and
created new variables in the code.
After I removed the Decref call in RunString, it seems to work as I would
expect it to.

Cheers
Nils
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20150608/ae29e1fe/attachment-0001.html>


More information about the PythonDotNet mailing list