| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -813,6 +813,11 @@ Deprecated | |||
| 813 | 813 | translation was not found. | |
| 814 | 814 | (Contributed by Serhiy Storchaka in :gh:`88434`.) | |
| 815 | 815 | ||
| 816 | + * :mod:`glob`: The undocumented :func:`!glob.glob0` and :func:`!glob.glob1` | ||
| 817 | + functions are deprecated. Use :func:`glob.glob` and pass a directory to its | ||
| 818 | + *root_dir* argument instead. | ||
| 819 | + (Contributed by Barney Gale in :gh:`117337`.) | ||
| 820 | + | ||
| 816 | 821 | * :mod:`http.server`: :class:`http.server.CGIHTTPRequestHandler` now emits a | |
| 817 | 822 | :exc:`DeprecationWarning` as it will be removed in 3.15. Process-based CGI | |
| 818 | 823 | HTTP servers have been out of favor for a very long time. This code was | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,12 +119,19 @@ def _glob0(dirname, basename, dir_fd, dironly, include_hidden=False): | |||
| 119 | 119 | return [basename] | |
| 120 | 120 | return [] | |
| 121 | 121 | ||
| 122 | - # Following functions are not public but can be used by third-party code. | ||
| 122 | + _deprecated_function_message = ( | ||
| 123 | + "{name} is deprecated and will be removed in Python {remove}. Use " | ||
| 124 | + "glob.glob and pass a directory to its root_dir argument instead." | ||
| 125 | + ) | ||
| 123 | 126 | ||
| 124 | 127 | def glob0(dirname, pattern): | |
| 128 | + import warnings | ||
| 129 | + warnings._deprecated("glob.glob0", _deprecated_function_message, remove=(3, 15)) | ||
| 125 | 130 | return _glob0(dirname, pattern, None, False) | |
| 126 | 131 | ||
| 127 | 132 | def glob1(dirname, pattern): | |
| 133 | + import warnings | ||
| 134 | + warnings._deprecated("glob.glob1", _deprecated_function_message, remove=(3, 15)) | ||
| 128 | 135 | return _glob1(dirname, pattern, None, False) | |
| 129 | 136 | ||
| 130 | 137 | # This helper function recursively yields relative pathnames inside a literal | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ | |||
| 4 | 4 | import shutil | |
| 5 | 5 | import sys | |
| 6 | 6 | import unittest | |
| 7 | + import warnings | ||
| 7 | 8 | ||
| 8 | 9 | from test.support.os_helper import (TESTFN, skip_unless_symlink, | |
| 9 | 10 | can_symlink, create_empty_file, change_cwd) | |
@@ -382,6 +383,36 @@ def test_glob_many_open_files(self): | |||
| 382 | 383 | for it in iters: | |
| 383 | 384 | self.assertEqual(next(it), p) | |
| 384 | 385 | ||
| 386 | + def test_glob0(self): | ||
| 387 | + with self.assertWarns(DeprecationWarning): | ||
| 388 | + glob.glob0(self.tempdir, 'a') | ||
| 389 | + | ||
| 390 | + with warnings.catch_warnings(): | ||
| 391 | + warnings.simplefilter('ignore') | ||
| 392 | + eq = self.assertSequencesEqual_noorder | ||
| 393 | + eq(glob.glob0(self.tempdir, 'a'), ['a']) | ||
| 394 | + eq(glob.glob0(self.tempdir, '.bb'), ['.bb']) | ||
| 395 | + eq(glob.glob0(self.tempdir, '.b*'), []) | ||
| 396 | + eq(glob.glob0(self.tempdir, 'b'), []) | ||
| 397 | + eq(glob.glob0(self.tempdir, '?'), []) | ||
| 398 | + eq(glob.glob0(self.tempdir, '*a'), []) | ||
| 399 | + eq(glob.glob0(self.tempdir, 'a*'), []) | ||
| 400 | + | ||
| 401 | + def test_glob1(self): | ||
| 402 | + with self.assertWarns(DeprecationWarning): | ||
| 403 | + glob.glob1(self.tempdir, 'a') | ||
| 404 | + | ||
| 405 | + with warnings.catch_warnings(): | ||
| 406 | + warnings.simplefilter('ignore') | ||
| 407 | + eq = self.assertSequencesEqual_noorder | ||
| 408 | + eq(glob.glob1(self.tempdir, 'a'), ['a']) | ||
| 409 | + eq(glob.glob1(self.tempdir, '.bb'), ['.bb']) | ||
| 410 | + eq(glob.glob1(self.tempdir, '.b*'), ['.bb']) | ||
| 411 | + eq(glob.glob1(self.tempdir, 'b'), []) | ||
| 412 | + eq(glob.glob1(self.tempdir, '?'), ['a']) | ||
| 413 | + eq(glob.glob1(self.tempdir, '*a'), ['a', 'aaa']) | ||
| 414 | + eq(glob.glob1(self.tempdir, 'a*'), ['a', 'aaa', 'aab']) | ||
| 415 | + | ||
| 385 | 416 | def test_translate_matching(self): | |
| 386 | 417 | match = re.compile(glob.translate('*')).match | |
| 387 | 418 | self.assertIsNotNone(match('foo')) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + Deprecate undocumented :func:`!glob.glob0` and :func:`!glob.glob1` | ||
| 2 | + functions. Use :func:`glob.glob` and pass a directory to its | ||
| 3 | + *root_dir* argument instead. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments