123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- --- contrib/python/parso/py2/parso/cache.py (working tree)
- +++ contrib/python/parso/py2/parso/cache.py (index)
- @@ -142,6 +142,8 @@
- 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
- try:
- if p_time > os.path.getmtime(cache_path):
- # Cache is outdated
- --- contrib/python/parso/py2/parso/file_io.py (working tree)
- +++ contrib/python/parso/py2/parso/file_io.py (index)
- @@ -1,6 +1,8 @@
- import os
- from parso._compatibility import FileNotFoundError
-
- +import __res as res
- +
-
- class FileIO(object):
- def __init__(self, path):
- @@ -10,6 +12,9 @@
- # 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/py2/parso/grammar.py (working tree)
- +++ contrib/python/parso/py2/parso/grammar.py (index)
- @@ -1,5 +1,7 @@
- import hashlib
- import os
- +import sys
- +import pkgutil
-
- from parso._compatibility import FileNotFoundError, is_pypy
- from parso.pgen2 import generate_grammar
- @@ -246,12 +248,15 @@
- return _loaded_grammars[path]
- except KeyError:
- try:
- + bnf_text = pkgutil.get_data("parso", file)
- + if bnf_text is None:
- + raise FileNotFoundError
- + if sys.version_info[0] == 3:
- + bnf_text = bnf_text.decode("ascii")
- - with open(path) as f:
- - bnf_text = f.read()
-
- grammar = PythonGrammar(version_info, bnf_text)
- return _loaded_grammars.setdefault(path, grammar)
- + except (FileNotFoundError, IOError):
- - except FileNotFoundError:
- message = "Python version %s.%s is currently not supported." % (version_info.major, version_info.minor)
- raise NotImplementedError(message)
- else:
- --- contrib/python/parso/py2/tests/conftest.py (working tree)
- +++ contrib/python/parso/py2/tests/conftest.py (index)
- @@ -6,6 +6,7 @@
- import os
-
- import pytest
- +import yatest.common
-
- import parso
- from parso import cache
- @@ -43,7 +44,7 @@
-
- def pytest_generate_tests(metafunc):
- if 'normalizer_issue_case' in metafunc.fixturenames:
- + base_dir = os.path.join(yatest.common.test_source_path(), 'normalizer_issue_files')
- - base_dir = os.path.join(os.path.dirname(__file__), 'test', 'normalizer_issue_files')
-
- cases = list(colllect_normalizer_tests(base_dir))
- metafunc.parametrize(
- --- contrib/python/parso/py2/tests/test_cache.py (working tree)
- +++ contrib/python/parso/py2/tests/test_cache.py (index)
- @@ -36,6 +36,7 @@
- return cache_path
-
-
- +@pytest.mark.skip("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.
- @@ -101,6 +102,7 @@
- assert cached2 is None
-
-
- +@pytest.mark.skip
- def test_cache_limit():
- def cache_size():
- return sum(len(v) for v in parser_cache.values())
- @@ -131,6 +133,7 @@
- return self._last_modified
-
-
- +@pytest.mark.skip
- @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):
- @@ -177,6 +180,7 @@
- assert not old_paths.intersection(os.listdir(raw_cache_path))
-
-
- +@pytest.mark.skip
- @skip_pypy
- def test_permission_error(monkeypatch):
- def save(*args, **kwargs):
|