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