bpo-36301: Remove _PyCoreConfig.preconfig (GH-12546) · python/cpython@2000495 (original) (raw)
`@@ -272,12 +272,19 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
`
272
272
`'allocator': None,
`
273
273
`'coerce_c_locale': 0,
`
274
274
`'coerce_c_locale_warn': 0,
`
275
``
`-
'dev_mode': 0,
`
276
``
`-
'isolated': 0,
`
277
``
`-
'use_environment': 1,
`
278
275
`'utf8_mode': 0,
`
279
276
` }
`
``
277
`+
COPY_PRE_CONFIG = [
`
``
278
`+
'dev_mode',
`
``
279
`+
'isolated',
`
``
280
`+
'use_environment',
`
``
281
`+
]
`
``
282
+
280
283
`DEFAULT_CORE_CONFIG = {
`
``
284
`+
'isolated': 0,
`
``
285
`+
'use_environment': 1,
`
``
286
`+
'dev_mode': 0,
`
``
287
+
281
288
`'install_signal_handlers': 1,
`
282
289
`'use_hash_seed': 0,
`
283
290
`'hash_seed': 0,
`
`@@ -363,8 +370,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
`
363
370
`'_Py_HasFileSystemDefaultEncodeErrors': 0,
`
364
371
` }
`
365
372
`COPY_GLOBAL_PRE_CONFIG = [
`
366
``
`-
('Py_IgnoreEnvironmentFlag', 'use_environment', True),
`
367
``
`-
('Py_IsolatedFlag', 'isolated'),
`
368
373
` ('Py_UTF8Mode', 'utf8_mode'),
`
369
374
` ]
`
370
375
`COPY_GLOBAL_CONFIG = [
`
`@@ -376,8 +381,10 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
`
376
381
` ('Py_FileSystemDefaultEncodeErrors', 'filesystem_errors'),
`
377
382
` ('Py_FileSystemDefaultEncoding', 'filesystem_encoding'),
`
378
383
` ('Py_FrozenFlag', '_frozen'),
`
``
384
`+
('Py_IgnoreEnvironmentFlag', 'use_environment', True),
`
379
385
` ('Py_InspectFlag', 'inspect'),
`
380
386
` ('Py_InteractiveFlag', 'interactive'),
`
``
387
`+
('Py_IsolatedFlag', 'isolated'),
`
381
388
` ('Py_NoSiteFlag', 'site_import', True),
`
382
389
` ('Py_NoUserSiteDirectory', 'user_site_directory', True),
`
383
390
` ('Py_OptimizeFlag', 'optimization_level'),
`
`@@ -415,7 +422,7 @@ def check_main_config(self, config):
`
415
422
`expected['xoptions'] = self.main_xoptions(core_config['xoptions'])
`
416
423
`self.assertEqual(main_config, expected)
`
417
424
``
418
``
`-
def get_expected_config(self, expected, expected_preconfig, env):
`
``
425
`+
def get_expected_config(self, expected, env):
`
419
426
`expected = dict(self.DEFAULT_CORE_CONFIG, **expected)
`
420
427
``
421
428
`code = textwrap.dedent('''
`
`@@ -443,7 +450,7 @@ def get_expected_config(self, expected, expected_preconfig, env):
`
443
450
`# when test_embed is run from a venv (bpo-35313)
`
444
451
`args = (sys.executable, '-S', '-c', code)
`
445
452
`env = dict(env)
`
446
``
`-
if not expected_preconfig['isolated']:
`
``
453
`+
if not expected['isolated']:
`
447
454
`env['PYTHONCOERCECLOCALE'] = '0'
`
448
455
`env['PYTHONUTF8'] = '0'
`
449
456
`proc = subprocess.run(args, env=env,
`
`@@ -509,7 +516,10 @@ def check_config(self, testname, expected_config, expected_preconfig):
`
509
516
`config = json.loads(out)
`
510
517
``
511
518
`expected_preconfig = dict(self.DEFAULT_PRE_CONFIG, **expected_preconfig)
`
512
``
`-
expected_config = self.get_expected_config(expected_config, expected_preconfig, env)
`
``
519
`+
expected_config = self.get_expected_config(expected_config, env)
`
``
520
`+
for key in self.COPY_PRE_CONFIG:
`
``
521
`+
if key not in expected_preconfig:
`
``
522
`+
expected_preconfig[key] = expected_config[key]
`
513
523
``
514
524
`self.check_core_config(config, expected_config)
`
515
525
`self.check_pre_config(config, expected_preconfig)
`
`@@ -617,35 +627,36 @@ def test_init_env(self):
`
617
627
``
618
628
`def test_init_env_dev_mode(self):
`
619
629
`preconfig = dict(self.INIT_ENV_PRECONFIG,
`
620
``
`-
allocator='debug',
`
621
``
`-
dev_mode=1)
`
``
630
`+
allocator='debug')
`
622
631
`config = dict(self.INIT_ENV_CONFIG,
`
623
632
`dev_mode=1)
`
624
633
`self.check_config("init_env_dev_mode", config, preconfig)
`
625
634
``
626
``
`-
def test_init_env_dev_mode(self):
`
``
635
`+
def test_init_env_dev_mode_alloc(self):
`
627
636
`preconfig = dict(self.INIT_ENV_PRECONFIG,
`
628
``
`-
allocator='malloc',
`
629
``
`-
dev_mode=1)
`
630
``
`-
config = dict(self.INIT_ENV_CONFIG)
`
``
637
`+
allocator='malloc')
`
``
638
`+
config = dict(self.INIT_ENV_CONFIG,
`
``
639
`+
dev_mode=1)
`
631
640
`self.check_config("init_env_dev_mode_alloc", config, preconfig)
`
632
641
``
633
642
`def test_init_dev_mode(self):
`
634
643
`preconfig = {
`
635
644
`'allocator': 'debug',
`
636
``
`-
'dev_mode': 1,
`
637
645
` }
`
638
646
`config = {
`
639
647
`'faulthandler': 1,
`
``
648
`+
'dev_mode': 1,
`
640
649
` }
`
641
650
`self.check_config("init_dev_mode", config, preconfig)
`
642
651
``
643
652
`def test_init_isolated(self):
`
644
653
`preconfig = {
`
645
``
`-
'isolated': 1,
`
646
``
`-
'use_environment': 0,
`
``
654
`+
'isolated': 0,
`
``
655
`+
'use_environment': 1,
`
647
656
` }
`
648
657
`config = {
`
``
658
`+
'isolated': 1,
`
``
659
`+
'use_environment': 0,
`
649
660
`'user_site_directory': 0,
`
650
661
` }
`
651
662
`self.check_config("init_isolated", config, preconfig)
`