@@ -542,6 +542,41 @@ def test_venv_symlink_to_separate_exec_prefix_posix(self):
542542 actual = getpath (ns , expected )
543543 self .assertEqual (expected , actual )
544544
545+ def test_venv_separate_exec_prefix_with_misleading_home_posix (self ):
546+ "Test that a stale lib-dynload near home does not override the base executable."
547+ ns = MockPosixNamespace (
548+ argv0 = "/venv/bin/python" ,
549+ PREFIX = "/stdlib" ,
550+ EXEC_PREFIX = "/build/exec" ,
551+ )
552+ ns .add_known_xfile ("/exec/bin/python" )
553+ ns .add_known_xfile ("/public/bin/python" )
554+ ns .add_known_link ("/public/bin/python" , "/exec/bin/python" )
555+ ns .add_known_xfile ("/venv/bin/python" )
556+ ns .add_known_link ("/venv/bin/python" , "/public/bin/python" )
557+ ns .add_known_file ("/stdlib/lib/python9.8/os.py" )
558+ ns .add_known_dir ("/exec/lib/python9.8/lib-dynload" )
559+ # An empty directory near the symlink must not win.
560+ ns .add_known_dir ("/public/lib/python9.8/lib-dynload" )
561+ ns .add_known_file ("/venv/pyvenv.cfg" , [
562+ "home = /public/bin" ,
563+ ])
564+ expected = dict (
565+ executable = "/venv/bin/python" ,
566+ prefix = "/venv" ,
567+ exec_prefix = "/venv" ,
568+ base_executable = "/exec/bin/python" ,
569+ base_prefix = "/stdlib" ,
570+ base_exec_prefix = "/exec" ,
571+ module_search_paths_set = 1 ,
572+ module_search_paths = [
573+ "/stdlib/lib/python98.zip" ,
574+ "/stdlib/lib/python9.8" ,
575+ "/exec/lib/python9.8/lib-dynload" ,
576+ ],
577+ )
578+ actual = getpath (ns , expected )
579+ self .assertEqual (expected , actual )
545580 def test_venv_non_installed_zip_path_posix (self ):
546581 "Test a venv created from non-installed python has correct zip path." ""
547582 ns = MockPosixNamespace (
0 commit comments