Skip to content

bytes.index(), bytes.rindex(), bytearray.index() and bytearray.rindex() get a different error message #136894

@hyperkai

Description

@hyperkai

Bug report

Bug description:

str.index() and str.rindex() get the error message as shown below:

v = str('Hello')

print(v.index('abc'))
print(v.rindex('abc'))
# ValueError: substring not found

But bytes.index() and bytes.rindex() get the different error message as shown below:

v = bytes(b'Hello')

print(v.index(b'abc'))
print(v.rindex(b'abc'))
# ValueError: subsection not found

And, bytearray.index() and bytearray.rindex() also get the different error message as shown below:

v = bytearray(b'Hello')

print(v.index(b'abc'))
print(v.rindex(b'abc'))
# ValueError: subsection not found

So, the error message of them should be the same for consistency as shown below:

ValueError: substring not found

Or:

ValueError: subsection not found

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy