GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Deprecate glob.glob0() and glob.glob1() · Issue #117337 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Deprecate glob.glob0() and glob.glob1()#117337
Copy link
Labels
3.13only security fixesonly security fixes

Description

@serhiy-storchaka
serhiy-storchaka
opened on Mar 28, 2024
Issue body actions

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

  • GH-117337: Deprecate glob.glob0() and glob.glob1(). #117371
Reacted by Barney Gale, Gregory P. Smith and carschandler

Activity

  1. serhiy-storchaka
    added
    3.13only security fixesonly security fixes
    on Mar 28, 2024
  2. barneygale commented on Mar 29, 2024

    @barneygale
    barneygale
    on Mar 29, 2024
    Contributor
    More actions

    Two small corrections: the functions return results that are relative to dirname (i.e. they don't include dirname as a prefix), and the return value is a list (so they're more similar to glob() than iglob()).

    >>> glob.glob0('Doc', 'about.rst')
    ['about.rst']
    >>> glob.glob1('Doc', '*.rst')
    ['copyright.rst', 'contents.rst', 'license.rst', 'about.rst', 'bugs.rst', 'README.rst', 'glossary.rst']

    Both functions can be approximated by glob.glob(pattern, root_dir=dirname) I believe, without the need to escape or join dirname.

  3. barneygale
    added 3 commits that reference this issue on Mar 29, 2024

    pythonGH-117337: Deprecated `glob.glob0()` and `glob.glob1()`.

    6b07f91

    Merge branch 'main' into pythongh-117337-deprecate-glob0-glob1

    f9074ff

    GH-117337: Deprecate `glob.glob0()` and `glob.glob1()`. (#117371)

    fc8007e
  4. barneygale
    closed this as completedon Apr 2, 2024
  5. NGRsoftlab
    added 2 commits that reference this issue on Apr 2, 2024

    Squashed commit of the following:

    1b5fe4c

    Squashed commit of the following:

    a016a54
  6. diegorusso
    added a commit that references this issue on Apr 17, 2024

    pythonGH-117337: Deprecate `glob.glob0()` and `glob.glob1()`. (python…

    e64289a
  7. StanFromIreland
    added this to Fnmatch and glob issueson Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixesonly security fixes

    Projects

    • Fnmatch and glob issues
      Status
      No status
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.