A new Python header
Kirk McDonald
kirklin.mcdonald at gmail.com
Tue Jun 20 22:44:53 PDT 2006
Ha! I fixed it. It was a stupid problem. I managed to decrement a
reference count when I shouldn't have, causing Python to free()
something twice when the interpreter closed down.
Kirk McDonald wrote:
> // Note the new function template syntax. Ohh, ahh.
> typeof(Ptr) lazy_sys(alias Ptr, char[] name) () {
> if (Ptr is null) {
> PyObject* sys_modules = PyImport_GetModuleDict();
> Ptr = PyDict_GetItemString(sys_modules, name ~ \0);
This one right here; GetModuleDict returns a borrowed reference!
> Py_DECREF(sys_modules);
> assert (Ptr !is null,
> "python.d couldn't load " ~ name ~ " attribute!");
> }
> return Ptr;
> }
>
Anyway, the updated (and now working) header can be found at:
http://216.190.88.10/media/python.d
-Kirk McDonald
More information about the Digitalmars-d
mailing list