[Python-checkins] gh-91256: Ensure help text has the program name even before getpath is called (GH-94929)

miss-islington webhook-mailer at python.org
Tue Jul 19 15:03:25 EDT 2022


https://github.com/python/cpython/commit/bb8e20a329f83cdeb74e5a6cc5a4079349ba2a87
commit: bb8e20a329f83cdeb74e5a6cc5a4079349ba2a87
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-07-19T12:03:15-07:00
summary:

gh-91256: Ensure help text has the program name even before getpath is called (GH-94929)

(cherry picked from commit 49aeff49d71fa4bd935212340410311f13879447)

Co-authored-by: Steve Dower <steve.dower at python.org>

files:
A Misc/NEWS.d/next/Core and Builtins/2022-07-17-15-54-29.gh-issue-91256.z7i7Q5.rst
M Python/initconfig.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-07-17-15-54-29.gh-issue-91256.z7i7Q5.rst b/Misc/NEWS.d/next/Core and Builtins/2022-07-17-15-54-29.gh-issue-91256.z7i7Q5.rst
new file mode 100644
index 0000000000000..802a614fd48d7
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-07-17-15-54-29.gh-issue-91256.z7i7Q5.rst	
@@ -0,0 +1 @@
+Ensures the program name is known for help text during interpreter startup.
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 86dcdd9a8bd6b..d31385039932b 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -2295,6 +2295,9 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions,
     const PyWideStringList *argv = &config->argv;
     int print_version = 0;
     const wchar_t* program = config->program_name;
+    if (!program && argv->length >= 1) {
+        program = argv->items[0];
+    }
 
     _PyOS_ResetGetOpt();
     do {



More information about the Python-checkins mailing list