Skip to content

Commit 080f5b9

Browse files
[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 0def8c7) Co-authored-by: Victor Stinner <[email protected]>
1 parent cb1f499 commit 080f5b9

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
@@ -454,7 +454,7 @@ def _copytree(entries, src, dst, symlinks, ignore, copy_function,
454454
if ignore is not None:
455455
ignored_names = ignore(os.fspath(src), [x.name for x in entries])
456456
else:
457-
ignored_names = set()
457+
ignored_names = ()
458458

459459
os.makedirs(dst, exist_ok=dirs_exist_ok)
460460
errors = []

Lib/test/test_support.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ def test_copy_python_src_ignore(self):
818818
self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)),
819819
ignored | {'build', 'venv'})
820820

821-
# An other directory
821+
# Another directory
822822
path = os.path.join(src_dir, 'Objects')
823823
self.assertEqual(support.copy_python_src_ignore(path, os.listdir(path)),
824824
ignored)

Lib/test/test_venv.py

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

0 commit comments

Comments
 (0)