Unverified Kaydet (Commit) ca719ac4 authored tarafından Victor Stinner's avatar Victor Stinner Kaydeden (comit) GitHub

bpo-32030: Add _PyCoreConfig.warnoptions (#4936)

Merge _PyCoreConfig_ReadEnv() into _PyCoreConfig_Read(), and
_Py_CommandLineDetails usage is now restricted to pymain_cmdline().

Changes:

* _PyCoreConfig: Add nxoption, xoptions, nwarnoption and warnoptions
* Add _PyCoreConfig.program: argv[0] or ""
* Move filename, command, module and xoptions from
  _Py_CommandLineDetails to _PyMain. xoptions _Py_OptList becomes
  (int, wchar_t**) list.
* Add pymain_cmdline() function
* Rename copy_argv() to copy_wstrlist(). Rename clear_argv() to
  clear_wstrlist(). Remove _Py_OptList structure: use (int,
  wchar_t**) list instead.
* Rename pymain_set_flag_from_env() to pymain_get_env_flag()
* Rename pymain_set_flags_from_env() to pymain_get_env_flags()
* _PyMainInterpreterConfig_Read() now creates the warnoptions from
  _PyCoreConfig.warnoptions
* Inline pymain_add_warning_dev_mode() and
  pymain_add_warning_bytes_flag() into config_init_warnoptions()
* Inline pymain_get_program_name() into _PyCoreConfig_Read()
* _Py_CommandLineDetails: Replace warning_options with nwarnoption
  and warnoptions. Replace env_warning_options with nenv_warnoption
  and env_warnoptions.
* pymain_warnings_envvar() now has a single implementation for
  Windows and Unix: use config_get_env_var_dup() to also get the
  variable as wchar_t* on Unix.
üst 1f1a34c3
...@@ -54,7 +54,6 @@ PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding, ...@@ -54,7 +54,6 @@ PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding,
PyAPI_FUNC(_PyInitError) _Py_InitializeCore(const _PyCoreConfig *); PyAPI_FUNC(_PyInitError) _Py_InitializeCore(const _PyCoreConfig *);
PyAPI_FUNC(int) _Py_IsCoreInitialized(void); PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
PyAPI_FUNC(_PyInitError) _PyCoreConfig_ReadEnv(_PyCoreConfig *);
PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *); PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *);
PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *); PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *);
PyAPI_FUNC(int) _PyCoreConfig_Copy( PyAPI_FUNC(int) _PyCoreConfig_Copy(
......
...@@ -50,7 +50,14 @@ typedef struct { ...@@ -50,7 +50,14 @@ typedef struct {
int argc; /* Number of command line arguments, int argc; /* Number of command line arguments,
-1 means unset */ -1 means unset */
wchar_t **argv; /* sys.argv, ignored if argc is negative */ wchar_t **argv; /* Command line arguments */
wchar_t *program; /* argv[0] or "" */
int nxoption; /* Number of -X options */
wchar_t **xoptions; /* -X options */
int nwarnoption; /* Number of warnings options */
wchar_t **warnoptions; /* Warnings options */
} _PyCoreConfig; } _PyCoreConfig;
#define _PyCoreConfig_INIT \ #define _PyCoreConfig_INIT \
......
This diff is collapsed.
...@@ -107,11 +107,6 @@ pathconfig_global_init(void) ...@@ -107,11 +107,6 @@ pathconfig_global_init(void)
_PyInitError err; _PyInitError err;
_PyCoreConfig config = _PyCoreConfig_INIT; _PyCoreConfig config = _PyCoreConfig_INIT;
err = _PyCoreConfig_ReadEnv(&config);
if (_Py_INIT_FAILED(err)) {
goto error;
}
err = _PyCoreConfig_Read(&config); err = _PyCoreConfig_Read(&config);
if (_Py_INIT_FAILED(err)) { if (_Py_INIT_FAILED(err)) {
goto error; goto error;
......
...@@ -882,7 +882,7 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib) ...@@ -882,7 +882,7 @@ _Py_InitializeEx_Private(int install_sigs, int install_importlib)
core_config._disable_importlib = !install_importlib; core_config._disable_importlib = !install_importlib;
config.install_signal_handlers = install_sigs; config.install_signal_handlers = install_sigs;
err = _PyCoreConfig_ReadEnv(&core_config); err = _PyCoreConfig_Read(&core_config);
if (_Py_INIT_FAILED(err)) { if (_Py_INIT_FAILED(err)) {
goto done; goto done;
} }
...@@ -2030,7 +2030,7 @@ void _Py_PyAtExit(void (*func)(PyObject *), PyObject *module) ...@@ -2030,7 +2030,7 @@ void _Py_PyAtExit(void (*func)(PyObject *), PyObject *module)
{ {
PyThreadState *ts; PyThreadState *ts;
PyInterpreterState *is; PyInterpreterState *is;
ts = PyThreadState_GET(); ts = PyThreadState_GET();
is = ts->interp; is = ts->interp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment