Skip to content

Commit 4c838a2

Browse files
committed
fix xoptions help sort order
1 parent 46bbb87 commit 4c838a2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Lib/test/test_cmd_line.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ def test_help_env(self):
7373
def test_help_xoptions(self):
7474
out = self.verify_valid_flag('--help-xoptions')
7575
self.assertIn(b'-X dev', out)
76+
sort_key = lambda k: k.replace(b'_', b'').replace(b'-', b'').lower()
7677
options = re.findall(rb'^-X (\w+)', out, re.MULTILINE)
77-
self.assertEqual(options, sorted(options),
78+
self.assertEqual(options, sorted(options, key=sort_key),
7879
"options should be sorted alphabetically")
7980

8081
@support.cpython_only

Python/initconfig.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ file : program read from script file\n\
303303
arg ...: arguments passed to program in sys.argv[1:]\n\
304304
";
305305

306+
/* Please keep sorted by -X option name, ignoring -s and _s */
306307
static const char usage_xoptions[] = "\
307308
The following implementation-specific options are available:\n\
308309
-X context_aware_warnings=[0|1]: if true (1) then the warnings module will\n\
@@ -319,10 +320,6 @@ The following implementation-specific options are available:\n\
319320
-X frozen_modules=[on|off]: whether to use frozen modules; the default is \"on\"\n\
320321
for installed Python and \"off\" for a local build;\n\
321322
also PYTHON_FROZEN_MODULES\n\
322-
-X traceback_timestamps=[us|ns|iso|0|1]: display timestamp in tracebacks when\n\
323-
exception occurs; \"us\" shows microseconds;\n\
324-
\"ns\" shows raw nanoseconds; \"iso\" shows ISO-8601 format; \"0\" disables timestamps;\n\
325-
\"1\" is equivalent to \"us\"; also PYTHON_TRACEBACK_TIMESTAMPS\n\
326323
"
327324
#ifdef Py_GIL_DISABLED
328325
"-X gil=[0|1]: enable (1) or disable (0) the GIL; also PYTHON_GIL\n"
@@ -366,6 +363,10 @@ The following implementation-specific options are available:\n\
366363
PYTHON_TLBC\n"
367364
#endif
368365
"\
366+
-X traceback_timestamps=[us|ns|iso|0|1]: display timestamp in tracebacks when\n\
367+
exception occurs; \"us\" shows microseconds;\n\
368+
\"ns\" shows raw nanoseconds; \"iso\" shows ISO-8601 format; \"0\" disables timestamps;\n\
369+
\"1\" is equivalent to \"us\"; also PYTHON_TRACEBACK_TIMESTAMPS\n\
369370
-X tracemalloc[=N]: trace Python memory allocations; N sets a traceback limit\n\
370371
of N frames (default: 1); also PYTHONTRACEMALLOC=N\n\
371372
-X utf8[=0|1]: enable (1) or disable (0) UTF-8 mode; also PYTHONUTF8\n\
@@ -374,6 +375,7 @@ The following implementation-specific options are available:\n\
374375
";
375376

376377
/* Envvars that don't have equivalent command-line options are listed first */
378+
/* Please keep sections sorted by environment variable name, ignoring _s */
377379
static const char usage_envvars[] =
378380
"Environment variables that change behavior:\n"
379381
"PYTHONASYNCIODEBUG: enable asyncio debug mode\n"

0 commit comments

Comments
 (0)