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