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

Minor documentation bug with os.path.split #51074

Closed
evaned mannequin opened this issue Sep 2, 2009 · 6 comments
Closed

Minor documentation bug with os.path.split #51074

evaned mannequin opened this issue Sep 2, 2009 · 6 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@evaned
Copy link
Mannequin

evaned mannequin commented Sep 2, 2009

BPO 6825
Nosy @birkenfeld, @jackdied, @sandrotosi
Files
  • issue6825-py3k.patch
  • issue6825-py3k-v2.patch
  • 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 = 'https://github.com/birkenfeld'
    closed_at = <Date 2010-10-14.06:46:17.729>
    created_at = <Date 2009-09-02.20:35:21.766>
    labels = ['docs']
    title = 'Minor documentation bug with os.path.split'
    updated_at = <Date 2010-10-14.06:46:17.727>
    user = 'https://bugs.python.org/evaned'

    bugs.python.org fields:

    activity = <Date 2010-10-14.06:46:17.727>
    actor = 'georg.brandl'
    assignee = 'georg.brandl'
    closed = True
    closed_date = <Date 2010-10-14.06:46:17.729>
    closer = 'georg.brandl'
    components = ['Documentation']
    creation = <Date 2009-09-02.20:35:21.766>
    creator = 'evaned'
    dependencies = []
    files = ['19152', '19163']
    hgrepos = []
    issue_num = 6825
    keywords = ['patch']
    message_count = 6.0
    messages = ['92180', '99931', '118148', '118159', '118207', '118624']
    nosy_count = 4.0
    nosy_names = ['georg.brandl', 'jackdied', 'evaned', 'sandro.tosi']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue6825'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @evaned
    Copy link
    Mannequin Author

    evaned mannequin commented Sep 2, 2009

    The documentation for os.path.split says, in part:

    "In nearly all cases, join(head, tail) equals path (the only
    exception being when there were multiple slashes separating head
    from tail)."

    But this is not quite true: that's not the *only* exception, at least
    without a somewhat liberal definition of "equals".

    This can also happen if os.altsep is used in the path being split, in
    which case it will be replaced by os.sep:

    >>> import ntpath
    >>> path = "a/b"
    >>> (head, tail) = ntpath.split(path)
    >>> joined = ntpath.join(head, tail)
    >>> joined == path
    False
    >>> joined
    'a\\b'

    [I only selected the versions that I actually verified, but I would
    guess it's present in more.]

    @evaned evaned mannequin assigned birkenfeld Sep 2, 2009
    @evaned evaned mannequin added the docs Documentation in the Doc dir label Sep 2, 2009
    @jackdied
    Copy link
    Contributor

    how about "an equivalent path" instead of "equal path"? The result of ntpath.join(ntpath.split(path)) should point to the same location even if it isn't literally the same string.

    @sandrotosi
    Copy link
    Contributor

    Hello,
    I find the proposed text change good, and so here's a patch to add that in a bit different format (sorry it's quite of a mess, but I took the occasion to wrap that paragraph to 80th column).

    Regards,
    Sandro

    @evaned
    Copy link
    Mannequin Author

    evaned mannequin commented Oct 8, 2010

    Hah, I totally forgot about this thing.

    I'd suggest a change to the proposed patch. The patched version says:

    "In nearly all cases, join(head, tail) returns a location
    equivalent to path (the only exception being when there were
    multiple slashes separating head from tail)."

    Except now the parenthetical remark at the end of that sentence is a bit weird, because "a//a" != "a/a" is no longer an exception.

    I'd suggest a wording such as one of the following, depending on where you want the emphasis (on the meaning of the return value of a path or on the actual contents of the return value as a string):

    "In all cases, join(head, tail) returns a location equivalent
    to path."

    "In most cases, join(head, tail) equals path; the
    exceptions to this are when there were multiple slashes
    separating head from tail or when os.altsep separators
    are replaced by os.sep."

    The first suggestion could be followed by a remark "(but the strings may be unequal)" if you'd like.

    I'd also replace "a location equivalent to" with "a path to the same location as" or something like that; "location" doesn't appear anywhere else on that page, and it seems slightly out of place to me.

    @sandrotosi
    Copy link
    Contributor

    Hi Evan,
    all your comments make sense, so I prepared a new patch about it.

    I decided to go with the first option and adding a note about the possible different strings.

    Regards,
    Sandro

    @birkenfeld
    Copy link
    Member

    Thanks, applied in r85453.

    @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
    docs Documentation in the Doc dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants