From dd12aa0aea733820807ec4f99e4e476064a0ee41 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 27 Nov 2018 00:12:05 +0100 Subject: [PATCH] bpo-35134: Create Include/cpython/pylifecycle.h (GH-10731) Move pylifecycle.h code surrounded by "#ifndef Py_LIMITED_API" to a new Include/cpython/pylifecycle.h header file. --- Include/cpython/pylifecycle.h | 99 +++++++++++++++++++++++++++++++++ Include/pylifecycle.h | 100 +--------------------------------- 2 files changed, 102 insertions(+), 97 deletions(-) create mode 100644 Include/cpython/pylifecycle.h diff --git a/Include/cpython/pylifecycle.h b/Include/cpython/pylifecycle.h new file mode 100644 index 00000000000..3009c4f10d3 --- /dev/null +++ b/Include/cpython/pylifecycle.h @@ -0,0 +1,99 @@ +#ifndef Py_CPYTHON_PYLIFECYCLE_H +# error "this header file must not be included directly" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Only used by applications that embed the interpreter and need to + * override the standard encoding determination mechanism + */ +PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding, + const char *errors); + +/* PEP 432 Multi-phase initialization API (Private while provisional!) */ + +PyAPI_FUNC(_PyInitError) _Py_InitializeCore( + PyInterpreterState **interp, + const _PyCoreConfig *); +PyAPI_FUNC(int) _Py_IsCoreInitialized(void); + + +PyAPI_FUNC(_PyInitError) _PyMainInterpreterConfig_Read( + _PyMainInterpreterConfig *config, + const _PyCoreConfig *core_config); +PyAPI_FUNC(void) _PyMainInterpreterConfig_Clear(_PyMainInterpreterConfig *); +PyAPI_FUNC(int) _PyMainInterpreterConfig_Copy( + _PyMainInterpreterConfig *config, + const _PyMainInterpreterConfig *config2); +/* Used by _testcapi.get_main_config() */ +PyAPI_FUNC(PyObject*) _PyMainInterpreterConfig_AsDict( + const _PyMainInterpreterConfig *config); + +PyAPI_FUNC(_PyInitError) _Py_InitializeMainInterpreter( + PyInterpreterState *interp, + const _PyMainInterpreterConfig *); + +/* Initialization and finalization */ + +PyAPI_FUNC(_PyInitError) _Py_InitializeFromConfig( + const _PyCoreConfig *config); +PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalInitError(_PyInitError err); + +/* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level + * exit functions. + */ +PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(PyObject *), PyObject *); + +/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */ +PyAPI_FUNC(void) _Py_RestoreSignals(void); + +PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); + +PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *); + +PyAPI_FUNC(const char *) _Py_gitidentifier(void); +PyAPI_FUNC(const char *) _Py_gitversion(void); + +/* Internal -- various one-time initializations */ +PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); +PyAPI_FUNC(_PyInitError) _PySys_BeginInit(PyObject **sysmod); +PyAPI_FUNC(int) _PySys_EndInit(PyObject *sysdict, PyInterpreterState *interp); +PyAPI_FUNC(_PyInitError) _PyImport_Init(PyInterpreterState *interp); +PyAPI_FUNC(void) _PyExc_Init(PyObject * bltinmod); +PyAPI_FUNC(_PyInitError) _PyImportHooks_Init(void); +PyAPI_FUNC(int) _PyFloat_Init(void); +PyAPI_FUNC(int) PyByteArray_Init(void); +PyAPI_FUNC(_PyInitError) _Py_HashRandomization_Init(const _PyCoreConfig *); + +/* Various internal finalizers */ + +PyAPI_FUNC(void) PyMethod_Fini(void); +PyAPI_FUNC(void) PyFrame_Fini(void); +PyAPI_FUNC(void) PyCFunction_Fini(void); +PyAPI_FUNC(void) PyDict_Fini(void); +PyAPI_FUNC(void) PyTuple_Fini(void); +PyAPI_FUNC(void) PyList_Fini(void); +PyAPI_FUNC(void) PySet_Fini(void); +PyAPI_FUNC(void) PyBytes_Fini(void); +PyAPI_FUNC(void) PyByteArray_Fini(void); +PyAPI_FUNC(void) PyFloat_Fini(void); +PyAPI_FUNC(void) PyOS_FiniInterrupts(void); +PyAPI_FUNC(void) PySlice_Fini(void); +PyAPI_FUNC(void) PyAsyncGen_Fini(void); + +PyAPI_FUNC(int) _Py_IsFinalizing(void); + +/* Random */ +PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size); +PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size); + +/* Legacy locale support */ +PyAPI_FUNC(void) _Py_CoerceLegacyLocale(int warn); +PyAPI_FUNC(int) _Py_LegacyLocaleDetected(void); +PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category); + +#ifdef __cplusplus +} +#endif diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h index 93fb26b43fe..5419bc94324 100644 --- a/Include/pylifecycle.h +++ b/Include/pylifecycle.h @@ -7,47 +7,10 @@ extern "C" { #endif -#ifndef Py_LIMITED_API -/* Only used by applications that embed the interpreter and need to - * override the standard encoding determination mechanism - */ -PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding, - const char *errors); -#endif - - -#ifndef Py_LIMITED_API -/* PEP 432 Multi-phase initialization API (Private while provisional!) */ -PyAPI_FUNC(_PyInitError) _Py_InitializeCore( - PyInterpreterState **interp, - const _PyCoreConfig *); -PyAPI_FUNC(int) _Py_IsCoreInitialized(void); - - -PyAPI_FUNC(_PyInitError) _PyMainInterpreterConfig_Read( - _PyMainInterpreterConfig *config, - const _PyCoreConfig *core_config); -PyAPI_FUNC(void) _PyMainInterpreterConfig_Clear(_PyMainInterpreterConfig *); -PyAPI_FUNC(int) _PyMainInterpreterConfig_Copy( - _PyMainInterpreterConfig *config, - const _PyMainInterpreterConfig *config2); -/* Used by _testcapi.get_main_config() */ -PyAPI_FUNC(PyObject*) _PyMainInterpreterConfig_AsDict( - const _PyMainInterpreterConfig *config); - -PyAPI_FUNC(_PyInitError) _Py_InitializeMainInterpreter( - PyInterpreterState *interp, - const _PyMainInterpreterConfig *); -#endif /* Initialization and finalization */ PyAPI_FUNC(void) Py_Initialize(void); PyAPI_FUNC(void) Py_InitializeEx(int); -#ifndef Py_LIMITED_API -PyAPI_FUNC(_PyInitError) _Py_InitializeFromConfig( - const _PyCoreConfig *config); -PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalInitError(_PyInitError err); -#endif PyAPI_FUNC(void) Py_Finalize(void); PyAPI_FUNC(int) Py_FinalizeEx(void); PyAPI_FUNC(int) Py_IsInitialized(void); @@ -60,20 +23,10 @@ PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); /* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level * exit functions. */ -#ifndef Py_LIMITED_API -PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(PyObject *), PyObject *); -#endif PyAPI_FUNC(int) Py_AtExit(void (*func)(void)); PyAPI_FUNC(void) _Py_NO_RETURN Py_Exit(int); -/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */ -#ifndef Py_LIMITED_API -PyAPI_FUNC(void) _Py_RestoreSignals(void); - -PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); -#endif - /* Bootstrap __main__ (defined in Modules/main.c) */ PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv); @@ -84,9 +37,6 @@ PyAPI_FUNC(wchar_t *) Py_GetProgramName(void); PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *); PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void); -#ifndef Py_LIMITED_API -PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *); -#endif PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void); PyAPI_FUNC(wchar_t *) Py_GetPrefix(void); @@ -103,43 +53,6 @@ PyAPI_FUNC(const char *) Py_GetPlatform(void); PyAPI_FUNC(const char *) Py_GetCopyright(void); PyAPI_FUNC(const char *) Py_GetCompiler(void); PyAPI_FUNC(const char *) Py_GetBuildInfo(void); -#ifndef Py_LIMITED_API -PyAPI_FUNC(const char *) _Py_gitidentifier(void); -PyAPI_FUNC(const char *) _Py_gitversion(void); -#endif - -/* Internal -- various one-time initializations */ -#ifndef Py_LIMITED_API -PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); -PyAPI_FUNC(_PyInitError) _PySys_BeginInit(PyObject **sysmod); -PyAPI_FUNC(int) _PySys_EndInit(PyObject *sysdict, PyInterpreterState *interp); -PyAPI_FUNC(_PyInitError) _PyImport_Init(PyInterpreterState *interp); -PyAPI_FUNC(void) _PyExc_Init(PyObject * bltinmod); -PyAPI_FUNC(_PyInitError) _PyImportHooks_Init(void); -PyAPI_FUNC(int) _PyFloat_Init(void); -PyAPI_FUNC(int) PyByteArray_Init(void); -PyAPI_FUNC(_PyInitError) _Py_HashRandomization_Init(const _PyCoreConfig *); -#endif - -/* Various internal finalizers */ - -#ifndef Py_LIMITED_API -PyAPI_FUNC(void) PyMethod_Fini(void); -PyAPI_FUNC(void) PyFrame_Fini(void); -PyAPI_FUNC(void) PyCFunction_Fini(void); -PyAPI_FUNC(void) PyDict_Fini(void); -PyAPI_FUNC(void) PyTuple_Fini(void); -PyAPI_FUNC(void) PyList_Fini(void); -PyAPI_FUNC(void) PySet_Fini(void); -PyAPI_FUNC(void) PyBytes_Fini(void); -PyAPI_FUNC(void) PyByteArray_Fini(void); -PyAPI_FUNC(void) PyFloat_Fini(void); -PyAPI_FUNC(void) PyOS_FiniInterrupts(void); -PyAPI_FUNC(void) PySlice_Fini(void); -PyAPI_FUNC(void) PyAsyncGen_Fini(void); - -PyAPI_FUNC(int) _Py_IsFinalizing(void); -#endif /* !Py_LIMITED_API */ /* Signals */ typedef void (*PyOS_sighandler_t)(int); @@ -147,16 +60,9 @@ PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); #ifndef Py_LIMITED_API -/* Random */ -PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size); -PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size); -#endif /* !Py_LIMITED_API */ - -/* Legacy locale support */ -#ifndef Py_LIMITED_API -PyAPI_FUNC(void) _Py_CoerceLegacyLocale(int warn); -PyAPI_FUNC(int) _Py_LegacyLocaleDetected(void); -PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category); +# define Py_CPYTHON_PYLIFECYCLE_H +# include "cpython/pylifecycle.h" +# undef Py_CPYTHON_PYLIFECYCLE_H #endif #ifdef __cplusplus