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

os.path.relpath does not document ValueError on Windows with different drives #85827

Closed
andy-maier mannequin opened this issue Aug 29, 2020 · 5 comments
Closed

os.path.relpath does not document ValueError on Windows with different drives #85827

andy-maier mannequin opened this issue Aug 29, 2020 · 5 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes docs Documentation in the Doc dir OS-windows type-feature A feature request or enhancement

Comments

@andy-maier
Copy link
Mannequin

andy-maier mannequin commented Aug 29, 2020

BPO 41661
Nosy @pfmoore, @tjguk, @ambv, @zware, @eryksun, @zooba, @andy-maier, @ZackerySpytz, @miss-islington
PRs
  • bpo-41661: Document os.path.relpath() behavior on Windows with different drives #25346
  • [3.9] bpo-41661: Document os.path.relpath() exception on Windows with different drives (GH-25346) #25366
  • [3.8] bpo-41661: Document os.path.relpath() exception on Windows with different drives (GH-25346) #25367
  • 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 2021-04-12.15:42:18.907>
    created_at = <Date 2020-08-29.06:15:05.527>
    labels = ['3.8', '3.9', '3.10', 'type-feature', 'OS-windows', 'docs']
    title = 'os.path.relpath does not document ValueError on Windows with different drives'
    updated_at = <Date 2021-04-26.19:46:17.940>
    user = 'https://github.com/andy-maier'

    bugs.python.org fields:

    activity = <Date 2021-04-26.19:46:17.940>
    actor = 'lukasz.langa'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2021-04-12.15:42:18.907>
    closer = 'steve.dower'
    components = ['Documentation', 'Windows']
    creation = <Date 2020-08-29.06:15:05.527>
    creator = 'andymaier'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41661
    keywords = ['patch']
    message_count = 5.0
    messages = ['376057', '389589', '390857', '390863', '391981']
    nosy_count = 10.0
    nosy_names = ['paul.moore', 'tim.golden', 'docs@python', 'lukasz.langa', 'zach.ware', 'eryksun', 'steve.dower', 'andymaier', 'ZackerySpytz', 'miss-islington']
    pr_nums = ['25346', '25366', '25367']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue41661'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @andy-maier
    Copy link
    Mannequin Author

    andy-maier mannequin commented Aug 29, 2020

    I found that os.path.relpath() on Windows raises ValueError when the path and the start path are on different drives. This is to be expected, as there is no single root on Windows.

    On Python 3.7, the behavior is:

    >>> os.path.relpath('c:/abc', 'a:/')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "...\Python\Python37\lib\ntpath.py", line 564, in relpath
        path_drive, start_drive))
    ValueError: path is on mount 'c:', start on mount 'a:'

    The issue is that this ValueError and the reasons for it are not mentioned at all in the documentation for os.path.relpath(). Other os.path functions do document specific behaviors for different drives on Windows, for example os.path.commonpath(), so there is a precedence for documenting this. Also, it should be normal to document the possible exceptions that can be raised.

    I did read https://bugs.python.org/issue7195 from 2009 where the original issue discussed also lead to a request to update the documentation of os.path.relpath() to show the ValueError for this case, but that angle of the issue ended up being ignored back then, unfortunately.

    My suggestion is to add something like the following sentence the documentation:

    "On Windows, ValueError is raised when path and start are on different drives."

    @andy-maier andy-maier mannequin added the 3.7 (EOL) end of life label Aug 29, 2020
    @andy-maier andy-maier mannequin assigned docspython Aug 29, 2020
    @andy-maier andy-maier mannequin added docs Documentation in the Doc dir 3.7 (EOL) end of life labels Aug 29, 2020
    @andy-maier andy-maier mannequin assigned docspython Aug 29, 2020
    @andy-maier andy-maier mannequin added the docs Documentation in the Doc dir label Aug 29, 2020
    @tirkarthi tirkarthi added OS-windows type-bug An unexpected behavior, bug, or error labels Aug 29, 2020
    @eryksun
    Copy link
    Contributor

    eryksun commented Mar 27, 2021

    The suggested documentation change looks good to me.

    @eryksun eryksun added 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes type-feature A feature request or enhancement and removed 3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error labels Mar 27, 2021
    @zooba
    Copy link
    Member

    zooba commented Apr 12, 2021

    New changeset 67c0b3d by Zackery Spytz in branch 'master':
    bpo-41661: Document os.path.relpath() exception on Windows with different drives (GH-25346)
    67c0b3d

    @zooba zooba closed this as completed Apr 12, 2021
    @zooba zooba closed this as completed Apr 12, 2021
    @miss-islington
    Copy link
    Contributor

    New changeset de06baa by Miss Islington (bot) in branch '3.9':
    bpo-41661: Document os.path.relpath() exception on Windows with different drives (GH-25346)
    de06baa

    @ambv
    Copy link
    Contributor

    ambv commented Apr 26, 2021

    New changeset b570fea by Miss Islington (bot) in branch '3.8':
    bpo-41661: Document os.path.relpath() exception on Windows with different drives (GH-25346) (bpo-25367)
    b570fea

    @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
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes docs Documentation in the Doc dir OS-windows type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants