summaryrefslogtreecommitdiff
path: root/src/zope/interface/common/mapping.py
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2020-02-06 09:02:56 -0600
committerJason Madden <jamadden@gmail.com>2020-02-06 09:02:56 -0600
commit0b0e22727b52aa2e0f05884ce130524700163902 (patch)
tree45a3aac378da646272b02f04d660d4f868d40219 /src/zope/interface/common/mapping.py
parent0048a56bac299db7c78a9c8e52c5928e4ec06f38 (diff)
downloadzope-interface-issue118.tar.gz
Fix verification for methods of builtin types with pseudo-default arguments on Pypyissue118
On PyPy2, they are ignored (like on CPython), but on PyPy3 they can actually be validated. Fixes #118
Diffstat (limited to 'src/zope/interface/common/mapping.py')
-rw-r--r--src/zope/interface/common/mapping.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/zope/interface/common/mapping.py b/src/zope/interface/common/mapping.py
index 1c5661a..a005aed 100644
--- a/src/zope/interface/common/mapping.py
+++ b/src/zope/interface/common/mapping.py
@@ -17,6 +17,7 @@ Importing this module does *not* mark any standard classes
as implementing any of these interfaces.
"""
from zope.interface import Interface
+from zope.interface._compat import PYTHON2 as PY2
class IItemMapping(Interface):
"""Simplest readable mapping object
@@ -89,14 +90,15 @@ class IIterableMapping(IEnumerableMapping):
without copying.
"""
- def iterkeys():
- "iterate over keys; equivalent to ``__iter__``"
+ if PY2:
+ def iterkeys():
+ "iterate over keys; equivalent to ``__iter__``"
- def itervalues():
- "iterate over values"
+ def itervalues():
+ "iterate over values"
- def iteritems():
- "iterate over items"
+ def iteritems():
+ "iterate over items"
class IClonableMapping(Interface):
"""Something that can produce a copy of itself.
@@ -115,8 +117,9 @@ class IExtendedReadMapping(IIterableMapping):
in Python 3.
"""
- def has_key(key):
- """Tell if a key exists in the mapping; equivalent to ``__contains__``"""
+ if PY2:
+ def has_key(key):
+ """Tell if a key exists in the mapping; equivalent to ``__contains__``"""
class IExtendedWriteMapping(IWriteMapping):
"""Additional mutation methods.
@@ -133,12 +136,16 @@ class IExtendedWriteMapping(IWriteMapping):
def setdefault(key, default=None):
"D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D"
- def pop(k, *args):
- """Remove specified key and return the corresponding value.
+ def pop(k, default=None):
+ """
+ pop(k[,default]) -> value
+
+ Remove specified key and return the corresponding value.
- ``*args`` may contain a single default value, or may not be supplied.
- If key is not found, default is returned if given, otherwise
- `KeyError` is raised"""
+ If key is not found, *default* is returned if given, otherwise
+ `KeyError` is raised. Note that *default* must not be passed by
+ name.
+ """
def popitem():
"""remove and return some (key, value) pair as a