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_getrefcount__doc__,
671 "getrefcount($module, object, /)\n"
672 "--\n"
673 "\n"
674 "Return the reference count of object.\n"
675 "\n"
676 "The count returned is generally one higher than you might expect,\n"
677 "because it includes the (temporary) reference as an argument to\n"
678 "getrefcount().");
679
680 #define SYS_GETREFCOUNT_METHODDEF \
681 {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__},
682
683 static Py_ssize_t
684 sys_getrefcount_impl(PyObject *module, PyObject *object);
685
686 static PyObject *
sys_getrefcount(PyObject * module,PyObject * object)687 sys_getrefcount(PyObject *module, PyObject *object)
688 {
689 PyObject *return_value = NULL;
690 Py_ssize_t _return_value;
691
692 _return_value = sys_getrefcount_impl(module, object);
693 if ((_return_value == -1) && PyErr_Occurred()) {
694 goto exit;
695 }
696 return_value = PyLong_FromSsize_t(_return_value);
697
698 exit:
699 return return_value;
700 }
701
702 #if defined(Py_REF_DEBUG)
703
704 PyDoc_STRVAR(sys_gettotalrefcount__doc__,
705 "gettotalrefcount($module, /)\n"
706 "--\n"
707 "\n");
708
709 #define SYS_GETTOTALREFCOUNT_METHODDEF \
710 {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__},
711
712 static Py_ssize_t
713 sys_gettotalrefcount_impl(PyObject *module);
714
715 static PyObject *
sys_gettotalrefcount(PyObject * module,PyObject * Py_UNUSED (ignored))716 sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored))
717 {
718 PyObject *return_value = NULL;
719 Py_ssize_t _return_value;
720
721 _return_value = sys_gettotalrefcount_impl(module);
722 if ((_return_value == -1) && PyErr_Occurred()) {
723 goto exit;
724 }
725 return_value = PyLong_FromSsize_t(_return_value);
726
727 exit:
728 return return_value;
729 }
730
731 #endif /* defined(Py_REF_DEBUG) */
732
733 PyDoc_STRVAR(sys_getallocatedblocks__doc__,
734 "getallocatedblocks($module, /)\n"
735 "--\n"
736 "\n"
737 "Return the number of memory blocks currently allocated.");
738
739 #define SYS_GETALLOCATEDBLOCKS_METHODDEF \
740 {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
741
742 static Py_ssize_t
743 sys_getallocatedblocks_impl(PyObject *module);
744
745 static PyObject *
sys_getallocatedblocks(PyObject * module,PyObject * Py_UNUSED (ignored))746 sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
747 {
748 PyObject *return_value = NULL;
749 Py_ssize_t _return_value;
750
751 _return_value = sys_getallocatedblocks_impl(module);
752 if ((_return_value == -1) && PyErr_Occurred()) {
753 goto exit;
754 }
755 return_value = PyLong_FromSsize_t(_return_value);
756
757 exit:
758 return return_value;
759 }
760
761 PyDoc_STRVAR(sys__getframe__doc__,
762 "_getframe($module, depth=0, /)\n"
763 "--\n"
764 "\n"
765 "Return a frame object from the call stack.\n"
766 "\n"
767 "If optional integer depth is given, return the frame object that many\n"
768 "calls below the top of the stack. If that is deeper than the call\n"
769 "stack, ValueError is raised. The default for depth is zero, returning\n"
770 "the frame at the top of the call stack.\n"
771 "\n"
772 "This function should be used for internal and specialized purposes\n"
773 "only.");
774
775 #define SYS__GETFRAME_METHODDEF \
776 {"_getframe", (PyCFunction)(void(*)(void))sys__getframe, METH_FASTCALL, sys__getframe__doc__},
777
778 static PyObject *
779 sys__getframe_impl(PyObject *module, int depth);
780
781 static PyObject *
sys__getframe(PyObject * module,PyObject * const * args,Py_ssize_t nargs)782 sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
783 {
784 PyObject *return_value = NULL;
785 int depth = 0;
786
787 if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
788 goto exit;
789 }
790 if (nargs < 1) {
791 goto skip_optional;
792 }
793 if (PyFloat_Check(args[0])) {
794 PyErr_SetString(PyExc_TypeError,
795 "integer argument expected, got float" );
796 goto exit;
797 }
798 depth = _PyLong_AsInt(args[0]);
799 if (depth == -1 && PyErr_Occurred()) {
800 goto exit;
801 }
802 skip_optional:
803 return_value = sys__getframe_impl(module, depth);
804
805 exit:
806 return return_value;
807 }
808
809 PyDoc_STRVAR(sys__current_frames__doc__,
810 "_current_frames($module, /)\n"
811 "--\n"
812 "\n"
813 "Return a dict mapping each thread\'s thread id to its current stack frame.\n"
814 "\n"
815 "This function should be used for specialized purposes only.");
816
817 #define SYS__CURRENT_FRAMES_METHODDEF \
818 {"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__},
819
820 static PyObject *
821 sys__current_frames_impl(PyObject *module);
822
823 static PyObject *
sys__current_frames(PyObject * module,PyObject * Py_UNUSED (ignored))824 sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored))
825 {
826 return sys__current_frames_impl(module);
827 }
828
829 PyDoc_STRVAR(sys_call_tracing__doc__,
830 "call_tracing($module, func, args, /)\n"
831 "--\n"
832 "\n"
833 "Call func(*args), while tracing is enabled.\n"
834 "\n"
835 "The tracing state is saved, and restored afterwards. This is intended\n"
836 "to be called from a debugger from a checkpoint, to recursively debug\n"
837 "some other code.");
838
839 #define SYS_CALL_TRACING_METHODDEF \
840 {"call_tracing", (PyCFunction)(void(*)(void))sys_call_tracing, METH_FASTCALL, sys_call_tracing__doc__},
841
842 static PyObject *
843 sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs);
844
845 static PyObject *
sys_call_tracing(PyObject * module,PyObject * const * args,Py_ssize_t nargs)846 sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
847 {
848 PyObject *return_value = NULL;
849 PyObject *func;
850 PyObject *funcargs;
851
852 if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
853 goto exit;
854 }
855 func = args[0];
856 if (!PyTuple_Check(args[1])) {
857 _PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]);
858 goto exit;
859 }
860 funcargs = args[1];
861 return_value = sys_call_tracing_impl(module, func, funcargs);
862
863 exit:
864 return return_value;
865 }
866
867 PyDoc_STRVAR(sys__debugmallocstats__doc__,
868 "_debugmallocstats($module, /)\n"
869 "--\n"
870 "\n"
871 "Print summary info to stderr about the state of pymalloc\'s structures.\n"
872 "\n"
873 "In Py_DEBUG mode, also perform some expensive internal consistency\n"
874 "checks.");
875
876 #define SYS__DEBUGMALLOCSTATS_METHODDEF \
877 {"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__},
878
879 static PyObject *
880 sys__debugmallocstats_impl(PyObject *module);
881
882 static PyObject *
sys__debugmallocstats(PyObject * module,PyObject * Py_UNUSED (ignored))883 sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored))
884 {
885 return sys__debugmallocstats_impl(module);
886 }
887
888 PyDoc_STRVAR(sys__clear_type_cache__doc__,
889 "_clear_type_cache($module, /)\n"
890 "--\n"
891 "\n"
892 "Clear the internal type lookup cache.");
893
894 #define SYS__CLEAR_TYPE_CACHE_METHODDEF \
895 {"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__},
896
897 static PyObject *
898 sys__clear_type_cache_impl(PyObject *module);
899
900 static PyObject *
sys__clear_type_cache(PyObject * module,PyObject * Py_UNUSED (ignored))901 sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored))
902 {
903 return sys__clear_type_cache_impl(module);
904 }
905
906 PyDoc_STRVAR(sys_is_finalizing__doc__,
907 "is_finalizing($module, /)\n"
908 "--\n"
909 "\n"
910 "Return True if Python is exiting.");
911
912 #define SYS_IS_FINALIZING_METHODDEF \
913 {"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__},
914
915 static PyObject *
916 sys_is_finalizing_impl(PyObject *module);
917
918 static PyObject *
sys_is_finalizing(PyObject * module,PyObject * Py_UNUSED (ignored))919 sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
920 {
921 return sys_is_finalizing_impl(module);
922 }
923
924 #if defined(ANDROID_API_LEVEL)
925
926 PyDoc_STRVAR(sys_getandroidapilevel__doc__,
927 "getandroidapilevel($module, /)\n"
928 "--\n"
929 "\n"
930 "Return the build time API version of Android as an integer.");
931
932 #define SYS_GETANDROIDAPILEVEL_METHODDEF \
933 {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__},
934
935 static PyObject *
936 sys_getandroidapilevel_impl(PyObject *module);
937
938 static PyObject *
sys_getandroidapilevel(PyObject * module,PyObject * Py_UNUSED (ignored))939 sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
940 {
941 return sys_getandroidapilevel_impl(module);
942 }
943
944 #endif /* defined(ANDROID_API_LEVEL) */
945
946 #ifndef SYS_GETWINDOWSVERSION_METHODDEF
947 #define SYS_GETWINDOWSVERSION_METHODDEF
948 #endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
949
950 #ifndef SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
951 #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
952 #endif /* !defined(SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF) */
953
954 #ifndef SYS_SETDLOPENFLAGS_METHODDEF
955 #define SYS_SETDLOPENFLAGS_METHODDEF
956 #endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */
957
958 #ifndef SYS_GETDLOPENFLAGS_METHODDEF
959 #define SYS_GETDLOPENFLAGS_METHODDEF
960 #endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */
961
962 #ifndef SYS_MDEBUG_METHODDEF
963 #define SYS_MDEBUG_METHODDEF
964 #endif /* !defined(SYS_MDEBUG_METHODDEF) */
965
966 #ifndef SYS_GETTOTALREFCOUNT_METHODDEF
967 #define SYS_GETTOTALREFCOUNT_METHODDEF
968 #endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
969
970 #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
971 #define SYS_GETANDROIDAPILEVEL_METHODDEF
972 #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
973 /*[clinic end generated code: output=39eb34a01fb9a919 input=a9049054013a1b77]*/
974