]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109748: Fix again venv test_zippath_from_non_installed_posix() (#110149)
authorVictor Stinner <vstinner@python.org>
Sat, 30 Sep 2023 18:23:26 +0000 (20:23 +0200)
committerGitHub <noreply@github.com>
Sat, 30 Sep 2023 18:23:26 +0000 (20:23 +0200)
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.

Lib/shutil.py
Lib/test/test_support.py
Lib/test/test_venv.py

index b37bd082eee0c6b55cbb5f00540a6157f342b0bd..b903f13d8b76a754e7c770233544be60e95b9e1c 100644 (file)
@@ -481,7 +481,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 = []
index 902bec784513075d7e8ebc0b9ee5dc3463019dd3..97de81677b10bce852f7301869a7efece5402876 100644 (file)
@@ -832,7 +832,7 @@ class TestSupport(unittest.TestCase):
         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)
index 0ffe3e1d0cc498f47da2e29a87088fbe274c97aa..890672c5d27eec47795f1172ce33341db12334ec 100644 (file)
@@ -569,7 +569,11 @@ class BasicTest(BaseTest):
                         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)