[Python-checkins] r60927 - python/trunk/Lib/UserDict.py python/trunk/Lib/shelve.py
Neal Norwitz
nnorwitz at gmail.com
Sun Feb 24 03:34:28 CET 2008
This change looks like it causes a bunch of failures in test_shelve of
the form below. (ie, for dbm and gdbm).
It looks like neither of these modules implements __contains__. I
wonder how many more sequences/mappings we have that don't support
__contains__.
n
--
ERROR: test_get (test.test_shelve.TestAsciiFileShelve)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/pybot/buildarea/trunk.klose-ubuntu-sparc/build/Lib/test/mapping_tests.py",
line 271, in test_get
self.assert_(d.get(self.other.keys()[0]) is None)
File "/home/pybot/buildarea/trunk.klose-ubuntu-sparc/build/Lib/shelve.py",
line 104, in get
if key in self.dict:
TypeError: argument of type 'gdbm.gdbm' is not iterable
and
ERROR: test_get (test.test_shelve.TestAsciiFileShelve)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/users/buildbot/slave/trunk.loewis-sun/build/Lib/test/mapping_tests.py",
line 271, in test_get
self.assert_(d.get(self.other.keys()[0]) is None)
File "/opt/users/buildbot/slave/trunk.loewis-sun/build/Lib/shelve.py",
line 104, in get
if key in self.dict:
TypeError: argument of type 'dbm.dbm' is not iterable
On Thu, Feb 21, 2008 at 11:24 AM, raymond.hettinger
<python-checkins at python.org> wrote:
> Author: raymond.hettinger
> Date: Thu Feb 21 20:24:53 2008
> New Revision: 60927
>
> Modified:
> python/trunk/Lib/UserDict.py
> python/trunk/Lib/shelve.py
> Log:
> Update more instances of has_key().
>
> Modified: python/trunk/Lib/UserDict.py
> ==============================================================================
> --- python/trunk/Lib/UserDict.py (original)
> +++ python/trunk/Lib/UserDict.py Thu Feb 21 20:24:53 2008
> @@ -41,7 +41,7 @@
> def iterkeys(self): return self.data.iterkeys()
> def itervalues(self): return self.data.itervalues()
> def values(self): return self.data.values()
> - def has_key(self, key): return self.data.has_key(key)
> + def has_key(self, key): return key in self.data
> def update(self, dict=None, **kwargs):
> if dict is None:
> pass
> @@ -59,7 +59,7 @@
> return failobj
> return self[key]
> def setdefault(self, key, failobj=None):
> - if not self.has_key(key):
> + if key not in self:
> self[key] = failobj
> return self[key]
> def pop(self, key, *args):
>
> Modified: python/trunk/Lib/shelve.py
> ==============================================================================
> --- python/trunk/Lib/shelve.py (original)
> +++ python/trunk/Lib/shelve.py Thu Feb 21 20:24:53 2008
> @@ -95,13 +95,13 @@
> return len(self.dict)
>
> def has_key(self, key):
> - return self.dict.has_key(key)
> + return key in self.dict
>
> def __contains__(self, key):
> - return self.dict.has_key(key)
> + return key in self.dict
>
> def get(self, key, default=None):
> - if self.dict.has_key(key):
> + if key in self.dict:
> return self[key]
> return default
>
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>
More information about the Python-checkins
mailing list