This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Py_GetArgcArgv() is no longer exported by the C API
Type: Stage: resolved
Components: C API Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: miss-islington, piro, vstinner
Priority: normal Keywords: patch

Created on 2020-06-08 13:22 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20721 merged vstinner, 2020-06-08 14:02
PR 20723 merged vstinner, 2020-06-08 16:16
PR 20886 merged vstinner, 2020-06-15 13:49
PR 20887 merged miss-islington, 2020-06-15 14:28
Messages (13)
msg370978 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 13:22
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
msg370979 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 13:23
setproctitle upstream report:
https://github.com/dvarrazzo/py-setproctitle/issues/76
msg370980 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 13:23
See also bpo-15577 "Real argc and argv in embedded interpreter".
msg370982 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 14:08
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.
"""
msg370983 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 14:09
See also bpo-29857: Provide `sys.executable_argv` for host application's command line arguments.
msg370984 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 14:11
See also bpo-23427 "Python should expose command when invoked with -c"
msg370996 - (view) Author: Daniele Varrazzo (piro) * Date: 2020-06-08 15:35
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.
msg371006 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 16:13
New changeset e81f6e687d0f04a45f2389d0b43fafd6d8491624 by Victor Stinner in branch 'master':
bpo-40910: Export Py_GetArgcArgv() function (GH-20721)
https://github.com/python/cpython/commit/e81f6e687d0f04a45f2389d0b43fafd6d8491624
msg371010 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 16:44
Py_GetArgcArgv() is not new at all. It exists since:

commit ac56b03f9a931423714ab3a0e8cfae78f81f9b85
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 7b1e974b4bd7c17cd90a6d03bab0aaa079d78d29
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;
+}
+
msg371011 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 16:44
New changeset dedaac040fe5b0b88acdec072623bb39ec53687f by Victor Stinner in branch '3.9':
bpo-40910: Export Py_GetArgcArgv() function (GH-20721) (GH-20723)
https://github.com/python/cpython/commit/dedaac040fe5b0b88acdec072623bb39ec53687f
msg371030 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-08 17:26
Ok, I fixed Python 3.9: Py_GetArgcArgv() function is exported again.

Let's continue the discussion in bpo-23427.
msg371552 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-06-15 14:27
New changeset e2d47a0568c6da9229580829917fd6aa702133b3 by Victor Stinner in branch 'master':
bpo-40910: PyConfig_Clear() clears _orig_argv (GH-20886)
https://github.com/python/cpython/commit/e2d47a0568c6da9229580829917fd6aa702133b3
msg371562 - (view) Author: miss-islington (miss-islington) Date: 2020-06-15 15:19
New changeset bab0833d49f8d38488ff1469edcec9b47db0dc5c by Miss Islington (bot) in branch '3.9':
bpo-40910: PyConfig_Clear() clears _orig_argv (GH-20886)
https://github.com/python/cpython/commit/bab0833d49f8d38488ff1469edcec9b47db0dc5c
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85087
2020-06-15 15:19:10miss-islingtonsetmessages: + msg371562
2020-06-15 14:28:03miss-islingtonsetnosy: + miss-islington

pull_requests: + pull_request20069
2020-06-15 14:27:54vstinnersetmessages: + msg371552
2020-06-15 13:49:07vstinnersetpull_requests: + pull_request20068
2020-06-08 17:26:53vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg371030

stage: patch review -> resolved
2020-06-08 16:44:58vstinnersetmessages: + msg371011
2020-06-08 16:44:36vstinnersetmessages: + msg371010
2020-06-08 16:16:44vstinnersetpull_requests: + pull_request19933
2020-06-08 16:13:07vstinnersetmessages: + msg371006
2020-06-08 15:35:09pirosetnosy: + piro
messages: + msg370996
2020-06-08 14:11:46vstinnersetmessages: + msg370984
2020-06-08 14:09:46vstinnersetmessages: + msg370983
2020-06-08 14:08:56vstinnersetmessages: + msg370982
2020-06-08 14:02:49vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request19930
2020-06-08 13:23:56vstinnersetmessages: + msg370980
2020-06-08 13:23:04vstinnersetmessages: + msg370979
2020-06-08 13:22:42vstinnercreate