[issue23241] shutil should accept pathlib types

2017-03-27 Thread STINNER Victor

STINNER Victor added the comment:

I'm unable to reproduce the bug on Python 3.6:
---
from pathlib import Path
import shutil
import os
def touch(name):
with open(name, "x"):
pass
os.mkdir('a')
touch('a/x')
touch('a/y')
touch('a/z')
os.mkdir('b')
source_path = Path('a')
destination_path = Path('b')
for file_name in source_path.glob('*'):
file_name = file_name.name
src = source_path / file_name
dst = destination_path / file_name
print("%r -> %r" % (src, dst))
shutil.copyfile(src, dst)
---

Output:
---
PosixPath('a/y') -> PosixPath('b/y')
PosixPath('a/x') -> PosixPath('b/x')
PosixPath('a/z') -> PosixPath('b/z')
---

Thank you PEP 519 ;-)

--
nosy: +haypo
resolution:  -> fixed
stage:  -> resolved
status: pending -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23241] shutil should accept pathlib types

2017-03-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Is this issue outdated since implementing a file system path protocol (PEP 519) 
in 3.6?

--
nosy: +serhiy.storchaka
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23241] shutil should accept pathlib types

2015-01-14 Thread R. David Murray

R. David Murray added the comment:

This is a specific example of a global discussion about handling of paths in 
the stdlib.  So far we have elected not to provide special handling.  The 
correct thing to do is call str.  I'm not sure if shutil is special enough to 
be a special case, but it would need to be discussed in the context of the 
larger issue in some forum other than the bug tracker (probably python-dev).

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23241
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23241] shutil should accept pathlib types

2015-01-14 Thread Michael Kesper

New submission from Michael Kesper:

source_path = Path('../data')
destination_path = Path('//file_server/work/whatever')
for file_name in source_path.glob('xyz-*'):
shutil.copyfile(source_path / file_name, destination_path / file_name)

leads to:

Traceback (most recent call last):
  File copy_shares_2_work.py, line 9, in module
shutil.copyfile(source_path / file_name, destination_path / file_name)
  File C:\Python34\lib\shutil.py, line 90, in copyfile
if _samefile(src, dst):
  File C:\Python34\lib\shutil.py, line 75, in _samefile
return os.path.samefile(src, dst)
  File C:\Python34\lib\genericpath.py, line 90, in samefile
s1 = os.stat(f1)
TypeError: argument should be string, bytes or integer, not WindowsPath

Converting to str() works but is unexpected.

--
messages: 234025
nosy: mkesper
priority: normal
severity: normal
status: open
title: shutil should accept pathlib types
type: behavior
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23241
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com