https://github.com/python/cpython/commit/1c984ba953e140b88ff890dbe1408f9611027444
commit: 1c984ba953e140b88ff890dbe1408f9611027444
branch: main
author: sobolevn <[email protected]>
committer: sobolevn <[email protected]>
date: 2025-09-14T20:00:03+03:00
summary:

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]>

files:
A Misc/NEWS.d/next/C_API/2025-09-14-14-44-24.gh-issue-136355.LCaYyC.rst
A 
Misc/NEWS.d/next/Core_and_Builtins/2025-07-07-12-24-00.gh-issue-136355.MTcA8j.rst
M Doc/c-api/init_config.rst
M Doc/using/cmdline.rst
M Doc/whatsnew/3.15.rst
M Python/initconfig.c

diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst
index 4f0199838e151d..b20495e672dd75 100644
--- a/Doc/c-api/init_config.rst
+++ b/Doc/c-api/init_config.rst
@@ -1278,6 +1278,11 @@ PyConfig
 
       Default: ``0``.
 
+      .. deprecated-removed:: 3.15 3.17
+
+         The :option:`-b` and :option:`!-bb` options will become no-op in 3.17.
+         :c:member:`~PyConfig.bytes_warning` member will be removed in 3.17.
+
    .. c:member:: int warn_default_encoding
 
       If non-zero, emit a :exc:`EncodingWarning` warning when 
:class:`io.TextIOWrapper`
diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst
index 448f2725e9a3db..3f8b52e2345b25 100644
--- a/Doc/using/cmdline.rst
+++ b/Doc/using/cmdline.rst
@@ -254,6 +254,15 @@ Miscellaneous options
    .. versionchanged:: 3.5
       Affects also comparisons of :class:`bytes` with :class:`int`.
 
+   .. deprecated:: 3.15
+
+      Deprecate :option:`-b` and :option:`!-bb` command line options
+      and schedule them to become no-op in Python 3.17.
+      These were primarily helpers for the Python 2 -> 3 transition.
+      Starting with Python 3.17, no :exc:`BytesWarning` will be raised
+      for these cases; use a type checker instead.
+
+
 .. option:: -B
 
    If given, Python won't try to write ``.pyc`` files on the
diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst
index 1d029e3914baf5..9031301989e396 100644
--- a/Doc/whatsnew/3.15.rst
+++ b/Doc/whatsnew/3.15.rst
@@ -537,6 +537,17 @@ module_name
 Deprecated
 ==========
 
+CLI
+---
+
+* Deprecate :option:`-b` and :option:`!-bb` command line options
+  and schedule them to become no-op in Python 3.17.
+  These were primarily helpers for the Python 2 -> 3 transition.
+  Starting with Python 3.17, no :exc:`BytesWarning` will be raised
+  for these cases; use a type checker instead.
+
+  (Contributed by Nikita Sobolev in :gh:`136355`.)
+
 hashlib
 -------
 
@@ -775,6 +786,10 @@ Deprecated C APIs
   :c:func:`_Py_c_abs` are :term:`soft deprecated`.
   (Contributed by Sergey B Kirpichev in :gh:`128813`.)
 
+* :c:member:`~PyConfig.bytes_warning` is deprecated
+  since 3.15 and will be removed in 3.17.
+  (Contributed by Nikita Sobolev in :gh:`136355`.)
+
 
 .. Add C API deprecations above alphabetically, not here at the end.
 
diff --git 
a/Misc/NEWS.d/next/C_API/2025-09-14-14-44-24.gh-issue-136355.LCaYyC.rst 
b/Misc/NEWS.d/next/C_API/2025-09-14-14-44-24.gh-issue-136355.LCaYyC.rst
new file mode 100644
index 00000000000000..44537729b3f0a3
--- /dev/null
+++ b/Misc/NEWS.d/next/C_API/2025-09-14-14-44-24.gh-issue-136355.LCaYyC.rst
@@ -0,0 +1,2 @@
+Deprecate :c:member:`PyConfig.bytes_warning` field and schedule its removal
+in 3.17.
diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2025-07-07-12-24-00.gh-issue-136355.MTcA8j.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-07-12-24-00.gh-issue-136355.MTcA8j.rst
new file mode 100644
index 00000000000000..dd6bd28c3ff02b
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2025-07-07-12-24-00.gh-issue-136355.MTcA8j.rst
@@ -0,0 +1,2 @@
+Deprecate :option:`-b` and :option:`!-bb` command line options
+and schedule them to become no-op in Python 3.17.
diff --git a/Python/initconfig.c b/Python/initconfig.c
index efb276ac680ed9..5dc68eb4ec2cca 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -258,6 +258,7 @@ static const char usage_help[] = "\
 Options (and corresponding environment variables):\n\
 -b     : issue warnings about converting bytes/bytearray to str and 
comparing\n\
          bytes/bytearray with str or bytes with int. (-bb: issue errors)\n\
+         deprecated since 3.15 and will become no-op in 3.17.\n\
 -B     : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x\n\
 -c cmd : program passed in as string (terminates option list)\n\
 -d     : turn on parser debugging output (for experts only, only works on\n\

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to