summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Richter <stephan.richter@gmail.com>2013-03-11 10:21:49 -0400
committerStephan Richter <stephan.richter@gmail.com>2013-03-11 10:21:49 -0400
commit6b6617f70b2b3d7efaadecf09855d5b9137bb659 (patch)
tree3598c9a1a775ba5c96a9652922cc9d34e56f0d8d
parent607f637295068590d5812ce32dcdfc021f4f48c9 (diff)
downloadzope-location-6b6617f70b2b3d7efaadecf09855d5b9137bb659.tar.gz
- Changed the behavior of ``LocationProxy``'s ``__setattr__()`` to correctly
behave when dealing with the pure Python version of the ``ProxyBase`` class. Also added a test suite that fully tests the pure Python proxy version of the ``LocationProxy`` class.
-rw-r--r--CHANGES.rst5
-rw-r--r--src/zope/location/location.py4
-rw-r--r--src/zope/location/tests/test_location.py46
3 files changed, 52 insertions, 3 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 17fd7f5..c09a3f3 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -5,7 +5,10 @@ CHANGES
4.0.2 (unreleased)
------------------
-- Nothing changed yet.
+- Changed the behavior of ``LocationProxy``'s ``__setattr__()`` to correctly
+ behave when dealing with the pure Python version of the ``ProxyBase``
+ class. Also added a test suite that fully tests the pure Python proxy
+ version of the ``LocationProxy`` class.
4.0.1 (2013-02-19)
diff --git a/src/zope/location/location.py b/src/zope/location/location.py
index 717a4fe..3554c51 100644
--- a/src/zope/location/location.py
+++ b/src/zope/location/location.py
@@ -113,9 +113,9 @@ class LocationProxy(ProxyBase):
if name in self.__slots__ + getattr(ProxyBase, '__slots__', ()):
#('_wrapped', '__parent__', '__name__'):
try:
- return ProxyBase.__setattr__(self, name, value)
- except AttributeError: #pragma NO COVER PyPy
return object.__setattr__(self, name, value)
+ except TypeError: #pragma NO COVER C Optimization
+ return ProxyBase.__setattr__(self, name, value)
return ProxyBase.__setattr__(self, name, value)
@non_overridable
diff --git a/src/zope/location/tests/test_location.py b/src/zope/location/tests/test_location.py
index 985fee4..552af75 100644
--- a/src/zope/location/tests/test_location.py
+++ b/src/zope/location/tests/test_location.py
@@ -366,6 +366,50 @@ class LocationProxyTests(unittest.TestCase, ConformsToILocation):
self.assertEqual(list(providedBy(proxy)), [IContext, IProxy, ILocation])
+class LocationPyProxyTests(LocationProxyTests):
+
+ def setUp(self):
+ import sys
+ for mod in ('zope.location.location',
+ 'zope.proxy.decorator'):
+ try:
+ del sys.modules[mod]
+ except KeyError:
+ pass
+ import zope.proxy
+ self.orig = (zope.proxy.ProxyBase,
+ zope.proxy.getProxiedObject,
+ zope.proxy.setProxiedObject,
+ zope.proxy.isProxy,
+ zope.proxy.sameProxiedObjects,
+ zope.proxy.queryProxy,
+ zope.proxy.queryInnerProxy,
+ zope.proxy.removeAllProxies,
+ zope.proxy.non_overridable)
+ zope.proxy.ProxyBase = zope.proxy.PyProxyBase
+ zope.proxy.getProxiedObject = zope.proxy.py_getProxiedObject
+ zope.proxy.setProxiedObject = zope.proxy.py_setProxiedObject
+ zope.proxy.isProxy = zope.proxy.py_isProxy
+ zope.proxy.sameProxiedObjects = zope.proxy.py_sameProxiedObjects
+ zope.proxy.queryProxy = zope.proxy.py_queryProxy
+ zope.proxy.queryInnerProxy = zope.proxy.py_queryInnerProxy
+ zope.proxy.removeAllProxies = zope.proxy.py_removeAllProxies
+ zope.proxy.non_overridable = zope.proxy.PyNonOverridable
+
+
+ def tearDown(self):
+ import zope.proxy
+ (zope.proxy.ProxyBase,
+ zope.proxy.getProxiedObject,
+ zope.proxy.setProxiedObject,
+ zope.proxy.isProxy,
+ zope.proxy.sameProxiedObjects,
+ zope.proxy.queryProxy,
+ zope.proxy.queryInnerProxy,
+ zope.proxy.removeAllProxies,
+ zope.proxy.non_overridable) = self.orig
+
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(LocationTests),
@@ -374,5 +418,7 @@ def test_suite():
unittest.makeSuite(Test_inside),
unittest.makeSuite(Test_LocationIterator),
unittest.makeSuite(ClassAndInstanceDescrTests),
+ # In case of Python-only version, tests are simply run twice.
unittest.makeSuite(LocationProxyTests),
+ unittest.makeSuite(LocationPyProxyTests),
))