Branch data Line data Source code
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 : :
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 : 1 : sys_addaudithook(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
25 : : {
26 : 1 : PyObject *return_value = NULL;
27 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
28 : :
29 : : #define NUM_KEYWORDS 1
30 : : static struct {
31 : : PyGC_Head _this_is_not_used;
32 : : PyObject_VAR_HEAD
33 : : PyObject *ob_item[NUM_KEYWORDS];
34 : : } _kwtuple = {
35 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
36 : : .ob_item = { &_Py_ID(hook), },
37 : : };
38 : : #undef NUM_KEYWORDS
39 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
40 : :
41 : : #else // !Py_BUILD_CORE
42 : : # define KWTUPLE NULL
43 : : #endif // !Py_BUILD_CORE
44 : :
45 : : static const char * const _keywords[] = {"hook", NULL};
46 : : static _PyArg_Parser _parser = {
47 : : .keywords = _keywords,
48 : : .fname = "addaudithook",
49 : : .kwtuple = KWTUPLE,
50 : : };
51 : : #undef KWTUPLE
52 : : PyObject *argsbuf[1];
53 : : PyObject *hook;
54 : :
55 [ + - + - : 1 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ - - + ]
56 [ - + ]: 1 : if (!args) {
57 : 0 : goto exit;
58 : : }
59 : 1 : hook = args[0];
60 : 1 : return_value = sys_addaudithook_impl(module, hook);
61 : :
62 : 1 : exit:
63 : 1 : return return_value;
64 : : }
65 : :
66 : : PyDoc_STRVAR(sys_displayhook__doc__,
67 : : "displayhook($module, object, /)\n"
68 : : "--\n"
69 : : "\n"
70 : : "Print an object to sys.stdout and also save it in builtins._");
71 : :
72 : : #define SYS_DISPLAYHOOK_METHODDEF \
73 : : {"displayhook", (PyCFunction)sys_displayhook, METH_O, sys_displayhook__doc__},
74 : :
75 : : PyDoc_STRVAR(sys_excepthook__doc__,
76 : : "excepthook($module, exctype, value, traceback, /)\n"
77 : : "--\n"
78 : : "\n"
79 : : "Handle an exception by displaying it with a traceback on sys.stderr.");
80 : :
81 : : #define SYS_EXCEPTHOOK_METHODDEF \
82 : : {"excepthook", _PyCFunction_CAST(sys_excepthook), METH_FASTCALL, sys_excepthook__doc__},
83 : :
84 : : static PyObject *
85 : : sys_excepthook_impl(PyObject *module, PyObject *exctype, PyObject *value,
86 : : PyObject *traceback);
87 : :
88 : : static PyObject *
89 : 0 : sys_excepthook(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
90 : : {
91 : 0 : PyObject *return_value = NULL;
92 : : PyObject *exctype;
93 : : PyObject *value;
94 : : PyObject *traceback;
95 : :
96 [ # # # # : 0 : if (!_PyArg_CheckPositional("excepthook", nargs, 3, 3)) {
# # ]
97 : 0 : goto exit;
98 : : }
99 : 0 : exctype = args[0];
100 : 0 : value = args[1];
101 : 0 : traceback = args[2];
102 : 0 : return_value = sys_excepthook_impl(module, exctype, value, traceback);
103 : :
104 : 0 : exit:
105 : 0 : return return_value;
106 : : }
107 : :
108 : : PyDoc_STRVAR(sys_exception__doc__,
109 : : "exception($module, /)\n"
110 : : "--\n"
111 : : "\n"
112 : : "Return the current exception.\n"
113 : : "\n"
114 : : "Return the most recent exception caught by an except clause\n"
115 : : "in the current stack frame or in an older stack frame, or None\n"
116 : : "if no such exception exists.");
117 : :
118 : : #define SYS_EXCEPTION_METHODDEF \
119 : : {"exception", (PyCFunction)sys_exception, METH_NOARGS, sys_exception__doc__},
120 : :
121 : : static PyObject *
122 : : sys_exception_impl(PyObject *module);
123 : :
124 : : static PyObject *
125 : 0 : sys_exception(PyObject *module, PyObject *Py_UNUSED(ignored))
126 : : {
127 : 0 : return sys_exception_impl(module);
128 : : }
129 : :
130 : : PyDoc_STRVAR(sys_exc_info__doc__,
131 : : "exc_info($module, /)\n"
132 : : "--\n"
133 : : "\n"
134 : : "Return current exception information: (type, value, traceback).\n"
135 : : "\n"
136 : : "Return information about the most recent exception caught by an except\n"
137 : : "clause in the current stack frame or in an older stack frame.");
138 : :
139 : : #define SYS_EXC_INFO_METHODDEF \
140 : : {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, sys_exc_info__doc__},
141 : :
142 : : static PyObject *
143 : : sys_exc_info_impl(PyObject *module);
144 : :
145 : : static PyObject *
146 : 9 : sys_exc_info(PyObject *module, PyObject *Py_UNUSED(ignored))
147 : : {
148 : 9 : return sys_exc_info_impl(module);
149 : : }
150 : :
151 : : PyDoc_STRVAR(sys_unraisablehook__doc__,
152 : : "unraisablehook($module, unraisable, /)\n"
153 : : "--\n"
154 : : "\n"
155 : : "Handle an unraisable exception.\n"
156 : : "\n"
157 : : "The unraisable argument has the following attributes:\n"
158 : : "\n"
159 : : "* exc_type: Exception type.\n"
160 : : "* exc_value: Exception value, can be None.\n"
161 : : "* exc_traceback: Exception traceback, can be None.\n"
162 : : "* err_msg: Error message, can be None.\n"
163 : : "* object: Object causing the exception, can be None.");
164 : :
165 : : #define SYS_UNRAISABLEHOOK_METHODDEF \
166 : : {"unraisablehook", (PyCFunction)sys_unraisablehook, METH_O, sys_unraisablehook__doc__},
167 : :
168 : : PyDoc_STRVAR(sys_exit__doc__,
169 : : "exit($module, status=None, /)\n"
170 : : "--\n"
171 : : "\n"
172 : : "Exit the interpreter by raising SystemExit(status).\n"
173 : : "\n"
174 : : "If the status is omitted or None, it defaults to zero (i.e., success).\n"
175 : : "If the status is an integer, it will be used as the system exit status.\n"
176 : : "If it is another kind of object, it will be printed and the system\n"
177 : : "exit status will be one (i.e., failure).");
178 : :
179 : : #define SYS_EXIT_METHODDEF \
180 : : {"exit", _PyCFunction_CAST(sys_exit), METH_FASTCALL, sys_exit__doc__},
181 : :
182 : : static PyObject *
183 : : sys_exit_impl(PyObject *module, PyObject *status);
184 : :
185 : : static PyObject *
186 : 2 : sys_exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
187 : : {
188 : 2 : PyObject *return_value = NULL;
189 : 2 : PyObject *status = Py_None;
190 : :
191 [ + - - + : 2 : if (!_PyArg_CheckPositional("exit", nargs, 0, 1)) {
- - ]
192 : 0 : goto exit;
193 : : }
194 [ - + ]: 2 : if (nargs < 1) {
195 : 0 : goto skip_optional;
196 : : }
197 : 2 : status = args[0];
198 : 2 : skip_optional:
199 : 2 : return_value = sys_exit_impl(module, status);
200 : :
201 : 2 : exit:
202 : 2 : return return_value;
203 : : }
204 : :
205 : : PyDoc_STRVAR(sys_getdefaultencoding__doc__,
206 : : "getdefaultencoding($module, /)\n"
207 : : "--\n"
208 : : "\n"
209 : : "Return the current default encoding used by the Unicode implementation.");
210 : :
211 : : #define SYS_GETDEFAULTENCODING_METHODDEF \
212 : : {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, sys_getdefaultencoding__doc__},
213 : :
214 : : static PyObject *
215 : : sys_getdefaultencoding_impl(PyObject *module);
216 : :
217 : : static PyObject *
218 : 0 : sys_getdefaultencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
219 : : {
220 : 0 : return sys_getdefaultencoding_impl(module);
221 : : }
222 : :
223 : : PyDoc_STRVAR(sys_getfilesystemencoding__doc__,
224 : : "getfilesystemencoding($module, /)\n"
225 : : "--\n"
226 : : "\n"
227 : : "Return the encoding used to convert Unicode filenames to OS filenames.");
228 : :
229 : : #define SYS_GETFILESYSTEMENCODING_METHODDEF \
230 : : {"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding, METH_NOARGS, sys_getfilesystemencoding__doc__},
231 : :
232 : : static PyObject *
233 : : sys_getfilesystemencoding_impl(PyObject *module);
234 : :
235 : : static PyObject *
236 : 55 : sys_getfilesystemencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
237 : : {
238 : 55 : return sys_getfilesystemencoding_impl(module);
239 : : }
240 : :
241 : : PyDoc_STRVAR(sys_getfilesystemencodeerrors__doc__,
242 : : "getfilesystemencodeerrors($module, /)\n"
243 : : "--\n"
244 : : "\n"
245 : : "Return the error mode used Unicode to OS filename conversion.");
246 : :
247 : : #define SYS_GETFILESYSTEMENCODEERRORS_METHODDEF \
248 : : {"getfilesystemencodeerrors", (PyCFunction)sys_getfilesystemencodeerrors, METH_NOARGS, sys_getfilesystemencodeerrors__doc__},
249 : :
250 : : static PyObject *
251 : : sys_getfilesystemencodeerrors_impl(PyObject *module);
252 : :
253 : : static PyObject *
254 : 26 : sys_getfilesystemencodeerrors(PyObject *module, PyObject *Py_UNUSED(ignored))
255 : : {
256 : 26 : return sys_getfilesystemencodeerrors_impl(module);
257 : : }
258 : :
259 : : PyDoc_STRVAR(sys_intern__doc__,
260 : : "intern($module, string, /)\n"
261 : : "--\n"
262 : : "\n"
263 : : "``Intern\'\' the given string.\n"
264 : : "\n"
265 : : "This enters the string in the (global) table of interned strings whose\n"
266 : : "purpose is to speed up dictionary lookups. Return the string itself or\n"
267 : : "the previously interned string object with the same value.");
268 : :
269 : : #define SYS_INTERN_METHODDEF \
270 : : {"intern", (PyCFunction)sys_intern, METH_O, sys_intern__doc__},
271 : :
272 : : static PyObject *
273 : : sys_intern_impl(PyObject *module, PyObject *s);
274 : :
275 : : static PyObject *
276 : 739 : sys_intern(PyObject *module, PyObject *arg)
277 : : {
278 : 739 : PyObject *return_value = NULL;
279 : : PyObject *s;
280 : :
281 [ - + ]: 739 : if (!PyUnicode_Check(arg)) {
282 : 0 : _PyArg_BadArgument("intern", "argument", "str", arg);
283 : 0 : goto exit;
284 : : }
285 [ - + ]: 739 : if (PyUnicode_READY(arg) == -1) {
286 : 0 : goto exit;
287 : : }
288 : 739 : s = arg;
289 : 739 : return_value = sys_intern_impl(module, s);
290 : :
291 : 739 : exit:
292 : 739 : return return_value;
293 : : }
294 : :
295 : : PyDoc_STRVAR(sys__settraceallthreads__doc__,
296 : : "_settraceallthreads($module, arg, /)\n"
297 : : "--\n"
298 : : "\n"
299 : : "Set the global debug tracing function in all running threads belonging to the current interpreter.\n"
300 : : "\n"
301 : : "It will be called on each function call. See the debugger chapter\n"
302 : : "in the library manual.");
303 : :
304 : : #define SYS__SETTRACEALLTHREADS_METHODDEF \
305 : : {"_settraceallthreads", (PyCFunction)sys__settraceallthreads, METH_O, sys__settraceallthreads__doc__},
306 : :
307 : : PyDoc_STRVAR(sys_gettrace__doc__,
308 : : "gettrace($module, /)\n"
309 : : "--\n"
310 : : "\n"
311 : : "Return the global debug tracing function set with sys.settrace.\n"
312 : : "\n"
313 : : "See the debugger chapter in the library manual.");
314 : :
315 : : #define SYS_GETTRACE_METHODDEF \
316 : : {"gettrace", (PyCFunction)sys_gettrace, METH_NOARGS, sys_gettrace__doc__},
317 : :
318 : : static PyObject *
319 : : sys_gettrace_impl(PyObject *module);
320 : :
321 : : static PyObject *
322 : 5 : sys_gettrace(PyObject *module, PyObject *Py_UNUSED(ignored))
323 : : {
324 : 5 : return sys_gettrace_impl(module);
325 : : }
326 : :
327 : : PyDoc_STRVAR(sys__setprofileallthreads__doc__,
328 : : "_setprofileallthreads($module, arg, /)\n"
329 : : "--\n"
330 : : "\n"
331 : : "Set the profiling function in all running threads belonging to the current interpreter.\n"
332 : : "\n"
333 : : "It will be called on each function call and return. See the profiler chapter\n"
334 : : "in the library manual.");
335 : :
336 : : #define SYS__SETPROFILEALLTHREADS_METHODDEF \
337 : : {"_setprofileallthreads", (PyCFunction)sys__setprofileallthreads, METH_O, sys__setprofileallthreads__doc__},
338 : :
339 : : PyDoc_STRVAR(sys_getprofile__doc__,
340 : : "getprofile($module, /)\n"
341 : : "--\n"
342 : : "\n"
343 : : "Return the profiling function set with sys.setprofile.\n"
344 : : "\n"
345 : : "See the profiler chapter in the library manual.");
346 : :
347 : : #define SYS_GETPROFILE_METHODDEF \
348 : : {"getprofile", (PyCFunction)sys_getprofile, METH_NOARGS, sys_getprofile__doc__},
349 : :
350 : : static PyObject *
351 : : sys_getprofile_impl(PyObject *module);
352 : :
353 : : static PyObject *
354 : 0 : sys_getprofile(PyObject *module, PyObject *Py_UNUSED(ignored))
355 : : {
356 : 0 : return sys_getprofile_impl(module);
357 : : }
358 : :
359 : : PyDoc_STRVAR(sys_setswitchinterval__doc__,
360 : : "setswitchinterval($module, interval, /)\n"
361 : : "--\n"
362 : : "\n"
363 : : "Set the ideal thread switching delay inside the Python interpreter.\n"
364 : : "\n"
365 : : "The actual frequency of switching threads can be lower if the\n"
366 : : "interpreter executes long sequences of uninterruptible code\n"
367 : : "(this is implementation-specific and workload-dependent).\n"
368 : : "\n"
369 : : "The parameter must represent the desired switching delay in seconds\n"
370 : : "A typical value is 0.005 (5 milliseconds).");
371 : :
372 : : #define SYS_SETSWITCHINTERVAL_METHODDEF \
373 : : {"setswitchinterval", (PyCFunction)sys_setswitchinterval, METH_O, sys_setswitchinterval__doc__},
374 : :
375 : : static PyObject *
376 : : sys_setswitchinterval_impl(PyObject *module, double interval);
377 : :
378 : : static PyObject *
379 : 0 : sys_setswitchinterval(PyObject *module, PyObject *arg)
380 : : {
381 : 0 : PyObject *return_value = NULL;
382 : : double interval;
383 : :
384 [ # # ]: 0 : if (PyFloat_CheckExact(arg)) {
385 : 0 : interval = PyFloat_AS_DOUBLE(arg);
386 : : }
387 : : else
388 : : {
389 : 0 : interval = PyFloat_AsDouble(arg);
390 [ # # # # ]: 0 : if (interval == -1.0 && PyErr_Occurred()) {
391 : 0 : goto exit;
392 : : }
393 : : }
394 : 0 : return_value = sys_setswitchinterval_impl(module, interval);
395 : :
396 : 0 : exit:
397 : 0 : return return_value;
398 : : }
399 : :
400 : : PyDoc_STRVAR(sys_getswitchinterval__doc__,
401 : : "getswitchinterval($module, /)\n"
402 : : "--\n"
403 : : "\n"
404 : : "Return the current thread switch interval; see sys.setswitchinterval().");
405 : :
406 : : #define SYS_GETSWITCHINTERVAL_METHODDEF \
407 : : {"getswitchinterval", (PyCFunction)sys_getswitchinterval, METH_NOARGS, sys_getswitchinterval__doc__},
408 : :
409 : : static double
410 : : sys_getswitchinterval_impl(PyObject *module);
411 : :
412 : : static PyObject *
413 : 0 : sys_getswitchinterval(PyObject *module, PyObject *Py_UNUSED(ignored))
414 : : {
415 : 0 : PyObject *return_value = NULL;
416 : : double _return_value;
417 : :
418 : 0 : _return_value = sys_getswitchinterval_impl(module);
419 [ # # # # ]: 0 : if ((_return_value == -1.0) && PyErr_Occurred()) {
420 : 0 : goto exit;
421 : : }
422 : 0 : return_value = PyFloat_FromDouble(_return_value);
423 : :
424 : 0 : exit:
425 : 0 : return return_value;
426 : : }
427 : :
428 : : PyDoc_STRVAR(sys_setrecursionlimit__doc__,
429 : : "setrecursionlimit($module, limit, /)\n"
430 : : "--\n"
431 : : "\n"
432 : : "Set the maximum depth of the Python interpreter stack to n.\n"
433 : : "\n"
434 : : "This limit prevents infinite recursion from causing an overflow of the C\n"
435 : : "stack and crashing Python. The highest possible limit is platform-\n"
436 : : "dependent.");
437 : :
438 : : #define SYS_SETRECURSIONLIMIT_METHODDEF \
439 : : {"setrecursionlimit", (PyCFunction)sys_setrecursionlimit, METH_O, sys_setrecursionlimit__doc__},
440 : :
441 : : static PyObject *
442 : : sys_setrecursionlimit_impl(PyObject *module, int new_limit);
443 : :
444 : : static PyObject *
445 : 0 : sys_setrecursionlimit(PyObject *module, PyObject *arg)
446 : : {
447 : 0 : PyObject *return_value = NULL;
448 : : int new_limit;
449 : :
450 : 0 : new_limit = _PyLong_AsInt(arg);
451 [ # # # # ]: 0 : if (new_limit == -1 && PyErr_Occurred()) {
452 : 0 : goto exit;
453 : : }
454 : 0 : return_value = sys_setrecursionlimit_impl(module, new_limit);
455 : :
456 : 0 : exit:
457 : 0 : return return_value;
458 : : }
459 : :
460 : : PyDoc_STRVAR(sys_set_coroutine_origin_tracking_depth__doc__,
461 : : "set_coroutine_origin_tracking_depth($module, /, depth)\n"
462 : : "--\n"
463 : : "\n"
464 : : "Enable or disable origin tracking for coroutine objects in this thread.\n"
465 : : "\n"
466 : : "Coroutine objects will track \'depth\' frames of traceback information\n"
467 : : "about where they came from, available in their cr_origin attribute.\n"
468 : : "\n"
469 : : "Set a depth of 0 to disable.");
470 : :
471 : : #define SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
472 : : {"set_coroutine_origin_tracking_depth", _PyCFunction_CAST(sys_set_coroutine_origin_tracking_depth), METH_FASTCALL|METH_KEYWORDS, sys_set_coroutine_origin_tracking_depth__doc__},
473 : :
474 : : static PyObject *
475 : : sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth);
476 : :
477 : : static PyObject *
478 : 0 : sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
479 : : {
480 : 0 : PyObject *return_value = NULL;
481 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
482 : :
483 : : #define NUM_KEYWORDS 1
484 : : static struct {
485 : : PyGC_Head _this_is_not_used;
486 : : PyObject_VAR_HEAD
487 : : PyObject *ob_item[NUM_KEYWORDS];
488 : : } _kwtuple = {
489 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
490 : : .ob_item = { &_Py_ID(depth), },
491 : : };
492 : : #undef NUM_KEYWORDS
493 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
494 : :
495 : : #else // !Py_BUILD_CORE
496 : : # define KWTUPLE NULL
497 : : #endif // !Py_BUILD_CORE
498 : :
499 : : static const char * const _keywords[] = {"depth", NULL};
500 : : static _PyArg_Parser _parser = {
501 : : .keywords = _keywords,
502 : : .fname = "set_coroutine_origin_tracking_depth",
503 : : .kwtuple = KWTUPLE,
504 : : };
505 : : #undef KWTUPLE
506 : : PyObject *argsbuf[1];
507 : : int depth;
508 : :
509 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
# # # # ]
510 [ # # ]: 0 : if (!args) {
511 : 0 : goto exit;
512 : : }
513 : 0 : depth = _PyLong_AsInt(args[0]);
514 [ # # # # ]: 0 : if (depth == -1 && PyErr_Occurred()) {
515 : 0 : goto exit;
516 : : }
517 : 0 : return_value = sys_set_coroutine_origin_tracking_depth_impl(module, depth);
518 : :
519 : 0 : exit:
520 : 0 : return return_value;
521 : : }
522 : :
523 : : PyDoc_STRVAR(sys_get_coroutine_origin_tracking_depth__doc__,
524 : : "get_coroutine_origin_tracking_depth($module, /)\n"
525 : : "--\n"
526 : : "\n"
527 : : "Check status of origin tracking for coroutine objects in this thread.");
528 : :
529 : : #define SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
530 : : {"get_coroutine_origin_tracking_depth", (PyCFunction)sys_get_coroutine_origin_tracking_depth, METH_NOARGS, sys_get_coroutine_origin_tracking_depth__doc__},
531 : :
532 : : static int
533 : : sys_get_coroutine_origin_tracking_depth_impl(PyObject *module);
534 : :
535 : : static PyObject *
536 : 0 : sys_get_coroutine_origin_tracking_depth(PyObject *module, PyObject *Py_UNUSED(ignored))
537 : : {
538 : 0 : PyObject *return_value = NULL;
539 : : int _return_value;
540 : :
541 : 0 : _return_value = sys_get_coroutine_origin_tracking_depth_impl(module);
542 [ # # # # ]: 0 : if ((_return_value == -1) && PyErr_Occurred()) {
543 : 0 : goto exit;
544 : : }
545 : 0 : return_value = PyLong_FromLong((long)_return_value);
546 : :
547 : 0 : exit:
548 : 0 : return return_value;
549 : : }
550 : :
551 : : PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__,
552 : : "get_asyncgen_hooks($module, /)\n"
553 : : "--\n"
554 : : "\n"
555 : : "Return the installed asynchronous generators hooks.\n"
556 : : "\n"
557 : : "This returns a namedtuple of the form (firstiter, finalizer).");
558 : :
559 : : #define SYS_GET_ASYNCGEN_HOOKS_METHODDEF \
560 : : {"get_asyncgen_hooks", (PyCFunction)sys_get_asyncgen_hooks, METH_NOARGS, sys_get_asyncgen_hooks__doc__},
561 : :
562 : : static PyObject *
563 : : sys_get_asyncgen_hooks_impl(PyObject *module);
564 : :
565 : : static PyObject *
566 : 0 : sys_get_asyncgen_hooks(PyObject *module, PyObject *Py_UNUSED(ignored))
567 : : {
568 : 0 : return sys_get_asyncgen_hooks_impl(module);
569 : : }
570 : :
571 : : PyDoc_STRVAR(sys_getrecursionlimit__doc__,
572 : : "getrecursionlimit($module, /)\n"
573 : : "--\n"
574 : : "\n"
575 : : "Return the current value of the recursion limit.\n"
576 : : "\n"
577 : : "The recursion limit is the maximum depth of the Python interpreter\n"
578 : : "stack. This limit prevents infinite recursion from causing an overflow\n"
579 : : "of the C stack and crashing Python.");
580 : :
581 : : #define SYS_GETRECURSIONLIMIT_METHODDEF \
582 : : {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, sys_getrecursionlimit__doc__},
583 : :
584 : : static PyObject *
585 : : sys_getrecursionlimit_impl(PyObject *module);
586 : :
587 : : static PyObject *
588 : 0 : sys_getrecursionlimit(PyObject *module, PyObject *Py_UNUSED(ignored))
589 : : {
590 : 0 : return sys_getrecursionlimit_impl(module);
591 : : }
592 : :
593 : : #if defined(MS_WINDOWS)
594 : :
595 : : PyDoc_STRVAR(sys_getwindowsversion__doc__,
596 : : "getwindowsversion($module, /)\n"
597 : : "--\n"
598 : : "\n"
599 : : "Return info about the running version of Windows as a named tuple.\n"
600 : : "\n"
601 : : "The members are named: major, minor, build, platform, service_pack,\n"
602 : : "service_pack_major, service_pack_minor, suite_mask, product_type and\n"
603 : : "platform_version. For backward compatibility, only the first 5 items\n"
604 : : "are available by indexing. All elements are numbers, except\n"
605 : : "service_pack and platform_type which are strings, and platform_version\n"
606 : : "which is a 3-tuple. Platform is always 2. Product_type may be 1 for a\n"
607 : : "workstation, 2 for a domain controller, 3 for a server.\n"
608 : : "Platform_version is a 3-tuple containing a version number that is\n"
609 : : "intended for identifying the OS rather than feature detection.");
610 : :
611 : : #define SYS_GETWINDOWSVERSION_METHODDEF \
612 : : {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, sys_getwindowsversion__doc__},
613 : :
614 : : static PyObject *
615 : : sys_getwindowsversion_impl(PyObject *module);
616 : :
617 : : static PyObject *
618 : : sys_getwindowsversion(PyObject *module, PyObject *Py_UNUSED(ignored))
619 : : {
620 : : return sys_getwindowsversion_impl(module);
621 : : }
622 : :
623 : : #endif /* defined(MS_WINDOWS) */
624 : :
625 : : #if defined(MS_WINDOWS)
626 : :
627 : : PyDoc_STRVAR(sys__enablelegacywindowsfsencoding__doc__,
628 : : "_enablelegacywindowsfsencoding($module, /)\n"
629 : : "--\n"
630 : : "\n"
631 : : "Changes the default filesystem encoding to mbcs:replace.\n"
632 : : "\n"
633 : : "This is done for consistency with earlier versions of Python. See PEP\n"
634 : : "529 for more information.\n"
635 : : "\n"
636 : : "This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING\n"
637 : : "environment variable before launching Python.");
638 : :
639 : : #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF \
640 : : {"_enablelegacywindowsfsencoding", (PyCFunction)sys__enablelegacywindowsfsencoding, METH_NOARGS, sys__enablelegacywindowsfsencoding__doc__},
641 : :
642 : : static PyObject *
643 : : sys__enablelegacywindowsfsencoding_impl(PyObject *module);
644 : :
645 : : static PyObject *
646 : : sys__enablelegacywindowsfsencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
647 : : {
648 : : return sys__enablelegacywindowsfsencoding_impl(module);
649 : : }
650 : :
651 : : #endif /* defined(MS_WINDOWS) */
652 : :
653 : : #if defined(HAVE_DLOPEN)
654 : :
655 : : PyDoc_STRVAR(sys_setdlopenflags__doc__,
656 : : "setdlopenflags($module, flags, /)\n"
657 : : "--\n"
658 : : "\n"
659 : : "Set the flags used by the interpreter for dlopen calls.\n"
660 : : "\n"
661 : : "This is used, for example, when the interpreter loads extension\n"
662 : : "modules. Among other things, this will enable a lazy resolving of\n"
663 : : "symbols when importing a module, if called as sys.setdlopenflags(0).\n"
664 : : "To share symbols across extension modules, call as\n"
665 : : "sys.setdlopenflags(os.RTLD_GLOBAL). Symbolic names for the flag\n"
666 : : "modules can be found in the os module (RTLD_xxx constants, e.g.\n"
667 : : "os.RTLD_LAZY).");
668 : :
669 : : #define SYS_SETDLOPENFLAGS_METHODDEF \
670 : : {"setdlopenflags", (PyCFunction)sys_setdlopenflags, METH_O, sys_setdlopenflags__doc__},
671 : :
672 : : static PyObject *
673 : : sys_setdlopenflags_impl(PyObject *module, int new_val);
674 : :
675 : : static PyObject *
676 : 0 : sys_setdlopenflags(PyObject *module, PyObject *arg)
677 : : {
678 : 0 : PyObject *return_value = NULL;
679 : : int new_val;
680 : :
681 : 0 : new_val = _PyLong_AsInt(arg);
682 [ # # # # ]: 0 : if (new_val == -1 && PyErr_Occurred()) {
683 : 0 : goto exit;
684 : : }
685 : 0 : return_value = sys_setdlopenflags_impl(module, new_val);
686 : :
687 : 0 : exit:
688 : 0 : return return_value;
689 : : }
690 : :
691 : : #endif /* defined(HAVE_DLOPEN) */
692 : :
693 : : #if defined(HAVE_DLOPEN)
694 : :
695 : : PyDoc_STRVAR(sys_getdlopenflags__doc__,
696 : : "getdlopenflags($module, /)\n"
697 : : "--\n"
698 : : "\n"
699 : : "Return the current value of the flags that are used for dlopen calls.\n"
700 : : "\n"
701 : : "The flag constants are defined in the os module.");
702 : :
703 : : #define SYS_GETDLOPENFLAGS_METHODDEF \
704 : : {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, sys_getdlopenflags__doc__},
705 : :
706 : : static PyObject *
707 : : sys_getdlopenflags_impl(PyObject *module);
708 : :
709 : : static PyObject *
710 : 0 : sys_getdlopenflags(PyObject *module, PyObject *Py_UNUSED(ignored))
711 : : {
712 : 0 : return sys_getdlopenflags_impl(module);
713 : : }
714 : :
715 : : #endif /* defined(HAVE_DLOPEN) */
716 : :
717 : : #if defined(USE_MALLOPT)
718 : :
719 : : PyDoc_STRVAR(sys_mdebug__doc__,
720 : : "mdebug($module, flag, /)\n"
721 : : "--\n"
722 : : "\n");
723 : :
724 : : #define SYS_MDEBUG_METHODDEF \
725 : : {"mdebug", (PyCFunction)sys_mdebug, METH_O, sys_mdebug__doc__},
726 : :
727 : : static PyObject *
728 : : sys_mdebug_impl(PyObject *module, int flag);
729 : :
730 : : static PyObject *
731 : : sys_mdebug(PyObject *module, PyObject *arg)
732 : : {
733 : : PyObject *return_value = NULL;
734 : : int flag;
735 : :
736 : : flag = _PyLong_AsInt(arg);
737 : : if (flag == -1 && PyErr_Occurred()) {
738 : : goto exit;
739 : : }
740 : : return_value = sys_mdebug_impl(module, flag);
741 : :
742 : : exit:
743 : : return return_value;
744 : : }
745 : :
746 : : #endif /* defined(USE_MALLOPT) */
747 : :
748 : : PyDoc_STRVAR(sys_get_int_max_str_digits__doc__,
749 : : "get_int_max_str_digits($module, /)\n"
750 : : "--\n"
751 : : "\n"
752 : : "Return the maximum string digits limit for non-binary int<->str conversions.");
753 : :
754 : : #define SYS_GET_INT_MAX_STR_DIGITS_METHODDEF \
755 : : {"get_int_max_str_digits", (PyCFunction)sys_get_int_max_str_digits, METH_NOARGS, sys_get_int_max_str_digits__doc__},
756 : :
757 : : static PyObject *
758 : : sys_get_int_max_str_digits_impl(PyObject *module);
759 : :
760 : : static PyObject *
761 : 0 : sys_get_int_max_str_digits(PyObject *module, PyObject *Py_UNUSED(ignored))
762 : : {
763 : 0 : return sys_get_int_max_str_digits_impl(module);
764 : : }
765 : :
766 : : PyDoc_STRVAR(sys_set_int_max_str_digits__doc__,
767 : : "set_int_max_str_digits($module, /, maxdigits)\n"
768 : : "--\n"
769 : : "\n"
770 : : "Set the maximum string digits limit for non-binary int<->str conversions.");
771 : :
772 : : #define SYS_SET_INT_MAX_STR_DIGITS_METHODDEF \
773 : : {"set_int_max_str_digits", _PyCFunction_CAST(sys_set_int_max_str_digits), METH_FASTCALL|METH_KEYWORDS, sys_set_int_max_str_digits__doc__},
774 : :
775 : : static PyObject *
776 : : sys_set_int_max_str_digits_impl(PyObject *module, int maxdigits);
777 : :
778 : : static PyObject *
779 : 0 : sys_set_int_max_str_digits(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
780 : : {
781 : 0 : PyObject *return_value = NULL;
782 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
783 : :
784 : : #define NUM_KEYWORDS 1
785 : : static struct {
786 : : PyGC_Head _this_is_not_used;
787 : : PyObject_VAR_HEAD
788 : : PyObject *ob_item[NUM_KEYWORDS];
789 : : } _kwtuple = {
790 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
791 : : .ob_item = { &_Py_ID(maxdigits), },
792 : : };
793 : : #undef NUM_KEYWORDS
794 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
795 : :
796 : : #else // !Py_BUILD_CORE
797 : : # define KWTUPLE NULL
798 : : #endif // !Py_BUILD_CORE
799 : :
800 : : static const char * const _keywords[] = {"maxdigits", NULL};
801 : : static _PyArg_Parser _parser = {
802 : : .keywords = _keywords,
803 : : .fname = "set_int_max_str_digits",
804 : : .kwtuple = KWTUPLE,
805 : : };
806 : : #undef KWTUPLE
807 : : PyObject *argsbuf[1];
808 : : int maxdigits;
809 : :
810 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
# # # # ]
811 [ # # ]: 0 : if (!args) {
812 : 0 : goto exit;
813 : : }
814 : 0 : maxdigits = _PyLong_AsInt(args[0]);
815 [ # # # # ]: 0 : if (maxdigits == -1 && PyErr_Occurred()) {
816 : 0 : goto exit;
817 : : }
818 : 0 : return_value = sys_set_int_max_str_digits_impl(module, maxdigits);
819 : :
820 : 0 : exit:
821 : 0 : return return_value;
822 : : }
823 : :
824 : : PyDoc_STRVAR(sys_getrefcount__doc__,
825 : : "getrefcount($module, object, /)\n"
826 : : "--\n"
827 : : "\n"
828 : : "Return the reference count of object.\n"
829 : : "\n"
830 : : "The count returned is generally one higher than you might expect,\n"
831 : : "because it includes the (temporary) reference as an argument to\n"
832 : : "getrefcount().");
833 : :
834 : : #define SYS_GETREFCOUNT_METHODDEF \
835 : : {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__},
836 : :
837 : : static Py_ssize_t
838 : : sys_getrefcount_impl(PyObject *module, PyObject *object);
839 : :
840 : : static PyObject *
841 : 0 : sys_getrefcount(PyObject *module, PyObject *object)
842 : : {
843 : 0 : PyObject *return_value = NULL;
844 : : Py_ssize_t _return_value;
845 : :
846 : 0 : _return_value = sys_getrefcount_impl(module, object);
847 [ # # # # ]: 0 : if ((_return_value == -1) && PyErr_Occurred()) {
848 : 0 : goto exit;
849 : : }
850 : 0 : return_value = PyLong_FromSsize_t(_return_value);
851 : :
852 : 0 : exit:
853 : 0 : return return_value;
854 : : }
855 : :
856 : : #if defined(Py_REF_DEBUG)
857 : :
858 : : PyDoc_STRVAR(sys_gettotalrefcount__doc__,
859 : : "gettotalrefcount($module, /)\n"
860 : : "--\n"
861 : : "\n");
862 : :
863 : : #define SYS_GETTOTALREFCOUNT_METHODDEF \
864 : : {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__},
865 : :
866 : : static Py_ssize_t
867 : : sys_gettotalrefcount_impl(PyObject *module);
868 : :
869 : : static PyObject *
870 : : sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored))
871 : : {
872 : : PyObject *return_value = NULL;
873 : : Py_ssize_t _return_value;
874 : :
875 : : _return_value = sys_gettotalrefcount_impl(module);
876 : : if ((_return_value == -1) && PyErr_Occurred()) {
877 : : goto exit;
878 : : }
879 : : return_value = PyLong_FromSsize_t(_return_value);
880 : :
881 : : exit:
882 : : return return_value;
883 : : }
884 : :
885 : : #endif /* defined(Py_REF_DEBUG) */
886 : :
887 : : PyDoc_STRVAR(sys_getallocatedblocks__doc__,
888 : : "getallocatedblocks($module, /)\n"
889 : : "--\n"
890 : : "\n"
891 : : "Return the number of memory blocks currently allocated.");
892 : :
893 : : #define SYS_GETALLOCATEDBLOCKS_METHODDEF \
894 : : {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
895 : :
896 : : static Py_ssize_t
897 : : sys_getallocatedblocks_impl(PyObject *module);
898 : :
899 : : static PyObject *
900 : 0 : sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
901 : : {
902 : 0 : PyObject *return_value = NULL;
903 : : Py_ssize_t _return_value;
904 : :
905 : 0 : _return_value = sys_getallocatedblocks_impl(module);
906 [ # # # # ]: 0 : if ((_return_value == -1) && PyErr_Occurred()) {
907 : 0 : goto exit;
908 : : }
909 : 0 : return_value = PyLong_FromSsize_t(_return_value);
910 : :
911 : 0 : exit:
912 : 0 : return return_value;
913 : : }
914 : :
915 : : PyDoc_STRVAR(sys__getframe__doc__,
916 : : "_getframe($module, depth=0, /)\n"
917 : : "--\n"
918 : : "\n"
919 : : "Return a frame object from the call stack.\n"
920 : : "\n"
921 : : "If optional integer depth is given, return the frame object that many\n"
922 : : "calls below the top of the stack. If that is deeper than the call\n"
923 : : "stack, ValueError is raised. The default for depth is zero, returning\n"
924 : : "the frame at the top of the call stack.\n"
925 : : "\n"
926 : : "This function should be used for internal and specialized purposes\n"
927 : : "only.");
928 : :
929 : : #define SYS__GETFRAME_METHODDEF \
930 : : {"_getframe", _PyCFunction_CAST(sys__getframe), METH_FASTCALL, sys__getframe__doc__},
931 : :
932 : : static PyObject *
933 : : sys__getframe_impl(PyObject *module, int depth);
934 : :
935 : : static PyObject *
936 : 0 : sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
937 : : {
938 : 0 : PyObject *return_value = NULL;
939 : 0 : int depth = 0;
940 : :
941 [ # # # # : 0 : if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
# # ]
942 : 0 : goto exit;
943 : : }
944 [ # # ]: 0 : if (nargs < 1) {
945 : 0 : goto skip_optional;
946 : : }
947 : 0 : depth = _PyLong_AsInt(args[0]);
948 [ # # # # ]: 0 : if (depth == -1 && PyErr_Occurred()) {
949 : 0 : goto exit;
950 : : }
951 : 0 : skip_optional:
952 : 0 : return_value = sys__getframe_impl(module, depth);
953 : :
954 : 0 : exit:
955 : 0 : return return_value;
956 : : }
957 : :
958 : : PyDoc_STRVAR(sys__current_frames__doc__,
959 : : "_current_frames($module, /)\n"
960 : : "--\n"
961 : : "\n"
962 : : "Return a dict mapping each thread\'s thread id to its current stack frame.\n"
963 : : "\n"
964 : : "This function should be used for specialized purposes only.");
965 : :
966 : : #define SYS__CURRENT_FRAMES_METHODDEF \
967 : : {"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__},
968 : :
969 : : static PyObject *
970 : : sys__current_frames_impl(PyObject *module);
971 : :
972 : : static PyObject *
973 : 0 : sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored))
974 : : {
975 : 0 : return sys__current_frames_impl(module);
976 : : }
977 : :
978 : : PyDoc_STRVAR(sys__current_exceptions__doc__,
979 : : "_current_exceptions($module, /)\n"
980 : : "--\n"
981 : : "\n"
982 : : "Return a dict mapping each thread\'s identifier to its current raised exception.\n"
983 : : "\n"
984 : : "This function should be used for specialized purposes only.");
985 : :
986 : : #define SYS__CURRENT_EXCEPTIONS_METHODDEF \
987 : : {"_current_exceptions", (PyCFunction)sys__current_exceptions, METH_NOARGS, sys__current_exceptions__doc__},
988 : :
989 : : static PyObject *
990 : : sys__current_exceptions_impl(PyObject *module);
991 : :
992 : : static PyObject *
993 : 0 : sys__current_exceptions(PyObject *module, PyObject *Py_UNUSED(ignored))
994 : : {
995 : 0 : return sys__current_exceptions_impl(module);
996 : : }
997 : :
998 : : PyDoc_STRVAR(sys_call_tracing__doc__,
999 : : "call_tracing($module, func, args, /)\n"
1000 : : "--\n"
1001 : : "\n"
1002 : : "Call func(*args), while tracing is enabled.\n"
1003 : : "\n"
1004 : : "The tracing state is saved, and restored afterwards. This is intended\n"
1005 : : "to be called from a debugger from a checkpoint, to recursively debug\n"
1006 : : "some other code.");
1007 : :
1008 : : #define SYS_CALL_TRACING_METHODDEF \
1009 : : {"call_tracing", _PyCFunction_CAST(sys_call_tracing), METH_FASTCALL, sys_call_tracing__doc__},
1010 : :
1011 : : static PyObject *
1012 : : sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs);
1013 : :
1014 : : static PyObject *
1015 : 0 : sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1016 : : {
1017 : 0 : PyObject *return_value = NULL;
1018 : : PyObject *func;
1019 : : PyObject *funcargs;
1020 : :
1021 [ # # # # : 0 : if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
# # ]
1022 : 0 : goto exit;
1023 : : }
1024 : 0 : func = args[0];
1025 [ # # ]: 0 : if (!PyTuple_Check(args[1])) {
1026 : 0 : _PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]);
1027 : 0 : goto exit;
1028 : : }
1029 : 0 : funcargs = args[1];
1030 : 0 : return_value = sys_call_tracing_impl(module, func, funcargs);
1031 : :
1032 : 0 : exit:
1033 : 0 : return return_value;
1034 : : }
1035 : :
1036 : : PyDoc_STRVAR(sys__debugmallocstats__doc__,
1037 : : "_debugmallocstats($module, /)\n"
1038 : : "--\n"
1039 : : "\n"
1040 : : "Print summary info to stderr about the state of pymalloc\'s structures.\n"
1041 : : "\n"
1042 : : "In Py_DEBUG mode, also perform some expensive internal consistency\n"
1043 : : "checks.");
1044 : :
1045 : : #define SYS__DEBUGMALLOCSTATS_METHODDEF \
1046 : : {"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__},
1047 : :
1048 : : static PyObject *
1049 : : sys__debugmallocstats_impl(PyObject *module);
1050 : :
1051 : : static PyObject *
1052 : 0 : sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored))
1053 : : {
1054 : 0 : return sys__debugmallocstats_impl(module);
1055 : : }
1056 : :
1057 : : PyDoc_STRVAR(sys__clear_type_cache__doc__,
1058 : : "_clear_type_cache($module, /)\n"
1059 : : "--\n"
1060 : : "\n"
1061 : : "Clear the internal type lookup cache.");
1062 : :
1063 : : #define SYS__CLEAR_TYPE_CACHE_METHODDEF \
1064 : : {"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__},
1065 : :
1066 : : static PyObject *
1067 : : sys__clear_type_cache_impl(PyObject *module);
1068 : :
1069 : : static PyObject *
1070 : 0 : sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored))
1071 : : {
1072 : 0 : return sys__clear_type_cache_impl(module);
1073 : : }
1074 : :
1075 : : PyDoc_STRVAR(sys_is_finalizing__doc__,
1076 : : "is_finalizing($module, /)\n"
1077 : : "--\n"
1078 : : "\n"
1079 : : "Return True if Python is exiting.");
1080 : :
1081 : : #define SYS_IS_FINALIZING_METHODDEF \
1082 : : {"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__},
1083 : :
1084 : : static PyObject *
1085 : : sys_is_finalizing_impl(PyObject *module);
1086 : :
1087 : : static PyObject *
1088 : 0 : sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
1089 : : {
1090 : 0 : return sys_is_finalizing_impl(module);
1091 : : }
1092 : :
1093 : : #if defined(Py_STATS)
1094 : :
1095 : : PyDoc_STRVAR(sys__stats_on__doc__,
1096 : : "_stats_on($module, /)\n"
1097 : : "--\n"
1098 : : "\n"
1099 : : "Turns on stats gathering (stats gathering is on by default).");
1100 : :
1101 : : #define SYS__STATS_ON_METHODDEF \
1102 : : {"_stats_on", (PyCFunction)sys__stats_on, METH_NOARGS, sys__stats_on__doc__},
1103 : :
1104 : : static PyObject *
1105 : : sys__stats_on_impl(PyObject *module);
1106 : :
1107 : : static PyObject *
1108 : : sys__stats_on(PyObject *module, PyObject *Py_UNUSED(ignored))
1109 : : {
1110 : : return sys__stats_on_impl(module);
1111 : : }
1112 : :
1113 : : #endif /* defined(Py_STATS) */
1114 : :
1115 : : #if defined(Py_STATS)
1116 : :
1117 : : PyDoc_STRVAR(sys__stats_off__doc__,
1118 : : "_stats_off($module, /)\n"
1119 : : "--\n"
1120 : : "\n"
1121 : : "Turns off stats gathering (stats gathering is on by default).");
1122 : :
1123 : : #define SYS__STATS_OFF_METHODDEF \
1124 : : {"_stats_off", (PyCFunction)sys__stats_off, METH_NOARGS, sys__stats_off__doc__},
1125 : :
1126 : : static PyObject *
1127 : : sys__stats_off_impl(PyObject *module);
1128 : :
1129 : : static PyObject *
1130 : : sys__stats_off(PyObject *module, PyObject *Py_UNUSED(ignored))
1131 : : {
1132 : : return sys__stats_off_impl(module);
1133 : : }
1134 : :
1135 : : #endif /* defined(Py_STATS) */
1136 : :
1137 : : #if defined(Py_STATS)
1138 : :
1139 : : PyDoc_STRVAR(sys__stats_clear__doc__,
1140 : : "_stats_clear($module, /)\n"
1141 : : "--\n"
1142 : : "\n"
1143 : : "Clears the stats.");
1144 : :
1145 : : #define SYS__STATS_CLEAR_METHODDEF \
1146 : : {"_stats_clear", (PyCFunction)sys__stats_clear, METH_NOARGS, sys__stats_clear__doc__},
1147 : :
1148 : : static PyObject *
1149 : : sys__stats_clear_impl(PyObject *module);
1150 : :
1151 : : static PyObject *
1152 : : sys__stats_clear(PyObject *module, PyObject *Py_UNUSED(ignored))
1153 : : {
1154 : : return sys__stats_clear_impl(module);
1155 : : }
1156 : :
1157 : : #endif /* defined(Py_STATS) */
1158 : :
1159 : : #if defined(Py_STATS)
1160 : :
1161 : : PyDoc_STRVAR(sys__stats_dump__doc__,
1162 : : "_stats_dump($module, /)\n"
1163 : : "--\n"
1164 : : "\n"
1165 : : "Dump stats to file, and clears the stats.");
1166 : :
1167 : : #define SYS__STATS_DUMP_METHODDEF \
1168 : : {"_stats_dump", (PyCFunction)sys__stats_dump, METH_NOARGS, sys__stats_dump__doc__},
1169 : :
1170 : : static PyObject *
1171 : : sys__stats_dump_impl(PyObject *module);
1172 : :
1173 : : static PyObject *
1174 : : sys__stats_dump(PyObject *module, PyObject *Py_UNUSED(ignored))
1175 : : {
1176 : : return sys__stats_dump_impl(module);
1177 : : }
1178 : :
1179 : : #endif /* defined(Py_STATS) */
1180 : :
1181 : : #if defined(ANDROID_API_LEVEL)
1182 : :
1183 : : PyDoc_STRVAR(sys_getandroidapilevel__doc__,
1184 : : "getandroidapilevel($module, /)\n"
1185 : : "--\n"
1186 : : "\n"
1187 : : "Return the build time API version of Android as an integer.");
1188 : :
1189 : : #define SYS_GETANDROIDAPILEVEL_METHODDEF \
1190 : : {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__},
1191 : :
1192 : : static PyObject *
1193 : : sys_getandroidapilevel_impl(PyObject *module);
1194 : :
1195 : : static PyObject *
1196 : : sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
1197 : : {
1198 : : return sys_getandroidapilevel_impl(module);
1199 : : }
1200 : :
1201 : : #endif /* defined(ANDROID_API_LEVEL) */
1202 : :
1203 : : PyDoc_STRVAR(sys_activate_stack_trampoline__doc__,
1204 : : "activate_stack_trampoline($module, backend, /)\n"
1205 : : "--\n"
1206 : : "\n"
1207 : : "Activate stack profiler trampoline *backend*.");
1208 : :
1209 : : #define SYS_ACTIVATE_STACK_TRAMPOLINE_METHODDEF \
1210 : : {"activate_stack_trampoline", (PyCFunction)sys_activate_stack_trampoline, METH_O, sys_activate_stack_trampoline__doc__},
1211 : :
1212 : : static PyObject *
1213 : : sys_activate_stack_trampoline_impl(PyObject *module, const char *backend);
1214 : :
1215 : : static PyObject *
1216 : 0 : sys_activate_stack_trampoline(PyObject *module, PyObject *arg)
1217 : : {
1218 : 0 : PyObject *return_value = NULL;
1219 : : const char *backend;
1220 : :
1221 [ # # ]: 0 : if (!PyUnicode_Check(arg)) {
1222 : 0 : _PyArg_BadArgument("activate_stack_trampoline", "argument", "str", arg);
1223 : 0 : goto exit;
1224 : : }
1225 : : Py_ssize_t backend_length;
1226 : 0 : backend = PyUnicode_AsUTF8AndSize(arg, &backend_length);
1227 [ # # ]: 0 : if (backend == NULL) {
1228 : 0 : goto exit;
1229 : : }
1230 [ # # ]: 0 : if (strlen(backend) != (size_t)backend_length) {
1231 : 0 : PyErr_SetString(PyExc_ValueError, "embedded null character");
1232 : 0 : goto exit;
1233 : : }
1234 : 0 : return_value = sys_activate_stack_trampoline_impl(module, backend);
1235 : :
1236 : 0 : exit:
1237 : 0 : return return_value;
1238 : : }
1239 : :
1240 : : PyDoc_STRVAR(sys_deactivate_stack_trampoline__doc__,
1241 : : "deactivate_stack_trampoline($module, /)\n"
1242 : : "--\n"
1243 : : "\n"
1244 : : "Deactivate the current stack profiler trampoline backend.\n"
1245 : : "\n"
1246 : : "If no stack profiler is activated, this function has no effect.");
1247 : :
1248 : : #define SYS_DEACTIVATE_STACK_TRAMPOLINE_METHODDEF \
1249 : : {"deactivate_stack_trampoline", (PyCFunction)sys_deactivate_stack_trampoline, METH_NOARGS, sys_deactivate_stack_trampoline__doc__},
1250 : :
1251 : : static PyObject *
1252 : : sys_deactivate_stack_trampoline_impl(PyObject *module);
1253 : :
1254 : : static PyObject *
1255 : 0 : sys_deactivate_stack_trampoline(PyObject *module, PyObject *Py_UNUSED(ignored))
1256 : : {
1257 : 0 : return sys_deactivate_stack_trampoline_impl(module);
1258 : : }
1259 : :
1260 : : PyDoc_STRVAR(sys_is_stack_trampoline_active__doc__,
1261 : : "is_stack_trampoline_active($module, /)\n"
1262 : : "--\n"
1263 : : "\n"
1264 : : "Return *True* if a stack profiler trampoline is active.");
1265 : :
1266 : : #define SYS_IS_STACK_TRAMPOLINE_ACTIVE_METHODDEF \
1267 : : {"is_stack_trampoline_active", (PyCFunction)sys_is_stack_trampoline_active, METH_NOARGS, sys_is_stack_trampoline_active__doc__},
1268 : :
1269 : : static PyObject *
1270 : : sys_is_stack_trampoline_active_impl(PyObject *module);
1271 : :
1272 : : static PyObject *
1273 : 0 : sys_is_stack_trampoline_active(PyObject *module, PyObject *Py_UNUSED(ignored))
1274 : : {
1275 : 0 : return sys_is_stack_trampoline_active_impl(module);
1276 : : }
1277 : :
1278 : : PyDoc_STRVAR(sys__getframemodulename__doc__,
1279 : : "_getframemodulename($module, /, depth=0)\n"
1280 : : "--\n"
1281 : : "\n"
1282 : : "Return the name of the module for a calling frame.\n"
1283 : : "\n"
1284 : : "The default depth returns the module containing the call to this API.\n"
1285 : : "A more typical use in a library will pass a depth of 1 to get the user\'s\n"
1286 : : "module rather than the library module.\n"
1287 : : "\n"
1288 : : "If no frame, module, or name can be found, returns None.");
1289 : :
1290 : : #define SYS__GETFRAMEMODULENAME_METHODDEF \
1291 : : {"_getframemodulename", _PyCFunction_CAST(sys__getframemodulename), METH_FASTCALL|METH_KEYWORDS, sys__getframemodulename__doc__},
1292 : :
1293 : : static PyObject *
1294 : : sys__getframemodulename_impl(PyObject *module, int depth);
1295 : :
1296 : : static PyObject *
1297 : 88 : sys__getframemodulename(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1298 : : {
1299 : 88 : PyObject *return_value = NULL;
1300 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1301 : :
1302 : : #define NUM_KEYWORDS 1
1303 : : static struct {
1304 : : PyGC_Head _this_is_not_used;
1305 : : PyObject_VAR_HEAD
1306 : : PyObject *ob_item[NUM_KEYWORDS];
1307 : : } _kwtuple = {
1308 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1309 : : .ob_item = { &_Py_ID(depth), },
1310 : : };
1311 : : #undef NUM_KEYWORDS
1312 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1313 : :
1314 : : #else // !Py_BUILD_CORE
1315 : : # define KWTUPLE NULL
1316 : : #endif // !Py_BUILD_CORE
1317 : :
1318 : : static const char * const _keywords[] = {"depth", NULL};
1319 : : static _PyArg_Parser _parser = {
1320 : : .keywords = _keywords,
1321 : : .fname = "_getframemodulename",
1322 : : .kwtuple = KWTUPLE,
1323 : : };
1324 : : #undef KWTUPLE
1325 : : PyObject *argsbuf[1];
1326 [ - + ]: 88 : Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1327 : 88 : int depth = 0;
1328 : :
1329 [ + - + - : 88 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
+ - - + ]
1330 [ - + ]: 88 : if (!args) {
1331 : 0 : goto exit;
1332 : : }
1333 [ - + ]: 88 : if (!noptargs) {
1334 : 0 : goto skip_optional_pos;
1335 : : }
1336 : 88 : depth = _PyLong_AsInt(args[0]);
1337 [ - + - - ]: 88 : if (depth == -1 && PyErr_Occurred()) {
1338 : 0 : goto exit;
1339 : : }
1340 : 88 : skip_optional_pos:
1341 : 88 : return_value = sys__getframemodulename_impl(module, depth);
1342 : :
1343 : 88 : exit:
1344 : 88 : return return_value;
1345 : : }
1346 : :
1347 : : #ifndef SYS_GETWINDOWSVERSION_METHODDEF
1348 : : #define SYS_GETWINDOWSVERSION_METHODDEF
1349 : : #endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
1350 : :
1351 : : #ifndef SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1352 : : #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1353 : : #endif /* !defined(SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF) */
1354 : :
1355 : : #ifndef SYS_SETDLOPENFLAGS_METHODDEF
1356 : : #define SYS_SETDLOPENFLAGS_METHODDEF
1357 : : #endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */
1358 : :
1359 : : #ifndef SYS_GETDLOPENFLAGS_METHODDEF
1360 : : #define SYS_GETDLOPENFLAGS_METHODDEF
1361 : : #endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */
1362 : :
1363 : : #ifndef SYS_MDEBUG_METHODDEF
1364 : : #define SYS_MDEBUG_METHODDEF
1365 : : #endif /* !defined(SYS_MDEBUG_METHODDEF) */
1366 : :
1367 : : #ifndef SYS_GETTOTALREFCOUNT_METHODDEF
1368 : : #define SYS_GETTOTALREFCOUNT_METHODDEF
1369 : : #endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
1370 : :
1371 : : #ifndef SYS__STATS_ON_METHODDEF
1372 : : #define SYS__STATS_ON_METHODDEF
1373 : : #endif /* !defined(SYS__STATS_ON_METHODDEF) */
1374 : :
1375 : : #ifndef SYS__STATS_OFF_METHODDEF
1376 : : #define SYS__STATS_OFF_METHODDEF
1377 : : #endif /* !defined(SYS__STATS_OFF_METHODDEF) */
1378 : :
1379 : : #ifndef SYS__STATS_CLEAR_METHODDEF
1380 : : #define SYS__STATS_CLEAR_METHODDEF
1381 : : #endif /* !defined(SYS__STATS_CLEAR_METHODDEF) */
1382 : :
1383 : : #ifndef SYS__STATS_DUMP_METHODDEF
1384 : : #define SYS__STATS_DUMP_METHODDEF
1385 : : #endif /* !defined(SYS__STATS_DUMP_METHODDEF) */
1386 : :
1387 : : #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
1388 : : #define SYS_GETANDROIDAPILEVEL_METHODDEF
1389 : : #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
1390 : : /*[clinic end generated code: output=5c761f14326ced54 input=a9049054013a1b77]*/
|