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