Mercurial > cpython-lru_cache-weakref
annotate Modules/dlmodule.c @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | 91dd223829c6 |
| children | a9e06ffaf7fb |
| rev | line source |
|---|---|
| 1650 | 1 |
| 2 /* dl module */ | |
| 3 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
4 #include "Python.h" |
| 1650 | 5 |
| 6 #include <dlfcn.h> | |
| 7 | |
| 8 #ifndef RTLD_LAZY | |
| 9 #define RTLD_LAZY 1 | |
| 10 #endif | |
| 11 | |
|
13709
4e2aaf1e722a
Use 'void' directly instead of the ANY #define, now that all code is ANSI C.
Thomas Wouters <thomas@python.org>
parents:
13651
diff
changeset
|
12 typedef void *PyUnivPtr; |
| 1650 | 13 typedef struct { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
14 PyObject_HEAD |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
15 PyUnivPtr *dl_handle; |
| 1650 | 16 } dlobject; |
| 17 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
18 staticforward PyTypeObject Dltype; |
| 1650 | 19 |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
20 static PyObject *Dlerror; |
| 1650 | 21 |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
22 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
23 newdlobject(PyUnivPtr *handle) |
| 1650 | 24 { |
| 25 dlobject *xp; | |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
6889
diff
changeset
|
26 xp = PyObject_New(dlobject, &Dltype); |
| 1650 | 27 if (xp == NULL) |
| 28 return NULL; | |
| 29 xp->dl_handle = handle; | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
30 return (PyObject *)xp; |
| 1650 | 31 } |
| 32 | |
| 33 static void | |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
34 dl_dealloc(dlobject *xp) |
| 1650 | 35 { |
| 36 if (xp->dl_handle != NULL) | |
| 37 dlclose(xp->dl_handle); | |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
6889
diff
changeset
|
38 PyObject_Del(xp); |
| 1650 | 39 } |
| 40 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
41 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
42 dl_close(dlobject *xp, PyObject *args) |
| 1650 | 43 { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
44 if (!PyArg_Parse(args, "")) |
| 1650 | 45 return NULL; |
| 46 if (xp->dl_handle != NULL) { | |
| 47 dlclose(xp->dl_handle); | |
| 48 xp->dl_handle = NULL; | |
| 49 } | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
50 Py_INCREF(Py_None); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
51 return Py_None; |
| 1650 | 52 } |
| 53 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
54 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
55 dl_sym(dlobject *xp, PyObject *args) |
| 1650 | 56 { |
| 57 char *name; | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
58 PyUnivPtr *func; |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
59 if (!PyArg_Parse(args, "s", &name)) |
| 1650 | 60 return NULL; |
| 61 func = dlsym(xp->dl_handle, name); | |
| 62 if (func == NULL) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
63 Py_INCREF(Py_None); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
64 return Py_None; |
| 1650 | 65 } |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
66 return PyInt_FromLong((long)func); |
| 1650 | 67 } |
| 68 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
69 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
70 dl_call(dlobject *xp, PyObject *args) |
| 1650 | 71 { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
72 PyObject *name; |
|
15157
459232a9b804
Remove one more gcc -Wall warning.
Fred Drake <fdrake@acm.org>
parents:
14542
diff
changeset
|
73 long (*func)(long, long, long, long, long, |
|
459232a9b804
Remove one more gcc -Wall warning.
Fred Drake <fdrake@acm.org>
parents:
14542
diff
changeset
|
74 long, long, long, long, long); |
| 1650 | 75 long alist[10]; |
| 76 long res; | |
| 77 int i; | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
78 int n = PyTuple_Size(args); |
| 1650 | 79 if (n < 1) { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
80 PyErr_SetString(PyExc_TypeError, "at least a name is needed"); |
| 1650 | 81 return NULL; |
| 82 } | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
83 name = PyTuple_GetItem(args, 0); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
84 if (!PyString_Check(name)) { |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
85 PyErr_SetString(PyExc_TypeError, |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
86 "function name must be a string"); |
| 1650 | 87 return NULL; |
| 88 } | |
|
16735
9f86cba4766b
Patch #103926: fix two warnings from Tru64's compiler
Andrew M. Kuchling <amk@amk.ca>
parents:
15157
diff
changeset
|
89 func = (long (*)(long, long, long, long, long, |
|
9f86cba4766b
Patch #103926: fix two warnings from Tru64's compiler
Andrew M. Kuchling <amk@amk.ca>
parents:
15157
diff
changeset
|
90 long, long, long, long, long)) |
|
9f86cba4766b
Patch #103926: fix two warnings from Tru64's compiler
Andrew M. Kuchling <amk@amk.ca>
parents:
15157
diff
changeset
|
91 dlsym(xp->dl_handle, PyString_AsString(name)); |
| 1650 | 92 if (func == NULL) { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
93 PyErr_SetString(PyExc_ValueError, dlerror()); |
| 1650 | 94 return NULL; |
| 95 } | |
| 96 if (n-1 > 10) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
97 PyErr_SetString(PyExc_TypeError, |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
98 "too many arguments (max 10)"); |
| 1650 | 99 return NULL; |
| 100 } | |
| 101 for (i = 1; i < n; i++) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
102 PyObject *v = PyTuple_GetItem(args, i); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
103 if (PyInt_Check(v)) |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
104 alist[i-1] = PyInt_AsLong(v); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
105 else if (PyString_Check(v)) |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
106 alist[i-1] = (long)PyString_AsString(v); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
107 else if (v == Py_None) |
| 1650 | 108 alist[i-1] = (long) ((char *)NULL); |
| 109 else { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
110 PyErr_SetString(PyExc_TypeError, |
| 1650 | 111 "arguments must be int, string or None"); |
| 112 return NULL; | |
| 113 } | |
| 114 } | |
| 115 for (; i <= 10; i++) | |
| 116 alist[i-1] = 0; | |
| 117 res = (*func)(alist[0], alist[1], alist[2], alist[3], alist[4], | |
| 118 alist[5], alist[6], alist[7], alist[8], alist[9]); | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
119 return PyInt_FromLong(res); |
| 1650 | 120 } |
| 121 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
122 static PyMethodDef dlobject_methods[] = { |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
123 {"call", (PyCFunction)dl_call, 1 /* varargs */}, |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
124 {"sym", (PyCFunction)dl_sym}, |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
125 {"close", (PyCFunction)dl_close}, |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
126 {NULL, NULL} /* Sentinel */ |
| 1650 | 127 }; |
| 128 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
129 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
130 dl_getattr(dlobject *xp, char *name) |
| 1650 | 131 { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
132 return Py_FindMethod(dlobject_methods, (PyObject *)xp, name); |
| 1650 | 133 } |
| 134 | |
| 135 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
136 static PyTypeObject Dltype = { |
|
16804
8156879fe60d
Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents:
16735
diff
changeset
|
137 PyObject_HEAD_INIT(NULL) |
| 1650 | 138 0, /*ob_size*/ |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
16804
diff
changeset
|
139 "dl.dl", /*tp_name*/ |
| 1650 | 140 sizeof(dlobject), /*tp_basicsize*/ |
| 141 0, /*tp_itemsize*/ | |
| 142 /* methods */ | |
| 143 (destructor)dl_dealloc, /*tp_dealloc*/ | |
| 144 0, /*tp_print*/ | |
| 145 (getattrfunc)dl_getattr,/*tp_getattr*/ | |
| 146 0, /*tp_setattr*/ | |
| 147 0, /*tp_compare*/ | |
| 148 0, /*tp_repr*/ | |
| 149 0, /*tp_as_number*/ | |
| 150 0, /*tp_as_sequence*/ | |
| 151 0, /*tp_as_mapping*/ | |
| 152 0, /*tp_hash*/ | |
| 153 }; | |
| 154 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
155 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
156 dl_open(PyObject *self, PyObject *args) |
| 1650 | 157 { |
| 158 char *name; | |
| 159 int mode; | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
160 PyUnivPtr *handle; |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
161 if (PyArg_Parse(args, "z", &name)) |
| 1650 | 162 mode = RTLD_LAZY; |
| 163 else { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
164 PyErr_Clear(); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
165 if (!PyArg_Parse(args, "(zi)", &name, &mode)) |
| 1650 | 166 return NULL; |
| 167 #ifndef RTLD_NOW | |
| 168 if (mode != RTLD_LAZY) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
169 PyErr_SetString(PyExc_ValueError, "mode must be 1"); |
| 1650 | 170 return NULL; |
| 171 } | |
| 172 #endif | |
| 173 } | |
| 174 handle = dlopen(name, mode); | |
| 175 if (handle == NULL) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
176 PyErr_SetString(Dlerror, dlerror()); |
| 1650 | 177 return NULL; |
| 178 } | |
| 179 return newdlobject(handle); | |
| 180 } | |
| 181 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
182 static PyMethodDef dl_methods[] = { |
| 1650 | 183 {"open", dl_open}, |
| 184 {NULL, NULL} /* sentinel */ | |
| 185 }; | |
| 186 | |
|
14542
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
187 /* From socketmodule.c |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
188 * Convenience routine to export an integer value. |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
189 * |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
190 * Errors are silently ignored, for better or for worse... |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
191 */ |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
192 static void |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
193 insint(PyObject *d, char *name, int value) |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
194 { |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
195 PyObject *v = PyInt_FromLong((long) value); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
196 if (!v || PyDict_SetItemString(d, name, v)) |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
197 PyErr_Clear(); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
198 |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
199 Py_XDECREF(v); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
200 } |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
201 |
|
16804
8156879fe60d
Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents:
16735
diff
changeset
|
202 DL_EXPORT(void) |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13499
diff
changeset
|
203 initdl(void) |
| 1650 | 204 { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
205 PyObject *m, *d, *x; |
| 1650 | 206 |
| 207 if (sizeof(int) != sizeof(long) || | |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
4725
diff
changeset
|
208 sizeof(long) != sizeof(char *)) { |
|
6889
c7bab73e63c6
Fix mysterious undetected error -- call to non-existant Py_Err_SetStr()
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
209 PyErr_SetString(PyExc_SystemError, |
| 1650 | 210 "module dl requires sizeof(int) == sizeof(long) == sizeof(char*)"); |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
4725
diff
changeset
|
211 return; |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
4725
diff
changeset
|
212 } |
| 1650 | 213 |
|
16804
8156879fe60d
Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents:
16735
diff
changeset
|
214 /* Initialize object type */ |
|
8156879fe60d
Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents:
16735
diff
changeset
|
215 Dltype.ob_type = &PyType_Type; |
|
8156879fe60d
Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents:
16735
diff
changeset
|
216 |
| 1650 | 217 /* Create the module and add the functions */ |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
218 m = Py_InitModule("dl", dl_methods); |
| 1650 | 219 |
| 220 /* Add some symbolic constants to the module */ | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
221 d = PyModule_GetDict(m); |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
4725
diff
changeset
|
222 Dlerror = x = PyErr_NewException("dl.error", NULL, NULL); |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
223 PyDict_SetItemString(d, "error", x); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
224 x = PyInt_FromLong((long)RTLD_LAZY); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
225 PyDict_SetItemString(d, "RTLD_LAZY", x); |
|
14542
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
226 #define INSINT(X) insint(d,#X,X) |
| 1650 | 227 #ifdef RTLD_NOW |
|
14542
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
228 INSINT(RTLD_NOW); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
229 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
230 #ifdef RTLD_NOLOAD |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
231 INSINT(RTLD_NOLOAD); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
232 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
233 #ifdef RTLD_GLOBAL |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
234 INSINT(RTLD_GLOBAL); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
235 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
236 #ifdef RTLD_LOCAL |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
237 INSINT(RTLD_LOCAL); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
238 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
239 #ifdef RTLD_PARENT |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
240 INSINT(RTLD_PARENT); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
241 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
242 #ifdef RTLD_GROUP |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
243 INSINT(RTLD_GROUP); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
244 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
245 #ifdef RTLD_WORLD |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
246 INSINT(RTLD_WORLD); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
247 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
248 #ifdef RTLD_NODELETE |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
249 INSINT(RTLD_NODELETE); |
| 1650 | 250 #endif |
| 251 } |
