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