This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Shutil module functions could accept Path-like objects
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.4, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: josh.r, rougeth
Priority: normal Keywords:

Created on 2018-03-05 22:39 by rougeth, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg313295 - (view) Author: Marco Rougeth (rougeth) * Date: 2018-03-05 22:39
This is issue is to suggest an enhancement to the shutil module, I believe it's quiet similar to the issue32642.

I was using shutil.copytree to copy some files around and I tried to pass Path-like objects as input but got the exception "TypeError: argument should be string, bytes or integer, not PosixPath".

e.g.
build_path = BASE_DIR / 'build'
static_path = BASE_DIR / 'static'
shutil.copytree(static_path, build_path)


As said in issue32642, it "wasn't obvious because Path objects appear as strings in normal debug output". I had a look at the shutil source code and it seems that it wouldn't be to hard to implement. I'd love to do it, if it makes sense.
msg313300 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2018-03-06 00:35
I think this falls under the umbrella of #30235, which posits that Path-like objects should be supported by shutil (and includes notes on doc validation).
msg313304 - (view) Author: Marco Rougeth (rougeth) * Date: 2018-03-06 03:26
You're right @josh.r! Thank you!
History
Date User Action Args
2022-04-11 14:58:58adminsetgithub: 77185
2018-03-06 03:26:10rougethsetstatus: open -> closed
resolution: duplicate
messages: + msg313304

stage: resolved
2018-03-06 00:35:29josh.rsetnosy: + josh.r
messages: + msg313300
2018-03-05 22:39:41rougethcreate