Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Py_FrozenMain() for _PyCoreConfig (PEP 587) #81121

Closed
vstinner opened this issue May 16, 2019 · 4 comments
Closed

Update Py_FrozenMain() for _PyCoreConfig (PEP 587) #81121

vstinner opened this issue May 16, 2019 · 4 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@vstinner
Copy link
Member

BPO 36940
Nosy @Yhg1s, @ncoghlan, @vstinner, @zooba
Superseder
  • bpo-44131: [C API] Add tests on Py_FrozenMain()
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-05-26.22:38:11.360>
    created_at = <Date 2019-05-16.15:26:17.504>
    labels = ['interpreter-core', '3.8']
    title = 'Update Py_FrozenMain() for _PyCoreConfig (PEP 587)'
    updated_at = <Date 2021-05-26.22:39:29.048>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2021-05-26.22:39:29.048>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-05-26.22:38:11.360>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2019-05-16.15:26:17.504>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36940
    keywords = []
    message_count = 4.0
    messages = ['342653', '343446', '394482', '394484']
    nosy_count = 4.0
    nosy_names = ['twouters', 'ncoghlan', 'vstinner', 'steve.dower']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '44131'
    type = None
    url = 'https://bugs.python.org/issue36940'
    versions = ['Python 3.8']

    @vstinner
    Copy link
    Member Author

    Python/frozenmain.c should use pre-initialization and be adapted for _PyCoreConfig. Py_FrozenMain() reimplements some features which are now implemented by _Py_InitializeFromConfig():

    • disable C streams (stdin, stdout, stderr) buffering
    • decode argv using Py_DecodeLocale()
    • set the program name (call Py_SetProgramName())
    • set sys.argv
    • reimplement the REPL

    It seems like it could use _Py_RunMain(), but I'm not sure.

    @vstinner vstinner added 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels May 16, 2019
    @vstinner
    Copy link
    Member Author

    Another file which should maybe also be updated to PEP-587, PC/bdist_wininst/install.c:

    static int compile_filelist(HINSTANCE hPython, BOOL optimize_flag)
    {
        DECLPROC(hPython, void, Py_Initialize, (void));
        DECLPROC(hPython, void, Py_SetProgramName, (wchar_t *));
        DECLPROC(hPython, void, Py_Finalize, (void));
        DECLPROC(hPython, int, PyRun_SimpleString, (char *));
        DECLPROC(hPython, PyObject *, PySys_GetObject, (char *));
        DECLVAR(hPython, int, Py_OptimizeFlag);
    
        int errors = 0;
        struct tagFile *p = file_list;
    if (!p)
        return 0;
    
    if (!Py_Initialize || !Py_SetProgramName || !Py_Finalize)
        return -1;
    
    if (!PyRun_SimpleString || !PySys_GetObject || !Py_OptimizeFlag)
        return -1;
    
        *Py_OptimizeFlag = optimize_flag ? 1 : 0;
        Py_SetProgramName(wmodulename);
        Py_Initialize();
    
        errors += do_compile_files(PyRun_SimpleString, optimize_flag);
        Py_Finalize();
    
        return errors;
    }

    @vstinner
    Copy link
    Member Author

    Fixed by bpo-44131.

    @vstinner
    Copy link
    Member Author

    Another file which should maybe also be updated to PEP-587, PC/bdist_wininst/install.c

    PC/bdist_wininst/ has been removed in the meanwhile.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant