diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-07-20 17:16:22 -0700 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-07-21 02:16:22 +0200 |
commit | 03ec4df67d6b4ce93a2da21db7c84dff8259953f (patch) | |
tree | c47087d89707148936e251a888cacb21642c864a /Programs | |
parent | 49abd307d222e6fe85b5175eed6b6f87fc656a8d (diff) | |
download | cpython-git-03ec4df67d6b4ce93a2da21db7c84dff8259953f.tar.gz |
bpo-34008: Allow to call Py_Main() after Py_Initialize() (GH-8043) (GH-8352)
Py_Main() can again be called after Py_Initialize(), as in Python
3.6. The new configuration is ignored, except of
_PyMainInterpreterConfig.argv which is used to update sys.argv.
(cherry picked from commit fb47bca9ee2d07ce96df94b4e4abafd11826eb01)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
Diffstat (limited to 'Programs')
-rw-r--r-- | Programs/_testembed.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c index b8827f074b..b1be682f7a 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -276,6 +276,21 @@ static int test_initialize_twice(void) return 0; } +static int test_initialize_pymain(void) +{ + wchar_t *argv[] = {L"PYTHON", L"-c", + L"import sys; print(f'Py_Main() after Py_Initialize: sys.argv={sys.argv}')", + L"arg2"}; + _testembed_Py_Initialize(); + + /* bpo-34008: Calling Py_Main() after Py_Initialize() must not crash */ + Py_Main(Py_ARRAY_LENGTH(argv), argv); + + Py_Finalize(); + + return 0; +} + /* ********************************************************* * List of test cases and the function that implements it. @@ -302,6 +317,7 @@ static struct TestCase TestCases[] = { { "pre_initialization_sys_options", test_pre_initialization_sys_options }, { "bpo20891", test_bpo20891 }, { "initialize_twice", test_initialize_twice }, + { "initialize_pymain", test_initialize_pymain }, { NULL, NULL } }; |