Commit d5afef8e authored by Kirill Smelkov's avatar Kirill Smelkov

Fix breakage with zodbpickle >= 2

Starting from zodbpickle 2 its binary class does not allow users to set
arbitrary attributes and so

	binary._pack = bytes.__str__

fails with

	TypeError: can't set attributes of built-in/extension type 'zodbpickle.binary'

-> Fix it by explicitly checking for binary type on encoding instead of
setting binary._pack

See nexedi/slapos@27f574bc for pre-history.

/cc @jerome
parent 7f81ac2d
......@@ -13,13 +13,6 @@
##############################################################################
def patch():
# For msgpack & Py2/ZODB5.
try:
from zodbpickle import binary
binary._pack = bytes.__str__
except ImportError:
pass
from hashlib import md5
from ZODB.Connection import Connection
......
......@@ -18,6 +18,12 @@ import threading
from functools import partial
from msgpack import packb
# For msgpack & Py2/ZODB5.
try:
from zodbpickle import binary
except ImportError:
class binary: pass # stub, binary should not be used
# The protocol version must be increased whenever upgrading a node may require
# to upgrade other nodes.
PROTOCOL_VERSION = 2
......@@ -52,6 +58,8 @@ def Unpacker():
iterable_types = set, tuple
def default(obj):
if isinstance(obj, binary):
return obj.__str__()
try:
pack = obj._pack
except AttributeError:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment