Skip to content

Commit 2c83cfc

Browse files
committed
No warning, no plans to remove -b and -bb, only make them no-op
1 parent 499343c commit 2c83cfc

File tree

6 files changed

+17
-41
lines changed

6 files changed

+17
-41
lines changed

Doc/c-api/init_config.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,10 @@ PyConfig
12801280
12811281
Default: ``0``.
12821282
1283+
.. deprecated:: 3.15
1284+
1285+
Deprecated, will become no-op in 3.17.
1286+
12831287
.. c:member:: int warn_default_encoding
12841288
12851289
If non-zero, emit a :exc:`EncodingWarning` warning when :class:`io.TextIOWrapper`

Doc/using/cmdline.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,11 @@ Miscellaneous options
256256

257257
.. deprecated-removed:: 3.15 3.17
258258

259-
Deprecate :option:`-b` and :option:`-bb`
260-
and schedule them for removal in Python 3.17.
261-
They were mainly a transition helpers for Python2 -> Python3 era.
262-
In 3.17 no :exc:`BytesWarning` won't be raised for these cases.
263-
If you want to check for the same things in the future,
264-
use any type-checker of your choice.
259+
Deprecate :option:`-b` and :option:`!-bb`
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.
265264

266265

267266
.. option:: -B

Doc/whatsnew/3.15.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,10 @@ CLI
210210
---
211211

212212
* Deprecate :option:`-b` and :option:`!-bb`
213-
and schedule them for removal in Python 3.17.
214-
They were mainly a transition helpers for Python2 -> Python3 era.
215-
In 3.17 no :exc:`BytesWarning` won't be raised for these cases.
216-
If you want to check for the same things in the future,
217-
use any type-checker of your choice.
213+
and schedule them to become no-op in Python 3.17.
214+
These were primarily helpers for the Python 2 -> 3 transition.
215+
Starting with Python 3.17, no :exc:`BytesWarning` will be raised
216+
for these cases; use a type checker instead.
218217

219218
(Contributed by Nikita Sobolev in :gh:`136355`.)
220219

Lib/test/test_cmd_line.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ def _kill_python_and_exit_code(p):
3232
return data, returncode
3333

3434

35-
b_deprecation_msg = (
36-
'-b option is deprecated since Python 3.15 '
37-
'and will be removed in Python 3.17'
38-
)
39-
40-
4135
class CmdLineTest(unittest.TestCase):
4236
def test_directories(self):
4337
assert_python_failure('.')
@@ -712,7 +706,7 @@ def run_xdev(self, *args, check_exitcode=True, xdev=True):
712706
env=env)
713707
if check_exitcode:
714708
self.assertEqual(proc.returncode, 0, proc)
715-
return self.maybe_remove_b_deprecation_msg(proc.stdout)
709+
return proc.stdout.rstrip()
716710

717711
@support.cpython_only
718712
def test_xdev(self):
@@ -795,22 +789,7 @@ def check_warnings_filters(self, cmdline_option, envvar, use_pywarning=False):
795789
universal_newlines=True,
796790
env=env)
797791
self.assertEqual(proc.returncode, 0, proc)
798-
return self.maybe_remove_b_deprecation_msg(proc.stdout)
799-
800-
def maybe_remove_b_deprecation_msg(self, output):
801-
return output.replace(b_deprecation_msg + '\n', '').rstrip()
802-
803-
def test_b_deprecation_msg_stderr(self):
804-
for arg in ['-b', '-bb']:
805-
with self.subTest(arg=arg):
806-
args = (sys.executable, arg, '-c', '')
807-
proc = subprocess.run(args,
808-
stdout=subprocess.PIPE,
809-
stderr=subprocess.PIPE,
810-
universal_newlines=True)
811-
self.assertEqual(proc.returncode, 0, proc)
812-
self.assertEqual(proc.stdout, '')
813-
self.assertEqual(proc.stderr.rstrip(), b_deprecation_msg)
792+
return proc.stdout.rstrip()
814793

815794
def test_warnings_filter_precedence(self):
816795
expected_filters = ("error::BytesWarning "
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Deprecate :option:`-b` and :option:`!-bb` and schedule them
2-
for removal in the future versions of Python.
2+
to become no-op in Python 3.17.

Python/initconfig.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static const char usage_help[] = "\
256256
Options (and corresponding environment variables):\n\
257257
-b : issue warnings about converting bytes/bytearray to str and comparing\n\
258258
bytes/bytearray with str or bytes with int. (-bb: issue errors)\n\
259-
deprecated since 3.15 and will be removed in 3.17\n\
259+
deprecated since 3.15 and will become no-op in 3.17.\n\
260260
-B : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x\n\
261261
-c cmd : program passed in as string (terminates option list)\n\
262262
-d : turn on parser debugging output (for experts only, only works on\n\
@@ -2945,11 +2945,6 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions,
29452945
return _PyStatus_EXIT(0);
29462946

29472947
case 'b':
2948-
if (!config->bytes_warning) {
2949-
fprintf(stderr,
2950-
"-b option is deprecated since Python 3.15 "
2951-
"and will be removed in Python 3.17\n");
2952-
}
29532948
config->bytes_warning++;
29542949
break;
29552950

0 commit comments

Comments
 (0)