CPython API sys 模块的操作

创建日期: 2024-06-09 08:53 | 作者: 风波 | 浏览次数: 19 | 分类: Python

文档:https://docs.python.org/3/c-api/sys.html

API 列表

API
PyObject *PyOS_FSPath(PyObject *path) Return the file system representation for path.
int Py_FdIsInteractive(FILE *fp, const char *filename) Return true (nonzero) if the standard I/O file fp with name filename is deemed interactive
void PyOS_BeforeFork() Function to prepare some internal state before a process fork
void PyOS_AfterFork_Parent() Function to update some internal state after a process fork
void PyOS_AfterFork_Child() Function to update internal interpreter state after a process fork
void PyOS_AfterFork() Function to update some internal state after a process fork; this should be called in the new process if the Python interpreter will continue to be used
int PyOS_CheckStack() Return true when the interpreter runs out of stack space.
typedef void (*PyOS_sighandler_t)(int)
PyOS_sighandler_t PyOS_getsig(int i)
PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h)
wchar_t *Py_DecodeLocale(const char *arg, size_t *size)
char *Py_EncodeLocale(const wchar_t *text, size_t *error_pos)

System Functions

API
PyObject PySys_GetObject(const char name) Return the object name from the sys module or NULL if it does not exist, without setting an exception.
int PySys_SetObject(const char name, PyObject v) Set name in the sys module to v unless v is NULL, in which case name is deleted from the sys module. Returns 0 on success, -1 on error.
void PySys_ResetWarnOptions()
void PySys_AddWarnOption(const wchar_t *s)
void PySys_AddWarnOptionUnicode(PyObject *unicode)
void PySys_SetPath(const wchar_t *path)
void PySys_WriteStdout(const char *format, ...)
void PySys_WriteStderr(const char *format, ...)
void PySys_FormatStdout(const char *format, ...)
void PySys_FormatStderr(const char *format, ...)
void PySys_AddXOption(const wchar_t *s)
PyObject *PySys_GetXOptions()
int PySys_Audit(const char *event, const char *format, ...)
int PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)

Process Control

API
void Py_FatalError(const char *message)
void Py_Exit(int status)
int Py_AtExit(void (*func)())
19 浏览
13 爬虫
0 评论