From 6935f6b4cce51ac2677a3084ff46a862c250c7d4 Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Sun, 1 Apr 2018 01:16:51 +0200 Subject: [PATCH 1/2] fix versioning for py3 --- Products/CMFEditions/ArchivistTool.py | 6 +++--- Products/CMFEditions/ZVCStorageTool.py | 10 +++++----- Products/CMFEditions/tests/DummyTools.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Products/CMFEditions/ArchivistTool.py b/Products/CMFEditions/ArchivistTool.py index fa16050b..1771152d 100644 --- a/Products/CMFEditions/ArchivistTool.py +++ b/Products/CMFEditions/ArchivistTool.py @@ -54,7 +54,7 @@ from Products.CMFEditions.utilities import dereference from Products.CMFEditions.utilities import KwAsAttributes -from six import StringIO +from six import BytesIO from six.moves.cPickle import Pickler from six.moves.cPickle import Unpickler from zope.interface import alsoProvides @@ -70,7 +70,7 @@ def deepcopy(obj): """Makes a deep copy of the object using the pickle mechanism. """ - stream = StringIO() + stream = BytesIO() p = Pickler(stream, 1) p.dump(aq_base(obj)) stream.seek(0) @@ -219,7 +219,7 @@ def _cloneByPickle(self, obj): else: inside_orefs, outside_orefs = (), () - stream = StringIO() + stream = BytesIO() p = Pickler(stream, 1) if callbacks is not None: p.persistent_id = pers_id diff --git a/Products/CMFEditions/ZVCStorageTool.py b/Products/CMFEditions/ZVCStorageTool.py index 74ae4118..47fcaa79 100644 --- a/Products/CMFEditions/ZVCStorageTool.py +++ b/Products/CMFEditions/ZVCStorageTool.py @@ -54,7 +54,7 @@ from Products.ZopeVersionControl.Utility import VersionControlError from Products.ZopeVersionControl.ZopeRepository import ZopeRepository -from six import StringIO +from six import BytesIO from six.moves.cPickle import dumps from six.moves.cPickle import HIGHEST_PROTOCOL from six.moves.cPickle import loads @@ -70,7 +70,7 @@ logger = logging.getLogger('CMFEditions') def deepCopy(obj): - stream = StringIO() + stream = BytesIO() p = Pickler(stream, 1) p.dump(obj) stream.seek(0) @@ -120,7 +120,7 @@ def getSize(obj): try: # fallback: pickling the object - stream = StringIO() + stream = BytesIO() p = Pickler(stream, 1) p.dump(obj) size = stream.tell() @@ -521,11 +521,11 @@ def _encodeMetadata(self, metadata): comment = dumps(comment) except KeyError: comment = '' - return '\x00\n'.join((comment, dumps(metadata, HIGHEST_PROTOCOL))) + return b'\x00\n'.join((comment, dumps(metadata, HIGHEST_PROTOCOL))) def _retrieveMetadataFromZVC(self, zvc_histid, zvc_selector): logEntry = self._retrieveZVCLogEntry(zvc_histid, zvc_selector) - metadata = loads(logEntry.message.split('\x00\n', 1)[1]) + metadata = loads(logEntry.message.split(b'\x00\n', 1)[1]) return metadata diff --git a/Products/CMFEditions/tests/DummyTools.py b/Products/CMFEditions/tests/DummyTools.py index 6737a14e..1652d63b 100644 --- a/Products/CMFEditions/tests/DummyTools.py +++ b/Products/CMFEditions/tests/DummyTools.py @@ -19,7 +19,7 @@ from Products.CMFEditions.interfaces.IStorage import IStreamableReference from Products.CMFEditions.utilities import dereference -from six import StringIO +from six import BytesIO from six.moves.cPickle import Pickler from six.moves.cPickle import Unpickler from zope.interface import implementer @@ -52,7 +52,7 @@ def getId(self): return self.id def deepCopy(obj): - stream = StringIO() + stream = BytesIO() p = Pickler(stream, 1) p.dump(obj) stream.seek(0) From 5fa0d0816c9725e06c430138f4627660c25d6233 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Tue, 3 Apr 2018 23:23:25 +0200 Subject: [PATCH 2/2] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index e73c62f3..0d5f0375 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,7 +17,7 @@ New features: Bug fixes: - Make imports Python 3 compatible - [ale-rt] + [ale-rt, pbauer] - Don't depend on ZODB version 3 directly [tomgross]