Coverage Report

Created: 2025-07-04 06:49

/src/cpython/Python/clinic/sysmodule.c.h
Line
Count
Source (jump to first uncovered line)
1
/*[clinic input]
2
preserve
3
[clinic start generated code]*/
4
5
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6
#  include "pycore_gc.h"          // PyGC_Head
7
#  include "pycore_runtime.h"     // _Py_ID()
8
#endif
9
#include "pycore_modsupport.h"    // _PyArg_UnpackKeywords()
10
#include "pycore_tuple.h"         // _PyTuple_FromArray()
11
12
PyDoc_STRVAR(sys_addaudithook__doc__,
13
"addaudithook($module, /, hook)\n"
14
"--\n"
15
"\n"
16
"Adds a new audit hook callback.");
17
18
#define SYS_ADDAUDITHOOK_METHODDEF    \
19
    {"addaudithook", _PyCFunction_CAST(sys_addaudithook), METH_FASTCALL|METH_KEYWORDS, sys_addaudithook__doc__},
20
21
static PyObject *
22
sys_addaudithook_impl(PyObject *module, PyObject *hook);
23
24
static PyObject *
25
sys_addaudithook(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
26
0
{
27
0
    PyObject *return_value = NULL;
28
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
29
30
0
    #define NUM_KEYWORDS 1
31
0
    static struct {
32
0
        PyGC_Head _this_is_not_used;
33
0
        PyObject_VAR_HEAD
34
0
        Py_hash_t ob_hash;
35
0
        PyObject *ob_item[NUM_KEYWORDS];
36
0
    } _kwtuple = {
37
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
38
0
        .ob_hash = -1,
39
0
        .ob_item = { &_Py_ID(hook), },
40
0
    };
41
0
    #undef NUM_KEYWORDS
42
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
43
44
    #else  // !Py_BUILD_CORE
45
    #  define KWTUPLE NULL
46
    #endif  // !Py_BUILD_CORE
47
48
0
    static const char * const _keywords[] = {"hook", NULL};
49
0
    static _PyArg_Parser _parser = {
50
0
        .keywords = _keywords,
51
0
        .fname = "addaudithook",
52
0
        .kwtuple = KWTUPLE,
53
0
    };
54
0
    #undef KWTUPLE
55
0
    PyObject *argsbuf[1];
56
0
    PyObject *hook;
57
58
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
59
0
            /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
60
0
    if (!args) {
61
0
        goto exit;
62
0
    }
63
0
    hook = args[0];
64
0
    return_value = sys_addaudithook_impl(module, hook);
65
66
0
exit:
67
0
    return return_value;
68
0
}
69
70
PyDoc_STRVAR(sys_audit__doc__,
71
"audit($module, event, /, *args)\n"
72
"--\n"
73
"\n"
74
"Passes the event to any audit hooks that are attached.");
75
76
#define SYS_AUDIT_METHODDEF    \
77
    {"audit", _PyCFunction_CAST(sys_audit), METH_FASTCALL, sys_audit__doc__},
78
79
static PyObject *
80
sys_audit_impl(PyObject *module, const char *event, PyObject *args);
81
82
static PyObject *
83
sys_audit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
84
0
{
85
0
    PyObject *return_value = NULL;
86
0
    const char *event;
87
0
    PyObject *__clinic_args = NULL;
88
89
0
    if (!_PyArg_CheckPositional("audit", nargs, 1, PY_SSIZE_T_MAX)) {
90
0
        goto exit;
91
0
    }
92
0
    if (!PyUnicode_Check(args[0])) {
93
0
        _PyArg_BadArgument("audit", "argument 1", "str", args[0]);
94
0
        goto exit;
95
0
    }
96
0
    Py_ssize_t event_length;
97
0
    event = PyUnicode_AsUTF8AndSize(args[0], &event_length);
98
0
    if (event == NULL) {
99
0
        goto exit;
100
0
    }
101
0
    if (strlen(event) != (size_t)event_length) {
102
0
        PyErr_SetString(PyExc_ValueError, "embedded null character");
103
0
        goto exit;
104
0
    }
105
0
    __clinic_args = _PyTuple_FromArray(args + 1, nargs - 1);
106
0
    if (__clinic_args == NULL) {
107
0
        goto exit;
108
0
    }
109
0
    return_value = sys_audit_impl(module, event, __clinic_args);
110
111
0
exit:
112
    /* Cleanup for args */
113
0
    Py_XDECREF(__clinic_args);
114
115
0
    return return_value;
116
0
}
117
118
PyDoc_STRVAR(sys_displayhook__doc__,
119
"displayhook($module, object, /)\n"
120
"--\n"
121
"\n"
122
"Print an object to sys.stdout and also save it in builtins._");
123
124
#define SYS_DISPLAYHOOK_METHODDEF    \
125
    {"displayhook", (PyCFunction)sys_displayhook, METH_O, sys_displayhook__doc__},
126
127
PyDoc_STRVAR(sys_excepthook__doc__,
128
"excepthook($module, exctype, value, traceback, /)\n"
129
"--\n"
130
"\n"
131
"Handle an exception by displaying it with a traceback on sys.stderr.");
132
133
#define SYS_EXCEPTHOOK_METHODDEF    \
134
    {"excepthook", _PyCFunction_CAST(sys_excepthook), METH_FASTCALL, sys_excepthook__doc__},
135
136
static PyObject *
137
sys_excepthook_impl(PyObject *module, PyObject *exctype, PyObject *value,
138
                    PyObject *traceback);
139
140
static PyObject *
141
sys_excepthook(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
142
0
{
143
0
    PyObject *return_value = NULL;
144
0
    PyObject *exctype;
145
0
    PyObject *value;
146
0
    PyObject *traceback;
147
148
0
    if (!_PyArg_CheckPositional("excepthook", nargs, 3, 3)) {
149
0
        goto exit;
150
0
    }
151
0
    exctype = args[0];
152
0
    value = args[1];
153
0
    traceback = args[2];
154
0
    return_value = sys_excepthook_impl(module, exctype, value, traceback);
155
156
0
exit:
157
0
    return return_value;
158
0
}
159
160
PyDoc_STRVAR(sys_exception__doc__,
161
"exception($module, /)\n"
162
"--\n"
163
"\n"
164
"Return the current exception.\n"
165
"\n"
166
"Return the most recent exception caught by an except clause\n"
167
"in the current stack frame or in an older stack frame, or None\n"
168
"if no such exception exists.");
169
170
#define SYS_EXCEPTION_METHODDEF    \
171
    {"exception", (PyCFunction)sys_exception, METH_NOARGS, sys_exception__doc__},
172
173
static PyObject *
174
sys_exception_impl(PyObject *module);
175
176
static PyObject *
177
sys_exception(PyObject *module, PyObject *Py_UNUSED(ignored))
178
0
{
179
0
    return sys_exception_impl(module);
180
0
}
181
182
PyDoc_STRVAR(sys_exc_info__doc__,
183
"exc_info($module, /)\n"
184
"--\n"
185
"\n"
186
"Return current exception information: (type, value, traceback).\n"
187
"\n"
188
"Return information about the most recent exception caught by an except\n"
189
"clause in the current stack frame or in an older stack frame.");
190
191
#define SYS_EXC_INFO_METHODDEF    \
192
    {"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, sys_exc_info__doc__},
193
194
static PyObject *
195
sys_exc_info_impl(PyObject *module);
196
197
static PyObject *
198
sys_exc_info(PyObject *module, PyObject *Py_UNUSED(ignored))
199
0
{
200
0
    return sys_exc_info_impl(module);
201
0
}
202
203
PyDoc_STRVAR(sys_unraisablehook__doc__,
204
"unraisablehook($module, unraisable, /)\n"
205
"--\n"
206
"\n"
207
"Handle an unraisable exception.\n"
208
"\n"
209
"The unraisable argument has the following attributes:\n"
210
"\n"
211
"* exc_type: Exception type.\n"
212
"* exc_value: Exception value, can be None.\n"
213
"* exc_traceback: Exception traceback, can be None.\n"
214
"* err_msg: Error message, can be None.\n"
215
"* object: Object causing the exception, can be None.");
216
217
#define SYS_UNRAISABLEHOOK_METHODDEF    \
218
    {"unraisablehook", (PyCFunction)sys_unraisablehook, METH_O, sys_unraisablehook__doc__},
219
220
PyDoc_STRVAR(sys_exit__doc__,
221
"exit($module, status=None, /)\n"
222
"--\n"
223
"\n"
224
"Exit the interpreter by raising SystemExit(status).\n"
225
"\n"
226
"If the status is omitted or None, it defaults to zero (i.e., success).\n"
227
"If the status is an integer, it will be used as the system exit status.\n"
228
"If it is another kind of object, it will be printed and the system\n"
229
"exit status will be one (i.e., failure).");
230
231
#define SYS_EXIT_METHODDEF    \
232
    {"exit", _PyCFunction_CAST(sys_exit), METH_FASTCALL, sys_exit__doc__},
233
234
static PyObject *
235
sys_exit_impl(PyObject *module, PyObject *status);
236
237
static PyObject *
238
sys_exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
239
0
{
240
0
    PyObject *return_value = NULL;
241
0
    PyObject *status = Py_None;
242
243
0
    if (!_PyArg_CheckPositional("exit", nargs, 0, 1)) {
244
0
        goto exit;
245
0
    }
246
0
    if (nargs < 1) {
247
0
        goto skip_optional;
248
0
    }
249
0
    status = args[0];
250
0
skip_optional:
251
0
    return_value = sys_exit_impl(module, status);
252
253
0
exit:
254
0
    return return_value;
255
0
}
256
257
PyDoc_STRVAR(sys_getdefaultencoding__doc__,
258
"getdefaultencoding($module, /)\n"
259
"--\n"
260
"\n"
261
"Return the current default encoding used by the Unicode implementation.");
262
263
#define SYS_GETDEFAULTENCODING_METHODDEF    \
264
    {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, sys_getdefaultencoding__doc__},
265
266
static PyObject *
267
sys_getdefaultencoding_impl(PyObject *module);
268
269
static PyObject *
270
sys_getdefaultencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
271
0
{
272
0
    return sys_getdefaultencoding_impl(module);
273
0
}
274
275
PyDoc_STRVAR(sys_getfilesystemencoding__doc__,
276
"getfilesystemencoding($module, /)\n"
277
"--\n"
278
"\n"
279
"Return the encoding used to convert Unicode filenames to OS filenames.");
280
281
#define SYS_GETFILESYSTEMENCODING_METHODDEF    \
282
    {"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding, METH_NOARGS, sys_getfilesystemencoding__doc__},
283
284
static PyObject *
285
sys_getfilesystemencoding_impl(PyObject *module);
286
287
static PyObject *
288
sys_getfilesystemencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
289
32
{
290
32
    return sys_getfilesystemencoding_impl(module);
291
32
}
292
293
PyDoc_STRVAR(sys_getfilesystemencodeerrors__doc__,
294
"getfilesystemencodeerrors($module, /)\n"
295
"--\n"
296
"\n"
297
"Return the error mode used Unicode to OS filename conversion.");
298
299
#define SYS_GETFILESYSTEMENCODEERRORS_METHODDEF    \
300
    {"getfilesystemencodeerrors", (PyCFunction)sys_getfilesystemencodeerrors, METH_NOARGS, sys_getfilesystemencodeerrors__doc__},
301
302
static PyObject *
303
sys_getfilesystemencodeerrors_impl(PyObject *module);
304
305
static PyObject *
306
sys_getfilesystemencodeerrors(PyObject *module, PyObject *Py_UNUSED(ignored))
307
16
{
308
16
    return sys_getfilesystemencodeerrors_impl(module);
309
16
}
310
311
PyDoc_STRVAR(sys_intern__doc__,
312
"intern($module, string, /)\n"
313
"--\n"
314
"\n"
315
"``Intern\'\' the given string.\n"
316
"\n"
317
"This enters the string in the (global) table of interned strings whose\n"
318
"purpose is to speed up dictionary lookups. Return the string itself or\n"
319
"the previously interned string object with the same value.");
320
321
#define SYS_INTERN_METHODDEF    \
322
    {"intern", (PyCFunction)sys_intern, METH_O, sys_intern__doc__},
323
324
static PyObject *
325
sys_intern_impl(PyObject *module, PyObject *s);
326
327
static PyObject *
328
sys_intern(PyObject *module, PyObject *arg)
329
399
{
330
399
    PyObject *return_value = NULL;
331
399
    PyObject *s;
332
333
399
    if (!PyUnicode_Check(arg)) {
334
0
        _PyArg_BadArgument("intern", "argument", "str", arg);
335
0
        goto exit;
336
0
    }
337
399
    s = arg;
338
399
    return_value = sys_intern_impl(module, s);
339
340
399
exit:
341
399
    return return_value;
342
399
}
343
344
PyDoc_STRVAR(sys__is_interned__doc__,
345
"_is_interned($module, string, /)\n"
346
"--\n"
347
"\n"
348
"Return True if the given string is \"interned\".");
349
350
#define SYS__IS_INTERNED_METHODDEF    \
351
    {"_is_interned", (PyCFunction)sys__is_interned, METH_O, sys__is_interned__doc__},
352
353
static int
354
sys__is_interned_impl(PyObject *module, PyObject *string);
355
356
static PyObject *
357
sys__is_interned(PyObject *module, PyObject *arg)
358
0
{
359
0
    PyObject *return_value = NULL;
360
0
    PyObject *string;
361
0
    int _return_value;
362
363
0
    if (!PyUnicode_Check(arg)) {
364
0
        _PyArg_BadArgument("_is_interned", "argument", "str", arg);
365
0
        goto exit;
366
0
    }
367
0
    string = arg;
368
0
    _return_value = sys__is_interned_impl(module, string);
369
0
    if ((_return_value == -1) && PyErr_Occurred()) {
370
0
        goto exit;
371
0
    }
372
0
    return_value = PyBool_FromLong((long)_return_value);
373
374
0
exit:
375
0
    return return_value;
376
0
}
377
378
PyDoc_STRVAR(sys__is_immortal__doc__,
379
"_is_immortal($module, op, /)\n"
380
"--\n"
381
"\n"
382
"Return True if the given object is \"immortal\" per PEP 683.\n"
383
"\n"
384
"This function should be used for specialized purposes only.");
385
386
#define SYS__IS_IMMORTAL_METHODDEF    \
387
    {"_is_immortal", (PyCFunction)sys__is_immortal, METH_O, sys__is_immortal__doc__},
388
389
static int
390
sys__is_immortal_impl(PyObject *module, PyObject *op);
391
392
static PyObject *
393
sys__is_immortal(PyObject *module, PyObject *op)
394
0
{
395
0
    PyObject *return_value = NULL;
396
0
    int _return_value;
397
398
0
    _return_value = sys__is_immortal_impl(module, op);
399
0
    if ((_return_value == -1) && PyErr_Occurred()) {
400
0
        goto exit;
401
0
    }
402
0
    return_value = PyBool_FromLong((long)_return_value);
403
404
0
exit:
405
0
    return return_value;
406
0
}
407
408
PyDoc_STRVAR(sys_settrace__doc__,
409
"settrace($module, function, /)\n"
410
"--\n"
411
"\n"
412
"Set the global debug tracing function.\n"
413
"\n"
414
"It will be called on each function call.  See the debugger chapter\n"
415
"in the library manual.");
416
417
#define SYS_SETTRACE_METHODDEF    \
418
    {"settrace", (PyCFunction)sys_settrace, METH_O, sys_settrace__doc__},
419
420
PyDoc_STRVAR(sys__settraceallthreads__doc__,
421
"_settraceallthreads($module, function, /)\n"
422
"--\n"
423
"\n"
424
"Set the global debug tracing function in all running threads belonging to the current interpreter.\n"
425
"\n"
426
"It will be called on each function call. See the debugger chapter\n"
427
"in the library manual.");
428
429
#define SYS__SETTRACEALLTHREADS_METHODDEF    \
430
    {"_settraceallthreads", (PyCFunction)sys__settraceallthreads, METH_O, sys__settraceallthreads__doc__},
431
432
PyDoc_STRVAR(sys_gettrace__doc__,
433
"gettrace($module, /)\n"
434
"--\n"
435
"\n"
436
"Return the global debug tracing function set with sys.settrace.\n"
437
"\n"
438
"See the debugger chapter in the library manual.");
439
440
#define SYS_GETTRACE_METHODDEF    \
441
    {"gettrace", (PyCFunction)sys_gettrace, METH_NOARGS, sys_gettrace__doc__},
442
443
static PyObject *
444
sys_gettrace_impl(PyObject *module);
445
446
static PyObject *
447
sys_gettrace(PyObject *module, PyObject *Py_UNUSED(ignored))
448
0
{
449
0
    return sys_gettrace_impl(module);
450
0
}
451
452
PyDoc_STRVAR(sys_setprofile__doc__,
453
"setprofile($module, function, /)\n"
454
"--\n"
455
"\n"
456
"Set the profiling function.\n"
457
"\n"
458
"It will be called on each function call and return.  See the profiler\n"
459
"chapter in the library manual.");
460
461
#define SYS_SETPROFILE_METHODDEF    \
462
    {"setprofile", (PyCFunction)sys_setprofile, METH_O, sys_setprofile__doc__},
463
464
PyDoc_STRVAR(sys__setprofileallthreads__doc__,
465
"_setprofileallthreads($module, function, /)\n"
466
"--\n"
467
"\n"
468
"Set the profiling function in all running threads belonging to the current interpreter.\n"
469
"\n"
470
"It will be called on each function call and return.  See the profiler\n"
471
"chapter in the library manual.");
472
473
#define SYS__SETPROFILEALLTHREADS_METHODDEF    \
474
    {"_setprofileallthreads", (PyCFunction)sys__setprofileallthreads, METH_O, sys__setprofileallthreads__doc__},
475
476
PyDoc_STRVAR(sys_getprofile__doc__,
477
"getprofile($module, /)\n"
478
"--\n"
479
"\n"
480
"Return the profiling function set with sys.setprofile.\n"
481
"\n"
482
"See the profiler chapter in the library manual.");
483
484
#define SYS_GETPROFILE_METHODDEF    \
485
    {"getprofile", (PyCFunction)sys_getprofile, METH_NOARGS, sys_getprofile__doc__},
486
487
static PyObject *
488
sys_getprofile_impl(PyObject *module);
489
490
static PyObject *
491
sys_getprofile(PyObject *module, PyObject *Py_UNUSED(ignored))
492
0
{
493
0
    return sys_getprofile_impl(module);
494
0
}
495
496
PyDoc_STRVAR(sys_setswitchinterval__doc__,
497
"setswitchinterval($module, interval, /)\n"
498
"--\n"
499
"\n"
500
"Set the ideal thread switching delay inside the Python interpreter.\n"
501
"\n"
502
"The actual frequency of switching threads can be lower if the\n"
503
"interpreter executes long sequences of uninterruptible code\n"
504
"(this is implementation-specific and workload-dependent).\n"
505
"\n"
506
"The parameter must represent the desired switching delay in seconds\n"
507
"A typical value is 0.005 (5 milliseconds).");
508
509
#define SYS_SETSWITCHINTERVAL_METHODDEF    \
510
    {"setswitchinterval", (PyCFunction)sys_setswitchinterval, METH_O, sys_setswitchinterval__doc__},
511
512
static PyObject *
513
sys_setswitchinterval_impl(PyObject *module, double interval);
514
515
static PyObject *
516
sys_setswitchinterval(PyObject *module, PyObject *arg)
517
0
{
518
0
    PyObject *return_value = NULL;
519
0
    double interval;
520
521
0
    if (PyFloat_CheckExact(arg)) {
522
0
        interval = PyFloat_AS_DOUBLE(arg);
523
0
    }
524
0
    else
525
0
    {
526
0
        interval = PyFloat_AsDouble(arg);
527
0
        if (interval == -1.0 && PyErr_Occurred()) {
528
0
            goto exit;
529
0
        }
530
0
    }
531
0
    return_value = sys_setswitchinterval_impl(module, interval);
532
533
0
exit:
534
0
    return return_value;
535
0
}
536
537
PyDoc_STRVAR(sys_getswitchinterval__doc__,
538
"getswitchinterval($module, /)\n"
539
"--\n"
540
"\n"
541
"Return the current thread switch interval; see sys.setswitchinterval().");
542
543
#define SYS_GETSWITCHINTERVAL_METHODDEF    \
544
    {"getswitchinterval", (PyCFunction)sys_getswitchinterval, METH_NOARGS, sys_getswitchinterval__doc__},
545
546
static double
547
sys_getswitchinterval_impl(PyObject *module);
548
549
static PyObject *
550
sys_getswitchinterval(PyObject *module, PyObject *Py_UNUSED(ignored))
551
0
{
552
0
    PyObject *return_value = NULL;
553
0
    double _return_value;
554
555
0
    _return_value = sys_getswitchinterval_impl(module);
556
0
    if ((_return_value == -1.0) && PyErr_Occurred()) {
557
0
        goto exit;
558
0
    }
559
0
    return_value = PyFloat_FromDouble(_return_value);
560
561
0
exit:
562
0
    return return_value;
563
0
}
564
565
PyDoc_STRVAR(sys_setrecursionlimit__doc__,
566
"setrecursionlimit($module, limit, /)\n"
567
"--\n"
568
"\n"
569
"Set the maximum depth of the Python interpreter stack to n.\n"
570
"\n"
571
"This limit prevents infinite recursion from causing an overflow of the C\n"
572
"stack and crashing Python.  The highest possible limit is platform-\n"
573
"dependent.");
574
575
#define SYS_SETRECURSIONLIMIT_METHODDEF    \
576
    {"setrecursionlimit", (PyCFunction)sys_setrecursionlimit, METH_O, sys_setrecursionlimit__doc__},
577
578
static PyObject *
579
sys_setrecursionlimit_impl(PyObject *module, int new_limit);
580
581
static PyObject *
582
sys_setrecursionlimit(PyObject *module, PyObject *arg)
583
0
{
584
0
    PyObject *return_value = NULL;
585
0
    int new_limit;
586
587
0
    new_limit = PyLong_AsInt(arg);
588
0
    if (new_limit == -1 && PyErr_Occurred()) {
589
0
        goto exit;
590
0
    }
591
0
    return_value = sys_setrecursionlimit_impl(module, new_limit);
592
593
0
exit:
594
0
    return return_value;
595
0
}
596
597
PyDoc_STRVAR(sys_set_coroutine_origin_tracking_depth__doc__,
598
"set_coroutine_origin_tracking_depth($module, /, depth)\n"
599
"--\n"
600
"\n"
601
"Enable or disable origin tracking for coroutine objects in this thread.\n"
602
"\n"
603
"Coroutine objects will track \'depth\' frames of traceback information\n"
604
"about where they came from, available in their cr_origin attribute.\n"
605
"\n"
606
"Set a depth of 0 to disable.");
607
608
#define SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF    \
609
    {"set_coroutine_origin_tracking_depth", _PyCFunction_CAST(sys_set_coroutine_origin_tracking_depth), METH_FASTCALL|METH_KEYWORDS, sys_set_coroutine_origin_tracking_depth__doc__},
610
611
static PyObject *
612
sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth);
613
614
static PyObject *
615
sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
616
0
{
617
0
    PyObject *return_value = NULL;
618
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
619
620
0
    #define NUM_KEYWORDS 1
621
0
    static struct {
622
0
        PyGC_Head _this_is_not_used;
623
0
        PyObject_VAR_HEAD
624
0
        Py_hash_t ob_hash;
625
0
        PyObject *ob_item[NUM_KEYWORDS];
626
0
    } _kwtuple = {
627
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
628
0
        .ob_hash = -1,
629
0
        .ob_item = { &_Py_ID(depth), },
630
0
    };
631
0
    #undef NUM_KEYWORDS
632
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
633
634
    #else  // !Py_BUILD_CORE
635
    #  define KWTUPLE NULL
636
    #endif  // !Py_BUILD_CORE
637
638
0
    static const char * const _keywords[] = {"depth", NULL};
639
0
    static _PyArg_Parser _parser = {
640
0
        .keywords = _keywords,
641
0
        .fname = "set_coroutine_origin_tracking_depth",
642
0
        .kwtuple = KWTUPLE,
643
0
    };
644
0
    #undef KWTUPLE
645
0
    PyObject *argsbuf[1];
646
0
    int depth;
647
648
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
649
0
            /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
650
0
    if (!args) {
651
0
        goto exit;
652
0
    }
653
0
    depth = PyLong_AsInt(args[0]);
654
0
    if (depth == -1 && PyErr_Occurred()) {
655
0
        goto exit;
656
0
    }
657
0
    return_value = sys_set_coroutine_origin_tracking_depth_impl(module, depth);
658
659
0
exit:
660
0
    return return_value;
661
0
}
662
663
PyDoc_STRVAR(sys_get_coroutine_origin_tracking_depth__doc__,
664
"get_coroutine_origin_tracking_depth($module, /)\n"
665
"--\n"
666
"\n"
667
"Check status of origin tracking for coroutine objects in this thread.");
668
669
#define SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF    \
670
    {"get_coroutine_origin_tracking_depth", (PyCFunction)sys_get_coroutine_origin_tracking_depth, METH_NOARGS, sys_get_coroutine_origin_tracking_depth__doc__},
671
672
static int
673
sys_get_coroutine_origin_tracking_depth_impl(PyObject *module);
674
675
static PyObject *
676
sys_get_coroutine_origin_tracking_depth(PyObject *module, PyObject *Py_UNUSED(ignored))
677
0
{
678
0
    PyObject *return_value = NULL;
679
0
    int _return_value;
680
681
0
    _return_value = sys_get_coroutine_origin_tracking_depth_impl(module);
682
0
    if ((_return_value == -1) && PyErr_Occurred()) {
683
0
        goto exit;
684
0
    }
685
0
    return_value = PyLong_FromLong((long)_return_value);
686
687
0
exit:
688
0
    return return_value;
689
0
}
690
691
PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__,
692
"get_asyncgen_hooks($module, /)\n"
693
"--\n"
694
"\n"
695
"Return the installed asynchronous generators hooks.\n"
696
"\n"
697
"This returns a namedtuple of the form (firstiter, finalizer).");
698
699
#define SYS_GET_ASYNCGEN_HOOKS_METHODDEF    \
700
    {"get_asyncgen_hooks", (PyCFunction)sys_get_asyncgen_hooks, METH_NOARGS, sys_get_asyncgen_hooks__doc__},
701
702
static PyObject *
703
sys_get_asyncgen_hooks_impl(PyObject *module);
704
705
static PyObject *
706
sys_get_asyncgen_hooks(PyObject *module, PyObject *Py_UNUSED(ignored))
707
0
{
708
0
    return sys_get_asyncgen_hooks_impl(module);
709
0
}
710
711
PyDoc_STRVAR(sys_getrecursionlimit__doc__,
712
"getrecursionlimit($module, /)\n"
713
"--\n"
714
"\n"
715
"Return the current value of the recursion limit.\n"
716
"\n"
717
"The recursion limit is the maximum depth of the Python interpreter\n"
718
"stack.  This limit prevents infinite recursion from causing an overflow\n"
719
"of the C stack and crashing Python.");
720
721
#define SYS_GETRECURSIONLIMIT_METHODDEF    \
722
    {"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, sys_getrecursionlimit__doc__},
723
724
static PyObject *
725
sys_getrecursionlimit_impl(PyObject *module);
726
727
static PyObject *
728
sys_getrecursionlimit(PyObject *module, PyObject *Py_UNUSED(ignored))
729
0
{
730
0
    return sys_getrecursionlimit_impl(module);
731
0
}
732
733
#if defined(MS_WINDOWS)
734
735
PyDoc_STRVAR(sys_getwindowsversion__doc__,
736
"getwindowsversion($module, /)\n"
737
"--\n"
738
"\n"
739
"Return info about the running version of Windows as a named tuple.\n"
740
"\n"
741
"The members are named: major, minor, build, platform, service_pack,\n"
742
"service_pack_major, service_pack_minor, suite_mask, product_type and\n"
743
"platform_version. For backward compatibility, only the first 5 items\n"
744
"are available by indexing. All elements are numbers, except\n"
745
"service_pack and platform_type which are strings, and platform_version\n"
746
"which is a 3-tuple. Platform is always 2. Product_type may be 1 for a\n"
747
"workstation, 2 for a domain controller, 3 for a server.\n"
748
"Platform_version is a 3-tuple containing a version number that is\n"
749
"intended for identifying the OS rather than feature detection.");
750
751
#define SYS_GETWINDOWSVERSION_METHODDEF    \
752
    {"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, sys_getwindowsversion__doc__},
753
754
static PyObject *
755
sys_getwindowsversion_impl(PyObject *module);
756
757
static PyObject *
758
sys_getwindowsversion(PyObject *module, PyObject *Py_UNUSED(ignored))
759
{
760
    return sys_getwindowsversion_impl(module);
761
}
762
763
#endif /* defined(MS_WINDOWS) */
764
765
#if defined(MS_WINDOWS)
766
767
PyDoc_STRVAR(sys__enablelegacywindowsfsencoding__doc__,
768
"_enablelegacywindowsfsencoding($module, /)\n"
769
"--\n"
770
"\n"
771
"Changes the default filesystem encoding to mbcs:replace.\n"
772
"\n"
773
"This is done for consistency with earlier versions of Python. See PEP\n"
774
"529 for more information.\n"
775
"\n"
776
"This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING\n"
777
"environment variable before launching Python.");
778
779
#define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF    \
780
    {"_enablelegacywindowsfsencoding", (PyCFunction)sys__enablelegacywindowsfsencoding, METH_NOARGS, sys__enablelegacywindowsfsencoding__doc__},
781
782
static PyObject *
783
sys__enablelegacywindowsfsencoding_impl(PyObject *module);
784
785
static PyObject *
786
sys__enablelegacywindowsfsencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
787
{
788
    return sys__enablelegacywindowsfsencoding_impl(module);
789
}
790
791
#endif /* defined(MS_WINDOWS) */
792
793
#if defined(HAVE_DLOPEN)
794
795
PyDoc_STRVAR(sys_setdlopenflags__doc__,
796
"setdlopenflags($module, flags, /)\n"
797
"--\n"
798
"\n"
799
"Set the flags used by the interpreter for dlopen calls.\n"
800
"\n"
801
"This is used, for example, when the interpreter loads extension\n"
802
"modules. Among other things, this will enable a lazy resolving of\n"
803
"symbols when importing a module, if called as sys.setdlopenflags(0).\n"
804
"To share symbols across extension modules, call as\n"
805
"sys.setdlopenflags(os.RTLD_GLOBAL).  Symbolic names for the flag\n"
806
"modules can be found in the os module (RTLD_xxx constants, e.g.\n"
807
"os.RTLD_LAZY).");
808
809
#define SYS_SETDLOPENFLAGS_METHODDEF    \
810
    {"setdlopenflags", (PyCFunction)sys_setdlopenflags, METH_O, sys_setdlopenflags__doc__},
811
812
static PyObject *
813
sys_setdlopenflags_impl(PyObject *module, int new_val);
814
815
static PyObject *
816
sys_setdlopenflags(PyObject *module, PyObject *arg)
817
0
{
818
0
    PyObject *return_value = NULL;
819
0
    int new_val;
820
821
0
    new_val = PyLong_AsInt(arg);
822
0
    if (new_val == -1 && PyErr_Occurred()) {
823
0
        goto exit;
824
0
    }
825
0
    return_value = sys_setdlopenflags_impl(module, new_val);
826
827
0
exit:
828
0
    return return_value;
829
0
}
830
831
#endif /* defined(HAVE_DLOPEN) */
832
833
#if defined(HAVE_DLOPEN)
834
835
PyDoc_STRVAR(sys_getdlopenflags__doc__,
836
"getdlopenflags($module, /)\n"
837
"--\n"
838
"\n"
839
"Return the current value of the flags that are used for dlopen calls.\n"
840
"\n"
841
"The flag constants are defined in the os module.");
842
843
#define SYS_GETDLOPENFLAGS_METHODDEF    \
844
    {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, sys_getdlopenflags__doc__},
845
846
static PyObject *
847
sys_getdlopenflags_impl(PyObject *module);
848
849
static PyObject *
850
sys_getdlopenflags(PyObject *module, PyObject *Py_UNUSED(ignored))
851
0
{
852
0
    return sys_getdlopenflags_impl(module);
853
0
}
854
855
#endif /* defined(HAVE_DLOPEN) */
856
857
#if defined(USE_MALLOPT)
858
859
PyDoc_STRVAR(sys_mdebug__doc__,
860
"mdebug($module, flag, /)\n"
861
"--\n"
862
"\n");
863
864
#define SYS_MDEBUG_METHODDEF    \
865
    {"mdebug", (PyCFunction)sys_mdebug, METH_O, sys_mdebug__doc__},
866
867
static PyObject *
868
sys_mdebug_impl(PyObject *module, int flag);
869
870
static PyObject *
871
sys_mdebug(PyObject *module, PyObject *arg)
872
{
873
    PyObject *return_value = NULL;
874
    int flag;
875
876
    flag = PyLong_AsInt(arg);
877
    if (flag == -1 && PyErr_Occurred()) {
878
        goto exit;
879
    }
880
    return_value = sys_mdebug_impl(module, flag);
881
882
exit:
883
    return return_value;
884
}
885
886
#endif /* defined(USE_MALLOPT) */
887
888
PyDoc_STRVAR(sys_get_int_max_str_digits__doc__,
889
"get_int_max_str_digits($module, /)\n"
890
"--\n"
891
"\n"
892
"Return the maximum string digits limit for non-binary int<->str conversions.");
893
894
#define SYS_GET_INT_MAX_STR_DIGITS_METHODDEF    \
895
    {"get_int_max_str_digits", (PyCFunction)sys_get_int_max_str_digits, METH_NOARGS, sys_get_int_max_str_digits__doc__},
896
897
static PyObject *
898
sys_get_int_max_str_digits_impl(PyObject *module);
899
900
static PyObject *
901
sys_get_int_max_str_digits(PyObject *module, PyObject *Py_UNUSED(ignored))
902
0
{
903
0
    return sys_get_int_max_str_digits_impl(module);
904
0
}
905
906
PyDoc_STRVAR(sys_set_int_max_str_digits__doc__,
907
"set_int_max_str_digits($module, /, maxdigits)\n"
908
"--\n"
909
"\n"
910
"Set the maximum string digits limit for non-binary int<->str conversions.");
911
912
#define SYS_SET_INT_MAX_STR_DIGITS_METHODDEF    \
913
    {"set_int_max_str_digits", _PyCFunction_CAST(sys_set_int_max_str_digits), METH_FASTCALL|METH_KEYWORDS, sys_set_int_max_str_digits__doc__},
914
915
static PyObject *
916
sys_set_int_max_str_digits_impl(PyObject *module, int maxdigits);
917
918
static PyObject *
919
sys_set_int_max_str_digits(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
920
0
{
921
0
    PyObject *return_value = NULL;
922
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
923
924
0
    #define NUM_KEYWORDS 1
925
0
    static struct {
926
0
        PyGC_Head _this_is_not_used;
927
0
        PyObject_VAR_HEAD
928
0
        Py_hash_t ob_hash;
929
0
        PyObject *ob_item[NUM_KEYWORDS];
930
0
    } _kwtuple = {
931
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
932
0
        .ob_hash = -1,
933
0
        .ob_item = { &_Py_ID(maxdigits), },
934
0
    };
935
0
    #undef NUM_KEYWORDS
936
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
937
938
    #else  // !Py_BUILD_CORE
939
    #  define KWTUPLE NULL
940
    #endif  // !Py_BUILD_CORE
941
942
0
    static const char * const _keywords[] = {"maxdigits", NULL};
943
0
    static _PyArg_Parser _parser = {
944
0
        .keywords = _keywords,
945
0
        .fname = "set_int_max_str_digits",
946
0
        .kwtuple = KWTUPLE,
947
0
    };
948
0
    #undef KWTUPLE
949
0
    PyObject *argsbuf[1];
950
0
    int maxdigits;
951
952
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
953
0
            /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
954
0
    if (!args) {
955
0
        goto exit;
956
0
    }
957
0
    maxdigits = PyLong_AsInt(args[0]);
958
0
    if (maxdigits == -1 && PyErr_Occurred()) {
959
0
        goto exit;
960
0
    }
961
0
    return_value = sys_set_int_max_str_digits_impl(module, maxdigits);
962
963
0
exit:
964
0
    return return_value;
965
0
}
966
967
PyDoc_STRVAR(sys_getrefcount__doc__,
968
"getrefcount($module, object, /)\n"
969
"--\n"
970
"\n"
971
"Return the reference count of object.\n"
972
"\n"
973
"The count returned is generally one higher than you might expect,\n"
974
"because it includes the (temporary) reference as an argument to\n"
975
"getrefcount().");
976
977
#define SYS_GETREFCOUNT_METHODDEF    \
978
    {"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__},
979
980
static Py_ssize_t
981
sys_getrefcount_impl(PyObject *module, PyObject *object);
982
983
static PyObject *
984
sys_getrefcount(PyObject *module, PyObject *object)
985
0
{
986
0
    PyObject *return_value = NULL;
987
0
    Py_ssize_t _return_value;
988
989
0
    _return_value = sys_getrefcount_impl(module, object);
990
0
    if ((_return_value == -1) && PyErr_Occurred()) {
991
0
        goto exit;
992
0
    }
993
0
    return_value = PyLong_FromSsize_t(_return_value);
994
995
0
exit:
996
0
    return return_value;
997
0
}
998
999
#if defined(Py_REF_DEBUG)
1000
1001
PyDoc_STRVAR(sys_gettotalrefcount__doc__,
1002
"gettotalrefcount($module, /)\n"
1003
"--\n"
1004
"\n");
1005
1006
#define SYS_GETTOTALREFCOUNT_METHODDEF    \
1007
    {"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__},
1008
1009
static Py_ssize_t
1010
sys_gettotalrefcount_impl(PyObject *module);
1011
1012
static PyObject *
1013
sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored))
1014
{
1015
    PyObject *return_value = NULL;
1016
    Py_ssize_t _return_value;
1017
1018
    _return_value = sys_gettotalrefcount_impl(module);
1019
    if ((_return_value == -1) && PyErr_Occurred()) {
1020
        goto exit;
1021
    }
1022
    return_value = PyLong_FromSsize_t(_return_value);
1023
1024
exit:
1025
    return return_value;
1026
}
1027
1028
#endif /* defined(Py_REF_DEBUG) */
1029
1030
PyDoc_STRVAR(sys_getallocatedblocks__doc__,
1031
"getallocatedblocks($module, /)\n"
1032
"--\n"
1033
"\n"
1034
"Return the number of memory blocks currently allocated.");
1035
1036
#define SYS_GETALLOCATEDBLOCKS_METHODDEF    \
1037
    {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
1038
1039
static Py_ssize_t
1040
sys_getallocatedblocks_impl(PyObject *module);
1041
1042
static PyObject *
1043
sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
1044
0
{
1045
0
    PyObject *return_value = NULL;
1046
0
    Py_ssize_t _return_value;
1047
1048
0
    _return_value = sys_getallocatedblocks_impl(module);
1049
0
    if ((_return_value == -1) && PyErr_Occurred()) {
1050
0
        goto exit;
1051
0
    }
1052
0
    return_value = PyLong_FromSsize_t(_return_value);
1053
1054
0
exit:
1055
0
    return return_value;
1056
0
}
1057
1058
PyDoc_STRVAR(sys_getunicodeinternedsize__doc__,
1059
"getunicodeinternedsize($module, /, *, _only_immortal=False)\n"
1060
"--\n"
1061
"\n"
1062
"Return the number of elements of the unicode interned dictionary");
1063
1064
#define SYS_GETUNICODEINTERNEDSIZE_METHODDEF    \
1065
    {"getunicodeinternedsize", _PyCFunction_CAST(sys_getunicodeinternedsize), METH_FASTCALL|METH_KEYWORDS, sys_getunicodeinternedsize__doc__},
1066
1067
static Py_ssize_t
1068
sys_getunicodeinternedsize_impl(PyObject *module, int _only_immortal);
1069
1070
static PyObject *
1071
sys_getunicodeinternedsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1072
0
{
1073
0
    PyObject *return_value = NULL;
1074
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1075
1076
0
    #define NUM_KEYWORDS 1
1077
0
    static struct {
1078
0
        PyGC_Head _this_is_not_used;
1079
0
        PyObject_VAR_HEAD
1080
0
        Py_hash_t ob_hash;
1081
0
        PyObject *ob_item[NUM_KEYWORDS];
1082
0
    } _kwtuple = {
1083
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1084
0
        .ob_hash = -1,
1085
0
        .ob_item = { &_Py_ID(_only_immortal), },
1086
0
    };
1087
0
    #undef NUM_KEYWORDS
1088
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1089
1090
    #else  // !Py_BUILD_CORE
1091
    #  define KWTUPLE NULL
1092
    #endif  // !Py_BUILD_CORE
1093
1094
0
    static const char * const _keywords[] = {"_only_immortal", NULL};
1095
0
    static _PyArg_Parser _parser = {
1096
0
        .keywords = _keywords,
1097
0
        .fname = "getunicodeinternedsize",
1098
0
        .kwtuple = KWTUPLE,
1099
0
    };
1100
0
    #undef KWTUPLE
1101
0
    PyObject *argsbuf[1];
1102
0
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1103
0
    int _only_immortal = 0;
1104
0
    Py_ssize_t _return_value;
1105
1106
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1107
0
            /*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1108
0
    if (!args) {
1109
0
        goto exit;
1110
0
    }
1111
0
    if (!noptargs) {
1112
0
        goto skip_optional_kwonly;
1113
0
    }
1114
0
    _only_immortal = PyObject_IsTrue(args[0]);
1115
0
    if (_only_immortal < 0) {
1116
0
        goto exit;
1117
0
    }
1118
0
skip_optional_kwonly:
1119
0
    _return_value = sys_getunicodeinternedsize_impl(module, _only_immortal);
1120
0
    if ((_return_value == -1) && PyErr_Occurred()) {
1121
0
        goto exit;
1122
0
    }
1123
0
    return_value = PyLong_FromSsize_t(_return_value);
1124
1125
0
exit:
1126
0
    return return_value;
1127
0
}
1128
1129
PyDoc_STRVAR(sys__getframe__doc__,
1130
"_getframe($module, depth=0, /)\n"
1131
"--\n"
1132
"\n"
1133
"Return a frame object from the call stack.\n"
1134
"\n"
1135
"If optional integer depth is given, return the frame object that many\n"
1136
"calls below the top of the stack.  If that is deeper than the call\n"
1137
"stack, ValueError is raised.  The default for depth is zero, returning\n"
1138
"the frame at the top of the call stack.\n"
1139
"\n"
1140
"This function should be used for internal and specialized purposes\n"
1141
"only.");
1142
1143
#define SYS__GETFRAME_METHODDEF    \
1144
    {"_getframe", _PyCFunction_CAST(sys__getframe), METH_FASTCALL, sys__getframe__doc__},
1145
1146
static PyObject *
1147
sys__getframe_impl(PyObject *module, int depth);
1148
1149
static PyObject *
1150
sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1151
16
{
1152
16
    PyObject *return_value = NULL;
1153
16
    int depth = 0;
1154
1155
16
    if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
1156
0
        goto exit;
1157
0
    }
1158
16
    if (nargs < 1) {
1159
16
        goto skip_optional;
1160
16
    }
1161
0
    depth = PyLong_AsInt(args[0]);
1162
0
    if (depth == -1 && PyErr_Occurred()) {
1163
0
        goto exit;
1164
0
    }
1165
16
skip_optional:
1166
16
    return_value = sys__getframe_impl(module, depth);
1167
1168
16
exit:
1169
16
    return return_value;
1170
16
}
1171
1172
PyDoc_STRVAR(sys__current_frames__doc__,
1173
"_current_frames($module, /)\n"
1174
"--\n"
1175
"\n"
1176
"Return a dict mapping each thread\'s thread id to its current stack frame.\n"
1177
"\n"
1178
"This function should be used for specialized purposes only.");
1179
1180
#define SYS__CURRENT_FRAMES_METHODDEF    \
1181
    {"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__},
1182
1183
static PyObject *
1184
sys__current_frames_impl(PyObject *module);
1185
1186
static PyObject *
1187
sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored))
1188
0
{
1189
0
    return sys__current_frames_impl(module);
1190
0
}
1191
1192
PyDoc_STRVAR(sys__current_exceptions__doc__,
1193
"_current_exceptions($module, /)\n"
1194
"--\n"
1195
"\n"
1196
"Return a dict mapping each thread\'s identifier to its current raised exception.\n"
1197
"\n"
1198
"This function should be used for specialized purposes only.");
1199
1200
#define SYS__CURRENT_EXCEPTIONS_METHODDEF    \
1201
    {"_current_exceptions", (PyCFunction)sys__current_exceptions, METH_NOARGS, sys__current_exceptions__doc__},
1202
1203
static PyObject *
1204
sys__current_exceptions_impl(PyObject *module);
1205
1206
static PyObject *
1207
sys__current_exceptions(PyObject *module, PyObject *Py_UNUSED(ignored))
1208
0
{
1209
0
    return sys__current_exceptions_impl(module);
1210
0
}
1211
1212
PyDoc_STRVAR(sys_call_tracing__doc__,
1213
"call_tracing($module, func, args, /)\n"
1214
"--\n"
1215
"\n"
1216
"Call func(*args), while tracing is enabled.\n"
1217
"\n"
1218
"The tracing state is saved, and restored afterwards.  This is intended\n"
1219
"to be called from a debugger from a checkpoint, to recursively debug\n"
1220
"some other code.");
1221
1222
#define SYS_CALL_TRACING_METHODDEF    \
1223
    {"call_tracing", _PyCFunction_CAST(sys_call_tracing), METH_FASTCALL, sys_call_tracing__doc__},
1224
1225
static PyObject *
1226
sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs);
1227
1228
static PyObject *
1229
sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1230
0
{
1231
0
    PyObject *return_value = NULL;
1232
0
    PyObject *func;
1233
0
    PyObject *funcargs;
1234
1235
0
    if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
1236
0
        goto exit;
1237
0
    }
1238
0
    func = args[0];
1239
0
    if (!PyTuple_Check(args[1])) {
1240
0
        _PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]);
1241
0
        goto exit;
1242
0
    }
1243
0
    funcargs = args[1];
1244
0
    return_value = sys_call_tracing_impl(module, func, funcargs);
1245
1246
0
exit:
1247
0
    return return_value;
1248
0
}
1249
1250
PyDoc_STRVAR(sys__debugmallocstats__doc__,
1251
"_debugmallocstats($module, /)\n"
1252
"--\n"
1253
"\n"
1254
"Print summary info to stderr about the state of pymalloc\'s structures.\n"
1255
"\n"
1256
"In Py_DEBUG mode, also perform some expensive internal consistency\n"
1257
"checks.");
1258
1259
#define SYS__DEBUGMALLOCSTATS_METHODDEF    \
1260
    {"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__},
1261
1262
static PyObject *
1263
sys__debugmallocstats_impl(PyObject *module);
1264
1265
static PyObject *
1266
sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored))
1267
0
{
1268
0
    return sys__debugmallocstats_impl(module);
1269
0
}
1270
1271
PyDoc_STRVAR(sys__clear_type_cache__doc__,
1272
"_clear_type_cache($module, /)\n"
1273
"--\n"
1274
"\n"
1275
"Clear the internal type lookup cache.");
1276
1277
#define SYS__CLEAR_TYPE_CACHE_METHODDEF    \
1278
    {"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__},
1279
1280
static PyObject *
1281
sys__clear_type_cache_impl(PyObject *module);
1282
1283
static PyObject *
1284
sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored))
1285
0
{
1286
0
    return sys__clear_type_cache_impl(module);
1287
0
}
1288
1289
PyDoc_STRVAR(sys__clear_internal_caches__doc__,
1290
"_clear_internal_caches($module, /)\n"
1291
"--\n"
1292
"\n"
1293
"Clear all internal performance-related caches.");
1294
1295
#define SYS__CLEAR_INTERNAL_CACHES_METHODDEF    \
1296
    {"_clear_internal_caches", (PyCFunction)sys__clear_internal_caches, METH_NOARGS, sys__clear_internal_caches__doc__},
1297
1298
static PyObject *
1299
sys__clear_internal_caches_impl(PyObject *module);
1300
1301
static PyObject *
1302
sys__clear_internal_caches(PyObject *module, PyObject *Py_UNUSED(ignored))
1303
0
{
1304
0
    return sys__clear_internal_caches_impl(module);
1305
0
}
1306
1307
PyDoc_STRVAR(sys_is_finalizing__doc__,
1308
"is_finalizing($module, /)\n"
1309
"--\n"
1310
"\n"
1311
"Return True if Python is exiting.");
1312
1313
#define SYS_IS_FINALIZING_METHODDEF    \
1314
    {"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__},
1315
1316
static PyObject *
1317
sys_is_finalizing_impl(PyObject *module);
1318
1319
static PyObject *
1320
sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
1321
0
{
1322
0
    return sys_is_finalizing_impl(module);
1323
0
}
1324
1325
#if defined(Py_STATS)
1326
1327
PyDoc_STRVAR(sys__stats_on__doc__,
1328
"_stats_on($module, /)\n"
1329
"--\n"
1330
"\n"
1331
"Turns on stats gathering (stats gathering is off by default).");
1332
1333
#define SYS__STATS_ON_METHODDEF    \
1334
    {"_stats_on", (PyCFunction)sys__stats_on, METH_NOARGS, sys__stats_on__doc__},
1335
1336
static PyObject *
1337
sys__stats_on_impl(PyObject *module);
1338
1339
static PyObject *
1340
sys__stats_on(PyObject *module, PyObject *Py_UNUSED(ignored))
1341
{
1342
    return sys__stats_on_impl(module);
1343
}
1344
1345
#endif /* defined(Py_STATS) */
1346
1347
#if defined(Py_STATS)
1348
1349
PyDoc_STRVAR(sys__stats_off__doc__,
1350
"_stats_off($module, /)\n"
1351
"--\n"
1352
"\n"
1353
"Turns off stats gathering (stats gathering is off by default).");
1354
1355
#define SYS__STATS_OFF_METHODDEF    \
1356
    {"_stats_off", (PyCFunction)sys__stats_off, METH_NOARGS, sys__stats_off__doc__},
1357
1358
static PyObject *
1359
sys__stats_off_impl(PyObject *module);
1360
1361
static PyObject *
1362
sys__stats_off(PyObject *module, PyObject *Py_UNUSED(ignored))
1363
{
1364
    return sys__stats_off_impl(module);
1365
}
1366
1367
#endif /* defined(Py_STATS) */
1368
1369
#if defined(Py_STATS)
1370
1371
PyDoc_STRVAR(sys__stats_clear__doc__,
1372
"_stats_clear($module, /)\n"
1373
"--\n"
1374
"\n"
1375
"Clears the stats.");
1376
1377
#define SYS__STATS_CLEAR_METHODDEF    \
1378
    {"_stats_clear", (PyCFunction)sys__stats_clear, METH_NOARGS, sys__stats_clear__doc__},
1379
1380
static PyObject *
1381
sys__stats_clear_impl(PyObject *module);
1382
1383
static PyObject *
1384
sys__stats_clear(PyObject *module, PyObject *Py_UNUSED(ignored))
1385
{
1386
    return sys__stats_clear_impl(module);
1387
}
1388
1389
#endif /* defined(Py_STATS) */
1390
1391
#if defined(Py_STATS)
1392
1393
PyDoc_STRVAR(sys__stats_dump__doc__,
1394
"_stats_dump($module, /)\n"
1395
"--\n"
1396
"\n"
1397
"Dump stats to file, and clears the stats.\n"
1398
"\n"
1399
"Return False if no statistics were not dumped because stats gathering was off.");
1400
1401
#define SYS__STATS_DUMP_METHODDEF    \
1402
    {"_stats_dump", (PyCFunction)sys__stats_dump, METH_NOARGS, sys__stats_dump__doc__},
1403
1404
static int
1405
sys__stats_dump_impl(PyObject *module);
1406
1407
static PyObject *
1408
sys__stats_dump(PyObject *module, PyObject *Py_UNUSED(ignored))
1409
{
1410
    PyObject *return_value = NULL;
1411
    int _return_value;
1412
1413
    _return_value = sys__stats_dump_impl(module);
1414
    if ((_return_value == -1) && PyErr_Occurred()) {
1415
        goto exit;
1416
    }
1417
    return_value = PyBool_FromLong((long)_return_value);
1418
1419
exit:
1420
    return return_value;
1421
}
1422
1423
#endif /* defined(Py_STATS) */
1424
1425
#if defined(ANDROID_API_LEVEL)
1426
1427
PyDoc_STRVAR(sys_getandroidapilevel__doc__,
1428
"getandroidapilevel($module, /)\n"
1429
"--\n"
1430
"\n"
1431
"Return the build time API version of Android as an integer.");
1432
1433
#define SYS_GETANDROIDAPILEVEL_METHODDEF    \
1434
    {"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__},
1435
1436
static PyObject *
1437
sys_getandroidapilevel_impl(PyObject *module);
1438
1439
static PyObject *
1440
sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
1441
{
1442
    return sys_getandroidapilevel_impl(module);
1443
}
1444
1445
#endif /* defined(ANDROID_API_LEVEL) */
1446
1447
PyDoc_STRVAR(sys_activate_stack_trampoline__doc__,
1448
"activate_stack_trampoline($module, backend, /)\n"
1449
"--\n"
1450
"\n"
1451
"Activate stack profiler trampoline *backend*.");
1452
1453
#define SYS_ACTIVATE_STACK_TRAMPOLINE_METHODDEF    \
1454
    {"activate_stack_trampoline", (PyCFunction)sys_activate_stack_trampoline, METH_O, sys_activate_stack_trampoline__doc__},
1455
1456
static PyObject *
1457
sys_activate_stack_trampoline_impl(PyObject *module, const char *backend);
1458
1459
static PyObject *
1460
sys_activate_stack_trampoline(PyObject *module, PyObject *arg)
1461
0
{
1462
0
    PyObject *return_value = NULL;
1463
0
    const char *backend;
1464
1465
0
    if (!PyUnicode_Check(arg)) {
1466
0
        _PyArg_BadArgument("activate_stack_trampoline", "argument", "str", arg);
1467
0
        goto exit;
1468
0
    }
1469
0
    Py_ssize_t backend_length;
1470
0
    backend = PyUnicode_AsUTF8AndSize(arg, &backend_length);
1471
0
    if (backend == NULL) {
1472
0
        goto exit;
1473
0
    }
1474
0
    if (strlen(backend) != (size_t)backend_length) {
1475
0
        PyErr_SetString(PyExc_ValueError, "embedded null character");
1476
0
        goto exit;
1477
0
    }
1478
0
    return_value = sys_activate_stack_trampoline_impl(module, backend);
1479
1480
0
exit:
1481
0
    return return_value;
1482
0
}
1483
1484
PyDoc_STRVAR(sys_deactivate_stack_trampoline__doc__,
1485
"deactivate_stack_trampoline($module, /)\n"
1486
"--\n"
1487
"\n"
1488
"Deactivate the current stack profiler trampoline backend.\n"
1489
"\n"
1490
"If no stack profiler is activated, this function has no effect.");
1491
1492
#define SYS_DEACTIVATE_STACK_TRAMPOLINE_METHODDEF    \
1493
    {"deactivate_stack_trampoline", (PyCFunction)sys_deactivate_stack_trampoline, METH_NOARGS, sys_deactivate_stack_trampoline__doc__},
1494
1495
static PyObject *
1496
sys_deactivate_stack_trampoline_impl(PyObject *module);
1497
1498
static PyObject *
1499
sys_deactivate_stack_trampoline(PyObject *module, PyObject *Py_UNUSED(ignored))
1500
0
{
1501
0
    return sys_deactivate_stack_trampoline_impl(module);
1502
0
}
1503
1504
PyDoc_STRVAR(sys_is_stack_trampoline_active__doc__,
1505
"is_stack_trampoline_active($module, /)\n"
1506
"--\n"
1507
"\n"
1508
"Return *True* if a stack profiler trampoline is active.");
1509
1510
#define SYS_IS_STACK_TRAMPOLINE_ACTIVE_METHODDEF    \
1511
    {"is_stack_trampoline_active", (PyCFunction)sys_is_stack_trampoline_active, METH_NOARGS, sys_is_stack_trampoline_active__doc__},
1512
1513
static PyObject *
1514
sys_is_stack_trampoline_active_impl(PyObject *module);
1515
1516
static PyObject *
1517
sys_is_stack_trampoline_active(PyObject *module, PyObject *Py_UNUSED(ignored))
1518
0
{
1519
0
    return sys_is_stack_trampoline_active_impl(module);
1520
0
}
1521
1522
PyDoc_STRVAR(sys_is_remote_debug_enabled__doc__,
1523
"is_remote_debug_enabled($module, /)\n"
1524
"--\n"
1525
"\n"
1526
"Return True if remote debugging is enabled, False otherwise.");
1527
1528
#define SYS_IS_REMOTE_DEBUG_ENABLED_METHODDEF    \
1529
    {"is_remote_debug_enabled", (PyCFunction)sys_is_remote_debug_enabled, METH_NOARGS, sys_is_remote_debug_enabled__doc__},
1530
1531
static PyObject *
1532
sys_is_remote_debug_enabled_impl(PyObject *module);
1533
1534
static PyObject *
1535
sys_is_remote_debug_enabled(PyObject *module, PyObject *Py_UNUSED(ignored))
1536
0
{
1537
0
    return sys_is_remote_debug_enabled_impl(module);
1538
0
}
1539
1540
PyDoc_STRVAR(sys_remote_exec__doc__,
1541
"remote_exec($module, /, pid, script)\n"
1542
"--\n"
1543
"\n"
1544
"Executes a file containing Python code in a given remote Python process.\n"
1545
"\n"
1546
"This function returns immediately, and the code will be executed by the\n"
1547
"target process\'s main thread at the next available opportunity, similarly\n"
1548
"to how signals are handled. There is no interface to determine when the\n"
1549
"code has been executed. The caller is responsible for making sure that\n"
1550
"the file still exists whenever the remote process tries to read it and that\n"
1551
"it hasn\'t been overwritten.\n"
1552
"\n"
1553
"The remote process must be running a CPython interpreter of the same major\n"
1554
"and minor version as the local process. If either the local or remote\n"
1555
"interpreter is pre-release (alpha, beta, or release candidate) then the\n"
1556
"local and remote interpreters must be the same exact version.\n"
1557
"\n"
1558
"Args:\n"
1559
"     pid (int): The process ID of the target Python process.\n"
1560
"     script (str|bytes): The path to a file containing\n"
1561
"         the Python code to be executed.");
1562
1563
#define SYS_REMOTE_EXEC_METHODDEF    \
1564
    {"remote_exec", _PyCFunction_CAST(sys_remote_exec), METH_FASTCALL|METH_KEYWORDS, sys_remote_exec__doc__},
1565
1566
static PyObject *
1567
sys_remote_exec_impl(PyObject *module, int pid, PyObject *script);
1568
1569
static PyObject *
1570
sys_remote_exec(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1571
0
{
1572
0
    PyObject *return_value = NULL;
1573
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1574
1575
0
    #define NUM_KEYWORDS 2
1576
0
    static struct {
1577
0
        PyGC_Head _this_is_not_used;
1578
0
        PyObject_VAR_HEAD
1579
0
        Py_hash_t ob_hash;
1580
0
        PyObject *ob_item[NUM_KEYWORDS];
1581
0
    } _kwtuple = {
1582
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1583
0
        .ob_hash = -1,
1584
0
        .ob_item = { &_Py_ID(pid), &_Py_ID(script), },
1585
0
    };
1586
0
    #undef NUM_KEYWORDS
1587
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1588
1589
    #else  // !Py_BUILD_CORE
1590
    #  define KWTUPLE NULL
1591
    #endif  // !Py_BUILD_CORE
1592
1593
0
    static const char * const _keywords[] = {"pid", "script", NULL};
1594
0
    static _PyArg_Parser _parser = {
1595
0
        .keywords = _keywords,
1596
0
        .fname = "remote_exec",
1597
0
        .kwtuple = KWTUPLE,
1598
0
    };
1599
0
    #undef KWTUPLE
1600
0
    PyObject *argsbuf[2];
1601
0
    int pid;
1602
0
    PyObject *script;
1603
1604
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1605
0
            /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1606
0
    if (!args) {
1607
0
        goto exit;
1608
0
    }
1609
0
    pid = PyLong_AsInt(args[0]);
1610
0
    if (pid == -1 && PyErr_Occurred()) {
1611
0
        goto exit;
1612
0
    }
1613
0
    script = args[1];
1614
0
    return_value = sys_remote_exec_impl(module, pid, script);
1615
1616
0
exit:
1617
0
    return return_value;
1618
0
}
1619
1620
PyDoc_STRVAR(sys__dump_tracelets__doc__,
1621
"_dump_tracelets($module, /, outpath)\n"
1622
"--\n"
1623
"\n"
1624
"Dump the graph of tracelets in graphviz format");
1625
1626
#define SYS__DUMP_TRACELETS_METHODDEF    \
1627
    {"_dump_tracelets", _PyCFunction_CAST(sys__dump_tracelets), METH_FASTCALL|METH_KEYWORDS, sys__dump_tracelets__doc__},
1628
1629
static PyObject *
1630
sys__dump_tracelets_impl(PyObject *module, PyObject *outpath);
1631
1632
static PyObject *
1633
sys__dump_tracelets(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1634
0
{
1635
0
    PyObject *return_value = NULL;
1636
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1637
1638
0
    #define NUM_KEYWORDS 1
1639
0
    static struct {
1640
0
        PyGC_Head _this_is_not_used;
1641
0
        PyObject_VAR_HEAD
1642
0
        Py_hash_t ob_hash;
1643
0
        PyObject *ob_item[NUM_KEYWORDS];
1644
0
    } _kwtuple = {
1645
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1646
0
        .ob_hash = -1,
1647
0
        .ob_item = { &_Py_ID(outpath), },
1648
0
    };
1649
0
    #undef NUM_KEYWORDS
1650
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1651
1652
    #else  // !Py_BUILD_CORE
1653
    #  define KWTUPLE NULL
1654
    #endif  // !Py_BUILD_CORE
1655
1656
0
    static const char * const _keywords[] = {"outpath", NULL};
1657
0
    static _PyArg_Parser _parser = {
1658
0
        .keywords = _keywords,
1659
0
        .fname = "_dump_tracelets",
1660
0
        .kwtuple = KWTUPLE,
1661
0
    };
1662
0
    #undef KWTUPLE
1663
0
    PyObject *argsbuf[1];
1664
0
    PyObject *outpath;
1665
1666
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1667
0
            /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1668
0
    if (!args) {
1669
0
        goto exit;
1670
0
    }
1671
0
    outpath = args[0];
1672
0
    return_value = sys__dump_tracelets_impl(module, outpath);
1673
1674
0
exit:
1675
0
    return return_value;
1676
0
}
1677
1678
PyDoc_STRVAR(sys__getframemodulename__doc__,
1679
"_getframemodulename($module, /, depth=0)\n"
1680
"--\n"
1681
"\n"
1682
"Return the name of the module for a calling frame.\n"
1683
"\n"
1684
"The default depth returns the module containing the call to this API.\n"
1685
"A more typical use in a library will pass a depth of 1 to get the user\'s\n"
1686
"module rather than the library module.\n"
1687
"\n"
1688
"If no frame, module, or name can be found, returns None.");
1689
1690
#define SYS__GETFRAMEMODULENAME_METHODDEF    \
1691
    {"_getframemodulename", _PyCFunction_CAST(sys__getframemodulename), METH_FASTCALL|METH_KEYWORDS, sys__getframemodulename__doc__},
1692
1693
static PyObject *
1694
sys__getframemodulename_impl(PyObject *module, int depth);
1695
1696
static PyObject *
1697
sys__getframemodulename(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1698
43
{
1699
43
    PyObject *return_value = NULL;
1700
43
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1701
1702
43
    #define NUM_KEYWORDS 1
1703
43
    static struct {
1704
43
        PyGC_Head _this_is_not_used;
1705
43
        PyObject_VAR_HEAD
1706
43
        Py_hash_t ob_hash;
1707
43
        PyObject *ob_item[NUM_KEYWORDS];
1708
43
    } _kwtuple = {
1709
43
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1710
43
        .ob_hash = -1,
1711
43
        .ob_item = { &_Py_ID(depth), },
1712
43
    };
1713
43
    #undef NUM_KEYWORDS
1714
43
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
1715
1716
    #else  // !Py_BUILD_CORE
1717
    #  define KWTUPLE NULL
1718
    #endif  // !Py_BUILD_CORE
1719
1720
43
    static const char * const _keywords[] = {"depth", NULL};
1721
43
    static _PyArg_Parser _parser = {
1722
43
        .keywords = _keywords,
1723
43
        .fname = "_getframemodulename",
1724
43
        .kwtuple = KWTUPLE,
1725
43
    };
1726
43
    #undef KWTUPLE
1727
43
    PyObject *argsbuf[1];
1728
43
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1729
43
    int depth = 0;
1730
1731
43
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
1732
43
            /*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
1733
43
    if (!args) {
1734
0
        goto exit;
1735
0
    }
1736
43
    if (!noptargs) {
1737
0
        goto skip_optional_pos;
1738
0
    }
1739
43
    depth = PyLong_AsInt(args[0]);
1740
43
    if (depth == -1 && PyErr_Occurred()) {
1741
0
        goto exit;
1742
0
    }
1743
43
skip_optional_pos:
1744
43
    return_value = sys__getframemodulename_impl(module, depth);
1745
1746
43
exit:
1747
43
    return return_value;
1748
43
}
1749
1750
PyDoc_STRVAR(sys__get_cpu_count_config__doc__,
1751
"_get_cpu_count_config($module, /)\n"
1752
"--\n"
1753
"\n"
1754
"Private function for getting PyConfig.cpu_count");
1755
1756
#define SYS__GET_CPU_COUNT_CONFIG_METHODDEF    \
1757
    {"_get_cpu_count_config", (PyCFunction)sys__get_cpu_count_config, METH_NOARGS, sys__get_cpu_count_config__doc__},
1758
1759
static int
1760
sys__get_cpu_count_config_impl(PyObject *module);
1761
1762
static PyObject *
1763
sys__get_cpu_count_config(PyObject *module, PyObject *Py_UNUSED(ignored))
1764
16
{
1765
16
    PyObject *return_value = NULL;
1766
16
    int _return_value;
1767
1768
16
    _return_value = sys__get_cpu_count_config_impl(module);
1769
16
    if ((_return_value == -1) && PyErr_Occurred()) {
1770
0
        goto exit;
1771
0
    }
1772
16
    return_value = PyLong_FromLong((long)_return_value);
1773
1774
16
exit:
1775
16
    return return_value;
1776
16
}
1777
1778
PyDoc_STRVAR(sys__baserepl__doc__,
1779
"_baserepl($module, /)\n"
1780
"--\n"
1781
"\n"
1782
"Private function for getting the base REPL");
1783
1784
#define SYS__BASEREPL_METHODDEF    \
1785
    {"_baserepl", (PyCFunction)sys__baserepl, METH_NOARGS, sys__baserepl__doc__},
1786
1787
static PyObject *
1788
sys__baserepl_impl(PyObject *module);
1789
1790
static PyObject *
1791
sys__baserepl(PyObject *module, PyObject *Py_UNUSED(ignored))
1792
0
{
1793
0
    return sys__baserepl_impl(module);
1794
0
}
1795
1796
PyDoc_STRVAR(sys__is_gil_enabled__doc__,
1797
"_is_gil_enabled($module, /)\n"
1798
"--\n"
1799
"\n"
1800
"Return True if the GIL is currently enabled and False otherwise.");
1801
1802
#define SYS__IS_GIL_ENABLED_METHODDEF    \
1803
    {"_is_gil_enabled", (PyCFunction)sys__is_gil_enabled, METH_NOARGS, sys__is_gil_enabled__doc__},
1804
1805
static int
1806
sys__is_gil_enabled_impl(PyObject *module);
1807
1808
static PyObject *
1809
sys__is_gil_enabled(PyObject *module, PyObject *Py_UNUSED(ignored))
1810
0
{
1811
0
    PyObject *return_value = NULL;
1812
0
    int _return_value;
1813
1814
0
    _return_value = sys__is_gil_enabled_impl(module);
1815
0
    if ((_return_value == -1) && PyErr_Occurred()) {
1816
0
        goto exit;
1817
0
    }
1818
0
    return_value = PyBool_FromLong((long)_return_value);
1819
1820
0
exit:
1821
0
    return return_value;
1822
0
}
1823
1824
PyDoc_STRVAR(_jit_is_available__doc__,
1825
"is_available($module, /)\n"
1826
"--\n"
1827
"\n"
1828
"Return True if the current Python executable supports JIT compilation, and False otherwise.");
1829
1830
#define _JIT_IS_AVAILABLE_METHODDEF    \
1831
    {"is_available", (PyCFunction)_jit_is_available, METH_NOARGS, _jit_is_available__doc__},
1832
1833
static int
1834
_jit_is_available_impl(PyObject *module);
1835
1836
static PyObject *
1837
_jit_is_available(PyObject *module, PyObject *Py_UNUSED(ignored))
1838
0
{
1839
0
    PyObject *return_value = NULL;
1840
0
    int _return_value;
1841
1842
0
    _return_value = _jit_is_available_impl(module);
1843
0
    if ((_return_value == -1) && PyErr_Occurred()) {
1844
0
        goto exit;
1845
0
    }
1846
0
    return_value = PyBool_FromLong((long)_return_value);
1847
1848
0
exit:
1849
0
    return return_value;
1850
0
}
1851
1852
PyDoc_STRVAR(_jit_is_enabled__doc__,
1853
"is_enabled($module, /)\n"
1854
"--\n"
1855
"\n"
1856
"Return True if JIT compilation is enabled for the current Python process (implies sys._jit.is_available()), and False otherwise.");
1857
1858
#define _JIT_IS_ENABLED_METHODDEF    \
1859
    {"is_enabled", (PyCFunction)_jit_is_enabled, METH_NOARGS, _jit_is_enabled__doc__},
1860
1861
static int
1862
_jit_is_enabled_impl(PyObject *module);
1863
1864
static PyObject *
1865
_jit_is_enabled(PyObject *module, PyObject *Py_UNUSED(ignored))
1866
0
{
1867
0
    PyObject *return_value = NULL;
1868
0
    int _return_value;
1869
1870
0
    _return_value = _jit_is_enabled_impl(module);
1871
0
    if ((_return_value == -1) && PyErr_Occurred()) {
1872
0
        goto exit;
1873
0
    }
1874
0
    return_value = PyBool_FromLong((long)_return_value);
1875
1876
0
exit:
1877
0
    return return_value;
1878
0
}
1879
1880
PyDoc_STRVAR(_jit_is_active__doc__,
1881
"is_active($module, /)\n"
1882
"--\n"
1883
"\n"
1884
"Return True if the topmost Python frame is currently executing JIT code (implies sys._jit.is_enabled()), and False otherwise.");
1885
1886
#define _JIT_IS_ACTIVE_METHODDEF    \
1887
    {"is_active", (PyCFunction)_jit_is_active, METH_NOARGS, _jit_is_active__doc__},
1888
1889
static int
1890
_jit_is_active_impl(PyObject *module);
1891
1892
static PyObject *
1893
_jit_is_active(PyObject *module, PyObject *Py_UNUSED(ignored))
1894
0
{
1895
0
    PyObject *return_value = NULL;
1896
0
    int _return_value;
1897
1898
0
    _return_value = _jit_is_active_impl(module);
1899
0
    if ((_return_value == -1) && PyErr_Occurred()) {
1900
0
        goto exit;
1901
0
    }
1902
0
    return_value = PyBool_FromLong((long)_return_value);
1903
1904
0
exit:
1905
0
    return return_value;
1906
0
}
1907
1908
#ifndef SYS_GETWINDOWSVERSION_METHODDEF
1909
    #define SYS_GETWINDOWSVERSION_METHODDEF
1910
#endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
1911
1912
#ifndef SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1913
    #define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1914
#endif /* !defined(SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF) */
1915
1916
#ifndef SYS_SETDLOPENFLAGS_METHODDEF
1917
    #define SYS_SETDLOPENFLAGS_METHODDEF
1918
#endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */
1919
1920
#ifndef SYS_GETDLOPENFLAGS_METHODDEF
1921
    #define SYS_GETDLOPENFLAGS_METHODDEF
1922
#endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */
1923
1924
#ifndef SYS_MDEBUG_METHODDEF
1925
    #define SYS_MDEBUG_METHODDEF
1926
#endif /* !defined(SYS_MDEBUG_METHODDEF) */
1927
1928
#ifndef SYS_GETTOTALREFCOUNT_METHODDEF
1929
    #define SYS_GETTOTALREFCOUNT_METHODDEF
1930
#endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
1931
1932
#ifndef SYS__STATS_ON_METHODDEF
1933
    #define SYS__STATS_ON_METHODDEF
1934
#endif /* !defined(SYS__STATS_ON_METHODDEF) */
1935
1936
#ifndef SYS__STATS_OFF_METHODDEF
1937
    #define SYS__STATS_OFF_METHODDEF
1938
#endif /* !defined(SYS__STATS_OFF_METHODDEF) */
1939
1940
#ifndef SYS__STATS_CLEAR_METHODDEF
1941
    #define SYS__STATS_CLEAR_METHODDEF
1942
#endif /* !defined(SYS__STATS_CLEAR_METHODDEF) */
1943
1944
#ifndef SYS__STATS_DUMP_METHODDEF
1945
    #define SYS__STATS_DUMP_METHODDEF
1946
#endif /* !defined(SYS__STATS_DUMP_METHODDEF) */
1947
1948
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
1949
    #define SYS_GETANDROIDAPILEVEL_METHODDEF
1950
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
1951
/*[clinic end generated code: output=449d16326e69dcf6 input=a9049054013a1b77]*/