Skip to content

Commit f8ac776

Browse files
committed
[3.7] bpo-39427: Document -X opt options in the CLI --help and the man page (GH-18131)
https://bugs.python.org/issue39427 Automerge-Triggered-By: @pablogsal. (cherry picked from commit 41f0ef6) Co-authored-by: Pablo Galindo <[email protected]>
1 parent 9e06d61 commit f8ac776

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Document all possibilities for the ``-X`` options in the command line help
2+
section. Patch by Pablo Galindo.

Misc/python.man

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,42 @@ field matches the line number, where zero matches all line numbers and
273273
is thus equivalent to an omitted line number.
274274
.TP
275275
.BI "\-X " option
276-
Set implementation specific option.
276+
Set implementation specific option. The following options are available:
277+
278+
-X faulthandler: enable faulthandler
279+
280+
-X showrefcount: output the total reference count and number of used
281+
memory blocks when the program finishes or after each statement in the
282+
interactive interpreter. This only works on debug builds
283+
284+
-X tracemalloc: start tracing Python memory allocations using the
285+
tracemalloc module. By default, only the most recent frame is stored in a
286+
traceback of a trace. Use -X tracemalloc=NFRAME to start tracing with a
287+
traceback limit of NFRAME frames
288+
289+
-X showalloccount: output the total count of allocated objects for each
290+
type when the program finishes. This only works when Python was built with
291+
COUNT_ALLOCS defined
292+
293+
-X importtime: show how long each import takes. It shows module name,
294+
cumulative time (including nested imports) and self time (excluding
295+
nested imports). Note that its output may be broken in multi-threaded
296+
application. Typical usage is python3 -X importtime -c 'import asyncio'
297+
298+
-X dev: enable CPython’s “development mode”, introducing additional runtime
299+
checks which are too expensive to be enabled by default. It will not be
300+
more verbose than the default if the code is correct: new warnings are
301+
only emitted when an issue is detected. Effect of the developer mode:
302+
* Add default warning filter, as -W default
303+
* Install debug hooks on memory allocators: see the PyMem_SetupDebugHooks() C function
304+
* Enable the faulthandler module to dump the Python traceback on a crash
305+
* Enable asyncio debug mode
306+
* Set the dev_mode attribute of sys.flags to True
307+
308+
-X utf8: enable UTF-8 mode for operating system interfaces, overriding the default
309+
locale-aware mode. -X utf8=0 explicitly disables UTF-8 mode (even when it would
310+
otherwise activate automatically). See PYTHONUTF8 for more details
311+
277312
.TP
278313
.B \-x
279314
Skip the first line of the source. This is intended for a DOS

Modules/main.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,35 @@ static const char usage_3[] = "\
114114
-W arg : warning control; arg is action:message:category:module:lineno\n\
115115
also PYTHONWARNINGS=arg\n\
116116
-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
117-
-X opt : set implementation-specific option\n\
117+
-X opt : set implementation-specific option. The following options are available:\n\
118+
\n\
119+
-X faulthandler: enable faulthandler\n\
120+
-X showrefcount: output the total reference count and number of used\n\
121+
memory blocks when the program finishes or after each statement in the\n\
122+
interactive interpreter. This only works on debug builds\n\
123+
-X tracemalloc: start tracing Python memory allocations using the\n\
124+
tracemalloc module. By default, only the most recent frame is stored in a\n\
125+
traceback of a trace. Use -X tracemalloc=NFRAME to start tracing with a\n\
126+
traceback limit of NFRAME frames\n\
127+
-X showalloccount: output the total count of allocated objects for each\n\
128+
type when the program finishes. This only works when Python was built with\n\
129+
COUNT_ALLOCS defined\n\
130+
-X importtime: show how long each import takes. It shows module name,\n\
131+
cumulative time (including nested imports) and self time (excluding\n\
132+
nested imports). Note that its output may be broken in multi-threaded\n\
133+
application. Typical usage is python3 -X importtime -c 'import asyncio'\n\
134+
-X dev: enable CPython’s “development mode”, introducing additional runtime\n\
135+
checks which are too expensive to be enabled by default. Effect of the\n\
136+
developer mode:\n\
137+
* Add default warning filter, as -W default\n\
138+
* Install debug hooks on memory allocators: see the PyMem_SetupDebugHooks() C function\n\
139+
* Enable the faulthandler module to dump the Python traceback on a crash\n\
140+
* Enable asyncio debug mode\n\
141+
* Set the dev_mode attribute of sys.flags to True\n\
142+
-X utf8: enable UTF-8 mode for operating system interfaces, overriding the default\n\
143+
locale-aware mode. -X utf8=0 explicitly disables UTF-8 mode (even when it would\n\
144+
otherwise activate automatically)\n\
145+
\n\
118146
--check-hash-based-pycs always|default|never:\n\
119147
control how Python invalidates hash-based .pyc files\n\
120148
";

0 commit comments

Comments
 (0)