8000 gh-90300: Reformat the Python CLI help output (GH-93415) · python/cpython@2e92ffd · GitHub
[go: up one dir, main page]

Skip to content

Commit 2e92ffd

Browse files
gh-90300: Reformat the Python CLI help output (GH-93415)
1 parent e3f462c commit 2e92ffd

File tree

1 file changed

+106
-108
lines changed

1 file changed

+106
-108
lines changed

Python/initconfig.c

Lines changed: 106 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ Options (and corresponding environment variables):\n\
153153
.pyc extension; also PYTHONOPTIMIZE=x\n\
154154
-OO : do -O changes and also discard docstrings; add .opt-2 before\n\
155155
.pyc extension\n\
156-
-P : don't prepend a potentially unsafe path to sys.path; also PYTHONSAFEPATH\n\
156+
-P : don't prepend a potentially unsafe path to sys.path; also\n\
157+
PYTHONSAFEPATH\n\
157158
-q : don't print version and copyright messages on interactive startup\n\
158159
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
159160
-S : don't imply 'import site' on initialization\n\
@@ 8000 -169,9 +170,10 @@ Options (and corresponding environment variables):\n\
169170
-X opt : set implementation-specific option\n\
170171
--check-hash-based-pycs always|default|never:\n\
171172
control how Python invalidates hash-based .pyc files\n\
172-
--help-env : print help about Python environment variables and exit\n\
173-
--help-xoptions : print help about implementation-specific -X options and exit\n\
174-
--help-all : print complete help information and exit\n\
173+
--help-env: print help about Python environment variables and exit\n\
174+
--help-xoptions: print help about implementation-specific -X options and exit\n\
175+
--help-all: print complete help information and exit\n\
176+
\n\
175177
Arguments:\n\
176178
file : program read from script file\n\
177179
- : program read from stdin (default; interactive mode if a tty)\n\
@@ -180,139 +182,135 @@ arg ...: arguments passed to program in sys.argv[1:]\n\
180182

181183
static const char usage_xoptions[] = "\
182184
The following implementation-specific options are available:\n\
183-
\n\
184185
-X faulthandler: enable faulthandler\n\
185-
\n\
186186
-X showrefcount: output the total reference count and number of used\n\
187-
memory blocks when the program finishes or after each statement in the\n\
188-
interactive interpreter. This only works on debug builds\n\
189-
\n\
187+
memory blocks when the program finishes or after each statement in\n\
188+
the interactive interpreter. This only works on debug builds\n\
190189
-X tracemalloc: start tracing Python memory allocations using the\n\
191-
tracemalloc module. By default, only the most recent frame is stored in a\n\
192-
traceback of a trace. Use -X tracemalloc=NFRAME to start tracing with a\n\
193-
traceback limit of NFRAME frames\n\
194-
\n\
195-
-X importtime: show how long each import takes. It shows module name,\n\
196-
cumulative time (including nested imports) and self time (excluding\n\
197-
nested imports). Note that its output may be broken in multi-threaded\n\
198-
application. Typical usage is python3 -X importtime -c 'import asyncio'\n\
199-
\n\
200-
-X dev: enable CPython's \"development mode\", introducing additional runtime\n\
201-
checks which are too expensive to be enabled by default. Effect of the\n\
202-
developer mode:\n\
203-
* Add default warning filter, as -W default\n\
204-
* Install debug hooks on memory allocators: see the PyMem_SetupDebugHooks()\n\
205-
C function\n\
206-
* Enable the faulthandler module to dump the Python traceback on a crash\n\
207-
* Enable asyncio debug mode\n\
208-
* Set the dev_mode attribute of sys.flags to True\n\
209-
* io.IOBase destructor logs close() exceptions\n\
210-
\n\
211-
-X utf8: enable UTF-8 mode for operating system interfaces, overriding the default\n\
212-
locale-aware mode. -X utf8=0 explicitly disables UTF-8 mode (even when it would\n\
213-
otherwise activate automatically)\n\
214-
\n\
215-
-X pycache_prefix=PATH: enable writing .pyc files to a parallel tree rooted at the\n\
216-
given directory instead of to the code tree\n\
217-
\n\
190+
tracemalloc module. By default, only the most recent frame is stored\n\
191+
in a traceback of a trace. Use -X tracemalloc=NFRAME to start\n\
192+
tracing with a traceback limit of NFRAME frames\n\
193+
-X importtime: show how long each import takes. It shows module name,\n\
194+
cumulative time (including nested imports) and self time (excluding\n\
195+
nested imports). Note that its output may be broken in\n\
196+
multi-threaded application.\n\
197+
Typical usage is python3 -X importtime -c 'import asyncio'\n\
198+
-X dev : enable CPython's \"development mode\", introducing additional runtime\n\
199+
checks which are too expensive to be enabled by default. Effect of\n\
200+
the developer mode:\n\
201+
* Add default warning filter, as -W default\n\
202+
* Install debug hooks on memory allocators: see the\n\
203+
PyMem_SetupDebugHooks() C function\n\
204+
* Enable the faulthandler module to dump the Python traceback on\n\
205+
a crash\n\
206+
* Enable asyncio debug mode\n\
207+
* Set the dev_mode attribute of sys.flags to True\n\
208+
* io.IOBase destructor logs close() exceptions\n\
209+
-X utf8: enable UTF-8 mode for operating system interfaces, overriding the\n\
210+
default locale-aware mode. -X utf8=0 explicitly disables UTF-8 mode\n\
211+
(even when it would otherwise activate automatically)\n\
212+
-X pycache_prefix=PATH: enable writing .pyc files to a parallel tree rooted\n\
213+
at the given directory instead of to the code tree\n\
218214
-X warn_default_encoding: enable opt-in EncodingWarning for 'encoding=None'\n\
219-
\n\
220-
-X no_debug_ranges: disable the inclusion of the tables mapping extra location \n\
221-
information (end line, start column offset and end column offset) to every \n\
222-
instruction in code objects. This is useful when smaller code objects and pyc \n\
223-
files are desired as well as suppressing the extra visual location indicators \n\
224-
when the interpreter displays tracebacks.\n\
225-
\n\
226-
-X perf: activate support for the Linux \"perf\" profiler by activating the \"perf\"\n\
227-
trampoline. When this option is activated, the Linux \"perf\" profiler will be \n\
228-
able to report Python calls. This option is only available on some platforms and will \n\
229-
do nothing if is not supported on the current system. The default value is \"off\".\n\
230-
\n\
215+
-X no_debug_ranges: disable the inclusion of the tables mapping extra location\n\
216+
information (end line, start column offset and end column offset) to\n\
217+
every instruction in code objects. This is useful when smaller code\n\
218+
objects and pyc files are desired as well as suppressing the extra\n\
219+
visual location indicators when the interpreter displays tracebacks.\n\
220+
-X perf: activate support for the Linux \"perf\" profiler by activating the\n\
221+
\"perf\" trampoline. When this option is activated, the Linux \"perf\"\n\
222+
profiler will be able to report Python calls. This option is only\n\
223+
available on some platforms and will do nothing if is not supported\n\
224+
on the current system. The default value is \"off\".\n\
231225
-X frozen_modules=[on|off]: whether or not frozen modules should be used.\n\
232-
The default is \"on\" (or \"off\" if you are running a local build).\n\
233-
\n\
226+
The default is \"on\" (or \"off\" if you are running a local build).\n\
234227
-X int_max_str_digits=number: limit the size of int<->str conversions.\n\
235-
This helps avoid denial of service attacks when parsing untrusted data.\n\
236-
The default is sys.int_info.default_max_str_digits. 0 disables.\n\
237-
\n\
228+
This helps avoid denial of service attacks when parsing untrusted\n\
229+
data. The default is sys.int_info.default_max_str_digits.\n\
230+
0 disables.\n\
238231
-X cpu_count=[n|default]: Override the return value of os.cpu_count(),\n\
239-
os.process_cpu_count(), and multiprocessing.cpu_count(). This can help users who need\n\
240-
to limit resources in a container."
241-
232+
os.process_cpu_count(), and multiprocessing.cpu_count(). This can\n\
233+
help users who need to limit resources in a container."
242234
#ifdef Py_STATS
243235
"\n\
244-
\n\
245236
-X pystats: Enable pystats collection at startup."
246237
#endif
247238
#ifdef Py_DEBUG
248239
"\n\
249-
\n\
250240
-X presite=package.module: import this module before site.py is run."
251241
#endif
252242
;
253243

254244
/* Envvars that don't have equivalent command-line options are listed first */
255245
static const char usage_envvars[] =
256246
"Environment variables that change behavior:\n"
257-
"PYTHONSTARTUP: file executed on interactive startup (no default)\n"
258-
"PYTHONPATH : '%lc'-separated list of directories prefixed to the\n"
259-
" default module search path. The result is sys.path.\n"
260-
"PYTHONHOME : alternate <prefix> directory (or <prefix>%lc<exec_prefix>).\n"
261-
" The default module search path uses %s.\n"
262-
"PYTHONPLATLIBDIR : override sys.platlibdir.\n"
263-
"PYTHONCASEOK : ignore case in 'import' statements (Windows).\n"
264-
"PYTHONUTF8: if set to 1, enable the UTF-8 mode.\n"
247+
"PYTHONSTARTUP : file executed on interactive startup (no default)\n"
248+
"PYTHONPATH : '%lc'-separated list of directories prefixed to the\n"
249+
" default module search path. The result is sys.path.\n"
250+
"PYTHONHOME : alternate <prefix> directory (or <prefix>%lc<exec_prefix>).\n"
251+
" The default module search path uses %s.\n"
252+
"PYTHONPLATLIBDIR: override sys.platlibdir.\n"
253+
"PYTHONCASEOK : ignore case in 'import' statements (Windows).\n"
254+
"PYTHONUTF8 : if set to 1, enable the UTF-8 mode.\n"
265255
"PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n"
266256
"PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.\n"
267-
"PYTHONHASHSEED: if this variable is set to 'random', a random value is used\n"
268-
" to seed the hashes of str and bytes objects. It can also be set to an\n"
269-
" integer in the range [0,4294967295] to get hash values with a\n"
270-
" predictable seed.\n"
257+
"PYTHONHASHSEED : if this variable is set to 'random', a random value is used\n"
258+
" to seed the hashes of str and bytes objects. It can also be\n"
259+
" set to an integer in the range [0,4294967295] to get hash\n"
260+
" values with a predictable seed.\n"
271261
"PYTHONINTMAXSTRDIGITS: limits the maximum digit characters in an int value\n"
272-
" when converting from a string and when converting an int back to a str.\n"
273-
" A value of 0 disables the limit. Conversions to or from bases 2, 4, 8,\n"
274-
" 16, and 32 are never limited.\n"
275-
"PYTHONMALLOC: set the Python memory allocators and/or install debug hooks\n"
276-
" on Python memory allocators. Use PYTHONMALLOC=debug to install debug\n"
277-
" hooks.\n"
262+
" when converting from a string and when converting an int\n"
263+
" back to a str. A value of 0 disables the limit.\n"
264+
" Conversions to or from bases 2, 4, 8, 16, and 32 are never\n"
265+
" limited.\n"
266+
"PYTHONMALLOC : set the Python memory allocators and/or install debug hooks\n"
267+
" on Python memory allocators. Use PYTHONMALLOC=debug to\n"
268+
" install debug hooks.\n"
278269
"PYTHONCOERCECLOCALE: if this variable is set to 0, it disables the locale\n"
279-
" coercion behavior. Use PYTHONCOERCECLOCALE=warn to request display of\n"
280-
" locale coercion and locale compatibility warnings on stderr.\n"
270+
" coercion behavior. Use PYTHONCOERCECLOCALE=warn to request\n"
271+
" display of locale coercion and locale compatibility warnings\n"
272+
" on stderr.\n"
281273
"PYTHONBREAKPOINT: if this variable is set to 0, it disables the default\n"
282-
" debugger. It can be set to the callable of your debugger of choice.\n"
274+
" debugger. It can be set to the callable of your debugger of\n"
275+
" choice.\n"
283276
"PYTHON_CPU_COUNT: Overrides the return value of os.process_cpu_count(),\n"
284-
" os.cpu_count(), and multiprocessing.cpu_count() if set to a positive integer.\n"
285-
"PYTHONDEVMODE: enable the development mode.\n"
277+
" os.cpu_count(), and multiprocessing.cpu_count() if set to\n"
278+
" a positive integer.\n"
279+
"PYTHONDEVMODE : enable the development mode.\n"
286280
"PYTHONPYCACHEPREFIX: root directory for bytecode cache (pyc) files.\n"
287281
"PYTHONWARNDEFAULTENCODING: enable opt-in EncodingWarning for 'encoding=None'.\n"
288-
"PYTHONNODEBUGRANGES: if this variable is set, it disables the inclusion of the \n"
289-
" tables mapping extra location information (end line, start column offset \n"
290-
" and end column offset) to every instruction in code objects. This is useful \n"
291-
" when smaller code objects and pyc files are desired as well as suppressing the \n"
292-
" extra visual location indicators when the interpreter displays tracebacks.\n"
293-
"PYTHON_FROZEN_MODULES : if this variable is set, it determines whether or not \n"
294-
" frozen modules should be used. The default is \"on\" (or \"off\" if you are \n"
295-
" running a local build).\n"
296-
"PYTHON_COLORS : If this variable is set to 1, the interpreter will"
297-
" colorize various kinds of output. Setting it to 0 deactivates this behavior.\n"
298-
"PYTHON_HISTORY : the location of a .python_history file.\n"
299-
"These variables have equivalent command-line parameters (see --help for details):\n"
300-
"PYTHONDEBUG : enable parser debug mode (-d)\n"
301-
"PYTHONDONTWRITEBYTECODE : don't write .pyc files (-B)\n"
302-
"PYTHONINSPECT : inspect interactively after running script (-i)\n"
303-
"PYTHONINTMAXSTRDIGITS : limit max digit characters in an int value\n"
304-
" (-X int_max_str_digits=number)\n"
305-
"PYTHONNOUSERSITE : disable user site directory (-s)\n"
306-
"PYTHONOPTIMIZE : enable level 1 optimizations (-O)\n"
307-
"PYTHONSAFEPATH : don't prepend a potentially unsafe path to sys.path (-P)\n"
308-
"PYTHONUNBUFFERED : disable stdout/stderr buffering (-u)\n"
309-
"PYTHONVERBOSE : trace import statements (-v)\n"
310-
"PYTHONWARNINGS=arg : warning control (-W arg)\n"
282+
"PYTHONNODEBUGRANGES: if this variable is set, it disables the inclusion of\n"
283+
" the tables mapping extra location information (end line,\n"
284+
" start column offset and end column offset) to every\n"
285+
" instruction in code objects. This is useful when smaller\n"
286+
" code objects and pyc files are desired as well as\n"
287+
" suppressing the extra visual location indicators when the\n"
288+
" interpreter displays tracebacks.\n"
289+
"PYTHON_FROZEN_MODULES: if this variable is set, it determines whether or not\n"
290+
" frozen modules should be used. The default is \"on\" (or\n"
291+
" \"off\" if you are running a local build).\n"
292+
"PYTHON_COLORS : if this variable is set to 1, the interpreter will colorize\n"
293+
" various kinds of output. Setting it to 0 deactivates\n"
294+
" this behavior.\n"
295+
"PYTHON_HISTORY : the location of a .python_history file.\n"
296+
"\n"
297+
"These variables have equivalent command-line options (see --help for details):\n"
298+
"PYTHONDEBUG : enable parser debug mode (-d)\n"
299+
"PYTHONDONTWRITEBYTECODE: don't write .pyc files (-B)\n"
300+
"PYTHONINSPECT : inspect interactively after running script (-i)\n"
301+
"PYTHONINTMAXSTRDIGITS: limit max digit characters in an int value\n"
302+
" (-X int_max_str_digits=number)\n"
303+
"PYTHONNOUSERSITE: disable user site directory (-s)\n"
304+
"PYTHONOPTIMIZE : enable level 1 optimizations (-O)\n"
305+
"PYTHONSAFEPATH : don't prepend a potentially unsafe path to sys.path.\n"
306+
"PYTHONUNBUFFERED: disable stdout/stderr buffering (-u)\n"
307+
"PYTHONVERBOSE : trace import statements (-v)\n"
308+
"PYTHONWARNINGS=arg: warning control (-W arg)\n"
311309
#ifdef Py_STATS
312-
"PYTHONSTATS : turns on statistics gathering\n"
310+
"PYTHONSTATS : turns on statistics gathering\n"
313311
#endif
314312
#ifdef Py_DEBUG
315-
"PYTHON_PRESITE=pkg.mod : import this module before site.py is run\n"
313+
"PYTHON_PRESITE=pkg.mod: import this module before site.py is run\n"
316314
#endif
317315
;
318316

@@ -2387,9 +2385,9 @@ static void
23872385
config_complete_usage(const wchar_t* program)
23882386
{
23892387
config_usage(0, program);
2390-
puts("\n");
2388+
putchar('\n');
23912389
config_envvars_usage();
2392-
puts("\n");
2390+
putchar('\n');
23932391
config_xoptions_usage();
23942392
}
23952393

0 commit comments

Comments
 (0)
0