Skip to content

Fix IndexError in pydoc.replace #136572

Closed as not planned
Closed as not planned
@picnixz

Description

@picnixz

Bug report

Proposal:

We should instead raise a ValueError:

$ ./python -c "import pydoc; pydoc.replace('text', 'a')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import pydoc; pydoc.replace('text', 'a')
                  ~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/projects/python/cpython/Lib/pydoc.py", line 266, in replace
    text = pairs[1].join(text.split(pairs[0]))
           ~~~~~^^^
IndexError: tuple index out of range

Note

Since I changed the exception type, I won't backport this.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibPython modules in the Lib dirtype-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