소스 검색

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 년 전
부모
커밋
d41e3cdfb9
No known key found for this signature in database GPG 키 ID: 4D3FE66DA9BBE2EE
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):


불러오는 중...
취소
저장