mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix pickle_binary_string
Also change the conversion tests to use binary strings
This commit is contained in:
parent
9adc3b0ffb
commit
79037fcbf1
@ -444,7 +444,7 @@ class WritingTest(BaseTest):
|
||||
all_ids = cache.all_book_ids()
|
||||
self.assertFalse(cache.has_conversion_options(all_ids))
|
||||
self.assertIsNone(cache.conversion_options(1))
|
||||
op1, op2 = {'xx':'yy'}, {'yy':'zz'}
|
||||
op1, op2 = b"{'xx':'yy'}", b"{'yy':'zz'}"
|
||||
cache.set_conversion_options({1:op1, 2:op2})
|
||||
self.assertTrue(cache.has_conversion_options(all_ids))
|
||||
self.assertEqual(cache.conversion_options(1), op1)
|
||||
|
@ -47,6 +47,6 @@ def unpickle_binary_string(data):
|
||||
def pickle_binary_string(data):
|
||||
# Maintains compatibility with python's pickle module protocol version 2
|
||||
import struct
|
||||
from pickle import PROTO, BINSTRING
|
||||
from pickle import PROTO, BINSTRING, STOP
|
||||
data = bytes(data)
|
||||
return PROTO + b'\x1b' + BINSTRING + struct.pack(b'<i', len(data)) + data
|
||||
return PROTO + b'\x02' + BINSTRING + struct.pack(b'<i', len(data)) + data + STOP
|
||||
|
Loading…
x
Reference in New Issue
Block a user