summaryrefslogtreecommitdiffstats
path: root/contrib/python/parso/py3
diff options
context:
space:
mode:
authormaxim-yurchuk <[email protected]>2024-10-09 12:29:46 +0300
committermaxim-yurchuk <[email protected]>2024-10-09 13:14:22 +0300
commit9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch)
treea8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/parso/py3
parenta44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff)
publishFullContrib: true for ydb
<HIDDEN_URL> commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/parso/py3')
-rw-r--r--contrib/python/parso/py3/.yandex_meta/yamaker.yaml2
-rw-r--r--contrib/python/parso/py3/patches/01-arcadia.patch111
-rw-r--r--contrib/python/parso/py3/patches/02-disable-tests-for-python-3.10.patch11
3 files changed, 124 insertions, 0 deletions
diff --git a/contrib/python/parso/py3/.yandex_meta/yamaker.yaml b/contrib/python/parso/py3/.yandex_meta/yamaker.yaml
new file mode 100644
index 00000000000..da1aff39684
--- /dev/null
+++ b/contrib/python/parso/py3/.yandex_meta/yamaker.yaml
@@ -0,0 +1,2 @@
+disable_dos_to_unix:
+ - tests/normalizer_issue_files/utf-8-bom.py
diff --git a/contrib/python/parso/py3/patches/01-arcadia.patch b/contrib/python/parso/py3/patches/01-arcadia.patch
new file mode 100644
index 00000000000..adabd429a1e
--- /dev/null
+++ b/contrib/python/parso/py3/patches/01-arcadia.patch
@@ -0,0 +1,111 @@
+--- contrib/python/parso/py3/parso/cache.py (index)
++++ contrib/python/parso/py3/parso/cache.py (working tree)
+@@ -135,6 +135,8 @@ def load_module(hashed_grammar, file_io, cache_path=None):
+ def _load_from_file_system(hashed_grammar, path, p_time, cache_path=None):
+ cache_path = _get_hashed_path(hashed_grammar, path, cache_path=cache_path)
+ try:
++ # SUBBOTNIK-2721 - Для безопасности отключаем загрузку с диска
++ raise FileNotFoundError
+ if p_time > os.path.getmtime(cache_path):
+ # Cache is outdated
+ return None
+--- contrib/python/parso/py3/parso/file_io.py (index)
++++ contrib/python/parso/py3/parso/file_io.py (working tree)
+@@ -2,6 +2,8 @@ import os
+ from pathlib import Path
+ from typing import Union
+
++import __res as res
++
+
+ class FileIO:
+ def __init__(self, path: Union[os.PathLike, str]):
+@@ -13,6 +15,9 @@ class FileIO:
+ # We would like to read unicode here, but we cannot, because we are not
+ # sure if it is a valid unicode file. Therefore just read whatever is
+ # here.
++ data = res.resfs_read(self.path)
++ if data:
++ return data
+ with open(self.path, 'rb') as f:
+ return f.read()
+
+--- contrib/python/parso/py3/parso/grammar.py (index)
++++ contrib/python/parso/py3/parso/grammar.py (working tree)
+@@ -1,5 +1,6 @@
+ import hashlib
+ import os
++import pkgutil
+ from typing import Generic, TypeVar, Union, Dict, Optional, Any
+ from pathlib import Path
+
+@@ -252,12 +253,13 @@ def load_grammar(*, version: str = None, path: str = None):
+ return _loaded_grammars[path]
+ except KeyError:
+ try:
+- with open(path) as f:
+- bnf_text = f.read()
++ bnf_text = pkgutil.get_data("parso", file).decode("utf-8")
++ if bnf_text is None:
++ raise FileNotFoundError
+
+ grammar = PythonGrammar(version_info, bnf_text)
+ return _loaded_grammars.setdefault(path, grammar)
+- except FileNotFoundError:
++ except (FileNotFoundError, IOError):
+ message = "Python version %s.%s is currently not supported." % (
+ version_info.major, version_info.minor
+ )
+--- contrib/python/parso/py3/tests/conftest.py (index)
++++ contrib/python/parso/py3/tests/conftest.py (working tree)
+@@ -6,6 +6,7 @@ import os
+ from pathlib import Path
+
+ import pytest
++import yatest.common
+
+ import parso
+ from parso import cache
+@@ -42,7 +43,7 @@ def pytest_addoption(parser):
+
+ def pytest_generate_tests(metafunc):
+ if 'normalizer_issue_case' in metafunc.fixturenames:
+- base_dir = os.path.join(os.path.dirname(__file__), 'test', 'normalizer_issue_files')
++ base_dir = os.path.join(yatest.common.test_source_path(), 'normalizer_issue_files')
+
+ cases = list(colllect_normalizer_tests(base_dir))
+ metafunc.parametrize(
+--- contrib/python/parso/py3/tests/test_cache.py (index)
++++ contrib/python/parso/py3/tests/test_cache.py (working tree)
+@@ -34,6 +34,7 @@ def isolated_parso_cache(monkeypatch, tmpdir):
+ return cache_path
+
+
[email protected]("SUBBOTNIK-2721 Disable load cache from disk")
+ def test_modulepickling_change_cache_dir(tmpdir):
+ """
+ ParserPickling should not save old cache when cache_directory is changed.
+@@ -99,6 +100,7 @@ def test_modulepickling_simulate_deleted_cache(tmpdir):
+ assert cached2 is None
+
+
+ def test_cache_limit():
+ def cache_size():
+ return sum(len(v) for v in parser_cache.values())
+@@ -129,6 +131,7 @@ class _FixedTimeFileIO(file_io.KnownContentFileIO):
+ return self._last_modified
+
+
+ @pytest.mark.parametrize('diff_cache', [False, True])
+ @pytest.mark.parametrize('use_file_io', [False, True])
+ def test_cache_last_used_update(diff_cache, use_file_io):
+@@ -175,6 +178,7 @@ def test_inactive_cache(tmpdir, isolated_parso_cache):
+ assert not old_paths.intersection(os.listdir(raw_cache_path))
+
+
+ @skip_pypy
+ def test_permission_error(monkeypatch):
+ def save(*args, **kwargs):
diff --git a/contrib/python/parso/py3/patches/02-disable-tests-for-python-3.10.patch b/contrib/python/parso/py3/patches/02-disable-tests-for-python-3.10.patch
new file mode 100644
index 00000000000..27ea99772d4
--- /dev/null
+++ b/contrib/python/parso/py3/patches/02-disable-tests-for-python-3.10.patch
@@ -0,0 +1,11 @@
+--- contrib/python/parso/py3/tests/test_python_errors.py (index)
++++ contrib/python/parso/py3/tests/test_python_errors.py (working tree)
+@@ -28,7 +28,7 @@ def assert_comparison(code, error_code, positions):
+ errors = [(error.start_pos, error.code) for error in _get_error_list(code)]
+ assert [(pos, error_code) for pos in positions] == errors
+
+-
[email protected](sys.version_info >= (3, 10), reason="parso don't support Python 3.10 yet")
+ @pytest.mark.parametrize('code', FAILING_EXAMPLES)
+ def test_python_exception_matches(code):
+ wanted, line_nr = _get_actual_exception(code)