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: Recursive '**' matches non-existent directories.
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: daniel, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-11-09 16:54 by daniel, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg329537 - (view) Author: Daniel Israel (daniel) Date: 2018-11-09 16:54
In the following case, when there is no file or directory 'a', glob will still return it:

>>> glob.glob("a/**", recursive=True)
[ 'a/' ]

Note that this is inconsistent with the '*' pattern:

>>> glob.glob("a/*", recursive=True)
[]
msg329539 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-11-09 17:25
This is expected behavior, and it matches the behavior of Bash.

$ mkdir empty
$ shopt -s globstar failglob
$ echo empty/*
bash: no match: empty/*
$ echo empty/**
empty/

"**" matches zero or more path components. In this case case it matches zero.
msg329703 - (view) Author: Daniel Israel (daniel) Date: 2018-11-12 00:27
In the Bash example, you created the directory empty/.  This bug is specifically when the directory in question does not exist.
History
Date User Action Args
2022-04-11 14:59:08adminsetgithub: 79382
2021-12-01 22:35:42iritkatrielsetresolution: not a bug ->
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.5, Python 3.6, Python 3.7, Python 3.8
2018-11-12 00:27:30danielsetmessages: + msg329703
2018-11-10 01:38:27Windson Yangsetversions: + Python 3.5, Python 3.7, Python 3.8
2018-11-09 17:25:08serhiy.storchakasetresolution: not a bug

messages: + msg329539
nosy: + serhiy.storchaka
2018-11-09 16:54:51danielcreate