Mercurial > cpython-lru_cache-weakref
annotate Python/dynload_aix.c @ 87690:66c1c9f32567 default tip
Add use_weakref option to functools.lru_cache
The use_weakref option makes lru_cache create weak references to the function
arguments when creating the cache key, which prevents them from staying in the
memory forever even after all other references to them are gone.
This is a proof of concept for http://bugs.python.org/issue19859
| author | Radomir Dopieralski <devel@sheep.art.pl> |
|---|---|
| date | Tue, 03 Dec 2013 16:02:48 +0100 |
| parents | e7f6cef7a4cc |
| children |
| 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 <errno.h> /* for global errno */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
8 #include <string.h> /* for strerror() */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
9 #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
|
10 #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
|
11 |
|
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 #ifdef AIX_GENUINE_CPLUSPLUS |
|
68018
34ae316318ef
Merged revisions 88430,88438,88440 via svnmerge from
Georg Brandl <georg@python.org>
parents:
61463
diff
changeset
|
14 #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
|
15 #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
|
16 #else |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 #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
|
18 #endif |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 |
|
13663
29da35543833
ANSIfy as many declarations as possible.
Thomas Wouters <thomas@python.org>
parents:
13658
diff
changeset
|
21 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
|
22 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 typedef struct Module { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
24 struct Module *next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
25 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
|
26 } Module, *ModulePtr; |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 |
|
76754
257cbd2fac38
Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py.
Brett Cannon <brett@python.org>
parents:
76436
diff
changeset
|
28 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
|
29 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 static int |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13620
diff
changeset
|
31 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
|
32 { |
|
85157
e7f6cef7a4cc
Issue #18722: Remove uses of the "register" keyword in C code.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82111
diff
changeset
|
33 ModulePtr modptr, prevmodptr; |
|
e7f6cef7a4cc
Issue #18722: Remove uses of the "register" keyword in C code.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82111
diff
changeset
|
34 struct ld_info *ldiptr; |
|
e7f6cef7a4cc
Issue #18722: Remove uses of the "register" keyword in C code.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82111
diff
changeset
|
35 char *ldibuf; |
|
e7f6cef7a4cc
Issue #18722: Remove uses of the "register" keyword in C code.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82111
diff
changeset
|
36 int errflag, bufsize = 1024; |
|
e7f6cef7a4cc
Issue #18722: Remove uses of the "register" keyword in C code.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82111
diff
changeset
|
37 unsigned int offset; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
38 char *progname = Py_GetProgramName(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
39 |
|
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 -- 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
|
42 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
43 if ((ldibuf = malloc(bufsize)) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
44 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
45 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
46 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
47 while ((errflag = loadquery(L_GETINFO, ldibuf, bufsize)) == -1 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
48 && errno == ENOMEM) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
49 free(ldibuf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
50 bufsize += 1024; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
51 if ((ldibuf = malloc(bufsize)) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
52 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
53 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
54 } |
|
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 if (errflag == -1) { |
|
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 -- 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
|
62 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
63 ldiptr = (struct ld_info *)ldibuf; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
64 prevmodptr = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
65 do { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
66 if (strstr(progname, ldiptr->ldinfo_filename) == NULL && |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
67 strstr(ldiptr->ldinfo_filename, "python") == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
68 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
69 -- Extract only the modules belonging to the main |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
70 -- executable + those containing "python" as a |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
71 -- substring (like the "python[version]" binary or |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
72 -- "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
|
73 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
74 offset = (unsigned int)ldiptr->ldinfo_next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
75 ldiptr = (struct ld_info *)((char*)ldiptr + offset); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
76 continue; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
77 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
78 if ((modptr = (ModulePtr)malloc(sizeof(Module))) == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
79 PyErr_SetString(PyExc_ImportError, strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
80 while (*modlistptr) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
81 modptr = (ModulePtr)*modlistptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
82 *modlistptr = (void *)modptr->next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
83 free(modptr); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
84 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
85 return -1; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
86 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
87 modptr->entry = ldiptr->ldinfo_dataorg; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
88 modptr->next = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
89 if (prevmodptr == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
90 *modlistptr = (void *)modptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
91 else |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
92 prevmodptr->next = modptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
93 prevmodptr = modptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
94 offset = (unsigned int)ldiptr->ldinfo_next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
95 ldiptr = (struct ld_info *)((char*)ldiptr + offset); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
96 } while (offset); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
97 free(ldibuf); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
98 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
|
99 } |
|
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 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
|
103 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
|
104 { |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
106 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
|
107 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
|
108 PyObject *errbuf_ob = NULL; |
|
85157
e7f6cef7a4cc
Issue #18722: Remove uses of the "register" keyword in C code.
Antoine Pitrou <solipsis@pitrou.net>
parents:
82111
diff
changeset
|
109 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
|
110 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
111 struct errtab { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
112 int errNo; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
113 char *errstr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
114 } load_errtab[] = { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
115 {L_ERROR_TOOMANY, "too many errors, rest skipped."}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
116 {L_ERROR_NOLIB, "can't load library:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
117 {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
|
118 {L_ERROR_RLDBAD, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
119 "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
|
120 {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
|
121 {L_ERROR_MEMBER, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
122 "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
|
123 {L_ERROR_TYPE, "symbol table mismatch:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
124 {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
|
125 {L_ERROR_SYSTEM, "System error:"}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
126 {L_ERROR_ERRNO, NULL} |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
127 }; |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 #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
|
130 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
131 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
|
132 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
133 if (!loadquery(L_GETMESSAGES, &message[0], sizeof(message))) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
134 ERRBUF_APPEND(strerror(errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
135 ERRBUF_APPEND("\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
136 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
137 for(i = 0; message[i] && *message[i]; i++) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
138 int nerr = atoi(message[i]); |
|
72510
b534b56379cb
Use the new Py_ARRAY_LENGTH macro
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68108
diff
changeset
|
139 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
|
140 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
|
141 ERRBUF_APPEND(load_errtab[j].errstr); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
142 } |
|
82110
38830281d43b
Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter.
Antoine Pitrou <solipsis@pitrou.net>
parents:
68018
diff
changeset
|
143 while (Py_ISDIGIT(Py_CHARMASK(*message[i]))) message[i]++ ; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
144 ERRBUF_APPEND(message[i]); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
145 ERRBUF_APPEND("\n"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
146 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 Py_DECREF(errbuf_ob); |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
153 return; |
|
11599
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 |
|
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 |
|
68108
0874698b1201
Issue #3080: Remove unused argument of _PyImport_GetDynLoadFunc()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
68018
diff
changeset
|
157 dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
158 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
|
159 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
160 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
|
161 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
162 /* |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
163 -- 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
|
164 -- 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
|
165 -- 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
|
166 -- 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
|
167 -- (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
|
168 -- with loadquery(L_GETINFO). |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
169 */ |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
171 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
|
172 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
173 if (!staticmodlistptr) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
174 if (aix_getoldmodules(&staticmodlistptr) == -1) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
175 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
176 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
|
177 if (p == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
178 aix_loaderror(pathname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
179 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
180 } |
|
11599
78fe87ce0ded
The old platform-specific contents of importdl.c, broken down into one
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
36090
diff
changeset
|
182 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
|
183 } |
