bpo-36763: Add _PyCoreConfig_InitPythonConfig() (GH-13388) · python/cpython@cab5d07

@@ -307,7 +307,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):

307307308308

'pycache_prefix': None,

309309

'program_name': GET_DEFAULT_CONFIG,

310-

'parse_argv': 1,

310+

'parse_argv': 0,

311311

'argv': [""],

312312313313

'xoptions': [],

@@ -333,7 +333,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):

333333

'verbose': 0,

334334

'quiet': 0,

335335

'user_site_directory': 1,

336-

'configure_c_stdio': 1,

336+

'configure_c_stdio': 0,

337337

'buffered_stdio': 1,

338338339339

'stdio_encoding': GET_DEFAULT_CONFIG,

@@ -588,6 +588,7 @@ def test_init_from_config(self):

588588

'pycache_prefix': 'conf_pycache_prefix',

589589

'program_name': './conf_program_name',

590590

'argv': ['-c', 'arg2'],

591+

'parse_argv': 1,

591592

'xoptions': ['core_xoption1=3', 'core_xoption2=', 'core_xoption3'],

592593

'warnoptions': ['error::ResourceWarning', 'default::BytesWarning'],

593594

'run_command': 'pass\n',

@@ -600,7 +601,7 @@ def test_init_from_config(self):

600601

'write_bytecode': 0,

601602

'verbose': 1,

602603

'quiet': 1,

603-

'configure_c_stdio': 0,

604+

'configure_c_stdio': 1,

604605

'buffered_stdio': 0,

605606

'user_site_directory': 0,

606607

'faulthandler': 1,

@@ -661,14 +662,14 @@ def test_init_dev_mode(self):

661662

}

662663

self.check_config("init_dev_mode", config, preconfig)

663664664-

def test_init_isolated(self):

665+

def test_init_isolated_flag(self):

665666

preconfig = {}

666667

config = {

667668

'isolated': 1,

668669

'use_environment': 0,

669670

'user_site_directory': 0,

670671

}

671-

self.check_config("init_isolated", config, preconfig)

672+

self.check_config("init_isolated_flag", config, preconfig)

672673673674

def test_preinit_isolated1(self):

674675

# _PyPreConfig.isolated=1, _PyCoreConfig.isolated not set

@@ -690,6 +691,25 @@ def test_preinit_isolated2(self):

690691

}

691692

self.check_config("preinit_isolated2", config, preconfig)

692693694+

def test_init_isolated_config(self):

695+

preconfig = {}

696+

config = {

697+

'isolated': 1,

698+

'use_environment': 0,

699+

'user_site_directory': 0,

700+

'install_signal_handlers': 0,

701+

'pathconfig_warnings': 0,

702+

}

703+

self.check_config("init_isolated_config", config, preconfig)

704+705+

def test_init_python_config(self):

706+

preconfig = {}

707+

config = {

708+

'configure_c_stdio': 1,

709+

'parse_argv': 1,

710+

}

711+

self.check_config("init_python_config", config, preconfig)

712+693713

def test_init_read_set(self):

694714

preconfig = {}

695715

core_config = {

@@ -707,6 +727,7 @@ def test_init_run_main(self):

707727

'argv': ['-c', 'arg2'],

708728

'program_name': './python3',

709729

'run_command': code + '\n',

730+

'parse_argv': 1,

710731

}

711732

self.check_config("init_run_main", core_config, preconfig)

712733

@@ -718,15 +739,26 @@ def test_init_main(self):

718739

'argv': ['-c', 'arg2'],

719740

'program_name': './python3',

720741

'run_command': code + '\n',

742+

'parse_argv': 1,

721743

'_init_main': 0,

722744

}

723745

self.check_config("init_main", core_config, preconfig,

724746

stderr="Run Python code before _Py_InitializeMain")

725747748+

def test_init_parse_argv(self):

749+

core_config = {

750+

'argv': ['-c', 'arg1', '-v', 'arg3'],

751+

'program_name': './argv0',

752+

'parse_argv': 1,

753+

'run_command': 'pass\n',

754+

'use_environment': 0,

755+

}

756+

self.check_config("init_parse_argv", core_config, {})

757+726758

def test_init_dont_parse_argv(self):

727759

core_config = {

728-

'argv': ['-v', '-c', 'arg1', '-W', 'arg2'],

729-

'parse_argv': 0,

760+

'argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],

761+

'program_name': './argv0',

730762

}

731763

self.check_config("init_dont_parse_argv", core_config, {})

732764