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

Return destination path in Path.rename and Path.replace #75346

Closed
albertogomcas mannequin opened this issue Aug 9, 2017 · 5 comments
Closed

Return destination path in Path.rename and Path.replace #75346

albertogomcas mannequin opened this issue Aug 9, 2017 · 5 comments
Labels
3.8 (EOL) end of life 3.9 only security fixes docs Documentation in the Doc dir easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@albertogomcas
Copy link
Mannequin

albertogomcas mannequin commented Aug 9, 2017

BPO 31163
Nosy @jaraco, @pitrou, @bitdancer, @berkerpeksag, @csabella
PRs
  • bpo-31163: Adding return values to pathlib's rename and replace methods #4055
  • bpo-31163: Added return values to pathlib.Path instance's rename and replace methods. #13582
  • [3.8] bpo-31163: Added return values to pathlib.Path instance's rename and replace methods. (GH-13582) #15944
  • 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 2019-09-11.14:23:08.013>
    created_at = <Date 2017-08-09.15:32:24.454>
    labels = ['easy', '3.8', '3.9', 'type-feature', 'library', 'docs']
    title = 'Return destination path in Path.rename and Path.replace'
    updated_at = <Date 2019-09-11.14:23:08.008>
    user = 'https://bugs.python.org/albertogomcas'

    bugs.python.org fields:

    activity = <Date 2019-09-11.14:23:08.008>
    actor = 'jaraco'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2019-09-11.14:23:08.013>
    closer = 'jaraco'
    components = ['Documentation', 'Library (Lib)']
    creation = <Date 2017-08-09.15:32:24.454>
    creator = 'albertogomcas'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31163
    keywords = ['patch', 'easy']
    message_count = 5.0
    messages = ['300019', '300027', '342970', '351865', '351892']
    nosy_count = 7.0
    nosy_names = ['jaraco', 'pitrou', 'r.david.murray', 'docs@python', 'berker.peksag', 'cheryl.sabella', 'albertogomcas']
    pr_nums = ['4055', '13582', '15944']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue31163'
    versions = ['Python 3.8', 'Python 3.9']

    @albertogomcas
    Copy link
    Mannequin Author

    albertogomcas mannequin commented Aug 9, 2017

    Extracted from bpo-31154

    Both calls lack any kind of return, which leads me to expect after a rename/replace the Path instance would be changed to the new path. This is not the case (reading the PEP I have seen Path instances are kind of immutable), after the call the Path instance keeps "pointing" to the previous (and quite likely now useless) path.

    Returning the new path would be a reasonable option. In any case, I think the documentation should mention this behavior explicitly.

    @albertogomcas albertogomcas mannequin assigned docspython Aug 9, 2017
    @albertogomcas albertogomcas mannequin added docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Aug 9, 2017
    @bitdancer
    Copy link
    Member

    I agree. The normal python convention is that an immutable object returns the new value when an operation "changes" it, while a mutable object returns None. It seems like replace and rename should follow this convention (and that it would also be convenient).

    @csabella
    Copy link
    Contributor

    I've closed the original pull request as the Github user account that created it no longer exists.

    @csabella csabella added easy 3.8 (EOL) end of life labels May 21, 2019
    @jaraco
    Copy link
    Member

    jaraco commented Sep 11, 2019

    New changeset 088a09a by Jason R. Coombs (hui shang) in branch 'master':
    bpo-31163: Added return values to pathlib.Path instance's rename and replace methods. (GH-13582)
    088a09a

    @jaraco
    Copy link
    Member

    jaraco commented Sep 11, 2019

    New changeset cbd7b2a by Jason R. Coombs (Miss Islington (bot)) in branch '3.8':
    bpo-31163: Added return values to pathlib.Path instance's rename and replace methods. (GH-13582) (GH-15944)
    cbd7b2a

    @jaraco jaraco added the 3.9 only security fixes label Sep 11, 2019
    @jaraco jaraco closed this as completed Sep 11, 2019
    @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 (EOL) end of life 3.9 only security fixes docs Documentation in the Doc dir easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants