bpo-32030: Simplify _PyCoreConfig_INIT macro by vstinner · Pull Request #4728 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions Include/internal/pystate.h
22 changes: 4 additions & 18 deletions Include/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,8 @@ typedef struct {
int show_alloc_count; /* -X showalloccount */
} _PyCoreConfig;

#define _PyCoreConfig_INIT \
(_PyCoreConfig){\
.ignore_environment = 0, \
.use_hash_seed = -1, \
.hash_seed = 0, \
._disable_importlib = 0, \
.allocator = NULL, \
.dev_mode = 0, \
.faulthandler = 0, \
.tracemalloc = 0, \
.import_time = 0, \
.show_ref_count = 0, \
.show_alloc_count = 0}
#define _PyCoreConfig_INIT (_PyCoreConfig){.use_hash_seed = -1}
/* Note: _PyCoreConfig_INIT sets other fields to 0/NULL */

/* Placeholders while working on the new configuration API
*
Expand All @@ -69,11 +58,8 @@ typedef struct {
} _PyMainInterpreterConfig;

#define _PyMainInterpreterConfig_INIT \
(_PyMainInterpreterConfig){\
.install_signal_handlers = -1, \
.module_search_path_env = NULL, \
.home = NULL, \
.program_name = NULL}
(_PyMainInterpreterConfig){.install_signal_handlers = -1}
/* Note: _PyMainInterpreterConfig_INIT sets other fields to 0/NULL */

typedef struct _is {

Expand Down
12 changes: 3 additions & 9 deletions Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pymain_get_env_var(const char *name)


static void
pymain_run_statup(PyCompilerFlags *cf)
pymain_run_startup(PyCompilerFlags *cf)
{
char *startup = Py_GETENV("PYTHONSTARTUP");
if (startup == NULL || startup[0] == '\0') {
Expand Down Expand Up @@ -367,8 +367,6 @@ pymain_run_file(FILE *fp, const wchar_t *filename, PyCompilerFlags *p_cf)

/* Main program */

/*TODO: Add arg processing to PEP 432 as a new configuration setup API
*/
typedef struct {
size_t len;
wchar_t **options;
Expand Down Expand Up @@ -949,8 +947,6 @@ pymain_get_program_name(_PyMain *pymain)
*
* Replaces previous call to Py_Initialize()
*
* TODO: Move environment queries (etc) into Py_ReadConfig
*
* Return 0 on success.
* Set pymain->err and return -1 on error.
*/
Expand Down Expand Up @@ -1121,10 +1117,9 @@ pymain_run_filename(_PyMain *pymain)

if (cmdline->filename == NULL && pymain->stdin_is_interactive) {
Py_InspectFlag = 0; /* do exit on SystemExit */
pymain_run_statup(&pymain->cf);
pymain_run_startup(&pymain->cf);
pymain_run_interactive_hook();
}
/* XXX */

if (pymain->main_importer_path != NULL) {
pymain->status = pymain_run_main_from_importer(pymain);
Expand Down Expand Up @@ -1162,7 +1157,7 @@ pymain_repl(_PyMain *pymain)

Py_InspectFlag = 0;
pymain_run_interactive_hook();
/* XXX */

int res = PyRun_AnyFileFlags(stdin, "<stdin>", &pymain->cf);
pymain->status = (res != 0);
}
Expand Down Expand Up @@ -1630,7 +1625,6 @@ pymain_init(_PyMain *pymain)
}

pymain->core_config._disable_importlib = 0;
/* TODO: Moar config options! */
pymain->config.install_signal_handlers = 1;

orig_argc = pymain->argc; /* For Py_GetArgcArgv() */
Expand Down
9 changes: 2 additions & 7 deletions Python/pylifecycle.c