• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 #  include "pycore_gc.h"          // PyGC_Head
7 #  include "pycore_runtime.h"     // _Py_ID()
8 #endif
9 #include "pycore_modsupport.h"    // _PyArg_UnpackKeywords()
10 
11 PyDoc_STRVAR(sys_addaudithook__doc__,
12 "addaudithook($module, /, hook)\n"
13 "--\n"
14 "\n"
15 "Adds a new audit hook callback.");
16 
17 #define SYS_ADDAUDITHOOK_METHODDEF    \
18     {"addaudithook", _PyCFunction_CAST(sys_addaudithook), METH_FASTCALL|METH_KEYWORDS, sys_addaudithook__doc__},
19 
20 static PyObject *
21 sys_addaudithook_impl(PyObject *module, PyObject *hook);
22 
23 static PyObject *
sys_addaudithook(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)24 sys_addaudithook(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
25 {
26     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     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
56     if (!args) {
57         goto exit;
58     }
59     hook = args[0];
60     return_value = sys_addaudithook_impl(module, hook);
61 
62 exit:
63     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 *
sys_excepthook(PyObject * module,PyObject * const * args,Py_ssize_t nargs)89 sys_excepthook(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
90 {
91     PyObject *return_value = NULL;
92     PyObject *exctype;
93     PyObject *value;
94     PyObject *traceback;
95 
96     if (!_PyArg_CheckPositional("excepthook", nargs, 3, 3)) {
97         goto exit;
98     }
99     exctype = args[0];
100     value = args[1];
101     traceback = args[2];
102     return_value = sys_excepthook_impl(module, exctype, value, traceback);
103 
104 exit:
105     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 *
sys_exception(PyObject * module,PyObject * Py_UNUSED (ignored))125 sys_exception(PyObject *module, PyObject *Py_UNUSED(ignored))
126 {
127     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 *
sys_exc_info(PyObject * module,PyObject * Py_UNUSED (ignored))146 sys_exc_info(PyObject *module, PyObject *Py_UNUSED(ignored))
147 {
148     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 *
sys_exit(PyObject * module,PyObject * const * args,Py_ssize_t nargs)186 sys_exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
187 {
188     PyObject *return_value = NULL;
189     PyObject *status = Py_None;
190 
191     if (!_PyArg_CheckPositional("exit", nargs, 0, 1)) {
192         goto exit;
193     }
194     if (nargs < 1) {
195         goto skip_optional;
196     }
197     status = args[0];
198 skip_optional:
199     return_value = sys_exit_impl(module, status);
200 
201 exit:
202     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 *
sys_getdefaultencoding(PyObject * module,PyObject * Py_UNUSED (ignored))218 sys_getdefaultencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
219 {
220     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 *
sys_getfilesystemencoding(PyObject * module,PyObject * Py_UNUSED (ignored))236 sys_getfilesystemencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
237 {
238     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 *
sys_getfilesystemencodeerrors(PyObject * module,PyObject * Py_UNUSED (ignored))254 sys_getfilesystemencodeerrors(PyObject *module, PyObject *Py_UNUSED(ignored))
255 {
256     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 *
sys_intern(PyObject * module,PyObject * arg)276 sys_intern(PyObject *module, PyObject *arg)
277 {
278     PyObject *return_value = NULL;
279     PyObject *s;
280 
281     if (!PyUnicode_Check(arg)) {
282         _PyArg_BadArgument("intern", "argument", "str", arg);
283         goto exit;
284     }
285     s = arg;
286     return_value = sys_intern_impl(module, s);
287 
288 exit:
289     return return_value;
290 }
291 
292 PyDoc_STRVAR(sys__is_interned__doc__,
293 "_is_interned($module, string, /)\n"
294 "--\n"
295 "\n"
296 "Return True if the given string is \"interned\".");
297 
298 #define SYS__IS_INTERNED_METHODDEF    \
299     {"_is_interned", (PyCFunction)sys__is_interned, METH_O, sys__is_interned__doc__},
300 
301 static int
302 sys__is_interned_impl(PyObject *module, PyObject *string);
303 
304 static PyObject *
sys__is_interned(PyObject * module,PyObject * arg)305 sys__is_interned(PyObject *module, PyObject *arg)
306 {
307     PyObject *return_value = NULL;
308     PyObject *string;
309     int _return_value;
310 
311     if (!PyUnicode_Check(arg)) {
312         _PyArg_BadArgument("_is_interned", "argument", "str", arg);
313         goto exit;
314     }
315     string = arg;
316     _return_value = sys__is_interned_impl(module, string);
317     if ((_return_value == -1) && PyErr_Occurred()) {
318         goto exit;
319     }
320     return_value = PyBool_FromLong((long)_return_value);
321 
322 exit:
323     return return_value;
324 }
325 
326 PyDoc_STRVAR(sys_settrace__doc__,
327 "settrace($module, function, /)\n"
328 "--\n"
329 "\n"
330 "Set the global debug tracing function.\n"
331 "\n"
332 "It will be called on each function call.  See the debugger chapter\n"
333 "in the library manual.");
334 
335 #define SYS_SETTRACE_METHODDEF    \
336     {"settrace", (PyCFunction)sys_settrace, METH_O, sys_settrace__doc__},
337 
338 PyDoc_STRVAR(sys__settraceallthreads__doc__,
339 "_settraceallthreads($module, function, /)\n"
340 "--\n"
341 "\n"
342 "Set the global debug tracing function in all running threads belonging to the current interpreter.\n"
343 "\n"
344 "It will be called on each function call. See the debugger chapter\n"
345 "in the library manual.");
346 
347 #define SYS__SETTRACEALLTHREADS_METHODDEF    \
348     {"_settraceallthreads", (PyCFunction)sys__settraceallthreads, METH_O, sys__settraceallthreads__doc__},
349 
350 PyDoc_STRVAR(sys_gettrace__doc__,
351 "gettrace($module, /)\n"
352 "--\n"
353 "\n"
354 "Return the global debug tracing function set with sys.settrace.\n"
355 "\n"
356 "See the debugger chapter in the library manual.");
357 
358 #define SYS_GETTRACE_METHODDEF    \
359     {"gettrace", (PyCFunction)sys_gettrace, METH_NOARGS, sys_gettrace__doc__},
360 
361 static PyObject *
362 sys_gettrace_impl(PyObject *module);
363 
364 static PyObject *
sys_gettrace(PyObject * module,PyObject * Py_UNUSED (ignored))365 sys_gettrace(PyObject *module, PyObject *Py_UNUSED(ignored))
366 {
367     return sys_gettrace_impl(module);
368 }
369 
370 PyDoc_STRVAR(sys_setprofile__doc__,
371 "setprofile($module, function, /)\n"
372 "--\n"
373 "\n"
374 "Set the profiling function.\n"
375 "\n"
376 "It will be called on each function call and return.  See the profiler\n"
377 "chapter in the library manual.");
378 
379 #define SYS_SETPROFILE_METHODDEF    \
380     {"setprofile", (PyCFunction)sys_setprofile, METH_O, sys_setprofile__doc__},
381 
382 PyDoc_STRVAR(sys__setprofileallthreads__doc__,
383 "_setprofileallthreads($module, function, /)\n"
384 "--\n"
385 "\n"
386 "Set the profiling function in all running threads belonging to the current interpreter.\n"
387 "\n"
388 "It will be called on each function call and return.  See the profiler\n"
389 "chapter in the library manual.");
390 
391 #define SYS__SETPROFILEALLTHREADS_METHODDEF    \
392     {"_setprofileallthreads", (PyCFunction)sys__setprofileallthreads, METH_O, sys__setprofileallthreads__doc__},
393 
394 PyDoc_STRVAR(sys_getprofile__doc__,
395 "getprofile($module, /)\n"
396 "--\n"
397 "\n"
398 "Return the profiling function set with sys.setprofile.\n"
399 "\n"
400 "See the profiler chapter in the library manual.");
401 
402 #define SYS_GETPROFILE_METHODDEF    \
403     {"getprofile", (PyCFunction)sys_getprofile, METH_NOARGS, sys_getprofile__doc__},
404 
405 static PyObject *
406 sys_getprofile_impl(PyObject *module);
407 
408 static PyObject *
sys_getprofile(PyObject * module,PyObject * Py_UNUSED (ignored))409 sys_getprofile(PyObject *module, PyObject *Py_UNUSED(ignored))
410 {
411     return sys_getprofile_impl(module);
412 }
413 
414 PyDoc_STRVAR(sys_setswitchinterval__doc__,
415 "setswitchinterval($module, interval, /)\n"
416 "--\n"
417 "\n"
418 "Set the ideal thread switching delay inside the Python interpreter.\n"
419 "\n"
420 "The actual frequency of switching threads can be lower if the\n"
421 "interpreter executes long sequences of uninterruptible code\n"
422 "(this is implementation-specific and workload-dependent).\n"
423 "\n"
424 "The parameter must represent the desired switching delay in seconds\n"
425 "A typical value is 0.005 (5 milliseconds).");
426 
427 #define SYS_SETSWITCHINTERVAL_METHODDEF    \
428     {"setswitchinterval", (PyCFunction)sys_setswitchinterval, METH_O, sys_setswitchinterval__doc__},
429 
430 static PyObject *
431 sys_setswitchinterval_impl(PyObject *module, double interval);
432 
433 static PyObject *
sys_setswitchinterval(PyObject * module,PyObject * arg)434 sys_setswitchinterval(PyObject *module, PyObject *arg)
435 {
436     PyObject *return_value = NULL;
437     double interval;
438 
439     if (PyFloat_CheckExact(arg)) {
440         interval = PyFloat_AS_DOUBLE(arg);
441     }
442     else
443     {
444         interval = PyFloat_AsDouble(arg);
445         if (interval == -1.0 && PyErr_Occurred()) {
446             goto exit;
447         }
448     }
449     return_value = sys_setswitchinterval_impl(module, interval);
450 
451 exit:
452     return return_value;
453 }
454 
455 PyDoc_STRVAR(sys_getswitchinterval__doc__,
456 "getswitchinterval($module, /)\n"
457 "--\n"
458 "\n"
459 "Return the current thread switch interval; see sys.setswitchinterval().");
460 
461 #define SYS_GETSWITCHINTERVAL_METHODDEF    \
462     {"getswitchinterval", (PyCFunction)sys_getswitchinterval, METH_NOARGS, sys_getswitchinterval__doc__},
463 
464 static double
465 sys_getswitchinterval_impl(PyObject *module);
466 
467 static PyObject *
sys_getswitchinterval(PyObject * module,PyObject * Py_UNUSED (ignored))468 sys_getswitchinterval(PyObject *module, PyObject *Py_UNUSED(ignored))
469 {
470     PyObject *return_value = NULL;
471     double _return_value;
472 
473     _return_value = sys_getswitchinterval_impl(module);
474     if ((_return_value == -1.0) && PyErr_Occurred()) {
475         goto exit;
476     }
477     return_value = PyFloat_FromDouble(_return_value);
478 
479 exit:
480     return return_value;
481 }
482 
483 PyDoc_STRVAR(sys_setrecursionlimit__doc__,
484 "setrecursionlimit($module, limit, /)\n"
485 "--\n"
486 "\n"
487 "Set the maximum depth of the Python interpreter stack to n.\n"
488 "\n"
489 "This limit prevents infinite recursion from causing an overflow of the C\n"
490 "stack and crashing Python.  The highest possible limit is platform-\n"
491 "dependent.");
492 
493 #define SYS_SETRECURSIONLIMIT_METHODDEF    \
494     {"setrecursionlimit", (PyCFunction)sys_setrecursionlimit, METH_O, sys_setrecursionlimit__doc__},
495 
496 static PyObject *
497 sys_setrecursionlimit_impl(PyObject *module, int new_limit);
498 
499 static PyObject *
sys_setrecursionlimit(PyObject * module,PyObject * arg)500 sys_setrecursionlimit(PyObject *module, PyObject *arg)
501 {
502     PyObject *return_value = NULL;
503     int new_limit;
504 
505     new_limit = PyLong_AsInt(arg);
506     if (new_limit == -1 && PyErr_Occurred()) {
507         goto exit;
508     }
509     return_value = sys_setrecursionlimit_impl(module, new_limit);
510 
511 exit:
512     return return_value;
513 }
514 
515 PyDoc_STRVAR(sys_set_coroutine_origin_tracking_depth__doc__,
516 "set_coroutine_origin_tracking_depth($module, /, depth)\n"
517 "--\n"
518 "\n"
519 "Enable or disable origin tracking for coroutine objects in this thread.\n"
520 "\n"
521 "Coroutine objects will track \'depth\' frames of traceback information\n"
522 "about where they came from, available in their cr_origin attribute.\n"
523 "\n"
524 "Set a depth of 0 to disable.");
525 
526 #define SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF    \
527     {"set_coroutine_origin_tracking_depth", _PyCFunction_CAST(sys_set_coroutine_origin_tracking_depth), METH_FASTCALL|METH_KEYWORDS, sys_set_coroutine_origin_tracking_depth__doc__},
528 
529 static PyObject *
530 sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth);
531 
532 static PyObject *
sys_set_coroutine_origin_tracking_depth(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)533 sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
534 {
535     PyObject *return_value = NULL;
536     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
537 
538     #define NUM_KEYWORDS 1
539     static struct {
540         PyGC_Head _this_is_not_used;
541         PyObject_VAR_HEAD
542         PyObject *ob_item[NUM_KEYWORDS];
543     } _kwtuple = {
544         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
545         .ob_item = { &_Py_ID(depth), },
546     };
547     #undef NUM_KEYWORDS
548     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
549 
550     #else  // !Py_BUILD_CORE
551     #  define KWTUPLE NULL
552     #endif  // !Py_BUILD_CORE
553 
554     static const char * const _keywords[] = {"depth", NULL};
555     static _PyArg_Parser _parser = {
556         .keywords = _keywords,
557         .fname = "set_coroutine_origin_tracking_depth",
558         .kwtuple = KWTUPLE,
559     };
560     #undef KWTUPLE
561     PyObject *argsbuf[1];
562     int depth;
563 
564     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
565     if (!args) {
566         goto exit;
567     }
568     depth = PyLong_AsInt(args[0]);
569     if (depth == -1 && PyErr_Occurred()) {
570         goto exit;
571     }
572     return_value = sys_set_coroutine_origin_tracking_depth_impl(module, depth);
573 
574 exit:
575     return return_value;
576 }
577 
578 PyDoc_STRVAR(sys_get_coroutine_origin_tracking_depth__doc__,
579 "get_coroutine_origin_tracking_depth($module, /)\n"
580 "--\n"
581 "\n"
582 "Check status of origin tracking for coroutine objects in this thread.");
583 
584 #define SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF    \
585     {"get_coroutine_origin_tracking_depth", (PyCFunction)sys_get_coroutine_origin_tracking_depth, METH_NOARGS, sys_get_coroutine_origin_tracking_depth__doc__},
586 
587 static int
588 sys_get_coroutine_origin_tracking_depth_impl(PyObject *module);
589 
590 static PyObject *
sys_get_coroutine_origin_tracking_depth(PyObject * module,PyObject * Py_UNUSED (ignored))591 sys_get_coroutine_origin_tracking_depth(PyObject *module, PyObject *Py_UNUSED(ignored))
592 {
593     PyObject *return_value = NULL;
594     int _return_value;
595 
596     _return_value = sys_get_coroutine_origin_tracking_depth_impl(module);
597     if ((_return_value == -1) && PyErr_Occurred()) {
598         goto exit;
599     }
600     return_value = PyLong_FromLong((long)_return_value);
601 
602 exit:
603     return return_value;
604 }
605 
606 PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__,
607 "get_asyncgen_hooks($module, /)\n"
608 "--\n"
609 "\n"
610 "Return the installed asynchronous generators hooks.\n"
611 "\n"
612 "This returns a namedtuple of the form (firstiter, finalizer).");
613 
614 #define SYS_GET_ASYNCGEN_HOOKS_METHODDEF    \
615     {"get_asyncgen_hooks", (PyCFunction)sys_get_asyncgen_hooks, METH_NOARGS, sys_get_asyncgen_hooks__doc__},
616 
617 static PyObject *
618 sys_get_asyncgen_hooks_impl(PyObject *module);
619 
620 static PyObject *
sys_get_asyncgen_hooks(PyObject * module,PyObject * Py_UNUSED (ignored))621 sys_get_asyncgen_hooks(PyObject *module, PyObject *Py_UNUSED(ignored))
622 {
623     return sys_get_asyncgen_hooks_impl(module);
624 }
625 
626 PyDoc_STRVAR(sys_getrecursionlimit__doc__,
627 "getrecursionlimit($module, /)\n"
628 "--\n"
629 "\n"
630 "Return the current value of the recursion limit.\n"
631 "\n"
632 "The recursion limit is the maximum depth of the Python interpreter\n"
633 "stack.  This limit prevents infinite recursion from causing an overflow\n"
634 "of the C stack and crashing Python.");
635 
636 #define SYS_GETRECURSIONLIMIT_METHODDEF    \
637     {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, sys_getrecursionlimit__doc__},
638 
639 static PyObject *
640 sys_getrecursionlimit_impl(PyObject *module);
641 
642 static PyObject *
sys_getrecursionlimit(PyObject * module,PyObject * Py_UNUSED (ignored))643 sys_getrecursionlimit(PyObject *module, PyObject *Py_UNUSED(ignored))
644 {
645     return sys_getrecursionlimit_impl(module);
646 }
647 
648 #if defined(MS_WINDOWS)
649 
650 PyDoc_STRVAR(sys_getwindowsversion__doc__,
651 "getwindowsversion($module, /)\n"
652 "--\n"
653 "\n"
654 "Return info about the running version of Windows as a named tuple.\n"
655 "\n"
656 "The members are named: major, minor, build, platform, service_pack,\n"
657 "service_pack_major, service_pack_minor, suite_mask, product_type and\n"
658 "platform_version. For backward compatibility, only the first 5 items\n"
659 "are available by indexing. All elements are numbers, except\n"
660 "service_pack and platform_type which are strings, and platform_version\n"
661 "which is a 3-tuple. Platform is always 2. Product_type may be 1 for a\n"
662 "workstation, 2 for a domain controller, 3 for a server.\n"
663 "Platform_version is a 3-tuple containing a version number that is\n"
664 "intended for identifying the OS rather than feature detection.");
665 
666 #define SYS_GETWINDOWSVERSION_METHODDEF    \
667     {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, sys_getwindowsversion__doc__},
668 
669 static PyObject *
670 sys_getwindowsversion_impl(PyObject *module);
671 
672 static PyObject *
sys_getwindowsversion(PyObject * module,PyObject * Py_UNUSED (ignored))673 sys_getwindowsversion(PyObject *module, PyObject *Py_UNUSED(ignored))
674 {
675     return sys_getwindowsversion_impl(module);
676 }
677 
678 #endif /* defined(MS_WINDOWS) */
679 
680 #if defined(MS_WINDOWS)
681 
682 PyDoc_STRVAR(sys__enablelegacywindowsfsencoding__doc__,
683 "_enablelegacywindowsfsencoding($module, /)\n"
684 "--\n"
685 "\n"
686 "Changes the default filesystem encoding to mbcs:replace.\n"
687 "\n"
688 "This is done for consistency with earlier versions of Python. See PEP\n"
689 "529 for more information.\n"
690 "\n"
691 "This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING\n"
692 "environment variable before launching Python.");
693 
694 #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF    \
695     {"_enablelegacywindowsfsencoding", (PyCFunction)sys__enablelegacywindowsfsencoding, METH_NOARGS, sys__enablelegacywindowsfsencoding__doc__},
696 
697 static PyObject *
698 sys__enablelegacywindowsfsencoding_impl(PyObject *module);
699 
700 static PyObject *
sys__enablelegacywindowsfsencoding(PyObject * module,PyObject * Py_UNUSED (ignored))701 sys__enablelegacywindowsfsencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
702 {
703     return sys__enablelegacywindowsfsencoding_impl(module);
704 }
705 
706 #endif /* defined(MS_WINDOWS) */
707 
708 #if defined(HAVE_DLOPEN)
709 
710 PyDoc_STRVAR(sys_setdlopenflags__doc__,
711 "setdlopenflags($module, flags, /)\n"
712 "--\n"
713 "\n"
714 "Set the flags used by the interpreter for dlopen calls.\n"
715 "\n"
716 "This is used, for example, when the interpreter loads extension\n"
717 "modules. Among other things, this will enable a lazy resolving of\n"
718 "symbols when importing a module, if called as sys.setdlopenflags(0).\n"
719 "To share symbols across extension modules, call as\n"
720 "sys.setdlopenflags(os.RTLD_GLOBAL).  Symbolic names for the flag\n"
721 "modules can be found in the os module (RTLD_xxx constants, e.g.\n"
722 "os.RTLD_LAZY).");
723 
724 #define SYS_SETDLOPENFLAGS_METHODDEF    \
725     {"setdlopenflags", (PyCFunction)sys_setdlopenflags, METH_O, sys_setdlopenflags__doc__},
726 
727 static PyObject *
728 sys_setdlopenflags_impl(PyObject *module, int new_val);
729 
730 static PyObject *
sys_setdlopenflags(PyObject * module,PyObject * arg)731 sys_setdlopenflags(PyObject *module, PyObject *arg)
732 {
733     PyObject *return_value = NULL;
734     int new_val;
735 
736     new_val = PyLong_AsInt(arg);
737     if (new_val == -1 && PyErr_Occurred()) {
738         goto exit;
739     }
740     return_value = sys_setdlopenflags_impl(module, new_val);
741 
742 exit:
743     return return_value;
744 }
745 
746 #endif /* defined(HAVE_DLOPEN) */
747 
748 #if defined(HAVE_DLOPEN)
749 
750 PyDoc_STRVAR(sys_getdlopenflags__doc__,
751 "getdlopenflags($module, /)\n"
752 "--\n"
753 "\n"
754 "Return the current value of the flags that are used for dlopen calls.\n"
755 "\n"
756 "The flag constants are defined in the os module.");
757 
758 #define SYS_GETDLOPENFLAGS_METHODDEF    \
759     {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, sys_getdlopenflags__doc__},
760 
761 static PyObject *
762 sys_getdlopenflags_impl(PyObject *module);
763 
764 static PyObject *
sys_getdlopenflags(PyObject * module,PyObject * Py_UNUSED (ignored))765 sys_getdlopenflags(PyObject *module, PyObject *Py_UNUSED(ignored))
766 {
767     return sys_getdlopenflags_impl(module);
768 }
769 
770 #endif /* defined(HAVE_DLOPEN) */
771 
772 #if defined(USE_MALLOPT)
773 
774 PyDoc_STRVAR(sys_mdebug__doc__,
775 "mdebug($module, flag, /)\n"
776 "--\n"
777 "\n");
778 
779 #define SYS_MDEBUG_METHODDEF    \
780     {"mdebug", (PyCFunction)sys_mdebug, METH_O, sys_mdebug__doc__},
781 
782 static PyObject *
783 sys_mdebug_impl(PyObject *module, int flag);
784 
785 static PyObject *
sys_mdebug(PyObject * module,PyObject * arg)786 sys_mdebug(PyObject *module, PyObject *arg)
787 {
788     PyObject *return_value = NULL;
789     int flag;
790 
791     flag = PyLong_AsInt(arg);
792     if (flag == -1 && PyErr_Occurred()) {
793         goto exit;
794     }
795     return_value = sys_mdebug_impl(module, flag);
796 
797 exit:
798     return return_value;
799 }
800 
801 #endif /* defined(USE_MALLOPT) */
802 
803 PyDoc_STRVAR(sys_get_int_max_str_digits__doc__,
804 "get_int_max_str_digits($module, /)\n"
805 "--\n"
806 "\n"
807 "Return the maximum string digits limit for non-binary int<->str conversions.");
808 
809 #define SYS_GET_INT_MAX_STR_DIGITS_METHODDEF    \
810     {"get_int_max_str_digits", (PyCFunction)sys_get_int_max_str_digits, METH_NOARGS, sys_get_int_max_str_digits__doc__},
811 
812 static PyObject *
813 sys_get_int_max_str_digits_impl(PyObject *module);
814 
815 static PyObject *
sys_get_int_max_str_digits(PyObject * module,PyObject * Py_UNUSED (ignored))816 sys_get_int_max_str_digits(PyObject *module, PyObject *Py_UNUSED(ignored))
817 {
818     return sys_get_int_max_str_digits_impl(module);
819 }
820 
821 PyDoc_STRVAR(sys_set_int_max_str_digits__doc__,
822 "set_int_max_str_digits($module, /, maxdigits)\n"
823 "--\n"
824 "\n"
825 "Set the maximum string digits limit for non-binary int<->str conversions.");
826 
827 #define SYS_SET_INT_MAX_STR_DIGITS_METHODDEF    \
828     {"set_int_max_str_digits", _PyCFunction_CAST(sys_set_int_max_str_digits), METH_FASTCALL|METH_KEYWORDS, sys_set_int_max_str_digits__doc__},
829 
830 static PyObject *
831 sys_set_int_max_str_digits_impl(PyObject *module, int maxdigits);
832 
833 static PyObject *
sys_set_int_max_str_digits(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)834 sys_set_int_max_str_digits(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
835 {
836     PyObject *return_value = NULL;
837     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
838 
839     #define NUM_KEYWORDS 1
840     static struct {
841         PyGC_Head _this_is_not_used;
842         PyObject_VAR_HEAD
843         PyObject *ob_item[NUM_KEYWORDS];
844     } _kwtuple = {
845         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
846         .ob_item = { &_Py_ID(maxdigits), },
847     };
848     #undef NUM_KEYWORDS
849     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
850 
851     #else  // !Py_BUILD_CORE
852     #  define KWTUPLE NULL
853     #endif  // !Py_BUILD_CORE
854 
855     static const char * const _keywords[] = {"maxdigits", NULL};
856     static _PyArg_Parser _parser = {
857         .keywords = _keywords,
858         .fname = "set_int_max_str_digits",
859         .kwtuple = KWTUPLE,
860     };
861     #undef KWTUPLE
862     PyObject *argsbuf[1];
863     int maxdigits;
864 
865     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
866     if (!args) {
867         goto exit;
868     }
869     maxdigits = PyLong_AsInt(args[0]);
870     if (maxdigits == -1 && PyErr_Occurred()) {
871         goto exit;
872     }
873     return_value = sys_set_int_max_str_digits_impl(module, maxdigits);
874 
875 exit:
876     return return_value;
877 }
878 
879 PyDoc_STRVAR(sys_getrefcount__doc__,
880 "getrefcount($module, object, /)\n"
881 "--\n"
882 "\n"
883 "Return the reference count of object.\n"
884 "\n"
885 "The count returned is generally one higher than you might expect,\n"
886 "because it includes the (temporary) reference as an argument to\n"
887 "getrefcount().");
888 
889 #define SYS_GETREFCOUNT_METHODDEF    \
890     {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__},
891 
892 static Py_ssize_t
893 sys_getrefcount_impl(PyObject *module, PyObject *object);
894 
895 static PyObject *
sys_getrefcount(PyObject * module,PyObject * object)896 sys_getrefcount(PyObject *module, PyObject *object)
897 {
898     PyObject *return_value = NULL;
899     Py_ssize_t _return_value;
900 
901     _return_value = sys_getrefcount_impl(module, object);
902     if ((_return_value == -1) && PyErr_Occurred()) {
903         goto exit;
904     }
905     return_value = PyLong_FromSsize_t(_return_value);
906 
907 exit:
908     return return_value;
909 }
910 
911 #if defined(Py_REF_DEBUG)
912 
913 PyDoc_STRVAR(sys_gettotalrefcount__doc__,
914 "gettotalrefcount($module, /)\n"
915 "--\n"
916 "\n");
917 
918 #define SYS_GETTOTALREFCOUNT_METHODDEF    \
919     {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__},
920 
921 static Py_ssize_t
922 sys_gettotalrefcount_impl(PyObject *module);
923 
924 static PyObject *
sys_gettotalrefcount(PyObject * module,PyObject * Py_UNUSED (ignored))925 sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored))
926 {
927     PyObject *return_value = NULL;
928     Py_ssize_t _return_value;
929 
930     _return_value = sys_gettotalrefcount_impl(module);
931     if ((_return_value == -1) && PyErr_Occurred()) {
932         goto exit;
933     }
934     return_value = PyLong_FromSsize_t(_return_value);
935 
936 exit:
937     return return_value;
938 }
939 
940 #endif /* defined(Py_REF_DEBUG) */
941 
942 PyDoc_STRVAR(sys_getallocatedblocks__doc__,
943 "getallocatedblocks($module, /)\n"
944 "--\n"
945 "\n"
946 "Return the number of memory blocks currently allocated.");
947 
948 #define SYS_GETALLOCATEDBLOCKS_METHODDEF    \
949     {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
950 
951 static Py_ssize_t
952 sys_getallocatedblocks_impl(PyObject *module);
953 
954 static PyObject *
sys_getallocatedblocks(PyObject * module,PyObject * Py_UNUSED (ignored))955 sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
956 {
957     PyObject *return_value = NULL;
958     Py_ssize_t _return_value;
959 
960     _return_value = sys_getallocatedblocks_impl(module);
961     if ((_return_value == -1) && PyErr_Occurred()) {
962         goto exit;
963     }
964     return_value = PyLong_FromSsize_t(_return_value);
965 
966 exit:
967     return return_value;
968 }
969 
970 PyDoc_STRVAR(sys_getunicodeinternedsize__doc__,
971 "getunicodeinternedsize($module, /, *, _only_immortal=False)\n"
972 "--\n"
973 "\n"
974 "Return the number of elements of the unicode interned dictionary");
975 
976 #define SYS_GETUNICODEINTERNEDSIZE_METHODDEF    \
977     {"getunicodeinternedsize", _PyCFunction_CAST(sys_getunicodeinternedsize), METH_FASTCALL|METH_KEYWORDS, sys_getunicodeinternedsize__doc__},
978 
979 static Py_ssize_t
980 sys_getunicodeinternedsize_impl(PyObject *module, int _only_immortal);
981 
982 static PyObject *
sys_getunicodeinternedsize(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)983 sys_getunicodeinternedsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
984 {
985     PyObject *return_value = NULL;
986     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
987 
988     #define NUM_KEYWORDS 1
989     static struct {
990         PyGC_Head _this_is_not_used;
991         PyObject_VAR_HEAD
992         PyObject *ob_item[NUM_KEYWORDS];
993     } _kwtuple = {
994         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
995         .ob_item = { &_Py_ID(_only_immortal), },
996     };
997     #undef NUM_KEYWORDS
998     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
999 
1000     #else  // !Py_BUILD_CORE
1001     #  define KWTUPLE NULL
1002     #endif  // !Py_BUILD_CORE
1003 
1004     static const char * const _keywords[] = {"_only_immortal", NULL};
1005     static _PyArg_Parser _parser = {
1006         .keywords = _keywords,
1007         .fname = "getunicodeinternedsize",
1008         .kwtuple = KWTUPLE,
1009     };
1010     #undef KWTUPLE
1011     PyObject *argsbuf[1];
1012     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1013     int _only_immortal = 0;
1014     Py_ssize_t _return_value;
1015 
1016     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
1017     if (!args) {
1018         goto exit;
1019     }
1020     if (!noptargs) {
1021         goto skip_optional_kwonly;
1022     }
1023     _only_immortal = PyObject_IsTrue(args[0]);
1024     if (_only_immortal < 0) {
1025         goto exit;
1026     }
1027 skip_optional_kwonly:
1028     _return_value = sys_getunicodeinternedsize_impl(module, _only_immortal);
1029     if ((_return_value == -1) && PyErr_Occurred()) {
1030         goto exit;
1031     }
1032     return_value = PyLong_FromSsize_t(_return_value);
1033 
1034 exit:
1035     return return_value;
1036 }
1037 
1038 PyDoc_STRVAR(sys__getframe__doc__,
1039 "_getframe($module, depth=0, /)\n"
1040 "--\n"
1041 "\n"
1042 "Return a frame object from the call stack.\n"
1043 "\n"
1044 "If optional integer depth is given, return the frame object that many\n"
1045 "calls below the top of the stack.  If that is deeper than the call\n"
1046 "stack, ValueError is raised.  The default for depth is zero, returning\n"
1047 "the frame at the top of the call stack.\n"
1048 "\n"
1049 "This function should be used for internal and specialized purposes\n"
1050 "only.");
1051 
1052 #define SYS__GETFRAME_METHODDEF    \
1053     {"_getframe", _PyCFunction_CAST(sys__getframe), METH_FASTCALL, sys__getframe__doc__},
1054 
1055 static PyObject *
1056 sys__getframe_impl(PyObject *module, int depth);
1057 
1058 static PyObject *
sys__getframe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1059 sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1060 {
1061     PyObject *return_value = NULL;
1062     int depth = 0;
1063 
1064     if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
1065         goto exit;
1066     }
1067     if (nargs < 1) {
1068         goto skip_optional;
1069     }
1070     depth = PyLong_AsInt(args[0]);
1071     if (depth == -1 && PyErr_Occurred()) {
1072         goto exit;
1073     }
1074 skip_optional:
1075     return_value = sys__getframe_impl(module, depth);
1076 
1077 exit:
1078     return return_value;
1079 }
1080 
1081 PyDoc_STRVAR(sys__current_frames__doc__,
1082 "_current_frames($module, /)\n"
1083 "--\n"
1084 "\n"
1085 "Return a dict mapping each thread\'s thread id to its current stack frame.\n"
1086 "\n"
1087 "This function should be used for specialized purposes only.");
1088 
1089 #define SYS__CURRENT_FRAMES_METHODDEF    \
1090     {"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__},
1091 
1092 static PyObject *
1093 sys__current_frames_impl(PyObject *module);
1094 
1095 static PyObject *
sys__current_frames(PyObject * module,PyObject * Py_UNUSED (ignored))1096 sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored))
1097 {
1098     return sys__current_frames_impl(module);
1099 }
1100 
1101 PyDoc_STRVAR(sys__current_exceptions__doc__,
1102 "_current_exceptions($module, /)\n"
1103 "--\n"
1104 "\n"
1105 "Return a dict mapping each thread\'s identifier to its current raised exception.\n"
1106 "\n"
1107 "This function should be used for specialized purposes only.");
1108 
1109 #define SYS__CURRENT_EXCEPTIONS_METHODDEF    \
1110     {"_current_exceptions", (PyCFunction)sys__current_exceptions, METH_NOARGS, sys__current_exceptions__doc__},
1111 
1112 static PyObject *
1113 sys__current_exceptions_impl(PyObject *module);
1114 
1115 static PyObject *
sys__current_exceptions(PyObject * module,PyObject * Py_UNUSED (ignored))1116 sys__current_exceptions(PyObject *module, PyObject *Py_UNUSED(ignored))
1117 {
1118     return sys__current_exceptions_impl(module);
1119 }
1120 
1121 PyDoc_STRVAR(sys_call_tracing__doc__,
1122 "call_tracing($module, func, args, /)\n"
1123 "--\n"
1124 "\n"
1125 "Call func(*args), while tracing is enabled.\n"
1126 "\n"
1127 "The tracing state is saved, and restored afterwards.  This is intended\n"
1128 "to be called from a debugger from a checkpoint, to recursively debug\n"
1129 "some other code.");
1130 
1131 #define SYS_CALL_TRACING_METHODDEF    \
1132     {"call_tracing", _PyCFunction_CAST(sys_call_tracing), METH_FASTCALL, sys_call_tracing__doc__},
1133 
1134 static PyObject *
1135 sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs);
1136 
1137 static PyObject *
sys_call_tracing(PyObject * module,PyObject * const * args,Py_ssize_t nargs)1138 sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1139 {
1140     PyObject *return_value = NULL;
1141     PyObject *func;
1142     PyObject *funcargs;
1143 
1144     if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
1145         goto exit;
1146     }
1147     func = args[0];
1148     if (!PyTuple_Check(args[1])) {
1149         _PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]);
1150         goto exit;
1151     }
1152     funcargs = args[1];
1153     return_value = sys_call_tracing_impl(module, func, funcargs);
1154 
1155 exit:
1156     return return_value;
1157 }
1158 
1159 PyDoc_STRVAR(sys__debugmallocstats__doc__,
1160 "_debugmallocstats($module, /)\n"
1161 "--\n"
1162 "\n"
1163 "Print summary info to stderr about the state of pymalloc\'s structures.\n"
1164 "\n"
1165 "In Py_DEBUG mode, also perform some expensive internal consistency\n"
1166 "checks.");
1167 
1168 #define SYS__DEBUGMALLOCSTATS_METHODDEF    \
1169     {"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__},
1170 
1171 static PyObject *
1172 sys__debugmallocstats_impl(PyObject *module);
1173 
1174 static PyObject *
sys__debugmallocstats(PyObject * module,PyObject * Py_UNUSED (ignored))1175 sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored))
1176 {
1177     return sys__debugmallocstats_impl(module);
1178 }
1179 
1180 PyDoc_STRVAR(sys__clear_type_cache__doc__,
1181 "_clear_type_cache($module, /)\n"
1182 "--\n"
1183 "\n"
1184 "Clear the internal type lookup cache.");
1185 
1186 #define SYS__CLEAR_TYPE_CACHE_METHODDEF    \
1187     {"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__},
1188 
1189 static PyObject *
1190 sys__clear_type_cache_impl(PyObject *module);
1191 
1192 static PyObject *
sys__clear_type_cache(PyObject * module,PyObject * Py_UNUSED (ignored))1193 sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored))
1194 {
1195     return sys__clear_type_cache_impl(module);
1196 }
1197 
1198 PyDoc_STRVAR(sys__clear_internal_caches__doc__,
1199 "_clear_internal_caches($module, /)\n"
1200 "--\n"
1201 "\n"
1202 "Clear all internal performance-related caches.");
1203 
1204 #define SYS__CLEAR_INTERNAL_CACHES_METHODDEF    \
1205     {"_clear_internal_caches", (PyCFunction)sys__clear_internal_caches, METH_NOARGS, sys__clear_internal_caches__doc__},
1206 
1207 static PyObject *
1208 sys__clear_internal_caches_impl(PyObject *module);
1209 
1210 static PyObject *
sys__clear_internal_caches(PyObject * module,PyObject * Py_UNUSED (ignored))1211 sys__clear_internal_caches(PyObject *module, PyObject *Py_UNUSED(ignored))
1212 {
1213     return sys__clear_internal_caches_impl(module);
1214 }
1215 
1216 PyDoc_STRVAR(sys_is_finalizing__doc__,
1217 "is_finalizing($module, /)\n"
1218 "--\n"
1219 "\n"
1220 "Return True if Python is exiting.");
1221 
1222 #define SYS_IS_FINALIZING_METHODDEF    \
1223     {"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__},
1224 
1225 static PyObject *
1226 sys_is_finalizing_impl(PyObject *module);
1227 
1228 static PyObject *
sys_is_finalizing(PyObject * module,PyObject * Py_UNUSED (ignored))1229 sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
1230 {
1231     return sys_is_finalizing_impl(module);
1232 }
1233 
1234 #if defined(Py_STATS)
1235 
1236 PyDoc_STRVAR(sys__stats_on__doc__,
1237 "_stats_on($module, /)\n"
1238 "--\n"
1239 "\n"
1240 "Turns on stats gathering (stats gathering is off by default).");
1241 
1242 #define SYS__STATS_ON_METHODDEF    \
1243     {"_stats_on", (PyCFunction)sys__stats_on, METH_NOARGS, sys__stats_on__doc__},
1244 
1245 static PyObject *
1246 sys__stats_on_impl(PyObject *module);
1247 
1248 static PyObject *
sys__stats_on(PyObject * module,PyObject * Py_UNUSED (ignored))1249 sys__stats_on(PyObject *module, PyObject *Py_UNUSED(ignored))
1250 {
1251     return sys__stats_on_impl(module);
1252 }
1253 
1254 #endif /* defined(Py_STATS) */
1255 
1256 #if defined(Py_STATS)
1257 
1258 PyDoc_STRVAR(sys__stats_off__doc__,
1259 "_stats_off($module, /)\n"
1260 "--\n"
1261 "\n"
1262 "Turns off stats gathering (stats gathering is off by default).");
1263 
1264 #define SYS__STATS_OFF_METHODDEF    \
1265     {"_stats_off", (PyCFunction)sys__stats_off, METH_NOARGS, sys__stats_off__doc__},
1266 
1267 static PyObject *
1268 sys__stats_off_impl(PyObject *module);
1269 
1270 static PyObject *
sys__stats_off(PyObject * module,PyObject * Py_UNUSED (ignored))1271 sys__stats_off(PyObject *module, PyObject *Py_UNUSED(ignored))
1272 {
1273     return sys__stats_off_impl(module);
1274 }
1275 
1276 #endif /* defined(Py_STATS) */
1277 
1278 #if defined(Py_STATS)
1279 
1280 PyDoc_STRVAR(sys__stats_clear__doc__,
1281 "_stats_clear($module, /)\n"
1282 "--\n"
1283 "\n"
1284 "Clears the stats.");
1285 
1286 #define SYS__STATS_CLEAR_METHODDEF    \
1287     {"_stats_clear", (PyCFunction)sys__stats_clear, METH_NOARGS, sys__stats_clear__doc__},
1288 
1289 static PyObject *
1290 sys__stats_clear_impl(PyObject *module);
1291 
1292 static PyObject *
sys__stats_clear(PyObject * module,PyObject * Py_UNUSED (ignored))1293 sys__stats_clear(PyObject *module, PyObject *Py_UNUSED(ignored))
1294 {
1295     return sys__stats_clear_impl(module);
1296 }
1297 
1298 #endif /* defined(Py_STATS) */
1299 
1300 #if defined(Py_STATS)
1301 
1302 PyDoc_STRVAR(sys__stats_dump__doc__,
1303 "_stats_dump($module, /)\n"
1304 "--\n"
1305 "\n"
1306 "Dump stats to file, and clears the stats.\n"
1307 "\n"
1308 "Return False if no statistics were not dumped because stats gathering was off.");
1309 
1310 #define SYS__STATS_DUMP_METHODDEF    \
1311     {"_stats_dump", (PyCFunction)sys__stats_dump, METH_NOARGS, sys__stats_dump__doc__},
1312 
1313 static int
1314 sys__stats_dump_impl(PyObject *module);
1315 
1316 static PyObject *
sys__stats_dump(PyObject * module,PyObject * Py_UNUSED (ignored))1317 sys__stats_dump(PyObject *module, PyObject *Py_UNUSED(ignored))
1318 {
1319     PyObject *return_value = NULL;
1320     int _return_value;
1321 
1322     _return_value = sys__stats_dump_impl(module);
1323     if ((_return_value == -1) && PyErr_Occurred()) {
1324         goto exit;
1325     }
1326     return_value = PyBool_FromLong((long)_return_value);
1327 
1328 exit:
1329     return return_value;
1330 }
1331 
1332 #endif /* defined(Py_STATS) */
1333 
1334 #if defined(ANDROID_API_LEVEL)
1335 
1336 PyDoc_STRVAR(sys_getandroidapilevel__doc__,
1337 "getandroidapilevel($module, /)\n"
1338 "--\n"
1339 "\n"
1340 "Return the build time API version of Android as an integer.");
1341 
1342 #define SYS_GETANDROIDAPILEVEL_METHODDEF    \
1343     {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__},
1344 
1345 static PyObject *
1346 sys_getandroidapilevel_impl(PyObject *module);
1347 
1348 static PyObject *
sys_getandroidapilevel(PyObject * module,PyObject * Py_UNUSED (ignored))1349 sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
1350 {
1351     return sys_getandroidapilevel_impl(module);
1352 }
1353 
1354 #endif /* defined(ANDROID_API_LEVEL) */
1355 
1356 PyDoc_STRVAR(sys_activate_stack_trampoline__doc__,
1357 "activate_stack_trampoline($module, backend, /)\n"
1358 "--\n"
1359 "\n"
1360 "Activate stack profiler trampoline *backend*.");
1361 
1362 #define SYS_ACTIVATE_STACK_TRAMPOLINE_METHODDEF    \
1363     {"activate_stack_trampoline", (PyCFunction)sys_activate_stack_trampoline, METH_O, sys_activate_stack_trampoline__doc__},
1364 
1365 static PyObject *
1366 sys_activate_stack_trampoline_impl(PyObject *module, const char *backend);
1367 
1368 static PyObject *
sys_activate_stack_trampoline(PyObject * module,PyObject * arg)1369 sys_activate_stack_trampoline(PyObject *module, PyObject *arg)
1370 {
1371     PyObject *return_value = NULL;
1372     const char *backend;
1373 
1374     if (!PyUnicode_Check(arg)) {
1375         _PyArg_BadArgument("activate_stack_trampoline", "argument", "str", arg);
1376         goto exit;
1377     }
1378     Py_ssize_t backend_length;
1379     backend = PyUnicode_AsUTF8AndSize(arg, &backend_length);
1380     if (backend == NULL) {
1381         goto exit;
1382     }
1383     if (strlen(backend) != (size_t)backend_length) {
1384         PyErr_SetString(PyExc_ValueError, "embedded null character");
1385         goto exit;
1386     }
1387     return_value = sys_activate_stack_trampoline_impl(module, backend);
1388 
1389 exit:
1390     return return_value;
1391 }
1392 
1393 PyDoc_STRVAR(sys_deactivate_stack_trampoline__doc__,
1394 "deactivate_stack_trampoline($module, /)\n"
1395 "--\n"
1396 "\n"
1397 "Deactivate the current stack profiler trampoline backend.\n"
1398 "\n"
1399 "If no stack profiler is activated, this function has no effect.");
1400 
1401 #define SYS_DEACTIVATE_STACK_TRAMPOLINE_METHODDEF    \
1402     {"deactivate_stack_trampoline", (PyCFunction)sys_deactivate_stack_trampoline, METH_NOARGS, sys_deactivate_stack_trampoline__doc__},
1403 
1404 static PyObject *
1405 sys_deactivate_stack_trampoline_impl(PyObject *module);
1406 
1407 static PyObject *
sys_deactivate_stack_trampoline(PyObject * module,PyObject * Py_UNUSED (ignored))1408 sys_deactivate_stack_trampoline(PyObject *module, PyObject *Py_UNUSED(ignored))
1409 {
1410     return sys_deactivate_stack_trampoline_impl(module);
1411 }
1412 
1413 PyDoc_STRVAR(sys_is_stack_trampoline_active__doc__,
1414 "is_stack_trampoline_active($module, /)\n"
1415 "--\n"
1416 "\n"
1417 "Return *True* if a stack profiler trampoline is active.");
1418 
1419 #define SYS_IS_STACK_TRAMPOLINE_ACTIVE_METHODDEF    \
1420     {"is_stack_trampoline_active", (PyCFunction)sys_is_stack_trampoline_active, METH_NOARGS, sys_is_stack_trampoline_active__doc__},
1421 
1422 static PyObject *
1423 sys_is_stack_trampoline_active_impl(PyObject *module);
1424 
1425 static PyObject *
sys_is_stack_trampoline_active(PyObject * module,PyObject * Py_UNUSED (ignored))1426 sys_is_stack_trampoline_active(PyObject *module, PyObject *Py_UNUSED(ignored))
1427 {
1428     return sys_is_stack_trampoline_active_impl(module);
1429 }
1430 
1431 PyDoc_STRVAR(sys__getframemodulename__doc__,
1432 "_getframemodulename($module, /, depth=0)\n"
1433 "--\n"
1434 "\n"
1435 "Return the name of the module for a calling frame.\n"
1436 "\n"
1437 "The default depth returns the module containing the call to this API.\n"
1438 "A more typical use in a library will pass a depth of 1 to get the user\'s\n"
1439 "module rather than the library module.\n"
1440 "\n"
1441 "If no frame, module, or name can be found, returns None.");
1442 
1443 #define SYS__GETFRAMEMODULENAME_METHODDEF    \
1444     {"_getframemodulename", _PyCFunction_CAST(sys__getframemodulename), METH_FASTCALL|METH_KEYWORDS, sys__getframemodulename__doc__},
1445 
1446 static PyObject *
1447 sys__getframemodulename_impl(PyObject *module, int depth);
1448 
1449 static PyObject *
sys__getframemodulename(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)1450 sys__getframemodulename(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1451 {
1452     PyObject *return_value = NULL;
1453     #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1454 
1455     #define NUM_KEYWORDS 1
1456     static struct {
1457         PyGC_Head _this_is_not_used;
1458         PyObject_VAR_HEAD
1459         PyObject *ob_item[NUM_KEYWORDS];
1460     } _kwtuple = {
1461         .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1462         .ob_item = { &_Py_ID(depth), },
1463     };
1464     #undef NUM_KEYWORDS
1465     #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1466 
1467     #else  // !Py_BUILD_CORE
1468     #  define KWTUPLE NULL
1469     #endif  // !Py_BUILD_CORE
1470 
1471     static const char * const _keywords[] = {"depth", NULL};
1472     static _PyArg_Parser _parser = {
1473         .keywords = _keywords,
1474         .fname = "_getframemodulename",
1475         .kwtuple = KWTUPLE,
1476     };
1477     #undef KWTUPLE
1478     PyObject *argsbuf[1];
1479     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1480     int depth = 0;
1481 
1482     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
1483     if (!args) {
1484         goto exit;
1485     }
1486     if (!noptargs) {
1487         goto skip_optional_pos;
1488     }
1489     depth = PyLong_AsInt(args[0]);
1490     if (depth == -1 && PyErr_Occurred()) {
1491         goto exit;
1492     }
1493 skip_optional_pos:
1494     return_value = sys__getframemodulename_impl(module, depth);
1495 
1496 exit:
1497     return return_value;
1498 }
1499 
1500 PyDoc_STRVAR(sys__get_cpu_count_config__doc__,
1501 "_get_cpu_count_config($module, /)\n"
1502 "--\n"
1503 "\n"
1504 "Private function for getting PyConfig.cpu_count");
1505 
1506 #define SYS__GET_CPU_COUNT_CONFIG_METHODDEF    \
1507     {"_get_cpu_count_config", (PyCFunction)sys__get_cpu_count_config, METH_NOARGS, sys__get_cpu_count_config__doc__},
1508 
1509 static int
1510 sys__get_cpu_count_config_impl(PyObject *module);
1511 
1512 static PyObject *
sys__get_cpu_count_config(PyObject * module,PyObject * Py_UNUSED (ignored))1513 sys__get_cpu_count_config(PyObject *module, PyObject *Py_UNUSED(ignored))
1514 {
1515     PyObject *return_value = NULL;
1516     int _return_value;
1517 
1518     _return_value = sys__get_cpu_count_config_impl(module);
1519     if ((_return_value == -1) && PyErr_Occurred()) {
1520         goto exit;
1521     }
1522     return_value = PyLong_FromLong((long)_return_value);
1523 
1524 exit:
1525     return return_value;
1526 }
1527 
1528 PyDoc_STRVAR(sys__baserepl__doc__,
1529 "_baserepl($module, /)\n"
1530 "--\n"
1531 "\n"
1532 "Private function for getting the base REPL");
1533 
1534 #define SYS__BASEREPL_METHODDEF    \
1535     {"_baserepl", (PyCFunction)sys__baserepl, METH_NOARGS, sys__baserepl__doc__},
1536 
1537 static PyObject *
1538 sys__baserepl_impl(PyObject *module);
1539 
1540 static PyObject *
sys__baserepl(PyObject * module,PyObject * Py_UNUSED (ignored))1541 sys__baserepl(PyObject *module, PyObject *Py_UNUSED(ignored))
1542 {
1543     return sys__baserepl_impl(module);
1544 }
1545 
1546 PyDoc_STRVAR(sys__is_gil_enabled__doc__,
1547 "_is_gil_enabled($module, /)\n"
1548 "--\n"
1549 "\n"
1550 "Return True if the GIL is currently enabled and False otherwise.");
1551 
1552 #define SYS__IS_GIL_ENABLED_METHODDEF    \
1553     {"_is_gil_enabled", (PyCFunction)sys__is_gil_enabled, METH_NOARGS, sys__is_gil_enabled__doc__},
1554 
1555 static int
1556 sys__is_gil_enabled_impl(PyObject *module);
1557 
1558 static PyObject *
sys__is_gil_enabled(PyObject * module,PyObject * Py_UNUSED (ignored))1559 sys__is_gil_enabled(PyObject *module, PyObject *Py_UNUSED(ignored))
1560 {
1561     PyObject *return_value = NULL;
1562     int _return_value;
1563 
1564     _return_value = sys__is_gil_enabled_impl(module);
1565     if ((_return_value == -1) && PyErr_Occurred()) {
1566         goto exit;
1567     }
1568     return_value = PyBool_FromLong((long)_return_value);
1569 
1570 exit:
1571     return return_value;
1572 }
1573 
1574 #ifndef SYS_GETWINDOWSVERSION_METHODDEF
1575     #define SYS_GETWINDOWSVERSION_METHODDEF
1576 #endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
1577 
1578 #ifndef SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1579     #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1580 #endif /* !defined(SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF) */
1581 
1582 #ifndef SYS_SETDLOPENFLAGS_METHODDEF
1583     #define SYS_SETDLOPENFLAGS_METHODDEF
1584 #endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */
1585 
1586 #ifndef SYS_GETDLOPENFLAGS_METHODDEF
1587     #define SYS_GETDLOPENFLAGS_METHODDEF
1588 #endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */
1589 
1590 #ifndef SYS_MDEBUG_METHODDEF
1591     #define SYS_MDEBUG_METHODDEF
1592 #endif /* !defined(SYS_MDEBUG_METHODDEF) */
1593 
1594 #ifndef SYS_GETTOTALREFCOUNT_METHODDEF
1595     #define SYS_GETTOTALREFCOUNT_METHODDEF
1596 #endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
1597 
1598 #ifndef SYS__STATS_ON_METHODDEF
1599     #define SYS__STATS_ON_METHODDEF
1600 #endif /* !defined(SYS__STATS_ON_METHODDEF) */
1601 
1602 #ifndef SYS__STATS_OFF_METHODDEF
1603     #define SYS__STATS_OFF_METHODDEF
1604 #endif /* !defined(SYS__STATS_OFF_METHODDEF) */
1605 
1606 #ifndef SYS__STATS_CLEAR_METHODDEF
1607     #define SYS__STATS_CLEAR_METHODDEF
1608 #endif /* !defined(SYS__STATS_CLEAR_METHODDEF) */
1609 
1610 #ifndef SYS__STATS_DUMP_METHODDEF
1611     #define SYS__STATS_DUMP_METHODDEF
1612 #endif /* !defined(SYS__STATS_DUMP_METHODDEF) */
1613 
1614 #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
1615     #define SYS_GETANDROIDAPILEVEL_METHODDEF
1616 #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
1617 /*[clinic end generated code: output=9cc9069aef1482bc input=a9049054013a1b77]*/
1618