/* System module */ /*Various bits of information used by the interpreter are collected inmodule 'sys'.Function member:- exit(sts): raise SystemExitData members:- stdin, stdout, stderr: standard file objects- modules: the table of modules (dictionary)- path: module search path (list of strings)- argv: script arguments (list of strings)- ps1, ps2: optional primary and secondary prompts (strings)*/ #include "Python.h"#include "code.h"#include "frameobject.h"#include "eval.h" #include "osdefs.h" #ifdef MS_WINDOWS#define WIN32_LEAN_AND_MEAN#include "windows.h"#endif /* MS_WINDOWS */ #ifdef MS_COREDLLextern void *PyWin_DLLhModule;/* A string loaded from the DLL at startup: */extern const char *PyWin_DLLVersionString;#endif #ifdef __VMS#include <unixlib.h>#endif #ifdef MS_WINDOWS#include <windows.h>#endif #ifdef HAVE_LANGINFO_H#include <locale.h>#include <langinfo.h>#endif PyObject *PySys_GetObject(char *name){ PyThreadState *tstate = PyThreadState_GET(); PyObject *sd = tstate->interp->sysdict; if (sd == NULL) return NULL; return PyDict_GetItemString(sd, name);} FILE *PySys_GetFile(char *name, FILE *def){ FILE *fp = NULL; PyObject *v = PySys_GetObject(name); if (v != NULL && PyFile_Check(v)) fp = PyFile_AsFile(v); if (fp == NULL) fp = def; return fp;} intPySys_SetObject(char *name, PyObject *v){ PyThreadState *tstate = PyThreadState_GET(); PyObject *sd = tstate->interp->sysdict; if (v == NULL) { if (PyDict_GetItemString(sd, name) == NULL) return 0; else return PyDict_DelItemString(sd, name); } else return PyDict_SetItemString(sd, name, v);} static PyObject *sys_displayhook(PyObject *self, PyObject *o){ PyObject *outf; PyInterpreterState *interp = PyThreadState_GET()->interp; PyObject *modules = interp->modules; PyObject *builtins = PyDict_GetItemString(modules, "__builtin__"); if (builtins == NULL) { PyErr_SetString(PyExc_RuntimeError, "lost __builtin__"); return NULL; } /* Print value except if None */ /* After printing, also assign to '_' */ /* Before, set '_' to None to avoid recursion */ if (o == Py_None) { Py_INCREF(Py_None); return Py_None; } if (PyObject_SetAttrString(builtins, "_", Py_None) != 0) return NULL; if (Py_FlushLine() != 0) return NULL; outf = PySys_GetObject("stdout"); if (outf == NULL) { PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); return NULL; } if (PyFile_WriteObject(o, outf, 0) != 0) return NULL; PyFile_SoftSpace(outf, 1); if (Py_FlushLine() != 0) return NULL; if (PyObject_SetAttrString(builtins, "_", o) != 0) return NULL; Py_INCREF(Py_None); return Py_None;} PyDoc_STRVAR(displayhook_doc,"displayhook(object) -> None\n""\n""Print an object to sys.stdout and also save it in __builtin__.\n"); static PyObject *sys_excepthook(PyObject* self, PyObject* args){ PyObject *exc, *value, *tb; if (!PyArg_UnpackTuple(args, "excepthook", 3, 3, &exc, &value, &tb)) return NULL; PyErr_Display(exc, value, tb); Py_INCREF(Py_None); return Py_None;} PyDoc_STRVAR(excepthook_doc,"excepthook(exctype, value, traceback) -> None\n""\n""Handle an exception by displaying it with a traceback on sys.stderr.\n"); static PyObject *sys_exc_info(PyObject *self, PyObject *noargs){ PyThreadState *tstate; tstate = PyThreadState_GET(); return Py_BuildValue( "(OOO)", tstate->exc_type != NULL ? tstate->exc_type : Py_None, tstate->exc_value != NULL ? tstate->exc_value : Py_None, tstate->exc_traceback != NULL ? tstate->exc_traceback : Py_None);} PyDoc_STRVAR(exc_info_doc,"exc_info() -> (type, value, traceback)\n\\n\Return information about the most recent exception caught by an except\n\clause in the current stack frame or in an older stack frame."); static PyObject *sys_exc_clear(PyObject *self, PyObject *noargs){ PyThreadState *tstate = PyThreadState_GET(); PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = NULL; tstate->exc_value = NULL; tstate->exc_traceback = NULL; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); /* For b/w compatibility */ PySys_SetObject("exc_type", Py_None); PySys_SetObject("exc_value", Py_None); PySys_SetObject("exc_traceback", Py_None); Py_INCREF(Py_None); return Py_None;} PyDoc_STRVAR(exc_clear_doc,"exc_clear() -> None\n\\n\Clear global information on the current exception. Subsequent calls to\n\exc_info() will return (None,None,None) until another exception is raised\n\in the current thread or the execution stack returns to a frame where\n\another exception is being handled."); static PyObject *sys_exit(PyObject *self, PyObject *args){ PyObject *exit_code = 0; if (!PyArg_UnpackTuple(args, "exit", 0, 1, &exit_code)) return NULL; /* Raise SystemExit so callers may catch it or clean up. */ PyErr_SetObject(PyExc_SystemExit, exit_code); return NULL;} PyDoc_STRVAR(exit_doc,"exit([status])\n\\n\Exit the interpreter by raising SystemExit(status).\n\If the status is omitted or None, it defaults to zero (i.e., success).\n\If the status is numeric, it will be used as the system exit status.\n\If it is another kind of object, it will be printed and the system\n\exit status will be one (i.e., failure)."); #ifdef Py_USING_UNICODE static PyObject *sys_getdefaultencoding(PyObject *self){ return PyString_FromString(PyUnicode_GetDefaultEncoding());} PyDoc_STRVAR(getdefaultencoding_doc,"getdefaultencoding() -> string\n\\n\Return the current default string encoding used by the Unicode \n\implementation."); static PyObject *sys_setdefaultencoding(PyObject *self, PyObject *args){ char *encoding; if (!PyArg_ParseTuple(args, "s:setdefaultencoding", &encoding)) return NULL; if (PyUnicode_SetDefaultEncoding(encoding)) return NULL; Py_INCREF(Py_None); return Py_None;} PyDoc_STRVAR(setdefaultencoding_doc,"setdefaultencoding(encoding)\n\\n\Set the current default string encoding used by the Unicode implementation."); static PyObject *sys_getfilesystemencoding(PyObject *self){ if (Py_FileSystemDefaultEncoding) return PyString_FromString(Py_FileSystemDefaultEncoding); Py_INCREF(Py_None); return Py_None;} PyDoc_STRVAR(getfilesystemencoding_doc,"getfilesystemencoding() -> string\n\\n\Return the encoding used to convert Unicode filenames in\n\operating system filenames."); #endif /* * Cached interned string objects used for calling the profile and * trace functions. Initialized by trace_init(). */static PyObject *whatstrings[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; static inttrace_init(void){ static char *whatnames[7] = {"call", "exception", "line", "return", "c_call", "c_exception", "c_return"}; PyObject *name; int i; for (i = 0; i < 7; ++i) { if (whatstrings[i] == NULL) { name = PyString_InternFromString(whatnames[i]); if (name == NULL) return -1; whatstrings[i] = name; } } return 0;} static PyObject *call_trampoline(PyThreadState *tstate, PyObject* callback, PyFrameObject *frame, int what, PyObject *arg){ PyObject *args = PyTuple_New(3); PyObject *whatstr; PyObject *result; if (args == NULL) return NULL; Py_INCREF(frame); whatstr = whatstrings[what]; Py_INCREF(whatstr); if (arg == NULL) arg = Py_None; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, (PyObject *)frame); PyTuple_SET_ITEM(args, 1, whatstr); PyTuple_SET_ITEM(args, 2, arg); /* call the Python-level function */ PyFrame_FastToLocals(frame); result = PyEval_CallObject(callback, args); PyFrame_LocalsToFast(frame, 1); if (result == NULL) PyTraceBack_Here(frame); /* cleanup */ Py_DECREF(args); return result;} static intprofile_trampoline(PyObject *self, PyFrameObject *frame, int what, PyObject *arg){ PyThreadState *tstate = frame->f_tstate; PyObject *result; if (arg == NULL) arg = Py_None; result = call_trampoline(tstate, self, frame, what, arg); if (result == NULL) { PyEval_SetProfile(NULL, NULL); return -1; } Py_DECREF(result); return 0;} static inttrace_trampoline(PyObject *self, PyFrameObject *frame, int what, PyObject *arg){ PyThreadState *tstate = frame->f_tstate; PyObject *callback; PyObject *result; if (what == PyTrace_CALL) callback = self; else callback = frame->f_trace; if (callback == NULL) return 0; result = call_trampoline(tstate, callback, frame, what, arg); if (result == NULL) { PyEval_SetTrace(NULL, NULL); Py_XDECREF(frame->f_trace); frame->f_trace = NULL; return -1; } if (result != Py_None) { PyObject *temp = frame->f_trace; frame->f_trace = NULL; Py_XDECREF(temp); frame->f_trace = result; } else { Py_DECREF(result); } return 0;} static PyObject *sys_settrace(PyObject *self, PyObject *args){ if (trace_init() == -1) return NULL; if (args == Py_None) PyEval_SetTrace(NULL, NULL); else PyEval_SetTrace(trace_trampoline, args); Py_INCREF(Py_None); return Py_None;} PyDoc_STRVAR(settrace_doc,"settrace(function)\n\\n\Set the global debug tracing function. It will be called on each\n\function call. See the debugger chapter in the library manual."); static PyObject *sys_setprofile(PyObject *self, PyObject *args){ if (trace_init() == -1) return NULL; if (args == Py_None) PyEval_SetProfile(NULL, NULL); else PyEval_SetProfile(profile_trampoline, args); Py_INCREF(Py_None); return Py_None;} PyDoc_STRVAR(setprofile_doc,"setprofile(function)\n\\n\Set the profiling function. It will be called on each function call\n\and return. See the profiler chapter in the library manual."); static PyObject *sys_setcheckinterval(PyObject *self, PyObject *args){ if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval)) return NULL; Py_INCREF(Py_None); return Py_None;} PyDoc_STRVAR(setcheckinterval_doc,"setcheckinterval(n)\n\\n\Tell the Python interpreter to check for asynchronous events every\n\n instructions. This also affects how often thread switches occur."); static PyObject *sys_getcheckinterval(PyObject *self, PyObject *args){ return PyInt_FromLong(_Py_CheckInterval);} PyDoc_STRVAR(getcheckinterval_doc,"getcheckinterval() -> current check interval; see setcheckinterval()."); #ifdef WITH_TSCstatic PyObject *sys_settscdump(PyObject *self, PyObject *args){ int bool; PyThreadState *tstate = PyThreadState_Get(); if (!PyArg_ParseTuple(args, "i:settscdump", &bool)) return NULL; if (bool) tstate->interp->tscdump = 1; else tstate->interp->tscdump = 0; Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(settscdump_doc,"settscdump(bool)\n\\n\If true, tell the Python interpreter to dump VM measurements to\n\stderr. If false, turn off dump. The measurements are based on the\n\processor's time-stamp counter.");#endif /* TSC */ static PyObject *sys_setrecursionlimit(PyObject *self, PyObject *args){ int new_limit; if (!PyArg_ParseTuple(args, "i:setrecursionlimit", &new_limit)) return NULL; if (new_limit <= 0) { PyErr_SetString(PyExc_ValueError, "recursion limit must be positive"); return NULL; } Py_SetRecursionLimit(new_limit); Py_INCREF(Py_None); return Py_None;} PyDoc_STRVAR(setrecursionlimit_doc,"setrecursionlimit(n)\n\\n\Set the maximum depth of the Python interpreter stack to n. This\n\limit prevents infinite recursion from causing an overflow of the C\n\stack and crashing Python. The highest possible limit is platform-\n\dependent."); static PyObject *sys_getrecursionlimit(PyObject *self){ return PyInt_FromLong(Py_GetRecursionLimit());Lines 1–500 of 1468. Load more
/* System module */ /* Various bits of information used by the interpreter are collected in module 'sys'. Function member: - exit(sts): raise SystemExit Data members: - stdin, stdout, stderr: standard file objects - modules: the table of modules (dictionary) - path: module search path (list of strings) - argv: script arguments (list of strings) - ps1, ps2: optional primary and secondary prompts (strings) */ #include "Python.h" #include "code.h" #include "frameobject.h" #include "eval.h" #include "osdefs.h" #ifdef MS_WINDOWS #define WIN32_LEAN_AND_MEAN #include "windows.h" #endif /* MS_WINDOWS */ #ifdef MS_COREDLL extern void *PyWin_DLLhModule; /* A string loaded from the DLL at startup: */ extern const char *PyWin_DLLVersionString; #endif #ifdef __VMS #include <unixlib.h> #endif #ifdef MS_WINDOWS #include <windows.h> #endif #ifdef HAVE_LANGINFO_H #include <locale.h> #include <langinfo.h> #endif PyObject * PySys_GetObject(char *name) { PyThreadState *tstate = PyThreadState_GET(); PyObject *sd = tstate->interp->sysdict; if (sd == NULL) return NULL; return PyDict_GetItemString(sd, name); } FILE * PySys_GetFile(char *name, FILE *def) { FILE *fp = NULL; PyObject *v = PySys_GetObject(name); if (v != NULL && PyFile_Check(v)) fp = PyFile_AsFile(v); if (fp == NULL) fp = def; return fp; } int PySys_SetObject(char *name, PyObject *v) { PyThreadState *tstate = PyThreadState_GET(); PyObject *sd = tstate->interp->sysdict; if (v == NULL) { if (PyDict_GetItemString(sd, name) == NULL) return 0; else return PyDict_DelItemString(sd, name); } else return PyDict_SetItemString(sd, name, v); } static PyObject * sys_displayhook(PyObject *self, PyObject *o) { PyObject *outf; PyInterpreterState *interp = PyThreadState_GET()->interp; PyObject *modules = interp->modules; PyObject *builtins = PyDict_GetItemString(modules, "__builtin__"); if (builtins == NULL) { PyErr_SetString(PyExc_RuntimeError, "lost __builtin__"); return NULL; } /* Print value except if None */ /* After printing, also assign to '_' */ /* Before, set '_' to None to avoid recursion */ if (o == Py_None) { Py_INCREF(Py_None); return Py_None; } if (PyObject_SetAttrString(builtins, "_", Py_None) != 0) return NULL; if (Py_FlushLine() != 0) return NULL; outf = PySys_GetObject("stdout"); if (outf == NULL) { PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); return NULL; } if (PyFile_WriteObject(o, outf, 0) != 0) return NULL; PyFile_SoftSpace(outf, 1); if (Py_FlushLine() != 0) return NULL; if (PyObject_SetAttrString(builtins, "_", o) != 0) return NULL; Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(displayhook_doc, "displayhook(object) -> None\n" "\n" "Print an object to sys.stdout and also save it in __builtin__.\n" ); static PyObject * sys_excepthook(PyObject* self, PyObject* args) { PyObject *exc, *value, *tb; if (!PyArg_UnpackTuple(args, "excepthook", 3, 3, &exc, &value, &tb)) return NULL; PyErr_Display(exc, value, tb); Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(excepthook_doc, "excepthook(exctype, value, traceback) -> None\n" "\n" "Handle an exception by displaying it with a traceback on sys.stderr.\n" ); static PyObject * sys_exc_info(PyObject *self, PyObject *noargs) { PyThreadState *tstate; tstate = PyThreadState_GET(); return Py_BuildValue( "(OOO)", tstate->exc_type != NULL ? tstate->exc_type : Py_None, tstate->exc_value != NULL ? tstate->exc_value : Py_None, tstate->exc_traceback != NULL ? tstate->exc_traceback : Py_None); } PyDoc_STRVAR(exc_info_doc, "exc_info() -> (type, value, traceback)\n\ \n\ Return information about the most recent exception caught by an except\n\ clause in the current stack frame or in an older stack frame." ); static PyObject * sys_exc_clear(PyObject *self, PyObject *noargs) { PyThreadState *tstate = PyThreadState_GET(); PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = NULL; tstate->exc_value = NULL; tstate->exc_traceback = NULL; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); /* For b/w compatibility */ PySys_SetObject("exc_type", Py_None); PySys_SetObject("exc_value", Py_None); PySys_SetObject("exc_traceback", Py_None); Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(exc_clear_doc, "exc_clear() -> None\n\ \n\ Clear global information on the current exception. Subsequent calls to\n\ exc_info() will return (None,None,None) until another exception is raised\n\ in the current thread or the execution stack returns to a frame where\n\ another exception is being handled." ); static PyObject * sys_exit(PyObject *self, PyObject *args) { PyObject *exit_code = 0; if (!PyArg_UnpackTuple(args, "exit", 0, 1, &exit_code)) return NULL; /* Raise SystemExit so callers may catch it or clean up. */ PyErr_SetObject(PyExc_SystemExit, exit_code); return NULL; } PyDoc_STRVAR(exit_doc, "exit([status])\n\ \n\ Exit the interpreter by raising SystemExit(status).\n\ If the status is omitted or None, it defaults to zero (i.e., success).\n\ If the status is numeric, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ exit status will be one (i.e., failure)." ); #ifdef Py_USING_UNICODE static PyObject * sys_getdefaultencoding(PyObject *self) { return PyString_FromString(PyUnicode_GetDefaultEncoding()); } PyDoc_STRVAR(getdefaultencoding_doc, "getdefaultencoding() -> string\n\ \n\ Return the current default string encoding used by the Unicode \n\ implementation." ); static PyObject * sys_setdefaultencoding(PyObject *self, PyObject *args) { char *encoding; if (!PyArg_ParseTuple(args, "s:setdefaultencoding", &encoding)) return NULL; if (PyUnicode_SetDefaultEncoding(encoding)) return NULL; Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(setdefaultencoding_doc, "setdefaultencoding(encoding)\n\ \n\ Set the current default string encoding used by the Unicode implementation." ); static PyObject * sys_getfilesystemencoding(PyObject *self) { if (Py_FileSystemDefaultEncoding) return PyString_FromString(Py_FileSystemDefaultEncoding); Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(getfilesystemencoding_doc, "getfilesystemencoding() -> string\n\ \n\ Return the encoding used to convert Unicode filenames in\n\ operating system filenames." ); #endif /* * Cached interned string objects used for calling the profile and * trace functions. Initialized by trace_init(). */ static PyObject *whatstrings[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; static int trace_init(void) { static char *whatnames[7] = {"call", "exception", "line", "return", "c_call", "c_exception", "c_return"}; PyObject *name; int i; for (i = 0; i < 7; ++i) { if (whatstrings[i] == NULL) { name = PyString_InternFromString(whatnames[i]); if (name == NULL) return -1; whatstrings[i] = name; } } return 0; } static PyObject * call_trampoline(PyThreadState *tstate, PyObject* callback, PyFrameObject *frame, int what, PyObject *arg) { PyObject *args = PyTuple_New(3); PyObject *whatstr; PyObject *result; if (args == NULL) return NULL; Py_INCREF(frame); whatstr = whatstrings[what]; Py_INCREF(whatstr); if (arg == NULL) arg = Py_None; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, (PyObject *)frame); PyTuple_SET_ITEM(args, 1, whatstr); PyTuple_SET_ITEM(args, 2, arg); /* call the Python-level function */ PyFrame_FastToLocals(frame); result = PyEval_CallObject(callback, args); PyFrame_LocalsToFast(frame, 1); if (result == NULL) PyTraceBack_Here(frame); /* cleanup */ Py_DECREF(args); return result; } static int profile_trampoline(PyObject *self, PyFrameObject *frame, int what, PyObject *arg) { PyThreadState *tstate = frame->f_tstate; PyObject *result; if (arg == NULL) arg = Py_None; result = call_trampoline(tstate, self, frame, what, arg); if (result == NULL) { PyEval_SetProfile(NULL, NULL); return -1; } Py_DECREF(result); return 0; } static int trace_trampoline(PyObject *self, PyFrameObject *frame, int what, PyObject *arg) { PyThreadState *tstate = frame->f_tstate; PyObject *callback; PyObject *result; if (what == PyTrace_CALL) callback = self; else callback = frame->f_trace; if (callback == NULL) return 0; result = call_trampoline(tstate, callback, frame, what, arg); if (result == NULL) { PyEval_SetTrace(NULL, NULL); Py_XDECREF(frame->f_trace); frame->f_trace = NULL; return -1; } if (result != Py_None) { PyObject *temp = frame->f_trace; frame->f_trace = NULL; Py_XDECREF(temp); frame->f_trace = result; } else { Py_DECREF(result); } return 0; } static PyObject * sys_settrace(PyObject *self, PyObject *args) { if (trace_init() == -1) return NULL; if (args == Py_None) PyEval_SetTrace(NULL, NULL); else PyEval_SetTrace(trace_trampoline, args); Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(settrace_doc, "settrace(function)\n\ \n\ Set the global debug tracing function. It will be called on each\n\ function call. See the debugger chapter in the library manual." ); static PyObject * sys_setprofile(PyObject *self, PyObject *args) { if (trace_init() == -1) return NULL; if (args == Py_None) PyEval_SetProfile(NULL, NULL); else PyEval_SetProfile(profile_trampoline, args); Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(setprofile_doc, "setprofile(function)\n\ \n\ Set the profiling function. It will be called on each function call\n\ and return. See the profiler chapter in the library manual." ); static PyObject * sys_setcheckinterval(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_Py_CheckInterval)) return NULL; Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(setcheckinterval_doc, "setcheckinterval(n)\n\ \n\ Tell the Python interpreter to check for asynchronous events every\n\ n instructions. This also affects how often thread switches occur." ); static PyObject * sys_getcheckinterval(PyObject *self, PyObject *args) { return PyInt_FromLong(_Py_CheckInterval); } PyDoc_STRVAR(getcheckinterval_doc, "getcheckinterval() -> current check interval; see setcheckinterval()." ); #ifdef WITH_TSC static PyObject * sys_settscdump(PyObject *self, PyObject *args) { int bool; PyThreadState *tstate = PyThreadState_Get(); if (!PyArg_ParseTuple(args, "i:settscdump", &bool)) return NULL; if (bool) tstate->interp->tscdump = 1; else tstate->interp->tscdump = 0; Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(settscdump_doc, "settscdump(bool)\n\ \n\ If true, tell the Python interpreter to dump VM measurements to\n\ stderr. If false, turn off dump. The measurements are based on the\n\ processor's time-stamp counter." ); #endif /* TSC */ static PyObject * sys_setrecursionlimit(PyObject *self, PyObject *args) { int new_limit; if (!PyArg_ParseTuple(args, "i:setrecursionlimit", &new_limit)) return NULL; if (new_limit <= 0) { PyErr_SetString(PyExc_ValueError, "recursion limit must be positive"); return NULL; } Py_SetRecursionLimit(new_limit); Py_INCREF(Py_None); return Py_None; } PyDoc_STRVAR(setrecursionlimit_doc, "setrecursionlimit(n)\n\ \n\ Set the maximum depth of the Python interpreter stack to n. This\n\ limit prevents infinite recursion from causing an overflow of the C\n\ stack and crashing Python. The highest possible limit is platform-\n\ dependent." ); static PyObject * sys_getrecursionlimit(PyObject *self) { return PyInt_FromLong(Py_GetRecursionLimit());