[3.11] gh-109748: Fix again venv test_zippath_from_non_installed_posix() (GH-110149) (#110153)
https://github.com/python/cpython/commit/080f5b98d1eac67abc13fe9654ff8a3feee... commit: 080f5b98d1eac67abc13fe9654ff8a3feeef55ea branch: 3.11 author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> committer: vstinner <vstinner@python.org> date: 2023-09-30T18:46:37Z summary: [3.11] gh-109748: Fix again venv test_zippath_from_non_installed_posix() (GH-110149) (#110153) gh-109748: Fix again venv test_zippath_from_non_installed_posix() (GH-110149) Call also copy_python_src_ignore() on listdir() names. shutil.copytree(): replace set() with an empty tuple. An empty tuple becomes a constant in the compiler and checking if an item is in an empty tuple is cheap. (cherry picked from commit 0def8c712bb6f66f1081cab71deb3681566b846d) Co-authored-by: Victor Stinner <vstinner@python.org> files: M Lib/shutil.py M Lib/test/test_support.py M Lib/test/test_venv.py diff --git a/Lib/shutil.py b/Lib/shutil.py index 1c3a75da55ba5..d108986d13026 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -454,7 +454,7 @@ def _copytree(entries, src, dst, symlinks, ignore, copy_function, if ignore is not None: ignored_names = ignore(os.fspath(src), [x.name for x in entries]) else: - ignored_names = set() + ignored_names = () os.makedirs(dst, exist_ok=dirs_exist_ok) errors = [] diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 2efdbd22d90e2..01ba88ce42c5f 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -818,7 +818,7 @@ def test_copy_python_src_ignore(self): self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)), ignored | {'build', 'venv'}) - # An other directory + # Another directory path = os.path.join(src_dir, 'Objects') self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)), ignored) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 884ac3ac567c0..eb9227a3b7037 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -572,7 +572,11 @@ def test_zippath_from_non_installed_posix(self): eachpath, os.path.join(non_installed_dir, platlibdir)) elif os.path.isfile(os.path.join(eachpath, "os.py")): - for name in os.listdir(eachpath): + names = os.listdir(eachpath) + ignored_names = copy_python_src_ignore(eachpath, names) + for name in names: + if name in ignored_names: + continue if name == "site-packages": continue fn = os.path.join(eachpath, name)
participants (1)
-
vstinner