aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/parso/py2/patches/01-arcadia.patch
blob: 84052adb1a02fc224592c243a5a71bb4627134a2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
--- contrib/python/parso/py3/parso/cache.py	(working tree) 
+++ contrib/python/parso/py3/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/py3/parso/file_io.py	(working tree) 
+++ contrib/python/parso/py3/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/py3/parso/grammar.py	(working tree) 
+++ contrib/python/parso/py3/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/py3/tests/conftest.py	(working tree) 
+++ contrib/python/parso/py3/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/py3/tests/test_cache.py	(working tree) 
+++ contrib/python/parso/py3/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):