Skip to content

Commit e8fb762

Browse files
[3.11] gh-90300: Reformat the Python CLI help output (GH-115847) (GH-116418)
(cherry picked from commit 2e92ffd) (cherry picked from commit 2bdd1d6) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 26f7956 commit e8fb762

File tree

1 file changed

+91
-88
lines changed

1 file changed

+91
-88
lines changed

Python/initconfig.c

+91-88
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ Options (and corresponding environment variables):\n\
4949
.pyc extension; also PYTHONOPTIMIZE=x\n\
5050
-OO : do -O changes and also discard docstrings; add .opt-2 before\n\
5151
.pyc extension\n\
52-
-P : don't prepend a potentially unsafe path to sys.path; also PYTHONSAFEPATH\n\
52+
-P : don't prepend a potentially unsafe path to sys.path; also\n\
53+
PYTHONSAFEPATH\n\
5354
-q : don't print version and copyright messages on interactive startup\n\
5455
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
5556
-S : don't imply 'import site' on initialization\n\
@@ -65,9 +66,10 @@ Options (and corresponding environment variables):\n\
6566
-X opt : set implementation-specific option\n\
6667
--check-hash-based-pycs always|default|never:\n\
6768
control how Python invalidates hash-based .pyc files\n\
68-
--help-env : print help about Python environment variables and exit\n\
69-
--help-xoptions : print help about implementation-specific -X options and exit\n\
70-
--help-all : print complete help information and exit\n\
69+
--help-env: print help about Python environment variables and exit\n\
70+
--help-xoptions: print help about implementation-specific -X options and exit\n\
71+
--help-all: print complete help information and exit\n\
72+
\n\
7173
Arguments:\n\
7274
file : program read from script file\n\
7375
- : program read from stdin (default; interactive mode if a tty)\n\
@@ -76,105 +78,106 @@ arg ...: arguments passed to program in sys.argv[1:]\n\
7678

7779
static const char usage_xoptions[] = "\
7880
The following implementation-specific options are available:\n\
79-
\n\
8081
-X faulthandler: enable faulthandler\n\
81-
\n\
8282
-X showrefcount: output the total reference count and number of used\n\
83-
memory blocks when the program finishes or after each statement in the\n\
84-
interactive interpreter. This only works on debug builds\n\
85-
\n\
83+
memory blocks when the program finishes or after each statement in\n\
84+
the interactive interpreter. This only works on debug builds\n\
8685
-X tracemalloc: start tracing Python memory allocations using the\n\
87-
tracemalloc module. By default, only the most recent frame is stored in a\n\
88-
traceback of a trace. Use -X tracemalloc=NFRAME to start tracing with a\n\
89-
traceback limit of NFRAME frames\n\
90-
\n\
91-
-X importtime: show how long each import takes. It shows module name,\n\
92-
cumulative time (including nested imports) and self time (excluding\n\
93-
nested imports). Note that its output may be broken in multi-threaded\n\
94-
application. Typical usage is python3 -X importtime -c 'import asyncio'\n\
95-
\n\
96-
-X dev: enable CPython's \"development mode\", introducing additional runtime\n\
97-
checks which are too expensive to be enabled by default. Effect of the\n\
98-
developer mode:\n\
99-
* Add default warning filter, as -W default\n\
100-
* Install debug hooks on memory allocators: see the PyMem_SetupDebugHooks()\n\
101-
C function\n\
102-
* Enable the faulthandler module to dump the Python traceback on a crash\n\
103-
* Enable asyncio debug mode\n\
104-
* Set the dev_mode attribute of sys.flags to True\n\
105-
* io.IOBase destructor logs close() exceptions\n\
106-
\n\
107-
-X utf8: enable UTF-8 mode for operating system interfaces, overriding the default\n\
108-
locale-aware mode. -X utf8=0 explicitly disables UTF-8 mode (even when it would\n\
109-
otherwise activate automatically)\n\
110-
\n\
111-
-X pycache_prefix=PATH: enable writing .pyc files to a parallel tree rooted at the\n\
112-
given directory instead of to the code tree\n\
113-
\n\
86+
tracemalloc module. By default, only the most recent frame is stored\n\
87+
in a traceback of a trace. Use -X tracemalloc=NFRAME to start\n\
88+
tracing with a traceback limit of NFRAME frames\n\
89+
-X importtime: show how long each import takes. It shows module name,\n\
90+
cumulative time (including nested imports) and self time (excluding\n\
91+
nested imports). Note that its output may be broken in\n\
92+
multi-threaded application.\n\
93+
Typical usage is python3 -X importtime -c 'import asyncio'\n\
94+
-X dev : enable CPython's \"development mode\", introducing additional runtime\n\
95+
checks which are too expensive to be enabled by default. Effect of\n\
96+
the developer mode:\n\
97+
* Add default warning filter, as -W default\n\
98+
* Install debug hooks on memory allocators: see the\n\
99+
PyMem_SetupDebugHooks() C function\n\
100+
* Enable the faulthandler module to dump the Python traceback on\n\
101+
a crash\n\
102+
* Enable asyncio debug mode\n\
103+
* Set the dev_mode attribute of sys.flags to True\n\
104+
* io.IOBase destructor logs close() exceptions\n\
105+
-X utf8: enable UTF-8 mode for operating system interfaces, overriding the\n\
106+
default locale-aware mode. -X utf8=0 explicitly disables UTF-8 mode\n\
107+
(even when it would otherwise activate automatically)\n\
108+
-X pycache_prefix=PATH: enable writing .pyc files to a parallel tree rooted\n\
109+
at the given directory instead of to the code tree\n\
114110
-X warn_default_encoding: enable opt-in EncodingWarning for 'encoding=None'\n\
115-
\n\
116-
-X no_debug_ranges: disable the inclusion of the tables mapping extra location \n\
117-
information (end line, start column offset and end column offset) to every \n\
118-
instruction in code objects. This is useful when smaller code objects and pyc \n\
119-
files are desired as well as suppressing the extra visual location indicators \n\
120-
when the interpreter displays tracebacks.\n\
121-
\n\
111+
-X no_debug_ranges: disable the inclusion of the tables mapping extra location\n\
112+
information (end line, start column offset and end column offset) to\n\
113+
every instruction in code objects. This is useful when smaller code\n\
114+
objects and pyc files are desired as well as suppressing the extra\n\
115+
visual location indicators when the interpreter displays tracebacks.\n\
122116
-X frozen_modules=[on|off]: whether or not frozen modules should be used.\n\
123-
The default is \"on\" (or \"off\" if you are running a local build).\n\
124-
\n\
117+
The default is \"on\" (or \"off\" if you are running a local build).\n\
125118
-X int_max_str_digits=number: limit the size of int<->str conversions.\n\
126-
This helps avoid denial of service attacks when parsing untrusted data.\n\
127-
The default is sys.int_info.default_max_str_digits. 0 disables.";
119+
This helps avoid denial of service attacks when parsing untrusted\n\
120+
data. The default is sys.int_info.default_max_str_digits.\n\
121+
0 disables.\
122+
"
123+
;
128124

129125
/* Envvars that don't have equivalent command-line options are listed first */
130126
static const char usage_envvars[] =
131127
"Environment variables that change behavior:\n"
132-
"PYTHONSTARTUP: file executed on interactive startup (no default)\n"
133-
"PYTHONPATH : '%lc'-separated list of directories prefixed to the\n"
134-
" default module search path. The result is sys.path.\n"
135-
"PYTHONHOME : alternate <prefix> directory (or <prefix>%lc<exec_prefix>).\n"
136-
" The default module search path uses %s.\n"
137-
"PYTHONPLATLIBDIR : override sys.platlibdir.\n"
138-
"PYTHONCASEOK : ignore case in 'import' statements (Windows).\n"
139-
"PYTHONUTF8: if set to 1, enable the UTF-8 mode.\n"
128+
"PYTHONSTARTUP : file executed on interactive startup (no default)\n"
129+
"PYTHONPATH : '%lc'-separated list of directories prefixed to the\n"
130+
" default module search path. The result is sys.path.\n"
131+
"PYTHONHOME : alternate <prefix> directory (or <prefix>%lc<exec_prefix>).\n"
132+
" The default module search path uses %s.\n"
133+
"PYTHONPLATLIBDIR: override sys.platlibdir.\n"
134+
"PYTHONCASEOK : ignore case in 'import' statements (Windows).\n"
135+
"PYTHONUTF8 : if set to 1, enable the UTF-8 mode.\n"
140136
"PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n"
141137
"PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.\n"
142-
"PYTHONHASHSEED: if this variable is set to 'random', a random value is used\n"
143-
" to seed the hashes of str and bytes objects. It can also be set to an\n"
144-
" integer in the range [0,4294967295] to get hash values with a\n"
145-
" predictable seed.\n"
138+
"PYTHONHASHSEED : if this variable is set to 'random', a random value is used\n"
139+
" to seed the hashes of str and bytes objects. It can also be\n"
140+
" set to an integer in the range [0,4294967295] to get hash\n"
141+
" values with a predictable seed.\n"
146142
"PYTHONINTMAXSTRDIGITS: limits the maximum digit characters in an int value\n"
147-
" when converting from a string and when converting an int back to a str.\n"
148-
" A value of 0 disables the limit. Conversions to or from bases 2, 4, 8,\n"
149-
" 16, and 32 are never limited.\n"
150-
"PYTHONMALLOC: set the Python memory allocators and/or install debug hooks\n"
151-
" on Python memory allocators. Use PYTHONMALLOC=debug to install debug\n"
152-
" hooks.\n"
143+
" when converting from a string and when converting an int\n"
144+
" back to a str. A value of 0 disables the limit.\n"
145+
" Conversions to or from bases 2, 4, 8, 16, and 32 are never\n"
146+
" limited.\n"
147+
"PYTHONMALLOC : set the Python memory allocators and/or install debug hooks\n"
148+
" on Python memory allocators. Use PYTHONMALLOC=debug to\n"
149+
" install debug hooks.\n"
153150
"PYTHONCOERCECLOCALE: if this variable is set to 0, it disables the locale\n"
154-
" coercion behavior. Use PYTHONCOERCECLOCALE=warn to request display of\n"
155-
" locale coercion and locale compatibility warnings on stderr.\n"
151+
" coercion behavior. Use PYTHONCOERCECLOCALE=warn to request\n"
152+
" display of locale coercion and locale compatibility warnings\n"
153+
" on stderr.\n"
156154
"PYTHONBREAKPOINT: if this variable is set to 0, it disables the default\n"
157-
" debugger. It can be set to the callable of your debugger of choice.\n"
158-
"PYTHONDEVMODE: enable the development mode.\n"
155+
" debugger. It can be set to the callable of your debugger of\n"
156+
" choice.\n"
157+
"PYTHONDEVMODE : enable the development mode.\n"
159158
"PYTHONPYCACHEPREFIX: root directory for bytecode cache (pyc) files.\n"
160159
"PYTHONWARNDEFAULTENCODING: enable opt-in EncodingWarning for 'encoding=None'.\n"
161-
"PYTHONNODEBUGRANGES: If this variable is set, it disables the inclusion of the \n"
162-
" tables mapping extra location information (end line, start column offset \n"
163-
" and end column offset) to every instruction in code objects. This is useful \n"
164-
" when smaller code objects and pyc files are desired as well as suppressing the \n"
165-
" extra visual location indicators when the interpreter displays tracebacks.\n"
166-
"These variables have equivalent command-line parameters (see --help for details):\n"
167-
"PYTHONDEBUG : enable parser debug mode (-d)\n"
168-
"PYTHONDONTWRITEBYTECODE : don't write .pyc files (-B)\n"
169-
"PYTHONINSPECT : inspect interactively after running script (-i)\n"
170-
"PYTHONINTMAXSTRDIGITS : limit max digit characters in an int value\n"
171-
" (-X int_max_str_digits=number)\n"
172-
"PYTHONNOUSERSITE : disable user site directory (-s)\n"
173-
"PYTHONOPTIMIZE : enable level 1 optimizations (-O)\n"
174-
"PYTHONSAFEPATH : don't prepend a potentially unsafe path to sys.path (-P)\n"
175-
"PYTHONUNBUFFERED : disable stdout/stderr buffering (-u)\n"
176-
"PYTHONVERBOSE : trace import statements (-v)\n"
177-
"PYTHONWARNINGS=arg : warning control (-W arg)\n";
160+
"PYTHONNODEBUGRANGES: if this variable is set, it disables the inclusion of\n"
161+
" the tables mapping extra location information (end line,\n"
162+
" start column offset and end column offset) to every\n"
163+
" instruction in code objects. This is useful when smaller\n"
164+
" code objects and pyc files are desired as well as\n"
165+
" suppressing the extra visual location indicators when the\n"
166+
" interpreter displays tracebacks.\n"
167+
"\n"
168+
"These variables have equivalent command-line options (see --help for details):\n"
169+
"PYTHONDEBUG : enable parser debug mode (-d)\n"
170+
"PYTHONDONTWRITEBYTECODE: don't write .pyc files (-B)\n"
171+
"PYTHONINSPECT : inspect interactively after running script (-i)\n"
172+
"PYTHONINTMAXSTRDIGITS: limit max digit characters in an int value\n"
173+
" (-X int_max_str_digits=number)\n"
174+
"PYTHONNOUSERSITE: disable user site directory (-s)\n"
175+
"PYTHONOPTIMIZE : enable level 1 optimizations (-O)\n"
176+
"PYTHONSAFEPATH : don't prepend a potentially unsafe path to sys.path.\n"
177+
"PYTHONUNBUFFERED: disable stdout/stderr buffering (-u)\n"
178+
"PYTHONVERBOSE : trace import statements (-v)\n"
179+
"PYTHONWARNINGS=arg: warning control (-W arg)\n"
180+
;
178181

179182
#if defined(MS_WINDOWS)
180183
# define PYTHONHOMEHELP "<prefix>\\python{major}{minor}"
@@ -2295,9 +2298,9 @@ static void
22952298
config_complete_usage(const wchar_t* program)
22962299
{
22972300
config_usage(0, program);
2298-
puts("\n");
2301+
putchar('\n');
22992302
config_envvars_usage();
2300-
puts("\n");
2303+
putchar('\n');
23012304
config_xoptions_usage();
23022305
}
23032306

0 commit comments

Comments
 (0)