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