Skip to content

Commit 6458a33

Browse files
serhiy-storchakaambv
authored andcommitted
[3.12] pythongh-90300: Reformat the Python CLI help output (pythonGH-93415)
(cherry picked from commit 2e92ffd) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent a3bef56 commit 6458a33

File tree

1 file changed

+94
-95
lines changed

1 file changed

+94
-95
lines changed

Python/initconfig.c

Lines changed: 94 additions & 95 deletions
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,117 +78,114 @@ 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\
122-
-X perf: activate support for the Linux \"perf\" profiler by activating the \"perf\"\n\
123-
trampoline. When this option is activated, the Linux \"perf\" profiler will be \n\
124-
able to report Python calls. This option is only available on some platforms and will \n\
125-
do nothing if is not supported on the current system. The default value is \"off\".\n\
126-
\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\
116+
-X perf: activate support for the Linux \"perf\" profiler by activating the\n\
117+
\"perf\" trampoline. When this option is activated, the Linux \"perf\"\n\
118+
profiler will be able to report Python calls. This option is only\n\
119+
available on some platforms and will do nothing if is not supported\n\
120+
on the current system. The default value is \"off\".\n\
127121
-X frozen_modules=[on|off]: whether or not frozen modules should be used.\n\
128-
The default is \"on\" (or \"off\" if you are running a local build).\n\
129-
\n\
122+
The default is \"on\" (or \"off\" if you are running a local build).\n\
130123
-X int_max_str_digits=number: limit the size of int<->str conversions.\n\
131-
This helps avoid denial of service attacks when parsing untrusted data.\n\
132-
The default is sys.int_info.default_max_str_digits. 0 disables."
133-
124+
This helps avoid denial of service attacks when parsing untrusted\n\
125+
data. The default is sys.int_info.default_max_str_digits.\n\
126+
0 disables.\n\
134127
#ifdef Py_STATS
135128
"\n\
136-
\n\
137129
-X pystats: Enable pystats collection at startup."
138130
#endif
139131
;
140132

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

191190
#if defined(MS_WINDOWS)
192191
# define PYTHONHOMEHELP "<prefix>\\python{major}{minor}"
@@ -2370,9 +2369,9 @@ static void
23702369
config_complete_usage(const wchar_t* program)
23712370
{
23722371
config_usage(0, program);
2373-
puts("\n");
2372+
putchar('\n');
23742373
config_envvars_usage();
2375-
puts("\n");
2374+
putchar('\n');
23762375
config_xoptions_usage();
23772376
}
23782377

0 commit comments

Comments
 (0)