Kaydet (Commit) 1e612490 authored tarafından Guido van Rossum's avatar Guido van Rossum

Many little fixes:

- support for SCO_SV dynamic loading
- on Mac, auto-detect dynamic loading by __CFM68K__ or _powerc)
- on Mac, long shared library extension is .cfm68k.slb or .ppc.slb
- on hp, don't redefine hpux if already defined
- add __file__ property to successfully loaded module
üst 71bd363d
...@@ -55,8 +55,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -55,8 +55,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Configure dynamic linking */ /* Configure dynamic linking */
#ifdef __hpux #ifdef __hpux
#ifndef hpux
#define hpux #define hpux
#endif #endif
#endif
#ifdef hpux #ifdef hpux
#define DYNAMIC_LINK #define DYNAMIC_LINK
...@@ -106,6 +108,10 @@ typedef FARPROC dl_funcptr; ...@@ -106,6 +108,10 @@ typedef FARPROC dl_funcptr;
#define USE_DL #define USE_DL
#endif #endif
#ifdef __powerc
#define USE_MAC_DYNAMIC_LOADING
#endif
#ifdef __CFM68K__ #ifdef __CFM68K__
#define USE_MAC_DYNAMIC_LOADING #define USE_MAC_DYNAMIC_LOADING
#endif #endif
...@@ -113,13 +119,17 @@ typedef FARPROC dl_funcptr; ...@@ -113,13 +119,17 @@ typedef FARPROC dl_funcptr;
#ifdef USE_MAC_DYNAMIC_LOADING #ifdef USE_MAC_DYNAMIC_LOADING
#define DYNAMIC_LINK #define DYNAMIC_LINK
#define SHORT_EXT ".slb" #define SHORT_EXT ".slb"
#define LONG_EXT "module.slb" #ifdef __CFM68K__
#define LONG_EXT ".CFM68K.slb"
#else
#define LONG_EXT ".ppc.slb"
#endif
#ifndef _DL_FUNCPTR_DEFINED #ifndef _DL_FUNCPTR_DEFINED
typedef void (*dl_funcptr)(); typedef void (*dl_funcptr)();
#endif #endif
#endif #endif
#if !defined(DYNAMIC_LINK) && defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN) #if !defined(DYNAMIC_LINK) && defined(HAVE_DLFCN_H) && (defined(HAVE_DLOPEN) || defined(M_UNIX))
#define DYNAMIC_LINK #define DYNAMIC_LINK
#define USE_SHLIB #define USE_SHLIB
#endif #endif
...@@ -232,7 +242,7 @@ load_dynamic_module(name, pathname, fp) ...@@ -232,7 +242,7 @@ load_dynamic_module(name, pathname, fp)
err_setstr(ImportError, "dynamically linked modules not supported"); err_setstr(ImportError, "dynamically linked modules not supported");
return NULL; return NULL;
#else #else
object *m; object *m, *d, *s;
char funcname[258]; char funcname[258];
dl_funcptr p = NULL; dl_funcptr p = NULL;
#ifdef USE_SHLIB #ifdef USE_SHLIB
...@@ -507,6 +517,12 @@ load_dynamic_module(name, pathname, fp) ...@@ -507,6 +517,12 @@ load_dynamic_module(name, pathname, fp)
"dynamic module not initialized properly"); "dynamic module not initialized properly");
return NULL; return NULL;
} }
/* Remember the filename as the __file__ attribute */
d = getmoduledict(m);
s = newstringobject(pathname);
if (s == NULL || dictinsert(d, "__file__", s) != 0)
err_clear(); /* Not important enough to report */
XDECREF(s);
if (verbose) if (verbose)
fprintf(stderr, fprintf(stderr,
"import %s # dynamically loaded from %s\n", "import %s # dynamically loaded from %s\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment