Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1e61249

Browse files
committed
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
1 parent 71bd363 commit 1e61249

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

Python/importdl.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5555
/* Configure dynamic linking */
5656

5757
#ifdef __hpux
58+
#ifndef hpux
5859
#define hpux
5960
#endif
61+
#endif
6062

6163
#ifdef hpux
6264
#define DYNAMIC_LINK
@@ -106,20 +108,28 @@ typedef FARPROC dl_funcptr;
106108
#define USE_DL
107109
#endif
108110

111+
#ifdef __powerc
112+
#define USE_MAC_DYNAMIC_LOADING
113+
#endif
114+
109115
#ifdef __CFM68K__
110116
#define USE_MAC_DYNAMIC_LOADING
111117
#endif
112118

113119
#ifdef USE_MAC_DYNAMIC_LOADING
114120
#define DYNAMIC_LINK
115121
#define SHORT_EXT ".slb"
116-
#define LONG_EXT "module.slb"
122+
#ifdef __CFM68K__
123+
#define LONG_EXT ".CFM68K.slb"
124+
#else
125+
#define LONG_EXT ".ppc.slb"
126+
#endif
117127
#ifndef _DL_FUNCPTR_DEFINED
118128
typedef void (*dl_funcptr)();
119129
#endif
120130
#endif
121131

122-
#if !defined(DYNAMIC_LINK) && defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN)
132+
#if !defined(DYNAMIC_LINK) && defined(HAVE_DLFCN_H) && (defined(HAVE_DLOPEN) || defined(M_UNIX))
123133
#define DYNAMIC_LINK
124134
#define USE_SHLIB
125135
#endif
@@ -232,7 +242,7 @@ load_dynamic_module(name, pathname, fp)
232242
err_setstr(ImportError, "dynamically linked modules not supported");
233243
return NULL;
234244
#else
235-
object *m;
245+
object *m, *d, *s;
236246
char funcname[258];
237247
dl_funcptr p = NULL;
238248
#ifdef USE_SHLIB
@@ -507,6 +517,12 @@ load_dynamic_module(name, pathname, fp)
507517
"dynamic module not initialized properly");
508518
return NULL;
509519
}
520+
/* Remember the filename as the __file__ attribute */
521+
d = getmoduledict(m);
522+
s = newstringobject(pathname);
523+
if (s == NULL || dictinsert(d, "__file__", s) != 0)
524+
err_clear(); /* Not important enough to report */
525+
XDECREF(s);
510526
if (verbose)
511527
fprintf(stderr,
512528
"import %s # dynamically loaded from %s\n",

0 commit comments

Comments
 (0)