New submission from Brandt Bucher <>:

This has been discussed before, but we now have examples in the news of glob's 
non-deterministic behavior causing some real headaches for hundreds of people 
in the scientific community. After some cursory discussion 
 it was suggested that this issue would at least be worth revisiting, given the 
damage... bad programming practices aside.

The attached patch guarantees glob/iglob traversal order across all platforms, 
and modifies all of the existing tests to check for this.

One reason this was rejected twice before (in both issue 21748, four years ago, 
and issue 30461, two years ago) was the argument that the user could always 
just call "sorted" on the returned list if they wanted ordered results. Aside 
from losing the laziness of iglob, this solution also loses the traversal 
order, since recursive globs use a breadth-first search. In the attached patch, 
iglob is still just as lazy as ever, and the traversal is unchanged for anyone 
using a platform that already returns sorted results.

components: Library (Lib)
messages: 356344
nosy: brandtbucher, njs
priority: normal
severity: normal
status: open
title: Deterministic globbing.
type: enhancement
versions: Python 3.9

Python tracker <>
Python-bugs-list mailing list

Reply via email to