Issue 31163: Return destination path in Path.rename and Path.replace (original) (raw)

Issue31163

Created on 2017-08-09 15:32 by albertogomcas, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4055 closed keichiri,2017-10-20 00:27
PR 13582 merged shangdahao,2019-05-26 08:55
PR 15944 merged miss-islington,2019-09-11 13:27
Messages (5)
msg300019 - (view) Author: Alberto Gomez Casado (albertogomcas) Date: 2017-08-09 15:32
Extracted from 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.
msg300027 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-08-09 18:14
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).
msg342970 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-05-21 01:16
I've closed the original pull request as the Github user account that created it no longer exists.
msg351865 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2019-09-11 13:26
New changeset 088a09af4bdeff52b9dedeb7acd1e82069f37d98 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) https://github.com/python/cpython/commit/088a09af4bdeff52b9dedeb7acd1e82069f37d98
msg351892 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2019-09-11 14:12
New changeset cbd7b2a399a8ff2ed9994c380b07ef598892b6b1 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) https://github.com/python/cpython/commit/cbd7b2a399a8ff2ed9994c380b07ef598892b6b1
History
Date User Action Args
2022-04-11 14:58:49 admin set github: 75346
2019-09-11 14:23:08 jaraco set status: open -> closedstage: patch review -> resolvedresolution: fixedversions: + Python 3.9
2019-09-11 14:12:56 jaraco set messages: +
2019-09-11 13:27:02 miss-islington set pull_requests: + <pull%5Frequest15578>
2019-09-11 13:26:52 jaraco set nosy: + jaracomessages: +
2019-05-26 08:55:00 shangdahao set keywords: + patchstage: needs patch -> patch reviewpull_requests: + <pull%5Frequest13489>
2019-05-21 01:16:02 cheryl.sabella set versions: + Python 3.8, - Python 3.6nosy: + berker.peksag, cheryl.sabellamessages: + keywords: + easy, - patchstage: patch review -> needs patch
2017-10-20 00:27:58 keichiri set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest4024>
2017-08-09 18:14:33 r.david.murray set nosy: + r.david.murraymessages: +
2017-08-09 15:32:24 albertogomcas create