blob: 5df8af1a1172c60b9f137d40a9af7e76b0ea32ef [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
513PyDoc_STRVAR(sys_set_coroutine_wrapper__doc__,
514"set_coroutine_wrapper($module, wrapper, /)\n"
515"--\n"
516"\n"
517"Set a wrapper for coroutine objects.");
518
519#define SYS_SET_COROUTINE_WRAPPER_METHODDEF \
520 {"set_coroutine_wrapper", (PyCFunction)sys_set_coroutine_wrapper, METH_O, sys_set_coroutine_wrapper__doc__},
521
522PyDoc_STRVAR(sys_get_coroutine_wrapper__doc__,
523"get_coroutine_wrapper($module, /)\n"
524"--\n"
525"\n"
526"Return the wrapper for coroutines set by sys.set_coroutine_wrapper.");
527
528#define SYS_GET_COROUTINE_WRAPPER_METHODDEF \
529 {"get_coroutine_wrapper", (PyCFunction)sys_get_coroutine_wrapper, METH_NOARGS, sys_get_coroutine_wrapper__doc__},
530
531static PyObject *
532sys_get_coroutine_wrapper_impl(PyObject *module);
533
534static PyObject *
535sys_get_coroutine_wrapper(PyObject *module, PyObject *Py_UNUSED(ignored))
536{
537 return sys_get_coroutine_wrapper_impl(module);
538}
539
540PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__,
541"get_asyncgen_hooks($module, /)\n"
542"--\n"
543"\n"
544"Return the installed asynchronous generators hooks.\n"
545"\n"
546"This returns a namedtuple of the form (firstiter, finalizer).");
547
548#define SYS_GET_ASYNCGEN_HOOKS_METHODDEF \
549 {"get_asyncgen_hooks", (PyCFunction)sys_get_asyncgen_hooks, METH_NOARGS, sys_get_asyncgen_hooks__doc__},
550
551static PyObject *
552sys_get_asyncgen_hooks_impl(PyObject *module);
553
554static PyObject *
555sys_get_asyncgen_hooks(PyObject *module, PyObject *Py_UNUSED(ignored))
556{
557 return sys_get_asyncgen_hooks_impl(module);
558}
559
560PyDoc_STRVAR(sys_getrecursionlimit__doc__,
561"getrecursionlimit($module, /)\n"
562"--\n"
563"\n"
564"Return the current value of the recursion limit.\n"
565"\n"
566"The recursion limit is the maximum depth of the Python interpreter\n"
567"stack. This limit prevents infinite recursion from causing an overflow\n"
568"of the C stack and crashing Python.");
569
570#define SYS_GETRECURSIONLIMIT_METHODDEF \
571 {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, sys_getrecursionlimit__doc__},
572
573static PyObject *
574sys_getrecursionlimit_impl(PyObject *module);
575
576static PyObject *
577sys_getrecursionlimit(PyObject *module, PyObject *Py_UNUSED(ignored))
578{
579 return sys_getrecursionlimit_impl(module);
580}
581
582#if defined(MS_WINDOWS)
583
584PyDoc_STRVAR(sys_getwindowsversion__doc__,
585"getwindowsversion($module, /)\n"
586"--\n"
587"\n"
588"Return info about the running version of Windows as a named tuple.\n"
589"\n"
590"The members are named: major, minor, build, platform, service_pack,\n"
591"service_pack_major, service_pack_minor, suite_mask, product_type and\n"
592"platform_version. For backward compatibility, only the first 5 items\n"
593"are available by indexing. All elements are numbers, except\n"
594"service_pack and platform_type which are strings, and platform_version\n"
595"which is a 3-tuple. Platform is always 2. Product_type may be 1 for a\n"
596"workstation, 2 for a domain controller, 3 for a server.\n"
597"Platform_version is a 3-tuple containing a version number that is\n"
598"intended for identifying the OS rather than feature detection.");
599
600#define SYS_GETWINDOWSVERSION_METHODDEF \
601 {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, sys_getwindowsversion__doc__},
602
603static PyObject *
604sys_getwindowsversion_impl(PyObject *module);
605
606static PyObject *
607sys_getwindowsversion(PyObject *module, PyObject *Py_UNUSED(ignored))
608{
609 return sys_getwindowsversion_impl(module);
610}
611
612#endif /* defined(MS_WINDOWS) */
613
614#if defined(MS_WINDOWS)
615
616PyDoc_STRVAR(sys__enablelegacywindowsfsencoding__doc__,
617"_enablelegacywindowsfsencoding($module, /)\n"
618"--\n"
619"\n"
620"Changes the default filesystem encoding to mbcs:replace.\n"
621"\n"
622"This is done for consistency with earlier versions of Python. See PEP\n"
623"529 for more information.\n"
624"\n"
625"This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING\n"
626"environment variable before launching Python.");
627
628#define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF \
629 {"_enablelegacywindowsfsencoding", (PyCFunction)sys__enablelegacywindowsfsencoding, METH_NOARGS, sys__enablelegacywindowsfsencoding__doc__},
630
631static PyObject *
632sys__enablelegacywindowsfsencoding_impl(PyObject *module);
633
634static PyObject *
635sys__enablelegacywindowsfsencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
636{
637 return sys__enablelegacywindowsfsencoding_impl(module);
638}
639
640#endif /* defined(MS_WINDOWS) */
641
642#if defined(HAVE_DLOPEN)
643
644PyDoc_STRVAR(sys_setdlopenflags__doc__,
645"setdlopenflags($module, flags, /)\n"
646"--\n"
647"\n"
648"Set the flags used by the interpreter for dlopen calls.\n"
649"\n"
650"This is used, for example, when the interpreter loads extension\n"
651"modules. Among other things, this will enable a lazy resolving of\n"
652"symbols when importing a module, if called as sys.setdlopenflags(0).\n"
653"To share symbols across extension modules, call as\n"
654"sys.setdlopenflags(os.RTLD_GLOBAL). Symbolic names for the flag\n"
655"modules can be found in the os module (RTLD_xxx constants, e.g.\n"
656"os.RTLD_LAZY).");
657
658#define SYS_SETDLOPENFLAGS_METHODDEF \
659 {"setdlopenflags", (PyCFunction)sys_setdlopenflags, METH_O, sys_setdlopenflags__doc__},
660
661static PyObject *
662sys_setdlopenflags_impl(PyObject *module, int new_val);
663
664static PyObject *
665sys_setdlopenflags(PyObject *module, PyObject *arg)
666{
667 PyObject *return_value = NULL;
668 int new_val;
669
670 if (PyFloat_Check(arg)) {
671 PyErr_SetString(PyExc_TypeError,
672 "integer argument expected, got float" );
673 goto exit;
674 }
675 new_val = _PyLong_AsInt(arg);
676 if (new_val == -1 && PyErr_Occurred()) {
677 goto exit;
678 }
679 return_value = sys_setdlopenflags_impl(module, new_val);
680
681exit:
682 return return_value;
683}
684
685#endif /* defined(HAVE_DLOPEN) */
686
687#if defined(HAVE_DLOPEN)
688
689PyDoc_STRVAR(sys_getdlopenflags__doc__,
690"getdlopenflags($module, /)\n"
691"--\n"
692"\n"
693"Return the current value of the flags that are used for dlopen calls.\n"
694"\n"
695"The flag constants are defined in the os module.");
696
697#define SYS_GETDLOPENFLAGS_METHODDEF \
698 {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, sys_getdlopenflags__doc__},
699
700static PyObject *
701sys_getdlopenflags_impl(PyObject *module);
702
703static PyObject *
704sys_getdlopenflags(PyObject *module, PyObject *Py_UNUSED(ignored))
705{
706 return sys_getdlopenflags_impl(module);
707}
708
709#endif /* defined(HAVE_DLOPEN) */
710
711#if defined(USE_MALLOPT)
712
713PyDoc_STRVAR(sys_mdebug__doc__,
714"mdebug($module, flag, /)\n"
715"--\n"
716"\n");
717
718#define SYS_MDEBUG_METHODDEF \
719 {"mdebug", (PyCFunction)sys_mdebug, METH_O, sys_mdebug__doc__},
720
721static PyObject *
722sys_mdebug_impl(PyObject *module, int flag);
723
724static PyObject *
725sys_mdebug(PyObject *module, PyObject *arg)
726{
727 PyObject *return_value = NULL;
728 int flag;
729
730 if (PyFloat_Check(arg)) {
731 PyErr_SetString(PyExc_TypeError,
732 "integer argument expected, got float" );
733 goto exit;
734 }
735 flag = _PyLong_AsInt(arg);
736 if (flag == -1 && PyErr_Occurred()) {
737 goto exit;
738 }
739 return_value = sys_mdebug_impl(module, flag);
740
741exit:
742 return return_value;
743}
744
745#endif /* defined(USE_MALLOPT) */
746
747PyDoc_STRVAR(sys_getrefcount__doc__,
748"getrefcount($module, object, /)\n"
749"--\n"
750"\n"
751"Return the reference count of object.\n"
752"\n"
753"The count returned is generally one higher than you might expect,\n"
754"because it includes the (temporary) reference as an argument to\n"
755"getrefcount().");
756
757#define SYS_GETREFCOUNT_METHODDEF \
758 {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__},
759
760static Py_ssize_t
761sys_getrefcount_impl(PyObject *module, PyObject *object);
762
763static PyObject *
764sys_getrefcount(PyObject *module, PyObject *object)
765{
766 PyObject *return_value = NULL;
767 Py_ssize_t _return_value;
768
769 _return_value = sys_getrefcount_impl(module, object);
770 if ((_return_value == -1) && PyErr_Occurred()) {
771 goto exit;
772 }
773 return_value = PyLong_FromSsize_t(_return_value);
774
775exit:
776 return return_value;
777}
778
779#if defined(Py_REF_DEBUG)
780
781PyDoc_STRVAR(sys_gettotalrefcount__doc__,
782"gettotalrefcount($module, /)\n"
783"--\n"
784"\n");
785
786#define SYS_GETTOTALREFCOUNT_METHODDEF \
787 {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__},
788
789static Py_ssize_t
790sys_gettotalrefcount_impl(PyObject *module);
791
792static PyObject *
793sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored))
794{
795 PyObject *return_value = NULL;
796 Py_ssize_t _return_value;
797
798 _return_value = sys_gettotalrefcount_impl(module);
799 if ((_return_value == -1) && PyErr_Occurred()) {
800 goto exit;
801 }
802 return_value = PyLong_FromSsize_t(_return_value);
803
804exit:
805 return return_value;
806}
807
808#endif /* defined(Py_REF_DEBUG) */
809
810PyDoc_STRVAR(sys_getallocatedblocks__doc__,
811"getallocatedblocks($module, /)\n"
812"--\n"
813"\n"
814"Return the number of memory blocks currently allocated.");
815
816#define SYS_GETALLOCATEDBLOCKS_METHODDEF \
817 {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
818
819static Py_ssize_t
820sys_getallocatedblocks_impl(PyObject *module);
821
822static PyObject *
823sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
824{
825 PyObject *return_value = NULL;
826 Py_ssize_t _return_value;
827
828 _return_value = sys_getallocatedblocks_impl(module);
829 if ((_return_value == -1) && PyErr_Occurred()) {
830 goto exit;
831 }
832 return_value = PyLong_FromSsize_t(_return_value);
833
834exit:
835 return return_value;
836}
837
838#if defined(COUNT_ALLOCS)
839
840PyDoc_STRVAR(sys_getcounts__doc__,
841"getcounts($module, /)\n"
842"--\n"
843"\n");
844
845#define SYS_GETCOUNTS_METHODDEF \
846 {"getcounts", (PyCFunction)sys_getcounts, METH_NOARGS, sys_getcounts__doc__},
847
848static PyObject *
849sys_getcounts_impl(PyObject *module);
850
851static PyObject *
852sys_getcounts(PyObject *module, PyObject *Py_UNUSED(ignored))
853{
854 return sys_getcounts_impl(module);
855}
856
857#endif /* defined(COUNT_ALLOCS) */
858
859PyDoc_STRVAR(sys__getframe__doc__,
860"_getframe($module, depth=0, /)\n"
861"--\n"
862"\n"
863"Return a frame object from the call stack.\n"
864"\n"
865"If optional integer depth is given, return the frame object that many\n"
866"calls below the top of the stack. If that is deeper than the call\n"
867"stack, ValueError is raised. The default for depth is zero, returning\n"
868"the frame at the top of the call stack.\n"
869"\n"
870"This function should be used for internal and specialized purposes\n"
871"only.");
872
873#define SYS__GETFRAME_METHODDEF \
874 {"_getframe", (PyCFunction)(void(*)(void))sys__getframe, METH_FASTCALL, sys__getframe__doc__},
875
876static PyObject *
877sys__getframe_impl(PyObject *module, int depth);
878
879static PyObject *
880sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
881{
882 PyObject *return_value = NULL;
883 int depth = 0;
884
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200885 if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
Tal Einatede0b6f2018-12-31 17:12:08 +0200886 goto exit;
887 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200888 if (nargs < 1) {
889 goto skip_optional;
890 }
891 if (PyFloat_Check(args[0])) {
892 PyErr_SetString(PyExc_TypeError,
893 "integer argument expected, got float" );
894 goto exit;
895 }
896 depth = _PyLong_AsInt(args[0]);
897 if (depth == -1 && PyErr_Occurred()) {
898 goto exit;
899 }
900skip_optional:
Tal Einatede0b6f2018-12-31 17:12:08 +0200901 return_value = sys__getframe_impl(module, depth);
902
903exit:
904 return return_value;
905}
906
907PyDoc_STRVAR(sys__current_frames__doc__,
908"_current_frames($module, /)\n"
909"--\n"
910"\n"
911"Return a dict mapping each thread\'s thread id to its current stack frame.\n"
912"\n"
913"This function should be used for specialized purposes only.");
914
915#define SYS__CURRENT_FRAMES_METHODDEF \
916 {"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__},
917
918static PyObject *
919sys__current_frames_impl(PyObject *module);
920
921static PyObject *
922sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored))
923{
924 return sys__current_frames_impl(module);
925}
926
927PyDoc_STRVAR(sys_call_tracing__doc__,
928"call_tracing($module, func, args, /)\n"
929"--\n"
930"\n"
931"Call func(*args), while tracing is enabled.\n"
932"\n"
933"The tracing state is saved, and restored afterwards. This is intended\n"
934"to be called from a debugger from a checkpoint, to recursively debug\n"
935"some other code.");
936
937#define SYS_CALL_TRACING_METHODDEF \
938 {"call_tracing", (PyCFunction)(void(*)(void))sys_call_tracing, METH_FASTCALL, sys_call_tracing__doc__},
939
940static PyObject *
941sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs);
942
943static PyObject *
944sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
945{
946 PyObject *return_value = NULL;
947 PyObject *func;
948 PyObject *funcargs;
949
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200950 if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
Tal Einatede0b6f2018-12-31 17:12:08 +0200951 goto exit;
952 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200953 func = args[0];
954 if (!PyTuple_Check(args[1])) {
955 _PyArg_BadArgument("call_tracing", 2, "tuple", args[1]);
956 goto exit;
957 }
958 funcargs = args[1];
Tal Einatede0b6f2018-12-31 17:12:08 +0200959 return_value = sys_call_tracing_impl(module, func, funcargs);
960
961exit:
962 return return_value;
963}
964
965PyDoc_STRVAR(sys_callstats__doc__,
966"callstats($module, /)\n"
967"--\n"
968"\n"
969"Return a tuple of function call statistics.\n"
970"\n"
971"A tuple is returned only if CALL_PROFILE was defined when Python was\n"
972"built. Otherwise, this returns None.\n"
973"\n"
974"When enabled, this function returns detailed, implementation-specific\n"
975"details about the number of function calls executed. The return value\n"
976"is a 11-tuple where the entries in the tuple are counts of:\n"
977"0. all function calls\n"
978"1. calls to PyFunction_Type objects\n"
979"2. PyFunction calls that do not create an argument tuple\n"
980"3. PyFunction calls that do not create an argument tuple\n"
981" and bypass PyEval_EvalCodeEx()\n"
982"4. PyMethod calls\n"
983"5. PyMethod calls on bound methods\n"
984"6. PyType calls\n"
985"7. PyCFunction calls\n"
986"8. generator calls\n"
987"9. All other calls\n"
988"10. Number of stack pops performed by call_function()");
989
990#define SYS_CALLSTATS_METHODDEF \
991 {"callstats", (PyCFunction)sys_callstats, METH_NOARGS, sys_callstats__doc__},
992
993static PyObject *
994sys_callstats_impl(PyObject *module);
995
996static PyObject *
997sys_callstats(PyObject *module, PyObject *Py_UNUSED(ignored))
998{
999 return sys_callstats_impl(module);
1000}
1001
1002PyDoc_STRVAR(sys__debugmallocstats__doc__,
1003"_debugmallocstats($module, /)\n"
1004"--\n"
1005"\n"
1006"Print summary info to stderr about the state of pymalloc\'s structures.\n"
1007"\n"
1008"In Py_DEBUG mode, also perform some expensive internal consistency\n"
1009"checks.");
1010
1011#define SYS__DEBUGMALLOCSTATS_METHODDEF \
1012 {"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__},
1013
1014static PyObject *
1015sys__debugmallocstats_impl(PyObject *module);
1016
1017static PyObject *
1018sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored))
1019{
1020 return sys__debugmallocstats_impl(module);
1021}
1022
1023PyDoc_STRVAR(sys__clear_type_cache__doc__,
1024"_clear_type_cache($module, /)\n"
1025"--\n"
1026"\n"
1027"Clear the internal type lookup cache.");
1028
1029#define SYS__CLEAR_TYPE_CACHE_METHODDEF \
1030 {"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__},
1031
1032static PyObject *
1033sys__clear_type_cache_impl(PyObject *module);
1034
1035static PyObject *
1036sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored))
1037{
1038 return sys__clear_type_cache_impl(module);
1039}
1040
1041PyDoc_STRVAR(sys_is_finalizing__doc__,
1042"is_finalizing($module, /)\n"
1043"--\n"
1044"\n"
1045"Return True if Python is exiting.");
1046
1047#define SYS_IS_FINALIZING_METHODDEF \
1048 {"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__},
1049
1050static PyObject *
1051sys_is_finalizing_impl(PyObject *module);
1052
1053static PyObject *
1054sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
1055{
1056 return sys_is_finalizing_impl(module);
1057}
1058
1059#if defined(ANDROID_API_LEVEL)
1060
1061PyDoc_STRVAR(sys_getandroidapilevel__doc__,
1062"getandroidapilevel($module, /)\n"
1063"--\n"
1064"\n"
1065"Return the build time API version of Android as an integer.");
1066
1067#define SYS_GETANDROIDAPILEVEL_METHODDEF \
1068 {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__},
1069
1070static PyObject *
1071sys_getandroidapilevel_impl(PyObject *module);
1072
1073static PyObject *
1074sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
1075{
1076 return sys_getandroidapilevel_impl(module);
1077}
1078
1079#endif /* defined(ANDROID_API_LEVEL) */
1080
1081#ifndef SYS_GETWINDOWSVERSION_METHODDEF
1082 #define SYS_GETWINDOWSVERSION_METHODDEF
1083#endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
1084
1085#ifndef SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1086 #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1087#endif /* !defined(SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF) */
1088
1089#ifndef SYS_SETDLOPENFLAGS_METHODDEF
1090 #define SYS_SETDLOPENFLAGS_METHODDEF
1091#endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */
1092
1093#ifndef SYS_GETDLOPENFLAGS_METHODDEF
1094 #define SYS_GETDLOPENFLAGS_METHODDEF
1095#endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */
1096
1097#ifndef SYS_MDEBUG_METHODDEF
1098 #define SYS_MDEBUG_METHODDEF
1099#endif /* !defined(SYS_MDEBUG_METHODDEF) */
1100
1101#ifndef SYS_GETTOTALREFCOUNT_METHODDEF
1102 #define SYS_GETTOTALREFCOUNT_METHODDEF
1103#endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
1104
1105#ifndef SYS_GETCOUNTS_METHODDEF
1106 #define SYS_GETCOUNTS_METHODDEF
1107#endif /* !defined(SYS_GETCOUNTS_METHODDEF) */
1108
1109#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
1110 #define SYS_GETANDROIDAPILEVEL_METHODDEF
1111#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
Victor Stinner71c52e32019-05-27 08:57:14 +02001112/*[clinic end generated code: output=03da2eb03135d9f2 input=a9049054013a1b77]*/