1/*[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(PyObject *module);
18
19static PyObject *
20_imp_lock_held(PyObject *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(PyObject *module);
39
40static PyObject *
41_imp_acquire_lock(PyObject *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(PyObject *module);
59
60static PyObject *
61_imp_release_lock(PyObject *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)(void(*)(void))_imp__fix_co_filename, METH_FASTCALL, _imp__fix_co_filename__doc__},
79
80static PyObject *
81_imp__fix_co_filename_impl(PyObject *module, PyCodeObject *code,
82 PyObject *path);
83
84static PyObject *
85_imp__fix_co_filename(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
86{
87 PyObject *return_value = NULL;
88 PyCodeObject *code;
89 PyObject *path;
90
91 if (!_PyArg_CheckPositional("_fix_co_filename", nargs, 2, 2)) {
92 goto exit;
93 }
94 if (!PyObject_TypeCheck(args[0], &PyCode_Type)) {
95 _PyArg_BadArgument("_fix_co_filename", "argument 1", (&PyCode_Type)->tp_name, args[0]);
96 goto exit;
97 }
98 code = (PyCodeObject *)args[0];
99 if (!PyUnicode_Check(args[1])) {
100 _PyArg_BadArgument("_fix_co_filename", "argument 2", "str", args[1]);
101 goto exit;
102 }
103 if (PyUnicode_READY(args[1]) == -1) {
104 goto exit;
105 }
106 path = args[1];
107 return_value = _imp__fix_co_filename_impl(module, code, path);
108
109exit:
110 return return_value;
111}
112
113PyDoc_STRVAR(_imp_create_builtin__doc__,
114"create_builtin($module, spec, /)\n"
115"--\n"
116"\n"
117"Create an extension module.");
118
119#define _IMP_CREATE_BUILTIN_METHODDEF \
120 {"create_builtin", (PyCFunction)_imp_create_builtin, METH_O, _imp_create_builtin__doc__},
121
122PyDoc_STRVAR(_imp_extension_suffixes__doc__,
123"extension_suffixes($module, /)\n"
124"--\n"
125"\n"
126"Returns the list of file suffixes used to identify extension modules.");
127
128#define _IMP_EXTENSION_SUFFIXES_METHODDEF \
129 {"extension_suffixes", (PyCFunction)_imp_extension_suffixes, METH_NOARGS, _imp_extension_suffixes__doc__},
130
131static PyObject *
132_imp_extension_suffixes_impl(PyObject *module);
133
134static PyObject *
135_imp_extension_suffixes(PyObject *module, PyObject *Py_UNUSED(ignored))
136{
137 return _imp_extension_suffixes_impl(module);
138}
139
140PyDoc_STRVAR(_imp_init_frozen__doc__,
141"init_frozen($module, name, /)\n"
142"--\n"
143"\n"
144"Initializes a frozen module.");
145
146#define _IMP_INIT_FROZEN_METHODDEF \
147 {"init_frozen", (PyCFunction)_imp_init_frozen, METH_O, _imp_init_frozen__doc__},
148
149static PyObject *
150_imp_init_frozen_impl(PyObject *module, PyObject *name);
151
152static PyObject *
153_imp_init_frozen(PyObject *module, PyObject *arg)
154{
155 PyObject *return_value = NULL;
156 PyObject *name;
157
158 if (!PyUnicode_Check(arg)) {
159 _PyArg_BadArgument("init_frozen", "argument", "str", arg);
160 goto exit;
161 }
162 if (PyUnicode_READY(arg) == -1) {
163 goto exit;
164 }
165 name = arg;
166 return_value = _imp_init_frozen_impl(module, name);
167
168exit:
169 return return_value;
170}
171
172PyDoc_STRVAR(_imp_get_frozen_object__doc__,
173"get_frozen_object($module, name, /)\n"
174"--\n"
175"\n"
176"Create a code object for a frozen module.");
177
178#define _IMP_GET_FROZEN_OBJECT_METHODDEF \
179 {"get_frozen_object", (PyCFunction)_imp_get_frozen_object, METH_O, _imp_get_frozen_object__doc__},
180
181static PyObject *
182_imp_get_frozen_object_impl(PyObject *module, PyObject *name);
183
184static PyObject *
185_imp_get_frozen_object(PyObject *module, PyObject *arg)
186{
187 PyObject *return_value = NULL;
188 PyObject *name;
189
190 if (!PyUnicode_Check(arg)) {
191 _PyArg_BadArgument("get_frozen_object", "argument", "str", arg);
192 goto exit;
193 }
194 if (PyUnicode_READY(arg) == -1) {
195 goto exit;
196 }
197 name = arg;
198 return_value = _imp_get_frozen_object_impl(module, name);
199
200exit:
201 return return_value;
202}
203
204PyDoc_STRVAR(_imp_is_frozen_package__doc__,
205"is_frozen_package($module, name, /)\n"
206"--\n"
207"\n"
208"Returns True if the module name is of a frozen package.");
209
210#define _IMP_IS_FROZEN_PACKAGE_METHODDEF \
211 {"is_frozen_package", (PyCFunction)_imp_is_frozen_package, METH_O, _imp_is_frozen_package__doc__},
212
213static PyObject *
214_imp_is_frozen_package_impl(PyObject *module, PyObject *name);
215
216static PyObject *
217_imp_is_frozen_package(PyObject *module, PyObject *arg)
218{
219 PyObject *return_value = NULL;
220 PyObject *name;
221
222 if (!PyUnicode_Check(arg)) {
223 _PyArg_BadArgument("is_frozen_package", "argument", "str", arg);
224 goto exit;
225 }
226 if (PyUnicode_READY(arg) == -1) {
227 goto exit;
228 }
229 name = arg;
230 return_value = _imp_is_frozen_package_impl(module, name);
231
232exit:
233 return return_value;
234}
235
236PyDoc_STRVAR(_imp_is_builtin__doc__,
237"is_builtin($module, name, /)\n"
238"--\n"
239"\n"
240"Returns True if the module name corresponds to a built-in module.");
241
242#define _IMP_IS_BUILTIN_METHODDEF \
243 {"is_builtin", (PyCFunction)_imp_is_builtin, METH_O, _imp_is_builtin__doc__},
244
245static PyObject *
246_imp_is_builtin_impl(PyObject *module, PyObject *name);
247
248static PyObject *
249_imp_is_builtin(PyObject *module, PyObject *arg)
250{
251 PyObject *return_value = NULL;
252 PyObject *name;
253
254 if (!PyUnicode_Check(arg)) {
255 _PyArg_BadArgument("is_builtin", "argument", "str", arg);
256 goto exit;
257 }
258 if (PyUnicode_READY(arg) == -1) {
259 goto exit;
260 }
261 name = arg;
262 return_value = _imp_is_builtin_impl(module, name);
263
264exit:
265 return return_value;
266}
267
268PyDoc_STRVAR(_imp_is_frozen__doc__,
269"is_frozen($module, name, /)\n"
270"--\n"
271"\n"
272"Returns True if the module name corresponds to a frozen module.");
273
274#define _IMP_IS_FROZEN_METHODDEF \
275 {"is_frozen", (PyCFunction)_imp_is_frozen, METH_O, _imp_is_frozen__doc__},
276
277static PyObject *
278_imp_is_frozen_impl(PyObject *module, PyObject *name);
279
280static PyObject *
281_imp_is_frozen(PyObject *module, PyObject *arg)
282{
283 PyObject *return_value = NULL;
284 PyObject *name;
285
286 if (!PyUnicode_Check(arg)) {
287 _PyArg_BadArgument("is_frozen", "argument", "str", arg);
288 goto exit;
289 }
290 if (PyUnicode_READY(arg) == -1) {
291 goto exit;
292 }
293 name = arg;
294 return_value = _imp_is_frozen_impl(module, name);
295
296exit:
297 return return_value;
298}
299
300#if defined(HAVE_DYNAMIC_LOADING)
301
302PyDoc_STRVAR(_imp_create_dynamic__doc__,
303"create_dynamic($module, spec, file=<unrepresentable>, /)\n"
304"--\n"
305"\n"
306"Create an extension module.");
307
308#define _IMP_CREATE_DYNAMIC_METHODDEF \
309 {"create_dynamic", (PyCFunction)(void(*)(void))_imp_create_dynamic, METH_FASTCALL, _imp_create_dynamic__doc__},
310
311static PyObject *
312_imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file);
313
314static PyObject *
315_imp_create_dynamic(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
316{
317 PyObject *return_value = NULL;
318 PyObject *spec;
319 PyObject *file = NULL;
320
321 if (!_PyArg_CheckPositional("create_dynamic", nargs, 1, 2)) {
322 goto exit;
323 }
324 spec = args[0];
325 if (nargs < 2) {
326 goto skip_optional;
327 }
328 file = args[1];
329skip_optional:
330 return_value = _imp_create_dynamic_impl(module, spec, file);
331
332exit:
333 return return_value;
334}
335
336#endif /* defined(HAVE_DYNAMIC_LOADING) */
337
338#if defined(HAVE_DYNAMIC_LOADING)
339
340PyDoc_STRVAR(_imp_exec_dynamic__doc__,
341"exec_dynamic($module, mod, /)\n"
342"--\n"
343"\n"
344"Initialize an extension module.");
345
346#define _IMP_EXEC_DYNAMIC_METHODDEF \
347 {"exec_dynamic", (PyCFunction)_imp_exec_dynamic, METH_O, _imp_exec_dynamic__doc__},
348
349static int
350_imp_exec_dynamic_impl(PyObject *module, PyObject *mod);
351
352static PyObject *
353_imp_exec_dynamic(PyObject *module, PyObject *mod)
354{
355 PyObject *return_value = NULL;
356 int _return_value;
357
358 _return_value = _imp_exec_dynamic_impl(module, mod);
359 if ((_return_value == -1) && PyErr_Occurred()) {
360 goto exit;
361 }
362 return_value = PyLong_FromLong((long)_return_value);
363
364exit:
365 return return_value;
366}
367
368#endif /* defined(HAVE_DYNAMIC_LOADING) */
369
370PyDoc_STRVAR(_imp_exec_builtin__doc__,
371"exec_builtin($module, mod, /)\n"
372"--\n"
373"\n"
374"Initialize a built-in module.");
375
376#define _IMP_EXEC_BUILTIN_METHODDEF \
377 {"exec_builtin", (PyCFunction)_imp_exec_builtin, METH_O, _imp_exec_builtin__doc__},
378
379static int
380_imp_exec_builtin_impl(PyObject *module, PyObject *mod);
381
382static PyObject *
383_imp_exec_builtin(PyObject *module, PyObject *mod)
384{
385 PyObject *return_value = NULL;
386 int _return_value;
387
388 _return_value = _imp_exec_builtin_impl(module, mod);
389 if ((_return_value == -1) && PyErr_Occurred()) {
390 goto exit;
391 }
392 return_value = PyLong_FromLong((long)_return_value);
393
394exit:
395 return return_value;
396}
397
398PyDoc_STRVAR(_imp_source_hash__doc__,
399"source_hash($module, /, key, source)\n"
400"--\n"
401"\n");
402
403#define _IMP_SOURCE_HASH_METHODDEF \
404 {"source_hash", (PyCFunction)(void(*)(void))_imp_source_hash, METH_FASTCALL|METH_KEYWORDS, _imp_source_hash__doc__},
405
406static PyObject *
407_imp_source_hash_impl(PyObject *module, long key, Py_buffer *source);
408
409static PyObject *
410_imp_source_hash(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
411{
412 PyObject *return_value = NULL;
413 static const char * const _keywords[] = {"key", "source", NULL};
414 static _PyArg_Parser _parser = {NULL, _keywords, "source_hash", 0};
415 PyObject *argsbuf[2];
416 long key;
417 Py_buffer source = {NULL, NULL};
418
419 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
420 if (!args) {
421 goto exit;
422 }
423 key = PyLong_AsLong(args[0]);
424 if (key == -1 && PyErr_Occurred()) {
425 goto exit;
426 }
427 if (PyObject_GetBuffer(args[1], &source, PyBUF_SIMPLE) != 0) {
428 goto exit;
429 }
430 if (!PyBuffer_IsContiguous(&source, 'C')) {
431 _PyArg_BadArgument("source_hash", "argument 'source'", "contiguous buffer", args[1]);
432 goto exit;
433 }
434 return_value = _imp_source_hash_impl(module, key, &source);
435
436exit:
437 /* Cleanup for source */
438 if (source.obj) {
439 PyBuffer_Release(&source);
440 }
441
442 return return_value;
443}
444
445#ifndef _IMP_CREATE_DYNAMIC_METHODDEF
446 #define _IMP_CREATE_DYNAMIC_METHODDEF
447#endif /* !defined(_IMP_CREATE_DYNAMIC_METHODDEF) */
448
449#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
450 #define _IMP_EXEC_DYNAMIC_METHODDEF
451#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
452/*[clinic end generated code: output=7c31c433af88af6b input=a9049054013a1b77]*/
453