Skip to content

Commit f919462

Browse files
committed
Load the copied library in the deleted-mapping test
1 parent 22d79d9 commit f919462

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎Lib/test/test_sys.py‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,16 +2365,20 @@ def test_remote_exec_deleted_libpython(self):
23652365
if not os.path.exists(source_libpython):
23662366
self.skipTest(f'{source_libpython!r} does not exist')
23672367

2368-
with os_helper.temp_dir() as lib_dir:
2369-
copied_libpython = os.path.join(lib_dir, instsoname)
2368+
with os_helper.temp_dir(os_helper.TESTFN) as lib_dir:
2369+
copied_libpython = os.path.abspath(
2370+
os.path.join(lib_dir, instsoname))
23702371
shutil.copy2(source_libpython, copied_libpython)
23712372
if ldlibrary != instsoname:
23722373
os.symlink(instsoname, os.path.join(lib_dir, ldlibrary))
23732374

23742375
env = os.environ.copy()
2375-
ld_library_path = env.get('LD_LIBRARY_PATH')
2376-
env['LD_LIBRARY_PATH'] = lib_dir if not ld_library_path else (
2377-
lib_dir + os.pathsep + ld_library_path)
2376+
# Preload the copy even when `RPATH` overrides `LD_LIBRARY_PATH`.
2377+
# Use a relative path to avoid spaces or colons in parent directories.
2378+
preload = os.path.join(os.curdir, lib_dir, instsoname)
2379+
ld_preload = env.get('LD_PRELOAD')
2380+
env['LD_PRELOAD'] = preload if not ld_preload else (
2381+
preload + os.pathsep + ld_preload)
23782382

23792383
self._run_remote_exec_with_deleted_mapping(copied_libpython,
23802384
env=env)

0 commit comments

Comments
 (0)