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