[issue35453] pathlib.Path: glob and rglob should accept PathLike patterns

2018-12-10 Thread Cristian Ciupitu


Cristian Ciupitu  added the comment:

Err, I meant os.path.join instead of os.path.combine.

--

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



[issue35453] pathlib.Path: glob and rglob should accept PathLike patterns

2018-12-10 Thread Cristian Ciupitu


Cristian Ciupitu  added the comment:

What if the pattern has some directories in it, e.g. "SourceArt/**/*.png", how 
do you compose it? The traditional way is to either hardcode the separator 
(e.g. / or \) or use os.path.combine. I don't see why PurePath can't be used 
for this, e.g. PurePath('SourceArt')/"**'/'*.png'.

--

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



[issue35453] pathlib.Path: glob and rglob should accept PathLike patterns

2018-12-10 Thread Cristian Ciupitu


New submission from Cristian Ciupitu :

pathlib.Path.glob and pathlib.Path.rglob don't work with os.PathLike patterns.

Short example:

from pathlib import Path, PurePath
# fails
tuple(Path('/etc').glob(PurePath('passwd')))# TypeError
tuple(Path('/etc').rglob(PurePath('passwd')))   # TypeError
tuple(Path('C:\\').glob(PurePath('Windows')))   # AttributeError
tuple(Path('C:\\').rglob(PurePath('Windows')))  # AttributeError
# works
from os import fspath
tuple(Path('/etc').glob(fspath(PurePath('passwd'
tuple(Path('/etc').rglob(fspath(PurePath('passwd'
tuple(Path('C:\\').glob(fspath(PurePath('Windows'
tuple(Path('C:\\').rglob(fspath(PurePath('Windows'

--
components: Library (Lib)
messages: 331491
nosy: ciupicri
priority: normal
severity: normal
status: open
title: pathlib.Path: glob and rglob should accept PathLike patterns
versions: Python 3.7

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