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