From c616b6639fc99067edbe32b7b6c8d34bacecf114 Mon Sep 17 00:00:00 2001 From: prettyboy Date: Wed, 19 Mar 2025 10:41:02 +0300 Subject: [library/python/runtime_py3/importer.pxi] Support trailing newline in root.path files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Для того чтобы работал сценарий ``` echo `arc root` > /tmp/.root.path ``` commit_hash:255b16f66c1a610cea5322a3842edc492634faaf --- library/python/runtime_py3/importer.pxi | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'library/python/runtime_py3') diff --git a/library/python/runtime_py3/importer.pxi b/library/python/runtime_py3/importer.pxi index d449bc9bddc..51bc3020a3f 100644 --- a/library/python/runtime_py3/importer.pxi +++ b/library/python/runtime_py3/importer.pxi @@ -91,10 +91,13 @@ def _init_venv(): raise RuntimeError(f'{cfg_source_root} key not found in {virtual_conf}') -def file_bytes(path): +def file_bytes(path, strip=False): # 'open' is not avaiable yet. with FileIO(path, 'r') as f: - return f.read() + data = f.read() + if strip: + return data.strip() + return data def _guess_source_root(): @@ -103,7 +106,7 @@ def _guess_source_root(): while tail: guidence_file = _path_join(path, '.root.path') if _path_isfile(guidence_file): - return file_bytes(guidence_file) + return file_bytes(guidence_file, strip=True) if _path_isfile(_path_join(path, '.arcadia.root')): return _b(path) -- cgit v1.3