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