Skip to content

Commit 1c984ba

Browse files
sobolevnvstinnerStanFromIreland
authored
gh-136355: Deprecate -b and -bb CLI flags in 3.15 (#136363)
Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Stan Ulbrych <[email protected]>
1 parent 8b5ce31 commit 1c984ba

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

Doc/c-api/init_config.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,11 @@ PyConfig
12781278
12791279
Default: ``0``.
12801280
1281+
.. deprecated-removed:: 3.15 3.17
1282+
1283+
The :option:`-b` and :option:`!-bb` options will become no-op in 3.17.
1284+
:c:member:`~PyConfig.bytes_warning` member will be removed in 3.17.
1285+
12811286
.. c:member:: int warn_default_encoding
12821287
12831288
If non-zero, emit a :exc:`EncodingWarning` warning when :class:`io.TextIOWrapper`

Doc/using/cmdline.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@ Miscellaneous options
254254
.. versionchanged:: 3.5
255255
Affects also comparisons of :class:`bytes` with :class:`int`.
256256

257+
.. deprecated:: 3.15
258+
259+
Deprecate :option:`-b` and :option:`!-bb` command line options
260+
and schedule them to become no-op in Python 3.17.
261+
These were primarily helpers for the Python 2 -> 3 transition.
262+
Starting with Python 3.17, no :exc:`BytesWarning` will be raised
263+
for these cases; use a type checker instead.
264+
265+
257266
.. option:: -B
258267

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

Doc/whatsnew/3.15.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,17 @@ module_name
537537
Deprecated
538538
==========
539539

540+
CLI
541+
---
542+
543+
* Deprecate :option:`-b` and :option:`!-bb` command line options
544+
and schedule them to become no-op in Python 3.17.
545+
These were primarily helpers for the Python 2 -> 3 transition.
546+
Starting with Python 3.17, no :exc:`BytesWarning` will be raised
547+
for these cases; use a type checker instead.
548+
549+
(Contributed by Nikita Sobolev in :gh:`136355`.)
550+
540551
hashlib
541552
-------
542553

@@ -775,6 +786,10 @@ Deprecated C APIs
775786
:c:func:`_Py_c_abs` are :term:`soft deprecated`.
776787
(Contributed by Sergey B Kirpichev in :gh:`128813`.)
777788

789+
* :c:member:`~PyConfig.bytes_warning` is deprecated
790+
since 3.15 and will be removed in 3.17.
791+
(Contributed by Nikita Sobolev in :gh:`136355`.)
792+
778793

779794
.. Add C API deprecations above alphabetically, not here at the end.
780795
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate :c:member:`PyConfig.bytes_warning` field and schedule its removal
2+
in 3.17.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate :option:`-b` and :option:`!-bb` command line options
2+
and schedule them to become no-op in Python 3.17.

Python/initconfig.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ static const char usage_help[] = "\
258258
Options (and corresponding environment variables):\n\
259259
-b : issue warnings about converting bytes/bytearray to str and comparing\n\
260260
bytes/bytearray with str or bytes with int. (-bb: issue errors)\n\
261+
deprecated since 3.15 and will become no-op in 3.17.\n\
261262
-B : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x\n\
262263
-c cmd : program passed in as string (terminates option list)\n\
263264
-d : turn on parser debugging output (for experts only, only works on\n\

0 commit comments

Comments
 (0)