This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: str.replace() TypeError exception message backward
Type: behavior Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: bland328
Priority: normal Keywords:

Created on 2021-02-23 23:42 by bland328, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg387593 - (view) Author: bland328 (bland328) Date: 2021-02-23 23:42
Attempting to replace a character in a bytes string literal results in an exception saying that "a bytes-like object is required, not 'str'", when (unless I'm missing something) it should say the opposite.

To repro:

>>> x=b'abc'
>>> x.replace('a','z')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'
msg387594 - (view) Author: bland328 (bland328) Date: 2021-02-23 23:49
Dumb misunderstanding on my part--didn't realize replace() would actually work on a bytes-type object, so *I* had it backwards.
History
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87475
2021-02-23 23:49:51bland328setstatus: open -> closed
resolution: not a bug
messages: + msg387594

stage: resolved
2021-02-23 23:42:25bland328create