Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/cpython
Path: blob/main/Python/clinic/sysmodule.c.h
12 views
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
10
11
PyDoc_STRVAR(sys_addaudithook__doc__,
12
"addaudithook($module, /, hook)\n"
13
"--\n"
14
"\n"
15
"Adds a new audit hook callback.");
16
17
#define SYS_ADDAUDITHOOK_METHODDEF \
18
{"addaudithook", _PyCFunction_CAST(sys_addaudithook), METH_FASTCALL|METH_KEYWORDS, sys_addaudithook__doc__},
19
20
static PyObject *
21
sys_addaudithook_impl(PyObject *module, PyObject *hook);
22
23
static PyObject *
24
sys_addaudithook(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
25
{
26
PyObject *return_value = NULL;
27
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
28
29
#define NUM_KEYWORDS 1
30
static struct {
31
PyGC_Head _this_is_not_used;
32
PyObject_VAR_HEAD
33
PyObject *ob_item[NUM_KEYWORDS];
34
} _kwtuple = {
35
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
36
.ob_item = { &_Py_ID(hook), },
37
};
38
#undef NUM_KEYWORDS
39
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
40
41
#else // !Py_BUILD_CORE
42
# define KWTUPLE NULL
43
#endif // !Py_BUILD_CORE
44
45
static const char * const _keywords[] = {"hook", NULL};
46
static _PyArg_Parser _parser = {
47
.keywords = _keywords,
48
.fname = "addaudithook",
49
.kwtuple = KWTUPLE,
50
};
51
#undef KWTUPLE
52
PyObject *argsbuf[1];
53
PyObject *hook;
54
55
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
56
if (!args) {
57
goto exit;
58
}
59
hook = args[0];
60
return_value = sys_addaudithook_impl(module, hook);
61
62
exit:
63
return return_value;
64
}
65
66
PyDoc_STRVAR(sys_displayhook__doc__,
67
"displayhook($module, object, /)\n"
68
"--\n"
69
"\n"
70
"Print an object to sys.stdout and also save it in builtins._");
71
72
#define SYS_DISPLAYHOOK_METHODDEF \
73
{"displayhook", (PyCFunction)sys_displayhook, METH_O, sys_displayhook__doc__},
74
75
PyDoc_STRVAR(sys_excepthook__doc__,
76
"excepthook($module, exctype, value, traceback, /)\n"
77
"--\n"
78
"\n"
79
"Handle an exception by displaying it with a traceback on sys.stderr.");
80
81
#define SYS_EXCEPTHOOK_METHODDEF \
82
{"excepthook", _PyCFunction_CAST(sys_excepthook), METH_FASTCALL, sys_excepthook__doc__},
83
84
static PyObject *
85
sys_excepthook_impl(PyObject *module, PyObject *exctype, PyObject *value,
86
PyObject *traceback);
87
88
static PyObject *
89
sys_excepthook(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
90
{
91
PyObject *return_value = NULL;
92
PyObject *exctype;
93
PyObject *value;
94
PyObject *traceback;
95
96
if (!_PyArg_CheckPositional("excepthook", nargs, 3, 3)) {
97
goto exit;
98
}
99
exctype = args[0];
100
value = args[1];
101
traceback = args[2];
102
return_value = sys_excepthook_impl(module, exctype, value, traceback);
103
104
exit:
105
return return_value;
106
}
107
108
PyDoc_STRVAR(sys_exception__doc__,
109
"exception($module, /)\n"
110
"--\n"
111
"\n"
112
"Return the current exception.\n"
113
"\n"
114
"Return the most recent exception caught by an except clause\n"
115
"in the current stack frame or in an older stack frame, or None\n"
116
"if no such exception exists.");
117
118
#define SYS_EXCEPTION_METHODDEF \
119
{"exception", (PyCFunction)sys_exception, METH_NOARGS, sys_exception__doc__},
120
121
static PyObject *
122
sys_exception_impl(PyObject *module);
123
124
static PyObject *
125
sys_exception(PyObject *module, PyObject *Py_UNUSED(ignored))
126
{
127
return sys_exception_impl(module);
128
}
129
130
PyDoc_STRVAR(sys_exc_info__doc__,
131
"exc_info($module, /)\n"
132
"--\n"
133
"\n"
134
"Return current exception information: (type, value, traceback).\n"
135
"\n"
136
"Return information about the most recent exception caught by an except\n"
137
"clause in the current stack frame or in an older stack frame.");
138
139
#define SYS_EXC_INFO_METHODDEF \
140
{"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, sys_exc_info__doc__},
141
142
static PyObject *
143
sys_exc_info_impl(PyObject *module);
144
145
static PyObject *
146
sys_exc_info(PyObject *module, PyObject *Py_UNUSED(ignored))
147
{
148
return sys_exc_info_impl(module);
149
}
150
151
PyDoc_STRVAR(sys_unraisablehook__doc__,
152
"unraisablehook($module, unraisable, /)\n"
153
"--\n"
154
"\n"
155
"Handle an unraisable exception.\n"
156
"\n"
157
"The unraisable argument has the following attributes:\n"
158
"\n"
159
"* exc_type: Exception type.\n"
160
"* exc_value: Exception value, can be None.\n"
161
"* exc_traceback: Exception traceback, can be None.\n"
162
"* err_msg: Error message, can be None.\n"
163
"* object: Object causing the exception, can be None.");
164
165
#define SYS_UNRAISABLEHOOK_METHODDEF \
166
{"unraisablehook", (PyCFunction)sys_unraisablehook, METH_O, sys_unraisablehook__doc__},
167
168
PyDoc_STRVAR(sys_exit__doc__,
169
"exit($module, status=None, /)\n"
170
"--\n"
171
"\n"
172
"Exit the interpreter by raising SystemExit(status).\n"
173
"\n"
174
"If the status is omitted or None, it defaults to zero (i.e., success).\n"
175
"If the status is an integer, it will be used as the system exit status.\n"
176
"If it is another kind of object, it will be printed and the system\n"
177
"exit status will be one (i.e., failure).");
178
179
#define SYS_EXIT_METHODDEF \
180
{"exit", _PyCFunction_CAST(sys_exit), METH_FASTCALL, sys_exit__doc__},
181
182
static PyObject *
183
sys_exit_impl(PyObject *module, PyObject *status);
184
185
static PyObject *
186
sys_exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
187
{
188
PyObject *return_value = NULL;
189
PyObject *status = Py_None;
190
191
if (!_PyArg_CheckPositional("exit", nargs, 0, 1)) {
192
goto exit;
193
}
194
if (nargs < 1) {
195
goto skip_optional;
196
}
197
status = args[0];
198
skip_optional:
199
return_value = sys_exit_impl(module, status);
200
201
exit:
202
return return_value;
203
}
204
205
PyDoc_STRVAR(sys_getdefaultencoding__doc__,
206
"getdefaultencoding($module, /)\n"
207
"--\n"
208
"\n"
209
"Return the current default encoding used by the Unicode implementation.");
210
211
#define SYS_GETDEFAULTENCODING_METHODDEF \
212
{"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS, sys_getdefaultencoding__doc__},
213
214
static PyObject *
215
sys_getdefaultencoding_impl(PyObject *module);
216
217
static PyObject *
218
sys_getdefaultencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
219
{
220
return sys_getdefaultencoding_impl(module);
221
}
222
223
PyDoc_STRVAR(sys_getfilesystemencoding__doc__,
224
"getfilesystemencoding($module, /)\n"
225
"--\n"
226
"\n"
227
"Return the encoding used to convert Unicode filenames to OS filenames.");
228
229
#define SYS_GETFILESYSTEMENCODING_METHODDEF \
230
{"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding, METH_NOARGS, sys_getfilesystemencoding__doc__},
231
232
static PyObject *
233
sys_getfilesystemencoding_impl(PyObject *module);
234
235
static PyObject *
236
sys_getfilesystemencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
237
{
238
return sys_getfilesystemencoding_impl(module);
239
}
240
241
PyDoc_STRVAR(sys_getfilesystemencodeerrors__doc__,
242
"getfilesystemencodeerrors($module, /)\n"
243
"--\n"
244
"\n"
245
"Return the error mode used Unicode to OS filename conversion.");
246
247
#define SYS_GETFILESYSTEMENCODEERRORS_METHODDEF \
248
{"getfilesystemencodeerrors", (PyCFunction)sys_getfilesystemencodeerrors, METH_NOARGS, sys_getfilesystemencodeerrors__doc__},
249
250
static PyObject *
251
sys_getfilesystemencodeerrors_impl(PyObject *module);
252
253
static PyObject *
254
sys_getfilesystemencodeerrors(PyObject *module, PyObject *Py_UNUSED(ignored))
255
{
256
return sys_getfilesystemencodeerrors_impl(module);
257
}
258
259
PyDoc_STRVAR(sys_intern__doc__,
260
"intern($module, string, /)\n"
261
"--\n"
262
"\n"
263
"``Intern\'\' the given string.\n"
264
"\n"
265
"This enters the string in the (global) table of interned strings whose\n"
266
"purpose is to speed up dictionary lookups. Return the string itself or\n"
267
"the previously interned string object with the same value.");
268
269
#define SYS_INTERN_METHODDEF \
270
{"intern", (PyCFunction)sys_intern, METH_O, sys_intern__doc__},
271
272
static PyObject *
273
sys_intern_impl(PyObject *module, PyObject *s);
274
275
static PyObject *
276
sys_intern(PyObject *module, PyObject *arg)
277
{
278
PyObject *return_value = NULL;
279
PyObject *s;
280
281
if (!PyUnicode_Check(arg)) {
282
_PyArg_BadArgument("intern", "argument", "str", arg);
283
goto exit;
284
}
285
s = arg;
286
return_value = sys_intern_impl(module, s);
287
288
exit:
289
return return_value;
290
}
291
292
PyDoc_STRVAR(sys__settraceallthreads__doc__,
293
"_settraceallthreads($module, arg, /)\n"
294
"--\n"
295
"\n"
296
"Set the global debug tracing function in all running threads belonging to the current interpreter.\n"
297
"\n"
298
"It will be called on each function call. See the debugger chapter\n"
299
"in the library manual.");
300
301
#define SYS__SETTRACEALLTHREADS_METHODDEF \
302
{"_settraceallthreads", (PyCFunction)sys__settraceallthreads, METH_O, sys__settraceallthreads__doc__},
303
304
PyDoc_STRVAR(sys_gettrace__doc__,
305
"gettrace($module, /)\n"
306
"--\n"
307
"\n"
308
"Return the global debug tracing function set with sys.settrace.\n"
309
"\n"
310
"See the debugger chapter in the library manual.");
311
312
#define SYS_GETTRACE_METHODDEF \
313
{"gettrace", (PyCFunction)sys_gettrace, METH_NOARGS, sys_gettrace__doc__},
314
315
static PyObject *
316
sys_gettrace_impl(PyObject *module);
317
318
static PyObject *
319
sys_gettrace(PyObject *module, PyObject *Py_UNUSED(ignored))
320
{
321
return sys_gettrace_impl(module);
322
}
323
324
PyDoc_STRVAR(sys__setprofileallthreads__doc__,
325
"_setprofileallthreads($module, arg, /)\n"
326
"--\n"
327
"\n"
328
"Set the profiling function in all running threads belonging to the current interpreter.\n"
329
"\n"
330
"It will be called on each function call and return. See the profiler chapter\n"
331
"in the library manual.");
332
333
#define SYS__SETPROFILEALLTHREADS_METHODDEF \
334
{"_setprofileallthreads", (PyCFunction)sys__setprofileallthreads, METH_O, sys__setprofileallthreads__doc__},
335
336
PyDoc_STRVAR(sys_getprofile__doc__,
337
"getprofile($module, /)\n"
338
"--\n"
339
"\n"
340
"Return the profiling function set with sys.setprofile.\n"
341
"\n"
342
"See the profiler chapter in the library manual.");
343
344
#define SYS_GETPROFILE_METHODDEF \
345
{"getprofile", (PyCFunction)sys_getprofile, METH_NOARGS, sys_getprofile__doc__},
346
347
static PyObject *
348
sys_getprofile_impl(PyObject *module);
349
350
static PyObject *
351
sys_getprofile(PyObject *module, PyObject *Py_UNUSED(ignored))
352
{
353
return sys_getprofile_impl(module);
354
}
355
356
PyDoc_STRVAR(sys_setswitchinterval__doc__,
357
"setswitchinterval($module, interval, /)\n"
358
"--\n"
359
"\n"
360
"Set the ideal thread switching delay inside the Python interpreter.\n"
361
"\n"
362
"The actual frequency of switching threads can be lower if the\n"
363
"interpreter executes long sequences of uninterruptible code\n"
364
"(this is implementation-specific and workload-dependent).\n"
365
"\n"
366
"The parameter must represent the desired switching delay in seconds\n"
367
"A typical value is 0.005 (5 milliseconds).");
368
369
#define SYS_SETSWITCHINTERVAL_METHODDEF \
370
{"setswitchinterval", (PyCFunction)sys_setswitchinterval, METH_O, sys_setswitchinterval__doc__},
371
372
static PyObject *
373
sys_setswitchinterval_impl(PyObject *module, double interval);
374
375
static PyObject *
376
sys_setswitchinterval(PyObject *module, PyObject *arg)
377
{
378
PyObject *return_value = NULL;
379
double interval;
380
381
if (PyFloat_CheckExact(arg)) {
382
interval = PyFloat_AS_DOUBLE(arg);
383
}
384
else
385
{
386
interval = PyFloat_AsDouble(arg);
387
if (interval == -1.0 && PyErr_Occurred()) {
388
goto exit;
389
}
390
}
391
return_value = sys_setswitchinterval_impl(module, interval);
392
393
exit:
394
return return_value;
395
}
396
397
PyDoc_STRVAR(sys_getswitchinterval__doc__,
398
"getswitchinterval($module, /)\n"
399
"--\n"
400
"\n"
401
"Return the current thread switch interval; see sys.setswitchinterval().");
402
403
#define SYS_GETSWITCHINTERVAL_METHODDEF \
404
{"getswitchinterval", (PyCFunction)sys_getswitchinterval, METH_NOARGS, sys_getswitchinterval__doc__},
405
406
static double
407
sys_getswitchinterval_impl(PyObject *module);
408
409
static PyObject *
410
sys_getswitchinterval(PyObject *module, PyObject *Py_UNUSED(ignored))
411
{
412
PyObject *return_value = NULL;
413
double _return_value;
414
415
_return_value = sys_getswitchinterval_impl(module);
416
if ((_return_value == -1.0) && PyErr_Occurred()) {
417
goto exit;
418
}
419
return_value = PyFloat_FromDouble(_return_value);
420
421
exit:
422
return return_value;
423
}
424
425
PyDoc_STRVAR(sys_setrecursionlimit__doc__,
426
"setrecursionlimit($module, limit, /)\n"
427
"--\n"
428
"\n"
429
"Set the maximum depth of the Python interpreter stack to n.\n"
430
"\n"
431
"This limit prevents infinite recursion from causing an overflow of the C\n"
432
"stack and crashing Python. The highest possible limit is platform-\n"
433
"dependent.");
434
435
#define SYS_SETRECURSIONLIMIT_METHODDEF \
436
{"setrecursionlimit", (PyCFunction)sys_setrecursionlimit, METH_O, sys_setrecursionlimit__doc__},
437
438
static PyObject *
439
sys_setrecursionlimit_impl(PyObject *module, int new_limit);
440
441
static PyObject *
442
sys_setrecursionlimit(PyObject *module, PyObject *arg)
443
{
444
PyObject *return_value = NULL;
445
int new_limit;
446
447
new_limit = _PyLong_AsInt(arg);
448
if (new_limit == -1 && PyErr_Occurred()) {
449
goto exit;
450
}
451
return_value = sys_setrecursionlimit_impl(module, new_limit);
452
453
exit:
454
return return_value;
455
}
456
457
PyDoc_STRVAR(sys_set_coroutine_origin_tracking_depth__doc__,
458
"set_coroutine_origin_tracking_depth($module, /, depth)\n"
459
"--\n"
460
"\n"
461
"Enable or disable origin tracking for coroutine objects in this thread.\n"
462
"\n"
463
"Coroutine objects will track \'depth\' frames of traceback information\n"
464
"about where they came from, available in their cr_origin attribute.\n"
465
"\n"
466
"Set a depth of 0 to disable.");
467
468
#define SYS_SET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
469
{"set_coroutine_origin_tracking_depth", _PyCFunction_CAST(sys_set_coroutine_origin_tracking_depth), METH_FASTCALL|METH_KEYWORDS, sys_set_coroutine_origin_tracking_depth__doc__},
470
471
static PyObject *
472
sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth);
473
474
static PyObject *
475
sys_set_coroutine_origin_tracking_depth(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
476
{
477
PyObject *return_value = NULL;
478
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
479
480
#define NUM_KEYWORDS 1
481
static struct {
482
PyGC_Head _this_is_not_used;
483
PyObject_VAR_HEAD
484
PyObject *ob_item[NUM_KEYWORDS];
485
} _kwtuple = {
486
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
487
.ob_item = { &_Py_ID(depth), },
488
};
489
#undef NUM_KEYWORDS
490
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
491
492
#else // !Py_BUILD_CORE
493
# define KWTUPLE NULL
494
#endif // !Py_BUILD_CORE
495
496
static const char * const _keywords[] = {"depth", NULL};
497
static _PyArg_Parser _parser = {
498
.keywords = _keywords,
499
.fname = "set_coroutine_origin_tracking_depth",
500
.kwtuple = KWTUPLE,
501
};
502
#undef KWTUPLE
503
PyObject *argsbuf[1];
504
int depth;
505
506
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
507
if (!args) {
508
goto exit;
509
}
510
depth = _PyLong_AsInt(args[0]);
511
if (depth == -1 && PyErr_Occurred()) {
512
goto exit;
513
}
514
return_value = sys_set_coroutine_origin_tracking_depth_impl(module, depth);
515
516
exit:
517
return return_value;
518
}
519
520
PyDoc_STRVAR(sys_get_coroutine_origin_tracking_depth__doc__,
521
"get_coroutine_origin_tracking_depth($module, /)\n"
522
"--\n"
523
"\n"
524
"Check status of origin tracking for coroutine objects in this thread.");
525
526
#define SYS_GET_COROUTINE_ORIGIN_TRACKING_DEPTH_METHODDEF \
527
{"get_coroutine_origin_tracking_depth", (PyCFunction)sys_get_coroutine_origin_tracking_depth, METH_NOARGS, sys_get_coroutine_origin_tracking_depth__doc__},
528
529
static int
530
sys_get_coroutine_origin_tracking_depth_impl(PyObject *module);
531
532
static PyObject *
533
sys_get_coroutine_origin_tracking_depth(PyObject *module, PyObject *Py_UNUSED(ignored))
534
{
535
PyObject *return_value = NULL;
536
int _return_value;
537
538
_return_value = sys_get_coroutine_origin_tracking_depth_impl(module);
539
if ((_return_value == -1) && PyErr_Occurred()) {
540
goto exit;
541
}
542
return_value = PyLong_FromLong((long)_return_value);
543
544
exit:
545
return return_value;
546
}
547
548
PyDoc_STRVAR(sys_get_asyncgen_hooks__doc__,
549
"get_asyncgen_hooks($module, /)\n"
550
"--\n"
551
"\n"
552
"Return the installed asynchronous generators hooks.\n"
553
"\n"
554
"This returns a namedtuple of the form (firstiter, finalizer).");
555
556
#define SYS_GET_ASYNCGEN_HOOKS_METHODDEF \
557
{"get_asyncgen_hooks", (PyCFunction)sys_get_asyncgen_hooks, METH_NOARGS, sys_get_asyncgen_hooks__doc__},
558
559
static PyObject *
560
sys_get_asyncgen_hooks_impl(PyObject *module);
561
562
static PyObject *
563
sys_get_asyncgen_hooks(PyObject *module, PyObject *Py_UNUSED(ignored))
564
{
565
return sys_get_asyncgen_hooks_impl(module);
566
}
567
568
PyDoc_STRVAR(sys_getrecursionlimit__doc__,
569
"getrecursionlimit($module, /)\n"
570
"--\n"
571
"\n"
572
"Return the current value of the recursion limit.\n"
573
"\n"
574
"The recursion limit is the maximum depth of the Python interpreter\n"
575
"stack. This limit prevents infinite recursion from causing an overflow\n"
576
"of the C stack and crashing Python.");
577
578
#define SYS_GETRECURSIONLIMIT_METHODDEF \
579
{"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS, sys_getrecursionlimit__doc__},
580
581
static PyObject *
582
sys_getrecursionlimit_impl(PyObject *module);
583
584
static PyObject *
585
sys_getrecursionlimit(PyObject *module, PyObject *Py_UNUSED(ignored))
586
{
587
return sys_getrecursionlimit_impl(module);
588
}
589
590
#if defined(MS_WINDOWS)
591
592
PyDoc_STRVAR(sys_getwindowsversion__doc__,
593
"getwindowsversion($module, /)\n"
594
"--\n"
595
"\n"
596
"Return info about the running version of Windows as a named tuple.\n"
597
"\n"
598
"The members are named: major, minor, build, platform, service_pack,\n"
599
"service_pack_major, service_pack_minor, suite_mask, product_type and\n"
600
"platform_version. For backward compatibility, only the first 5 items\n"
601
"are available by indexing. All elements are numbers, except\n"
602
"service_pack and platform_type which are strings, and platform_version\n"
603
"which is a 3-tuple. Platform is always 2. Product_type may be 1 for a\n"
604
"workstation, 2 for a domain controller, 3 for a server.\n"
605
"Platform_version is a 3-tuple containing a version number that is\n"
606
"intended for identifying the OS rather than feature detection.");
607
608
#define SYS_GETWINDOWSVERSION_METHODDEF \
609
{"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS, sys_getwindowsversion__doc__},
610
611
static PyObject *
612
sys_getwindowsversion_impl(PyObject *module);
613
614
static PyObject *
615
sys_getwindowsversion(PyObject *module, PyObject *Py_UNUSED(ignored))
616
{
617
return sys_getwindowsversion_impl(module);
618
}
619
620
#endif /* defined(MS_WINDOWS) */
621
622
#if defined(MS_WINDOWS)
623
624
PyDoc_STRVAR(sys__enablelegacywindowsfsencoding__doc__,
625
"_enablelegacywindowsfsencoding($module, /)\n"
626
"--\n"
627
"\n"
628
"Changes the default filesystem encoding to mbcs:replace.\n"
629
"\n"
630
"This is done for consistency with earlier versions of Python. See PEP\n"
631
"529 for more information.\n"
632
"\n"
633
"This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING\n"
634
"environment variable before launching Python.");
635
636
#define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF \
637
{"_enablelegacywindowsfsencoding", (PyCFunction)sys__enablelegacywindowsfsencoding, METH_NOARGS, sys__enablelegacywindowsfsencoding__doc__},
638
639
static PyObject *
640
sys__enablelegacywindowsfsencoding_impl(PyObject *module);
641
642
static PyObject *
643
sys__enablelegacywindowsfsencoding(PyObject *module, PyObject *Py_UNUSED(ignored))
644
{
645
return sys__enablelegacywindowsfsencoding_impl(module);
646
}
647
648
#endif /* defined(MS_WINDOWS) */
649
650
#if defined(HAVE_DLOPEN)
651
652
PyDoc_STRVAR(sys_setdlopenflags__doc__,
653
"setdlopenflags($module, flags, /)\n"
654
"--\n"
655
"\n"
656
"Set the flags used by the interpreter for dlopen calls.\n"
657
"\n"
658
"This is used, for example, when the interpreter loads extension\n"
659
"modules. Among other things, this will enable a lazy resolving of\n"
660
"symbols when importing a module, if called as sys.setdlopenflags(0).\n"
661
"To share symbols across extension modules, call as\n"
662
"sys.setdlopenflags(os.RTLD_GLOBAL). Symbolic names for the flag\n"
663
"modules can be found in the os module (RTLD_xxx constants, e.g.\n"
664
"os.RTLD_LAZY).");
665
666
#define SYS_SETDLOPENFLAGS_METHODDEF \
667
{"setdlopenflags", (PyCFunction)sys_setdlopenflags, METH_O, sys_setdlopenflags__doc__},
668
669
static PyObject *
670
sys_setdlopenflags_impl(PyObject *module, int new_val);
671
672
static PyObject *
673
sys_setdlopenflags(PyObject *module, PyObject *arg)
674
{
675
PyObject *return_value = NULL;
676
int new_val;
677
678
new_val = _PyLong_AsInt(arg);
679
if (new_val == -1 && PyErr_Occurred()) {
680
goto exit;
681
}
682
return_value = sys_setdlopenflags_impl(module, new_val);
683
684
exit:
685
return return_value;
686
}
687
688
#endif /* defined(HAVE_DLOPEN) */
689
690
#if defined(HAVE_DLOPEN)
691
692
PyDoc_STRVAR(sys_getdlopenflags__doc__,
693
"getdlopenflags($module, /)\n"
694
"--\n"
695
"\n"
696
"Return the current value of the flags that are used for dlopen calls.\n"
697
"\n"
698
"The flag constants are defined in the os module.");
699
700
#define SYS_GETDLOPENFLAGS_METHODDEF \
701
{"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, sys_getdlopenflags__doc__},
702
703
static PyObject *
704
sys_getdlopenflags_impl(PyObject *module);
705
706
static PyObject *
707
sys_getdlopenflags(PyObject *module, PyObject *Py_UNUSED(ignored))
708
{
709
return sys_getdlopenflags_impl(module);
710
}
711
712
#endif /* defined(HAVE_DLOPEN) */
713
714
#if defined(USE_MALLOPT)
715
716
PyDoc_STRVAR(sys_mdebug__doc__,
717
"mdebug($module, flag, /)\n"
718
"--\n"
719
"\n");
720
721
#define SYS_MDEBUG_METHODDEF \
722
{"mdebug", (PyCFunction)sys_mdebug, METH_O, sys_mdebug__doc__},
723
724
static PyObject *
725
sys_mdebug_impl(PyObject *module, int flag);
726
727
static PyObject *
728
sys_mdebug(PyObject *module, PyObject *arg)
729
{
730
PyObject *return_value = NULL;
731
int flag;
732
733
flag = _PyLong_AsInt(arg);
734
if (flag == -1 && PyErr_Occurred()) {
735
goto exit;
736
}
737
return_value = sys_mdebug_impl(module, flag);
738
739
exit:
740
return return_value;
741
}
742
743
#endif /* defined(USE_MALLOPT) */
744
745
PyDoc_STRVAR(sys_get_int_max_str_digits__doc__,
746
"get_int_max_str_digits($module, /)\n"
747
"--\n"
748
"\n"
749
"Return the maximum string digits limit for non-binary int<->str conversions.");
750
751
#define SYS_GET_INT_MAX_STR_DIGITS_METHODDEF \
752
{"get_int_max_str_digits", (PyCFunction)sys_get_int_max_str_digits, METH_NOARGS, sys_get_int_max_str_digits__doc__},
753
754
static PyObject *
755
sys_get_int_max_str_digits_impl(PyObject *module);
756
757
static PyObject *
758
sys_get_int_max_str_digits(PyObject *module, PyObject *Py_UNUSED(ignored))
759
{
760
return sys_get_int_max_str_digits_impl(module);
761
}
762
763
PyDoc_STRVAR(sys_set_int_max_str_digits__doc__,
764
"set_int_max_str_digits($module, /, maxdigits)\n"
765
"--\n"
766
"\n"
767
"Set the maximum string digits limit for non-binary int<->str conversions.");
768
769
#define SYS_SET_INT_MAX_STR_DIGITS_METHODDEF \
770
{"set_int_max_str_digits", _PyCFunction_CAST(sys_set_int_max_str_digits), METH_FASTCALL|METH_KEYWORDS, sys_set_int_max_str_digits__doc__},
771
772
static PyObject *
773
sys_set_int_max_str_digits_impl(PyObject *module, int maxdigits);
774
775
static PyObject *
776
sys_set_int_max_str_digits(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
777
{
778
PyObject *return_value = NULL;
779
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
780
781
#define NUM_KEYWORDS 1
782
static struct {
783
PyGC_Head _this_is_not_used;
784
PyObject_VAR_HEAD
785
PyObject *ob_item[NUM_KEYWORDS];
786
} _kwtuple = {
787
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
788
.ob_item = { &_Py_ID(maxdigits), },
789
};
790
#undef NUM_KEYWORDS
791
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
792
793
#else // !Py_BUILD_CORE
794
# define KWTUPLE NULL
795
#endif // !Py_BUILD_CORE
796
797
static const char * const _keywords[] = {"maxdigits", NULL};
798
static _PyArg_Parser _parser = {
799
.keywords = _keywords,
800
.fname = "set_int_max_str_digits",
801
.kwtuple = KWTUPLE,
802
};
803
#undef KWTUPLE
804
PyObject *argsbuf[1];
805
int maxdigits;
806
807
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
808
if (!args) {
809
goto exit;
810
}
811
maxdigits = _PyLong_AsInt(args[0]);
812
if (maxdigits == -1 && PyErr_Occurred()) {
813
goto exit;
814
}
815
return_value = sys_set_int_max_str_digits_impl(module, maxdigits);
816
817
exit:
818
return return_value;
819
}
820
821
PyDoc_STRVAR(sys_getrefcount__doc__,
822
"getrefcount($module, object, /)\n"
823
"--\n"
824
"\n"
825
"Return the reference count of object.\n"
826
"\n"
827
"The count returned is generally one higher than you might expect,\n"
828
"because it includes the (temporary) reference as an argument to\n"
829
"getrefcount().");
830
831
#define SYS_GETREFCOUNT_METHODDEF \
832
{"getrefcount", (PyCFunction)sys_getrefcount, METH_O, sys_getrefcount__doc__},
833
834
static Py_ssize_t
835
sys_getrefcount_impl(PyObject *module, PyObject *object);
836
837
static PyObject *
838
sys_getrefcount(PyObject *module, PyObject *object)
839
{
840
PyObject *return_value = NULL;
841
Py_ssize_t _return_value;
842
843
_return_value = sys_getrefcount_impl(module, object);
844
if ((_return_value == -1) && PyErr_Occurred()) {
845
goto exit;
846
}
847
return_value = PyLong_FromSsize_t(_return_value);
848
849
exit:
850
return return_value;
851
}
852
853
#if defined(Py_REF_DEBUG)
854
855
PyDoc_STRVAR(sys_gettotalrefcount__doc__,
856
"gettotalrefcount($module, /)\n"
857
"--\n"
858
"\n");
859
860
#define SYS_GETTOTALREFCOUNT_METHODDEF \
861
{"gettotalrefcount", (PyCFunction)sys_gettotalrefcount, METH_NOARGS, sys_gettotalrefcount__doc__},
862
863
static Py_ssize_t
864
sys_gettotalrefcount_impl(PyObject *module);
865
866
static PyObject *
867
sys_gettotalrefcount(PyObject *module, PyObject *Py_UNUSED(ignored))
868
{
869
PyObject *return_value = NULL;
870
Py_ssize_t _return_value;
871
872
_return_value = sys_gettotalrefcount_impl(module);
873
if ((_return_value == -1) && PyErr_Occurred()) {
874
goto exit;
875
}
876
return_value = PyLong_FromSsize_t(_return_value);
877
878
exit:
879
return return_value;
880
}
881
882
#endif /* defined(Py_REF_DEBUG) */
883
884
PyDoc_STRVAR(sys_getallocatedblocks__doc__,
885
"getallocatedblocks($module, /)\n"
886
"--\n"
887
"\n"
888
"Return the number of memory blocks currently allocated.");
889
890
#define SYS_GETALLOCATEDBLOCKS_METHODDEF \
891
{"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
892
893
static Py_ssize_t
894
sys_getallocatedblocks_impl(PyObject *module);
895
896
static PyObject *
897
sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
898
{
899
PyObject *return_value = NULL;
900
Py_ssize_t _return_value;
901
902
_return_value = sys_getallocatedblocks_impl(module);
903
if ((_return_value == -1) && PyErr_Occurred()) {
904
goto exit;
905
}
906
return_value = PyLong_FromSsize_t(_return_value);
907
908
exit:
909
return return_value;
910
}
911
912
PyDoc_STRVAR(sys_getunicodeinternedsize__doc__,
913
"getunicodeinternedsize($module, /)\n"
914
"--\n"
915
"\n"
916
"Return the number of elements of the unicode interned dictionary");
917
918
#define SYS_GETUNICODEINTERNEDSIZE_METHODDEF \
919
{"getunicodeinternedsize", (PyCFunction)sys_getunicodeinternedsize, METH_NOARGS, sys_getunicodeinternedsize__doc__},
920
921
static Py_ssize_t
922
sys_getunicodeinternedsize_impl(PyObject *module);
923
924
static PyObject *
925
sys_getunicodeinternedsize(PyObject *module, PyObject *Py_UNUSED(ignored))
926
{
927
PyObject *return_value = NULL;
928
Py_ssize_t _return_value;
929
930
_return_value = sys_getunicodeinternedsize_impl(module);
931
if ((_return_value == -1) && PyErr_Occurred()) {
932
goto exit;
933
}
934
return_value = PyLong_FromSsize_t(_return_value);
935
936
exit:
937
return return_value;
938
}
939
940
PyDoc_STRVAR(sys__getframe__doc__,
941
"_getframe($module, depth=0, /)\n"
942
"--\n"
943
"\n"
944
"Return a frame object from the call stack.\n"
945
"\n"
946
"If optional integer depth is given, return the frame object that many\n"
947
"calls below the top of the stack. If that is deeper than the call\n"
948
"stack, ValueError is raised. The default for depth is zero, returning\n"
949
"the frame at the top of the call stack.\n"
950
"\n"
951
"This function should be used for internal and specialized purposes\n"
952
"only.");
953
954
#define SYS__GETFRAME_METHODDEF \
955
{"_getframe", _PyCFunction_CAST(sys__getframe), METH_FASTCALL, sys__getframe__doc__},
956
957
static PyObject *
958
sys__getframe_impl(PyObject *module, int depth);
959
960
static PyObject *
961
sys__getframe(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
962
{
963
PyObject *return_value = NULL;
964
int depth = 0;
965
966
if (!_PyArg_CheckPositional("_getframe", nargs, 0, 1)) {
967
goto exit;
968
}
969
if (nargs < 1) {
970
goto skip_optional;
971
}
972
depth = _PyLong_AsInt(args[0]);
973
if (depth == -1 && PyErr_Occurred()) {
974
goto exit;
975
}
976
skip_optional:
977
return_value = sys__getframe_impl(module, depth);
978
979
exit:
980
return return_value;
981
}
982
983
PyDoc_STRVAR(sys__current_frames__doc__,
984
"_current_frames($module, /)\n"
985
"--\n"
986
"\n"
987
"Return a dict mapping each thread\'s thread id to its current stack frame.\n"
988
"\n"
989
"This function should be used for specialized purposes only.");
990
991
#define SYS__CURRENT_FRAMES_METHODDEF \
992
{"_current_frames", (PyCFunction)sys__current_frames, METH_NOARGS, sys__current_frames__doc__},
993
994
static PyObject *
995
sys__current_frames_impl(PyObject *module);
996
997
static PyObject *
998
sys__current_frames(PyObject *module, PyObject *Py_UNUSED(ignored))
999
{
1000
return sys__current_frames_impl(module);
1001
}
1002
1003
PyDoc_STRVAR(sys__current_exceptions__doc__,
1004
"_current_exceptions($module, /)\n"
1005
"--\n"
1006
"\n"
1007
"Return a dict mapping each thread\'s identifier to its current raised exception.\n"
1008
"\n"
1009
"This function should be used for specialized purposes only.");
1010
1011
#define SYS__CURRENT_EXCEPTIONS_METHODDEF \
1012
{"_current_exceptions", (PyCFunction)sys__current_exceptions, METH_NOARGS, sys__current_exceptions__doc__},
1013
1014
static PyObject *
1015
sys__current_exceptions_impl(PyObject *module);
1016
1017
static PyObject *
1018
sys__current_exceptions(PyObject *module, PyObject *Py_UNUSED(ignored))
1019
{
1020
return sys__current_exceptions_impl(module);
1021
}
1022
1023
PyDoc_STRVAR(sys_call_tracing__doc__,
1024
"call_tracing($module, func, args, /)\n"
1025
"--\n"
1026
"\n"
1027
"Call func(*args), while tracing is enabled.\n"
1028
"\n"
1029
"The tracing state is saved, and restored afterwards. This is intended\n"
1030
"to be called from a debugger from a checkpoint, to recursively debug\n"
1031
"some other code.");
1032
1033
#define SYS_CALL_TRACING_METHODDEF \
1034
{"call_tracing", _PyCFunction_CAST(sys_call_tracing), METH_FASTCALL, sys_call_tracing__doc__},
1035
1036
static PyObject *
1037
sys_call_tracing_impl(PyObject *module, PyObject *func, PyObject *funcargs);
1038
1039
static PyObject *
1040
sys_call_tracing(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1041
{
1042
PyObject *return_value = NULL;
1043
PyObject *func;
1044
PyObject *funcargs;
1045
1046
if (!_PyArg_CheckPositional("call_tracing", nargs, 2, 2)) {
1047
goto exit;
1048
}
1049
func = args[0];
1050
if (!PyTuple_Check(args[1])) {
1051
_PyArg_BadArgument("call_tracing", "argument 2", "tuple", args[1]);
1052
goto exit;
1053
}
1054
funcargs = args[1];
1055
return_value = sys_call_tracing_impl(module, func, funcargs);
1056
1057
exit:
1058
return return_value;
1059
}
1060
1061
PyDoc_STRVAR(sys__debugmallocstats__doc__,
1062
"_debugmallocstats($module, /)\n"
1063
"--\n"
1064
"\n"
1065
"Print summary info to stderr about the state of pymalloc\'s structures.\n"
1066
"\n"
1067
"In Py_DEBUG mode, also perform some expensive internal consistency\n"
1068
"checks.");
1069
1070
#define SYS__DEBUGMALLOCSTATS_METHODDEF \
1071
{"_debugmallocstats", (PyCFunction)sys__debugmallocstats, METH_NOARGS, sys__debugmallocstats__doc__},
1072
1073
static PyObject *
1074
sys__debugmallocstats_impl(PyObject *module);
1075
1076
static PyObject *
1077
sys__debugmallocstats(PyObject *module, PyObject *Py_UNUSED(ignored))
1078
{
1079
return sys__debugmallocstats_impl(module);
1080
}
1081
1082
PyDoc_STRVAR(sys__clear_type_cache__doc__,
1083
"_clear_type_cache($module, /)\n"
1084
"--\n"
1085
"\n"
1086
"Clear the internal type lookup cache.");
1087
1088
#define SYS__CLEAR_TYPE_CACHE_METHODDEF \
1089
{"_clear_type_cache", (PyCFunction)sys__clear_type_cache, METH_NOARGS, sys__clear_type_cache__doc__},
1090
1091
static PyObject *
1092
sys__clear_type_cache_impl(PyObject *module);
1093
1094
static PyObject *
1095
sys__clear_type_cache(PyObject *module, PyObject *Py_UNUSED(ignored))
1096
{
1097
return sys__clear_type_cache_impl(module);
1098
}
1099
1100
PyDoc_STRVAR(sys_is_finalizing__doc__,
1101
"is_finalizing($module, /)\n"
1102
"--\n"
1103
"\n"
1104
"Return True if Python is exiting.");
1105
1106
#define SYS_IS_FINALIZING_METHODDEF \
1107
{"is_finalizing", (PyCFunction)sys_is_finalizing, METH_NOARGS, sys_is_finalizing__doc__},
1108
1109
static PyObject *
1110
sys_is_finalizing_impl(PyObject *module);
1111
1112
static PyObject *
1113
sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
1114
{
1115
return sys_is_finalizing_impl(module);
1116
}
1117
1118
#if defined(Py_STATS)
1119
1120
PyDoc_STRVAR(sys__stats_on__doc__,
1121
"_stats_on($module, /)\n"
1122
"--\n"
1123
"\n"
1124
"Turns on stats gathering (stats gathering is on by default).");
1125
1126
#define SYS__STATS_ON_METHODDEF \
1127
{"_stats_on", (PyCFunction)sys__stats_on, METH_NOARGS, sys__stats_on__doc__},
1128
1129
static PyObject *
1130
sys__stats_on_impl(PyObject *module);
1131
1132
static PyObject *
1133
sys__stats_on(PyObject *module, PyObject *Py_UNUSED(ignored))
1134
{
1135
return sys__stats_on_impl(module);
1136
}
1137
1138
#endif /* defined(Py_STATS) */
1139
1140
#if defined(Py_STATS)
1141
1142
PyDoc_STRVAR(sys__stats_off__doc__,
1143
"_stats_off($module, /)\n"
1144
"--\n"
1145
"\n"
1146
"Turns off stats gathering (stats gathering is on by default).");
1147
1148
#define SYS__STATS_OFF_METHODDEF \
1149
{"_stats_off", (PyCFunction)sys__stats_off, METH_NOARGS, sys__stats_off__doc__},
1150
1151
static PyObject *
1152
sys__stats_off_impl(PyObject *module);
1153
1154
static PyObject *
1155
sys__stats_off(PyObject *module, PyObject *Py_UNUSED(ignored))
1156
{
1157
return sys__stats_off_impl(module);
1158
}
1159
1160
#endif /* defined(Py_STATS) */
1161
1162
#if defined(Py_STATS)
1163
1164
PyDoc_STRVAR(sys__stats_clear__doc__,
1165
"_stats_clear($module, /)\n"
1166
"--\n"
1167
"\n"
1168
"Clears the stats.");
1169
1170
#define SYS__STATS_CLEAR_METHODDEF \
1171
{"_stats_clear", (PyCFunction)sys__stats_clear, METH_NOARGS, sys__stats_clear__doc__},
1172
1173
static PyObject *
1174
sys__stats_clear_impl(PyObject *module);
1175
1176
static PyObject *
1177
sys__stats_clear(PyObject *module, PyObject *Py_UNUSED(ignored))
1178
{
1179
return sys__stats_clear_impl(module);
1180
}
1181
1182
#endif /* defined(Py_STATS) */
1183
1184
#if defined(Py_STATS)
1185
1186
PyDoc_STRVAR(sys__stats_dump__doc__,
1187
"_stats_dump($module, /)\n"
1188
"--\n"
1189
"\n"
1190
"Dump stats to file, and clears the stats.");
1191
1192
#define SYS__STATS_DUMP_METHODDEF \
1193
{"_stats_dump", (PyCFunction)sys__stats_dump, METH_NOARGS, sys__stats_dump__doc__},
1194
1195
static PyObject *
1196
sys__stats_dump_impl(PyObject *module);
1197
1198
static PyObject *
1199
sys__stats_dump(PyObject *module, PyObject *Py_UNUSED(ignored))
1200
{
1201
return sys__stats_dump_impl(module);
1202
}
1203
1204
#endif /* defined(Py_STATS) */
1205
1206
#if defined(ANDROID_API_LEVEL)
1207
1208
PyDoc_STRVAR(sys_getandroidapilevel__doc__,
1209
"getandroidapilevel($module, /)\n"
1210
"--\n"
1211
"\n"
1212
"Return the build time API version of Android as an integer.");
1213
1214
#define SYS_GETANDROIDAPILEVEL_METHODDEF \
1215
{"getandroidapilevel", (PyCFunction)sys_getandroidapilevel, METH_NOARGS, sys_getandroidapilevel__doc__},
1216
1217
static PyObject *
1218
sys_getandroidapilevel_impl(PyObject *module);
1219
1220
static PyObject *
1221
sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
1222
{
1223
return sys_getandroidapilevel_impl(module);
1224
}
1225
1226
#endif /* defined(ANDROID_API_LEVEL) */
1227
1228
PyDoc_STRVAR(sys_activate_stack_trampoline__doc__,
1229
"activate_stack_trampoline($module, backend, /)\n"
1230
"--\n"
1231
"\n"
1232
"Activate stack profiler trampoline *backend*.");
1233
1234
#define SYS_ACTIVATE_STACK_TRAMPOLINE_METHODDEF \
1235
{"activate_stack_trampoline", (PyCFunction)sys_activate_stack_trampoline, METH_O, sys_activate_stack_trampoline__doc__},
1236
1237
static PyObject *
1238
sys_activate_stack_trampoline_impl(PyObject *module, const char *backend);
1239
1240
static PyObject *
1241
sys_activate_stack_trampoline(PyObject *module, PyObject *arg)
1242
{
1243
PyObject *return_value = NULL;
1244
const char *backend;
1245
1246
if (!PyUnicode_Check(arg)) {
1247
_PyArg_BadArgument("activate_stack_trampoline", "argument", "str", arg);
1248
goto exit;
1249
}
1250
Py_ssize_t backend_length;
1251
backend = PyUnicode_AsUTF8AndSize(arg, &backend_length);
1252
if (backend == NULL) {
1253
goto exit;
1254
}
1255
if (strlen(backend) != (size_t)backend_length) {
1256
PyErr_SetString(PyExc_ValueError, "embedded null character");
1257
goto exit;
1258
}
1259
return_value = sys_activate_stack_trampoline_impl(module, backend);
1260
1261
exit:
1262
return return_value;
1263
}
1264
1265
PyDoc_STRVAR(sys_deactivate_stack_trampoline__doc__,
1266
"deactivate_stack_trampoline($module, /)\n"
1267
"--\n"
1268
"\n"
1269
"Deactivate the current stack profiler trampoline backend.\n"
1270
"\n"
1271
"If no stack profiler is activated, this function has no effect.");
1272
1273
#define SYS_DEACTIVATE_STACK_TRAMPOLINE_METHODDEF \
1274
{"deactivate_stack_trampoline", (PyCFunction)sys_deactivate_stack_trampoline, METH_NOARGS, sys_deactivate_stack_trampoline__doc__},
1275
1276
static PyObject *
1277
sys_deactivate_stack_trampoline_impl(PyObject *module);
1278
1279
static PyObject *
1280
sys_deactivate_stack_trampoline(PyObject *module, PyObject *Py_UNUSED(ignored))
1281
{
1282
return sys_deactivate_stack_trampoline_impl(module);
1283
}
1284
1285
PyDoc_STRVAR(sys_is_stack_trampoline_active__doc__,
1286
"is_stack_trampoline_active($module, /)\n"
1287
"--\n"
1288
"\n"
1289
"Return *True* if a stack profiler trampoline is active.");
1290
1291
#define SYS_IS_STACK_TRAMPOLINE_ACTIVE_METHODDEF \
1292
{"is_stack_trampoline_active", (PyCFunction)sys_is_stack_trampoline_active, METH_NOARGS, sys_is_stack_trampoline_active__doc__},
1293
1294
static PyObject *
1295
sys_is_stack_trampoline_active_impl(PyObject *module);
1296
1297
static PyObject *
1298
sys_is_stack_trampoline_active(PyObject *module, PyObject *Py_UNUSED(ignored))
1299
{
1300
return sys_is_stack_trampoline_active_impl(module);
1301
}
1302
1303
PyDoc_STRVAR(sys__getframemodulename__doc__,
1304
"_getframemodulename($module, /, depth=0)\n"
1305
"--\n"
1306
"\n"
1307
"Return the name of the module for a calling frame.\n"
1308
"\n"
1309
"The default depth returns the module containing the call to this API.\n"
1310
"A more typical use in a library will pass a depth of 1 to get the user\'s\n"
1311
"module rather than the library module.\n"
1312
"\n"
1313
"If no frame, module, or name can be found, returns None.");
1314
1315
#define SYS__GETFRAMEMODULENAME_METHODDEF \
1316
{"_getframemodulename", _PyCFunction_CAST(sys__getframemodulename), METH_FASTCALL|METH_KEYWORDS, sys__getframemodulename__doc__},
1317
1318
static PyObject *
1319
sys__getframemodulename_impl(PyObject *module, int depth);
1320
1321
static PyObject *
1322
sys__getframemodulename(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1323
{
1324
PyObject *return_value = NULL;
1325
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
1326
1327
#define NUM_KEYWORDS 1
1328
static struct {
1329
PyGC_Head _this_is_not_used;
1330
PyObject_VAR_HEAD
1331
PyObject *ob_item[NUM_KEYWORDS];
1332
} _kwtuple = {
1333
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
1334
.ob_item = { &_Py_ID(depth), },
1335
};
1336
#undef NUM_KEYWORDS
1337
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
1338
1339
#else // !Py_BUILD_CORE
1340
# define KWTUPLE NULL
1341
#endif // !Py_BUILD_CORE
1342
1343
static const char * const _keywords[] = {"depth", NULL};
1344
static _PyArg_Parser _parser = {
1345
.keywords = _keywords,
1346
.fname = "_getframemodulename",
1347
.kwtuple = KWTUPLE,
1348
};
1349
#undef KWTUPLE
1350
PyObject *argsbuf[1];
1351
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
1352
int depth = 0;
1353
1354
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
1355
if (!args) {
1356
goto exit;
1357
}
1358
if (!noptargs) {
1359
goto skip_optional_pos;
1360
}
1361
depth = _PyLong_AsInt(args[0]);
1362
if (depth == -1 && PyErr_Occurred()) {
1363
goto exit;
1364
}
1365
skip_optional_pos:
1366
return_value = sys__getframemodulename_impl(module, depth);
1367
1368
exit:
1369
return return_value;
1370
}
1371
1372
#ifndef SYS_GETWINDOWSVERSION_METHODDEF
1373
#define SYS_GETWINDOWSVERSION_METHODDEF
1374
#endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
1375
1376
#ifndef SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1377
#define SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF
1378
#endif /* !defined(SYS__ENABLELEGACYWINDOWSFSENCODING_METHODDEF) */
1379
1380
#ifndef SYS_SETDLOPENFLAGS_METHODDEF
1381
#define SYS_SETDLOPENFLAGS_METHODDEF
1382
#endif /* !defined(SYS_SETDLOPENFLAGS_METHODDEF) */
1383
1384
#ifndef SYS_GETDLOPENFLAGS_METHODDEF
1385
#define SYS_GETDLOPENFLAGS_METHODDEF
1386
#endif /* !defined(SYS_GETDLOPENFLAGS_METHODDEF) */
1387
1388
#ifndef SYS_MDEBUG_METHODDEF
1389
#define SYS_MDEBUG_METHODDEF
1390
#endif /* !defined(SYS_MDEBUG_METHODDEF) */
1391
1392
#ifndef SYS_GETTOTALREFCOUNT_METHODDEF
1393
#define SYS_GETTOTALREFCOUNT_METHODDEF
1394
#endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
1395
1396
#ifndef SYS__STATS_ON_METHODDEF
1397
#define SYS__STATS_ON_METHODDEF
1398
#endif /* !defined(SYS__STATS_ON_METHODDEF) */
1399
1400
#ifndef SYS__STATS_OFF_METHODDEF
1401
#define SYS__STATS_OFF_METHODDEF
1402
#endif /* !defined(SYS__STATS_OFF_METHODDEF) */
1403
1404
#ifndef SYS__STATS_CLEAR_METHODDEF
1405
#define SYS__STATS_CLEAR_METHODDEF
1406
#endif /* !defined(SYS__STATS_CLEAR_METHODDEF) */
1407
1408
#ifndef SYS__STATS_DUMP_METHODDEF
1409
#define SYS__STATS_DUMP_METHODDEF
1410
#endif /* !defined(SYS__STATS_DUMP_METHODDEF) */
1411
1412
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
1413
#define SYS_GETANDROIDAPILEVEL_METHODDEF
1414
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
1415
/*[clinic end generated code: output=41937e0843c68009 input=a9049054013a1b77]*/
1416
1417