1/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(sys_addaudithook__doc__,
6"addaudithook($module, /, hook)\n"
7"--\n"
8"\n"
9"Adds a new audit hook callback.");
10
11#define SYS_ADDAUDITHOOK_METHODDEF \
12 {"addaudithook", (PyCFunction)(void(*)(void))sys_addaudithook, METH_FASTCALL|METH_KEYWORDS, sys_addaudithook__doc__},
13
14static PyObject *
15sys_addaudithook_impl(PyObject *module, PyObject *hook);
16
17static PyObject *
18sys_addaudithook(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
19{
20 PyObject *return_value = NULL;
21 static const char * const _keywords[] = {"hook", NULL};
22 static _PyArg_Parser _parser = {NULL, _keywords, "addaudithook", 0};
23 PyObject *argsbuf[1];
24 PyObject *hook;
25
26 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
27 if (!args) {
28 goto exit;
29 }
30 hook = args[0];
31 return_value = sys_addaudithook_impl(module, hook);
32
33exit:
34 return return_value;
35}
36
37PyDoc_STRVAR(sys_displayhook__doc__,
38"displayhook($module, object, /)\n"
39"--\n"
40"\n"
41"Print an object to sys.stdout and also save it in builtins._");
42
43#define SYS_DISPLAYHOOK_METHODDEF \
44 {"displayhook", (PyCFunction)sys_displayhook, METH_O, sys_displayhook__doc__},
45
46PyDoc_STRVAR(sys_excepthook__doc__,
47"excepthook($module, exctype, value, traceback, /)\n"
48"--\n"
49"\n"
50"Handle an exception by displaying it with a traceback on sys.stderr.");
51
52#define SYS_EXCEPTHOOK_METHODDEF \
53 {"excepthook", (PyCFunction)(void(*)(void))sys_excepthook, METH_FASTCALL, sys_excepthook__doc__},
54
55static PyObject *
56sys_excepthook_impl(PyObject *module, PyObject *exctype, PyObject *value,
57 PyObject *traceback);
58
59static PyObject *
60sys_excepthook(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
61{
62 PyObject *return_value = NULL;
63 PyObject *exctype;
64 PyObject *value;
65 PyObject *traceback;
66
67 if (!_PyArg_CheckPositional("excepthook", nargs, 3, 3)) {
68 goto exit;
69 }
70 exctype = args[0];
71 value = args[1];
72 traceback = args[2];
73 return_value = sys_excepthook_impl(module, exctype, value, traceback);
74
75exit:
76 return return_value;
77}
78
79PyDoc_STRVAR(sys_exc_info__doc__,
80"exc_info($module, /)\n"
81"--\n"
82"\n"
83"Return current exception information: (type, value, traceback).\n"
84"\n"
85"Return information about the most recent exception caught by an except\n"
86"clause in the current stack frame or in an older stack frame.");
87
88#define SYS_EXC_INFO_METHODDEF \
89 {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, sys_exc_info__doc__},
90
91static PyObject *
92sys_exc_info_impl(PyObject *module);
93
94static PyObject *
95sys_exc_info(PyObject *module, PyObject *Py_UNUSED(ignored))
96{
97 return sys_exc_info_impl(module);
98}
99
100PyDoc_STRVAR(sys_unraisablehook__doc__,
101"unraisablehook($module, unraisable, /)\n"
102"--\n"
103"\n"
104"Handle an unraisable exception.\n"
105"\n"
106"The unraisable argument has the following attributes:\n"
107"\n"
108"* exc_type: Exception type.\n"
109"* exc_value: Exception value, can be None.\n"
110"* exc_traceback: Exception traceback, can be None.\n"
111"* err_msg: Error message, can be None.\n"
112"* object: Object causing the exception, can be None.");
113
114#define SYS_UNRAISABLEHOOK_METHODDEF \
115 {"unraisablehook", (PyCFunction)sys_unraisablehook, METH_O, sys_unraisablehook__doc__},
116
117PyDoc_STRVAR(sys_exit__doc__,
118"exit($module, status=None, /)\n"
119"--\n"
120"\n"
121"Exit the interpreter by raising SystemExit(status).\n"
122"\n"
123"If the status is omitted or None, it defaults to zero (i.e., success).\n"
124"If the status is an integer, it will be used as the system exit status.\n"
125"If it is another kind of object, it will be printed and the system\n"
126"exit status will be one (i.e., failure).");
127
128#define SYS_EXIT_METHODDEF \
129 {"exit", (PyCFunction)(void(*)(void))sys_exit, METH_FASTCALL, sys_exit__doc__},
130
131static PyObject *
132sys_exit_impl(PyObject *module, PyObject *status);
133
134static PyObject *
135sys_exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
136{
137 PyObject *return_value = NULL;
138 PyObject *status = Py_None;
139
140 if (!_PyArg_CheckPositional("exit", nargs, 0, 1)) {
141 goto exit;
142 }
143 if (nargs < 1) {
144 goto skip_optional;
145 }
146 status = args[0];
147skip_optional:
148 return_value = sys_exit_impl(module, status);
149
150exit:
151 return return_value;
152}
153
154PyDoc_STRVAR(sys_getdefaultencoding__doc__,
155"getdefaultencoding($module, /)\n"
156"--\n"
157"\n"
158"Return the current default encoding used by the Unicode implementation.");
159
160#define SYS_GETDEFAULTENCODING_METHODDEF \
161 {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, sys_getdefaultencoding__doc__},
162
163static PyObject *
164sys_getdefaultencoding_impl(PyObject *module);
165
166static PyObject *
167sys_getdefaultencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
168{
169 return sys_getdefaultencoding_impl(module);
170}
171
172PyDoc_STRVAR(sys_getfilesystemencoding__doc__,
173"getfilesystemencoding($module, /)\n"
174"--\n"
175"\n"
176"Return the encoding used to convert Unicode filenames to OS filenames.");
177
178#define SYS_GETFILESYSTEMENCODING_METHODDEF \
179 {"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding, METH_NOARGS, sys_getfilesystemencoding__doc__},
180
181static PyObject *
182sys_getfilesystemencoding_impl(PyObject *module);
183
184static PyObject *
185sys_getfilesystemencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
186{
187 return sys_getfilesystemencoding_impl(module);
188}
189
190PyDoc_STRVAR(sys_getfilesystemencodeerrors__doc__,
191"getfilesystemencodeerrors($module, /)\n"
192"--\n"
193"\n"
194"Return the error mode used Unicode to OS filename conversion.");
195
196#define SYS_GETFILESYSTEMENCODEERRORS_METHODDEF \
197 {"getfilesystemencodeerrors", (PyCFunction)sys_getfilesystemencodeerrors, METH_NOARGS, sys_getfilesystemencodeerrors__doc__},
198
199static PyObject *
200sys_getfilesystemencodeerrors_impl(PyObject *module);
201
202static PyObject *
203sys_getfilesystemencodeerrors(PyObject *module, PyObject *Py_UNUSED(ignored))
204{
205 return sys_getfilesystemencodeerrors_impl(module);
206}
207
208PyDoc_STRVAR(sys_intern__doc__,
209"intern($module, string, /)\n"
210"--\n"
211"\n"
212"``Intern\'\' the given string.\n"
213"\n"
214"This enters the string in the (global) table of interned strings whose\n"
215"purpose is to speed up dictionary lookups. Return the string itself or\n"
216"the previously interned string object with the same value.");
217
218#define SYS_INTERN_METHODDEF \
219 {"intern", (PyCFunction)sys_intern, METH_O, sys_intern__doc__},
220
221static PyObject *
222sys_intern_impl(PyObject *module, PyObject *s);
223
224static PyObject *
225sys_intern(PyObject *module, PyObject *arg)
226{
227 PyObject *return_value = NULL;
228 PyObject *s;
229
230 if (!PyUnicode_Check(arg)) {
231 _PyArg_BadArgument("intern", "argument", "str", arg);
232 goto exit;
233 }
234 if (PyUnicode_READY(arg) == -1) {
235 goto exit;
236 }
237 s = arg;
238 return_value = sys_intern_impl(module, s);
239
240exit:
241 return return_value;
242}
243
244PyDoc_STRVAR(sys_gettrace__doc__,
245"gettrace($module, /)\n"
246"--\n"
247"\n"
248"Return the global debug tracing function set with sys.settrace.\n"
249"\n"
250"See the debugger chapter in the library manual.");
251
252#define SYS_GETTRACE_METHODDEF \
253 {"gettrace", (PyCFunction)sys_gettrace, METH_NOARGS, sys_gettrace__doc__},
254
255static PyObject *
256sys_gettrace_impl(PyObject *module);
257
258static PyObject *
259sys_gettrace(PyObject *module, PyObject *Py_UNUSED(ignored))
260{
261 return sys_gettrace_impl(module);
262}
263
264PyDoc_STRVAR(sys_getprofile__doc__,
265"getprofile($module, /)\n"
266"--\n"
267"\n"
268"Return the profiling function set with sys.setprofile.\n"
269"\n"
270"See the profiler chapter in the library manual.");
271
272#define SYS_GETPROFILE_METHODDEF \
273 {"getprofile", (PyCFunction)sys_getprofile, METH_NOARGS, sys_getprofile__doc__},
274
275static PyObject *
276sys_getprofile_impl(PyObject *module);
277
278static PyObject *
279sys_getprofile(PyObject *module, PyObject *Py_UNUSED(ignored))
280{
281 return sys_getprofile_impl(module);
282}
283
284PyDoc_STRVAR(sys_setswitchinterval__doc__,
285"setswitchinterval($module, interval, /)\n"
286"--\n"
287"\n"
288"Set the ideal thread switching delay inside the Python interpreter.\n"
289"\n"
290"The actual frequency of switching threads can be lower if the\n"
291"interpreter executes long sequences of uninterruptible code\n"
292"(this is implementation-specific and workload-dependent).\n"
293"\n"
294"The parameter must represent the desired switching delay in seconds\n"
295"A typical value is 0.005 (5 milliseconds).");
296
297#define SYS_SETSWITCHINTERVAL_METHODDEF \
298 {"setswitchinterval", (PyCFunction)sys_setswitchinterval, METH_O, sys_setswitchinterval__doc__},
299
300static PyObject *
301sys_setswitchinterval_impl(PyObject *module, double interval);
302
303static PyObject *
304sys_setswitchinterval(PyObject *module, PyObject *arg)
305{
306 PyObject *return_value = NULL;
307 double interval;
308
309 if (PyFloat_CheckExact(arg)) {
310 interval = PyFloat_AS_DOUBLE(arg);
311 }
312 else
313 {
314 interval = PyFloat_AsDouble(arg);
315 if (interval == -1.0 && PyErr_Occurred()) {
316 goto exit;
317 }
318 }
319 return_value = sys_setswitchinterval_impl(module, interval);
320
321exit:
322 return return_value;
323}
324
325PyDoc_STRVAR(sys_getswitchinterval__doc__,
326"getswitchinterval($module, /)\n"
327"--\n"
328"\n"
329"Return the current thread switch interval; see sys.setswitchinterval().");
330
331#define SYS_GETSWITCHINTERVAL_METHODDEF \
332 {"getswitchinterval", (PyCFunction)sys_getswitchinterval, METH_NOARGS, sys_getswitchinterval__doc__},
333
334static double
335sys_getswitchinterval_impl(PyObject *module);
336
337static PyObject *
338sys_getswitchinterval(PyObject *module, PyObject *Py_UNUSED(ignored))
339{
340 PyObject *return_value = NULL;
341 double _return_value;
342
343 _return_value = sys_getswitchinterval_impl(module);
344 if ((_return_value == -1.0) && PyErr_Occurred()) {
345 goto exit;
346 }
347 return_value = PyFloat_FromDouble(_return_value);
348
349exit:
350 return return_value;
351}
352
353PyDoc_STRVAR(sys_setrecursionlimit__doc__,
354"setrecursionlimit($module, limit, /)\n"
355"--\n"
356"\n"
357"Set the maximum depth of the Python interpreter stack to n.\n"
358"\n"
359"This limit prevents infinite recursion from causing an overflow of the C\n"
360"stack and crashing Python. The highest possible limit is platform-\n"
361"dependent.");
362
363#define SYS_SETRECURSIONLIMIT_METHODDEF \
364 {"setrecursionlimit", (PyCFunction)sys_setrecursionlimit, METH_O, sys_setrecursionlimit__doc__},
365
366static PyObject *
367sys_setrecursionlimit_impl(PyObject *module, int new_limit);
368
369static PyObject *
370sys_setrecursionlimit(PyObject *module, PyObject *arg)
371{
372 PyObject *return_value = NULL;
373 int new_limit;
374
375 new_limit = _PyLong_AsInt(arg);
376 if (new_limit == -1 && PyErr_Occurred()) {
377 goto exit;
378 }
379 return_value = sys_setrecursionlimit_impl(module, new_limit);
380
381exit:
382 return return_value;
383}
384
385PyDoc_STRVAR(sys_set_coroutine_origin_tracking_depth__doc__,
386"set_coroutine_origin_tracking_depth($module, /, depth)\n"
387"--\n"
388"\n"
389"Enable or disable origin tracking for coroutine objects in this thread.\n"
390"\n"
391"Coroutine objects will track \'depth\' frames of traceback information\n"
392"about where they came from, available in their cr_origin attribute.\n"
393"\n"
394"Set a depth of 0 to disable.");
395
396#define SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
397 {"set_coroutine_origin_tracking_depth", (PyCFunction)(void(*)(void))sys_set_coroutine_origin_tracking_depth, METH_FASTCALL|METH_KEYWORDS, sys_set_coroutine_origin_tracking_depth__doc__},
398
399static PyObject *
400sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth);
401
402static PyObject *
403sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
404{
405 PyObject *return_value = NULL;
406 static const char * const _keywords[] = {"depth", NULL};
407 static _PyArg_Parser _parser = {NULL, _keywords, "set_coroutine_origin_tracking_depth", 0};
408 PyObject *argsbuf[1];
409 int depth;
410
411 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
412 if (!args) {
413 goto exit;
414 }
415 depth = _PyLong_AsInt(args[0]);
416 if (depth == -1 && PyErr_Occurred()) {
417 goto exit;
418 }
419 return_value = sys_set_coroutine_origin_tracking_depth_impl(module, depth);
420
421exit:
422 return return_value;
423}
424
425PyDoc_STRVAR(sys_get_coroutine_origin_tracking_depth__doc__,
426"get_coroutine_origin_tracking_depth($module, /)\n"
427"--\n"
428"\n"
429"Check status of origin tracking for coroutine objects in this thread.");
430
431#define SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
432 {"get_coroutine_origin_tracking_depth", (PyCFunction)sys_get_coroutine_origin_tracking_depth, METH_NOARGS, sys_get_coroutine_origin_tracking_depth__doc__},
433
434static int
435sys_get_coroutine_origin_tracking_depth_impl(PyObject *module);
436
437static PyObject *
438sys_get_coroutine_origin_tracking_depth(PyObject *module, PyObject *Py_UNUSED(ignored))
439{
440 PyObject *return_value = NULL;
441 int _return_value;
442
443 _return_value = sys_get_coroutine_origin_tracking_depth_impl(module);
444 if ((_return_value == -1) && PyErr_Occurred()) {
445 goto exit;
446 }
447 return_value = PyLong_FromLong((long)_return_value);
448
449exit:
450 return return_value;
451}
452
453PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__,
454"get_asyncgen_hooks($module, /)\n"
455"--\n"
456"\n"
457"Return the installed asynchronous generators hooks.\n"
458"\n"
459"This returns a namedtuple of the form (firstiter, finalizer).");
460
461#define SYS_GET_ASYNCGEN_HOOKS_METHODDEF \
462 {"get_asyncgen_hooks", (PyCFunction)sys_get_asyncgen_hooks, METH_NOARGS, sys_get_asyncgen_hooks__doc__},
463
464static PyObject *
465sys_get_asyncgen_hooks_impl(PyObject *module);
466
467static PyObject *
468sys_get_asyncgen_hooks(PyObject *module, PyObject *Py_UNUSED(ignored))
469{
470 return sys_get_asyncgen_hooks_impl(module);
471}
472
473PyDoc_STRVAR(sys_getrecursionlimit__doc__,
474"getrecursionlimit($module, /)\n"
475"--\n"
476"\n"
477"Return the current value of the recursion limit.\n"
478"\n"
479"The recursion limit is the maximum depth of the Python interpreter\n"
480"stack. This limit prevents infinite recursion from causing an overflow\n"
481"of the C stack and crashing Python.");
482
483#define SYS_GETRECURSIONLIMIT_METHODDEF \
484 {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, sys_getrecursionlimit__doc__},
485
486static PyObject *
487sys_getrecursionlimit_impl(PyObject *module);
488
489static PyObject *
490sys_getrecursionlimit(PyObject *module, PyObject *Py_UNUSED(ignored))
491{
492 return sys_getrecursionlimit_impl(module);
493}
494
495#if defined(MS_WINDOWS)
496
497PyDoc_STRVAR(sys_getwindowsversion__doc__,
498"getwindowsversion($module, /)\n"
499"--\n"
500"\n"
501"Return info about the running version of Windows as a named tuple.\n"
502"\n"
503"The members are named: major, minor, build, platform, service_pack,\n"
504"service_pack_major, service_pack_minor, suite_mask, product_type and\n"
505"platform_version. For backward compatibility, only the first 5 items\n"
506"are available by indexing. All elements are numbers, except\n"
507"service_pack and platform_type which are strings, and platform_version\n"
508"which is a 3-tuple. Platform is always 2. Product_type may be 1 for a\n"
509"workstation, 2 for a domain controller, 3 for a server.\n"
510"Platform_version is a 3-tuple containing a version number that is\n"
511"intended for identifying the OS rather than feature detection.");
512
513#define SYS_GETWINDOWSVERSION_METHODDEF \
514 {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, sys_getwindowsversion__doc__},
515
516static PyObject *
517sys_getwindowsversion_impl(PyObject *module);
518
519static PyObject *
520sys_getwindowsversion(PyObject *module, PyObject *Py_UNUSED(ignored))
521{
522 return sys_getwindowsversion_impl(module);
523}
524
525#endif /* defined(MS_WINDOWS) */
526
527#if defined(MS_WINDOWS)
528
529PyDoc_STRVAR(sys__enablelegacywindowsfsencoding__doc__,
530"_enablelegacywindowsfsencoding($module, /)\n"
531"--\n"
532"\n"
533"Changes the default filesystem encoding to mbcs:replace.\n"
534"\n"
535"This is done for consistency with earlier versions of Python. See PEP\n"
536"529 for more information.\n"
537"\n"
538"This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING\n"
539"environment variable before launching Python.");
540
541#define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF \
542 {"_enablelegacywindowsfsencoding", (PyCFunction)sys__enablelegacywindowsfsencoding, METH_NOARGS, sys__enablelegacywindowsfsencoding__doc__},
543
544static PyObject *
545sys__enablelegacywindowsfsencoding_impl(PyObject *module);
546
547static PyObject *
548sys__enablelegacywindowsfsencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
549{
550 return sys__enablelegacywindowsfsencoding_impl(module);
551}
552
553#endif /* defined(MS_WINDOWS) */
554
555#if defined(HAVE_DLOPEN)
556
557PyDoc_STRVAR(sys_setdlopenflags__doc__,
558"setdlopenflags($module, flags, /)\n"
559"--\n"
560"\n"
561"Set the flags used by the interpreter for dlopen calls.\n"
562"\n"
563"This is used, for example, when the interpreter loads extension\n"
564"modules. Among other things, this will enable a lazy resolving of\n"
565"symbols when importing a module, if called as sys.setdlopenflags(0).\n"
566"To share symbols across extension modules, call as\n"
567"sys.setdlopenflags(os.RTLD_GLOBAL). Symbolic names for the flag\n"
568"modules can be found in the os module (RTLD_xxx constants, e.g.\n"
569"os.RTLD_LAZY).");
570
571#define SYS_SETDLOPENFLAGS_METHODDEF \
572 {"setdlopenflags", (PyCFunction)sys_setdlopenflags, METH_O, sys_setdlopenflags__doc__},
573
574static PyObject *
575sys_setdlopenflags_impl(PyObject *module, int new_val);
576
577static PyObject *
578sys_setdlopenflags(PyObject *module, PyObject *arg)
579{
580 PyObject *return_value = NULL;
581 int new_val;
582
583 new_val = _PyLong_AsInt(arg);
584 if (new_val == -1 && PyErr_Occurred()) {
585 goto exit;
586 }
587 return_value = sys_setdlopenflags_impl(module, new_val);
588
589exit:
590 return return_value;
591}
592
593#endif /* defined(HAVE_DLOPEN) */
594
595#if defined(HAVE_DLOPEN)
596
597PyDoc_STRVAR(sys_getdlopenflags__doc__,
598"getdlopenflags($module, /)\n"
599"--\n"
600"\n"
601"Return the current value of the flags that are used for dlopen calls.\n"
602"\n"
603"The flag constants are defined in the os module.");
604
605#define SYS_GETDLOPENFLAGS_METHODDEF \
606 {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, sys_getdlopenflags__doc__},
607
608static PyObject *
609sys_getdlopenflags_impl(PyObject *module);
610
611static PyObject *
612sys_getdlopenflags(PyObject *module, PyObject *Py_UNUSED(ignored))
613{
614 return sys_getdlopenflags_impl(module);
615}
616
617#endif /* defined(HAVE_DLOPEN) */
618
619#if defined(USE_MALLOPT)
620
621PyDoc_STRVAR(sys_mdebug__doc__,
622"mdebug($module, flag, /)\n"
623"--\n"
624"\n");
625
626#define SYS_MDEBUG_METHODDEF \
627 {"mdebug", (PyCFunction)sys_mdebug, METH_O, sys_mdebug__doc__},
628
629static PyObject *
630sys_mdebug_impl(PyObject *module, int flag);
631
632static PyObject *
633sys_mdebug(PyObject *module, PyObject *arg)
634{
635 PyObject *return_value = NULL;
636 int flag;
637
638 flag = _PyLong_AsInt(arg);
639 if (flag == -1 && PyErr_Occurred()) {
640 goto exit;
641 }
642 return_value = sys_mdebug_impl(module, flag);
643
644exit:
645 return return_value;
646}
647
648#endif /* defined(USE_MALLOPT) */
649
650PyDoc_STRVAR(sys_getrefcount__doc__,
651"getrefcount($module, object, /)\n"
652"--\n"
653"\n"
654"Return the reference count of object.\n"
655"\n"
656"The count returned is generally one higher than you might expect,\n"
657"because it includes the (temporary) reference as an argument to\n"
658"getrefcount().");
659
660#define SYS_GETREFCOUNT_METHODDEF \
661 {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__},
662
663static Py_ssize_t
664sys_getrefcount_impl(PyObject *module, PyObject *object);
665
666static PyObject *
667sys_getrefcount(PyObject *module, PyObject *object)
668{
669 PyObject *return_value = NULL;
670 Py_ssize_t _return_value;
671
672 _return_value = sys_getrefcount_impl(module, object);
673 if ((_return_value == -1) && PyErr_Occurred()) {
674 goto exit;
675 }
676 return_value = PyLong_FromSsize_t(_return_value);
677
678exit:
679 return return_value;
680}
681
682#if defined(Py_REF_DEBUG)
683
684PyDoc_STRVAR(sys_gettotalrefcount__doc__,
685"gettotalrefcount($module, /)\n"
686"--\n"
687"\n");
688
689#define SYS_GETTOTALREFCOUNT_METHODDEF \
690 {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__},
691
692static Py_ssize_t
693sys_gettotalrefcount_impl(PyObject *module);
694
695static PyObject *
696sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored))
697{
698 PyObject *return_value = NULL;
699 Py_ssize_t _return_value;
700
701 _return_value = sys_gettotalrefcount_impl(module);
702 if ((_return_value == -1) && PyErr_Occurred()) {
703 goto exit;
704 }
705 return_value = PyLong_FromSsize_t(_return_value);
706
707exit:
708 return return_value;
709}
710
711#endif /* defined(Py_REF_DEBUG) */
712
713PyDoc_STRVAR(sys_getallocatedblocks__doc__,
714"getallocatedblocks($module, /)\n"
715"--\n"
716"\n"
717"Return the number of memory blocks currently allocated.");
718
719#define SYS_GETALLOCATEDBLOCKS_METHODDEF \
720 {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
721
722static Py_ssize_t
723sys_getallocatedblocks_impl(PyObject *module);
724
725static PyObject *
726sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
727{
728 PyObject *return_value = NULL;
729 Py_ssize_t _return_value;
730
731 _return_value = sys_getallocatedblocks_impl(module);
732 if ((_return_value == -1) && PyErr_Occurred()) {
733 goto exit;
734 }
735 return_value = PyLong_FromSsize_t(_return_value);
736
737exit:
738 return return_value;
739}
740
741PyDoc_STRVAR(sys__getframe__doc__,
742"_getframe($module, depth=0, /)\n"
743"--\n"
744"\n"
745"Return a frame object from the call stack.\n"
746"\n"
747"If optional integer depth is given, return the frame object that many\n"
748"calls below the top of the stack. If that is deeper than the call\n"
749"stack, ValueError is raised. The default for depth is zero, returning\n"
750"the frame at the top of the call stack.\n"
751"\n"
752"This function should be used for internal and specialized purposes\n"
753"only.");
754
755#define SYS__GETFRAME_METHODDEF \
756 {"_getframe", (PyCFunction)(void(*)(void))sys__getframe, METH_FASTCALL, sys__getframe__doc__},
757
758static PyObject *
759sys__getframe_impl(PyObject *module, int depth);
760
761static PyObject *
762sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
763{
764 PyObject *return_value = NULL;
765 int depth = 0;
766
767 if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
768 goto exit;
769 }
770 if (nargs < 1) {
771 goto skip_optional;
772 }
773 depth = _PyLong_AsInt(args[0]);
774 if (depth == -1 && PyErr_Occurred()) {
775 goto exit;
776 }
777skip_optional:
778 return_value = sys__getframe_impl(module, depth);
779
780exit:
781 return return_value;
782}
783
784PyDoc_STRVAR(sys__current_frames__doc__,
785"_current_frames($module, /)\n"
786"--\n"
787"\n"
788"Return a dict mapping each thread\'s thread id to its current stack frame.\n"
789"\n"
790"This function should be used for specialized purposes only.");
791
792#define SYS__CURRENT_FRAMES_METHODDEF \
793 {"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__},
794
795static PyObject *
796sys__current_frames_impl(PyObject *module);
797
798static PyObject *
799sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored))
800{
801 return sys__current_frames_impl(module);
802}
803
804PyDoc_STRVAR(sys__current_exceptions__doc__,
805"_current_exceptions($module, /)\n"
806"--\n"
807"\n"
808"Return a dict mapping each thread\'s identifier to its current raised exception.\n"
809"\n"
810"This function should be used for specialized purposes only.");
811
812#define SYS__CURRENT_EXCEPTIONS_METHODDEF \
813 {"_current_exceptions", (PyCFunction)sys__current_exceptions, METH_NOARGS, sys__current_exceptions__doc__},
814
815static PyObject *
816sys__current_exceptions_impl(PyObject *module);
817
818static PyObject *
819sys__current_exceptions(PyObject *module, PyObject *Py_UNUSED(ignored))
820{
821 return sys__current_exceptions_impl(module);
822}
823
824PyDoc_STRVAR(sys_call_tracing__doc__,
825"call_tracing($module, func, args, /)\n"
826"--\n"
827"\n"
828"Call func(*args), while tracing is enabled.\n"
829"\n"
830"The tracing state is saved, and restored afterwards. This is intended\n"
831"to be called from a debugger from a checkpoint, to recursively debug\n"
832"some other code.");
833
834#define SYS_CALL_TRACING_METHODDEF \
835 {"call_tracing", (PyCFunction)(void(*)(void))sys_call_tracing, METH_FASTCALL, sys_call_tracing__doc__},
836
837static PyObject *
838sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs);
839
840static PyObject *
841sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
842{
843 PyObject *return_value = NULL;
844 PyObject *func;
845 PyObject *funcargs;
846
847 if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
848 goto exit;
849 }
850 func = args[0];
851 if (!PyTuple_Check(args[1])) {
852 _PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]);
853 goto exit;
854 }
855 funcargs = args[1];
856 return_value = sys_call_tracing_impl(module, func, funcargs);
857
858exit:
859 return return_value;
860}
861
862PyDoc_STRVAR(sys__debugmallocstats__doc__,
863"_debugmallocstats($module, /)\n"
864"--\n"
865"\n"
866"Print summary info to stderr about the state of pymalloc\'s structures.\n"
867"\n"
868"In Py_DEBUG mode, also perform some expensive internal consistency\n"
869"checks.");
870
871#define SYS__DEBUGMALLOCSTATS_METHODDEF \
872 {"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__},
873
874static PyObject *
875sys__debugmallocstats_impl(PyObject *module);
876
877static PyObject *
878sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored))
879{
880 return sys__debugmallocstats_impl(module);
881}
882
883PyDoc_STRVAR(sys__clear_type_cache__doc__,
884"_clear_type_cache($module, /)\n"
885"--\n"
886"\n"
887"Clear the internal type lookup cache.");
888
889#define SYS__CLEAR_TYPE_CACHE_METHODDEF \
890 {"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__},
891
892static PyObject *
893sys__clear_type_cache_impl(PyObject *module);
894
895static PyObject *
896sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored))
897{
898 return sys__clear_type_cache_impl(module);
899}
900
901PyDoc_STRVAR(sys_is_finalizing__doc__,
902"is_finalizing($module, /)\n"
903"--\n"
904"\n"
905"Return True if Python is exiting.");
906
907#define SYS_IS_FINALIZING_METHODDEF \
908 {"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__},
909
910static PyObject *
911sys_is_finalizing_impl(PyObject *module);
912
913static PyObject *
914sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
915{
916 return sys_is_finalizing_impl(module);
917}
918
919#if defined(ANDROID_API_LEVEL)
920
921PyDoc_STRVAR(sys_getandroidapilevel__doc__,
922"getandroidapilevel($module, /)\n"
923"--\n"
924"\n"
925"Return the build time API version of Android as an integer.");
926
927#define SYS_GETANDROIDAPILEVEL_METHODDEF \
928 {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__},
929
930static PyObject *
931sys_getandroidapilevel_impl(PyObject *module);
932
933static PyObject *
934sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
935{
936 return sys_getandroidapilevel_impl(module);
937}
938
939#endif /* defined(ANDROID_API_LEVEL) */
940
941PyDoc_STRVAR(sys__deactivate_opcache__doc__,
942"_deactivate_opcache($module, /)\n"
943"--\n"
944"\n"
945"Deactivate the opcode cache permanently");
946
947#define SYS__DEACTIVATE_OPCACHE_METHODDEF \
948 {"_deactivate_opcache", (PyCFunction)sys__deactivate_opcache, METH_NOARGS, sys__deactivate_opcache__doc__},
949
950static PyObject *
951sys__deactivate_opcache_impl(PyObject *module);
952
953static PyObject *
954sys__deactivate_opcache(PyObject *module, PyObject *Py_UNUSED(ignored))
955{
956 return sys__deactivate_opcache_impl(module);
957}
958
959#ifndef SYS_GETWINDOWSVERSION_METHODDEF
960 #define SYS_GETWINDOWSVERSION_METHODDEF
961#endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
962
963#ifndef SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
964 #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
965#endif /* !defined(SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF) */
966
967#ifndef SYS_SETDLOPENFLAGS_METHODDEF
968 #define SYS_SETDLOPENFLAGS_METHODDEF
969#endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */
970
971#ifndef SYS_GETDLOPENFLAGS_METHODDEF
972 #define SYS_GETDLOPENFLAGS_METHODDEF
973#endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */
974
975#ifndef SYS_MDEBUG_METHODDEF
976 #define SYS_MDEBUG_METHODDEF
977#endif /* !defined(SYS_MDEBUG_METHODDEF) */
978
979#ifndef SYS_GETTOTALREFCOUNT_METHODDEF
980 #define SYS_GETTOTALREFCOUNT_METHODDEF
981#endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
982
983#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
984 #define SYS_GETANDROIDAPILEVEL_METHODDEF
985#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
986/*[clinic end generated code: output=68c62b9ca317a0c8 input=a9049054013a1b77]*/
987