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)(void(*)(void))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)(void(*)(void))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_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
91 static PyObject *
92 sys_exc_info_impl(PyObject *module);
93
94 static PyObject *
sys_exc_info(PyObject * module,PyObject * Py_UNUSED (ignored))95 sys_exc_info(PyObject *module, PyObject *Py_UNUSED(ignored))
96 {
97 return sys_exc_info_impl(module);
98 }
99
100 PyDoc_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
117 PyDoc_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
131 static PyObject *
132 sys_exit_impl(PyObject *module, PyObject *status);
133
134 static PyObject *
sys_exit(PyObject * module,PyObject * const * args,Py_ssize_t nargs)135 sys_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];
147 skip_optional:
148 return_value = sys_exit_impl(module, status);
149
150 exit:
151 return return_value;
152 }
153
154 PyDoc_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
163 static PyObject *
164 sys_getdefaultencoding_impl(PyObject *module);
165
166 static PyObject *
sys_getdefaultencoding(PyObject * module,PyObject * Py_UNUSED (ignored))167 sys_getdefaultencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
168 {
169 return sys_getdefaultencoding_impl(module);
170 }
171
172 PyDoc_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
181 static PyObject *
182 sys_getfilesystemencoding_impl(PyObject *module);
183
184 static PyObject *
sys_getfilesystemencoding(PyObject * module,PyObject * Py_UNUSED (ignored))185 sys_getfilesystemencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
186 {
187 return sys_getfilesystemencoding_impl(module);
188 }
189
190 PyDoc_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
199 static PyObject *
200 sys_getfilesystemencodeerrors_impl(PyObject *module);
201
202 static PyObject *
sys_getfilesystemencodeerrors(PyObject * module,PyObject * Py_UNUSED (ignored))203 sys_getfilesystemencodeerrors(PyObject *module, PyObject *Py_UNUSED(ignored))
204 {
205 return sys_getfilesystemencodeerrors_impl(module);
206 }
207
208 PyDoc_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
221 static PyObject *
222 sys_intern_impl(PyObject *module, PyObject *s);
223
224 static PyObject *
sys_intern(PyObject * module,PyObject * arg)225 sys_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
240 exit:
241 return return_value;
242 }
243
244 PyDoc_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
255 static PyObject *
256 sys_gettrace_impl(PyObject *module);
257
258 static PyObject *
sys_gettrace(PyObject * module,PyObject * Py_UNUSED (ignored))259 sys_gettrace(PyObject *module, PyObject *Py_UNUSED(ignored))
260 {
261 return sys_gettrace_impl(module);
262 }
263
264 PyDoc_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
275 static PyObject *
276 sys_getprofile_impl(PyObject *module);
277
278 static PyObject *
sys_getprofile(PyObject * module,PyObject * Py_UNUSED (ignored))279 sys_getprofile(PyObject *module, PyObject *Py_UNUSED(ignored))
280 {
281 return sys_getprofile_impl(module);
282 }
283
284 PyDoc_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
300 static PyObject *
301 sys_setswitchinterval_impl(PyObject *module, double interval);
302
303 static PyObject *
sys_setswitchinterval(PyObject * module,PyObject * arg)304 sys_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
321 exit:
322 return return_value;
323 }
324
325 PyDoc_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
334 static double
335 sys_getswitchinterval_impl(PyObject *module);
336
337 static PyObject *
sys_getswitchinterval(PyObject * module,PyObject * Py_UNUSED (ignored))338 sys_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
349 exit:
350 return return_value;
351 }
352
353 PyDoc_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
366 static PyObject *
367 sys_setrecursionlimit_impl(PyObject *module, int new_limit);
368
369 static PyObject *
sys_setrecursionlimit(PyObject * module,PyObject * arg)370 sys_setrecursionlimit(PyObject *module, PyObject *arg)
371 {
372 PyObject *return_value = NULL;
373 int new_limit;
374
375 if (PyFloat_Check(arg)) {
376 PyErr_SetString(PyExc_TypeError,
377 "integer argument expected, got float" );
378 goto exit;
379 }
380 new_limit = _PyLong_AsInt(arg);
381 if (new_limit == -1 && PyErr_Occurred()) {
382 goto exit;
383 }
384 return_value = sys_setrecursionlimit_impl(module, new_limit);
385
386 exit:
387 return return_value;
388 }
389
390 PyDoc_STRVAR(sys_set_coroutine_origin_tracking_depth__doc__,
391 "set_coroutine_origin_tracking_depth($module, /, depth)\n"
392 "--\n"
393 "\n"
394 "Enable or disable origin tracking for coroutine objects in this thread.\n"
395 "\n"
396 "Coroutine objects will track \'depth\' frames of traceback information\n"
397 "about where they came from, available in their cr_origin attribute.\n"
398 "\n"
399 "Set a depth of 0 to disable.");
400
401 #define SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
402 {"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__},
403
404 static PyObject *
405 sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth);
406
407 static PyObject *
sys_set_coroutine_origin_tracking_depth(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)408 sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
409 {
410 PyObject *return_value = NULL;
411 static const char * const _keywords[] = {"depth", NULL};
412 static _PyArg_Parser _parser = {NULL, _keywords, "set_coroutine_origin_tracking_depth", 0};
413 PyObject *argsbuf[1];
414 int depth;
415
416 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
417 if (!args) {
418 goto exit;
419 }
420 if (PyFloat_Check(args[0])) {
421 PyErr_SetString(PyExc_TypeError,
422 "integer argument expected, got float" );
423 goto exit;
424 }
425 depth = _PyLong_AsInt(args[0]);
426 if (depth == -1 && PyErr_Occurred()) {
427 goto exit;
428 }
429 return_value = sys_set_coroutine_origin_tracking_depth_impl(module, depth);
430
431 exit:
432 return return_value;
433 }
434
435 PyDoc_STRVAR(sys_get_coroutine_origin_tracking_depth__doc__,
436 "get_coroutine_origin_tracking_depth($module, /)\n"
437 "--\n"
438 "\n"
439 "Check status of origin tracking for coroutine objects in this thread.");
440
441 #define SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
442 {"get_coroutine_origin_tracking_depth", (PyCFunction)sys_get_coroutine_origin_tracking_depth, METH_NOARGS, sys_get_coroutine_origin_tracking_depth__doc__},
443
444 static int
445 sys_get_coroutine_origin_tracking_depth_impl(PyObject *module);
446
447 static PyObject *
sys_get_coroutine_origin_tracking_depth(PyObject * module,PyObject * Py_UNUSED (ignored))448 sys_get_coroutine_origin_tracking_depth(PyObject *module, PyObject *Py_UNUSED(ignored))
449 {
450 PyObject *return_value = NULL;
451 int _return_value;
452
453 _return_value = sys_get_coroutine_origin_tracking_depth_impl(module);
454 if ((_return_value == -1) && PyErr_Occurred()) {
455 goto exit;
456 }
457 return_value = PyLong_FromLong((long)_return_value);
458
459 exit:
460 return return_value;
461 }
462
463 PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__,
464 "get_asyncgen_hooks($module, /)\n"
465 "--\n"
466 "\n"
467 "Return the installed asynchronous generators hooks.\n"
468 "\n"
469 "This returns a namedtuple of the form (firstiter, finalizer).");
470
471 #define SYS_GET_ASYNCGEN_HOOKS_METHODDEF \
472 {"get_asyncgen_hooks", (PyCFunction)sys_get_asyncgen_hooks, METH_NOARGS, sys_get_asyncgen_hooks__doc__},
473
474 static PyObject *
475 sys_get_asyncgen_hooks_impl(PyObject *module);
476
477 static PyObject *
sys_get_asyncgen_hooks(PyObject * module,PyObject * Py_UNUSED (ignored))478 sys_get_asyncgen_hooks(PyObject *module, PyObject *Py_UNUSED(ignored))
479 {
480 return sys_get_asyncgen_hooks_impl(module);
481 }
482
483 PyDoc_STRVAR(sys_getrecursionlimit__doc__,
484 "getrecursionlimit($module, /)\n"
485 "--\n"
486 "\n"
487 "Return the current value of the recursion limit.\n"
488 "\n"
489 "The recursion limit is the maximum depth of the Python interpreter\n"
490 "stack. This limit prevents infinite recursion from causing an overflow\n"
491 "of the C stack and crashing Python.");
492
493 #define SYS_GETRECURSIONLIMIT_METHODDEF \
494 {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, sys_getrecursionlimit__doc__},
495
496 static PyObject *
497 sys_getrecursionlimit_impl(PyObject *module);
498
499 static PyObject *
sys_getrecursionlimit(PyObject * module,PyObject * Py_UNUSED (ignored))500 sys_getrecursionlimit(PyObject *module, PyObject *Py_UNUSED(ignored))
501 {
502 return sys_getrecursionlimit_impl(module);
503 }
504
505 #if defined(MS_WINDOWS)
506
507 PyDoc_STRVAR(sys_getwindowsversion__doc__,
508 "getwindowsversion($module, /)\n"
509 "--\n"
510 "\n"
511 "Return info about the running version of Windows as a named tuple.\n"
512 "\n"
513 "The members are named: major, minor, build, platform, service_pack,\n"
514 "service_pack_major, service_pack_minor, suite_mask, product_type and\n"
515 "platform_version. For backward compatibility, only the first 5 items\n"
516 "are available by indexing. All elements are numbers, except\n"
517 "service_pack and platform_type which are strings, and platform_version\n"
518 "which is a 3-tuple. Platform is always 2. Product_type may be 1 for a\n"
519 "workstation, 2 for a domain controller, 3 for a server.\n"
520 "Platform_version is a 3-tuple containing a version number that is\n"
521 "intended for identifying the OS rather than feature detection.");
522
523 #define SYS_GETWINDOWSVERSION_METHODDEF \
524 {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, sys_getwindowsversion__doc__},
525
526 static PyObject *
527 sys_getwindowsversion_impl(PyObject *module);
528
529 static PyObject *
sys_getwindowsversion(PyObject * module,PyObject * Py_UNUSED (ignored))530 sys_getwindowsversion(PyObject *module, PyObject *Py_UNUSED(ignored))
531 {
532 return sys_getwindowsversion_impl(module);
533 }
534
535 #endif /* defined(MS_WINDOWS) */
536
537 #if defined(MS_WINDOWS)
538
539 PyDoc_STRVAR(sys__enablelegacywindowsfsencoding__doc__,
540 "_enablelegacywindowsfsencoding($module, /)\n"
541 "--\n"
542 "\n"
543 "Changes the default filesystem encoding to mbcs:replace.\n"
544 "\n"
545 "This is done for consistency with earlier versions of Python. See PEP\n"
546 "529 for more information.\n"
547 "\n"
548 "This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING\n"
549 "environment variable before launching Python.");
550
551 #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF \
552 {"_enablelegacywindowsfsencoding", (PyCFunction)sys__enablelegacywindowsfsencoding, METH_NOARGS, sys__enablelegacywindowsfsencoding__doc__},
553
554 static PyObject *
555 sys__enablelegacywindowsfsencoding_impl(PyObject *module);
556
557 static PyObject *
sys__enablelegacywindowsfsencoding(PyObject * module,PyObject * Py_UNUSED (ignored))558 sys__enablelegacywindowsfsencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
559 {
560 return sys__enablelegacywindowsfsencoding_impl(module);
561 }
562
563 #endif /* defined(MS_WINDOWS) */
564
565 #if defined(HAVE_DLOPEN)
566
567 PyDoc_STRVAR(sys_setdlopenflags__doc__,
568 "setdlopenflags($module, flags, /)\n"
569 "--\n"
570 "\n"
571 "Set the flags used by the interpreter for dlopen calls.\n"
572 "\n"
573 "This is used, for example, when the interpreter loads extension\n"
574 "modules. Among other things, this will enable a lazy resolving of\n"
575 "symbols when importing a module, if called as sys.setdlopenflags(0).\n"
576 "To share symbols across extension modules, call as\n"
577 "sys.setdlopenflags(os.RTLD_GLOBAL). Symbolic names for the flag\n"
578 "modules can be found in the os module (RTLD_xxx constants, e.g.\n"
579 "os.RTLD_LAZY).");
580
581 #define SYS_SETDLOPENFLAGS_METHODDEF \
582 {"setdlopenflags", (PyCFunction)sys_setdlopenflags, METH_O, sys_setdlopenflags__doc__},
583
584 static PyObject *
585 sys_setdlopenflags_impl(PyObject *module, int new_val);
586
587 static PyObject *
sys_setdlopenflags(PyObject * module,PyObject * arg)588 sys_setdlopenflags(PyObject *module, PyObject *arg)
589 {
590 PyObject *return_value = NULL;
591 int new_val;
592
593 if (PyFloat_Check(arg)) {
594 PyErr_SetString(PyExc_TypeError,
595 "integer argument expected, got float" );
596 goto exit;
597 }
598 new_val = _PyLong_AsInt(arg);
599 if (new_val == -1 && PyErr_Occurred()) {
600 goto exit;
601 }
602 return_value = sys_setdlopenflags_impl(module, new_val);
603
604 exit:
605 return return_value;
606 }
607
608 #endif /* defined(HAVE_DLOPEN) */
609
610 #if defined(HAVE_DLOPEN)
611
612 PyDoc_STRVAR(sys_getdlopenflags__doc__,
613 "getdlopenflags($module, /)\n"
614 "--\n"
615 "\n"
616 "Return the current value of the flags that are used for dlopen calls.\n"
617 "\n"
618 "The flag constants are defined in the os module.");
619
620 #define SYS_GETDLOPENFLAGS_METHODDEF \
621 {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, sys_getdlopenflags__doc__},
622
623 static PyObject *
624 sys_getdlopenflags_impl(PyObject *module);
625
626 static PyObject *
sys_getdlopenflags(PyObject * module,PyObject * Py_UNUSED (ignored))627 sys_getdlopenflags(PyObject *module, PyObject *Py_UNUSED(ignored))
628 {
629 return sys_getdlopenflags_impl(module);
630 }
631
632 #endif /* defined(HAVE_DLOPEN) */
633
634 #if defined(USE_MALLOPT)
635
636 PyDoc_STRVAR(sys_mdebug__doc__,
637 "mdebug($module, flag, /)\n"
638 "--\n"
639 "\n");
640
641 #define SYS_MDEBUG_METHODDEF \
642 {"mdebug", (PyCFunction)sys_mdebug, METH_O, sys_mdebug__doc__},
643
644 static PyObject *
645 sys_mdebug_impl(PyObject *module, int flag);
646
647 static PyObject *
sys_mdebug(PyObject * module,PyObject * arg)648 sys_mdebug(PyObject *module, PyObject *arg)
649 {
650 PyObject *return_value = NULL;
651 int flag;
652
653 if (PyFloat_Check(arg)) {
654 PyErr_SetString(PyExc_TypeError,
655 "integer argument expected, got float" );
656 goto exit;
657 }
658 flag = _PyLong_AsInt(arg);
659 if (flag == -1 && PyErr_Occurred()) {
660 goto exit;
661 }
662 return_value = sys_mdebug_impl(module, flag);
663
664 exit:
665 return return_value;
666 }
667
668 #endif /* defined(USE_MALLOPT) */
669
670 PyDoc_STRVAR(sys_get_int_max_str_digits__doc__,
671 "get_int_max_str_digits($module, /)\n"
672 "--\n"
673 "\n"
674 "Set the maximum string digits limit for non-binary int<->str conversions.");
675
676 #define SYS_GET_INT_MAX_STR_DIGITS_METHODDEF \
677 {"get_int_max_str_digits", (PyCFunction)sys_get_int_max_str_digits, METH_NOARGS, sys_get_int_max_str_digits__doc__},
678
679 static PyObject *
680 sys_get_int_max_str_digits_impl(PyObject *module);
681
682 static PyObject *
sys_get_int_max_str_digits(PyObject * module,PyObject * Py_UNUSED (ignored))683 sys_get_int_max_str_digits(PyObject *module, PyObject *Py_UNUSED(ignored))
684 {
685 return sys_get_int_max_str_digits_impl(module);
686 }
687
688 PyDoc_STRVAR(sys_set_int_max_str_digits__doc__,
689 "set_int_max_str_digits($module, /, maxdigits)\n"
690 "--\n"
691 "\n"
692 "Set the maximum string digits limit for non-binary int<->str conversions.");
693
694 #define SYS_SET_INT_MAX_STR_DIGITS_METHODDEF \
695 {"set_int_max_str_digits", (PyCFunction)(void(*)(void))sys_set_int_max_str_digits, METH_FASTCALL|METH_KEYWORDS, sys_set_int_max_str_digits__doc__},
696
697 static PyObject *
698 sys_set_int_max_str_digits_impl(PyObject *module, int maxdigits);
699
700 static PyObject *
sys_set_int_max_str_digits(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)701 sys_set_int_max_str_digits(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
702 {
703 PyObject *return_value = NULL;
704 static const char * const _keywords[] = {"maxdigits", NULL};
705 static _PyArg_Parser _parser = {NULL, _keywords, "set_int_max_str_digits", 0};
706 PyObject *argsbuf[1];
707 int maxdigits;
708
709 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
710 if (!args) {
711 goto exit;
712 }
713 if (PyFloat_Check(args[0])) {
714 PyErr_SetString(PyExc_TypeError,
715 "integer argument expected, got float" );
716 goto exit;
717 }
718 maxdigits = _PyLong_AsInt(args[0]);
719 if (maxdigits == -1 && PyErr_Occurred()) {
720 goto exit;
721 }
722 return_value = sys_set_int_max_str_digits_impl(module, maxdigits);
723
724 exit:
725 return return_value;
726 }
727
728 PyDoc_STRVAR(sys_getrefcount__doc__,
729 "getrefcount($module, object, /)\n"
730 "--\n"
731 "\n"
732 "Return the reference count of object.\n"
733 "\n"
734 "The count returned is generally one higher than you might expect,\n"
735 "because it includes the (temporary) reference as an argument to\n"
736 "getrefcount().");
737
738 #define SYS_GETREFCOUNT_METHODDEF \
739 {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__},
740
741 static Py_ssize_t
742 sys_getrefcount_impl(PyObject *module, PyObject *object);
743
744 static PyObject *
sys_getrefcount(PyObject * module,PyObject * object)745 sys_getrefcount(PyObject *module, PyObject *object)
746 {
747 PyObject *return_value = NULL;
748 Py_ssize_t _return_value;
749
750 _return_value = sys_getrefcount_impl(module, object);
751 if ((_return_value == -1) && PyErr_Occurred()) {
752 goto exit;
753 }
754 return_value = PyLong_FromSsize_t(_return_value);
755
756 exit:
757 return return_value;
758 }
759
760 #if defined(Py_REF_DEBUG)
761
762 PyDoc_STRVAR(sys_gettotalrefcount__doc__,
763 "gettotalrefcount($module, /)\n"
764 "--\n"
765 "\n");
766
767 #define SYS_GETTOTALREFCOUNT_METHODDEF \
768 {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__},
769
770 static Py_ssize_t
771 sys_gettotalrefcount_impl(PyObject *module);
772
773 static PyObject *
sys_gettotalrefcount(PyObject * module,PyObject * Py_UNUSED (ignored))774 sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored))
775 {
776 PyObject *return_value = NULL;
777 Py_ssize_t _return_value;
778
779 _return_value = sys_gettotalrefcount_impl(module);
780 if ((_return_value == -1) && PyErr_Occurred()) {
781 goto exit;
782 }
783 return_value = PyLong_FromSsize_t(_return_value);
784
785 exit:
786 return return_value;
787 }
788
789 #endif /* defined(Py_REF_DEBUG) */
790
791 PyDoc_STRVAR(sys_getallocatedblocks__doc__,
792 "getallocatedblocks($module, /)\n"
793 "--\n"
794 "\n"
795 "Return the number of memory blocks currently allocated.");
796
797 #define SYS_GETALLOCATEDBLOCKS_METHODDEF \
798 {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
799
800 static Py_ssize_t
801 sys_getallocatedblocks_impl(PyObject *module);
802
803 static PyObject *
sys_getallocatedblocks(PyObject * module,PyObject * Py_UNUSED (ignored))804 sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
805 {
806 PyObject *return_value = NULL;
807 Py_ssize_t _return_value;
808
809 _return_value = sys_getallocatedblocks_impl(module);
810 if ((_return_value == -1) && PyErr_Occurred()) {
811 goto exit;
812 }
813 return_value = PyLong_FromSsize_t(_return_value);
814
815 exit:
816 return return_value;
817 }
818
819 PyDoc_STRVAR(sys__getframe__doc__,
820 "_getframe($module, depth=0, /)\n"
821 "--\n"
822 "\n"
823 "Return a frame object from the call stack.\n"
824 "\n"
825 "If optional integer depth is given, return the frame object that many\n"
826 "calls below the top of the stack. If that is deeper than the call\n"
827 "stack, ValueError is raised. The default for depth is zero, returning\n"
828 "the frame at the top of the call stack.\n"
829 "\n"
830 "This function should be used for internal and specialized purposes\n"
831 "only.");
832
833 #define SYS__GETFRAME_METHODDEF \
834 {"_getframe", (PyCFunction)(void(*)(void))sys__getframe, METH_FASTCALL, sys__getframe__doc__},
835
836 static PyObject *
837 sys__getframe_impl(PyObject *module, int depth);
838
839 static PyObject *
sys__getframe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)840 sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
841 {
842 PyObject *return_value = NULL;
843 int depth = 0;
844
845 if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
846 goto exit;
847 }
848 if (nargs < 1) {
849 goto skip_optional;
850 }
851 if (PyFloat_Check(args[0])) {
852 PyErr_SetString(PyExc_TypeError,
853 "integer argument expected, got float" );
854 goto exit;
855 }
856 depth = _PyLong_AsInt(args[0]);
857 if (depth == -1 && PyErr_Occurred()) {
858 goto exit;
859 }
860 skip_optional:
861 return_value = sys__getframe_impl(module, depth);
862
863 exit:
864 return return_value;
865 }
866
867 PyDoc_STRVAR(sys__current_frames__doc__,
868 "_current_frames($module, /)\n"
869 "--\n"
870 "\n"
871 "Return a dict mapping each thread\'s thread id to its current stack frame.\n"
872 "\n"
873 "This function should be used for specialized purposes only.");
874
875 #define SYS__CURRENT_FRAMES_METHODDEF \
876 {"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__},
877
878 static PyObject *
879 sys__current_frames_impl(PyObject *module);
880
881 static PyObject *
sys__current_frames(PyObject * module,PyObject * Py_UNUSED (ignored))882 sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored))
883 {
884 return sys__current_frames_impl(module);
885 }
886
887 PyDoc_STRVAR(sys_call_tracing__doc__,
888 "call_tracing($module, func, args, /)\n"
889 "--\n"
890 "\n"
891 "Call func(*args), while tracing is enabled.\n"
892 "\n"
893 "The tracing state is saved, and restored afterwards. This is intended\n"
894 "to be called from a debugger from a checkpoint, to recursively debug\n"
895 "some other code.");
896
897 #define SYS_CALL_TRACING_METHODDEF \
898 {"call_tracing", (PyCFunction)(void(*)(void))sys_call_tracing, METH_FASTCALL, sys_call_tracing__doc__},
899
900 static PyObject *
901 sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs);
902
903 static PyObject *
sys_call_tracing(PyObject * module,PyObject * const * args,Py_ssize_t nargs)904 sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
905 {
906 PyObject *return_value = NULL;
907 PyObject *func;
908 PyObject *funcargs;
909
910 if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
911 goto exit;
912 }
913 func = args[0];
914 if (!PyTuple_Check(args[1])) {
915 _PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]);
916 goto exit;
917 }
918 funcargs = args[1];
919 return_value = sys_call_tracing_impl(module, func, funcargs);
920
921 exit:
922 return return_value;
923 }
924
925 PyDoc_STRVAR(sys__debugmallocstats__doc__,
926 "_debugmallocstats($module, /)\n"
927 "--\n"
928 "\n"
929 "Print summary info to stderr about the state of pymalloc\'s structures.\n"
930 "\n"
931 "In Py_DEBUG mode, also perform some expensive internal consistency\n"
932 "checks.");
933
934 #define SYS__DEBUGMALLOCSTATS_METHODDEF \
935 {"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__},
936
937 static PyObject *
938 sys__debugmallocstats_impl(PyObject *module);
939
940 static PyObject *
sys__debugmallocstats(PyObject * module,PyObject * Py_UNUSED (ignored))941 sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored))
942 {
943 return sys__debugmallocstats_impl(module);
944 }
945
946 PyDoc_STRVAR(sys__clear_type_cache__doc__,
947 "_clear_type_cache($module, /)\n"
948 "--\n"
949 "\n"
950 "Clear the internal type lookup cache.");
951
952 #define SYS__CLEAR_TYPE_CACHE_METHODDEF \
953 {"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__},
954
955 static PyObject *
956 sys__clear_type_cache_impl(PyObject *module);
957
958 static PyObject *
sys__clear_type_cache(PyObject * module,PyObject * Py_UNUSED (ignored))959 sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored))
960 {
961 return sys__clear_type_cache_impl(module);
962 }
963
964 PyDoc_STRVAR(sys_is_finalizing__doc__,
965 "is_finalizing($module, /)\n"
966 "--\n"
967 "\n"
968 "Return True if Python is exiting.");
969
970 #define SYS_IS_FINALIZING_METHODDEF \
971 {"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__},
972
973 static PyObject *
974 sys_is_finalizing_impl(PyObject *module);
975
976 static PyObject *
sys_is_finalizing(PyObject * module,PyObject * Py_UNUSED (ignored))977 sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
978 {
979 return sys_is_finalizing_impl(module);
980 }
981
982 #if defined(ANDROID_API_LEVEL)
983
984 PyDoc_STRVAR(sys_getandroidapilevel__doc__,
985 "getandroidapilevel($module, /)\n"
986 "--\n"
987 "\n"
988 "Return the build time API version of Android as an integer.");
989
990 #define SYS_GETANDROIDAPILEVEL_METHODDEF \
991 {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__},
992
993 static PyObject *
994 sys_getandroidapilevel_impl(PyObject *module);
995
996 static PyObject *
sys_getandroidapilevel(PyObject * module,PyObject * Py_UNUSED (ignored))997 sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
998 {
999 return sys_getandroidapilevel_impl(module);
1000 }
1001
1002 #endif /* defined(ANDROID_API_LEVEL) */
1003
1004 #ifndef SYS_GETWINDOWSVERSION_METHODDEF
1005 #define SYS_GETWINDOWSVERSION_METHODDEF
1006 #endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
1007
1008 #ifndef SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1009 #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1010 #endif /* !defined(SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF) */
1011
1012 #ifndef SYS_SETDLOPENFLAGS_METHODDEF
1013 #define SYS_SETDLOPENFLAGS_METHODDEF
1014 #endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */
1015
1016 #ifndef SYS_GETDLOPENFLAGS_METHODDEF
1017 #define SYS_GETDLOPENFLAGS_METHODDEF
1018 #endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */
1019
1020 #ifndef SYS_MDEBUG_METHODDEF
1021 #define SYS_MDEBUG_METHODDEF
1022 #endif /* !defined(SYS_MDEBUG_METHODDEF) */
1023
1024 #ifndef SYS_GETTOTALREFCOUNT_METHODDEF
1025 #define SYS_GETTOTALREFCOUNT_METHODDEF
1026 #endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
1027
1028 #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
1029 #define SYS_GETANDROIDAPILEVEL_METHODDEF
1030 #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
1031 /*[clinic end generated code: output=401254a595859ac6 input=a9049054013a1b77]*/
1032