bpo-36142: Move command line parsing to coreconfig.c (GH-12123)
* Add _PyCoreConfig_ReadFromArgv() function which parses command line options: move code from main.c to coreconfig.c. * Add _PyCoreConfig_Write() to write the new configuration: coerce the LC_CTYPE locale, set Py_xxx global configuration variables, etc. * _PyCoreConfig_ReadFromArgv() now only changes the LC_CTYPE locale temporarily. _PyCoreConfig_Write() becomes responsible to set the LC_CTYPE locale. * Add _Py_SetArgcArgv() and _Py_ClearArgcArgv() functions * Rename many "pymain_xxx()" functions * Add "const" to some function parameters * Reorganize main.c to declare functions in the order in which they are called.
This commit is contained in:
parent
625dbf2567
commit
95e2cbf32f
|
@ -5,6 +5,16 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* _PyArgv */
|
||||
|
||||
typedef struct {
|
||||
int argc;
|
||||
int use_bytes_argv;
|
||||
char **bytes_argv;
|
||||
wchar_t **wchar_argv;
|
||||
} _PyArgv;
|
||||
|
||||
|
||||
/* _PyInitError */
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -8,6 +8,29 @@ extern "C" {
|
|||
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN defined"
|
||||
#endif
|
||||
|
||||
/* _Py_wstrlist */
|
||||
|
||||
PyAPI_FUNC(void) _Py_wstrlist_clear(
|
||||
int len,
|
||||
wchar_t **list);
|
||||
PyAPI_FUNC(wchar_t**) _Py_wstrlist_copy(
|
||||
int len,
|
||||
wchar_t * const *list);
|
||||
PyAPI_FUNC(_PyInitError) _Py_wstrlist_append(
|
||||
int *len,
|
||||
wchar_t ***list,
|
||||
const wchar_t *str);
|
||||
PyAPI_FUNC(PyObject*) _Py_wstrlist_as_pylist(
|
||||
int len,
|
||||
wchar_t **list);
|
||||
|
||||
/* Py_GetArgcArgv() helpers */
|
||||
|
||||
PyAPI_FUNC(void) _Py_ClearArgcArgv(void);
|
||||
PyAPI_FUNC(int) _Py_SetArgcArgv(int argc, wchar_t * const *argv);
|
||||
|
||||
/* _PyCoreConfig */
|
||||
|
||||
PyAPI_FUNC(_PyInitError) _PyCoreConfig_Read(_PyCoreConfig *config);
|
||||
PyAPI_FUNC(void) _PyCoreConfig_Clear(_PyCoreConfig *);
|
||||
PyAPI_FUNC(int) _PyCoreConfig_Copy(
|
||||
|
@ -26,6 +49,9 @@ PyAPI_FUNC(int) _PyCoreConfig_GetEnvDup(
|
|||
wchar_t **dest,
|
||||
wchar_t *wname,
|
||||
char *name);
|
||||
PyAPI_FUNC(_PyInitError) _PyCoreConfig_ReadFromArgv(_PyCoreConfig *config,
|
||||
const _PyArgv *args);
|
||||
PyAPI_FUNC(void) _PyCoreConfig_Write(const _PyCoreConfig *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -8,20 +8,6 @@ extern "C" {
|
|||
# error "this header requires Py_BUILD_CORE or Py_BUILD_CORE_BUILTIN define"
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) _Py_wstrlist_clear(
|
||||
int len,
|
||||
wchar_t **list);
|
||||
PyAPI_FUNC(wchar_t**) _Py_wstrlist_copy(
|
||||
int len,
|
||||
wchar_t **list);
|
||||
PyAPI_FUNC(_PyInitError) _Py_wstrlist_append(
|
||||
int *len,
|
||||
wchar_t ***list,
|
||||
const wchar_t *str);
|
||||
PyAPI_FUNC(PyObject*) _Py_wstrlist_as_pylist(
|
||||
int len,
|
||||
wchar_t **list);
|
||||
|
||||
typedef struct _PyPathConfig {
|
||||
/* Full path to the Python program */
|
||||
wchar_t *program_full_path;
|
||||
|
|
1963
Modules/main.c
1963
Modules/main.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue