Skip to content

Commit f6c6d1e

Browse files
authored
bpo-11681: Document the -b and -bb options (GH-1562)
1 parent 4be66b6 commit f6c6d1e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Doc/using/cmdline.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Command line
2424

2525
When invoking Python, you may specify any of these options::
2626

27-
python [-BdEiOQsRStuUvVWxX3?] [-c command | -m module-name | script | - ] [args]
27+
python [-bBdEiOQsRStuUvVWxX3?] [-c command | -m module-name | script | - ] [args]
2828

2929
The most common use case is, of course, a simple invocation of a script::
3030

@@ -191,6 +191,19 @@ Generic options
191191
Miscellaneous options
192192
~~~~~~~~~~~~~~~~~~~~~
193193

194+
.. cmdoption:: -b
195+
196+
Issue a warning when comparing :class:`unicode` with :class:`bytearray`.
197+
Issue an error when the option is given twice (:option:`!-bb`).
198+
199+
Note that, unlike the corresponding Python 3.x flag, this will **not** emit
200+
warnings for comparisons between :class:`str` and :class:`unicode`.
201+
Instead, the ``str`` instance will be implicitly decoded to ``unicode`` and
202+
Unicode comparison used.
203+
204+
.. versionadded:: 2.6
205+
206+
194207
.. cmdoption:: -B
195208

196209
If given, Python won't try to write ``.pyc`` or ``.pyo`` files on the

Modules/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ static char *usage_line =
6262
/* Long usage message, split into parts < 512 bytes */
6363
static char *usage_1 = "\
6464
Options and arguments (and corresponding environment variables):\n\
65+
-b : issue warnings about comparing bytearray with unicode\n\
66+
(-bb: issue errors)\n\
6567
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n\
6668
-c cmd : program passed in as string (terminates option list)\n\
6769
-d : debug output from parser; also PYTHONDEBUG=x\n\

0 commit comments

Comments
 (0)