Criteria for 1.0 (was: Re: If D becomes a failure, what's the key reason, do you think?)
Kirk McDonald
kirklin.mcdonald at gmail.com
Thu Jul 13 15:56:59 PDT 2006
Kirk McDonald wrote:
> When loaded by a D module, it works just fine. However, the following
> promptly causes Python to segfault when imported:
>
With these modifications, it works:
> [testpy.d]
> import python;
> import std.stdio;
>
> PyMethodDef testpy_methods[] = [
> { null, null, 0, null }
> ];
>
> class A {
> ~this() { writefln("A.~this()"); }
> void foo() { writefln("A.foo()"); }
> }
>
extern(C) {
void gc_init();
void gc_term();
}
> extern(C)
> export void inittestpy() {
gc_init();
> Py_InitModule("testpy", testpy_methods);
> A a = new A;
> a.foo();
> }
// The standard Linux dynamic library finalization function
extern(C)
void _fini() {
gc_term();
}
It must be compiled with the -nostartfiles switch. When imported:
>>> import testpy
A.foo()
>>> ^D
A.~this()
$
However, I saw some notes about _fini being obsolete and possibly
dangerous. Anyone more experienced with Linux coding want to comment?
--
Kirk McDonald
Pyd: Wrapping Python with D
http://dsource.org/projects/pyd/wiki
More information about the Digitalmars-d
mailing list