Mercurial > cpython-lru_cache-weakref
annotate Python/dynload_aix.c @ 79063:2bdc8c8ea42e
Issue #15977: Fix memory leak in Modules/_ssl.c when the function _set_npn_protocols() is called multiple times
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Thu, 20 Sep 2012 12:42:54 +0200 |
| parents | 257cbd2fac38 |
| children | c08bcf5302ec |
| 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 |
|
28383
f99cf9bfbbaf
Include Python.h first which defines _XOPEN_SOURCE
Neal Norwitz <nnorwitz@gmail.com>
parents:
26911
diff
changeset
|
4 #include "Python.h" |
|
f99cf9bfbbaf
Include Python.h first which defines _XOPEN_SOURCE
Neal Norwitz <nnorwitz@gmail.com>
parents:
26911
diff
changeset
|
5 #include "importdl.h" |
|
f99cf9bfbbaf
Include Python.h first which defines _XOPEN_SOURCE
Neal Norwitz <nnorwitz@gmail.com>
parents:
26911
diff
changeset
|
6 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
7 #include <ctype.h> /* for isdigit() */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
8 #include <errno.h> /* for global errno */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
9 #include <string.h> /* for strerror() */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
10 #include <stdlib.h> /* for malloc(), free() */ |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 #include <sys/ldr.h> |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 #ifdef AIX_GENUINE_CPLUSPLUS |
|
68018
34ae316318ef
Merged revisions 88430,88438,88440 via svnmerge from
Georg Brandl <georg@python.org>
parents:
61463
diff
changeset
|
15 #include <load.h> |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 #define aix_load loadAndInit |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 #else |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 #define aix_load load |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 #endif |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 |
|
13663
29da35543833
ANSIfy as many declarations as possible.
Thomas Wouters <thomas@python.org>
parents:
13658
diff
changeset
|
22 extern char *Py_GetProgramName(void); |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 typedef struct Module { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
25 struct Module *next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
26 void *entry; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 } Module, *ModulePtr; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 |
|
76754
257cbd2fac38
Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents:
76436
diff
changeset
|
29 const char *_PyImport_DynLoadFiletab[] = {".so", NULL}; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 static int |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
32 aix_getoldmodules(void **modlistptr) |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
34 register ModulePtr modptr, prevmodptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
35 register struct ld_info *ldiptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
36 register char *ldibuf; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
37 register int errflag, bufsize = 1024; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
38 register unsigned int offset; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
39 char *progname = Py_GetProgramName(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
40 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
41 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
42 -- Get the list of loaded modules into ld_info structures. |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
43 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
44 if ((ldibuf = malloc(bufsize)) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
45 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
46 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
47 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
48 while ((errflag = loadquery(L_GETINFO, ldibuf, bufsize)) == -1 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
49 && errno == ENOMEM) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
50 free(ldibuf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
51 bufsize += 1024; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
52 if ((ldibuf = malloc(bufsize)) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
53 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
54 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
55 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
56 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
57 if (errflag == -1) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
58 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
59 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
60 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
61 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
62 -- Make the modules list from the ld_info structures. |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
63 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
64 ldiptr = (struct ld_info *)ldibuf; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
65 prevmodptr = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
66 do { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
67 if (strstr(progname, ldiptr->ldinfo_filename) == NULL && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
68 strstr(ldiptr->ldinfo_filename, "python") == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
69 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
70 -- Extract only the modules belonging to the main |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
71 -- executable + those containing "python" as a |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
72 -- substring (like the "python[version]" binary or |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
73 -- "libpython[version].a" in case it's a shared lib). |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
74 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
75 offset = (unsigned int)ldiptr->ldinfo_next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
76 ldiptr = (struct ld_info *)((char*)ldiptr + offset); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
77 continue; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
78 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
79 if ((modptr = (ModulePtr)malloc(sizeof(Module))) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
80 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
81 while (*modlistptr) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
82 modptr = (ModulePtr)*modlistptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
83 *modlistptr = (void *)modptr->next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
84 free(modptr); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
85 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
86 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
87 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
88 modptr->entry = ldiptr->ldinfo_dataorg; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
89 modptr->next = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
90 if (prevmodptr == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
91 *modlistptr = (void *)modptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
92 else |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
93 prevmodptr->next = modptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
94 prevmodptr = modptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
95 offset = (unsigned int)ldiptr->ldinfo_next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
96 ldiptr = (struct ld_info *)((char*)ldiptr + offset); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
97 } while (offset); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
98 free(ldibuf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
99 return 0; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 } |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 static void |
|
14392
63d824679b28
Fix the char* vs. const char* mismatch for the argument of aix_loaderror()
Vladimir Marangozov <vladimir.marangozov@t-online.de>
parents:
14375
diff
changeset
|
104 aix_loaderror(const char *pathname) |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
107 char *message[1024], errbuf[1024]; |
|
76436
56aa4cda11a8
Issue #14599: Support ImportError.path on AIX and HPUX when loading
Brett Cannon <brett@python.org>
parents:
75059
diff
changeset
|
108 PyObject *pathname_ob = NULL; |
|
56aa4cda11a8
Issue #14599: Support ImportError.path on AIX and HPUX when loading
Brett Cannon <brett@python.org>
parents:
75059
diff
changeset
|
109 PyObject *errbuf_ob = NULL; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
110 register int i,j; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
112 struct errtab { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
113 int errNo; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
114 char *errstr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
115 } load_errtab[] = { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
116 {L_ERROR_TOOMANY, "too many errors, rest skipped."}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
117 {L_ERROR_NOLIB, "can't load library:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
118 {L_ERROR_UNDEF, "can't find symbol in library:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
119 {L_ERROR_RLDBAD, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
120 "RLD index out of range or bad relocation type:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
121 {L_ERROR_FORMAT, "not a valid, executable xcoff file:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
122 {L_ERROR_MEMBER, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
123 "file not an archive or does not contain requested member:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
124 {L_ERROR_TYPE, "symbol table mismatch:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
125 {L_ERROR_ALIGN, "text alignment in file is wrong."}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
126 {L_ERROR_SYSTEM, "System error:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
127 {L_ERROR_ERRNO, NULL} |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
128 }; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 #define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1) |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
132 PyOS_snprintf(errbuf, sizeof(errbuf), "from module %.200s ", pathname); |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
134 if (!loadquery(L_GETMESSAGES, &message[0], sizeof(message))) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
135 ERRBUF_APPEND(strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
136 ERRBUF_APPEND("\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
137 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
138 for(i = 0; message[i] && *message[i]; i++) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
139 int nerr = atoi(message[i]); |
|
72510
b534b56379cb
Use the new Py_ARRAY_LENGTH macro
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68108
diff
changeset
|
140 for (j=0; j < Py_ARRAY_LENGTH(load_errtab); j++) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
141 if (nerr == load_errtab[j].errNo && load_errtab[j].errstr) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
142 ERRBUF_APPEND(load_errtab[j].errstr); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
143 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
144 while (isdigit(Py_CHARMASK(*message[i]))) message[i]++ ; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
145 ERRBUF_APPEND(message[i]); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
146 ERRBUF_APPEND("\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
147 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
148 errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */ |
|
76436
56aa4cda11a8
Issue #14599: Support ImportError.path on AIX and HPUX when loading
Brett Cannon <brett@python.org>
parents:
75059
diff
changeset
|
149 pathname_ob = PyUnicode_FromString(pathname); |
|
56aa4cda11a8
Issue #14599: Support ImportError.path on AIX and HPUX when loading
Brett Cannon <brett@python.org>
parents:
75059
diff
changeset
|
150 errbuf_ob = PyUnicode_FromString(errbuf); |
|
56aa4cda11a8
Issue #14599: Support ImportError.path on AIX and HPUX when loading
Brett Cannon <brett@python.org>
parents:
75059
diff
changeset
|
151 PyErr_SetImportError(errbuf_ob, NULL, pathname); |
|
56aa4cda11a8
Issue #14599: Support ImportError.path on AIX and HPUX when loading
Brett Cannon <brett@python.org>
parents:
75059
diff
changeset
|
152 Py_DECREF(pathname_ob); |
|
56aa4cda11a8
Issue #14599: Support ImportError.path on AIX and HPUX when loading
Brett Cannon <brett@python.org>
parents:
75059
diff
changeset
|
153 Py_DECREF(errbuf_ob); |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
154 return; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 } |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 |
|
68108
0874698b1201
Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68018
diff
changeset
|
158 dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
159 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
|
160 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
161 dl_funcptr p; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
163 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
164 -- Invoke load() with L_NOAUTODEFER leaving the imported symbols |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
165 -- of the shared module unresolved. Thus we have to resolve them |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
166 -- explicitly with loadbind. The new module is loaded, then we |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
167 -- resolve its symbols using the list of already loaded modules |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
168 -- (only those that belong to the python executable). Get these |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
169 -- with loadquery(L_GETINFO). |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
170 */ |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
172 static void *staticmodlistptr = NULL; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
174 if (!staticmodlistptr) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
175 if (aix_getoldmodules(&staticmodlistptr) == -1) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
176 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
177 p = (dl_funcptr) aix_load((char *)pathname, L_NOAUTODEFER, 0); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
178 if (p == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
179 aix_loaderror(pathname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
180 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
181 } |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
183 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
|
184 } |
