sysmodule.c.h 40 KB

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