Get rid of dict.has_key(). Boy this has a lot of repercussions!
Not all code has been fixed yet; this is just a checkpoint...
The C API still has PyDict_HasKey() and _HasKeyString(); not sure
if I want to change those just yet.
diff --git a/Lib/DocXMLRPCServer.py b/Lib/DocXMLRPCServer.py
index 86ed32b..ddd5604 100644
--- a/Lib/DocXMLRPCServer.py
+++ b/Lib/DocXMLRPCServer.py
@@ -174,7 +174,7 @@
         methods = {}
 
         for method_name in self.system_listMethods():
-            if self.funcs.has_key(method_name):
+            if method_name in self.funcs:
                 method = self.funcs[method_name]
             elif self.instance is not None:
                 method_info = [None, None] # argspec, documentation
diff --git a/Lib/SimpleXMLRPCServer.py b/Lib/SimpleXMLRPCServer.py
index 0846a68..3b0a6a5 100644
--- a/Lib/SimpleXMLRPCServer.py
+++ b/Lib/SimpleXMLRPCServer.py
@@ -313,7 +313,7 @@
         Returns a string containing documentation for the specified method."""
 
         method = None
-        if self.funcs.has_key(method_name):
+        if method_name in self.funcs:
             method = self.funcs[method_name]
         elif self.instance is not None:
             # Instance can implement _methodHelp to return help for a method
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
index 5e97817..b560a11 100644
--- a/Lib/UserDict.py
+++ b/Lib/UserDict.py
@@ -41,7 +41,6 @@
     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 update(self, dict=None, **kwargs):
         if dict is None:
             pass
@@ -55,11 +54,11 @@
         if len(kwargs):
             self.data.update(kwargs)
     def get(self, key, failobj=None):
-        if not self.has_key(key):
+        if key not in self:
             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):
@@ -91,14 +90,12 @@
     def __iter__(self):
         for k in self.keys():
             yield k
-    def has_key(self, key):
+    def __contains__(self, key):
         try:
             value = self[key]
         except KeyError:
             return False
         return True
-    def __contains__(self, key):
-        return self.has_key(key)
 
     # third level takes advantage of second level definitions
     def iteritems(self):
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index 886c845..7b2f301 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -247,7 +247,7 @@
         fd = self._fileno
         if map is None:
             map = self._map
-        if map.has_key(fd):
+        if fd in map:
             #self.log_info('closing channel %d:%s' % (fd, self))
             del map[fd]
         self._fileno = None
diff --git a/Lib/bdb.py b/Lib/bdb.py
index 0c56b63..1e81c44 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -133,8 +133,7 @@
         raise NotImplementedError, "subclass of bdb must implement do_clear()"
 
     def break_anywhere(self, frame):
-        return self.breaks.has_key(
-            self.canonic(frame.f_code.co_filename))
+        return self.canonic(frame.f_code.co_filename) in self.breaks
 
     # Derived classes should override the user_* methods
     # to gain control.
@@ -245,7 +244,7 @@
         # pair, then remove the breaks entry
         for bp in Breakpoint.bplist[filename, lineno][:]:
             bp.deleteMe()
-        if not Breakpoint.bplist.has_key((filename, lineno)):
+        if (filename, lineno) not in Breakpoint.bplist:
             self.breaks[filename].remove(lineno)
         if not self.breaks[filename]:
             del self.breaks[filename]
@@ -453,7 +452,7 @@
         Breakpoint.next = Breakpoint.next + 1
         # Build the two lists
         self.bpbynumber.append(self)
-        if self.bplist.has_key((file, line)):
+        if (file, line) in self.bplist:
             self.bplist[file, line].append(self)
         else:
             self.bplist[file, line] = [self]
diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py
index cf32668..0eeefd1 100644
--- a/Lib/bsddb/__init__.py
+++ b/Lib/bsddb/__init__.py
@@ -255,6 +255,8 @@
         self._checkOpen()
         return _DeadlockWrap(self.db.has_key, key)
 
+    __contains__ = has_key
+
     def set_location(self, key):
         self._checkOpen()
         self._checkCursor()
diff --git a/Lib/bsddb/dbobj.py b/Lib/bsddb/dbobj.py
index 40a51ec..346c1ad 100644
--- a/Lib/bsddb/dbobj.py
+++ b/Lib/bsddb/dbobj.py
@@ -21,7 +21,7 @@
 # added to _bsddb.c.
 #
 
-import db
+from . import db
 
 try:
     from UserDict import DictMixin
@@ -161,6 +161,8 @@
         return self._cobj.key_range(*args, **kwargs)
     def has_key(self, *args, **kwargs):
         return self._cobj.has_key(*args, **kwargs)
+    def __contains__(self, key):
+        return self._cobj.has_key(key)
     def items(self, *args, **kwargs):
         return self._cobj.items(*args, **kwargs)
     def keys(self, *args, **kwargs):
diff --git a/Lib/bsddb/dbshelve.py b/Lib/bsddb/dbshelve.py
index 5cd4a53..afc1a1a 100644
--- a/Lib/bsddb/dbshelve.py
+++ b/Lib/bsddb/dbshelve.py
@@ -35,7 +35,7 @@
 except ImportError:
     # DictMixin is new in Python 2.3
     class DictMixin: pass
-import db
+from . import db
 
 #------------------------------------------------------------------------
 
@@ -197,6 +197,10 @@
         raise NotImplementedError
 
 
+    def __contains__(self, key):
+        return self.has_key(key)
+
+
     #----------------------------------------------
     # Methods allowed to pass-through to self.db
     #
diff --git a/Lib/bsddb/dbutils.py b/Lib/bsddb/dbutils.py
index 30b3cc7..0c4c1cb 100644
--- a/Lib/bsddb/dbutils.py
+++ b/Lib/bsddb/dbutils.py
@@ -55,7 +55,7 @@
     """
     sleeptime = _deadlock_MinSleepTime
     max_retries = _kwargs.get('max_retries', -1)
-    if _kwargs.has_key('max_retries'):
+    if 'max_tries' in _kwargs:
         del _kwargs['max_retries']
     while True:
         try:
diff --git a/Lib/bsddb/test/test_all.py b/Lib/bsddb/test/test_all.py
index ad8b1e9..0b132f4 100644
--- a/Lib/bsddb/test/test_all.py
+++ b/Lib/bsddb/test/test_all.py
@@ -41,8 +41,12 @@
 # This little hack is for when this module is run as main and all the
 # other modules import it so they will still be able to get the right
 # verbose setting.  It's confusing but it works.
-import test_all
-test_all.verbose = verbose
+try:
+    import test_all
+except ImportError:
+    pass
+else:
+    test_all.verbose = verbose
 
 
 def suite():
diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py
index 05ef83c..33a7837 100644
--- a/Lib/bsddb/test/test_associate.py
+++ b/Lib/bsddb/test/test_associate.py
@@ -14,7 +14,7 @@
     have_threads = 0
 
 import unittest
-from test_all import verbose
+from .test_all import verbose
 
 try:
     # For Pythons w/distutils pybsddb
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
index d6d507f..f7f4c2d 100644
--- a/Lib/bsddb/test/test_basics.py
+++ b/Lib/bsddb/test/test_basics.py
@@ -20,7 +20,7 @@
     # For Python 2.3
     from bsddb import db
 
-from test_all import verbose
+from .test_all import verbose
 
 DASH = '-'
 
diff --git a/Lib/bsddb/test/test_compare.py b/Lib/bsddb/test/test_compare.py
index 59a45ec..ccf8b83 100644
--- a/Lib/bsddb/test/test_compare.py
+++ b/Lib/bsddb/test/test_compare.py
@@ -3,9 +3,10 @@
 """
 
 import sys, os, re
-import test_all
 from cStringIO import StringIO
 
+from . import test_all
+
 import unittest
 try:
     # For Pythons w/distutils pybsddb
diff --git a/Lib/bsddb/test/test_compat.py b/Lib/bsddb/test/test_compat.py
index b108db4..841e01c 100644
--- a/Lib/bsddb/test/test_compat.py
+++ b/Lib/bsddb/test/test_compat.py
@@ -7,7 +7,7 @@
 import unittest
 import tempfile
 
-from test_all import verbose
+from .test_all import verbose
 
 try:
     # For Pythons w/distutils pybsddb
diff --git a/Lib/bsddb/test/test_dbshelve.py b/Lib/bsddb/test/test_dbshelve.py
index 722ee5b..bb85bf7 100644
--- a/Lib/bsddb/test/test_dbshelve.py
+++ b/Lib/bsddb/test/test_dbshelve.py
@@ -15,7 +15,7 @@
     # For Python 2.3
     from bsddb import db, dbshelve
 
-from test_all import verbose
+from .test_all import verbose
 
 
 #----------------------------------------------------------------------
diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py
index 26e3d36..2ff93a3 100644
--- a/Lib/bsddb/test/test_dbtables.py
+++ b/Lib/bsddb/test/test_dbtables.py
@@ -28,7 +28,7 @@
     import pickle
 
 import unittest
-from test_all import verbose
+from .test_all import verbose
 
 try:
     # For Pythons w/distutils pybsddb
diff --git a/Lib/bsddb/test/test_env_close.py b/Lib/bsddb/test/test_env_close.py
index c112941..43dcabe 100644
--- a/Lib/bsddb/test/test_env_close.py
+++ b/Lib/bsddb/test/test_env_close.py
@@ -15,7 +15,7 @@
     # For Python 2.3
     from bsddb import db
 
-from test_all import verbose
+from .test_all import verbose
 
 # We're going to get warnings in this module about trying to close the db when
 # its env is already closed.  Let's just ignore those.
diff --git a/Lib/bsddb/test/test_get_none.py b/Lib/bsddb/test/test_get_none.py
index 5f09cec..d1b69c7 100644
--- a/Lib/bsddb/test/test_get_none.py
+++ b/Lib/bsddb/test/test_get_none.py
@@ -14,7 +14,7 @@
     # For Python 2.3
     from bsddb import db
 
-from test_all import verbose
+from .test_all import verbose
 
 
 #----------------------------------------------------------------------
diff --git a/Lib/bsddb/test/test_join.py b/Lib/bsddb/test/test_join.py
index 69a1e9d..6e98b0b 100644
--- a/Lib/bsddb/test/test_join.py
+++ b/Lib/bsddb/test/test_join.py
@@ -13,7 +13,7 @@
     have_threads = 0
 
 import unittest
-from test_all import verbose
+from .test_all import verbose
 
 try:
     # For Pythons w/distutils pybsddb
diff --git a/Lib/bsddb/test/test_lock.py b/Lib/bsddb/test/test_lock.py
index 7d77798..53f11a8 100644
--- a/Lib/bsddb/test/test_lock.py
+++ b/Lib/bsddb/test/test_lock.py
@@ -15,7 +15,7 @@
 
 
 import unittest
-from test_all import verbose
+from .test_all import verbose
 
 try:
     # For Pythons w/distutils pybsddb
diff --git a/Lib/bsddb/test/test_queue.py b/Lib/bsddb/test/test_queue.py
index 95cf20d..4226c9e 100644
--- a/Lib/bsddb/test/test_queue.py
+++ b/Lib/bsddb/test/test_queue.py
@@ -14,7 +14,7 @@
     # For Python 2.3
     from bsddb import db
 
-from test_all import verbose
+from .test_all import verbose
 
 
 #----------------------------------------------------------------------
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
index f1ea56a..170448e 100644
--- a/Lib/bsddb/test/test_recno.py
+++ b/Lib/bsddb/test/test_recno.py
@@ -8,7 +8,7 @@
 from pprint import pprint
 import unittest
 
-from test_all import verbose
+from .test_all import verbose
 
 try:
     # For Pythons w/distutils pybsddb
diff --git a/Lib/bsddb/test/test_sequence.py b/Lib/bsddb/test/test_sequence.py
index 979f858..48631a3 100644
--- a/Lib/bsddb/test/test_sequence.py
+++ b/Lib/bsddb/test/test_sequence.py
@@ -10,7 +10,7 @@
 except ImportError:
     from bsddb import db
 
-from test_all import verbose
+from .test_all import verbose
 
 
 class DBSequenceTest(unittest.TestCase):
diff --git a/Lib/bsddb/test/test_thread.py b/Lib/bsddb/test/test_thread.py
index 31964f0..f187413 100644
--- a/Lib/bsddb/test/test_thread.py
+++ b/Lib/bsddb/test/test_thread.py
@@ -31,7 +31,7 @@
         pass
 
 import unittest
-from test_all import verbose
+from .test_all import verbose
 
 try:
     # For Pythons w/distutils pybsddb
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 41dc433..4c617a6 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -608,14 +608,6 @@
             if item.name not in keys: keys.append(item.name)
         return keys
 
-    def has_key(self, key):
-        """Dictionary style has_key() method."""
-        if self.list is None:
-            raise TypeError, "not indexable"
-        for item in self.list:
-            if item.name == key: return True
-        return False
-
     def __contains__(self, key):
         """Dictionary style __contains__ method."""
         if self.list is None:
diff --git a/Lib/difflib.py b/Lib/difflib.py
index 3e28b18..7ab682d 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -199,7 +199,7 @@
         #      DON'T USE!  Only __chain_b uses this.  Use isbjunk.
         # isbjunk
         #      for x in b, isbjunk(x) == isjunk(x) but much faster;
-        #      it's really the has_key method of a hidden dict.
+        #      it's really the __contains__ method of a hidden dict.
         #      DOES NOT WORK for x in a!
         # isbpopular
         #      for x in b, isbpopular(x) is true iff b is reasonably long
@@ -341,8 +341,8 @@
         # lot of junk in the sequence, the number of *unique* junk
         # elements is probably small.  So the memory burden of keeping
         # this dict alive is likely trivial compared to the size of b2j.
-        self.isbjunk = junkdict.has_key
-        self.isbpopular = populardict.has_key
+        self.isbjunk = junkdict.__contains__
+        self.isbpopular = populardict.__contains__
 
     def find_longest_match(self, alo, ahi, blo, bhi):
         """Find longest matching block in a[alo:ahi] and b[blo:bhi].
@@ -674,7 +674,7 @@
         # avail[x] is the number of times x appears in 'b' less the
         # number of times we've seen it in 'a' so far ... kinda
         avail = {}
-        availhas, matches = avail.has_key, 0
+        availhas, matches = avail.__contains__, 0
         for elt in self.a:
             if availhas(elt):
                 numb = avail[elt]
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py
index b725a14..059d544 100644
--- a/Lib/distutils/archive_util.py
+++ b/Lib/distutils/archive_util.py
@@ -124,7 +124,7 @@
 
 def check_archive_formats (formats):
     for format in formats:
-        if not ARCHIVE_FORMATS.has_key(format):
+        if format not in ARCHIVE_FORMATS:
             return format
     else:
         return None
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
index 1349abe..0ed9a40 100644
--- a/Lib/distutils/ccompiler.py
+++ b/Lib/distutils/ccompiler.py
@@ -159,7 +159,7 @@
         # basically the same things with Unix C compilers.
 
         for key in args.keys():
-            if not self.executables.has_key(key):
+            if key not in self.executables:
                 raise ValueError, \
                       "unknown executable '%s' for class %s" % \
                       (key, self.__class__.__name__)
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 9626710..cd67544 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -341,7 +341,7 @@
 
             # Medium-easy stuff: same syntax/semantics, different names.
             ext.runtime_library_dirs = build_info.get('rpath')
-            if build_info.has_key('def_file'):
+            if 'def_file' in build_info:
                 log.warn("'def_file' element of build info dict "
                          "no longer supported")
 
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py
index c9c6f03..85a28fe 100644
--- a/Lib/distutils/core.py
+++ b/Lib/distutils/core.py
@@ -101,9 +101,9 @@
     else:
         klass = Distribution
 
-    if not attrs.has_key('script_name'):
+    if 'script_name' not in attrs:
         attrs['script_name'] = os.path.basename(sys.argv[0])
-    if not attrs.has_key('script_args'):
+    if 'script_args'  not in attrs:
         attrs['script_args'] = sys.argv[1:]
 
     # Create the Distribution instance, using the remaining arguments
@@ -111,7 +111,7 @@
     try:
         _setup_distribution = dist = klass(attrs)
     except DistutilsSetupError, msg:
-        if attrs.has_key('name'):
+        if 'name' not in attrs:
             raise SystemExit, "error in %s setup command: %s" % \
                   (attrs['name'], msg)
         else:
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index ff49886..d098cb9 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -239,7 +239,7 @@
                     for (opt, val) in cmd_options.items():
                         opt_dict[opt] = ("setup script", val)
 
-            if attrs.has_key('licence'):
+            if 'licence' in attrs:
                 attrs['license'] = attrs['licence']
                 del attrs['licence']
                 msg = "'licence' distribution option is deprecated; use 'license'"
@@ -343,7 +343,7 @@
             user_filename = "pydistutils.cfg"
 
         # And look for the user config file
-        if os.environ.has_key('HOME'):
+        if 'HOME' in os.environ:
             user_file = os.path.join(os.environ.get('HOME'), user_filename)
             if os.path.isfile(user_file):
                 files.append(user_file)
@@ -388,7 +388,7 @@
         # If there was a "global" section in the config file, use it
         # to set Distribution options.
 
-        if self.command_options.has_key('global'):
+        if 'global' in self.command_options:
             for (opt, (src, val)) in self.command_options['global'].items():
                 alias = self.negative_opt.get(opt)
                 try:
@@ -907,7 +907,7 @@
 
             try:
                 is_string = type(value) is StringType
-                if neg_opt.has_key(option) and is_string:
+                if option in neg_opt and is_string:
                     setattr(command_obj, neg_opt[option], not strtobool(value))
                 elif option in bool_opts and is_string:
                     setattr(command_obj, option, strtobool(value))
diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py
index 218ed73..31cf0c5 100644
--- a/Lib/distutils/fancy_getopt.py
+++ b/Lib/distutils/fancy_getopt.py
@@ -97,7 +97,7 @@
         self._build_index()
 
     def add_option (self, long_option, short_option=None, help_string=None):
-        if self.option_index.has_key(long_option):
+        if long_option in self.option_index:
             raise DistutilsGetoptError, \
                   "option conflict: already an option '%s'" % long_option
         else:
@@ -109,7 +109,7 @@
     def has_option (self, long_option):
         """Return true if the option table for this parser has an
         option with long name 'long_option'."""
-        return self.option_index.has_key(long_option)
+        return long_option in self.option_index
 
     def get_attr_name (self, long_option):
         """Translate long option name 'long_option' to the form it
@@ -121,11 +121,11 @@
     def _check_alias_dict (self, aliases, what):
         assert type(aliases) is DictionaryType
         for (alias, opt) in aliases.items():
-            if not self.option_index.has_key(alias):
+            if alias not in self.option_index:
                 raise DistutilsGetoptError, \
                       ("invalid %s '%s': "
                        "option '%s' not defined") % (what, alias, alias)
-            if not self.option_index.has_key(opt):
+            if opt not in self.option_index:
                 raise DistutilsGetoptError, \
                       ("invalid %s '%s': "
                        "aliased option '%s' not defined") % (what, alias, opt)
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 76fe256..0ea4bb7 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -150,22 +150,22 @@
             get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
                             'CCSHARED', 'LDSHARED', 'SO')
 
-        if os.environ.has_key('CC'):
+        if 'CC' in os.environ:
             cc = os.environ['CC']
-        if os.environ.has_key('CXX'):
+        if 'CXX' in os.environ:
             cxx = os.environ['CXX']
-        if os.environ.has_key('LDSHARED'):
+        if 'LDSHARED' in os.environ:
             ldshared = os.environ['LDSHARED']
-        if os.environ.has_key('CPP'):
+        if 'CPP' in os.environ:
             cpp = os.environ['CPP']
         else:
             cpp = cc + " -E"           # not always
-        if os.environ.has_key('LDFLAGS'):
+        if 'LDFLAGS' in os.environ:
             ldshared = ldshared + ' ' + os.environ['LDFLAGS']
-        if os.environ.has_key('CFLAGS'):
+        if 'CFLAGS' in os.environ:
             cflags = opt + ' ' + os.environ['CFLAGS']
             ldshared = ldshared + ' ' + os.environ['CFLAGS']
-        if os.environ.has_key('CPPFLAGS'):
+        if 'CPPFLAGS' in os.environ:
             cpp = cpp + ' ' + os.environ['CPPFLAGS']
             cflags = cflags + ' ' + os.environ['CPPFLAGS']
             ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
@@ -277,12 +277,12 @@
             if m:
                 n = m.group(1)
                 found = True
-                if done.has_key(n):
+                if n in done:
                     item = str(done[n])
-                elif notdone.has_key(n):
+                elif n in notdone:
                     # get it on a subsequent round
                     found = False
-                elif os.environ.has_key(n):
+                elif n in os.environ:
                     # do it like make: fall back to environment
                     item = os.environ[n]
                 else:
@@ -366,7 +366,7 @@
     # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so
     # it needs to be compatible.
     # If it isn't set we set it to the configure-time value
-    if sys.platform == 'darwin' and g.has_key('MACOSX_DEPLOYMENT_TARGET'):
+    if sys.platform == 'darwin' and 'MACOSX_DEPLOYMENT_TARGET' in g:
         cfg_target = g['MACOSX_DEPLOYMENT_TARGET']
         cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '')
         if cur_target == '':
diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py
index 67efd65..ff2878d 100644
--- a/Lib/distutils/text_file.py
+++ b/Lib/distutils/text_file.py
@@ -89,7 +89,7 @@
         # set values for all options -- either from client option hash
         # or fallback to default_options
         for opt in self.default_options.keys():
-            if options.has_key (opt):
+            if opt in options:
                 setattr (self, opt, options[opt])
 
             else:
@@ -97,7 +97,7 @@
 
         # sanity check client option hash
         for opt in options.keys():
-            if not self.default_options.has_key (opt):
+            if opt not in self.default_options:
                 raise KeyError, "invalid TextFile option '%s'" % opt
 
         if file is None:
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 1265f4c..1bcda93 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -200,11 +200,11 @@
     if _environ_checked:
         return
 
-    if os.name == 'posix' and not os.environ.has_key('HOME'):
+    if os.name == 'posix' and 'HOME' not in os.environ:
         import pwd
         os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
 
-    if not os.environ.has_key('PLAT'):
+    if 'PLAT' not in os.environ:
         os.environ['PLAT'] = get_platform()
 
     _environ_checked = 1
@@ -222,7 +222,7 @@
     check_environ()
     def _subst (match, local_vars=local_vars):
         var_name = match.group(1)
-        if local_vars.has_key(var_name):
+        if var_name in local_vars:
             return str(local_vars[var_name])
         else:
             return os.environ[var_name]
diff --git a/Lib/dumbdbm.py b/Lib/dumbdbm.py
index 84a7665..e00d9e8 100644
--- a/Lib/dumbdbm.py
+++ b/Lib/dumbdbm.py
@@ -195,9 +195,6 @@
     def keys(self):
         return self._index.keys()
 
-    def has_key(self, key):
-        return key in self._index
-
     def __contains__(self, key):
         return key in self._index
 
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index b72128b..ed7c7d1 100755
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -120,13 +120,10 @@
         """Return a list of (key, message) tuples. Memory intensive."""
         return list(self.iteritems())
 
-    def has_key(self, key):
+    def __contains__(self, key):
         """Return True if the keyed message exists, False otherwise."""
         raise NotImplementedError('Method must be implemented by subclass')
 
-    def __contains__(self, key):
-        return self.has_key(key)
-
     def __len__(self):
         """Return a count of messages in the mailbox."""
         raise NotImplementedError('Method must be implemented by subclass')
@@ -330,7 +327,7 @@
                 continue
             yield key
 
-    def has_key(self, key):
+    def __contains__(self, key):
         """Return True if the keyed message exists, False otherwise."""
         self._refresh()
         return key in self._toc
@@ -515,7 +512,7 @@
         for key in self._toc.keys():
             yield key
 
-    def has_key(self, key):
+    def __contains__(self, key):
         """Return True if the keyed message exists, False otherwise."""
         self._lookup()
         return key in self._toc
@@ -902,7 +899,7 @@
         return iter(sorted(int(entry) for entry in os.listdir(self._path)
                                       if entry.isdigit()))
 
-    def has_key(self, key):
+    def __contains__(self, key):
         """Return True if the keyed message exists, False otherwise."""
         return os.path.exists(os.path.join(self._path, str(key)))
 
diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py
index 25e1482..2a31dbf 100644
--- a/Lib/modulefinder.py
+++ b/Lib/modulefinder.py
@@ -242,7 +242,7 @@
         else:
             self.msgout(3, "import_module ->", m)
             return m
-        if self.badmodules.has_key(fqname):
+        if fqname in self.badmodules:
             self.msgout(3, "import_module -> None")
             return None
         if parent and parent.__path__ is None:
@@ -388,7 +388,7 @@
         return m
 
     def add_module(self, fqname):
-        if self.modules.has_key(fqname):
+        if fqname in self.modules:
             return self.modules[fqname]
         self.modules[fqname] = m = Module(fqname)
         return m
diff --git a/Lib/optparse.py b/Lib/optparse.py
index 62d2f7e..a02f79a 100644
--- a/Lib/optparse.py
+++ b/Lib/optparse.py
@@ -602,7 +602,7 @@
 
     def _set_attrs(self, attrs):
         for attr in self.ATTRS:
-            if attrs.has_key(attr):
+            if attr in attrs:
                 setattr(self, attr, attrs[attr])
                 del attrs[attr]
             else:
@@ -854,7 +854,7 @@
         are silently ignored.
         """
         for attr in dir(self):
-            if dict.has_key(attr):
+            if attr in dict:
                 dval = dict[attr]
                 if dval is not None:
                     setattr(self, attr, dval)
@@ -974,10 +974,10 @@
     def _check_conflict(self, option):
         conflict_opts = []
         for opt in option._short_opts:
-            if self._short_opt.has_key(opt):
+            if opt in self._short_opt:
                 conflict_opts.append((opt, self._short_opt[opt]))
         for opt in option._long_opts:
-            if self._long_opt.has_key(opt):
+            if opt in self._long_opt:
                 conflict_opts.append((opt, self._long_opt[opt]))
 
         if conflict_opts:
@@ -1023,7 +1023,7 @@
         if option.dest is not None:     # option has a dest, we need a default
             if option.default is not NO_DEFAULT:
                 self.defaults[option.dest] = option.default
-            elif not self.defaults.has_key(option.dest):
+            elif option.dest not in self.defaults:
                 self.defaults[option.dest] = None
 
         return option
@@ -1039,8 +1039,8 @@
                 self._long_opt.get(opt_str))
 
     def has_option(self, opt_str):
-        return (self._short_opt.has_key(opt_str) or
-                self._long_opt.has_key(opt_str))
+        return (opt_str in self._short_opt or
+                opt_str) in self._long_opt
 
     def remove_option(self, opt_str):
         option = self._short_opt.get(opt_str)
@@ -1658,7 +1658,7 @@
     'words', raise BadOptionError.
     """
     # Is there an exact match?
-    if wordmap.has_key(s):
+    if s in wordmap:
         return s
     else:
         # Isolate all words with s as a prefix.
diff --git a/Lib/os.py b/Lib/os.py
index 2d1b29b..5ee3d4b 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -436,8 +436,6 @@
                 def __delitem__(self, key):
                     unsetenv(key)
                     del self.data[key.upper()]
-            def has_key(self, key):
-                return key.upper() in self.data
             def __contains__(self, key):
                 return key.upper() in self.data
             def get(self, key, failobj=None):
diff --git a/Lib/pickle.py b/Lib/pickle.py
index ccda3e7..b0b3aa1 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -1287,19 +1287,19 @@
     r"""Decode a long from a two's complement little-endian binary string.
 
     >>> decode_long('')
-    0L
+    0
     >>> decode_long("\xff\x00")
-    255L
+    255
     >>> decode_long("\xff\x7f")
-    32767L
+    32767
     >>> decode_long("\x00\xff")
-    -256L
+    -256
     >>> decode_long("\x00\x80")
-    -32768L
+    -32768
     >>> decode_long("\x80")
-    -128L
+    -128
     >>> decode_long("\x7f")
-    127L
+    127
     """
 
     nbytes = len(data)
diff --git a/Lib/pickletools.py b/Lib/pickletools.py
index ab5e247..941ca42 100644
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -517,23 +517,14 @@
     r"""
     >>> import StringIO
 
-    >>> read_decimalnl_long(StringIO.StringIO("1234\n56"))
-    Traceback (most recent call last):
-    ...
-    ValueError: trailing 'L' required in '1234'
-
-    Someday the trailing 'L' will probably go away from this output.
-
     >>> read_decimalnl_long(StringIO.StringIO("1234L\n56"))
-    1234L
+    1234
 
     >>> read_decimalnl_long(StringIO.StringIO("123456789012345678901234L\n6"))
-    123456789012345678901234L
+    123456789012345678901234
     """
 
     s = read_stringnl(f, decode=False, stripquotes=False)
-    if not s.endswith("L"):
-        raise ValueError("trailing 'L' required in %r" % s)
     return long(s)
 
 
@@ -625,15 +616,15 @@
     r"""
     >>> import StringIO
     >>> read_long1(StringIO.StringIO("\x00"))
-    0L
+    0
     >>> read_long1(StringIO.StringIO("\x02\xff\x00"))
-    255L
+    255
     >>> read_long1(StringIO.StringIO("\x02\xff\x7f"))
-    32767L
+    32767
     >>> read_long1(StringIO.StringIO("\x02\x00\xff"))
-    -256L
+    -256
     >>> read_long1(StringIO.StringIO("\x02\x00\x80"))
-    -32768L
+    -32768
     """
 
     n = read_uint1(f)
@@ -657,15 +648,15 @@
     r"""
     >>> import StringIO
     >>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\xff\x00"))
-    255L
+    255
     >>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\xff\x7f"))
-    32767L
+    32767
     >>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\x00\xff"))
-    -256L
+    -256
     >>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\x00\x80"))
-    -32768L
+    -32768
     >>> read_long1(StringIO.StringIO("\x00\x00\x00\x00"))
-    0L
+    0
     """
 
     n = read_int4(f)
diff --git a/Lib/platform.py b/Lib/platform.py
index 288bc95..5fd13a3 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -877,7 +877,7 @@
        executable == sys.executable:
         # "file" command did not return anything; we'll try to provide
         # some sensible defaults then...
-        if _default_architecture.has_key(sys.platform):
+        if sys.platform in _default_architecture:
             b,l = _default_architecture[sys.platform]
             if b:
                 bits = b
diff --git a/Lib/profile.py b/Lib/profile.py
index b6048aa..27d68ba 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -318,7 +318,7 @@
         fn = ("", 0, self.c_func_name)
         self.cur = (t, 0, 0, fn, frame, self.cur)
         timings = self.timings
-        if timings.has_key(fn):
+        if fn in timings:
             cc, ns, tt, ct, callers = timings[fn]
             timings[fn] = cc, ns+1, tt, ct, callers
         else:
diff --git a/Lib/pstats.py b/Lib/pstats.py
index 4e94b0c..20edd70 100644
--- a/Lib/pstats.py
+++ b/Lib/pstats.py
@@ -140,7 +140,7 @@
             self.total_calls += nc
             self.prim_calls  += cc
             self.total_tt    += tt
-            if callers.has_key(("jprofile", 0, "profiler")):
+            if ("jprofile", 0, "profiler") in callers:
                 self.top_level[func] = None
             if len(func_std_string(func)) > self.max_name_len:
                 self.max_name_len = len(func_std_string(func))
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
index d6d5e47..0ef0d97 100644
--- a/Lib/rfc822.py
+++ b/Lib/rfc822.py
@@ -428,10 +428,6 @@
             self.dict[lowername] = default
             return default
 
-    def has_key(self, name):
-        """Determine whether a message contains the named header."""
-        return name.lower() in self.dict
-
     def __contains__(self, name):
         """Determine whether a message contains the named header."""
         return name.lower() in self.dict
diff --git a/Lib/sets.py b/Lib/sets.py
index 32a0dd6..55f93a6d 100644
--- a/Lib/sets.py
+++ b/Lib/sets.py
@@ -231,7 +231,7 @@
             little, big = self, other
         else:
             little, big = other, self
-        common = ifilter(big._data.has_key, little)
+        common = ifilter(big._data.__contains__, little)
         return self.__class__(common)
 
     def __xor__(self, other):
@@ -256,9 +256,9 @@
             otherdata = other._data
         except AttributeError:
             otherdata = Set(other)._data
-        for elt in ifilterfalse(otherdata.has_key, selfdata):
+        for elt in ifilterfalse(otherdata.__contains__, selfdata):
             data[elt] = value
-        for elt in ifilterfalse(selfdata.has_key, otherdata):
+        for elt in ifilterfalse(selfdata.__contains__, otherdata):
             data[elt] = value
         return result
 
@@ -283,7 +283,7 @@
         except AttributeError:
             otherdata = Set(other)._data
         value = True
-        for elt in ifilterfalse(otherdata.has_key, self):
+        for elt in ifilterfalse(otherdata.__contains__, self):
             data[elt] = value
         return result
 
@@ -309,7 +309,7 @@
         self._binary_sanity_check(other)
         if len(self) > len(other):  # Fast check for obvious cases
             return False
-        for elt in ifilterfalse(other._data.has_key, self):
+        for elt in ifilterfalse(other._data.__contains__, self):
             return False
         return True
 
@@ -318,7 +318,7 @@
         self._binary_sanity_check(other)
         if len(self) < len(other):  # Fast check for obvious cases
             return False
-        for elt in ifilterfalse(self._data.has_key, other):
+        for elt in ifilterfalse(self._data.__contains__, other):
             return False
         return True
 
@@ -501,7 +501,7 @@
             other = Set(other)
         if self is other:
             self.clear()
-        for elt in ifilter(data.has_key, other):
+        for elt in ifilter(data.__contains__, other):
             del data[elt]
 
     # Python dict-like mass mutations: update, clear
diff --git a/Lib/shelve.py b/Lib/shelve.py
index 7a75445..2971354 100644
--- a/Lib/shelve.py
+++ b/Lib/shelve.py
@@ -20,7 +20,7 @@
                         # access returns a *copy* of the entry!
         del d[key]      # delete data stored at key (raises KeyError
                         # if no such key)
-        flag = d.has_key(key)   # true if the key exists; same as "key in d"
+        flag = key in d # true if the key exists
         list = d.keys() # a list of all existing keys (slow!)
 
         d.close()       # close it
@@ -94,14 +94,11 @@
     def __len__(self):
         return len(self.dict)
 
-    def has_key(self, key):
-        return self.dict.has_key(key)
-
     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
 
diff --git a/Lib/test/mapping_tests.py b/Lib/test/mapping_tests.py
index 4b0f797..1c570b6 100644
--- a/Lib/test/mapping_tests.py
+++ b/Lib/test/mapping_tests.py
@@ -54,12 +54,10 @@
         #len
         self.assertEqual(len(p), 0)
         self.assertEqual(len(d), len(self.reference))
-        #has_key
+        #__contains__
         for k in self.reference:
-            self.assert_(d.has_key(k))
             self.assert_(k in d)
         for k in self.other:
-            self.failIf(d.has_key(k))
             self.failIf(k in d)
         #cmp
         self.assertEqual(cmp(p,p), 0)
@@ -333,16 +331,6 @@
         d = self._full_mapping({1:2})
         self.assertEqual(d.items(), [(1, 2)])
 
-    def test_has_key(self):
-        d = self._empty_mapping()
-        self.assert_(not d.has_key('a'))
-        d = self._full_mapping({'a': 1, 'b': 2})
-        k = d.keys()
-        k.sort()
-        self.assertEqual(k, ['a', 'b'])
-
-        self.assertRaises(TypeError, d.has_key)
-
     def test_contains(self):
         d = self._empty_mapping()
         self.assert_(not ('a' in d))
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index a6e146b..8c0f2e4 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1034,7 +1034,6 @@
     'darwin':
         """
         test_al
-        test_bsddb3
         test_cd
         test_cl
         test_gdbm
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index c45e139..dba9161 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -24,7 +24,7 @@
                "%s has no __all__ attribute" % modname)
         names = {}
         exec "from %s import *" % modname in names
-        if names.has_key("__builtins__"):
+        if "__builtins__" in names:
             del names["__builtins__"]
         keys = set(names)
         all = set(sys.modules[modname].__all__)
diff --git a/Lib/test/test_bool.py b/Lib/test/test_bool.py
index 663417d..15e1ef7 100644
--- a/Lib/test/test_bool.py
+++ b/Lib/test/test_bool.py
@@ -183,9 +183,9 @@
         self.assertIs(issubclass(bool, int), True)
         self.assertIs(issubclass(int, bool), False)
 
-    def test_haskey(self):
-        self.assertIs({}.has_key(1), False)
-        self.assertIs({1:1}.has_key(1), True)
+    def test_contains(self):
+        self.assertIs(1 in {}, False)
+        self.assertIs(1 in {1:1}, True)
 
     def test_string(self):
         self.assertIs("xyz".endswith("z"), True)
diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py
index 474f3da..91c1cca 100755
--- a/Lib/test/test_bsddb.py
+++ b/Lib/test/test_bsddb.py
@@ -135,11 +135,6 @@
             self.assert_(k in self.f)
         self.assert_('not here' not in self.f)
 
-    def test_has_key(self):
-        for k in self.d:
-            self.assert_(self.f.has_key(k))
-        self.assert_(not self.f.has_key('not here'))
-
     def test_clear(self):
         self.f.clear()
         self.assertEqual(len(self.f), 0)
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index c7e4394..5797aef 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -630,9 +630,9 @@
 
     def test_hex(self):
         self.assertEqual(hex(16), '0x10')
-        self.assertEqual(hex(16L), '0x10L')
+        self.assertEqual(hex(16L), '0x10')
         self.assertEqual(hex(-16), '-0x10')
-        self.assertEqual(hex(-16L), '-0x10L')
+        self.assertEqual(hex(-16L), '-0x10')
         self.assertRaises(TypeError, hex, {})
 
     def test_id(self):
@@ -1240,9 +1240,9 @@
 
     def test_oct(self):
         self.assertEqual(oct(100), '0144')
-        self.assertEqual(oct(100L), '0144L')
+        self.assertEqual(oct(100L), '0144')
         self.assertEqual(oct(-100), '-0144')
-        self.assertEqual(oct(-100L), '-0144L')
+        self.assertEqual(oct(-100L), '-0144')
         self.assertRaises(TypeError, oct, ())
 
     def write_testfile(self):
@@ -1441,7 +1441,7 @@
     def test_repr(self):
         self.assertEqual(repr(''), '\'\'')
         self.assertEqual(repr(0), '0')
-        self.assertEqual(repr(0L), '0L')
+        self.assertEqual(repr(0L), '0')
         self.assertEqual(repr(()), '()')
         self.assertEqual(repr([]), '[]')
         self.assertEqual(repr({}), '{}')
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py
index f3c7c8c..2652343 100644
--- a/Lib/test/test_call.py
+++ b/Lib/test/test_call.py
@@ -9,39 +9,39 @@
 class CFunctionCalls(unittest.TestCase):
 
     def test_varargs0(self):
-        self.assertRaises(TypeError, {}.has_key)
+        self.assertRaises(TypeError, {}.__contains__)
 
     def test_varargs1(self):
-        {}.has_key(0)
+        {}.__contains__(0)
 
     def test_varargs2(self):
-        self.assertRaises(TypeError, {}.has_key, 0, 1)
+        self.assertRaises(TypeError, {}.__contains__, 0, 1)
 
     def test_varargs0_ext(self):
         try:
-            {}.has_key(*())
+            {}.__contains__(*())
         except TypeError:
             pass
 
     def test_varargs1_ext(self):
-        {}.has_key(*(0,))
+        {}.__contains__(*(0,))
 
     def test_varargs2_ext(self):
         try:
-            {}.has_key(*(1, 2))
+            {}.__contains__(*(1, 2))
         except TypeError:
             pass
         else:
             raise RuntimeError
 
     def test_varargs0_kw(self):
-        self.assertRaises(TypeError, {}.has_key, x=2)
+        self.assertRaises(TypeError, {}.__contains__, x=2)
 
     def test_varargs1_kw(self):
-        self.assertRaises(TypeError, {}.has_key, x=2)
+        self.assertRaises(TypeError, {}.__contains__, x=2)
 
     def test_varargs2_kw(self):
-        self.assertRaises(TypeError, {}.has_key, x=2, y=2)
+        self.assertRaises(TypeError, {}.__contains__, x=2, y=2)
 
     def test_oldargs0_0(self):
         {}.keys()
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index 130b19d..8b0b482 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -158,10 +158,10 @@
             # test individual fields
             for key in expect.keys():
                 expect_val = expect[key]
-                verify(fcd.has_key(key))
+                verify(key in fcd)
                 verify(norm(fcd[key]) == norm(expect[key]))
                 verify(fcd.get(key, "default") == fcd[key])
-                verify(fs.has_key(key))
+                verify(key in fs)
                 if len(expect_val) > 1:
                     single_value = 0
                 else:
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index e5757c9..8fdd262 100755
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -28,7 +28,7 @@
     d['a'] = 'b'
     d['12345678910'] = '019237410982340912840198242'
     d.keys()
-    if d.has_key('a'):
+    if 'a' in d:
         if verbose:
             print 'Test dbm keys: ', d.keys()
 
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index bbca798..f168846 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -21,8 +21,8 @@
         self.assertEqual(d.keys(), [])
         d = {'a': 1, 'b': 2}
         k = d.keys()
-        self.assert_(d.has_key('a'))
-        self.assert_(d.has_key('b'))
+        self.assert_('a' in d)
+        self.assert_('b' in d)
 
         self.assertRaises(TypeError, d.keys, None)
 
@@ -43,16 +43,6 @@
 
         self.assertRaises(TypeError, d.items, None)
 
-    def test_has_key(self):
-        d = {}
-        self.assert_(not d.has_key('a'))
-        d = {'a': 1, 'b': 2}
-        k = d.keys()
-        k.sort()
-        self.assertEqual(k, ['a', 'b'])
-
-        self.assertRaises(TypeError, d.has_key)
-
     def test_contains(self):
         d = {}
         self.assert_(not ('a' in d))
diff --git a/Lib/test/test_gdbm.py b/Lib/test/test_gdbm.py
index 03a47d9..e76539a 100755
--- a/Lib/test/test_gdbm.py
+++ b/Lib/test/test_gdbm.py
@@ -17,7 +17,7 @@
 if verbose:
     print 'Test gdbm file keys: ', a
 
-g.has_key('a')
+'a' in g
 g.close()
 try:
     g['a']
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index f160867..296dc9b 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -472,7 +472,7 @@
 f()
 g = {}
 exec 'z = 1' in g
-if g.has_key('__builtins__'): del g['__builtins__']
+if '__builtins__' in g: del g['__builtins__']
 if g != {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g'
 g = {}
 l = {}
@@ -480,8 +480,8 @@
 import warnings
 warnings.filterwarnings("ignore", "global statement", module="<string>")
 exec 'global a; a = 1; b = 2' in g, l
-if g.has_key('__builtins__'): del g['__builtins__']
-if l.has_key('__builtins__'): del l['__builtins__']
+if '__builtins__' in g: del g['__builtins__']
+if '__builtins__' in l: del l['__builtins__']
 if (g, l) != ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g (%s), l (%s)' %(g,l)
 
 
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 45dd118..04e856f 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -229,16 +229,9 @@
                 count += 1
             self.assert_(len(values) == count)
 
-    def test_has_key(self):
-        # Check existence of keys using has_key()
-        self._test_has_key_or_contains(self._box.has_key)
-
     def test_contains(self):
         # Check existence of keys using __contains__()
-        self._test_has_key_or_contains(self._box.__contains__)
-
-    def _test_has_key_or_contains(self, method):
-        # (Used by test_has_key() and test_contains().)
+        method = self._box.__contains__
         self.assert_(not method('foo'))
         key0 = self._box.add(self._template % 0)
         self.assert_(method(key0))
@@ -442,7 +435,7 @@
         self.assertRaises(NotImplementedError, lambda: box.get_message(''))
         self.assertRaises(NotImplementedError, lambda: box.get_string(''))
         self.assertRaises(NotImplementedError, lambda: box.get_file(''))
-        self.assertRaises(NotImplementedError, lambda: box.has_key(''))
+        self.assertRaises(NotImplementedError, lambda: '' in box)
         self.assertRaises(NotImplementedError, lambda: box.__contains__(''))
         self.assertRaises(NotImplementedError, lambda: box.__len__())
         self.assertRaises(NotImplementedError, lambda: box.clear())
diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py
index bec32de..50ed481 100644
--- a/Lib/test/test_multibytecodec_support.py
+++ b/Lib/test/test_multibytecodec_support.py
@@ -297,7 +297,7 @@
                 continue
 
             unich = unichrs(data[1])
-            if ord(unich) == 0xfffd or urt_wa.has_key(unich):
+            if ord(unich) == 0xfffd or unich in urt_wa:
                 continue
             urt_wa[unich] = csetch
 
diff --git a/Lib/test/test_operations.py b/Lib/test/test_operations.py
index fafc062..0b558de 100644
--- a/Lib/test/test_operations.py
+++ b/Lib/test/test_operations.py
@@ -25,7 +25,6 @@
 for stmt in ['d[x2] = 2',
              'z = d[x2]',
              'x2 in d',
-             'd.has_key(x2)',
              'd.get(x2)',
              'd.setdefault(x2, 42)',
              'd.pop(x2)',
diff --git a/Lib/test/test_pkgimport.py b/Lib/test/test_pkgimport.py
index c87c342..8b5e3ad 100644
--- a/Lib/test/test_pkgimport.py
+++ b/Lib/test/test_pkgimport.py
@@ -6,14 +6,14 @@
 
     def __init__(self, *args, **kw):
         self.package_name = 'PACKAGE_'
-        while sys.modules.has_key(self.package_name):
+        while self.package_name in sys.modules:
             self.package_name += random.choose(string.letters)
         self.module_name = self.package_name + '.foo'
         unittest.TestCase.__init__(self, *args, **kw)
 
     def remove_modules(self):
         for module_name in (self.package_name, self.module_name):
-            if sys.modules.has_key(module_name):
+            if module_name in sys.modules:
                 del sys.modules[module_name]
 
     def setUp(self):
@@ -52,7 +52,7 @@
         try: __import__(self.module_name)
         except SyntaxError: pass
         else: raise RuntimeError, 'Failed to induce SyntaxError'
-        self.assert_(not sys.modules.has_key(self.module_name) and
+        self.assert_(self.module_name not in sys.modules and
                      not hasattr(sys.modules[self.package_name], 'foo'))
 
         # ...make up a variable name that isn't bound in __builtins__
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 2410b03..01703b5 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -40,11 +40,11 @@
 
 
     def assertHaskey(self, obj, key, ignore):
-        ''' succeed iff obj.has_key(key) or key in ignore. '''
+        ''' succeed iff key in obj or key in ignore. '''
         if key in ignore: return
-        if not obj.has_key(key):
+        if key not in obj:
             print >>sys.stderr, "***",key
-        self.failUnless(obj.has_key(key))
+        self.failUnless(key) in obj
 
     def assertEqualsOrIgnored(self, a, b, ignore):
         ''' succeed iff a == b or a in ignore or b in ignore '''
diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py
index 6d22825..de577da 100644
--- a/Lib/test/test_rfc822.py
+++ b/Lib/test/test_rfc822.py
@@ -25,7 +25,7 @@
     def test_setdefault(self):
         msg = self.create_message(
             'To: "last, first" <userid@foo.net>\n\ntest\n')
-        self.assert_(not msg.has_key("New-Header"))
+        self.assert_("New-Header" not in msg)
         self.assert_(msg.setdefault("New-Header", "New-Value") == "New-Value")
         self.assert_(msg.setdefault("New-Header", "Different-Value")
                      == "New-Value")
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index af4c7dd..83ffcf1 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -357,7 +357,7 @@
            attrs.getNames() == [(ns_uri, "attr")] and \
            (attrs.getQNames() == [] or attrs.getQNames() == ["ns:attr"]) and \
            len(attrs) == 1 and \
-           attrs.has_key((ns_uri, "attr")) and \
+           (ns_uri, "attr") in attrs and \
            attrs.keys() == [(ns_uri, "attr")] and \
            attrs.get((ns_uri, "attr")) == "val" and \
            attrs.get((ns_uri, "attr"), 25) == "val" and \
@@ -571,7 +571,7 @@
            attrs.getNames() == [] and \
            attrs.getQNames() == [] and \
            len(attrs) == 0 and \
-           not attrs.has_key("attr") and \
+           "attr" not in  attrs and \
            attrs.keys() == [] and \
            attrs.get("attrs") is None and \
            attrs.get("attrs", 25) == 25 and \
@@ -584,7 +584,7 @@
            attrs.getNames() == ["attr"] and \
            attrs.getQNames() == ["attr"] and \
            len(attrs) == 1 and \
-           attrs.has_key("attr") and \
+           "attr" in attrs and \
            attrs.keys() == ["attr"] and \
            attrs.get("attr") == "val" and \
            attrs.get("attr", 25) == "val" and \
@@ -639,7 +639,7 @@
            attrs.getNames() == [] and \
            attrs.getQNames() == [] and \
            len(attrs) == 0 and \
-           not attrs.has_key((ns_uri, "attr")) and \
+           (ns_uri, "attr") not in attrs and \
            attrs.keys() == [] and \
            attrs.get((ns_uri, "attr")) is None and \
            attrs.get((ns_uri, "attr"), 25) == 25 and \
@@ -658,7 +658,7 @@
            attrs.getNames() == [(ns_uri, "attr")] and \
            attrs.getQNames() == ["ns:attr"] and \
            len(attrs) == 1 and \
-           attrs.has_key((ns_uri, "attr")) and \
+           (ns_uri, "attr") in attrs and \
            attrs.keys() == [(ns_uri, "attr")] and \
            attrs.get((ns_uri, "attr")) == "val" and \
            attrs.get((ns_uri, "attr"), 25) == "val" and \
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py
index 239745c..98b7ef3 100644
--- a/Lib/test/test_scope.py
+++ b/Lib/test/test_scope.py
@@ -472,7 +472,7 @@
     return g
 
 d = f(2)(4)
-verify(d.has_key('h'))
+verify('h' in d)
 del d['h']
 vereq(d, {'x': 2, 'y': 7, 'w': 6})
 
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 3a8b9d3..05a4ac4 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -216,7 +216,7 @@
 
     def test_sitecustomize_executed(self):
         # If sitecustomize is available, it should have been imported.
-        if not sys.modules.has_key("sitecustomize"):
+        if "sitecustomize" not in sys.modules:
             try:
                 import sitecustomize
             except ImportError:
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 66fd667..302698b 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -266,7 +266,7 @@
             if x < 0:
                 expected += 1L << self.bitsize
                 assert expected > 0
-            expected = hex(expected)[2:-1] # chop "0x" and trailing 'L'
+            expected = hex(expected)[2:] # chop "0x"
             if len(expected) & 1:
                 expected = "0" + expected
             expected = unhexlify(expected)
@@ -322,7 +322,7 @@
             # Try big-endian.
             format = ">" + code
             expected = long(x)
-            expected = hex(expected)[2:-1] # chop "0x" and trailing 'L'
+            expected = hex(expected)[2:] # chop "0x"
             if len(expected) & 1:
                 expected = "0" + expected
             expected = unhexlify(expected)
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index f4be759..4fd7834 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -180,7 +180,7 @@
             # rely on it.
             if org_TZ is not None:
                 environ['TZ'] = org_TZ
-            elif environ.has_key('TZ'):
+            elif 'TZ' in environ:
                 del environ['TZ']
             time.tzset()
 
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 67218b8..4df854e 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -653,7 +653,7 @@
             r.info; r.geturl  # addinfourl methods
             r.code, r.msg == 200, "OK"  # added from MockHTTPClass.getreply()
             hdrs = r.info()
-            hdrs.get; hdrs.has_key  # r.info() gives dict from .getreply()
+            hdrs.get; hdrs.__contains__  # r.info() gives dict from .getreply()
             self.assertEqual(r.geturl(), url)
 
             self.assertEqual(http.host, "example.com")
diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py
index a4b7de4..ecb33d1 100644
--- a/Lib/test/test_userdict.py
+++ b/Lib/test/test_userdict.py
@@ -94,13 +94,10 @@
         self.assertEqual(u2.items(), d2.items())
         self.assertEqual(u2.values(), d2.values())
 
-        # Test has_key and "in".
+        # Test "in".
         for i in u2.keys():
-            self.assert_(u2.has_key(i))
             self.assert_(i in u2)
-            self.assertEqual(u1.has_key(i), d1.has_key(i))
             self.assertEqual(i in u1, i in d1)
-            self.assertEqual(u0.has_key(i), d0.has_key(i))
             self.assertEqual(i in u0, i in d0)
 
         # Test update
@@ -132,7 +129,7 @@
         # Test setdefault
         t = UserDict.UserDict()
         self.assertEqual(t.setdefault("x", 42), 42)
-        self.assert_(t.has_key("x"))
+        self.assert_("x" in t)
         self.assertEqual(t.setdefault("x", 23), 42)
 
         # Test pop
@@ -269,9 +266,6 @@
         self.assertEqual(s.keys(), [10, 30])
 
         ## Now, test the DictMixin methods one by one
-        # has_key
-        self.assert_(s.has_key(10))
-        self.assert_(not s.has_key(20))
 
         # __contains__
         self.assert_(10 in s)
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 1f65010..a4fb7f3 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -739,7 +739,7 @@
     def test_weak_keys(self):
         #
         #  This exercises d.copy(), d.items(), d[] = v, d[], del d[],
-        #  len(d), d.has_key().
+        #  len(d), k in d.
         #
         dict, objects = self.make_weak_keyed_dict()
         for o in objects:
@@ -761,8 +761,8 @@
                      "deleting the keys did not clear the dictionary")
         o = Object(42)
         dict[o] = "What is the meaning of the universe?"
-        self.assert_(dict.has_key(o))
-        self.assert_(not dict.has_key(34))
+        self.assert_(o in dict)
+        self.assert_(34 not in dict)
 
     def test_weak_keyed_iters(self):
         dict, objects = self.make_weak_keyed_dict()
@@ -774,7 +774,7 @@
         objects2 = list(objects)
         for wr in refs:
             ob = wr()
-            self.assert_(dict.has_key(ob))
+            self.assert_(ob in dict)
             self.assert_(ob in dict)
             self.assertEqual(ob.arg, dict[ob])
             objects2.remove(ob)
@@ -785,7 +785,7 @@
         self.assertEqual(len(list(dict.iterkeyrefs())), len(objects))
         for wr in dict.iterkeyrefs():
             ob = wr()
-            self.assert_(dict.has_key(ob))
+            self.assert_(ob in dict)
             self.assert_(ob in dict)
             self.assertEqual(ob.arg, dict[ob])
             objects2.remove(ob)
@@ -900,13 +900,13 @@
         weakdict = klass()
         o = weakdict.setdefault(key, value1)
         self.assert_(o is value1)
-        self.assert_(weakdict.has_key(key))
+        self.assert_(key in weakdict)
         self.assert_(weakdict.get(key) is value1)
         self.assert_(weakdict[key] is value1)
 
         o = weakdict.setdefault(key, value2)
         self.assert_(o is value1)
-        self.assert_(weakdict.has_key(key))
+        self.assert_(key in weakdict)
         self.assert_(weakdict.get(key) is value1)
         self.assert_(weakdict[key] is value1)
 
@@ -920,20 +920,20 @@
 
     def check_update(self, klass, dict):
         #
-        #  This exercises d.update(), len(d), d.keys(), d.has_key(),
+        #  This exercises d.update(), len(d), d.keys(), k in d,
         #  d.get(), d[].
         #
         weakdict = klass()
         weakdict.update(dict)
         self.assert_(len(weakdict) == len(dict))
         for k in weakdict.keys():
-            self.assert_(dict.has_key(k),
+            self.assert_(k in dict,
                          "mysterious new key appeared in weak dict")
             v = dict.get(k)
             self.assert_(v is weakdict[k])
             self.assert_(v is weakdict.get(k))
         for k in dict.keys():
-            self.assert_(weakdict.has_key(k),
+            self.assert_(k in weakdict,
                          "original key disappeared in weak dict")
             v = dict[k]
             self.assert_(v is weakdict[k])
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py
index 1ec271b..b42f437 100755
--- a/Lib/test/test_wsgiref.py
+++ b/Lib/test/test_wsgiref.py
@@ -341,7 +341,7 @@
         del h['foo']   # should not raise an error
 
         h['Foo'] = 'bar'
-        for m in h.has_key, h.__contains__, h.get, h.get_all, h.__getitem__:
+        for m in h.__contains__, h.get, h.get_all, h.__getitem__:
             self.failUnless(m('foo'))
             self.failUnless(m('Foo'))
             self.failUnless(m('FOO'))
@@ -424,10 +424,10 @@
         env = handler.environ
         from os import environ
         for k,v in environ.items():
-            if not empty.has_key(k):
+            if k not in empty:
                 self.assertEqual(env[k],v)
         for k,v in empty.items():
-            self.failUnless(env.has_key(k))
+            self.failUnless(k in env)
 
     def testEnviron(self):
         h = TestHandler(X="Y")
@@ -440,7 +440,7 @@
         h = BaseCGIHandler(None,None,None,{})
         h.setup_environ()
         for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors':
-            self.assert_(h.environ.has_key(key))
+            self.assert_(key in h.environ)
 
     def testScheme(self):
         h=TestHandler(HTTPS="on"); h.setup_environ()
diff --git a/Lib/trace.py b/Lib/trace.py
index db36e1d..e70869c 100644
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -120,7 +120,7 @@
         self._ignore = { '<string>': 1 }
 
     def names(self, filename, modulename):
-        if self._ignore.has_key(modulename):
+        if modulename in self._ignore:
             return self._ignore[modulename]
 
         # haven't seen this one before, so see if the module name is
diff --git a/Lib/unittest.py b/Lib/unittest.py
index cde23d8..b34b389 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -153,7 +153,7 @@
         return ''.join(traceback.format_exception(exctype, value, tb))
 
     def _is_relevant_tb_level(self, tb):
-        return tb.tb_frame.f_globals.has_key('__unittest')
+        return '__unittest' in tb.tb_frame.f_globals
 
     def _count_relevant_tb_levels(self, tb):
         length = 0
diff --git a/Lib/urllib.py b/Lib/urllib.py
index d2a4c48..e01f421 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -114,7 +114,7 @@
     def __init__(self, proxies=None, **x509):
         if proxies is None:
             proxies = getproxies()
-        assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
+        assert hasattr(proxies, 'keys'), "proxies must be a mapping"
         self.proxies = proxies
         self.key_file = x509.get('key_file')
         self.cert_file = x509.get('cert_file')
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index 6ee9e2c..93cadd7 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -660,7 +660,7 @@
     def __init__(self, proxies=None):
         if proxies is None:
             proxies = getproxies()
-        assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
+        assert hasattr(proxies, 'keys'), "proxies must be a mapping"
         self.proxies = proxies
         for type, url in proxies.items():
             setattr(self, '%s_open' % type,
diff --git a/Lib/weakref.py b/Lib/weakref.py
index 4f6d757..44cf9a7 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -64,13 +64,6 @@
             return False
         return o is not None
 
-    def has_key(self, key):
-        try:
-            o = self.data[key]()
-        except KeyError:
-            return False
-        return o is not None
-
     def __repr__(self):
         return "<WeakValueDictionary at %s>" % id(self)
 
@@ -259,13 +252,6 @@
     def get(self, key, default=None):
         return self.data.get(ref(key),default)
 
-    def has_key(self, key):
-        try:
-            wr = ref(key)
-        except TypeError:
-            return 0
-        return wr in self.data
-
     def __contains__(self, key):
         try:
             wr = ref(key)
diff --git a/Lib/wsgiref/handlers.py b/Lib/wsgiref/handlers.py
index cc3a805..fb81bf3 100644
--- a/Lib/wsgiref/handlers.py
+++ b/Lib/wsgiref/handlers.py
@@ -159,7 +159,7 @@
 
         Subclasses can extend this to add other defaults.
         """
-        if not self.headers.has_key('Content-Length'):
+        if 'Content-Length' not in self.headers:
             self.set_content_length()
 
     def start_response(self, status, headers,exc_info=None):
@@ -194,11 +194,11 @@
         if self.origin_server:
             if self.client_is_modern():
                 self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
-                if not self.headers.has_key('Date'):
+                if 'Date' not in self.headers:
                     self._write(
                         'Date: %s\r\n' % format_date_time(time.time())
                     )
-                if self.server_software and not self.headers.has_key('Server'):
+                if self.server_software and 'Server' not in self.headers:
                     self._write('Server: %s\r\n' % self.server_software)
         else:
             self._write('Status: %s\r\n' % self.status)
diff --git a/Lib/wsgiref/headers.py b/Lib/wsgiref/headers.py
index 016eb86..934a645 100644
--- a/Lib/wsgiref/headers.py
+++ b/Lib/wsgiref/headers.py
@@ -80,12 +80,10 @@
 
 
 
-    def has_key(self, name):
+    def __contains__(self, name):
         """Return true if the message contains the header."""
         return self.get(name) is not None
 
-    __contains__ = has_key
-
 
     def get_all(self, name):
         """Return a list of all the values for the named field.
diff --git a/Lib/wsgiref/util.py b/Lib/wsgiref/util.py
index 9009b87..17fdff6 100644
--- a/Lib/wsgiref/util.py
+++ b/Lib/wsgiref/util.py
@@ -166,7 +166,7 @@
     'connection':1, 'keep-alive':1, 'proxy-authenticate':1,
     'proxy-authorization':1, 'te':1, 'trailers':1, 'transfer-encoding':1,
     'upgrade':1
-}.has_key
+}.__contains__
 
 def is_hop_by_hop(header_name):
     """Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header"""
diff --git a/Lib/wsgiref/validate.py b/Lib/wsgiref/validate.py
index 23ab9f8..43784f9 100644
--- a/Lib/wsgiref/validate.py
+++ b/Lib/wsgiref/validate.py
@@ -345,7 +345,7 @@
             "Invalid CONTENT_LENGTH: %r" % environ['CONTENT_LENGTH'])
 
     if not environ.get('SCRIPT_NAME'):
-        assert_(environ.has_key('PATH_INFO'),
+        assert_('PATH_INFO' in environ,
             "One of SCRIPT_NAME or PATH_INFO are required (PATH_INFO "
             "should at least be '/' if SCRIPT_NAME is empty)")
     assert_(environ.get('SCRIPT_NAME') != '/',
diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py
index 2938f29..d1bd2d8 100644
--- a/Lib/xmlrpclib.py
+++ b/Lib/xmlrpclib.py
@@ -686,7 +686,7 @@
 
     def dump_array(self, value, write):
         i = id(value)
-        if self.memo.has_key(i):
+        if i in self.memo:
             raise TypeError, "cannot marshal recursive sequences"
         self.memo[i] = None
         dump = self.__dump
@@ -700,7 +700,7 @@
 
     def dump_struct(self, value, write, escape=escape):
         i = id(value)
-        if self.memo.has_key(i):
+        if i in self.memo:
             raise TypeError, "cannot marshal recursive dictionaries"
         self.memo[i] = None
         dump = self.__dump