Skip to content

split silently returns wrong result for multi-character separators #14649

@Miladkhoshdel

Description

@Miladkhoshdel

Repository commit

791deb4

Python version (python --version)

3.14.4

Dependencies version (pip freeze)

pip==26.0.1

Expected behavior

In strings/split.py, the custom split function should not silently return the unsplit string when separator has multiple characters. It should raise a clear ValueError.

Actual behavior

File location

strings/split.py

Actual behavior

In strings/split.py, the custom split function compares each character in the input string with separator.

Because of that, a multi-character separator such as "--" is never matched:

split("a--b--c", separator="--")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions