mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-36471: Add _Py_RunMain() (GH-12618)
* Add config_read_cmdline() subfunction. Remove _PyCmdline structure. * _PyCoreConfig_Read() now also parses config->argv command line arguments
This commit is contained in:
parent
5f45979b63
commit
2f54908afc
5 changed files with 156 additions and 118 deletions
|
@ -53,7 +53,12 @@ class EmbeddingTestsMixin:
|
|||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
env=env)
|
||||
(out, err) = p.communicate()
|
||||
try:
|
||||
(out, err) = p.communicate()
|
||||
except:
|
||||
p.terminate()
|
||||
p.wait()
|
||||
raise
|
||||
if p.returncode != 0 and support.verbose:
|
||||
print(f"--- {cmd} failed ---")
|
||||
print(f"stdout:\n{out}")
|
||||
|
@ -254,6 +259,11 @@ class EmbeddingTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
self.assertEqual(out.rstrip(), "Py_Main() after Py_Initialize: sys.argv=['-c', 'arg2']")
|
||||
self.assertEqual(err, '')
|
||||
|
||||
def test_run_main(self):
|
||||
out, err = self.run_embedded_interpreter("run_main")
|
||||
self.assertEqual(out.rstrip(), "_Py_RunMain(): sys.argv=['-c', 'arg2']")
|
||||
self.assertEqual(err, '')
|
||||
|
||||
|
||||
class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||
maxDiff = 4096
|
||||
|
@ -549,10 +559,11 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
|||
|
||||
'pycache_prefix': 'conf_pycache_prefix',
|
||||
'program_name': './conf_program_name',
|
||||
'argv': ['-c', 'pass'],
|
||||
'argv': ['-c', 'arg2'],
|
||||
'program': 'conf_program',
|
||||
'xoptions': ['core_xoption1=3', 'core_xoption2=', 'core_xoption3'],
|
||||
'warnoptions': ['error::ResourceWarning', 'default::BytesWarning'],
|
||||
'run_command': 'pass\n',
|
||||
|
||||
'site_import': 0,
|
||||
'bytes_warning': 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue