Skip to content

Commit ca719ac

Browse files
authored
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.
1 parent 1f1a34c commit ca719ac

File tree

5 files changed

+456
-430
lines changed

5 files changed

+456
-430
lines changed

Include/pylifecycle.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding,
5454
PyAPI_FUNC(_PyInitError) _Py_InitializeCore(const _PyCoreConfig *);
5555
PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
5656

57-
PyAPI_FUNC(_PyInitError) _PyCoreConfig_ReadEnv(_PyCoreConfig *);
5857
PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *);
5958
PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *);
6059
PyAPI_FUNC(int) _PyCoreConfig_Copy(

Include/pystate.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ typedef struct {
5050

5151
int argc; /* Number of command line arguments,
5252
-1 means unset */
53-
wchar_t **argv; /* sys.argv, ignored if argc is negative */
53+
wchar_t **argv; /* Command line arguments */
54+
wchar_t *program; /* argv[0] or "" */
55+
56+
int nxoption; /* Number of -X options */
57+
wchar_t **xoptions; /* -X options */
58+
59+
int nwarnoption; /* Number of warnings options */
60+
wchar_t **warnoptions; /* Warnings options */
5461
} _PyCoreConfig;
5562

5663
#define _PyCoreConfig_INIT \

0 commit comments

Comments
 (0)