diff -ruN pyperl-1.0.1/dlhack.c pyperl-1.0.1-patched/dlhack.c --- pyperl-1.0.1/dlhack.c 2001-03-07 06:36:16.000000000 +1100 +++ pyperl-1.0.1-patched/dlhack.c 2003-09-05 17:12:12.000000000 +1000 @@ -1,50 +1,71 @@ #include #include +#include +#include +#include + /* This is a fake perl module that will look for the real thing ('perl2.so') * in sys.path and then load this one with the RTLD_GLOBAL set in order to * make the symbols available for extension modules that perl might load. */ -extern void initperl() -{ +extern void initperl() { void* handle; + char *error, *tmp; int i, npath, len; char buf[1024]; + int buflen = 1024; PyObject *path = PySys_GetObject("path"); if (path == NULL || !PyList_Check(path)) { - PyErr_SetString(PyExc_ImportError, - "sys.path must be a list of directory names"); - return; + PyErr_SetString(PyExc_ImportError, "sys.path must be a list of directory names"); + return; } npath = PyList_Size(path); - for (i = 0; i < npath; i++) { - PyObject *v = PyList_GetItem(path, i); - if (!PyString_Check(v)) - continue; - len = PyString_Size(v); - if (len + 10 >= sizeof(buf)) - continue; /* Too long */ - strcpy(buf, PyString_AsString(v)); - if (buf[0] != '/') - continue; /* Not absolute */ - if (strlen(buf) != len) - continue; /* v contains '\0' */ - strcpy(buf+len, "/perl2.so"); - - handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL); - if (handle) { - void (*f)() = dlsym(handle, "initperl2"); - if (f) { - f(); - } - else { - PyErr_SetString(PyExc_ImportError, "initperl2 entry point not found"); - } - return; + + for (i = 0; i < npath; i++) { + PyObject *v = PyList_GetItem(path, i); + if (!PyString_Check(v)) continue; + + len = PyString_Size(v); + if (len + 10 >= sizeof(buf)) { + continue; /* Too long */ + } + + strcpy(buf, PyString_AsString(v)); + if (buf[0] != '/') { + continue; /* Not absolute */ + } + + if (strlen(buf) != len) { + continue; /* v contains '\0' */ + } + + strcpy(buf+len, "/perl2.so"); + + /* only bother with dlopen()ing files that exist. 0 is success. */ + if (*buf && access (buf, F_OK | R_OK) == 0) { + handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL); + error = dlerror(); + if (!error && handle) { + void (*f)() = dlsym(handle, "initperl2"); + if (f) { + f(); + } else { + PyErr_SetString(PyExc_ImportError, "initperl2 entry point not found"); + } + return; + } + } } + + /* If we get to here, the return in the previous block was never reached. + * We must have a "terminal" error. */ + if (error != NULL) { + PyErr_SetString(PyExc_ImportError, error); + } else { + PyErr_SetString(PyExc_ImportError, "perl2.so not found"); } - PyErr_SetString(PyExc_ImportError, "perl2.so not found"); } diff -ruN pyperl-1.0.1/Python-Object/Object.xs pyperl-1.0.1-patched/Python-Object/Object.xs --- pyperl-1.0.1/Python-Object/Object.xs 2001-03-07 06:36:16.000000000 +1100 +++ pyperl-1.0.1-patched/Python-Object/Object.xs 2003-09-04 19:55:50.000000000 +1000 @@ -12,6 +12,11 @@ #include "../thrd_ctx.h" #include "../pyo.h" +#define SvOK_off(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ + SVf_IVisUV|SVf_UTF8), \ + SvOOK_off(sv)) + + /* so we can use different typemaps for borrowed/owned obj refs */ typedef PyObject NewPyObject; typedef PyObject NewPyObjectX; diff -ruN pyperl-1.0.1/svrv_object.c pyperl-1.0.1-patched/svrv_object.c --- pyperl-1.0.1/svrv_object.c 2001-03-07 06:36:16.000000000 +1100 +++ pyperl-1.0.1-patched/svrv_object.c 2003-09-08 15:15:22.000000000 +1000 @@ -492,7 +492,7 @@ diff = newlen - len; if (newlen && !AvREAL(av) && AvREIFY(av)) - av_reify(av); + Perl_av_reify(PERL_GET_THX, av); #ifdef SPLICE_DEBUG printf("splice(offset=%d, len=%d, diff=%d, after=%d, fill=%d, max=%d, pre=%d)\n", diff -ruN pyperl-1.0.1/try_perlapi.pl pyperl-1.0.1-patched/try_perlapi.pl --- pyperl-1.0.1/try_perlapi.pl 2001-03-07 06:36:16.000000000 +1100 +++ pyperl-1.0.1-patched/try_perlapi.pl 2003-09-08 15:12:11.000000000 +1000 @@ -16,6 +16,8 @@ print C < #include #include @@ -50,7 +52,7 @@ ENTER; SAVETMPS; - push_return(Nullop); + Perl_push_return(PERL_GET_THX, Nullop); PUSHBLOCK(cx, (CXt_EVAL|CXp_TRYBLOCK), PL_stack_sp); PUSHEVAL(cx, 0, 0); PL_eval_root = PL_op; @@ -71,7 +73,7 @@ POPBLOCK(cx,newpm); POPEVAL(cx); - pop_return(); + Perl_pop_return(PERL_GET_THX); PL_curpm = newpm; }