/src/cpython/Python/clinic/sysmodule.c.h
Line | Count | Source |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
6 | | # include "pycore_gc.h" // PyGC_Head |
7 | | # include "pycore_runtime.h" // _Py_ID() |
8 | | #endif |
9 | | #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
10 | | |
11 | | PyDoc_STRVAR(sys_addaudithook__doc__, |
12 | | "addaudithook($module, /, hook)\n" |
13 | | "--\n" |
14 | | "\n" |
15 | | "Adds a new audit hook callback."); |
16 | | |
17 | | #define SYS_ADDAUDITHOOK_METHODDEF \ |
18 | | {"addaudithook", _PyCFunction_CAST(sys_addaudithook), METH_FASTCALL|METH_KEYWORDS, sys_addaudithook__doc__}, |
19 | | |
20 | | static PyObject * |
21 | | sys_addaudithook_impl(PyObject *module, PyObject *hook); |
22 | | |
23 | | static PyObject * |
24 | | sys_addaudithook(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
25 | 4 | { |
26 | 4 | PyObject *return_value = NULL; |
27 | 4 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
28 | | |
29 | 4 | #define NUM_KEYWORDS 1 |
30 | 4 | static struct { |
31 | 4 | PyGC_Head _this_is_not_used; |
32 | 4 | PyObject_VAR_HEAD |
33 | 4 | Py_hash_t ob_hash; |
34 | 4 | PyObject *ob_item[NUM_KEYWORDS]; |
35 | 4 | } _kwtuple = { |
36 | 4 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
37 | 4 | .ob_hash = -1, |
38 | 4 | .ob_item = { &_Py_ID(hook), }, |
39 | 4 | }; |
40 | 4 | #undef NUM_KEYWORDS |
41 | 4 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
42 | | |
43 | | #else // !Py_BUILD_CORE |
44 | | # define KWTUPLE NULL |
45 | | #endif // !Py_BUILD_CORE |
46 | | |
47 | 4 | static const char * const _keywords[] = {"hook", NULL}; |
48 | 4 | static _PyArg_Parser _parser = { |
49 | 4 | .keywords = _keywords, |
50 | 4 | .fname = "addaudithook", |
51 | 4 | .kwtuple = KWTUPLE, |
52 | 4 | }; |
53 | 4 | #undef KWTUPLE |
54 | 4 | PyObject *argsbuf[1]; |
55 | 4 | PyObject *hook; |
56 | | |
57 | 4 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
58 | 4 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
59 | 4 | if (!args) { |
60 | 0 | goto exit; |
61 | 0 | } |
62 | 4 | hook = args[0]; |
63 | 4 | return_value = sys_addaudithook_impl(module, hook); |
64 | | |
65 | 4 | exit: |
66 | 4 | return return_value; |
67 | 4 | } |
68 | | |
69 | | PyDoc_STRVAR(sys_audit__doc__, |
70 | | "audit($module, event, /, *args)\n" |
71 | | "--\n" |
72 | | "\n" |
73 | | "Passes the event to any audit hooks that are attached."); |
74 | | |
75 | | #define SYS_AUDIT_METHODDEF \ |
76 | | {"audit", _PyCFunction_CAST(sys_audit), METH_FASTCALL, sys_audit__doc__}, |
77 | | |
78 | | static PyObject * |
79 | | sys_audit_impl(PyObject *module, const char *event, PyObject *args); |
80 | | |
81 | | static PyObject * |
82 | | sys_audit(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
83 | 26.9k | { |
84 | 26.9k | PyObject *return_value = NULL; |
85 | 26.9k | const char *event; |
86 | 26.9k | PyObject *__clinic_args = NULL; |
87 | | |
88 | 26.9k | if (!_PyArg_CheckPositional("audit", nargs, 1, PY_SSIZE_T_MAX)) { |
89 | 0 | goto exit; |
90 | 0 | } |
91 | 26.9k | if (!PyUnicode_Check(args[0])) { |
92 | 0 | _PyArg_BadArgument("audit", "argument 1", "str", args[0]); |
93 | 0 | goto exit; |
94 | 0 | } |
95 | 26.9k | Py_ssize_t event_length; |
96 | 26.9k | event = PyUnicode_AsUTF8AndSize(args[0], &event_length); |
97 | 26.9k | if (event == NULL) { |
98 | 0 | goto exit; |
99 | 0 | } |
100 | 26.9k | if (strlen(event) != (size_t)event_length) { |
101 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
102 | 0 | goto exit; |
103 | 0 | } |
104 | 26.9k | __clinic_args = PyTuple_FromArray(args + 1, nargs - 1); |
105 | 26.9k | if (__clinic_args == NULL) { |
106 | 0 | goto exit; |
107 | 0 | } |
108 | 26.9k | return_value = sys_audit_impl(module, event, __clinic_args); |
109 | | |
110 | 26.9k | exit: |
111 | | /* Cleanup for args */ |
112 | 26.9k | Py_XDECREF(__clinic_args); |
113 | | |
114 | 26.9k | return return_value; |
115 | 26.9k | } |
116 | | |
117 | | PyDoc_STRVAR(sys_displayhook__doc__, |
118 | | "displayhook($module, object, /)\n" |
119 | | "--\n" |
120 | | "\n" |
121 | | "Print an object to sys.stdout and also save it in builtins._"); |
122 | | |
123 | | #define SYS_DISPLAYHOOK_METHODDEF \ |
124 | | {"displayhook", (PyCFunction)sys_displayhook, METH_O, sys_displayhook__doc__}, |
125 | | |
126 | | PyDoc_STRVAR(sys_excepthook__doc__, |
127 | | "excepthook($module, exctype, value, traceback, /)\n" |
128 | | "--\n" |
129 | | "\n" |
130 | | "Handle an exception by displaying it with a traceback on sys.stderr."); |
131 | | |
132 | | #define SYS_EXCEPTHOOK_METHODDEF \ |
133 | | {"excepthook", _PyCFunction_CAST(sys_excepthook), METH_FASTCALL, sys_excepthook__doc__}, |
134 | | |
135 | | static PyObject * |
136 | | sys_excepthook_impl(PyObject *module, PyObject *exctype, PyObject *value, |
137 | | PyObject *traceback); |
138 | | |
139 | | static PyObject * |
140 | | sys_excepthook(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
141 | 0 | { |
142 | 0 | PyObject *return_value = NULL; |
143 | 0 | PyObject *exctype; |
144 | 0 | PyObject *value; |
145 | 0 | PyObject *traceback; |
146 | |
|
147 | 0 | if (!_PyArg_CheckPositional("excepthook", nargs, 3, 3)) { |
148 | 0 | goto exit; |
149 | 0 | } |
150 | 0 | exctype = args[0]; |
151 | 0 | value = args[1]; |
152 | 0 | traceback = args[2]; |
153 | 0 | return_value = sys_excepthook_impl(module, exctype, value, traceback); |
154 | |
|
155 | 0 | exit: |
156 | 0 | return return_value; |
157 | 0 | } |
158 | | |
159 | | PyDoc_STRVAR(sys_exception__doc__, |
160 | | "exception($module, /)\n" |
161 | | "--\n" |
162 | | "\n" |
163 | | "Return the current exception.\n" |
164 | | "\n" |
165 | | "Return the most recent exception caught by an except clause\n" |
166 | | "in the current stack frame or in an older stack frame, or None\n" |
167 | | "if no such exception exists."); |
168 | | |
169 | | #define SYS_EXCEPTION_METHODDEF \ |
170 | | {"exception", (PyCFunction)sys_exception, METH_NOARGS, sys_exception__doc__}, |
171 | | |
172 | | static PyObject * |
173 | | sys_exception_impl(PyObject *module); |
174 | | |
175 | | static PyObject * |
176 | | sys_exception(PyObject *module, PyObject *Py_UNUSED(ignored)) |
177 | 0 | { |
178 | 0 | return sys_exception_impl(module); |
179 | 0 | } |
180 | | |
181 | | PyDoc_STRVAR(sys_exc_info__doc__, |
182 | | "exc_info($module, /)\n" |
183 | | "--\n" |
184 | | "\n" |
185 | | "Return current exception information: (type, value, traceback).\n" |
186 | | "\n" |
187 | | "Return information about the most recent exception caught by an except\n" |
188 | | "clause in the current stack frame or in an older stack frame."); |
189 | | |
190 | | #define SYS_EXC_INFO_METHODDEF \ |
191 | | {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, sys_exc_info__doc__}, |
192 | | |
193 | | static PyObject * |
194 | | sys_exc_info_impl(PyObject *module); |
195 | | |
196 | | static PyObject * |
197 | | sys_exc_info(PyObject *module, PyObject *Py_UNUSED(ignored)) |
198 | 0 | { |
199 | 0 | return sys_exc_info_impl(module); |
200 | 0 | } |
201 | | |
202 | | PyDoc_STRVAR(sys_unraisablehook__doc__, |
203 | | "unraisablehook($module, unraisable, /)\n" |
204 | | "--\n" |
205 | | "\n" |
206 | | "Handle an unraisable exception.\n" |
207 | | "\n" |
208 | | "The unraisable argument has the following attributes:\n" |
209 | | "\n" |
210 | | "* exc_type: Exception type.\n" |
211 | | "* exc_value: Exception value, can be None.\n" |
212 | | "* exc_traceback: Exception traceback, can be None.\n" |
213 | | "* err_msg: Error message, can be None.\n" |
214 | | "* object: Object causing the exception, can be None."); |
215 | | |
216 | | #define SYS_UNRAISABLEHOOK_METHODDEF \ |
217 | | {"unraisablehook", (PyCFunction)sys_unraisablehook, METH_O, sys_unraisablehook__doc__}, |
218 | | |
219 | | PyDoc_STRVAR(sys_exit__doc__, |
220 | | "exit($module, status=None, /)\n" |
221 | | "--\n" |
222 | | "\n" |
223 | | "Exit the interpreter by raising SystemExit(status).\n" |
224 | | "\n" |
225 | | "If the status is omitted or None, it defaults to zero (i.e., success).\n" |
226 | | "If the status is an integer, it will be used as the system exit status.\n" |
227 | | "If it is another kind of object, it will be printed and the system\n" |
228 | | "exit status will be one (i.e., failure)."); |
229 | | |
230 | | #define SYS_EXIT_METHODDEF \ |
231 | | {"exit", _PyCFunction_CAST(sys_exit), METH_FASTCALL, sys_exit__doc__}, |
232 | | |
233 | | static PyObject * |
234 | | sys_exit_impl(PyObject *module, PyObject *status); |
235 | | |
236 | | static PyObject * |
237 | | sys_exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
238 | 0 | { |
239 | 0 | PyObject *return_value = NULL; |
240 | 0 | PyObject *status = Py_None; |
241 | |
|
242 | 0 | if (!_PyArg_CheckPositional("exit", nargs, 0, 1)) { |
243 | 0 | goto exit; |
244 | 0 | } |
245 | 0 | if (nargs < 1) { |
246 | 0 | goto skip_optional; |
247 | 0 | } |
248 | 0 | status = args[0]; |
249 | 0 | skip_optional: |
250 | 0 | return_value = sys_exit_impl(module, status); |
251 | |
|
252 | 0 | exit: |
253 | 0 | return return_value; |
254 | 0 | } |
255 | | |
256 | | PyDoc_STRVAR(sys_getdefaultencoding__doc__, |
257 | | "getdefaultencoding($module, /)\n" |
258 | | "--\n" |
259 | | "\n" |
260 | | "Return the current default encoding used by the Unicode implementation."); |
261 | | |
262 | | #define SYS_GETDEFAULTENCODING_METHODDEF \ |
263 | | {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, sys_getdefaultencoding__doc__}, |
264 | | |
265 | | static PyObject * |
266 | | sys_getdefaultencoding_impl(PyObject *module); |
267 | | |
268 | | static PyObject * |
269 | | sys_getdefaultencoding(PyObject *module, PyObject *Py_UNUSED(ignored)) |
270 | 0 | { |
271 | 0 | return sys_getdefaultencoding_impl(module); |
272 | 0 | } |
273 | | |
274 | | PyDoc_STRVAR(sys_getfilesystemencoding__doc__, |
275 | | "getfilesystemencoding($module, /)\n" |
276 | | "--\n" |
277 | | "\n" |
278 | | "Return the encoding used to convert Unicode filenames to OS filenames."); |
279 | | |
280 | | #define SYS_GETFILESYSTEMENCODING_METHODDEF \ |
281 | | {"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding, METH_NOARGS, sys_getfilesystemencoding__doc__}, |
282 | | |
283 | | static PyObject * |
284 | | sys_getfilesystemencoding_impl(PyObject *module); |
285 | | |
286 | | static PyObject * |
287 | | sys_getfilesystemencoding(PyObject *module, PyObject *Py_UNUSED(ignored)) |
288 | 78 | { |
289 | 78 | return sys_getfilesystemencoding_impl(module); |
290 | 78 | } |
291 | | |
292 | | PyDoc_STRVAR(sys_getfilesystemencodeerrors__doc__, |
293 | | "getfilesystemencodeerrors($module, /)\n" |
294 | | "--\n" |
295 | | "\n" |
296 | | "Return the error mode used Unicode to OS filename conversion."); |
297 | | |
298 | | #define SYS_GETFILESYSTEMENCODEERRORS_METHODDEF \ |
299 | | {"getfilesystemencodeerrors", (PyCFunction)sys_getfilesystemencodeerrors, METH_NOARGS, sys_getfilesystemencodeerrors__doc__}, |
300 | | |
301 | | static PyObject * |
302 | | sys_getfilesystemencodeerrors_impl(PyObject *module); |
303 | | |
304 | | static PyObject * |
305 | | sys_getfilesystemencodeerrors(PyObject *module, PyObject *Py_UNUSED(ignored)) |
306 | 37 | { |
307 | 37 | return sys_getfilesystemencodeerrors_impl(module); |
308 | 37 | } |
309 | | |
310 | | PyDoc_STRVAR(sys_intern__doc__, |
311 | | "intern($module, string, /)\n" |
312 | | "--\n" |
313 | | "\n" |
314 | | "``Intern\'\' the given string.\n" |
315 | | "\n" |
316 | | "This enters the string in the (global) table of interned strings whose\n" |
317 | | "purpose is to speed up dictionary lookups. Return the string itself or\n" |
318 | | "the previously interned string object with the same value."); |
319 | | |
320 | | #define SYS_INTERN_METHODDEF \ |
321 | | {"intern", (PyCFunction)sys_intern, METH_O, sys_intern__doc__}, |
322 | | |
323 | | static PyObject * |
324 | | sys_intern_impl(PyObject *module, PyObject *s); |
325 | | |
326 | | static PyObject * |
327 | | sys_intern(PyObject *module, PyObject *arg) |
328 | 1.90k | { |
329 | 1.90k | PyObject *return_value = NULL; |
330 | 1.90k | PyObject *s; |
331 | | |
332 | 1.90k | if (!PyUnicode_Check(arg)) { |
333 | 0 | _PyArg_BadArgument("intern", "argument", "str", arg); |
334 | 0 | goto exit; |
335 | 0 | } |
336 | 1.90k | s = arg; |
337 | 1.90k | return_value = sys_intern_impl(module, s); |
338 | | |
339 | 1.90k | exit: |
340 | 1.90k | return return_value; |
341 | 1.90k | } |
342 | | |
343 | | PyDoc_STRVAR(sys__is_interned__doc__, |
344 | | "_is_interned($module, string, /)\n" |
345 | | "--\n" |
346 | | "\n" |
347 | | "Return True if the given string is \"interned\"."); |
348 | | |
349 | | #define SYS__IS_INTERNED_METHODDEF \ |
350 | | {"_is_interned", (PyCFunction)sys__is_interned, METH_O, sys__is_interned__doc__}, |
351 | | |
352 | | static int |
353 | | sys__is_interned_impl(PyObject *module, PyObject *string); |
354 | | |
355 | | static PyObject * |
356 | | sys__is_interned(PyObject *module, PyObject *arg) |
357 | 0 | { |
358 | 0 | PyObject *return_value = NULL; |
359 | 0 | PyObject *string; |
360 | 0 | int _return_value; |
361 | |
|
362 | 0 | if (!PyUnicode_Check(arg)) { |
363 | 0 | _PyArg_BadArgument("_is_interned", "argument", "str", arg); |
364 | 0 | goto exit; |
365 | 0 | } |
366 | 0 | string = arg; |
367 | 0 | _return_value = sys__is_interned_impl(module, string); |
368 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
369 | 0 | goto exit; |
370 | 0 | } |
371 | 0 | return_value = PyBool_FromLong((long)_return_value); |
372 | |
|
373 | 0 | exit: |
374 | 0 | return return_value; |
375 | 0 | } |
376 | | |
377 | | PyDoc_STRVAR(sys__is_immortal__doc__, |
378 | | "_is_immortal($module, op, /)\n" |
379 | | "--\n" |
380 | | "\n" |
381 | | "Return True if the given object is \"immortal\" per PEP 683.\n" |
382 | | "\n" |
383 | | "This function should be used for specialized purposes only."); |
384 | | |
385 | | #define SYS__IS_IMMORTAL_METHODDEF \ |
386 | | {"_is_immortal", (PyCFunction)sys__is_immortal, METH_O, sys__is_immortal__doc__}, |
387 | | |
388 | | static int |
389 | | sys__is_immortal_impl(PyObject *module, PyObject *op); |
390 | | |
391 | | static PyObject * |
392 | | sys__is_immortal(PyObject *module, PyObject *op) |
393 | 0 | { |
394 | 0 | PyObject *return_value = NULL; |
395 | 0 | int _return_value; |
396 | |
|
397 | 0 | _return_value = sys__is_immortal_impl(module, op); |
398 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
399 | 0 | goto exit; |
400 | 0 | } |
401 | 0 | return_value = PyBool_FromLong((long)_return_value); |
402 | |
|
403 | 0 | exit: |
404 | 0 | return return_value; |
405 | 0 | } |
406 | | |
407 | | PyDoc_STRVAR(sys_settrace__doc__, |
408 | | "settrace($module, function, /)\n" |
409 | | "--\n" |
410 | | "\n" |
411 | | "Set the global debug tracing function.\n" |
412 | | "\n" |
413 | | "It will be called on each function call. See the debugger chapter\n" |
414 | | "in the library manual."); |
415 | | |
416 | | #define SYS_SETTRACE_METHODDEF \ |
417 | | {"settrace", (PyCFunction)sys_settrace, METH_O, sys_settrace__doc__}, |
418 | | |
419 | | PyDoc_STRVAR(sys__settraceallthreads__doc__, |
420 | | "_settraceallthreads($module, function, /)\n" |
421 | | "--\n" |
422 | | "\n" |
423 | | "Set the global debug tracing function in all running threads belonging to the current interpreter.\n" |
424 | | "\n" |
425 | | "It will be called on each function call. See the debugger chapter\n" |
426 | | "in the library manual."); |
427 | | |
428 | | #define SYS__SETTRACEALLTHREADS_METHODDEF \ |
429 | | {"_settraceallthreads", (PyCFunction)sys__settraceallthreads, METH_O, sys__settraceallthreads__doc__}, |
430 | | |
431 | | PyDoc_STRVAR(sys_gettrace__doc__, |
432 | | "gettrace($module, /)\n" |
433 | | "--\n" |
434 | | "\n" |
435 | | "Return the global debug tracing function set with sys.settrace.\n" |
436 | | "\n" |
437 | | "See the debugger chapter in the library manual."); |
438 | | |
439 | | #define SYS_GETTRACE_METHODDEF \ |
440 | | {"gettrace", (PyCFunction)sys_gettrace, METH_NOARGS, sys_gettrace__doc__}, |
441 | | |
442 | | static PyObject * |
443 | | sys_gettrace_impl(PyObject *module); |
444 | | |
445 | | static PyObject * |
446 | | sys_gettrace(PyObject *module, PyObject *Py_UNUSED(ignored)) |
447 | 0 | { |
448 | 0 | return sys_gettrace_impl(module); |
449 | 0 | } |
450 | | |
451 | | PyDoc_STRVAR(sys_setprofile__doc__, |
452 | | "setprofile($module, function, /)\n" |
453 | | "--\n" |
454 | | "\n" |
455 | | "Set the profiling function.\n" |
456 | | "\n" |
457 | | "It will be called on each function call and return. See the profiler\n" |
458 | | "chapter in the library manual."); |
459 | | |
460 | | #define SYS_SETPROFILE_METHODDEF \ |
461 | | {"setprofile", (PyCFunction)sys_setprofile, METH_O, sys_setprofile__doc__}, |
462 | | |
463 | | PyDoc_STRVAR(sys__setprofileallthreads__doc__, |
464 | | "_setprofileallthreads($module, function, /)\n" |
465 | | "--\n" |
466 | | "\n" |
467 | | "Set the profiling function in all running threads belonging to the current interpreter.\n" |
468 | | "\n" |
469 | | "It will be called on each function call and return. See the profiler\n" |
470 | | "chapter in the library manual."); |
471 | | |
472 | | #define SYS__SETPROFILEALLTHREADS_METHODDEF \ |
473 | | {"_setprofileallthreads", (PyCFunction)sys__setprofileallthreads, METH_O, sys__setprofileallthreads__doc__}, |
474 | | |
475 | | PyDoc_STRVAR(sys_getprofile__doc__, |
476 | | "getprofile($module, /)\n" |
477 | | "--\n" |
478 | | "\n" |
479 | | "Return the profiling function set with sys.setprofile.\n" |
480 | | "\n" |
481 | | "See the profiler chapter in the library manual."); |
482 | | |
483 | | #define SYS_GETPROFILE_METHODDEF \ |
484 | | {"getprofile", (PyCFunction)sys_getprofile, METH_NOARGS, sys_getprofile__doc__}, |
485 | | |
486 | | static PyObject * |
487 | | sys_getprofile_impl(PyObject *module); |
488 | | |
489 | | static PyObject * |
490 | | sys_getprofile(PyObject *module, PyObject *Py_UNUSED(ignored)) |
491 | 0 | { |
492 | 0 | return sys_getprofile_impl(module); |
493 | 0 | } |
494 | | |
495 | | PyDoc_STRVAR(sys_setswitchinterval__doc__, |
496 | | "setswitchinterval($module, interval, /)\n" |
497 | | "--\n" |
498 | | "\n" |
499 | | "Set the ideal thread switching delay inside the Python interpreter.\n" |
500 | | "\n" |
501 | | "The actual frequency of switching threads can be lower if the\n" |
502 | | "interpreter executes long sequences of uninterruptible code\n" |
503 | | "(this is implementation-specific and workload-dependent).\n" |
504 | | "\n" |
505 | | "The parameter must represent the desired switching delay in seconds\n" |
506 | | "A typical value is 0.005 (5 milliseconds)."); |
507 | | |
508 | | #define SYS_SETSWITCHINTERVAL_METHODDEF \ |
509 | | {"setswitchinterval", (PyCFunction)sys_setswitchinterval, METH_O, sys_setswitchinterval__doc__}, |
510 | | |
511 | | static PyObject * |
512 | | sys_setswitchinterval_impl(PyObject *module, double interval); |
513 | | |
514 | | static PyObject * |
515 | | sys_setswitchinterval(PyObject *module, PyObject *arg) |
516 | 0 | { |
517 | 0 | PyObject *return_value = NULL; |
518 | 0 | double interval; |
519 | |
|
520 | 0 | if (PyFloat_CheckExact(arg)) { |
521 | 0 | interval = PyFloat_AS_DOUBLE(arg); |
522 | 0 | } |
523 | 0 | else |
524 | 0 | { |
525 | 0 | interval = PyFloat_AsDouble(arg); |
526 | 0 | if (interval == -1.0 && PyErr_Occurred()) { |
527 | 0 | goto exit; |
528 | 0 | } |
529 | 0 | } |
530 | 0 | return_value = sys_setswitchinterval_impl(module, interval); |
531 | |
|
532 | 0 | exit: |
533 | 0 | return return_value; |
534 | 0 | } |
535 | | |
536 | | PyDoc_STRVAR(sys_getswitchinterval__doc__, |
537 | | "getswitchinterval($module, /)\n" |
538 | | "--\n" |
539 | | "\n" |
540 | | "Return the current thread switch interval; see sys.setswitchinterval()."); |
541 | | |
542 | | #define SYS_GETSWITCHINTERVAL_METHODDEF \ |
543 | | {"getswitchinterval", (PyCFunction)sys_getswitchinterval, METH_NOARGS, sys_getswitchinterval__doc__}, |
544 | | |
545 | | static double |
546 | | sys_getswitchinterval_impl(PyObject *module); |
547 | | |
548 | | static PyObject * |
549 | | sys_getswitchinterval(PyObject *module, PyObject *Py_UNUSED(ignored)) |
550 | 0 | { |
551 | 0 | PyObject *return_value = NULL; |
552 | 0 | double _return_value; |
553 | |
|
554 | 0 | _return_value = sys_getswitchinterval_impl(module); |
555 | 0 | if ((_return_value == -1.0) && PyErr_Occurred()) { |
556 | 0 | goto exit; |
557 | 0 | } |
558 | 0 | return_value = PyFloat_FromDouble(_return_value); |
559 | |
|
560 | 0 | exit: |
561 | 0 | return return_value; |
562 | 0 | } |
563 | | |
564 | | PyDoc_STRVAR(sys_setrecursionlimit__doc__, |
565 | | "setrecursionlimit($module, limit, /)\n" |
566 | | "--\n" |
567 | | "\n" |
568 | | "Set the maximum depth of the Python interpreter stack to n.\n" |
569 | | "\n" |
570 | | "This limit prevents infinite recursion from causing an overflow of the C\n" |
571 | | "stack and crashing Python. The highest possible limit is platform-\n" |
572 | | "dependent."); |
573 | | |
574 | | #define SYS_SETRECURSIONLIMIT_METHODDEF \ |
575 | | {"setrecursionlimit", (PyCFunction)sys_setrecursionlimit, METH_O, sys_setrecursionlimit__doc__}, |
576 | | |
577 | | static PyObject * |
578 | | sys_setrecursionlimit_impl(PyObject *module, int new_limit); |
579 | | |
580 | | static PyObject * |
581 | | sys_setrecursionlimit(PyObject *module, PyObject *arg) |
582 | 472 | { |
583 | 472 | PyObject *return_value = NULL; |
584 | 472 | int new_limit; |
585 | | |
586 | 472 | new_limit = PyLong_AsInt(arg); |
587 | 472 | if (new_limit == -1 && PyErr_Occurred()) { |
588 | 0 | goto exit; |
589 | 0 | } |
590 | 472 | return_value = sys_setrecursionlimit_impl(module, new_limit); |
591 | | |
592 | 472 | exit: |
593 | 472 | return return_value; |
594 | 472 | } |
595 | | |
596 | | PyDoc_STRVAR(sys_set_coroutine_origin_tracking_depth__doc__, |
597 | | "set_coroutine_origin_tracking_depth($module, /, depth)\n" |
598 | | "--\n" |
599 | | "\n" |
600 | | "Enable or disable origin tracking for coroutine objects in this thread.\n" |
601 | | "\n" |
602 | | "Coroutine objects will track \'depth\' frames of traceback information\n" |
603 | | "about where they came from, available in their cr_origin attribute.\n" |
604 | | "\n" |
605 | | "Set a depth of 0 to disable."); |
606 | | |
607 | | #define SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \ |
608 | | {"set_coroutine_origin_tracking_depth", _PyCFunction_CAST(sys_set_coroutine_origin_tracking_depth), METH_FASTCALL|METH_KEYWORDS, sys_set_coroutine_origin_tracking_depth__doc__}, |
609 | | |
610 | | static PyObject * |
611 | | sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth); |
612 | | |
613 | | static PyObject * |
614 | | sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
615 | 0 | { |
616 | 0 | PyObject *return_value = NULL; |
617 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
618 | |
|
619 | 0 | #define NUM_KEYWORDS 1 |
620 | 0 | static struct { |
621 | 0 | PyGC_Head _this_is_not_used; |
622 | 0 | PyObject_VAR_HEAD |
623 | 0 | Py_hash_t ob_hash; |
624 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
625 | 0 | } _kwtuple = { |
626 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
627 | 0 | .ob_hash = -1, |
628 | 0 | .ob_item = { &_Py_ID(depth), }, |
629 | 0 | }; |
630 | 0 | #undef NUM_KEYWORDS |
631 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
632 | |
|
633 | | #else // !Py_BUILD_CORE |
634 | | # define KWTUPLE NULL |
635 | | #endif // !Py_BUILD_CORE |
636 | |
|
637 | 0 | static const char * const _keywords[] = {"depth", NULL}; |
638 | 0 | static _PyArg_Parser _parser = { |
639 | 0 | .keywords = _keywords, |
640 | 0 | .fname = "set_coroutine_origin_tracking_depth", |
641 | 0 | .kwtuple = KWTUPLE, |
642 | 0 | }; |
643 | 0 | #undef KWTUPLE |
644 | 0 | PyObject *argsbuf[1]; |
645 | 0 | int depth; |
646 | |
|
647 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
648 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
649 | 0 | if (!args) { |
650 | 0 | goto exit; |
651 | 0 | } |
652 | 0 | depth = PyLong_AsInt(args[0]); |
653 | 0 | if (depth == -1 && PyErr_Occurred()) { |
654 | 0 | goto exit; |
655 | 0 | } |
656 | 0 | return_value = sys_set_coroutine_origin_tracking_depth_impl(module, depth); |
657 | |
|
658 | 0 | exit: |
659 | 0 | return return_value; |
660 | 0 | } |
661 | | |
662 | | PyDoc_STRVAR(sys_get_coroutine_origin_tracking_depth__doc__, |
663 | | "get_coroutine_origin_tracking_depth($module, /)\n" |
664 | | "--\n" |
665 | | "\n" |
666 | | "Check status of origin tracking for coroutine objects in this thread."); |
667 | | |
668 | | #define SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \ |
669 | | {"get_coroutine_origin_tracking_depth", (PyCFunction)sys_get_coroutine_origin_tracking_depth, METH_NOARGS, sys_get_coroutine_origin_tracking_depth__doc__}, |
670 | | |
671 | | static int |
672 | | sys_get_coroutine_origin_tracking_depth_impl(PyObject *module); |
673 | | |
674 | | static PyObject * |
675 | | sys_get_coroutine_origin_tracking_depth(PyObject *module, PyObject *Py_UNUSED(ignored)) |
676 | 0 | { |
677 | 0 | PyObject *return_value = NULL; |
678 | 0 | int _return_value; |
679 | |
|
680 | 0 | _return_value = sys_get_coroutine_origin_tracking_depth_impl(module); |
681 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
682 | 0 | goto exit; |
683 | 0 | } |
684 | 0 | return_value = PyLong_FromLong((long)_return_value); |
685 | |
|
686 | 0 | exit: |
687 | 0 | return return_value; |
688 | 0 | } |
689 | | |
690 | | PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__, |
691 | | "get_asyncgen_hooks($module, /)\n" |
692 | | "--\n" |
693 | | "\n" |
694 | | "Return the installed asynchronous generators hooks.\n" |
695 | | "\n" |
696 | | "This returns a namedtuple of the form (firstiter, finalizer)."); |
697 | | |
698 | | #define SYS_GET_ASYNCGEN_HOOKS_METHODDEF \ |
699 | | {"get_asyncgen_hooks", (PyCFunction)sys_get_asyncgen_hooks, METH_NOARGS, sys_get_asyncgen_hooks__doc__}, |
700 | | |
701 | | static PyObject * |
702 | | sys_get_asyncgen_hooks_impl(PyObject *module); |
703 | | |
704 | | static PyObject * |
705 | | sys_get_asyncgen_hooks(PyObject *module, PyObject *Py_UNUSED(ignored)) |
706 | 0 | { |
707 | 0 | return sys_get_asyncgen_hooks_impl(module); |
708 | 0 | } |
709 | | |
710 | | PyDoc_STRVAR(sys_getrecursionlimit__doc__, |
711 | | "getrecursionlimit($module, /)\n" |
712 | | "--\n" |
713 | | "\n" |
714 | | "Return the current value of the recursion limit.\n" |
715 | | "\n" |
716 | | "The recursion limit is the maximum depth of the Python interpreter\n" |
717 | | "stack. This limit prevents infinite recursion from causing an overflow\n" |
718 | | "of the C stack and crashing Python."); |
719 | | |
720 | | #define SYS_GETRECURSIONLIMIT_METHODDEF \ |
721 | | {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, sys_getrecursionlimit__doc__}, |
722 | | |
723 | | static PyObject * |
724 | | sys_getrecursionlimit_impl(PyObject *module); |
725 | | |
726 | | static PyObject * |
727 | | sys_getrecursionlimit(PyObject *module, PyObject *Py_UNUSED(ignored)) |
728 | 872 | { |
729 | 872 | return sys_getrecursionlimit_impl(module); |
730 | 872 | } |
731 | | |
732 | | #if defined(MS_WINDOWS) |
733 | | |
734 | | PyDoc_STRVAR(sys_getwindowsversion__doc__, |
735 | | "getwindowsversion($module, /)\n" |
736 | | "--\n" |
737 | | "\n" |
738 | | "Return info about the running version of Windows as a named tuple.\n" |
739 | | "\n" |
740 | | "The members are named: major, minor, build, platform, service_pack,\n" |
741 | | "service_pack_major, service_pack_minor, suite_mask, product_type and\n" |
742 | | "platform_version. For backward compatibility, only the first 5 items\n" |
743 | | "are available by indexing. All elements are numbers, except\n" |
744 | | "service_pack and platform_type which are strings, and platform_version\n" |
745 | | "which is a 3-tuple. Platform is always 2. Product_type may be 1 for a\n" |
746 | | "workstation, 2 for a domain controller, 3 for a server.\n" |
747 | | "Platform_version is a 3-tuple containing a version number that is\n" |
748 | | "intended for identifying the OS rather than feature detection."); |
749 | | |
750 | | #define SYS_GETWINDOWSVERSION_METHODDEF \ |
751 | | {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, sys_getwindowsversion__doc__}, |
752 | | |
753 | | static PyObject * |
754 | | sys_getwindowsversion_impl(PyObject *module); |
755 | | |
756 | | static PyObject * |
757 | | sys_getwindowsversion(PyObject *module, PyObject *Py_UNUSED(ignored)) |
758 | | { |
759 | | return sys_getwindowsversion_impl(module); |
760 | | } |
761 | | |
762 | | #endif /* defined(MS_WINDOWS) */ |
763 | | |
764 | | #if defined(HAVE_DLOPEN) |
765 | | |
766 | | PyDoc_STRVAR(sys_setdlopenflags__doc__, |
767 | | "setdlopenflags($module, flags, /)\n" |
768 | | "--\n" |
769 | | "\n" |
770 | | "Set the flags used by the interpreter for dlopen calls.\n" |
771 | | "\n" |
772 | | "This is used, for example, when the interpreter loads extension\n" |
773 | | "modules. Among other things, this will enable a lazy resolving of\n" |
774 | | "symbols when importing a module, if called as sys.setdlopenflags(0).\n" |
775 | | "To share symbols across extension modules, call as\n" |
776 | | "sys.setdlopenflags(os.RTLD_GLOBAL). Symbolic names for the flag\n" |
777 | | "modules can be found in the os module (RTLD_xxx constants, e.g.\n" |
778 | | "os.RTLD_LAZY)."); |
779 | | |
780 | | #define SYS_SETDLOPENFLAGS_METHODDEF \ |
781 | | {"setdlopenflags", (PyCFunction)sys_setdlopenflags, METH_O, sys_setdlopenflags__doc__}, |
782 | | |
783 | | static PyObject * |
784 | | sys_setdlopenflags_impl(PyObject *module, int new_val); |
785 | | |
786 | | static PyObject * |
787 | | sys_setdlopenflags(PyObject *module, PyObject *arg) |
788 | 0 | { |
789 | 0 | PyObject *return_value = NULL; |
790 | 0 | int new_val; |
791 | |
|
792 | 0 | new_val = PyLong_AsInt(arg); |
793 | 0 | if (new_val == -1 && PyErr_Occurred()) { |
794 | 0 | goto exit; |
795 | 0 | } |
796 | 0 | return_value = sys_setdlopenflags_impl(module, new_val); |
797 | |
|
798 | 0 | exit: |
799 | 0 | return return_value; |
800 | 0 | } |
801 | | |
802 | | #endif /* defined(HAVE_DLOPEN) */ |
803 | | |
804 | | #if defined(HAVE_DLOPEN) |
805 | | |
806 | | PyDoc_STRVAR(sys_getdlopenflags__doc__, |
807 | | "getdlopenflags($module, /)\n" |
808 | | "--\n" |
809 | | "\n" |
810 | | "Return the current value of the flags that are used for dlopen calls.\n" |
811 | | "\n" |
812 | | "The flag constants are defined in the os module."); |
813 | | |
814 | | #define SYS_GETDLOPENFLAGS_METHODDEF \ |
815 | | {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, sys_getdlopenflags__doc__}, |
816 | | |
817 | | static PyObject * |
818 | | sys_getdlopenflags_impl(PyObject *module); |
819 | | |
820 | | static PyObject * |
821 | | sys_getdlopenflags(PyObject *module, PyObject *Py_UNUSED(ignored)) |
822 | 0 | { |
823 | 0 | return sys_getdlopenflags_impl(module); |
824 | 0 | } |
825 | | |
826 | | #endif /* defined(HAVE_DLOPEN) */ |
827 | | |
828 | | #if defined(USE_MALLOPT) |
829 | | |
830 | | PyDoc_STRVAR(sys_mdebug__doc__, |
831 | | "mdebug($module, flag, /)\n" |
832 | | "--\n" |
833 | | "\n"); |
834 | | |
835 | | #define SYS_MDEBUG_METHODDEF \ |
836 | | {"mdebug", (PyCFunction)sys_mdebug, METH_O, sys_mdebug__doc__}, |
837 | | |
838 | | static PyObject * |
839 | | sys_mdebug_impl(PyObject *module, int flag); |
840 | | |
841 | | static PyObject * |
842 | | sys_mdebug(PyObject *module, PyObject *arg) |
843 | | { |
844 | | PyObject *return_value = NULL; |
845 | | int flag; |
846 | | |
847 | | flag = PyLong_AsInt(arg); |
848 | | if (flag == -1 && PyErr_Occurred()) { |
849 | | goto exit; |
850 | | } |
851 | | return_value = sys_mdebug_impl(module, flag); |
852 | | |
853 | | exit: |
854 | | return return_value; |
855 | | } |
856 | | |
857 | | #endif /* defined(USE_MALLOPT) */ |
858 | | |
859 | | PyDoc_STRVAR(sys_get_int_max_str_digits__doc__, |
860 | | "get_int_max_str_digits($module, /)\n" |
861 | | "--\n" |
862 | | "\n" |
863 | | "Return the maximum string digits limit for non-binary int<->str conversions."); |
864 | | |
865 | | #define SYS_GET_INT_MAX_STR_DIGITS_METHODDEF \ |
866 | | {"get_int_max_str_digits", (PyCFunction)sys_get_int_max_str_digits, METH_NOARGS, sys_get_int_max_str_digits__doc__}, |
867 | | |
868 | | static PyObject * |
869 | | sys_get_int_max_str_digits_impl(PyObject *module); |
870 | | |
871 | | static PyObject * |
872 | | sys_get_int_max_str_digits(PyObject *module, PyObject *Py_UNUSED(ignored)) |
873 | 0 | { |
874 | 0 | return sys_get_int_max_str_digits_impl(module); |
875 | 0 | } |
876 | | |
877 | | PyDoc_STRVAR(sys_set_int_max_str_digits__doc__, |
878 | | "set_int_max_str_digits($module, /, maxdigits)\n" |
879 | | "--\n" |
880 | | "\n" |
881 | | "Set the maximum string digits limit for non-binary int<->str conversions."); |
882 | | |
883 | | #define SYS_SET_INT_MAX_STR_DIGITS_METHODDEF \ |
884 | | {"set_int_max_str_digits", _PyCFunction_CAST(sys_set_int_max_str_digits), METH_FASTCALL|METH_KEYWORDS, sys_set_int_max_str_digits__doc__}, |
885 | | |
886 | | static PyObject * |
887 | | sys_set_int_max_str_digits_impl(PyObject *module, int maxdigits); |
888 | | |
889 | | static PyObject * |
890 | | sys_set_int_max_str_digits(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
891 | 0 | { |
892 | 0 | PyObject *return_value = NULL; |
893 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
894 | |
|
895 | 0 | #define NUM_KEYWORDS 1 |
896 | 0 | static struct { |
897 | 0 | PyGC_Head _this_is_not_used; |
898 | 0 | PyObject_VAR_HEAD |
899 | 0 | Py_hash_t ob_hash; |
900 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
901 | 0 | } _kwtuple = { |
902 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
903 | 0 | .ob_hash = -1, |
904 | 0 | .ob_item = { &_Py_ID(maxdigits), }, |
905 | 0 | }; |
906 | 0 | #undef NUM_KEYWORDS |
907 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
908 | |
|
909 | | #else // !Py_BUILD_CORE |
910 | | # define KWTUPLE NULL |
911 | | #endif // !Py_BUILD_CORE |
912 | |
|
913 | 0 | static const char * const _keywords[] = {"maxdigits", NULL}; |
914 | 0 | static _PyArg_Parser _parser = { |
915 | 0 | .keywords = _keywords, |
916 | 0 | .fname = "set_int_max_str_digits", |
917 | 0 | .kwtuple = KWTUPLE, |
918 | 0 | }; |
919 | 0 | #undef KWTUPLE |
920 | 0 | PyObject *argsbuf[1]; |
921 | 0 | int maxdigits; |
922 | |
|
923 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
924 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
925 | 0 | if (!args) { |
926 | 0 | goto exit; |
927 | 0 | } |
928 | 0 | maxdigits = PyLong_AsInt(args[0]); |
929 | 0 | if (maxdigits == -1 && PyErr_Occurred()) { |
930 | 0 | goto exit; |
931 | 0 | } |
932 | 0 | return_value = sys_set_int_max_str_digits_impl(module, maxdigits); |
933 | |
|
934 | 0 | exit: |
935 | 0 | return return_value; |
936 | 0 | } |
937 | | |
938 | | PyDoc_STRVAR(sys_getrefcount__doc__, |
939 | | "getrefcount($module, object, /)\n" |
940 | | "--\n" |
941 | | "\n" |
942 | | "Return the reference count of object.\n" |
943 | | "\n" |
944 | | "The count returned is generally one higher than you might expect,\n" |
945 | | "because it includes the (temporary) reference as an argument to\n" |
946 | | "getrefcount()."); |
947 | | |
948 | | #define SYS_GETREFCOUNT_METHODDEF \ |
949 | | {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__}, |
950 | | |
951 | | static Py_ssize_t |
952 | | sys_getrefcount_impl(PyObject *module, PyObject *object); |
953 | | |
954 | | static PyObject * |
955 | | sys_getrefcount(PyObject *module, PyObject *object) |
956 | 4 | { |
957 | 4 | PyObject *return_value = NULL; |
958 | 4 | Py_ssize_t _return_value; |
959 | | |
960 | 4 | _return_value = sys_getrefcount_impl(module, object); |
961 | 4 | if ((_return_value == -1) && PyErr_Occurred()) { |
962 | 0 | goto exit; |
963 | 0 | } |
964 | 4 | return_value = PyLong_FromSsize_t(_return_value); |
965 | | |
966 | 4 | exit: |
967 | 4 | return return_value; |
968 | 4 | } |
969 | | |
970 | | #if defined(Py_REF_DEBUG) |
971 | | |
972 | | PyDoc_STRVAR(sys_gettotalrefcount__doc__, |
973 | | "gettotalrefcount($module, /)\n" |
974 | | "--\n" |
975 | | "\n"); |
976 | | |
977 | | #define SYS_GETTOTALREFCOUNT_METHODDEF \ |
978 | | {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__}, |
979 | | |
980 | | static Py_ssize_t |
981 | | sys_gettotalrefcount_impl(PyObject *module); |
982 | | |
983 | | static PyObject * |
984 | | sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored)) |
985 | | { |
986 | | PyObject *return_value = NULL; |
987 | | Py_ssize_t _return_value; |
988 | | |
989 | | _return_value = sys_gettotalrefcount_impl(module); |
990 | | if ((_return_value == -1) && PyErr_Occurred()) { |
991 | | goto exit; |
992 | | } |
993 | | return_value = PyLong_FromSsize_t(_return_value); |
994 | | |
995 | | exit: |
996 | | return return_value; |
997 | | } |
998 | | |
999 | | #endif /* defined(Py_REF_DEBUG) */ |
1000 | | |
1001 | | PyDoc_STRVAR(sys_getallocatedblocks__doc__, |
1002 | | "getallocatedblocks($module, /)\n" |
1003 | | "--\n" |
1004 | | "\n" |
1005 | | "Return the number of memory blocks currently allocated."); |
1006 | | |
1007 | | #define SYS_GETALLOCATEDBLOCKS_METHODDEF \ |
1008 | | {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__}, |
1009 | | |
1010 | | static Py_ssize_t |
1011 | | sys_getallocatedblocks_impl(PyObject *module); |
1012 | | |
1013 | | static PyObject * |
1014 | | sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1015 | 0 | { |
1016 | 0 | PyObject *return_value = NULL; |
1017 | 0 | Py_ssize_t _return_value; |
1018 | |
|
1019 | 0 | _return_value = sys_getallocatedblocks_impl(module); |
1020 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
1021 | 0 | goto exit; |
1022 | 0 | } |
1023 | 0 | return_value = PyLong_FromSsize_t(_return_value); |
1024 | |
|
1025 | 0 | exit: |
1026 | 0 | return return_value; |
1027 | 0 | } |
1028 | | |
1029 | | PyDoc_STRVAR(sys_getunicodeinternedsize__doc__, |
1030 | | "getunicodeinternedsize($module, /, *, _only_immortal=False)\n" |
1031 | | "--\n" |
1032 | | "\n" |
1033 | | "Return the number of elements of the unicode interned dictionary"); |
1034 | | |
1035 | | #define SYS_GETUNICODEINTERNEDSIZE_METHODDEF \ |
1036 | | {"getunicodeinternedsize", _PyCFunction_CAST(sys_getunicodeinternedsize), METH_FASTCALL|METH_KEYWORDS, sys_getunicodeinternedsize__doc__}, |
1037 | | |
1038 | | static Py_ssize_t |
1039 | | sys_getunicodeinternedsize_impl(PyObject *module, int _only_immortal); |
1040 | | |
1041 | | static PyObject * |
1042 | | sys_getunicodeinternedsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1043 | 0 | { |
1044 | 0 | PyObject *return_value = NULL; |
1045 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
1046 | |
|
1047 | 0 | #define NUM_KEYWORDS 1 |
1048 | 0 | static struct { |
1049 | 0 | PyGC_Head _this_is_not_used; |
1050 | 0 | PyObject_VAR_HEAD |
1051 | 0 | Py_hash_t ob_hash; |
1052 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
1053 | 0 | } _kwtuple = { |
1054 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
1055 | 0 | .ob_hash = -1, |
1056 | 0 | .ob_item = { &_Py_ID(_only_immortal), }, |
1057 | 0 | }; |
1058 | 0 | #undef NUM_KEYWORDS |
1059 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
1060 | |
|
1061 | | #else // !Py_BUILD_CORE |
1062 | | # define KWTUPLE NULL |
1063 | | #endif // !Py_BUILD_CORE |
1064 | |
|
1065 | 0 | static const char * const _keywords[] = {"_only_immortal", NULL}; |
1066 | 0 | static _PyArg_Parser _parser = { |
1067 | 0 | .keywords = _keywords, |
1068 | 0 | .fname = "getunicodeinternedsize", |
1069 | 0 | .kwtuple = KWTUPLE, |
1070 | 0 | }; |
1071 | 0 | #undef KWTUPLE |
1072 | 0 | PyObject *argsbuf[1]; |
1073 | 0 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
1074 | 0 | int _only_immortal = 0; |
1075 | 0 | Py_ssize_t _return_value; |
1076 | |
|
1077 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
1078 | 0 | /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
1079 | 0 | if (!args) { |
1080 | 0 | goto exit; |
1081 | 0 | } |
1082 | 0 | if (!noptargs) { |
1083 | 0 | goto skip_optional_kwonly; |
1084 | 0 | } |
1085 | 0 | _only_immortal = PyObject_IsTrue(args[0]); |
1086 | 0 | if (_only_immortal < 0) { |
1087 | 0 | goto exit; |
1088 | 0 | } |
1089 | 0 | skip_optional_kwonly: |
1090 | 0 | _return_value = sys_getunicodeinternedsize_impl(module, _only_immortal); |
1091 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
1092 | 0 | goto exit; |
1093 | 0 | } |
1094 | 0 | return_value = PyLong_FromSsize_t(_return_value); |
1095 | |
|
1096 | 0 | exit: |
1097 | 0 | return return_value; |
1098 | 0 | } |
1099 | | |
1100 | | PyDoc_STRVAR(sys__getframe__doc__, |
1101 | | "_getframe($module, depth=0, /)\n" |
1102 | | "--\n" |
1103 | | "\n" |
1104 | | "Return a frame object from the call stack.\n" |
1105 | | "\n" |
1106 | | "If optional integer depth is given, return the frame object that many\n" |
1107 | | "calls below the top of the stack. If that is deeper than the call\n" |
1108 | | "stack, ValueError is raised. The default for depth is zero, returning\n" |
1109 | | "the frame at the top of the call stack.\n" |
1110 | | "\n" |
1111 | | "This function should be used for internal and specialized purposes\n" |
1112 | | "only."); |
1113 | | |
1114 | | #define SYS__GETFRAME_METHODDEF \ |
1115 | | {"_getframe", _PyCFunction_CAST(sys__getframe), METH_FASTCALL, sys__getframe__doc__}, |
1116 | | |
1117 | | static PyObject * |
1118 | | sys__getframe_impl(PyObject *module, int depth); |
1119 | | |
1120 | | static PyObject * |
1121 | | sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
1122 | 273 | { |
1123 | 273 | PyObject *return_value = NULL; |
1124 | 273 | int depth = 0; |
1125 | | |
1126 | 273 | if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) { |
1127 | 0 | goto exit; |
1128 | 0 | } |
1129 | 273 | if (nargs < 1) { |
1130 | 37 | goto skip_optional; |
1131 | 37 | } |
1132 | 236 | depth = PyLong_AsInt(args[0]); |
1133 | 236 | if (depth == -1 && PyErr_Occurred()) { |
1134 | 0 | goto exit; |
1135 | 0 | } |
1136 | 273 | skip_optional: |
1137 | 273 | return_value = sys__getframe_impl(module, depth); |
1138 | | |
1139 | 273 | exit: |
1140 | 273 | return return_value; |
1141 | 273 | } |
1142 | | |
1143 | | PyDoc_STRVAR(sys__current_frames__doc__, |
1144 | | "_current_frames($module, /)\n" |
1145 | | "--\n" |
1146 | | "\n" |
1147 | | "Return a dict mapping each thread\'s thread id to its current stack frame.\n" |
1148 | | "\n" |
1149 | | "This function should be used for specialized purposes only."); |
1150 | | |
1151 | | #define SYS__CURRENT_FRAMES_METHODDEF \ |
1152 | | {"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__}, |
1153 | | |
1154 | | static PyObject * |
1155 | | sys__current_frames_impl(PyObject *module); |
1156 | | |
1157 | | static PyObject * |
1158 | | sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1159 | 0 | { |
1160 | 0 | return sys__current_frames_impl(module); |
1161 | 0 | } |
1162 | | |
1163 | | PyDoc_STRVAR(sys__current_exceptions__doc__, |
1164 | | "_current_exceptions($module, /)\n" |
1165 | | "--\n" |
1166 | | "\n" |
1167 | | "Return a dict mapping each thread\'s identifier to its current raised exception.\n" |
1168 | | "\n" |
1169 | | "This function should be used for specialized purposes only."); |
1170 | | |
1171 | | #define SYS__CURRENT_EXCEPTIONS_METHODDEF \ |
1172 | | {"_current_exceptions", (PyCFunction)sys__current_exceptions, METH_NOARGS, sys__current_exceptions__doc__}, |
1173 | | |
1174 | | static PyObject * |
1175 | | sys__current_exceptions_impl(PyObject *module); |
1176 | | |
1177 | | static PyObject * |
1178 | | sys__current_exceptions(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1179 | 0 | { |
1180 | 0 | return sys__current_exceptions_impl(module); |
1181 | 0 | } |
1182 | | |
1183 | | PyDoc_STRVAR(sys_call_tracing__doc__, |
1184 | | "call_tracing($module, func, args, /)\n" |
1185 | | "--\n" |
1186 | | "\n" |
1187 | | "Call func(*args), while tracing is enabled.\n" |
1188 | | "\n" |
1189 | | "The tracing state is saved, and restored afterwards. This is intended\n" |
1190 | | "to be called from a debugger from a checkpoint, to recursively debug\n" |
1191 | | "some other code."); |
1192 | | |
1193 | | #define SYS_CALL_TRACING_METHODDEF \ |
1194 | | {"call_tracing", _PyCFunction_CAST(sys_call_tracing), METH_FASTCALL, sys_call_tracing__doc__}, |
1195 | | |
1196 | | static PyObject * |
1197 | | sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs); |
1198 | | |
1199 | | static PyObject * |
1200 | | sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
1201 | 0 | { |
1202 | 0 | PyObject *return_value = NULL; |
1203 | 0 | PyObject *func; |
1204 | 0 | PyObject *funcargs; |
1205 | |
|
1206 | 0 | if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) { |
1207 | 0 | goto exit; |
1208 | 0 | } |
1209 | 0 | func = args[0]; |
1210 | 0 | if (!PyTuple_Check(args[1])) { |
1211 | 0 | _PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]); |
1212 | 0 | goto exit; |
1213 | 0 | } |
1214 | 0 | funcargs = args[1]; |
1215 | 0 | return_value = sys_call_tracing_impl(module, func, funcargs); |
1216 | |
|
1217 | 0 | exit: |
1218 | 0 | return return_value; |
1219 | 0 | } |
1220 | | |
1221 | | PyDoc_STRVAR(sys__debugmallocstats__doc__, |
1222 | | "_debugmallocstats($module, /)\n" |
1223 | | "--\n" |
1224 | | "\n" |
1225 | | "Print summary info to stderr about the state of pymalloc\'s structures.\n" |
1226 | | "\n" |
1227 | | "In Py_DEBUG mode, also perform some expensive internal consistency\n" |
1228 | | "checks."); |
1229 | | |
1230 | | #define SYS__DEBUGMALLOCSTATS_METHODDEF \ |
1231 | | {"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__}, |
1232 | | |
1233 | | static PyObject * |
1234 | | sys__debugmallocstats_impl(PyObject *module); |
1235 | | |
1236 | | static PyObject * |
1237 | | sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1238 | 0 | { |
1239 | 0 | return sys__debugmallocstats_impl(module); |
1240 | 0 | } |
1241 | | |
1242 | | PyDoc_STRVAR(sys__clear_type_cache__doc__, |
1243 | | "_clear_type_cache($module, /)\n" |
1244 | | "--\n" |
1245 | | "\n" |
1246 | | "Clear the internal type lookup cache."); |
1247 | | |
1248 | | #define SYS__CLEAR_TYPE_CACHE_METHODDEF \ |
1249 | | {"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__}, |
1250 | | |
1251 | | static PyObject * |
1252 | | sys__clear_type_cache_impl(PyObject *module); |
1253 | | |
1254 | | static PyObject * |
1255 | | sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1256 | 0 | { |
1257 | 0 | return sys__clear_type_cache_impl(module); |
1258 | 0 | } |
1259 | | |
1260 | | PyDoc_STRVAR(sys__clear_internal_caches__doc__, |
1261 | | "_clear_internal_caches($module, /)\n" |
1262 | | "--\n" |
1263 | | "\n" |
1264 | | "Clear all internal performance-related caches."); |
1265 | | |
1266 | | #define SYS__CLEAR_INTERNAL_CACHES_METHODDEF \ |
1267 | | {"_clear_internal_caches", (PyCFunction)sys__clear_internal_caches, METH_NOARGS, sys__clear_internal_caches__doc__}, |
1268 | | |
1269 | | static PyObject * |
1270 | | sys__clear_internal_caches_impl(PyObject *module); |
1271 | | |
1272 | | static PyObject * |
1273 | | sys__clear_internal_caches(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1274 | 0 | { |
1275 | 0 | return sys__clear_internal_caches_impl(module); |
1276 | 0 | } |
1277 | | |
1278 | | PyDoc_STRVAR(sys_is_finalizing__doc__, |
1279 | | "is_finalizing($module, /)\n" |
1280 | | "--\n" |
1281 | | "\n" |
1282 | | "Return True if Python is exiting."); |
1283 | | |
1284 | | #define SYS_IS_FINALIZING_METHODDEF \ |
1285 | | {"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__}, |
1286 | | |
1287 | | static PyObject * |
1288 | | sys_is_finalizing_impl(PyObject *module); |
1289 | | |
1290 | | static PyObject * |
1291 | | sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1292 | 0 | { |
1293 | 0 | return sys_is_finalizing_impl(module); |
1294 | 0 | } |
1295 | | |
1296 | | #if defined(Py_STATS) |
1297 | | |
1298 | | PyDoc_STRVAR(sys__stats_on__doc__, |
1299 | | "_stats_on($module, /)\n" |
1300 | | "--\n" |
1301 | | "\n" |
1302 | | "Turns on stats gathering (stats gathering is off by default)."); |
1303 | | |
1304 | | #define SYS__STATS_ON_METHODDEF \ |
1305 | | {"_stats_on", (PyCFunction)sys__stats_on, METH_NOARGS, sys__stats_on__doc__}, |
1306 | | |
1307 | | static PyObject * |
1308 | | sys__stats_on_impl(PyObject *module); |
1309 | | |
1310 | | static PyObject * |
1311 | | sys__stats_on(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1312 | | { |
1313 | | return sys__stats_on_impl(module); |
1314 | | } |
1315 | | |
1316 | | #endif /* defined(Py_STATS) */ |
1317 | | |
1318 | | #if defined(Py_STATS) |
1319 | | |
1320 | | PyDoc_STRVAR(sys__stats_off__doc__, |
1321 | | "_stats_off($module, /)\n" |
1322 | | "--\n" |
1323 | | "\n" |
1324 | | "Turns off stats gathering (stats gathering is off by default)."); |
1325 | | |
1326 | | #define SYS__STATS_OFF_METHODDEF \ |
1327 | | {"_stats_off", (PyCFunction)sys__stats_off, METH_NOARGS, sys__stats_off__doc__}, |
1328 | | |
1329 | | static PyObject * |
1330 | | sys__stats_off_impl(PyObject *module); |
1331 | | |
1332 | | static PyObject * |
1333 | | sys__stats_off(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1334 | | { |
1335 | | return sys__stats_off_impl(module); |
1336 | | } |
1337 | | |
1338 | | #endif /* defined(Py_STATS) */ |
1339 | | |
1340 | | #if defined(Py_STATS) |
1341 | | |
1342 | | PyDoc_STRVAR(sys__stats_clear__doc__, |
1343 | | "_stats_clear($module, /)\n" |
1344 | | "--\n" |
1345 | | "\n" |
1346 | | "Clears the stats."); |
1347 | | |
1348 | | #define SYS__STATS_CLEAR_METHODDEF \ |
1349 | | {"_stats_clear", (PyCFunction)sys__stats_clear, METH_NOARGS, sys__stats_clear__doc__}, |
1350 | | |
1351 | | static PyObject * |
1352 | | sys__stats_clear_impl(PyObject *module); |
1353 | | |
1354 | | static PyObject * |
1355 | | sys__stats_clear(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1356 | | { |
1357 | | return sys__stats_clear_impl(module); |
1358 | | } |
1359 | | |
1360 | | #endif /* defined(Py_STATS) */ |
1361 | | |
1362 | | #if defined(Py_STATS) |
1363 | | |
1364 | | PyDoc_STRVAR(sys__stats_dump__doc__, |
1365 | | "_stats_dump($module, /)\n" |
1366 | | "--\n" |
1367 | | "\n" |
1368 | | "Dump stats to file, and clears the stats.\n" |
1369 | | "\n" |
1370 | | "Return False if no statistics were not dumped because stats gathering\n" |
1371 | | "was off."); |
1372 | | |
1373 | | #define SYS__STATS_DUMP_METHODDEF \ |
1374 | | {"_stats_dump", (PyCFunction)sys__stats_dump, METH_NOARGS, sys__stats_dump__doc__}, |
1375 | | |
1376 | | static int |
1377 | | sys__stats_dump_impl(PyObject *module); |
1378 | | |
1379 | | static PyObject * |
1380 | | sys__stats_dump(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1381 | | { |
1382 | | PyObject *return_value = NULL; |
1383 | | int _return_value; |
1384 | | |
1385 | | _return_value = sys__stats_dump_impl(module); |
1386 | | if ((_return_value == -1) && PyErr_Occurred()) { |
1387 | | goto exit; |
1388 | | } |
1389 | | return_value = PyBool_FromLong((long)_return_value); |
1390 | | |
1391 | | exit: |
1392 | | return return_value; |
1393 | | } |
1394 | | |
1395 | | #endif /* defined(Py_STATS) */ |
1396 | | |
1397 | | #if defined(ANDROID_API_LEVEL) |
1398 | | |
1399 | | PyDoc_STRVAR(sys_getandroidapilevel__doc__, |
1400 | | "getandroidapilevel($module, /)\n" |
1401 | | "--\n" |
1402 | | "\n" |
1403 | | "Return the build time API version of Android as an integer."); |
1404 | | |
1405 | | #define SYS_GETANDROIDAPILEVEL_METHODDEF \ |
1406 | | {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__}, |
1407 | | |
1408 | | static PyObject * |
1409 | | sys_getandroidapilevel_impl(PyObject *module); |
1410 | | |
1411 | | static PyObject * |
1412 | | sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1413 | | { |
1414 | | return sys_getandroidapilevel_impl(module); |
1415 | | } |
1416 | | |
1417 | | #endif /* defined(ANDROID_API_LEVEL) */ |
1418 | | |
1419 | | PyDoc_STRVAR(sys_activate_stack_trampoline__doc__, |
1420 | | "activate_stack_trampoline($module, backend, /)\n" |
1421 | | "--\n" |
1422 | | "\n" |
1423 | | "Activate stack profiler trampoline *backend*."); |
1424 | | |
1425 | | #define SYS_ACTIVATE_STACK_TRAMPOLINE_METHODDEF \ |
1426 | | {"activate_stack_trampoline", (PyCFunction)sys_activate_stack_trampoline, METH_O, sys_activate_stack_trampoline__doc__}, |
1427 | | |
1428 | | static PyObject * |
1429 | | sys_activate_stack_trampoline_impl(PyObject *module, const char *backend); |
1430 | | |
1431 | | static PyObject * |
1432 | | sys_activate_stack_trampoline(PyObject *module, PyObject *arg) |
1433 | 0 | { |
1434 | 0 | PyObject *return_value = NULL; |
1435 | 0 | const char *backend; |
1436 | |
|
1437 | 0 | if (!PyUnicode_Check(arg)) { |
1438 | 0 | _PyArg_BadArgument("activate_stack_trampoline", "argument", "str", arg); |
1439 | 0 | goto exit; |
1440 | 0 | } |
1441 | 0 | Py_ssize_t backend_length; |
1442 | 0 | backend = PyUnicode_AsUTF8AndSize(arg, &backend_length); |
1443 | 0 | if (backend == NULL) { |
1444 | 0 | goto exit; |
1445 | 0 | } |
1446 | 0 | if (strlen(backend) != (size_t)backend_length) { |
1447 | 0 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
1448 | 0 | goto exit; |
1449 | 0 | } |
1450 | 0 | return_value = sys_activate_stack_trampoline_impl(module, backend); |
1451 | |
|
1452 | 0 | exit: |
1453 | 0 | return return_value; |
1454 | 0 | } |
1455 | | |
1456 | | PyDoc_STRVAR(sys_deactivate_stack_trampoline__doc__, |
1457 | | "deactivate_stack_trampoline($module, /)\n" |
1458 | | "--\n" |
1459 | | "\n" |
1460 | | "Deactivate the current stack profiler trampoline backend.\n" |
1461 | | "\n" |
1462 | | "If no stack profiler is activated, this function has no effect."); |
1463 | | |
1464 | | #define SYS_DEACTIVATE_STACK_TRAMPOLINE_METHODDEF \ |
1465 | | {"deactivate_stack_trampoline", (PyCFunction)sys_deactivate_stack_trampoline, METH_NOARGS, sys_deactivate_stack_trampoline__doc__}, |
1466 | | |
1467 | | static PyObject * |
1468 | | sys_deactivate_stack_trampoline_impl(PyObject *module); |
1469 | | |
1470 | | static PyObject * |
1471 | | sys_deactivate_stack_trampoline(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1472 | 0 | { |
1473 | 0 | return sys_deactivate_stack_trampoline_impl(module); |
1474 | 0 | } |
1475 | | |
1476 | | PyDoc_STRVAR(sys_is_stack_trampoline_active__doc__, |
1477 | | "is_stack_trampoline_active($module, /)\n" |
1478 | | "--\n" |
1479 | | "\n" |
1480 | | "Return *True* if a stack profiler trampoline is active."); |
1481 | | |
1482 | | #define SYS_IS_STACK_TRAMPOLINE_ACTIVE_METHODDEF \ |
1483 | | {"is_stack_trampoline_active", (PyCFunction)sys_is_stack_trampoline_active, METH_NOARGS, sys_is_stack_trampoline_active__doc__}, |
1484 | | |
1485 | | static PyObject * |
1486 | | sys_is_stack_trampoline_active_impl(PyObject *module); |
1487 | | |
1488 | | static PyObject * |
1489 | | sys_is_stack_trampoline_active(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1490 | 0 | { |
1491 | 0 | return sys_is_stack_trampoline_active_impl(module); |
1492 | 0 | } |
1493 | | |
1494 | | PyDoc_STRVAR(sys_is_remote_debug_enabled__doc__, |
1495 | | "is_remote_debug_enabled($module, /)\n" |
1496 | | "--\n" |
1497 | | "\n" |
1498 | | "Return True if remote debugging is enabled, False otherwise."); |
1499 | | |
1500 | | #define SYS_IS_REMOTE_DEBUG_ENABLED_METHODDEF \ |
1501 | | {"is_remote_debug_enabled", (PyCFunction)sys_is_remote_debug_enabled, METH_NOARGS, sys_is_remote_debug_enabled__doc__}, |
1502 | | |
1503 | | static PyObject * |
1504 | | sys_is_remote_debug_enabled_impl(PyObject *module); |
1505 | | |
1506 | | static PyObject * |
1507 | | sys_is_remote_debug_enabled(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1508 | 0 | { |
1509 | 0 | return sys_is_remote_debug_enabled_impl(module); |
1510 | 0 | } |
1511 | | |
1512 | | PyDoc_STRVAR(sys_remote_exec__doc__, |
1513 | | "remote_exec($module, /, pid, script)\n" |
1514 | | "--\n" |
1515 | | "\n" |
1516 | | "Executes a file containing Python code in a given remote Python process.\n" |
1517 | | "\n" |
1518 | | "This function returns immediately, and the code will be executed by the\n" |
1519 | | "target process\'s main thread at the next available opportunity,\n" |
1520 | | "similarly to how signals are handled. There is no interface to\n" |
1521 | | "determine when the code has been executed. The caller is responsible\n" |
1522 | | "for making sure that the file still exists whenever the remote process\n" |
1523 | | "tries to read it and that it hasn\'t been overwritten.\n" |
1524 | | "\n" |
1525 | | "The remote process must be running a CPython interpreter of the same\n" |
1526 | | "major and minor version as the local process. If either the local or\n" |
1527 | | "remote interpreter is pre-release (alpha, beta, or release candidate)\n" |
1528 | | "then the local and remote interpreters must be the same exact version.\n" |
1529 | | "\n" |
1530 | | "Args:\n" |
1531 | | " pid (int): The process ID of the target Python process.\n" |
1532 | | " script (str|bytes): The path to a file containing\n" |
1533 | | " the Python code to be executed."); |
1534 | | |
1535 | | #define SYS_REMOTE_EXEC_METHODDEF \ |
1536 | | {"remote_exec", _PyCFunction_CAST(sys_remote_exec), METH_FASTCALL|METH_KEYWORDS, sys_remote_exec__doc__}, |
1537 | | |
1538 | | static PyObject * |
1539 | | sys_remote_exec_impl(PyObject *module, int pid, PyObject *script); |
1540 | | |
1541 | | static PyObject * |
1542 | | sys_remote_exec(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1543 | 0 | { |
1544 | 0 | PyObject *return_value = NULL; |
1545 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
1546 | |
|
1547 | 0 | #define NUM_KEYWORDS 2 |
1548 | 0 | static struct { |
1549 | 0 | PyGC_Head _this_is_not_used; |
1550 | 0 | PyObject_VAR_HEAD |
1551 | 0 | Py_hash_t ob_hash; |
1552 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
1553 | 0 | } _kwtuple = { |
1554 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
1555 | 0 | .ob_hash = -1, |
1556 | 0 | .ob_item = { &_Py_ID(pid), &_Py_ID(script), }, |
1557 | 0 | }; |
1558 | 0 | #undef NUM_KEYWORDS |
1559 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
1560 | |
|
1561 | | #else // !Py_BUILD_CORE |
1562 | | # define KWTUPLE NULL |
1563 | | #endif // !Py_BUILD_CORE |
1564 | |
|
1565 | 0 | static const char * const _keywords[] = {"pid", "script", NULL}; |
1566 | 0 | static _PyArg_Parser _parser = { |
1567 | 0 | .keywords = _keywords, |
1568 | 0 | .fname = "remote_exec", |
1569 | 0 | .kwtuple = KWTUPLE, |
1570 | 0 | }; |
1571 | 0 | #undef KWTUPLE |
1572 | 0 | PyObject *argsbuf[2]; |
1573 | 0 | int pid; |
1574 | 0 | PyObject *script; |
1575 | |
|
1576 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
1577 | 0 | /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
1578 | 0 | if (!args) { |
1579 | 0 | goto exit; |
1580 | 0 | } |
1581 | 0 | pid = PyLong_AsInt(args[0]); |
1582 | 0 | if (pid == -1 && PyErr_Occurred()) { |
1583 | 0 | goto exit; |
1584 | 0 | } |
1585 | 0 | script = args[1]; |
1586 | 0 | return_value = sys_remote_exec_impl(module, pid, script); |
1587 | |
|
1588 | 0 | exit: |
1589 | 0 | return return_value; |
1590 | 0 | } |
1591 | | |
1592 | | PyDoc_STRVAR(sys__dump_tracelets__doc__, |
1593 | | "_dump_tracelets($module, /, outpath)\n" |
1594 | | "--\n" |
1595 | | "\n" |
1596 | | "Dump the graph of tracelets in graphviz format"); |
1597 | | |
1598 | | #define SYS__DUMP_TRACELETS_METHODDEF \ |
1599 | | {"_dump_tracelets", _PyCFunction_CAST(sys__dump_tracelets), METH_FASTCALL|METH_KEYWORDS, sys__dump_tracelets__doc__}, |
1600 | | |
1601 | | static PyObject * |
1602 | | sys__dump_tracelets_impl(PyObject *module, PyObject *outpath); |
1603 | | |
1604 | | static PyObject * |
1605 | | sys__dump_tracelets(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1606 | 0 | { |
1607 | 0 | PyObject *return_value = NULL; |
1608 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
1609 | |
|
1610 | 0 | #define NUM_KEYWORDS 1 |
1611 | 0 | static struct { |
1612 | 0 | PyGC_Head _this_is_not_used; |
1613 | 0 | PyObject_VAR_HEAD |
1614 | 0 | Py_hash_t ob_hash; |
1615 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
1616 | 0 | } _kwtuple = { |
1617 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
1618 | 0 | .ob_hash = -1, |
1619 | 0 | .ob_item = { &_Py_ID(outpath), }, |
1620 | 0 | }; |
1621 | 0 | #undef NUM_KEYWORDS |
1622 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
1623 | |
|
1624 | | #else // !Py_BUILD_CORE |
1625 | | # define KWTUPLE NULL |
1626 | | #endif // !Py_BUILD_CORE |
1627 | |
|
1628 | 0 | static const char * const _keywords[] = {"outpath", NULL}; |
1629 | 0 | static _PyArg_Parser _parser = { |
1630 | 0 | .keywords = _keywords, |
1631 | 0 | .fname = "_dump_tracelets", |
1632 | 0 | .kwtuple = KWTUPLE, |
1633 | 0 | }; |
1634 | 0 | #undef KWTUPLE |
1635 | 0 | PyObject *argsbuf[1]; |
1636 | 0 | PyObject *outpath; |
1637 | |
|
1638 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
1639 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
1640 | 0 | if (!args) { |
1641 | 0 | goto exit; |
1642 | 0 | } |
1643 | 0 | outpath = args[0]; |
1644 | 0 | return_value = sys__dump_tracelets_impl(module, outpath); |
1645 | |
|
1646 | 0 | exit: |
1647 | 0 | return return_value; |
1648 | 0 | } |
1649 | | |
1650 | | PyDoc_STRVAR(sys__getframemodulename__doc__, |
1651 | | "_getframemodulename($module, /, depth=0)\n" |
1652 | | "--\n" |
1653 | | "\n" |
1654 | | "Return the name of the module for a calling frame.\n" |
1655 | | "\n" |
1656 | | "The default depth returns the module containing the call to this API.\n" |
1657 | | "A more typical use in a library will pass a depth of 1 to get the user\'s\n" |
1658 | | "module rather than the library module.\n" |
1659 | | "\n" |
1660 | | "If no frame, module, or name can be found, returns None."); |
1661 | | |
1662 | | #define SYS__GETFRAMEMODULENAME_METHODDEF \ |
1663 | | {"_getframemodulename", _PyCFunction_CAST(sys__getframemodulename), METH_FASTCALL|METH_KEYWORDS, sys__getframemodulename__doc__}, |
1664 | | |
1665 | | static PyObject * |
1666 | | sys__getframemodulename_impl(PyObject *module, int depth); |
1667 | | |
1668 | | static PyObject * |
1669 | | sys__getframemodulename(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1670 | 193 | { |
1671 | 193 | PyObject *return_value = NULL; |
1672 | 193 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
1673 | | |
1674 | 193 | #define NUM_KEYWORDS 1 |
1675 | 193 | static struct { |
1676 | 193 | PyGC_Head _this_is_not_used; |
1677 | 193 | PyObject_VAR_HEAD |
1678 | 193 | Py_hash_t ob_hash; |
1679 | 193 | PyObject *ob_item[NUM_KEYWORDS]; |
1680 | 193 | } _kwtuple = { |
1681 | 193 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
1682 | 193 | .ob_hash = -1, |
1683 | 193 | .ob_item = { &_Py_ID(depth), }, |
1684 | 193 | }; |
1685 | 193 | #undef NUM_KEYWORDS |
1686 | 193 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
1687 | | |
1688 | | #else // !Py_BUILD_CORE |
1689 | | # define KWTUPLE NULL |
1690 | | #endif // !Py_BUILD_CORE |
1691 | | |
1692 | 193 | static const char * const _keywords[] = {"depth", NULL}; |
1693 | 193 | static _PyArg_Parser _parser = { |
1694 | 193 | .keywords = _keywords, |
1695 | 193 | .fname = "_getframemodulename", |
1696 | 193 | .kwtuple = KWTUPLE, |
1697 | 193 | }; |
1698 | 193 | #undef KWTUPLE |
1699 | 193 | PyObject *argsbuf[1]; |
1700 | 193 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
1701 | 193 | int depth = 0; |
1702 | | |
1703 | 193 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
1704 | 193 | /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
1705 | 193 | if (!args) { |
1706 | 0 | goto exit; |
1707 | 0 | } |
1708 | 193 | if (!noptargs) { |
1709 | 0 | goto skip_optional_pos; |
1710 | 0 | } |
1711 | 193 | depth = PyLong_AsInt(args[0]); |
1712 | 193 | if (depth == -1 && PyErr_Occurred()) { |
1713 | 0 | goto exit; |
1714 | 0 | } |
1715 | 193 | skip_optional_pos: |
1716 | 193 | return_value = sys__getframemodulename_impl(module, depth); |
1717 | | |
1718 | 193 | exit: |
1719 | 193 | return return_value; |
1720 | 193 | } |
1721 | | |
1722 | | PyDoc_STRVAR(sys__get_cpu_count_config__doc__, |
1723 | | "_get_cpu_count_config($module, /)\n" |
1724 | | "--\n" |
1725 | | "\n" |
1726 | | "Private function for getting PyConfig.cpu_count"); |
1727 | | |
1728 | | #define SYS__GET_CPU_COUNT_CONFIG_METHODDEF \ |
1729 | | {"_get_cpu_count_config", (PyCFunction)sys__get_cpu_count_config, METH_NOARGS, sys__get_cpu_count_config__doc__}, |
1730 | | |
1731 | | static int |
1732 | | sys__get_cpu_count_config_impl(PyObject *module); |
1733 | | |
1734 | | static PyObject * |
1735 | | sys__get_cpu_count_config(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1736 | 37 | { |
1737 | 37 | PyObject *return_value = NULL; |
1738 | 37 | int _return_value; |
1739 | | |
1740 | 37 | _return_value = sys__get_cpu_count_config_impl(module); |
1741 | 37 | if ((_return_value == -1) && PyErr_Occurred()) { |
1742 | 0 | goto exit; |
1743 | 0 | } |
1744 | 37 | return_value = PyLong_FromLong((long)_return_value); |
1745 | | |
1746 | 37 | exit: |
1747 | 37 | return return_value; |
1748 | 37 | } |
1749 | | |
1750 | | PyDoc_STRVAR(sys__baserepl__doc__, |
1751 | | "_baserepl($module, /)\n" |
1752 | | "--\n" |
1753 | | "\n" |
1754 | | "Private function for getting the base REPL"); |
1755 | | |
1756 | | #define SYS__BASEREPL_METHODDEF \ |
1757 | | {"_baserepl", (PyCFunction)sys__baserepl, METH_NOARGS, sys__baserepl__doc__}, |
1758 | | |
1759 | | static PyObject * |
1760 | | sys__baserepl_impl(PyObject *module); |
1761 | | |
1762 | | static PyObject * |
1763 | | sys__baserepl(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1764 | 0 | { |
1765 | 0 | return sys__baserepl_impl(module); |
1766 | 0 | } |
1767 | | |
1768 | | PyDoc_STRVAR(sys__is_gil_enabled__doc__, |
1769 | | "_is_gil_enabled($module, /)\n" |
1770 | | "--\n" |
1771 | | "\n" |
1772 | | "Return True if the GIL is currently enabled and False otherwise."); |
1773 | | |
1774 | | #define SYS__IS_GIL_ENABLED_METHODDEF \ |
1775 | | {"_is_gil_enabled", (PyCFunction)sys__is_gil_enabled, METH_NOARGS, sys__is_gil_enabled__doc__}, |
1776 | | |
1777 | | static int |
1778 | | sys__is_gil_enabled_impl(PyObject *module); |
1779 | | |
1780 | | static PyObject * |
1781 | | sys__is_gil_enabled(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1782 | 0 | { |
1783 | 0 | PyObject *return_value = NULL; |
1784 | 0 | int _return_value; |
1785 | |
|
1786 | 0 | _return_value = sys__is_gil_enabled_impl(module); |
1787 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
1788 | 0 | goto exit; |
1789 | 0 | } |
1790 | 0 | return_value = PyBool_FromLong((long)_return_value); |
1791 | |
|
1792 | 0 | exit: |
1793 | 0 | return return_value; |
1794 | 0 | } |
1795 | | |
1796 | | PyDoc_STRVAR(sys_set_lazy_imports_filter__doc__, |
1797 | | "set_lazy_imports_filter($module, /, filter)\n" |
1798 | | "--\n" |
1799 | | "\n" |
1800 | | "Set the lazy imports filter callback.\n" |
1801 | | "\n" |
1802 | | "The filter is a callable which disables lazy imports when they\n" |
1803 | | "would otherwise be enabled. Returns True if the import is still enabled\n" |
1804 | | "or False to disable it. The callable is called with:\n" |
1805 | | "\n" |
1806 | | "(importing_module_name, resolved_imported_module_name, [fromlist])\n" |
1807 | | "\n" |
1808 | | "Pass None to clear the filter."); |
1809 | | |
1810 | | #define SYS_SET_LAZY_IMPORTS_FILTER_METHODDEF \ |
1811 | | {"set_lazy_imports_filter", _PyCFunction_CAST(sys_set_lazy_imports_filter), METH_FASTCALL|METH_KEYWORDS, sys_set_lazy_imports_filter__doc__}, |
1812 | | |
1813 | | static PyObject * |
1814 | | sys_set_lazy_imports_filter_impl(PyObject *module, PyObject *filter); |
1815 | | |
1816 | | static PyObject * |
1817 | | sys_set_lazy_imports_filter(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1818 | 0 | { |
1819 | 0 | PyObject *return_value = NULL; |
1820 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
1821 | |
|
1822 | 0 | #define NUM_KEYWORDS 1 |
1823 | 0 | static struct { |
1824 | 0 | PyGC_Head _this_is_not_used; |
1825 | 0 | PyObject_VAR_HEAD |
1826 | 0 | Py_hash_t ob_hash; |
1827 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
1828 | 0 | } _kwtuple = { |
1829 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
1830 | 0 | .ob_hash = -1, |
1831 | 0 | .ob_item = { &_Py_ID(filter), }, |
1832 | 0 | }; |
1833 | 0 | #undef NUM_KEYWORDS |
1834 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
1835 | |
|
1836 | | #else // !Py_BUILD_CORE |
1837 | | # define KWTUPLE NULL |
1838 | | #endif // !Py_BUILD_CORE |
1839 | |
|
1840 | 0 | static const char * const _keywords[] = {"filter", NULL}; |
1841 | 0 | static _PyArg_Parser _parser = { |
1842 | 0 | .keywords = _keywords, |
1843 | 0 | .fname = "set_lazy_imports_filter", |
1844 | 0 | .kwtuple = KWTUPLE, |
1845 | 0 | }; |
1846 | 0 | #undef KWTUPLE |
1847 | 0 | PyObject *argsbuf[1]; |
1848 | 0 | PyObject *filter; |
1849 | |
|
1850 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
1851 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
1852 | 0 | if (!args) { |
1853 | 0 | goto exit; |
1854 | 0 | } |
1855 | 0 | filter = args[0]; |
1856 | 0 | return_value = sys_set_lazy_imports_filter_impl(module, filter); |
1857 | |
|
1858 | 0 | exit: |
1859 | 0 | return return_value; |
1860 | 0 | } |
1861 | | |
1862 | | PyDoc_STRVAR(sys_get_lazy_imports_filter__doc__, |
1863 | | "get_lazy_imports_filter($module, /)\n" |
1864 | | "--\n" |
1865 | | "\n" |
1866 | | "Get the current lazy imports filter callback.\n" |
1867 | | "\n" |
1868 | | "Returns the filter callable or None if no filter is set."); |
1869 | | |
1870 | | #define SYS_GET_LAZY_IMPORTS_FILTER_METHODDEF \ |
1871 | | {"get_lazy_imports_filter", (PyCFunction)sys_get_lazy_imports_filter, METH_NOARGS, sys_get_lazy_imports_filter__doc__}, |
1872 | | |
1873 | | static PyObject * |
1874 | | sys_get_lazy_imports_filter_impl(PyObject *module); |
1875 | | |
1876 | | static PyObject * |
1877 | | sys_get_lazy_imports_filter(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1878 | 0 | { |
1879 | 0 | return sys_get_lazy_imports_filter_impl(module); |
1880 | 0 | } |
1881 | | |
1882 | | PyDoc_STRVAR(sys_set_lazy_imports__doc__, |
1883 | | "set_lazy_imports($module, /, mode)\n" |
1884 | | "--\n" |
1885 | | "\n" |
1886 | | "Sets the global lazy imports mode.\n" |
1887 | | "\n" |
1888 | | "The mode parameter must be one of the following strings:\n" |
1889 | | "- \"all\": All top-level imports become potentially lazy\n" |
1890 | | "- \"normal\": Only explicitly marked imports (with \'lazy\' keyword) are\n" |
1891 | | " lazy\n" |
1892 | | "\n" |
1893 | | "In addition to the mode, lazy imports can be controlled via the filter\n" |
1894 | | "provided to sys.set_lazy_imports_filter"); |
1895 | | |
1896 | | #define SYS_SET_LAZY_IMPORTS_METHODDEF \ |
1897 | | {"set_lazy_imports", _PyCFunction_CAST(sys_set_lazy_imports), METH_FASTCALL|METH_KEYWORDS, sys_set_lazy_imports__doc__}, |
1898 | | |
1899 | | static PyObject * |
1900 | | sys_set_lazy_imports_impl(PyObject *module, PyObject *mode); |
1901 | | |
1902 | | static PyObject * |
1903 | | sys_set_lazy_imports(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1904 | 0 | { |
1905 | 0 | PyObject *return_value = NULL; |
1906 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
1907 | |
|
1908 | 0 | #define NUM_KEYWORDS 1 |
1909 | 0 | static struct { |
1910 | 0 | PyGC_Head _this_is_not_used; |
1911 | 0 | PyObject_VAR_HEAD |
1912 | 0 | Py_hash_t ob_hash; |
1913 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
1914 | 0 | } _kwtuple = { |
1915 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
1916 | 0 | .ob_hash = -1, |
1917 | 0 | .ob_item = { &_Py_ID(mode), }, |
1918 | 0 | }; |
1919 | 0 | #undef NUM_KEYWORDS |
1920 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
1921 | |
|
1922 | | #else // !Py_BUILD_CORE |
1923 | | # define KWTUPLE NULL |
1924 | | #endif // !Py_BUILD_CORE |
1925 | |
|
1926 | 0 | static const char * const _keywords[] = {"mode", NULL}; |
1927 | 0 | static _PyArg_Parser _parser = { |
1928 | 0 | .keywords = _keywords, |
1929 | 0 | .fname = "set_lazy_imports", |
1930 | 0 | .kwtuple = KWTUPLE, |
1931 | 0 | }; |
1932 | 0 | #undef KWTUPLE |
1933 | 0 | PyObject *argsbuf[1]; |
1934 | 0 | PyObject *mode; |
1935 | |
|
1936 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
1937 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
1938 | 0 | if (!args) { |
1939 | 0 | goto exit; |
1940 | 0 | } |
1941 | 0 | mode = args[0]; |
1942 | 0 | return_value = sys_set_lazy_imports_impl(module, mode); |
1943 | |
|
1944 | 0 | exit: |
1945 | 0 | return return_value; |
1946 | 0 | } |
1947 | | |
1948 | | PyDoc_STRVAR(sys_get_lazy_imports__doc__, |
1949 | | "get_lazy_imports($module, /)\n" |
1950 | | "--\n" |
1951 | | "\n" |
1952 | | "Gets the global lazy imports mode.\n" |
1953 | | "\n" |
1954 | | "Returns \"all\" if all top level imports are potentially lazy.\n" |
1955 | | "Returns \"normal\" if only explicitly marked imports are lazy."); |
1956 | | |
1957 | | #define SYS_GET_LAZY_IMPORTS_METHODDEF \ |
1958 | | {"get_lazy_imports", (PyCFunction)sys_get_lazy_imports, METH_NOARGS, sys_get_lazy_imports__doc__}, |
1959 | | |
1960 | | static PyObject * |
1961 | | sys_get_lazy_imports_impl(PyObject *module); |
1962 | | |
1963 | | static PyObject * |
1964 | | sys_get_lazy_imports(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1965 | 0 | { |
1966 | 0 | return sys_get_lazy_imports_impl(module); |
1967 | 0 | } |
1968 | | |
1969 | | PyDoc_STRVAR(_jit_is_available__doc__, |
1970 | | "is_available($module, /)\n" |
1971 | | "--\n" |
1972 | | "\n" |
1973 | | "Return True if the current Python executable supports JIT compilation, and False otherwise."); |
1974 | | |
1975 | | #define _JIT_IS_AVAILABLE_METHODDEF \ |
1976 | | {"is_available", (PyCFunction)_jit_is_available, METH_NOARGS, _jit_is_available__doc__}, |
1977 | | |
1978 | | static int |
1979 | | _jit_is_available_impl(PyObject *module); |
1980 | | |
1981 | | static PyObject * |
1982 | | _jit_is_available(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1983 | 0 | { |
1984 | 0 | PyObject *return_value = NULL; |
1985 | 0 | int _return_value; |
1986 | |
|
1987 | 0 | _return_value = _jit_is_available_impl(module); |
1988 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
1989 | 0 | goto exit; |
1990 | 0 | } |
1991 | 0 | return_value = PyBool_FromLong((long)_return_value); |
1992 | |
|
1993 | 0 | exit: |
1994 | 0 | return return_value; |
1995 | 0 | } |
1996 | | |
1997 | | PyDoc_STRVAR(_jit_is_enabled__doc__, |
1998 | | "is_enabled($module, /)\n" |
1999 | | "--\n" |
2000 | | "\n" |
2001 | | "Return True if JIT compilation is enabled for the current Python process (implies sys._jit.is_available()), and False otherwise."); |
2002 | | |
2003 | | #define _JIT_IS_ENABLED_METHODDEF \ |
2004 | | {"is_enabled", (PyCFunction)_jit_is_enabled, METH_NOARGS, _jit_is_enabled__doc__}, |
2005 | | |
2006 | | static int |
2007 | | _jit_is_enabled_impl(PyObject *module); |
2008 | | |
2009 | | static PyObject * |
2010 | | _jit_is_enabled(PyObject *module, PyObject *Py_UNUSED(ignored)) |
2011 | 0 | { |
2012 | 0 | PyObject *return_value = NULL; |
2013 | 0 | int _return_value; |
2014 | |
|
2015 | 0 | _return_value = _jit_is_enabled_impl(module); |
2016 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
2017 | 0 | goto exit; |
2018 | 0 | } |
2019 | 0 | return_value = PyBool_FromLong((long)_return_value); |
2020 | |
|
2021 | 0 | exit: |
2022 | 0 | return return_value; |
2023 | 0 | } |
2024 | | |
2025 | | PyDoc_STRVAR(_jit_is_active__doc__, |
2026 | | "is_active($module, /)\n" |
2027 | | "--\n" |
2028 | | "\n" |
2029 | | "Return True if the topmost Python frame is currently executing JIT code (implies sys._jit.is_enabled()), and False otherwise."); |
2030 | | |
2031 | | #define _JIT_IS_ACTIVE_METHODDEF \ |
2032 | | {"is_active", (PyCFunction)_jit_is_active, METH_NOARGS, _jit_is_active__doc__}, |
2033 | | |
2034 | | static int |
2035 | | _jit_is_active_impl(PyObject *module); |
2036 | | |
2037 | | static PyObject * |
2038 | | _jit_is_active(PyObject *module, PyObject *Py_UNUSED(ignored)) |
2039 | 0 | { |
2040 | 0 | PyObject *return_value = NULL; |
2041 | 0 | int _return_value; |
2042 | |
|
2043 | 0 | _return_value = _jit_is_active_impl(module); |
2044 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
2045 | 0 | goto exit; |
2046 | 0 | } |
2047 | 0 | return_value = PyBool_FromLong((long)_return_value); |
2048 | |
|
2049 | 0 | exit: |
2050 | 0 | return return_value; |
2051 | 0 | } |
2052 | | |
2053 | | #ifndef SYS_GETWINDOWSVERSION_METHODDEF |
2054 | | #define SYS_GETWINDOWSVERSION_METHODDEF |
2055 | | #endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */ |
2056 | | |
2057 | | #ifndef SYS_SETDLOPENFLAGS_METHODDEF |
2058 | | #define SYS_SETDLOPENFLAGS_METHODDEF |
2059 | | #endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */ |
2060 | | |
2061 | | #ifndef SYS_GETDLOPENFLAGS_METHODDEF |
2062 | | #define SYS_GETDLOPENFLAGS_METHODDEF |
2063 | | #endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */ |
2064 | | |
2065 | | #ifndef SYS_MDEBUG_METHODDEF |
2066 | | #define SYS_MDEBUG_METHODDEF |
2067 | | #endif /* !defined(SYS_MDEBUG_METHODDEF) */ |
2068 | | |
2069 | | #ifndef SYS_GETTOTALREFCOUNT_METHODDEF |
2070 | | #define SYS_GETTOTALREFCOUNT_METHODDEF |
2071 | | #endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */ |
2072 | | |
2073 | | #ifndef SYS__STATS_ON_METHODDEF |
2074 | | #define SYS__STATS_ON_METHODDEF |
2075 | | #endif /* !defined(SYS__STATS_ON_METHODDEF) */ |
2076 | | |
2077 | | #ifndef SYS__STATS_OFF_METHODDEF |
2078 | | #define SYS__STATS_OFF_METHODDEF |
2079 | | #endif /* !defined(SYS__STATS_OFF_METHODDEF) */ |
2080 | | |
2081 | | #ifndef SYS__STATS_CLEAR_METHODDEF |
2082 | | #define SYS__STATS_CLEAR_METHODDEF |
2083 | | #endif /* !defined(SYS__STATS_CLEAR_METHODDEF) */ |
2084 | | |
2085 | | #ifndef SYS__STATS_DUMP_METHODDEF |
2086 | | #define SYS__STATS_DUMP_METHODDEF |
2087 | | #endif /* !defined(SYS__STATS_DUMP_METHODDEF) */ |
2088 | | |
2089 | | #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF |
2090 | | #define SYS_GETANDROIDAPILEVEL_METHODDEF |
2091 | | #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */ |
2092 | | /*[clinic end generated code: output=8a4482f9c5c493e5 input=a9049054013a1b77]*/ |