Skip to content

GH-137466: Remove deprecated and undocumented glob.glob0() and glob1() #137467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,15 @@ ctypes
(Contributed by Bénédikt Tran in :gh:`133866`.)


glob
----

* Removed the undocumented :func:`!glob.glob0` and :func:`!glob.glob1`
functions, which have been deprecated since Python 3.13. Use
:func:`glob.glob` and pass a directory to its *root_dir* argument instead.
(Contributed by Barney Gale in :gh:`137466`.)


http.server
-----------

Expand Down
15 changes: 0 additions & 15 deletions Lib/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,6 @@ def _glob0(dirname, basename, dir_fd, dironly, include_hidden=False):
return [basename]
return []

_deprecated_function_message = (
"{name} is deprecated and will be removed in Python {remove}. Use "
"glob.glob and pass a directory to its root_dir argument instead."
)

def glob0(dirname, pattern):
import warnings
warnings._deprecated("glob.glob0", _deprecated_function_message, remove=(3, 15))
return _glob0(dirname, pattern, None, False)

def glob1(dirname, pattern):
import warnings
warnings._deprecated("glob.glob1", _deprecated_function_message, remove=(3, 15))
return _glob1(dirname, pattern, None, False)

# This helper function recursively yields relative pathnames inside a literal
# directory.

Expand Down
31 changes: 0 additions & 31 deletions Lib/test/test_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import shutil
import sys
import unittest
import warnings

from test.support import is_wasi, Py_DEBUG
from test.support.os_helper import (TESTFN, skip_unless_symlink,
Expand Down Expand Up @@ -393,36 +392,6 @@ def test_glob_many_open_files(self):
for it in iters:
self.assertEqual(next(it), p)

def test_glob0(self):
with self.assertWarns(DeprecationWarning):
glob.glob0(self.tempdir, 'a')

with warnings.catch_warnings():
warnings.simplefilter('ignore')
eq = self.assertSequencesEqual_noorder
eq(glob.glob0(self.tempdir, 'a'), ['a'])
eq(glob.glob0(self.tempdir, '.bb'), ['.bb'])
eq(glob.glob0(self.tempdir, '.b*'), [])
eq(glob.glob0(self.tempdir, 'b'), [])
eq(glob.glob0(self.tempdir, '?'), [])
eq(glob.glob0(self.tempdir, '*a'), [])
eq(glob.glob0(self.tempdir, 'a*'), [])

def test_glob1(self):
with self.assertWarns(DeprecationWarning):
glob.glob1(self.tempdir, 'a')

with warnings.catch_warnings():
warnings.simplefilter('ignore')
eq = self.assertSequencesEqual_noorder
eq(glob.glob1(self.tempdir, 'a'), ['a'])
eq(glob.glob1(self.tempdir, '.bb'), ['.bb'])
eq(glob.glob1(self.tempdir, '.b*'), ['.bb'])
eq(glob.glob1(self.tempdir, 'b'), [])
eq(glob.glob1(self.tempdir, '?'), ['a'])
eq(glob.glob1(self.tempdir, '*a'), ['a', 'aaa'])
eq(glob.glob1(self.tempdir, 'a*'), ['a', 'aaa', 'aab'])

def test_translate_matching(self):
match = re.compile(glob.translate('*')).match
self.assertIsNotNone(match('foo'))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Remove undocumented :func:`!glob.glob0` and :func:`!glob.glob1` functions,
which have been deprecated since Python 3.13. Use :func:`glob.glob` and pass
a directory to its *root_dir* argument instead.
Loading