Skip to content

Commit

Permalink
Adjust Pickler and UnPickler imports to use ZODB._compat python 2 and…
Browse files Browse the repository at this point in the history
… 3 compatible versions.

Add conditional import for cStringIO also.
  • Loading branch information
rudaporto authored and jensens committed Jun 26, 2018
1 parent 381b50d commit 8ab36cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -28,7 +28,7 @@
'Acquisition',
'DateTime',
'transaction',
'ZODB3',
'ZODB',
'Zope2',
],
)
7 changes: 3 additions & 4 deletions src/Products/ZopeVersionControl/Version.py
Expand Up @@ -15,17 +15,16 @@

import tempfile
import time
from cStringIO import StringIO
from cPickle import Pickler, Unpickler

from Acquisition import Implicit, aq_parent, aq_inner, aq_base
from App.class_init import default__class_init__ as InitializeClass
from Persistence import Persistent
from AccessControl import ClassSecurityInfo
from BTrees.OOBTree import OOBTree
from OFS.SimpleItem import SimpleItem

from Utility import VersionControlError
from ZODB._compat import BytesIO
from ZODB._compat import Pickler, Unpickler
from nonversioned import listNonVersionedObjects, removeNonVersionedData


Expand Down Expand Up @@ -54,7 +53,7 @@ def persistent_load(ref):
placeholder.id = "ignored_subobject"
return placeholder

stream = StringIO()
stream = BytesIO()
p = Pickler(stream, 1)
p.persistent_id = persistent_id
p.dump(obj)
Expand Down
10 changes: 8 additions & 2 deletions src/Products/ZopeVersionControl/tests/common.py
Expand Up @@ -26,7 +26,6 @@ def common_setUp(self):
# Install a hack to make SimpleItem version aware, so that the
# tests work. In normal development, you would mix in the
# VersionSupport class on an as-needed basis.
import cStringIO
from AccessControl.SecurityManagement import newSecurityManager
from OFS.Application import Application
from OFS.DTMLDocument import addDTMLDocument
Expand All @@ -38,15 +37,22 @@ def common_setUp(self):

from Products.ZopeVersionControl.ZopeRepository import addRepository
from ZODB import DB
from ZODB._compat import PY3
from ZODB.DemoStorage import DemoStorage

if PY3:
from io import cStringIO
else:
from cStringIO import cStringIO

s = DemoStorage()
self.connection = DB( s ).open()
try:
r = self.connection.root()
a = Application()
r['Application'] = a
self.root = a
responseOut = self.responseOut = cStringIO.StringIO()
responseOut = self.responseOut = cStringIO()
self.app = makerequest( self.root, stdout=responseOut )
self.app.acl_users.userFolderAddUser('UnitTester', '123', (), ())
manage_addFolder(self.app, 'folder1')
Expand Down

0 comments on commit 8ab36cf

Please sign in to comment.