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