Skip to content

Commit 0def8c7

Browse files
authored
gh-109748: Fix again venv test_zippath_from_non_installed_posix() (#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.
1 parent 74e425e commit 0def8c7

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
@@ -832,7 +832,7 @@ def test_copy_python_src_ignore(self):
832832
self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)),
833833
ignored | {'build', 'venv'})
834834

835-
# An other directory
835+
# Another directory
836836
path = os.path.join(src_dir, 'Objects')
837837
self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)),
838838
ignored)

Lib/test/test_venv.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,11 @@ def test_zippath_from_non_installed_posix(self):
569569
eachpath,
570570
os.path.join(non_installed_dir, platlibdir))
571571
elif os.path.isfile(os.path.join(eachpath, "os.py")):
572-
for name in os.listdir(eachpath):
572+
names = os.listdir(eachpath)
573+
ignored_names = copy_python_src_ignore(eachpath, names)
574+
for name in names:
575+
if name in ignored_names:
576+
continue
573577
if name == "site-packages":
574578
continue
575579
fn = os.path.join(eachpath, name)

0 commit comments

Comments
 (0)