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

gh-90300: split --help output into separate options #30331

Merged
merged 33 commits into from Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
225c869
move list of X options out of help output
merwok Jan 2, 2022
eaefd1a
mention help option in fatal error message
merwok Jan 2, 2022
57fd33b
move variable declaration out of case block
merwok Jan 2, 2022
55dbf69
move extra envvars help to separate option
merwok Jan 2, 2022
0aaf9af
doc
merwok Jan 2, 2022
a592003
add minimal tests
merwok Jan 2, 2022
1c4cf63
flatten the sub-switch
merwok Jan 2, 2022
d8bfcff
suggestion from Barry
merwok Jan 3, 2022
38f2dd8
more suggestions from flufl
merwok Jan 3, 2022
a828fe8
remove unnecessary
merwok Jan 7, 2022
8bde4ec
mention all envvars in --help-env
merwok Jan 7, 2022
0dbaf03
mistake
merwok Jan 7, 2022
0c9a995
introduce --help-xoptions
merwok Jan 12, 2022
aab464f
add --help-all
merwok Jan 12, 2022
064d4ad
merge upstream
merwok Jan 12, 2022
b9a0b19
replace fprintf by printf; remove extra blanklines
merwok Jan 15, 2022
0ee24d4
merge upstream
merwok Feb 9, 2022
dd2beaa
Merge branch 'main' into shorten-help-output
merwok Apr 11, 2022
c74fc69
merge upstream
merwok May 5, 2022
2f108fe
merge upstream
merwok May 23, 2022
4f345e8
check return code in verify_valid_flag
merwok May 23, 2022
a6573d6
remove duplicate check
merwok May 24, 2022
da97a38
fix some help texts in 80 columns
merwok May 24, 2022
98525b4
remove needless checks
merwok May 25, 2022
5585095
reformat and rearrange some help entries
merwok May 25, 2022
24526bd
fix formatting issues and missing info in man page and --help
merwok May 25, 2022
0bb5dfa
make new tests a bit more useful
merwok May 25, 2022
8fa72f5
512 bytes should be enough for everyone
merwok May 25, 2022
29d04a0
keep long option at the end of help text
merwok May 26, 2022
356d1bf
merge branch 'fix-help-man'
merwok May 26, 2022
ac1b5fb
fix tests and output
merwok May 26, 2022
9bcea95
final fixes
merwok May 26, 2022
5485255
merge upstream
merwok May 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/using/cmdline.rst
Expand Up @@ -436,6 +436,7 @@ Miscellaneous options
See :ref:`warning-filter` and :ref:`describing-warning-filters` for more
details.


.. cmdoption:: -x

Skip the first line of the source, allowing use of non-Unix forms of
Expand All @@ -447,6 +448,7 @@ Miscellaneous options
Reserved for various implementation-specific options. CPython currently
defines the following possible values:

* ``-X help`` to print a short description of all X options;
merwok marked this conversation as resolved.
Show resolved Hide resolved
* ``-X faulthandler`` to enable :mod:`faulthandler`;
* ``-X showrefcount`` to output the total reference count and number of used
memory blocks when the program finishes or after each statement in the
Expand Down Expand Up @@ -528,6 +530,9 @@ Miscellaneous options
.. versionadded:: 3.11
The ``-X frozen_modules`` option.

.. versionadded:: 3.11
The ``-X help`` option.


Options you shouldn't use
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
27 changes: 21 additions & 6 deletions Python/initconfig.c
Expand Up @@ -63,8 +63,12 @@ static const char usage_3[] = "\
-W arg : warning control; arg is action:message:category:module:lineno\n\
also PYTHONWARNINGS=arg\n\
-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
-X opt : set implementation-specific option. The following options are available:\n\
\n\
-X opt : set implementation-specific option (see details with -X help)\n\
--check-hash-based-pycs always|default|never:\n\
control how Python invalidates hash-based .pyc files\n\
";
static const char usage_xoptions[] = "\
merwok marked this conversation as resolved.
Show resolved Hide resolved
The following implementation-specific options are available:\n\
-X faulthandler: enable faulthandler\n\
-X showrefcount: output the total reference count and number of used\n\
memory blocks when the program finishes or after each statement in the\n\
Expand Down Expand Up @@ -99,9 +103,6 @@ static const char usage_3[] = "\
when the interpreter displays tracebacks.\n\
-X frozen_modules=[on|off]: whether or not frozen modules should be used.\n\
The default is \"on\" (or \"off\" if you are running a local build).\n\
\n\
--check-hash-based-pycs always|default|never:\n\
control how Python invalidates hash-based .pyc files\n\
";
static const char usage_4[] = "\
merwok marked this conversation as resolved.
Show resolved Hide resolved
file : program read from script file\n\
Expand Down Expand Up @@ -2005,6 +2006,7 @@ _PyConfig_InitImportConfig(PyConfig *config)
// set, like -X showrefcount which requires a debug build. In this case unknown
// options are silently ignored.
const wchar_t* known_xoptions[] = {
L"help",
L"faulthandler",
L"showrefcount",
L"tracemalloc",
Expand Down Expand Up @@ -2222,6 +2224,11 @@ config_usage(int error, const wchar_t* program)
}
}

static void
config_xoptions_usage()
{
fputs(usage_xoptions, stdout);
}
merwok marked this conversation as resolved.
Show resolved Hide resolved

/* Parse the command line arguments */
static PyStatus
Expand Down Expand Up @@ -2308,7 +2315,6 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions,

case 'E':
case 'I':
case 'X':
/* option handled by _PyPreCmdline_Read() */
break;

Expand Down Expand Up @@ -2370,6 +2376,15 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions,
config->use_hash_seed = 0;
break;

case 'X':
const wchar_t *xoption = config_get_xoption(config, L"help");
if (xoption) {
config_xoptions_usage();
return _PyStatus_EXIT(0);
}
/* option handled by _PyPreCmdline_Read() */
break;

/* This space reserved for other options */

default:
Expand Down