Skip to content

Commit a334057

Browse files
committed
pythongh-109748: Fix again venv test_zippath_from_non_installed_posix() (python#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 0def8c7)
1 parent 4f4c799 commit a334057

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Lib/shutil.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def _copytree(entries, src, dst, symlinks, ignore, copy_function,
481481
if ignore is not None:
482482
ignored_names = ignore(os.fspath(src), [x.name for x in entries])
483483
else:
484-
ignored_names = set()
484+
ignored_names = ()
485485

486486
os.makedirs(dst, exist_ok=dirs_exist_ok)
487487
errors = []

Lib/test/test_support.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ def test_copy_python_src_ignore(self):
797797
self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)),
798798
ignored | {'build', 'venv'})
799799

800-
# An other directory
800+
# Another directory
801801
path = os.path.join(src_dir, 'Objects')
802802
self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)),
803803
ignored)

Lib/test/test_venv.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,11 @@ def test_zippath_from_non_installed_posix(self):
571571
eachpath,
572572
os.path.join(non_installed_dir, platlibdir))
573573
elif os.path.isfile(os.path.join(eachpath, "os.py")):
574-
for name in os.listdir(eachpath):
574+
names = os.listdir(eachpath)
575+
ignored_names = copy_python_src_ignore(eachpath, names)
576+
for name in names:
577+
if name in ignored_names:
578+
continue
575579
if name == "site-packages":
576580
continue
577581
fn = os.path.join(eachpath, name)

0 commit comments

Comments
 (0)