Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

str.split bug when using sep = None and maxsplit #45581

Closed
QuantumTim mannequin opened this issue Oct 5, 2007 · 4 comments
Closed

str.split bug when using sep = None and maxsplit #45581

QuantumTim mannequin opened this issue Oct 5, 2007 · 4 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@QuantumTim
Copy link
Mannequin

QuantumTim mannequin commented Oct 5, 2007

BPO 1240
Nosy @gvanrossum, @brettcannon
Superseder
  • bpo-1123: split(None, maxsplit) does not strip whitespace correctly
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2007-10-07.20:06:03.034>
    created_at = <Date 2007-10-05.13:20:23.067>
    labels = ['type-bug']
    title = 'str.split bug when using sep = None and maxsplit'
    updated_at = <Date 2007-10-07.20:06:03.033>
    user = 'https://bugs.python.org/QuantumTim'

    bugs.python.org fields:

    activity = <Date 2007-10-07.20:06:03.033>
    actor = 'brett.cannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2007-10-07.20:06:03.034>
    closer = 'brett.cannon'
    components = []
    creation = <Date 2007-10-05.13:20:23.067>
    creator = 'QuantumTim'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 1240
    keywords = []
    message_count = 4.0
    messages = ['56237', '56242', '56254', '56258']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'brett.cannon', 'QuantumTim']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '1123'
    type = 'behavior'
    url = 'https://bugs.python.org/issue1240'
    versions = ['Python 2.5', 'Python 2.4']

    @QuantumTim
    Copy link
    Mannequin Author

    QuantumTim mannequin commented Oct 5, 2007

    From the docs for str.split:
    "If sep is not specified or is None... First, whitespace characters are
    stripped from both ends. Then, words are separated by arbitrary length
    strings of whitespace characters."

    However, ' a b c '.split(None, 1) returns ['a', 'b c '] indicating that
    the "stripped from both ends" isn't taking place, but that it's
    removing whitespace as it goes and never gets to the end as it stops
    parsing when it hits the first split.

    Note this is easily worked around by calling str.strip().split(None,
    1), but it would be good not to have to.

    I've tested this on windows version 2.5, and 2.4.4 for Debian

    @QuantumTim QuantumTim mannequin added the type-bug An unexpected behavior, bug, or error label Oct 5, 2007
    @QuantumTim QuantumTim mannequin changed the title str.split possible bug str.split bug Oct 5, 2007
    @QuantumTim QuantumTim mannequin changed the title str.split bug str.split bug when using sep = None and maxsplit Oct 5, 2007
    @brettcannon
    Copy link
    Member

    I know there is another filed bug on this topic, I just need to find it.

    @gvanrossum
    Copy link
    Member

    It was deemed a documentation bug.

    @brettcannon
    Copy link
    Member

    bpo-1123 was the issue I was thinking of. Setting that as a superceder
    as 1123 was closed prematurely.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants