Skip to content

Commit

Permalink
fix ZopeUndo.Prefix decode on python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Sep 5, 2017
1 parent d8438a3 commit b7ba456
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -33,6 +33,7 @@
'random2',
'mock',
'msgpack-python',
'ZopeUndo',
]

classifiers = """
Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/asyncio/marshal.py
Expand Up @@ -157,7 +157,7 @@ def find_global(module, name):
def server_find_global(module, name):
"""Helper for message unpickler"""
try:
if module != 'ZopeUndo.Prefix':
if module not in ('ZopeUndo.Prefix', 'copy_reg', '__builtin__'):
raise ImportError
m = __import__(module, _globals, _globals, _silly)
except ImportError as msg:
Expand Down
25 changes: 25 additions & 0 deletions src/ZEO/tests/test_marshal.py
@@ -0,0 +1,25 @@
import unittest
from ZEO.asyncio.marshal import encode
from ZEO.asyncio.marshal import pickle_server_decode
from ZopeUndo.Prefix import Prefix


class MarshalTests(unittest.TestCase):

def testServerDecodeZopeUndoFilter(self):
# this is an example of Zope's
args = (0, 20, {'user_name': Prefix('test')})
# test against repr because Prefix __eq__ operator
# doesn't compare Prefix with Prefix but only
# Prefix with strings. see Prefix.__doc__
self.assertEqual(
repr(pickle_server_decode(encode(*args))),
repr(args)
)


def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(MarshalTests))
return suite

0 comments on commit b7ba456

Please sign in to comment.