Mercurial > cpython-lru_cache-weakref
annotate Python/dynload_aix.c @ 73323:dad02a080bbc
Improve byte-compilation in packaging to be independent of -O or -B.
The code I fixed to comply with PEP 3147 still had one bug: When run
under python -O, some paths for pyc files would be pyo, because I called
imp.cache_from_source without explicit debug_override argument in some
places, and under -O that would return .pyo (this is well explained in
the imp docs). Now all code (util.byte_compile, build_py, install_lib)
can create .pyo files according to options given by users,
without interference from the calling Python’s own optimize mode.
On a related topic, I also removed the code that prevented byte
compilation under python -B. The rationale is that packaging gives
control over the creation of pyc files to the user with its own explicit
option, and the behavior should not be changed if the calling Python
happens to run with -B for whatever reason. I will argue that this is a
bug fix and ask to be allowed to backport this change to distutils.
Finally, I moved one nugget of information about the --compile and
--optimize options from the source into the doc. It clears up a
misunderstanding that I (and maybe other people) had.
| author | Éric Araujo <merwok@netwok.org> |
|---|---|
| date | Thu, 03 Nov 2011 05:08:28 +0100 |
| parents | b534b56379cb |
| children | 42f61304f77d |
| 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 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 const struct filedescr _PyImport_DynLoadFiletab[] = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
30 {".so", "rb", C_EXTENSION}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
31 {"module.so", "rb", C_EXTENSION}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
32 {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
|
33 }; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 static int |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
36 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
|
37 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
38 register ModulePtr modptr, prevmodptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
39 register struct ld_info *ldiptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
40 register char *ldibuf; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
41 register int errflag, bufsize = 1024; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
42 register unsigned int offset; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
43 char *progname = Py_GetProgramName(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
44 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
45 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
46 -- 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
|
47 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
48 if ((ldibuf = malloc(bufsize)) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
49 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
50 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
51 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
52 while ((errflag = loadquery(L_GETINFO, ldibuf, bufsize)) == -1 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
53 && errno == ENOMEM) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
54 free(ldibuf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
55 bufsize += 1024; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
56 if ((ldibuf = malloc(bufsize)) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
57 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
58 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
59 } |
|
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 if (errflag == -1) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
62 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
63 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
64 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
65 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
66 -- 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
|
67 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
68 ldiptr = (struct ld_info *)ldibuf; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
69 prevmodptr = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
70 do { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
71 if (strstr(progname, ldiptr->ldinfo_filename) == NULL && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
72 strstr(ldiptr->ldinfo_filename, "python") == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
73 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
74 -- Extract only the modules belonging to the main |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
75 -- executable + those containing "python" as a |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
76 -- substring (like the "python[version]" binary or |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
77 -- "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
|
78 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
79 offset = (unsigned int)ldiptr->ldinfo_next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
80 ldiptr = (struct ld_info *)((char*)ldiptr + offset); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
81 continue; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
82 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
83 if ((modptr = (ModulePtr)malloc(sizeof(Module))) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
84 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
85 while (*modlistptr) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
86 modptr = (ModulePtr)*modlistptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
87 *modlistptr = (void *)modptr->next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
88 free(modptr); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
89 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
90 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
91 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
92 modptr->entry = ldiptr->ldinfo_dataorg; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
93 modptr->next = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
94 if (prevmodptr == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
95 *modlistptr = (void *)modptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
96 else |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
97 prevmodptr->next = modptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
98 prevmodptr = modptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
99 offset = (unsigned int)ldiptr->ldinfo_next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
100 ldiptr = (struct ld_info *)((char*)ldiptr + offset); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
101 } while (offset); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
102 free(ldibuf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
103 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
|
104 } |
|
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 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 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
|
108 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
|
109 { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
111 char *message[1024], errbuf[1024]; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
112 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
|
113 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
114 struct errtab { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
115 int errNo; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
116 char *errstr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
117 } load_errtab[] = { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
118 {L_ERROR_TOOMANY, "too many errors, rest skipped."}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
119 {L_ERROR_NOLIB, "can't load library:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
120 {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
|
121 {L_ERROR_RLDBAD, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
122 "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
|
123 {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
|
124 {L_ERROR_MEMBER, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
125 "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
|
126 {L_ERROR_TYPE, "symbol table mismatch:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
127 {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
|
128 {L_ERROR_SYSTEM, "System error:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
129 {L_ERROR_ERRNO, NULL} |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
130 }; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 #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
|
133 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
134 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
|
135 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
136 if (!loadquery(L_GETMESSAGES, &message[0], sizeof(message))) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
137 ERRBUF_APPEND(strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
138 ERRBUF_APPEND("\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
139 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
140 for(i = 0; message[i] && *message[i]; i++) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
141 int nerr = atoi(message[i]); |
|
72510
b534b56379cb
Use the new Py_ARRAY_LENGTH macro
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68108
diff
changeset
|
142 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
|
143 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
|
144 ERRBUF_APPEND(load_errtab[j].errstr); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
145 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
146 while (isdigit(Py_CHARMASK(*message[i]))) message[i]++ ; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
147 ERRBUF_APPEND(message[i]); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
148 ERRBUF_APPEND("\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
149 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
150 errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
151 PyErr_SetString(PyExc_ImportError, errbuf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
152 return; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
153 } |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
154 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 |
|
68108
0874698b1201
Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68018
diff
changeset
|
156 dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
157 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
|
158 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
159 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
|
160 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
161 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
162 -- 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
|
163 -- 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
|
164 -- 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
|
165 -- 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
|
166 -- (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
|
167 -- with loadquery(L_GETINFO). |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
168 */ |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
170 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
|
171 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
172 if (!staticmodlistptr) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
173 if (aix_getoldmodules(&staticmodlistptr) == -1) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
174 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
175 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
|
176 if (p == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
177 aix_loaderror(pathname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
178 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
179 } |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
181 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
|
182 } |
