summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Vagelpohl <jens@plyp.com>2023-01-17 08:43:33 +0100
committerJens Vagelpohl <jens@plyp.com>2023-01-17 08:43:33 +0100
commitfb429e54e938036887bb7c5b790d5f5898b71e7a (patch)
tree13863cf8cab5214d7bfc234582039cc5131736a1
parenteececdef0d0e4ec2d713bcc9b99b100233f1eb15 (diff)
downloadzope-proxy-fb429e54e938036887bb7c5b790d5f5898b71e7a.tar.gz
- `__getslice__` and `__setslice__` are Python 2 only
Python 3 uses slice objects passed to `__getitem__` instead.
-rw-r--r--src/zope/proxy/__init__.py14
-rw-r--r--src/zope/proxy/tests/test_proxy.py10
2 files changed, 1 insertions, 23 deletions
diff --git a/src/zope/proxy/__init__.py b/src/zope/proxy/__init__.py
index 4303257..b2366ab 100644
--- a/src/zope/proxy/__init__.py
+++ b/src/zope/proxy/__init__.py
@@ -219,23 +219,9 @@ class AbstractPyProxyBase:
def __len__(self):
return len(self._wrapped)
- def __getslice__(self, start, stop):
- try:
- getslice = type(self._wrapped).__getslice__
- except AttributeError:
- return self.__getitem__(slice(start, stop))
- return getslice(self._wrapped, start, stop)
-
def __getitem__(self, key):
return self._wrapped[key]
- def __setslice__(self, start, stop, value):
- try:
- setslice = type(self._wrapped).__setslice__
- except AttributeError:
- return self.__setitem__(slice(start, stop), value)
- return setslice(self._wrapped, start, stop, value)
-
def __setitem__(self, key, value):
self._wrapped[key] = value
diff --git a/src/zope/proxy/tests/test_proxy.py b/src/zope/proxy/tests/test_proxy.py
index 09bf3f9..7d0faba 100644
--- a/src/zope/proxy/tests/test_proxy.py
+++ b/src/zope/proxy/tests/test_proxy.py
@@ -310,8 +310,7 @@ class PyProxyBaseTestCase(unittest.TestCase):
data = [1, 2]
class DerivedList(list):
- def __getslice__(self, start, stop): # pragma: no cover PY2
- return list.__getslice__(self, start, stop)
+ pass
pList = self._makeOne(DerivedList(data))
@@ -326,9 +325,6 @@ class PyProxyBaseTestCase(unittest.TestCase):
def __len__(self):
return 2
- def __getslice__(self, start, end): # pragma: no cover PY2
- return (start, end)
-
def __getitem__(self, a_slice):
# On Python 3, we basically just return what the test expects.
# Mostly that's the computed indices (yay!) but there are
@@ -369,8 +365,6 @@ class PyProxyBaseTestCase(unittest.TestCase):
def __getitem__(self, x):
raise Missing('__getitem__')
- def __getslice__(self, start, stop): # pragma: no cover PY2
- raise Missing("__getslice__")
target = Get()
proxy = self._makeOne(target)
with self.assertRaisesRegex(Missing, self.getslice):
@@ -411,8 +405,6 @@ class PyProxyBaseTestCase(unittest.TestCase):
def __setitem__(self, k, v):
raise Missing('__setitem__')
- def __setslice__(self, start, stop, value): # pragma: no cover PY2
- raise Missing("__setslice__")
target = Set()
proxy = self._makeOne(target)
with self.assertRaisesRegex(Missing, self.setslice):