From 466b113d54b8f6540962abaa2e98302f7df46298 Mon Sep 17 00:00:00 2001 From: farisbasha Date: Wed, 18 Nov 2026 14:47:21 +0530 Subject: [PATCH 1/3] Fix the signature line in the gnu_getopt() docstring It was copied from getopt() and named the wrong function, so help(getopt.gnu_getopt) showed "getopt(args, options[, long_options])". --- Lib/getopt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/getopt.py b/Lib/getopt.py index 25f3e2439b3e352..cc2fc254a888bce 100644 --- a/Lib/getopt.py +++ b/Lib/getopt.py @@ -92,7 +92,7 @@ def getopt(args, shortopts, longopts = []): return opts, args def gnu_getopt(args, shortopts, longopts = []): - """getopt(args, options[, long_options]) -> opts, args + """gnu_getopt(args, options[, long_options]) -> opts, args This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option From 4356ad8e3a4ed759a13a61630e36a796cbf74e5f Mon Sep 17 00:00:00 2001 From: farisbasha Date: Wed, 18 Nov 2026 15:32:18 +0530 Subject: [PATCH 2/3] Remove the stale signature lines from the getopt() and gnu_getopt() docstrings --- Lib/getopt.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Lib/getopt.py b/Lib/getopt.py index cc2fc254a888bce..24208e58e072c22 100644 --- a/Lib/getopt.py +++ b/Lib/getopt.py @@ -47,9 +47,7 @@ def __str__(self): error = GetoptError # backward compatibility def getopt(args, shortopts, longopts = []): - """getopt(args, options[, long_options]) -> opts, args - - Parses command line options and parameter list. args is the + """Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the string of option letters that the script wants to @@ -92,9 +90,7 @@ def getopt(args, shortopts, longopts = []): return opts, args def gnu_getopt(args, shortopts, longopts = []): - """gnu_getopt(args, options[, long_options]) -> opts, args - - This function works like getopt(), except that GNU style scanning + """This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops processing options as soon as a non-option argument is From 4a26d9209956e2619065a505f18ac60c47901db0 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Wed, 18 Nov 2026 15:16:53 +0000 Subject: [PATCH 3/3] Add summary, drop trailing line --- Lib/getopt.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Lib/getopt.py b/Lib/getopt.py index 24208e58e072c22..272a4bf7d0c2820 100644 --- a/Lib/getopt.py +++ b/Lib/getopt.py @@ -47,9 +47,10 @@ def __str__(self): error = GetoptError # backward compatibility def getopt(args, shortopts, longopts = []): - """Parses command line options and parameter list. args is the - argument list to be parsed, without the leading reference to the - running program. Typically, this means "sys.argv[1:]". shortopts + """Parse command line options and parameter list. + + args is the argument list to be parsed, without the leading reference + to the running program. Typically, this means "sys.argv[1:]". shortopts is the string of option letters that the script wants to recognize, with options that require an argument followed by a colon and options that accept an optional argument followed by @@ -70,7 +71,6 @@ def getopt(args, shortopts, longopts = []): string if the option has no argument. The options occur in the list in the same order in which they were found, thus allowing multiple occurrences. Long and short options may be mixed. - """ opts = [] @@ -90,7 +90,9 @@ def getopt(args, shortopts, longopts = []): return opts, args def gnu_getopt(args, shortopts, longopts = []): - """This function works like getopt(), except that GNU style scanning + """Parse command line options using GNU style scanning. + + This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops processing options as soon as a non-option argument is @@ -99,7 +101,6 @@ def gnu_getopt(args, shortopts, longopts = []): If the first character of the option string is '+', or if the environment variable POSIXLY_CORRECT is set, then option processing stops as soon as a non-option argument is encountered. - """ opts = []