Title: Recursive '**' matches non-existent directories.
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.5
Status: open Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: daniel, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-11-09 16:54 by daniel, last changed 2018-11-12 00:27 by daniel.

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/**

"**" 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.
Date User Action Args
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