annotate Python/dynload_os2.c @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents fd25030223b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11599
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
1
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* Support for dynamic loading of extension modules */
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 #define INCL_DOSERRORS
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 #define INCL_DOSMODULEMGR
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 #include <os2.h>
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 #include "Python.h"
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 #include "importdl.h"
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 const struct filedescr _PyImport_DynLoadFiletab[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
13 {".pyd", "rb", C_EXTENSION},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
14 {".dll", "rb", C_EXTENSION},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
15 {0, 0}
11599
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 };
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
11618
528559a0b2f2 Cleanup patches from Greg Stein:
Guido van Rossum <guido@python.org>
parents: 11599
diff changeset
18 dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
19 const char *pathname, FILE *fp)
11599
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
21 dl_funcptr p;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
22 APIRET rc;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
23 HMODULE hDLL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
24 char failreason[256];
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
25 char funcname[258];
11599
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
26
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
27 rc = DosLoadModule(failreason,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
28 sizeof(failreason),
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
29 pathname,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
30 &hDLL);
11599
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
32 if (rc != NO_ERROR) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
33 char errBuf[256];
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
34 PyOS_snprintf(errBuf, sizeof(errBuf),
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
35 "DLL load failed, rc = %d: %.200s",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
36 rc, failreason);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
37 PyErr_SetString(PyExc_ImportError, errBuf);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
38 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
39 }
11599
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
40
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
41 PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
42 rc = DosQueryProcAddr(hDLL, 0L, funcname, &p);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
43 if (rc != NO_ERROR)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
44 p = NULL; /* Signify Failure to Acquire Entrypoint */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 21077
diff changeset
45 return p;
11599
78fe87ce0ded The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 }