classification
Title: pathlib Path.match does not behave as described
Type: Stage: patch review
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: anthony shaw, brett.cannon, xtreak
Priority: normal Keywords: patch

Created on 2018-12-14 06:40 by anthony shaw, last changed 2019-01-06 20:31 by brett.cannon.

Files
File name Uploaded Description Edit
test_pathlib.py anthony shaw, 2018-12-14 06:40
Pull Requests
URL Status Linked Edit
PR 11171 merged anthonypjshaw, 2018-12-14 22:48
Messages (5)
msg331782 - (view) Author: anthony shaw (anthony shaw) Date: 2018-12-14 06:40
The documentation for pathlib PurePath.match(needle) says it accepts "glob-style pattern.".

For an absolute path with a recursive pattern (**) it doesn't match correct for more than 1 directory level.

All of the assertions in the attached file should pass.

The issue I've seen is on the attached file. I'm using Python 3.7.1 and have also tested this against Python 3.6.6 with the pathlib module on PyPi.

Absolute path glob'ing with a recursive pattern works as expected:

entries = pathlib.Path('/var').glob('/var/**/*.log')

Once this issue is confirmed, I would be happy to test & contribute a fix
msg331791 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2018-12-14 09:49
Is this similar to issue29249 (See also msg285311) and issue34731 ? As I can see in Lib/test/test_pathlib.py there are also no tests for "**" and I think it's good to add one along with documenting it.
msg331878 - (view) Author: anthony shaw (anthony shaw) Date: 2018-12-14 22:49
Raised a PR for the test. Will look into doc PR
msg331890 - (view) Author: anthony shaw (anthony shaw) Date: 2018-12-15 09:02
Yes, this is similar to https://bugs.python.org/issue29249
In that issue, it suggests this feature is not supported, but that is neither documented, nor tested.
msg333117 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-01-06 20:31
New changeset 83da926b89daf80013ea966037c2c0e1e9d25c6b by Brett Cannon (Anthony Shaw) in branch 'master':
bpo-35488: Add tests for ** glob matching in pathlib (GH-11171)
https://github.com/python/cpython/commit/83da926b89daf80013ea966037c2c0e1e9d25c6b
History
Date User Action Args
2019-01-06 20:31:31brett.cannonsetmessages: + msg333117
2018-12-17 21:49:59brett.cannonsetnosy: + brett.cannon
2018-12-15 09:02:45anthony shawsetnosy: - serhiy.storchaka
messages: + msg331890
2018-12-15 02:48:49xtreaksetnosy: + serhiy.storchaka
2018-12-14 22:49:13anthony shawsetmessages: + msg331878
2018-12-14 22:48:35anthonypjshawsetkeywords: + patch
stage: patch review
pull_requests: + pull_request10410
2018-12-14 09:49:03xtreaksetmessages: + msg331791
2018-12-14 08:53:01xtreaksetnosy: + xtreak
2018-12-14 06:40:23anthony shawcreate