[New-bugs-announce] [issue35453] pathlib.Path: glob and rglob should accept PathLike patterns

Cristian Ciupitu report at bugs.python.org
Mon Dec 10 05:54:42 EST 2018


New submission from Cristian Ciupitu <cristian.ciupitu at yahoo.com>:

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 <report at bugs.python.org>
<https://bugs.python.org/issue35453>
_______________________________________


More information about the New-bugs-announce mailing list