Просмотр исходного кода

chg: Force pickle to use highest protocol

Python2.7 uses protocol 1 by default, which is not compatible with
class defining __slots__. On the other hand, all the Python versions
support versions >= 2.
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
Louis Dubois 4 лет назад
committed by Erez Sh
Родитель
Сommit
c6f2b023f3
3 измененных файлов: 3 добавлений и 5 удалений
  1. +2
    -1
      lark/lark.py
  2. +0
    -3
      tests/test_cache.py
  3. +1
    -1
      tests/test_trees.py

+ 2
- 1
lark/lark.py Просмотреть файл

@@ -336,7 +336,8 @@ class Lark(Serialize):
Useful for caching and multiprocessing.
"""
data, m = self.memo_serialize([TerminalDef, Rule])
pickle.dump({'data': data, 'memo': m}, f)
pickle.dump({'data': data, 'memo': m}, f,
protocol=pickle.HIGHEST_PROTOCOL)

@classmethod
def load(cls, f):


+ 0
- 3
tests/test_cache.py Просмотреть файл

@@ -93,6 +93,3 @@ class TestCache(TestCase):

if __name__ == '__main__':
main()




+ 1
- 1
tests/test_trees.py Просмотреть файл

@@ -20,7 +20,7 @@ class TestTrees(TestCase):

def test_pickle(self):
s = copy.deepcopy(self.tree1)
data = pickle.dumps(s)
data = pickle.dumps(s, protocol=pickle.HIGHEST_PROTOCOL)
assert pickle.loads(data) == s

def test_repr_runnable(self):


Загрузка…
Отмена
Сохранить