From bd388c1bc59f68612b39d68bea0b32bf76637ba8 Mon Sep 17 00:00:00 2001 From: barneygale Date: Wed, 6 Aug 2025 16:16:10 +0100 Subject: [PATCH 1/2] GH-137466: Remove deprecated and undocumented `glob.glob0()` and `glob1()` --- Doc/whatsnew/3.15.rst | 8 +++++ Lib/glob.py | 15 ---------- Lib/test/test_glob.py | 30 ------------------- ...-08-06-16-13-47.gh-issue-137466.Whv0-A.rst | 3 ++ 4 files changed, 11 insertions(+), 45 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-08-06-16-13-47.gh-issue-137466.Whv0-A.rst diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 54964da473760d..e5914043adf3d9 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -418,6 +418,14 @@ 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. + (Contributed by Barney Gale in :gh:`137466`.) + + http.server ----------- diff --git a/Lib/glob.py b/Lib/glob.py index 1e48fe43167200..5d42077003a240 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -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. diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py index d0ed5129253cdf..36646f33cf510b 100644 --- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -393,36 +393,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')) diff --git a/Misc/NEWS.d/next/Library/2025-08-06-16-13-47.gh-issue-137466.Whv0-A.rst b/Misc/NEWS.d/next/Library/2025-08-06-16-13-47.gh-issue-137466.Whv0-A.rst new file mode 100644 index 00000000000000..918019aa8c03eb --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-08-06-16-13-47.gh-issue-137466.Whv0-A.rst @@ -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. From dbc6e0a12dd06e66ff581368457a493a834baec2 Mon Sep 17 00:00:00 2001 From: barneygale Date: Wed, 6 Aug 2025 16:20:13 +0100 Subject: [PATCH 2/2] Fix lint, expand whatsnew --- Doc/whatsnew/3.15.rst | 3 ++- Lib/test/test_glob.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index e5914043adf3d9..89644a509a0bb4 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -422,7 +422,8 @@ glob ---- * Removed the undocumented :func:`!glob.glob0` and :func:`!glob.glob1` - functions, which have been deprecated since Python 3.13. + 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`.) diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py index 36646f33cf510b..9e4e82b2542c15 100644 --- a/Lib/test/test_glob.py +++ b/Lib/test/test_glob.py @@ -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,