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

pathlib relative_to behaviour change #86400

Closed
arminsbagrats mannequin opened this issue Nov 1, 2020 · 3 comments
Closed

pathlib relative_to behaviour change #86400

arminsbagrats mannequin opened this issue Nov 1, 2020 · 3 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@arminsbagrats
Copy link
Mannequin

arminsbagrats mannequin commented Nov 1, 2020

BPO 42234
Nosy @barneygale
Superseder
  • bpo-40358: pathlib's relative_to should behave like os.path.relpath
  • 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-06-23.10:41:51.481>
    created_at = <Date 2020-11-01.15:48:23.384>
    labels = ['type-bug', 'library', '3.10']
    title = 'pathlib relative_to behaviour change'
    updated_at = <Date 2022-02-22.23:52:02.772>
    user = 'https://bugs.python.org/arminsbagrats'

    bugs.python.org fields:

    activity = <Date 2022-02-22.23:52:02.772>
    actor = 'Socob'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-23.10:41:51.481>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2020-11-01.15:48:23.384>
    creator = 'armins.bagrats'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42234
    keywords = []
    message_count = 3.0
    messages = ['380148', '393774', '393776']
    nosy_count = 3.0
    nosy_names = ['Socob', 'barneygale', 'armins.bagrats']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '40358'
    type = 'behavior'
    url = 'https://bugs.python.org/issue42234'
    versions = ['Python 3.10']

    @arminsbagrats
    Copy link
    Mannequin Author

    arminsbagrats mannequin commented Nov 1, 2020

    In the docs (https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.relative_to) PurePath.relative_to() is specified to fail for arguments that are not on the original path (e.g. Path('/ham/beans').relative_to(Path('/spam'))).

    I believe it would be useful to extend the behaviour of relative_to so that it handles the case above. For example, I would expect Path('/ham/beans').relative_to(Path('/spam')) to return Path('../ham/beans').

    If this sounds like a useful change I'd be happy to make a PR for it.

    @arminsbagrats arminsbagrats mannequin added 3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 1, 2020
    @barneygale
    Copy link
    Mannequin

    barneygale mannequin commented May 17, 2021

    That does sound pretty useful! I'd be happy to review a PR though I'm not a core dev.

    @barneygale
    Copy link
    Mannequin

    barneygale mannequin commented May 17, 2021

    In fact, I think this is a duplicate of bpo-40358, which has an open PR against it.

    @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.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant