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