mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-34523: Use _PyCoreConfig instead of globals (GH-9005)
Use the core configuration of the interpreter, rather than using global configuration variables. For example, replace Py_QuietFlag with core_config->quiet.
This commit is contained in:
parent
de42755674
commit
fbca90856d
6 changed files with 50 additions and 40 deletions
|
@ -951,18 +951,18 @@ pymain_init_stdio(_PyMain *pymain, _PyCoreConfig *config)
|
|||
|
||||
|
||||
static void
|
||||
pymain_header(_PyMain *pymain)
|
||||
pymain_header(_PyMain *pymain, const _PyCoreConfig *config)
|
||||
{
|
||||
if (Py_QuietFlag) {
|
||||
if (config->quiet) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Py_VerboseFlag && (RUN_CODE(pymain) || !pymain->stdin_is_interactive)) {
|
||||
if (!config->verbose && (RUN_CODE(pymain) || !pymain->stdin_is_interactive)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Python %s on %s\n", Py_GetVersion(), Py_GetPlatform());
|
||||
if (!Py_NoSiteFlag) {
|
||||
if (config->site_import) {
|
||||
fprintf(stderr, "%s\n", COPYRIGHT);
|
||||
}
|
||||
}
|
||||
|
@ -1041,12 +1041,12 @@ wstrlist_as_pylist(int len, wchar_t **list)
|
|||
|
||||
|
||||
static void
|
||||
pymain_import_readline(_PyMain *pymain)
|
||||
pymain_import_readline(_PyMain *pymain, const _PyCoreConfig *config)
|
||||
{
|
||||
if (Py_IsolatedFlag) {
|
||||
if (config->isolated) {
|
||||
return;
|
||||
}
|
||||
if (!Py_InspectFlag && RUN_CODE(pymain)) {
|
||||
if (!config->inspect && RUN_CODE(pymain)) {
|
||||
return;
|
||||
}
|
||||
if (!isatty(fileno(stdin))) {
|
||||
|
@ -1591,8 +1591,8 @@ pymain_run_python(_PyMain *pymain, PyInterpreterState *interp)
|
|||
|
||||
PyCompilerFlags cf = {.cf_flags = 0};
|
||||
|
||||
pymain_header(pymain);
|
||||
pymain_import_readline(pymain);
|
||||
pymain_header(pymain, config);
|
||||
pymain_import_readline(pymain, config);
|
||||
|
||||
if (pymain->command) {
|
||||
pymain->status = pymain_run_command(pymain->command, &cf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue