blob: d2d1503926205d0be172849ad176793764ad0516 [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;
Serhiy Storchakad322abb2019-09-14 13:31:50 +0300138 PyObject *status = Py_None;
Tal Einatede0b6f2018-12-31 17:12:08 +0200139
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 Storchaka96631dc2019-08-29 18:29:59 +0300231 _PyArg_BadArgument("intern", "argument", "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
Raymond Hettinger21161d72019-08-24 19:45:12 -0700365 if (PyFloat_CheckExact(arg)) {
366 interval = PyFloat_AS_DOUBLE(arg);
367 }
368 else
369 {
370 interval = PyFloat_AsDouble(arg);
371 if (interval == -1.0 && PyErr_Occurred()) {
372 goto exit;
373 }
Tal Einatede0b6f2018-12-31 17:12:08 +0200374 }
375 return_value = sys_setswitchinterval_impl(module, interval);
376
377exit:
378 return return_value;
379}
380
381PyDoc_STRVAR(sys_getswitchinterval__doc__,
382"getswitchinterval($module, /)\n"
383"--\n"
384"\n"
385"Return the current thread switch interval; see sys.setswitchinterval().");
386
387#define SYS_GETSWITCHINTERVAL_METHODDEF \
388 {"getswitchinterval", (PyCFunction)sys_getswitchinterval, METH_NOARGS, sys_getswitchinterval__doc__},
389
390static double
391sys_getswitchinterval_impl(PyObject *module);
392
393static PyObject *
394sys_getswitchinterval(PyObject *module, PyObject *Py_UNUSED(ignored))
395{
396 PyObject *return_value = NULL;
397 double _return_value;
398
399 _return_value = sys_getswitchinterval_impl(module);
400 if ((_return_value == -1.0) && PyErr_Occurred()) {
401 goto exit;
402 }
403 return_value = PyFloat_FromDouble(_return_value);
404
405exit:
406 return return_value;
407}
408
409PyDoc_STRVAR(sys_setrecursionlimit__doc__,
410"setrecursionlimit($module, limit, /)\n"
411"--\n"
412"\n"
413"Set the maximum depth of the Python interpreter stack to n.\n"
414"\n"
415"This limit prevents infinite recursion from causing an overflow of the C\n"
416"stack and crashing Python. The highest possible limit is platform-\n"
417"dependent.");
418
419#define SYS_SETRECURSIONLIMIT_METHODDEF \
420 {"setrecursionlimit", (PyCFunction)sys_setrecursionlimit, METH_O, sys_setrecursionlimit__doc__},
421
422static PyObject *
423sys_setrecursionlimit_impl(PyObject *module, int new_limit);
424
425static PyObject *
426sys_setrecursionlimit(PyObject *module, PyObject *arg)
427{
428 PyObject *return_value = NULL;
429 int new_limit;
430
431 if (PyFloat_Check(arg)) {
432 PyErr_SetString(PyExc_TypeError,
433 "integer argument expected, got float" );
434 goto exit;
435 }
436 new_limit = _PyLong_AsInt(arg);
437 if (new_limit == -1 && PyErr_Occurred()) {
438 goto exit;
439 }
440 return_value = sys_setrecursionlimit_impl(module, new_limit);
441
442exit:
443 return return_value;
444}
445
Nathaniel J. Smithfc2f4072018-01-21 06:44:07 -0800446PyDoc_STRVAR(sys_set_coroutine_origin_tracking_depth__doc__,
447"set_coroutine_origin_tracking_depth($module, /, depth)\n"
448"--\n"
449"\n"
450"Enable or disable origin tracking for coroutine objects in this thread.\n"
451"\n"
Tal Einatede0b6f2018-12-31 17:12:08 +0200452"Coroutine objects will track \'depth\' frames of traceback information\n"
453"about where they came from, available in their cr_origin attribute.\n"
454"\n"
455"Set a depth of 0 to disable.");
Nathaniel J. Smithfc2f4072018-01-21 06:44:07 -0800456
457#define SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +0200458 {"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 -0800459
460static PyObject *
461sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth);
462
463static PyObject *
464sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
465{
466 PyObject *return_value = NULL;
467 static const char * const _keywords[] = {"depth", NULL};
Serhiy Storchaka31913912019-03-14 10:32:22 +0200468 static _PyArg_Parser _parser = {NULL, _keywords, "set_coroutine_origin_tracking_depth", 0};
469 PyObject *argsbuf[1];
Nathaniel J. Smithfc2f4072018-01-21 06:44:07 -0800470 int depth;
471
Serhiy Storchaka31913912019-03-14 10:32:22 +0200472 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
473 if (!args) {
474 goto exit;
475 }
476 if (PyFloat_Check(args[0])) {
477 PyErr_SetString(PyExc_TypeError,
478 "integer argument expected, got float" );
479 goto exit;
480 }
481 depth = _PyLong_AsInt(args[0]);
482 if (depth == -1 && PyErr_Occurred()) {
Nathaniel J. Smithfc2f4072018-01-21 06:44:07 -0800483 goto exit;
484 }
485 return_value = sys_set_coroutine_origin_tracking_depth_impl(module, depth);
486
487exit:
488 return return_value;
489}
490
491PyDoc_STRVAR(sys_get_coroutine_origin_tracking_depth__doc__,
492"get_coroutine_origin_tracking_depth($module, /)\n"
493"--\n"
494"\n"
495"Check status of origin tracking for coroutine objects in this thread.");
496
497#define SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
498 {"get_coroutine_origin_tracking_depth", (PyCFunction)sys_get_coroutine_origin_tracking_depth, METH_NOARGS, sys_get_coroutine_origin_tracking_depth__doc__},
499
500static int
501sys_get_coroutine_origin_tracking_depth_impl(PyObject *module);
502
503static PyObject *
504sys_get_coroutine_origin_tracking_depth(PyObject *module, PyObject *Py_UNUSED(ignored))
505{
506 PyObject *return_value = NULL;
507 int _return_value;
508
509 _return_value = sys_get_coroutine_origin_tracking_depth_impl(module);
510 if ((_return_value == -1) && PyErr_Occurred()) {
511 goto exit;
512 }
513 return_value = PyLong_FromLong((long)_return_value);
514
515exit:
516 return return_value;
517}
Tal Einatede0b6f2018-12-31 17:12:08 +0200518
Tal Einatede0b6f2018-12-31 17:12:08 +0200519PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__,
520"get_asyncgen_hooks($module, /)\n"
521"--\n"
522"\n"
523"Return the installed asynchronous generators hooks.\n"
524"\n"
525"This returns a namedtuple of the form (firstiter, finalizer).");
526
527#define SYS_GET_ASYNCGEN_HOOKS_METHODDEF \
528 {"get_asyncgen_hooks", (PyCFunction)sys_get_asyncgen_hooks, METH_NOARGS, sys_get_asyncgen_hooks__doc__},
529
530static PyObject *
531sys_get_asyncgen_hooks_impl(PyObject *module);
532
533static PyObject *
534sys_get_asyncgen_hooks(PyObject *module, PyObject *Py_UNUSED(ignored))
535{
536 return sys_get_asyncgen_hooks_impl(module);
537}
538
539PyDoc_STRVAR(sys_getrecursionlimit__doc__,
540"getrecursionlimit($module, /)\n"
541"--\n"
542"\n"
543"Return the current value of the recursion limit.\n"
544"\n"
545"The recursion limit is the maximum depth of the Python interpreter\n"
546"stack. This limit prevents infinite recursion from causing an overflow\n"
547"of the C stack and crashing Python.");
548
549#define SYS_GETRECURSIONLIMIT_METHODDEF \
550 {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, sys_getrecursionlimit__doc__},
551
552static PyObject *
553sys_getrecursionlimit_impl(PyObject *module);
554
555static PyObject *
556sys_getrecursionlimit(PyObject *module, PyObject *Py_UNUSED(ignored))
557{
558 return sys_getrecursionlimit_impl(module);
559}
560
561#if defined(MS_WINDOWS)
562
563PyDoc_STRVAR(sys_getwindowsversion__doc__,
564"getwindowsversion($module, /)\n"
565"--\n"
566"\n"
567"Return info about the running version of Windows as a named tuple.\n"
568"\n"
569"The members are named: major, minor, build, platform, service_pack,\n"
570"service_pack_major, service_pack_minor, suite_mask, product_type and\n"
571"platform_version. For backward compatibility, only the first 5 items\n"
572"are available by indexing. All elements are numbers, except\n"
573"service_pack and platform_type which are strings, and platform_version\n"
574"which is a 3-tuple. Platform is always 2. Product_type may be 1 for a\n"
575"workstation, 2 for a domain controller, 3 for a server.\n"
576"Platform_version is a 3-tuple containing a version number that is\n"
577"intended for identifying the OS rather than feature detection.");
578
579#define SYS_GETWINDOWSVERSION_METHODDEF \
580 {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, sys_getwindowsversion__doc__},
581
582static PyObject *
583sys_getwindowsversion_impl(PyObject *module);
584
585static PyObject *
586sys_getwindowsversion(PyObject *module, PyObject *Py_UNUSED(ignored))
587{
588 return sys_getwindowsversion_impl(module);
589}
590
591#endif /* defined(MS_WINDOWS) */
592
593#if defined(MS_WINDOWS)
594
595PyDoc_STRVAR(sys__enablelegacywindowsfsencoding__doc__,
596"_enablelegacywindowsfsencoding($module, /)\n"
597"--\n"
598"\n"
599"Changes the default filesystem encoding to mbcs:replace.\n"
600"\n"
601"This is done for consistency with earlier versions of Python. See PEP\n"
602"529 for more information.\n"
603"\n"
604"This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING\n"
605"environment variable before launching Python.");
606
607#define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF \
608 {"_enablelegacywindowsfsencoding", (PyCFunction)sys__enablelegacywindowsfsencoding, METH_NOARGS, sys__enablelegacywindowsfsencoding__doc__},
609
610static PyObject *
611sys__enablelegacywindowsfsencoding_impl(PyObject *module);
612
613static PyObject *
614sys__enablelegacywindowsfsencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
615{
616 return sys__enablelegacywindowsfsencoding_impl(module);
617}
618
619#endif /* defined(MS_WINDOWS) */
620
621#if defined(HAVE_DLOPEN)
622
623PyDoc_STRVAR(sys_setdlopenflags__doc__,
624"setdlopenflags($module, flags, /)\n"
625"--\n"
626"\n"
627"Set the flags used by the interpreter for dlopen calls.\n"
628"\n"
629"This is used, for example, when the interpreter loads extension\n"
630"modules. Among other things, this will enable a lazy resolving of\n"
631"symbols when importing a module, if called as sys.setdlopenflags(0).\n"
632"To share symbols across extension modules, call as\n"
633"sys.setdlopenflags(os.RTLD_GLOBAL). Symbolic names for the flag\n"
634"modules can be found in the os module (RTLD_xxx constants, e.g.\n"
635"os.RTLD_LAZY).");
636
637#define SYS_SETDLOPENFLAGS_METHODDEF \
638 {"setdlopenflags", (PyCFunction)sys_setdlopenflags, METH_O, sys_setdlopenflags__doc__},
639
640static PyObject *
641sys_setdlopenflags_impl(PyObject *module, int new_val);
642
643static PyObject *
644sys_setdlopenflags(PyObject *module, PyObject *arg)
645{
646 PyObject *return_value = NULL;
647 int new_val;
648
649 if (PyFloat_Check(arg)) {
650 PyErr_SetString(PyExc_TypeError,
651 "integer argument expected, got float" );
652 goto exit;
653 }
654 new_val = _PyLong_AsInt(arg);
655 if (new_val == -1 && PyErr_Occurred()) {
656 goto exit;
657 }
658 return_value = sys_setdlopenflags_impl(module, new_val);
659
660exit:
661 return return_value;
662}
663
664#endif /* defined(HAVE_DLOPEN) */
665
666#if defined(HAVE_DLOPEN)
667
668PyDoc_STRVAR(sys_getdlopenflags__doc__,
669"getdlopenflags($module, /)\n"
670"--\n"
671"\n"
672"Return the current value of the flags that are used for dlopen calls.\n"
673"\n"
674"The flag constants are defined in the os module.");
675
676#define SYS_GETDLOPENFLAGS_METHODDEF \
677 {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, sys_getdlopenflags__doc__},
678
679static PyObject *
680sys_getdlopenflags_impl(PyObject *module);
681
682static PyObject *
683sys_getdlopenflags(PyObject *module, PyObject *Py_UNUSED(ignored))
684{
685 return sys_getdlopenflags_impl(module);
686}
687
688#endif /* defined(HAVE_DLOPEN) */
689
690#if defined(USE_MALLOPT)
691
692PyDoc_STRVAR(sys_mdebug__doc__,
693"mdebug($module, flag, /)\n"
694"--\n"
695"\n");
696
697#define SYS_MDEBUG_METHODDEF \
698 {"mdebug", (PyCFunction)sys_mdebug, METH_O, sys_mdebug__doc__},
699
700static PyObject *
701sys_mdebug_impl(PyObject *module, int flag);
702
703static PyObject *
704sys_mdebug(PyObject *module, PyObject *arg)
705{
706 PyObject *return_value = NULL;
707 int flag;
708
709 if (PyFloat_Check(arg)) {
710 PyErr_SetString(PyExc_TypeError,
711 "integer argument expected, got float" );
712 goto exit;
713 }
714 flag = _PyLong_AsInt(arg);
715 if (flag == -1 && PyErr_Occurred()) {
716 goto exit;
717 }
718 return_value = sys_mdebug_impl(module, flag);
719
720exit:
721 return return_value;
722}
723
724#endif /* defined(USE_MALLOPT) */
725
726PyDoc_STRVAR(sys_getrefcount__doc__,
727"getrefcount($module, object, /)\n"
728"--\n"
729"\n"
730"Return the reference count of object.\n"
731"\n"
732"The count returned is generally one higher than you might expect,\n"
733"because it includes the (temporary) reference as an argument to\n"
734"getrefcount().");
735
736#define SYS_GETREFCOUNT_METHODDEF \
737 {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__},
738
739static Py_ssize_t
740sys_getrefcount_impl(PyObject *module, PyObject *object);
741
742static PyObject *
743sys_getrefcount(PyObject *module, PyObject *object)
744{
745 PyObject *return_value = NULL;
746 Py_ssize_t _return_value;
747
748 _return_value = sys_getrefcount_impl(module, object);
749 if ((_return_value == -1) && PyErr_Occurred()) {
750 goto exit;
751 }
752 return_value = PyLong_FromSsize_t(_return_value);
753
754exit:
755 return return_value;
756}
757
758#if defined(Py_REF_DEBUG)
759
760PyDoc_STRVAR(sys_gettotalrefcount__doc__,
761"gettotalrefcount($module, /)\n"
762"--\n"
763"\n");
764
765#define SYS_GETTOTALREFCOUNT_METHODDEF \
766 {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__},
767
768static Py_ssize_t
769sys_gettotalrefcount_impl(PyObject *module);
770
771static PyObject *
772sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored))
773{
774 PyObject *return_value = NULL;
775 Py_ssize_t _return_value;
776
777 _return_value = sys_gettotalrefcount_impl(module);
778 if ((_return_value == -1) && PyErr_Occurred()) {
779 goto exit;
780 }
781 return_value = PyLong_FromSsize_t(_return_value);
782
783exit:
784 return return_value;
785}
786
787#endif /* defined(Py_REF_DEBUG) */
788
789PyDoc_STRVAR(sys_getallocatedblocks__doc__,
790"getallocatedblocks($module, /)\n"
791"--\n"
792"\n"
793"Return the number of memory blocks currently allocated.");
794
795#define SYS_GETALLOCATEDBLOCKS_METHODDEF \
796 {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
797
798static Py_ssize_t
799sys_getallocatedblocks_impl(PyObject *module);
800
801static PyObject *
802sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
803{
804 PyObject *return_value = NULL;
805 Py_ssize_t _return_value;
806
807 _return_value = sys_getallocatedblocks_impl(module);
808 if ((_return_value == -1) && PyErr_Occurred()) {
809 goto exit;
810 }
811 return_value = PyLong_FromSsize_t(_return_value);
812
813exit:
814 return return_value;
815}
816
817#if defined(COUNT_ALLOCS)
818
819PyDoc_STRVAR(sys_getcounts__doc__,
820"getcounts($module, /)\n"
821"--\n"
822"\n");
823
824#define SYS_GETCOUNTS_METHODDEF \
825 {"getcounts", (PyCFunction)sys_getcounts, METH_NOARGS, sys_getcounts__doc__},
826
827static PyObject *
828sys_getcounts_impl(PyObject *module);
829
830static PyObject *
831sys_getcounts(PyObject *module, PyObject *Py_UNUSED(ignored))
832{
833 return sys_getcounts_impl(module);
834}
835
836#endif /* defined(COUNT_ALLOCS) */
837
838PyDoc_STRVAR(sys__getframe__doc__,
839"_getframe($module, depth=0, /)\n"
840"--\n"
841"\n"
842"Return a frame object from the call stack.\n"
843"\n"
844"If optional integer depth is given, return the frame object that many\n"
845"calls below the top of the stack. If that is deeper than the call\n"
846"stack, ValueError is raised. The default for depth is zero, returning\n"
847"the frame at the top of the call stack.\n"
848"\n"
849"This function should be used for internal and specialized purposes\n"
850"only.");
851
852#define SYS__GETFRAME_METHODDEF \
853 {"_getframe", (PyCFunction)(void(*)(void))sys__getframe, METH_FASTCALL, sys__getframe__doc__},
854
855static PyObject *
856sys__getframe_impl(PyObject *module, int depth);
857
858static PyObject *
859sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
860{
861 PyObject *return_value = NULL;
862 int depth = 0;
863
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200864 if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
Tal Einatede0b6f2018-12-31 17:12:08 +0200865 goto exit;
866 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200867 if (nargs < 1) {
868 goto skip_optional;
869 }
870 if (PyFloat_Check(args[0])) {
871 PyErr_SetString(PyExc_TypeError,
872 "integer argument expected, got float" );
873 goto exit;
874 }
875 depth = _PyLong_AsInt(args[0]);
876 if (depth == -1 && PyErr_Occurred()) {
877 goto exit;
878 }
879skip_optional:
Tal Einatede0b6f2018-12-31 17:12:08 +0200880 return_value = sys__getframe_impl(module, depth);
881
882exit:
883 return return_value;
884}
885
886PyDoc_STRVAR(sys__current_frames__doc__,
887"_current_frames($module, /)\n"
888"--\n"
889"\n"
890"Return a dict mapping each thread\'s thread id to its current stack frame.\n"
891"\n"
892"This function should be used for specialized purposes only.");
893
894#define SYS__CURRENT_FRAMES_METHODDEF \
895 {"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__},
896
897static PyObject *
898sys__current_frames_impl(PyObject *module);
899
900static PyObject *
901sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored))
902{
903 return sys__current_frames_impl(module);
904}
905
906PyDoc_STRVAR(sys_call_tracing__doc__,
907"call_tracing($module, func, args, /)\n"
908"--\n"
909"\n"
910"Call func(*args), while tracing is enabled.\n"
911"\n"
912"The tracing state is saved, and restored afterwards. This is intended\n"
913"to be called from a debugger from a checkpoint, to recursively debug\n"
914"some other code.");
915
916#define SYS_CALL_TRACING_METHODDEF \
917 {"call_tracing", (PyCFunction)(void(*)(void))sys_call_tracing, METH_FASTCALL, sys_call_tracing__doc__},
918
919static PyObject *
920sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs);
921
922static PyObject *
923sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
924{
925 PyObject *return_value = NULL;
926 PyObject *func;
927 PyObject *funcargs;
928
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200929 if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
Tal Einatede0b6f2018-12-31 17:12:08 +0200930 goto exit;
931 }
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200932 func = args[0];
933 if (!PyTuple_Check(args[1])) {
Serhiy Storchaka96631dc2019-08-29 18:29:59 +0300934 _PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]);
Serhiy Storchaka4fa95912019-01-11 16:01:14 +0200935 goto exit;
936 }
937 funcargs = args[1];
Tal Einatede0b6f2018-12-31 17:12:08 +0200938 return_value = sys_call_tracing_impl(module, func, funcargs);
939
940exit:
941 return return_value;
942}
943
944PyDoc_STRVAR(sys_callstats__doc__,
945"callstats($module, /)\n"
946"--\n"
947"\n"
948"Return a tuple of function call statistics.\n"
949"\n"
950"A tuple is returned only if CALL_PROFILE was defined when Python was\n"
951"built. Otherwise, this returns None.\n"
952"\n"
953"When enabled, this function returns detailed, implementation-specific\n"
954"details about the number of function calls executed. The return value\n"
955"is a 11-tuple where the entries in the tuple are counts of:\n"
956"0. all function calls\n"
957"1. calls to PyFunction_Type objects\n"
958"2. PyFunction calls that do not create an argument tuple\n"
959"3. PyFunction calls that do not create an argument tuple\n"
960" and bypass PyEval_EvalCodeEx()\n"
961"4. PyMethod calls\n"
962"5. PyMethod calls on bound methods\n"
963"6. PyType calls\n"
964"7. PyCFunction calls\n"
965"8. generator calls\n"
966"9. All other calls\n"
967"10. Number of stack pops performed by call_function()");
968
969#define SYS_CALLSTATS_METHODDEF \
970 {"callstats", (PyCFunction)sys_callstats, METH_NOARGS, sys_callstats__doc__},
971
972static PyObject *
973sys_callstats_impl(PyObject *module);
974
975static PyObject *
976sys_callstats(PyObject *module, PyObject *Py_UNUSED(ignored))
977{
978 return sys_callstats_impl(module);
979}
980
981PyDoc_STRVAR(sys__debugmallocstats__doc__,
982"_debugmallocstats($module, /)\n"
983"--\n"
984"\n"
985"Print summary info to stderr about the state of pymalloc\'s structures.\n"
986"\n"
987"In Py_DEBUG mode, also perform some expensive internal consistency\n"
988"checks.");
989
990#define SYS__DEBUGMALLOCSTATS_METHODDEF \
991 {"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__},
992
993static PyObject *
994sys__debugmallocstats_impl(PyObject *module);
995
996static PyObject *
997sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored))
998{
999 return sys__debugmallocstats_impl(module);
1000}
1001
1002PyDoc_STRVAR(sys__clear_type_cache__doc__,
1003"_clear_type_cache($module, /)\n"
1004"--\n"
1005"\n"
1006"Clear the internal type lookup cache.");
1007
1008#define SYS__CLEAR_TYPE_CACHE_METHODDEF \
1009 {"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__},
1010
1011static PyObject *
1012sys__clear_type_cache_impl(PyObject *module);
1013
1014static PyObject *
1015sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored))
1016{
1017 return sys__clear_type_cache_impl(module);
1018}
1019
1020PyDoc_STRVAR(sys_is_finalizing__doc__,
1021"is_finalizing($module, /)\n"
1022"--\n"
1023"\n"
1024"Return True if Python is exiting.");
1025
1026#define SYS_IS_FINALIZING_METHODDEF \
1027 {"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__},
1028
1029static PyObject *
1030sys_is_finalizing_impl(PyObject *module);
1031
1032static PyObject *
1033sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
1034{
1035 return sys_is_finalizing_impl(module);
1036}
1037
1038#if defined(ANDROID_API_LEVEL)
1039
1040PyDoc_STRVAR(sys_getandroidapilevel__doc__,
1041"getandroidapilevel($module, /)\n"
1042"--\n"
1043"\n"
1044"Return the build time API version of Android as an integer.");
1045
1046#define SYS_GETANDROIDAPILEVEL_METHODDEF \
1047 {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__},
1048
1049static PyObject *
1050sys_getandroidapilevel_impl(PyObject *module);
1051
1052static PyObject *
1053sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
1054{
1055 return sys_getandroidapilevel_impl(module);
1056}
1057
1058#endif /* defined(ANDROID_API_LEVEL) */
1059
1060#ifndef SYS_GETWINDOWSVERSION_METHODDEF
1061 #define SYS_GETWINDOWSVERSION_METHODDEF
1062#endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
1063
1064#ifndef SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1065 #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1066#endif /* !defined(SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF) */
1067
1068#ifndef SYS_SETDLOPENFLAGS_METHODDEF
1069 #define SYS_SETDLOPENFLAGS_METHODDEF
1070#endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */
1071
1072#ifndef SYS_GETDLOPENFLAGS_METHODDEF
1073 #define SYS_GETDLOPENFLAGS_METHODDEF
1074#endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */
1075
1076#ifndef SYS_MDEBUG_METHODDEF
1077 #define SYS_MDEBUG_METHODDEF
1078#endif /* !defined(SYS_MDEBUG_METHODDEF) */
1079
1080#ifndef SYS_GETTOTALREFCOUNT_METHODDEF
1081 #define SYS_GETTOTALREFCOUNT_METHODDEF
1082#endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
1083
1084#ifndef SYS_GETCOUNTS_METHODDEF
1085 #define SYS_GETCOUNTS_METHODDEF
1086#endif /* !defined(SYS_GETCOUNTS_METHODDEF) */
1087
1088#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
1089 #define SYS_GETANDROIDAPILEVEL_METHODDEF
1090#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
Serhiy Storchakad322abb2019-09-14 13:31:50 +03001091/*[clinic end generated code: output=273f9cec8bfcab91 input=a9049054013a1b77]*/