Skip to content

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

Closed

Description

@vstinner
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']

    Activity

    1. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

      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

    2. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

      setproctitle upstream report:
      dvarrazzo/py-setproctitle#76

    3. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

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

    4. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

      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.
      """

    5. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

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

    6. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

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

    7. dvarrazzo commented on Jun 8, 2020

      dvarrazzomannequin
      Mannequin

      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.

    8. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

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

    9. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

      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;
      +}
      +

    10. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

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

    11. vstinner commented on Jun 8, 2020

      @vstinner
      MemberAuthor

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

      Let's continue the discussion in bpo-23427.

    12. vstinner commented on Jun 15, 2020

      @vstinner
      MemberAuthor

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

    13. miss-islington commented on Jun 15, 2020

      @miss-islington
      Contributor

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

    14. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions