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

Py_GetArgcArgv() is no longer exported by the C API #85087

Closed
vstinner opened this issue Jun 8, 2020 · 13 comments
Closed

Py_GetArgcArgv() is no longer exported by the C API #85087

vstinner opened this issue Jun 8, 2020 · 13 comments
Labels
3.9 only security fixes 3.10 only security fixes topic-C-API

Comments

@vstinner
Copy link
Member

vstinner commented Jun 8, 2020

BPO 40910
Nosy @vstinner, @dvarrazzo, @miss-islington
PRs
  • bpo-40910: Export Py_GetArgcArgv() function #20721
  • [3.9] bpo-40910: Export Py_GetArgcArgv() function (GH-20721) #20723
  • bpo-40910: PyConfig_Clear() clears _orig_argv #20886
  • [3.9] bpo-40910: PyConfig_Clear() clears _orig_argv (GH-20886) #20887
  • 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 2020-06-08.17:26:53.015>
    created_at = <Date 2020-06-08.13:22:42.062>
    labels = ['expert-C-API', '3.9', '3.10']
    title = 'Py_GetArgcArgv() is no longer exported by the C API'
    updated_at = <Date 2020-06-15.15:19:10.261>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-06-15.15:19:10.261>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-06-08.17:26:53.015>
    closer = 'vstinner'
    components = ['C API']
    creation = <Date 2020-06-08.13:22:42.062>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40910
    keywords = ['patch']
    message_count = 13.0
    messages = ['370978', '370979', '370980', '370982', '370983', '370984', '370996', '371006', '371010', '371011', '371030', '371552', '371562']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'piro', 'miss-islington']
    pr_nums = ['20721', '20723', '20886', '20887']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue40910'
    versions = ['Python 3.9', 'Python 3.10']

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    Python 3.9 is now built with -fvisibility=hidden. The Py_GetArgcArgv() function is no longer exported. Previously, it was exported because all symbols were exported by default.

    I'm working on a PR to export it again.

    Fedora downstream issue, setproctitle is broken on Python 3.9: https://bugzilla.redhat.com/show_bug.cgi?id=1792059

    @vstinner vstinner added 3.9 only security fixes 3.10 only security fixes topic-C-API labels Jun 8, 2020
    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    setproctitle upstream report:
    dvarrazzo/py-setproctitle#76

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    See also bpo-15577 "Real argc and argv in embedded interpreter".

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    See also bpo-5672 "Implement a way to change the python process name", especially this comment:
    https://bugs.python.org/issue5672#msg108524

    """
    setproctitle is quite stable, my company uses it in production environment very heavily with python 2.x. Probably its users base is not huge, but that's because it's a relatively specialized tool.

    Python3 porting is not straightforward because python2 exports the original argv pointer using Py_GetArgcArgv() whereas python3 only exports a decoded version in a wchar_t* array. This may not be a showstopper: probably the original argv can still be found scanning backwards from environ: I want to test it but I haven't had requests for it yet, so it wasn't a top priority.

    So, while I'd be pleased to have it included in the stdlib, I'm not really convinced it would be useful to such a large audience. Anyway I'm available for any improvement it would make the tool more useful and to anybody eager to push for its inclusion.
    """

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    See also bpo-29857: Provide sys.executable_argv for host application's command line arguments.

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    See also bpo-23427 "Python should expose command when invoked with -c"

    @dvarrazzo
    Copy link
    Mannequin

    dvarrazzo mannequin commented Jun 8, 2020

    Thank you for opening this. FYI:

    probably the original argv can still be found scanning backwards from environ

    this is how the module works indeed in Python 3.

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    New changeset e81f6e6 by Victor Stinner in branch 'master':
    bpo-40910: Export Py_GetArgcArgv() function (GH-20721)
    e81f6e6

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    Py_GetArgcArgv() is not new at all. It exists since:

    commit ac56b03
    Author: Guido van Rossum <guido@python.org>
    Date: Sun Jul 21 02:33:38 1996 +0000

    New style names for getprogramname and getargcargv
    

    Previously, the function was known as getargcargv() and it existed since:

    commit 7b1e974
    Author: Guido van Rossum <guido@python.org>
    Date: Mon Aug 29 10:46:42 1994 +0000

    Makefile.pre.in: add $(OPT) to link command
    audioop.c: fix for MPW
    config.c.in: save original argc/argv for Lance
    rotormodule.c: new coding conventions
    timemodule.c: add casts for Lance
    

    +void
    +getargcargv(argc,argv)
    + int *argc;
    + char ***argv;
    +{
    + *argc = orig_argc;
    + *argv = orig_argv;
    +}
    +

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    New changeset dedaac0 by Victor Stinner in branch '3.9':
    bpo-40910: Export Py_GetArgcArgv() function (GH-20721) (GH-20723)
    dedaac0

    @vstinner
    Copy link
    Member Author

    vstinner commented Jun 8, 2020

    Ok, I fixed Python 3.9: Py_GetArgcArgv() function is exported again.

    Let's continue the discussion in bpo-23427.

    @vstinner vstinner closed this as completed Jun 8, 2020
    @vstinner
    Copy link
    Member Author

    New changeset e2d47a0 by Victor Stinner in branch 'master':
    bpo-40910: PyConfig_Clear() clears _orig_argv (GH-20886)
    e2d47a0

    @miss-islington
    Copy link
    Contributor

    New changeset bab0833 by Miss Islington (bot) in branch '3.9':
    bpo-40910: PyConfig_Clear() clears _orig_argv (GH-20886)
    bab0833

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes topic-C-API
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants