(root)/
Python-3.12.0/
Include/
cpython/
pylifecycle.h
       1  #ifndef Py_CPYTHON_PYLIFECYCLE_H
       2  #  error "this header file must not be included directly"
       3  #endif
       4  
       5  /* Py_FrozenMain is kept out of the Limited API until documented and present
       6     in all builds of Python */
       7  PyAPI_FUNC(int) Py_FrozenMain(int argc, char **argv);
       8  
       9  /* Only used by applications that embed the interpreter and need to
      10   * override the standard encoding determination mechanism
      11   */
      12  Py_DEPRECATED(3.11) PyAPI_FUNC(int) Py_SetStandardStreamEncoding(
      13      const char *encoding,
      14      const char *errors);
      15  
      16  /* PEP 432 Multi-phase initialization API (Private while provisional!) */
      17  
      18  PyAPI_FUNC(PyStatus) Py_PreInitialize(
      19      const PyPreConfig *src_config);
      20  PyAPI_FUNC(PyStatus) Py_PreInitializeFromBytesArgs(
      21      const PyPreConfig *src_config,
      22      Py_ssize_t argc,
      23      char **argv);
      24  PyAPI_FUNC(PyStatus) Py_PreInitializeFromArgs(
      25      const PyPreConfig *src_config,
      26      Py_ssize_t argc,
      27      wchar_t **argv);
      28  
      29  PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
      30  
      31  
      32  /* Initialization and finalization */
      33  
      34  PyAPI_FUNC(PyStatus) Py_InitializeFromConfig(
      35      const PyConfig *config);
      36  PyAPI_FUNC(PyStatus) _Py_InitializeMain(void);
      37  
      38  PyAPI_FUNC(int) Py_RunMain(void);
      39  
      40  
      41  PyAPI_FUNC(void) _Py_NO_RETURN Py_ExitStatusException(PyStatus err);
      42  
      43  /* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
      44  PyAPI_FUNC(void) _Py_RestoreSignals(void);
      45  
      46  PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
      47  PyAPI_FUNC(int) _Py_FdIsInteractive(FILE *fp, PyObject *filename);
      48  
      49  Py_DEPRECATED(3.11) PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *);
      50  
      51  PyAPI_FUNC(const char *) _Py_gitidentifier(void);
      52  PyAPI_FUNC(const char *) _Py_gitversion(void);
      53  
      54  PyAPI_FUNC(int) _Py_IsFinalizing(void);
      55  PyAPI_FUNC(int) _Py_IsInterpreterFinalizing(PyInterpreterState *interp);
      56  
      57  /* Random */
      58  PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
      59  PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
      60  
      61  /* Legacy locale support */
      62  PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn);
      63  PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
      64  PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
      65  
      66  /* --- PyInterpreterConfig ------------------------------------ */
      67  
      68  #define PyInterpreterConfig_DEFAULT_GIL (0)
      69  #define PyInterpreterConfig_SHARED_GIL (1)
      70  #define PyInterpreterConfig_OWN_GIL (2)
      71  
      72  typedef struct {
      73      // XXX "allow_object_sharing"?  "own_objects"?
      74      int use_main_obmalloc;
      75      int allow_fork;
      76      int allow_exec;
      77      int allow_threads;
      78      int allow_daemon_threads;
      79      int check_multi_interp_extensions;
      80      int gil;
      81  } PyInterpreterConfig;
      82  
      83  #define _PyInterpreterConfig_INIT \
      84      { \
      85          .use_main_obmalloc = 0, \
      86          .allow_fork = 0, \
      87          .allow_exec = 0, \
      88          .allow_threads = 1, \
      89          .allow_daemon_threads = 0, \
      90          .check_multi_interp_extensions = 1, \
      91          .gil = PyInterpreterConfig_OWN_GIL, \
      92      }
      93  
      94  #define _PyInterpreterConfig_LEGACY_INIT \
      95      { \
      96          .use_main_obmalloc = 1, \
      97          .allow_fork = 1, \
      98          .allow_exec = 1, \
      99          .allow_threads = 1, \
     100          .allow_daemon_threads = 1, \
     101          .check_multi_interp_extensions = 0, \
     102          .gil = PyInterpreterConfig_SHARED_GIL, \
     103      }
     104  
     105  PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
     106      PyThreadState **tstate_p,
     107      const PyInterpreterConfig *config);
     108  
     109  typedef void (*atexit_datacallbackfunc)(void *);
     110  PyAPI_FUNC(int) _Py_AtExit(
     111          PyInterpreterState *, atexit_datacallbackfunc, void *);