blob: d4012224df3b825c552ffcf95dd66d974ea641ed [file] [log] [blame]
Brett Cannonfd4d0502014-05-30 11:21:14 -04001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(_imp_lock_held__doc__,
6"lock_held($module, /)\n"
7"--\n"
8"\n"
9"Return True if the import lock is currently held, else False.\n"
10"\n"
11"On platforms without threads, return False.");
12
13#define _IMP_LOCK_HELD_METHODDEF \
14 {"lock_held", (PyCFunction)_imp_lock_held, METH_NOARGS, _imp_lock_held__doc__},
15
16static PyObject *
17_imp_lock_held_impl(PyModuleDef *module);
18
19static PyObject *
20_imp_lock_held(PyModuleDef *module, PyObject *Py_UNUSED(ignored))
21{
22 return _imp_lock_held_impl(module);
23}
24
25PyDoc_STRVAR(_imp_acquire_lock__doc__,
26"acquire_lock($module, /)\n"
27"--\n"
28"\n"
29"Acquires the interpreter\'s import lock for the current thread.\n"
30"\n"
31"This lock should be used by import hooks to ensure thread-safety when importing\n"
32"modules. On platforms without threads, this function does nothing.");
33
34#define _IMP_ACQUIRE_LOCK_METHODDEF \
35 {"acquire_lock", (PyCFunction)_imp_acquire_lock, METH_NOARGS, _imp_acquire_lock__doc__},
36
37static PyObject *
38_imp_acquire_lock_impl(PyModuleDef *module);
39
40static PyObject *
41_imp_acquire_lock(PyModuleDef *module, PyObject *Py_UNUSED(ignored))
42{
43 return _imp_acquire_lock_impl(module);
44}
45
46PyDoc_STRVAR(_imp_release_lock__doc__,
47"release_lock($module, /)\n"
48"--\n"
49"\n"
50"Release the interpreter\'s import lock.\n"
51"\n"
52"On platforms without threads, this function does nothing.");
53
54#define _IMP_RELEASE_LOCK_METHODDEF \
55 {"release_lock", (PyCFunction)_imp_release_lock, METH_NOARGS, _imp_release_lock__doc__},
56
57static PyObject *
58_imp_release_lock_impl(PyModuleDef *module);
59
60static PyObject *
61_imp_release_lock(PyModuleDef *module, PyObject *Py_UNUSED(ignored))
62{
63 return _imp_release_lock_impl(module);
64}
65
66PyDoc_STRVAR(_imp__fix_co_filename__doc__,
67"_fix_co_filename($module, code, path, /)\n"
68"--\n"
69"\n"
70"Changes code.co_filename to specify the passed-in file path.\n"
71"\n"
72" code\n"
73" Code object to change.\n"
74" path\n"
75" File path to use.");
76
77#define _IMP__FIX_CO_FILENAME_METHODDEF \
78 {"_fix_co_filename", (PyCFunction)_imp__fix_co_filename, METH_VARARGS, _imp__fix_co_filename__doc__},
79
80static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -040081_imp__fix_co_filename_impl(PyModuleDef *module, PyCodeObject *code,
82 PyObject *path);
Brett Cannonfd4d0502014-05-30 11:21:14 -040083
84static PyObject *
85_imp__fix_co_filename(PyModuleDef *module, PyObject *args)
86{
87 PyObject *return_value = NULL;
88 PyCodeObject *code;
89 PyObject *path;
90
Serhiy Storchaka247789c2015-04-24 00:40:51 +030091 if (!PyArg_ParseTuple(args, "O!U:_fix_co_filename",
Brett Cannonfd4d0502014-05-30 11:21:14 -040092 &PyCode_Type, &code, &path))
93 goto exit;
94 return_value = _imp__fix_co_filename_impl(module, code, path);
95
96exit:
97 return return_value;
98}
99
100PyDoc_STRVAR(_imp_extension_suffixes__doc__,
101"extension_suffixes($module, /)\n"
102"--\n"
103"\n"
104"Returns the list of file suffixes used to identify extension modules.");
105
106#define _IMP_EXTENSION_SUFFIXES_METHODDEF \
107 {"extension_suffixes", (PyCFunction)_imp_extension_suffixes, METH_NOARGS, _imp_extension_suffixes__doc__},
108
109static PyObject *
110_imp_extension_suffixes_impl(PyModuleDef *module);
111
112static PyObject *
113_imp_extension_suffixes(PyModuleDef *module, PyObject *Py_UNUSED(ignored))
114{
115 return _imp_extension_suffixes_impl(module);
116}
117
118PyDoc_STRVAR(_imp_init_builtin__doc__,
119"init_builtin($module, name, /)\n"
120"--\n"
121"\n"
122"Initializes a built-in module.");
123
124#define _IMP_INIT_BUILTIN_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300125 {"init_builtin", (PyCFunction)_imp_init_builtin, METH_O, _imp_init_builtin__doc__},
Brett Cannonfd4d0502014-05-30 11:21:14 -0400126
127static PyObject *
128_imp_init_builtin_impl(PyModuleDef *module, PyObject *name);
129
130static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300131_imp_init_builtin(PyModuleDef *module, PyObject *arg)
Brett Cannonfd4d0502014-05-30 11:21:14 -0400132{
133 PyObject *return_value = NULL;
134 PyObject *name;
135
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300136 if (!PyArg_Parse(arg, "U:init_builtin", &name))
Brett Cannonfd4d0502014-05-30 11:21:14 -0400137 goto exit;
138 return_value = _imp_init_builtin_impl(module, name);
139
140exit:
141 return return_value;
142}
143
144PyDoc_STRVAR(_imp_init_frozen__doc__,
145"init_frozen($module, name, /)\n"
146"--\n"
147"\n"
148"Initializes a frozen module.");
149
150#define _IMP_INIT_FROZEN_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300151 {"init_frozen", (PyCFunction)_imp_init_frozen, METH_O, _imp_init_frozen__doc__},
Brett Cannonfd4d0502014-05-30 11:21:14 -0400152
153static PyObject *
154_imp_init_frozen_impl(PyModuleDef *module, PyObject *name);
155
156static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300157_imp_init_frozen(PyModuleDef *module, PyObject *arg)
Brett Cannonfd4d0502014-05-30 11:21:14 -0400158{
159 PyObject *return_value = NULL;
160 PyObject *name;
161
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300162 if (!PyArg_Parse(arg, "U:init_frozen", &name))
Brett Cannonfd4d0502014-05-30 11:21:14 -0400163 goto exit;
164 return_value = _imp_init_frozen_impl(module, name);
165
166exit:
167 return return_value;
168}
169
170PyDoc_STRVAR(_imp_get_frozen_object__doc__,
171"get_frozen_object($module, name, /)\n"
172"--\n"
173"\n"
174"Create a code object for a frozen module.");
175
176#define _IMP_GET_FROZEN_OBJECT_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300177 {"get_frozen_object", (PyCFunction)_imp_get_frozen_object, METH_O, _imp_get_frozen_object__doc__},
Brett Cannonfd4d0502014-05-30 11:21:14 -0400178
179static PyObject *
180_imp_get_frozen_object_impl(PyModuleDef *module, PyObject *name);
181
182static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300183_imp_get_frozen_object(PyModuleDef *module, PyObject *arg)
Brett Cannonfd4d0502014-05-30 11:21:14 -0400184{
185 PyObject *return_value = NULL;
186 PyObject *name;
187
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300188 if (!PyArg_Parse(arg, "U:get_frozen_object", &name))
Brett Cannonfd4d0502014-05-30 11:21:14 -0400189 goto exit;
190 return_value = _imp_get_frozen_object_impl(module, name);
191
192exit:
193 return return_value;
194}
195
196PyDoc_STRVAR(_imp_is_frozen_package__doc__,
197"is_frozen_package($module, name, /)\n"
198"--\n"
199"\n"
200"Returns True if the module name is of a frozen package.");
201
202#define _IMP_IS_FROZEN_PACKAGE_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300203 {"is_frozen_package", (PyCFunction)_imp_is_frozen_package, METH_O, _imp_is_frozen_package__doc__},
Brett Cannonfd4d0502014-05-30 11:21:14 -0400204
205static PyObject *
206_imp_is_frozen_package_impl(PyModuleDef *module, PyObject *name);
207
208static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300209_imp_is_frozen_package(PyModuleDef *module, PyObject *arg)
Brett Cannonfd4d0502014-05-30 11:21:14 -0400210{
211 PyObject *return_value = NULL;
212 PyObject *name;
213
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300214 if (!PyArg_Parse(arg, "U:is_frozen_package", &name))
Brett Cannonfd4d0502014-05-30 11:21:14 -0400215 goto exit;
216 return_value = _imp_is_frozen_package_impl(module, name);
217
218exit:
219 return return_value;
220}
221
222PyDoc_STRVAR(_imp_is_builtin__doc__,
223"is_builtin($module, name, /)\n"
224"--\n"
225"\n"
226"Returns True if the module name corresponds to a built-in module.");
227
228#define _IMP_IS_BUILTIN_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300229 {"is_builtin", (PyCFunction)_imp_is_builtin, METH_O, _imp_is_builtin__doc__},
Brett Cannonfd4d0502014-05-30 11:21:14 -0400230
231static PyObject *
232_imp_is_builtin_impl(PyModuleDef *module, PyObject *name);
233
234static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300235_imp_is_builtin(PyModuleDef *module, PyObject *arg)
Brett Cannonfd4d0502014-05-30 11:21:14 -0400236{
237 PyObject *return_value = NULL;
238 PyObject *name;
239
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300240 if (!PyArg_Parse(arg, "U:is_builtin", &name))
Brett Cannonfd4d0502014-05-30 11:21:14 -0400241 goto exit;
242 return_value = _imp_is_builtin_impl(module, name);
243
244exit:
245 return return_value;
246}
247
248PyDoc_STRVAR(_imp_is_frozen__doc__,
249"is_frozen($module, name, /)\n"
250"--\n"
251"\n"
252"Returns True if the module name corresponds to a frozen module.");
253
254#define _IMP_IS_FROZEN_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300255 {"is_frozen", (PyCFunction)_imp_is_frozen, METH_O, _imp_is_frozen__doc__},
Brett Cannonfd4d0502014-05-30 11:21:14 -0400256
257static PyObject *
258_imp_is_frozen_impl(PyModuleDef *module, PyObject *name);
259
260static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300261_imp_is_frozen(PyModuleDef *module, PyObject *arg)
Brett Cannonfd4d0502014-05-30 11:21:14 -0400262{
263 PyObject *return_value = NULL;
264 PyObject *name;
265
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300266 if (!PyArg_Parse(arg, "U:is_frozen", &name))
Brett Cannonfd4d0502014-05-30 11:21:14 -0400267 goto exit;
268 return_value = _imp_is_frozen_impl(module, name);
269
270exit:
271 return return_value;
272}
273
274#if defined(HAVE_DYNAMIC_LOADING)
275
276PyDoc_STRVAR(_imp_load_dynamic__doc__,
277"load_dynamic($module, name, path, file=None, /)\n"
278"--\n"
279"\n"
280"Loads an extension module.");
281
282#define _IMP_LOAD_DYNAMIC_METHODDEF \
283 {"load_dynamic", (PyCFunction)_imp_load_dynamic, METH_VARARGS, _imp_load_dynamic__doc__},
284
285static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400286_imp_load_dynamic_impl(PyModuleDef *module, PyObject *name, PyObject *path,
287 PyObject *file);
Brett Cannonfd4d0502014-05-30 11:21:14 -0400288
289static PyObject *
290_imp_load_dynamic(PyModuleDef *module, PyObject *args)
291{
292 PyObject *return_value = NULL;
293 PyObject *name;
294 PyObject *path;
295 PyObject *file = NULL;
296
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300297 if (!PyArg_ParseTuple(args, "UO&|O:load_dynamic",
Brett Cannonfd4d0502014-05-30 11:21:14 -0400298 &name, PyUnicode_FSDecoder, &path, &file))
299 goto exit;
300 return_value = _imp_load_dynamic_impl(module, name, path, file);
301
302exit:
303 return return_value;
304}
305
306#endif /* defined(HAVE_DYNAMIC_LOADING) */
307
308#ifndef _IMP_LOAD_DYNAMIC_METHODDEF
309 #define _IMP_LOAD_DYNAMIC_METHODDEF
310#endif /* !defined(_IMP_LOAD_DYNAMIC_METHODDEF) */
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300311/*[clinic end generated code: output=6d75cece35863874 input=a9049054013a1b77]*/