Skip to content

Deprecate glob.glob0() and glob.glob1() #117337

Closed
@serhiy-storchaka

Description

@serhiy-storchaka

Undocumented functions glob0() and glob1() were just helpers for glob.iglob(). They are not underscored because the glob module has __all__. They survived numerous refactorings only because they were used in the msilib module and some MSI related scripts. But the msilib module and these scripts have been removed.

glob1(root_dir, pattern) is equivalent to iglob1(os.path.join(glob.escape(root_dir), pattern)), but more restricted and slightly faster, because it does not need to escape root_dir and process the result.

Other alternative is iglob(pattern, root_dir=root_dir), which can even be faster, but it emits paths relative to root_dir. You can use (os.path.join(root_dir, p) for p in iglob(pattern, root_dir=root_dir)) if you need to append root_dir. Actually, creating an efficient replacement of glob1() was one of purposes of root_dir.

glob0(root_dir, name) just checks that os.path.join(root_dir, name) exists. I did not see its use in third-party code.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions