Skip to content

Commit f0a3c6e

Browse files
authored
GH-137466: Remove deprecated and undocumented glob.glob0() and glob1() (#137467)
1 parent 481d5b5 commit f0a3c6e

File tree

4 files changed

+12
-46
lines changed

4 files changed

+12
-46
lines changed

Doc/whatsnew/3.15.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,15 @@ ctypes
418418
(Contributed by Bénédikt Tran in :gh:`133866`.)
419419

420420

421+
glob
422+
----
423+
424+
* Removed the undocumented :func:`!glob.glob0` and :func:`!glob.glob1`
425+
functions, which have been deprecated since Python 3.13. Use
426+
:func:`glob.glob` and pass a directory to its *root_dir* argument instead.
427+
(Contributed by Barney Gale in :gh:`137466`.)
428+
429+
421430
http.server
422431
-----------
423432

Lib/glob.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,6 @@ def _glob0(dirname, basename, dir_fd, dironly, include_hidden=False):
122122
return [basename]
123123
return []
124124

125-
_deprecated_function_message = (
126-
"{name} is deprecated and will be removed in Python {remove}. Use "
127-
"glob.glob and pass a directory to its root_dir argument instead."
128-
)
129-
130-
def glob0(dirname, pattern):
131-
import warnings
132-
warnings._deprecated("glob.glob0", _deprecated_function_message, remove=(3, 15))
133-
return _glob0(dirname, pattern, None, False)
134-
135-
def glob1(dirname, pattern):
136-
import warnings
137-
warnings._deprecated("glob.glob1", _deprecated_function_message, remove=(3, 15))
138-
return _glob1(dirname, pattern, None, False)
139-
140125
# This helper function recursively yields relative pathnames inside a literal
141126
# directory.
142127

Lib/test/test_glob.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import shutil
55
import sys
66
import unittest
7-
import warnings
87

98
from test.support import is_wasi, Py_DEBUG
109
from test.support.os_helper import (TESTFN, skip_unless_symlink,
@@ -393,36 +392,6 @@ def test_glob_many_open_files(self):
393392
for it in iters:
394393
self.assertEqual(next(it), p)
395394

396-
def test_glob0(self):
397-
with self.assertWarns(DeprecationWarning):
398-
glob.glob0(self.tempdir, 'a')
399-
400-
with warnings.catch_warnings():
401-
warnings.simplefilter('ignore')
402-
eq = self.assertSequencesEqual_noorder
403-
eq(glob.glob0(self.tempdir, 'a'), ['a'])
404-
eq(glob.glob0(self.tempdir, '.bb'), ['.bb'])
405-
eq(glob.glob0(self.tempdir, '.b*'), [])
406-
eq(glob.glob0(self.tempdir, 'b'), [])
407-
eq(glob.glob0(self.tempdir, '?'), [])
408-
eq(glob.glob0(self.tempdir, '*a'), [])
409-
eq(glob.glob0(self.tempdir, 'a*'), [])
410-
411-
def test_glob1(self):
412-
with self.assertWarns(DeprecationWarning):
413-
glob.glob1(self.tempdir, 'a')
414-
415-
with warnings.catch_warnings():
416-
warnings.simplefilter('ignore')
417-
eq = self.assertSequencesEqual_noorder
418-
eq(glob.glob1(self.tempdir, 'a'), ['a'])
419-
eq(glob.glob1(self.tempdir, '.bb'), ['.bb'])
420-
eq(glob.glob1(self.tempdir, '.b*'), ['.bb'])
421-
eq(glob.glob1(self.tempdir, 'b'), [])
422-
eq(glob.glob1(self.tempdir, '?'), ['a'])
423-
eq(glob.glob1(self.tempdir, '*a'), ['a', 'aaa'])
424-
eq(glob.glob1(self.tempdir, 'a*'), ['a', 'aaa', 'aab'])
425-
426395
def test_translate_matching(self):
427396
match = re.compile(glob.translate('*')).match
428397
self.assertIsNotNone(match('foo'))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove undocumented :func:`!glob.glob0` and :func:`!glob.glob1` functions,
2+
which have been deprecated since Python 3.13. Use :func:`glob.glob` and pass
3+
a directory to its *root_dir* argument instead.

0 commit comments

Comments
 (0)