Commit 46b5fec1 authored by Stefan H. Holek's avatar Stefan H. Holek

Also prevent publishing of Python 2.4's 'set' and 'frozenset' types.

parent 9a3d5f68
...@@ -579,6 +579,10 @@ for name in ('NoneType', 'IntType', 'LongType', 'FloatType', 'StringType', ...@@ -579,6 +579,10 @@ for name in ('NoneType', 'IntType', 'LongType', 'FloatType', 'StringType',
if hasattr(types, name): if hasattr(types, name):
itypes[getattr(types, name)] = 0 itypes[getattr(types, name)] = 0
# Python 2.4 no longer maintains the types module.
itypes[set] = 0
itypes[frozenset] = 0
def typeCheck(obj, deny=itypes): def typeCheck(obj, deny=itypes):
# Return true if its ok to publish the type, false otherwise. # Return true if its ok to publish the type, false otherwise.
return deny.get(type(obj), 1) return deny.get(type(obj), 1)
...@@ -102,6 +102,8 @@ class TestBaseRequest(TestCase): ...@@ -102,6 +102,8 @@ class TestBaseRequest(TestCase):
self.f1.simpleList = [] self.f1.simpleList = []
self.f1.simpleBoolean = True self.f1.simpleBoolean = True
self.f1.simpleComplex = complex(1) self.f1.simpleComplex = complex(1)
self.f1.simpleSet = set([])
self.f1.simpleFrozenSet = frozenset([])
def makeBaseRequest(self): def makeBaseRequest(self):
response = HTTPResponse() response = HTTPResponse()
...@@ -239,6 +241,12 @@ class TestBaseRequest(TestCase): ...@@ -239,6 +241,12 @@ class TestBaseRequest(TestCase):
self.assertRaises(NotFound, r.traverse, 'folder/simpleBoolean') self.assertRaises(NotFound, r.traverse, 'folder/simpleBoolean')
self.assertRaises(NotFound, r.traverse, 'folder/simpleComplex') self.assertRaises(NotFound, r.traverse, 'folder/simpleComplex')
def test_traverse_set_type(self):
from ZPublisher import NotFound
r = self.makeBaseRequest()
self.assertRaises(NotFound, r.traverse, 'folder/simpleSet')
self.assertRaises(NotFound, r.traverse, 'folder/simpleFrozenSet')
def test_suite(): def test_suite():
return TestSuite( ( makeSuite(TestBaseRequest), ) ) return TestSuite( ( makeSuite(TestBaseRequest), ) )
......
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