[Python-checkins] r75305 - in python/trunk/Lib: bdb.py curses/has_key.py email/message.py encodings/__init__.py hotshot/log.py idlelib/EditorWindow.py idlelib/FileList.py idlelib/MultiCall.py idlelib/MultiStatusBar.py idlelib/ObjectBrowser.py idlelib/PathBrowser.py idlelib/RemoteDebugger.py idlelib/TreeWidget.py idlelib/configDialog.py idlelib/rpc.py lib-tk/FileDialog.py lib-tk/FixTk.py lib-tk/Tix.py lib-tk/Tkinter.py lib-tk/tkSimpleDialog.py lib-tk/turtle.py msilib/__init__.py trace.py wsgiref/handlers.py wsgiref/validate.py xml/dom/domreg.py xml/dom/minidom.py xml/dom/xmlbuilder.py xml/sax/__init__.py

benjamin.peterson python-checkins at python.org
Sat Oct 10 00:15:51 CEST 2009


Author: benjamin.peterson
Date: Sat Oct 10 00:15:50 2009
New Revision: 75305

Log:
replace has_key with 'in' operator

Modified:
   python/trunk/Lib/bdb.py
   python/trunk/Lib/curses/has_key.py
   python/trunk/Lib/email/message.py
   python/trunk/Lib/encodings/__init__.py
   python/trunk/Lib/hotshot/log.py
   python/trunk/Lib/idlelib/EditorWindow.py
   python/trunk/Lib/idlelib/FileList.py
   python/trunk/Lib/idlelib/MultiCall.py
   python/trunk/Lib/idlelib/MultiStatusBar.py
   python/trunk/Lib/idlelib/ObjectBrowser.py
   python/trunk/Lib/idlelib/PathBrowser.py
   python/trunk/Lib/idlelib/RemoteDebugger.py
   python/trunk/Lib/idlelib/TreeWidget.py
   python/trunk/Lib/idlelib/configDialog.py
   python/trunk/Lib/idlelib/rpc.py
   python/trunk/Lib/lib-tk/FileDialog.py
   python/trunk/Lib/lib-tk/FixTk.py
   python/trunk/Lib/lib-tk/Tix.py
   python/trunk/Lib/lib-tk/Tkinter.py
   python/trunk/Lib/lib-tk/tkSimpleDialog.py
   python/trunk/Lib/lib-tk/turtle.py
   python/trunk/Lib/msilib/__init__.py
   python/trunk/Lib/trace.py
   python/trunk/Lib/wsgiref/handlers.py
   python/trunk/Lib/wsgiref/validate.py
   python/trunk/Lib/xml/dom/domreg.py
   python/trunk/Lib/xml/dom/minidom.py
   python/trunk/Lib/xml/dom/xmlbuilder.py
   python/trunk/Lib/xml/sax/__init__.py

Modified: python/trunk/Lib/bdb.py
==============================================================================
--- python/trunk/Lib/bdb.py	(original)
+++ python/trunk/Lib/bdb.py	Sat Oct 10 00:15:50 2009
@@ -257,7 +257,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]
@@ -464,7 +464,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]

Modified: python/trunk/Lib/curses/has_key.py
==============================================================================
--- python/trunk/Lib/curses/has_key.py	(original)
+++ python/trunk/Lib/curses/has_key.py	Sat Oct 10 00:15:50 2009
@@ -182,7 +182,7 @@
         L = []
         _curses.initscr()
         for key in _capability_names.keys():
-            system = _curses.has_key(key)
+            system = key in _curses
             python = has_key(key)
             if system != python:
                 L.append( 'Mismatch for key %s, system=%i, Python=%i'

Modified: python/trunk/Lib/email/message.py
==============================================================================
--- python/trunk/Lib/email/message.py	(original)
+++ python/trunk/Lib/email/message.py	Sat Oct 10 00:15:50 2009
@@ -249,16 +249,16 @@
         # BAW: should we accept strings that can serve as arguments to the
         # Charset constructor?
         self._charset = charset
-        if not self.has_key('MIME-Version'):
+        if 'MIME-Version' not in self:
             self.add_header('MIME-Version', '1.0')
-        if not self.has_key('Content-Type'):
+        if 'Content-Type' not in self:
             self.add_header('Content-Type', 'text/plain',
                             charset=charset.get_output_charset())
         else:
             self.set_param('charset', charset.get_output_charset())
         if str(charset) != charset.get_output_charset():
             self._payload = charset.body_encode(self._payload)
-        if not self.has_key('Content-Transfer-Encoding'):
+        if 'Content-Transfer-Encoding' not in self:
             cte = charset.get_body_encoding()
             try:
                 cte(self)
@@ -551,7 +551,7 @@
         VALUE item in the 3-tuple) is always unquoted, unless unquote is set
         to False.
         """
-        if not self.has_key(header):
+        if header not in self:
             return failobj
         for k, v in self._get_params_preserve(failobj, header):
             if k.lower() == param.lower():
@@ -582,7 +582,7 @@
         if not isinstance(value, tuple) and charset:
             value = (charset, language, value)
 
-        if not self.has_key(header) and header.lower() == 'content-type':
+        if header not in self and header.lower() == 'content-type':
             ctype = 'text/plain'
         else:
             ctype = self.get(header)
@@ -617,7 +617,7 @@
         False.  Optional header specifies an alternative to the Content-Type
         header.
         """
-        if not self.has_key(header):
+        if header not in self:
             return
         new_ctype = ''
         for p, v in self.get_params(header=header, unquote=requote):
@@ -653,7 +653,7 @@
         if header.lower() == 'content-type':
             del self['mime-version']
             self['MIME-Version'] = '1.0'
-        if not self.has_key(header):
+        if header not in self:
             self[header] = type
             return
         params = self.get_params(header=header, unquote=requote)

Modified: python/trunk/Lib/encodings/__init__.py
==============================================================================
--- python/trunk/Lib/encodings/__init__.py	(original)
+++ python/trunk/Lib/encodings/__init__.py	Sat Oct 10 00:15:50 2009
@@ -147,7 +147,7 @@
         pass
     else:
         for alias in codecaliases:
-            if not _aliases.has_key(alias):
+            if alias not in _aliases:
                 _aliases[alias] = modname
 
     # Return the registry entry

Modified: python/trunk/Lib/hotshot/log.py
==============================================================================
--- python/trunk/Lib/hotshot/log.py	(original)
+++ python/trunk/Lib/hotshot/log.py	Sat Oct 10 00:15:50 2009
@@ -30,7 +30,7 @@
         self._reader = _hotshot.logreader(logfn)
         self._nextitem = self._reader.next
         self._info = self._reader.info
-        if self._info.has_key('current-directory'):
+        if 'current-directory' in self._info:
             self.cwd = self._info['current-directory']
         else:
             self.cwd = None

Modified: python/trunk/Lib/idlelib/EditorWindow.py
==============================================================================
--- python/trunk/Lib/idlelib/EditorWindow.py	(original)
+++ python/trunk/Lib/idlelib/EditorWindow.py	Sat Oct 10 00:15:50 2009
@@ -705,8 +705,8 @@
                     if accel:
                         itemName = menu.entrycget(index, 'label')
                         event = ''
-                        if menuEventDict.has_key(menubarItem):
-                            if menuEventDict[menubarItem].has_key(itemName):
+                        if menubarItem in menuEventDict:
+                            if itemName in menuEventDict[menubarItem]:
                                 event = menuEventDict[menubarItem][itemName]
                         if event:
                             accel = get_accelerator(keydefs, event)

Modified: python/trunk/Lib/idlelib/FileList.py
==============================================================================
--- python/trunk/Lib/idlelib/FileList.py	(original)
+++ python/trunk/Lib/idlelib/FileList.py	Sat Oct 10 00:15:50 2009
@@ -25,7 +25,7 @@
                 master=self.root)
             return None
         key = os.path.normcase(filename)
-        if self.dict.has_key(key):
+        if key in self.dict:
             edit = self.dict[key]
             edit.top.wakeup()
             return edit
@@ -79,7 +79,7 @@
         newkey = os.path.normcase(filename)
         if newkey == key:
             return
-        if self.dict.has_key(newkey):
+        if newkey in self.dict:
             conflict = self.dict[newkey]
             self.inversedict[conflict] = None
             tkMessageBox.showerror(

Modified: python/trunk/Lib/idlelib/MultiCall.py
==============================================================================
--- python/trunk/Lib/idlelib/MultiCall.py	(original)
+++ python/trunk/Lib/idlelib/MultiCall.py	Sat Oct 10 00:15:50 2009
@@ -185,7 +185,7 @@
                                                           seq, handler)))
 
     def bind(self, triplet, func):
-        if not self.bindedfuncs.has_key(triplet[2]):
+        if triplet[2] not in self.bindedfuncs:
             self.bindedfuncs[triplet[2]] = [[] for s in _states]
             for s in _states:
                 lists = [ self.bindedfuncs[detail][i]

Modified: python/trunk/Lib/idlelib/MultiStatusBar.py
==============================================================================
--- python/trunk/Lib/idlelib/MultiStatusBar.py	(original)
+++ python/trunk/Lib/idlelib/MultiStatusBar.py	Sat Oct 10 00:15:50 2009
@@ -9,7 +9,7 @@
         self.labels = {}
 
     def set_label(self, name, text='', side=LEFT):
-        if not self.labels.has_key(name):
+        if name not in self.labels:
             label = Label(self, bd=1, relief=SUNKEN, anchor=W)
             label.pack(side=side)
             self.labels[name] = label

Modified: python/trunk/Lib/idlelib/ObjectBrowser.py
==============================================================================
--- python/trunk/Lib/idlelib/ObjectBrowser.py	(original)
+++ python/trunk/Lib/idlelib/ObjectBrowser.py	Sat Oct 10 00:15:50 2009
@@ -126,7 +126,7 @@
 
 def make_objecttreeitem(labeltext, object, setfunction=None):
     t = type(object)
-    if dispatch.has_key(t):
+    if t in dispatch:
         c = dispatch[t]
     else:
         c = ObjectTreeItem

Modified: python/trunk/Lib/idlelib/PathBrowser.py
==============================================================================
--- python/trunk/Lib/idlelib/PathBrowser.py	(original)
+++ python/trunk/Lib/idlelib/PathBrowser.py	Sat Oct 10 00:15:50 2009
@@ -78,7 +78,7 @@
                 normed_name = os.path.normcase(name)
                 if normed_name[i:] == suff:
                     mod_name = name[:i]
-                    if not modules.has_key(mod_name):
+                    if mod_name not in modules:
                         modules[mod_name] = None
                         sorted.append((normed_name, name))
                         allnames.remove(name)

Modified: python/trunk/Lib/idlelib/RemoteDebugger.py
==============================================================================
--- python/trunk/Lib/idlelib/RemoteDebugger.py	(original)
+++ python/trunk/Lib/idlelib/RemoteDebugger.py	Sat Oct 10 00:15:50 2009
@@ -230,7 +230,7 @@
         return self._get_dict_proxy(did)
 
     def _get_dict_proxy(self, did):
-        if self._dictcache.has_key(did):
+        if did in self._dictcache:
             return self._dictcache[did]
         dp = DictProxy(self._conn, self._oid, did)
         self._dictcache[did] = dp

Modified: python/trunk/Lib/idlelib/TreeWidget.py
==============================================================================
--- python/trunk/Lib/idlelib/TreeWidget.py	(original)
+++ python/trunk/Lib/idlelib/TreeWidget.py	Sat Oct 10 00:15:50 2009
@@ -409,7 +409,7 @@
 
 class ScrolledCanvas:
     def __init__(self, master, **opts):
-        if not opts.has_key('yscrollincrement'):
+        if 'yscrollincrement' not in opts:
             opts['yscrollincrement'] = 17
         self.master = master
         self.frame = Frame(master)

Modified: python/trunk/Lib/idlelib/configDialog.py
==============================================================================
--- python/trunk/Lib/idlelib/configDialog.py	(original)
+++ python/trunk/Lib/idlelib/configDialog.py	Sat Oct 10 00:15:50 2009
@@ -562,7 +562,7 @@
 
     def AddChangedItem(self,type,section,item,value):
         value=str(value) #make sure we use a string
-        if not self.changedItems[type].has_key(section):
+        if section not in self.changedItems[type]:
             self.changedItems[type][section]={}
         self.changedItems[type][section][item]=value
 
@@ -709,7 +709,7 @@
             return
         #remove key set from config
         idleConf.userCfg['keys'].remove_section(keySetName)
-        if self.changedItems['keys'].has_key(keySetName):
+        if keySetName in self.changedItems['keys']:
             del(self.changedItems['keys'][keySetName])
         #write changes
         idleConf.userCfg['keys'].Save()
@@ -736,7 +736,7 @@
             return
         #remove theme from config
         idleConf.userCfg['highlight'].remove_section(themeName)
-        if self.changedItems['highlight'].has_key(themeName):
+        if themeName in self.changedItems['highlight']:
             del(self.changedItems['highlight'][themeName])
         #write changes
         idleConf.userCfg['highlight'].Save()
@@ -871,9 +871,9 @@
             #handle any unsaved changes to this theme
             if theme in self.changedItems['highlight'].keys():
                 themeDict=self.changedItems['highlight'][theme]
-                if themeDict.has_key(element+'-foreground'):
+                if element+'-foreground' in themeDict:
                     colours['foreground']=themeDict[element+'-foreground']
-                if themeDict.has_key(element+'-background'):
+                if element+'-background' in themeDict:
                     colours['background']=themeDict[element+'-background']
             self.textHighlightSample.tag_config(element, **colours)
         self.SetColourSample()

Modified: python/trunk/Lib/idlelib/rpc.py
==============================================================================
--- python/trunk/Lib/idlelib/rpc.py	(original)
+++ python/trunk/Lib/idlelib/rpc.py	Sat Oct 10 00:15:50 2009
@@ -169,7 +169,7 @@
             how, (oid, methodname, args, kwargs) = request
         except TypeError:
             return ("ERROR", "Bad request format")
-        if not self.objtable.has_key(oid):
+        if oid not in self.objtable:
             return ("ERROR", "Unknown object id: %r" % (oid,))
         obj = self.objtable[oid]
         if methodname == "__methods__":
@@ -304,7 +304,7 @@
             # wait for notification from socket handling thread
             cvar = self.cvars[myseq]
             cvar.acquire()
-            while not self.responses.has_key(myseq):
+            while myseq not in self.responses:
                 cvar.wait()
             response = self.responses[myseq]
             self.debug("_getresponse:%s: thread woke up: response: %s" %
@@ -550,7 +550,7 @@
             return MethodProxy(self.sockio, self.oid, name)
         if self.__attributes is None:
             self.__getattributes()
-        if self.__attributes.has_key(name):
+        if name in self.__attributes:
             value = self.sockio.remotecall(self.oid, '__getattribute__',
                                            (name,), {})
             return value

Modified: python/trunk/Lib/lib-tk/FileDialog.py
==============================================================================
--- python/trunk/Lib/lib-tk/FileDialog.py	(original)
+++ python/trunk/Lib/lib-tk/FileDialog.py	Sat Oct 10 00:15:50 2009
@@ -107,7 +107,7 @@
         self.top.bind('<Alt-W>', self.cancel_command)
 
     def go(self, dir_or_file=os.curdir, pattern="*", default="", key=None):
-        if key and dialogstates.has_key(key):
+        if key and key in dialogstates:
             self.directory, pattern = dialogstates[key]
         else:
             dir_or_file = os.path.expanduser(dir_or_file)

Modified: python/trunk/Lib/lib-tk/FixTk.py
==============================================================================
--- python/trunk/Lib/lib-tk/FixTk.py	(original)
+++ python/trunk/Lib/lib-tk/FixTk.py	Sat Oct 10 00:15:50 2009
@@ -52,7 +52,7 @@
 # if this does not exist, no further search is needed
 if os.path.exists(prefix):
     prefix = convert_path(prefix)
-    if not os.environ.has_key("TCL_LIBRARY"):
+    if "TCL_LIBRARY" not in os.environ:
         for name in os.listdir(prefix):
             if name.startswith("tcl"):
                 tcldir = os.path.join(prefix,name)
@@ -62,13 +62,13 @@
     # as Tcl
     import _tkinter
     ver = str(_tkinter.TCL_VERSION)
-    if not os.environ.has_key("TK_LIBRARY"):
+    if "TK_LIBRARY" not in os.environ:
         v = os.path.join(prefix, 'tk'+ver)
         if os.path.exists(os.path.join(v, "tclIndex")):
             os.environ['TK_LIBRARY'] = v
     # We don't know the Tix version, so we must search the entire
     # directory
-    if not os.environ.has_key("TIX_LIBRARY"):
+    if "TIX_LIBRARY" not in os.environ:
         for name in os.listdir(prefix):
             if name.startswith("tix"):
                 tixdir = os.path.join(prefix,name)

Modified: python/trunk/Lib/lib-tk/Tix.py
==============================================================================
--- python/trunk/Lib/lib-tk/Tix.py	(original)
+++ python/trunk/Lib/lib-tk/Tix.py	Sat Oct 10 00:15:50 2009
@@ -336,7 +336,7 @@
     # We can even do w.ok.invoke() because w.ok is subclassed from the
     # Button class if you go through the proper constructors
     def __getattr__(self, name):
-        if self.subwidget_list.has_key(name):
+        if name in self.subwidget_list:
             return self.subwidget_list[name]
         raise AttributeError, name
 
@@ -464,9 +464,9 @@
         # also destroys the parent NoteBook thus leading to an exception
         # in Tkinter when it finally calls Tcl to destroy the NoteBook
         for c in self.children.values(): c.destroy()
-        if self.master.children.has_key(self._name):
+        if self._name in self.master.children:
             del self.master.children[self._name]
-        if self.master.subwidget_list.has_key(self._name):
+        if self._name in self.master.subwidget_list:
             del self.master.subwidget_list[self._name]
         if self.destroy_physically:
             # This is bypassed only for a few widgets
@@ -488,8 +488,8 @@
 
     def __init__(self, itemtype, cnf={}, **kw):
         master = _default_root              # global from Tkinter
-        if not master and cnf.has_key('refwindow'): master=cnf['refwindow']
-        elif not master and kw.has_key('refwindow'):  master= kw['refwindow']
+        if not master and 'refwindow' in cnf: master=cnf['refwindow']
+        elif not master and 'refwindow' in kw:  master= kw['refwindow']
         elif not master: raise RuntimeError, "Too early to create display style: no root window"
         self.tk = master.tk
         self.stylename = self.tk.call('tixDisplayStyle', itemtype,
@@ -571,7 +571,7 @@
         return btn
 
     def invoke(self, name):
-        if self.subwidget_list.has_key(name):
+        if name in self.subwidget_list:
             self.tk.call(self._w, 'invoke', name)
 
 class ComboBox(TixWidget):
@@ -1433,7 +1433,7 @@
         self.subwidget_list['help'] = _dummyButton(self, 'help')
 
     def invoke(self, name):
-        if self.subwidget_list.has_key(name):
+        if name in self.subwidget_list:
             self.tk.call(self._w, 'invoke', name)
 
 class TList(TixWidget, XView, YView):

Modified: python/trunk/Lib/lib-tk/Tkinter.py
==============================================================================
--- python/trunk/Lib/lib-tk/Tkinter.py	(original)
+++ python/trunk/Lib/lib-tk/Tkinter.py	Sat Oct 10 00:15:50 2009
@@ -547,7 +547,7 @@
 
         A widget specified for the optional displayof keyword
         argument specifies the target display."""
-        if not kw.has_key('displayof'): kw['displayof'] = self._w
+        if 'displayof' not in kw: kw['displayof'] = self._w
         self.tk.call(('clipboard', 'clear') + self._options(kw))
     def clipboard_append(self, string, **kw):
         """Append STRING to the Tk clipboard.
@@ -555,7 +555,7 @@
         A widget specified at the optional displayof keyword
         argument specifies the target display. The clipboard
         can be retrieved with selection_get."""
-        if not kw.has_key('displayof'): kw['displayof'] = self._w
+        if 'displayof' not in kw: kw['displayof'] = self._w
         self.tk.call(('clipboard', 'append') + self._options(kw)
               + ('--', string))
     # XXX grab current w/o window argument
@@ -613,7 +613,7 @@
         self.tk.call('option', 'readfile', fileName, priority)
     def selection_clear(self, **kw):
         """Clear the current X selection."""
-        if not kw.has_key('displayof'): kw['displayof'] = self._w
+        if 'displayof' not in kw: kw['displayof'] = self._w
         self.tk.call(('selection', 'clear') + self._options(kw))
     def selection_get(self, **kw):
         """Return the contents of the current X selection.
@@ -622,7 +622,7 @@
         the selection and defaults to PRIMARY.  A keyword
         parameter displayof specifies a widget on the display
         to use."""
-        if not kw.has_key('displayof'): kw['displayof'] = self._w
+        if 'displayof' not in kw: kw['displayof'] = self._w
         return self.tk.call(('selection', 'get') + self._options(kw))
     def selection_handle(self, command, **kw):
         """Specify a function COMMAND to call if the X
@@ -653,7 +653,7 @@
         be provided:
         selection - name of the selection (default PRIMARY),
         type - type of the selection (e.g. STRING, FILE_NAME)."""
-        if not kw.has_key('displayof'): kw['displayof'] = self._w
+        if 'displayof' not in kw: kw['displayof'] = self._w
         name = self.tk.call(('selection', 'own') + self._options(kw))
         if not name: return None
         return self._nametowidget(name)
@@ -1735,7 +1735,7 @@
         the Tcl Interpreter and calls execfile on BASENAME.py and CLASSNAME.py if
         such a file exists in the home directory."""
         import os
-        if os.environ.has_key('HOME'): home = os.environ['HOME']
+        if 'HOME' in os.environ: home = os.environ['HOME']
         else: home = os.curdir
         class_tcl = os.path.join(home, '.%s.tcl' % className)
         class_py = os.path.join(home, '.%s.py' % className)
@@ -1942,7 +1942,7 @@
         self.master = master
         self.tk = master.tk
         name = None
-        if cnf.has_key('name'):
+        if 'name' in cnf:
             name = cnf['name']
             del cnf['name']
         if not name:
@@ -1953,7 +1953,7 @@
         else:
             self._w = master._w + '.' + name
         self.children = {}
-        if self.master.children.has_key(self._name):
+        if self._name in self.master.children:
             self.master.children[self._name].destroy()
         self.master.children[self._name] = self
     def __init__(self, master, widgetName, cnf={}, kw={}, extra=()):
@@ -1978,7 +1978,7 @@
         """Destroy this and all descendants widgets."""
         for c in self.children.values(): c.destroy()
         self.tk.call('destroy', self._w)
-        if self.master.children.has_key(self._name):
+        if self._name in self.master.children:
             del self.master.children[self._name]
         Misc.destroy(self)
     def _do(self, name, args=()):
@@ -2006,7 +2006,7 @@
         extra = ()
         for wmkey in ['screen', 'class_', 'class', 'visual',
                   'colormap']:
-            if cnf.has_key(wmkey):
+            if wmkey in cnf:
                 val = cnf[wmkey]
                 # TBD: a hack needed because some keys
                 # are not valid as keyword arguments
@@ -2444,10 +2444,10 @@
         highlightcolor, highlightthickness, relief, takefocus, visual, width."""
         cnf = _cnfmerge((cnf, kw))
         extra = ()
-        if cnf.has_key('class_'):
+        if 'class_' in cnf:
             extra = ('-class', cnf['class_'])
             del cnf['class_']
-        elif cnf.has_key('class'):
+        elif 'class' in cnf:
             extra = ('-class', cnf['class'])
             del cnf['class']
         Widget.__init__(self, master, 'frame', cnf, {}, extra)
@@ -3153,7 +3153,7 @@
         self.menuname = menu._w
         # 'command' is the only supported keyword
         callback = kwargs.get('command')
-        if kwargs.has_key('command'):
+        if 'command' in kwargs:
             del kwargs['command']
         if kwargs:
             raise TclError, 'unknown option -'+kwargs.keys()[0]

Modified: python/trunk/Lib/lib-tk/tkSimpleDialog.py
==============================================================================
--- python/trunk/Lib/lib-tk/tkSimpleDialog.py	(original)
+++ python/trunk/Lib/lib-tk/tkSimpleDialog.py	Sat Oct 10 00:15:50 2009
@@ -283,7 +283,7 @@
 
 class _QueryString(_QueryDialog):
     def __init__(self, *args, **kw):
-        if kw.has_key("show"):
+        if "show" in kw:
             self.__show = kw["show"]
             del kw["show"]
         else:

Modified: python/trunk/Lib/lib-tk/turtle.py
==============================================================================
--- python/trunk/Lib/lib-tk/turtle.py	(original)
+++ python/trunk/Lib/lib-tk/turtle.py	Sat Oct 10 00:15:50 2009
@@ -335,10 +335,10 @@
         if ex[:1] == '_' or ex[-1:] == '_':
             del _dict[ex]
     for ex in exclude:
-        if _dict.has_key(ex):
+        if ex in _dict:
             del _dict[ex]
     for ex in __methods(fromClass):
-        if _dict.has_key(ex):
+        if ex in _dict:
             del _dict[ex]
 
     for method, func in _dict.items():

Modified: python/trunk/Lib/msilib/__init__.py
==============================================================================
--- python/trunk/Lib/msilib/__init__.py	(original)
+++ python/trunk/Lib/msilib/__init__.py	Sat Oct 10 00:15:50 2009
@@ -330,7 +330,7 @@
             file = os.path.basename(file)
         absolute = os.path.join(self.absolute, src)
         assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names
-        if self.keyfiles.has_key(file):
+        if file in self.keyfiles:
             logical = self.keyfiles[file]
         else:
             logical = None

Modified: python/trunk/Lib/trace.py
==============================================================================
--- python/trunk/Lib/trace.py	(original)
+++ python/trunk/Lib/trace.py	Sat Oct 10 00:15:50 2009
@@ -124,7 +124,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

Modified: python/trunk/Lib/wsgiref/handlers.py
==============================================================================
--- python/trunk/Lib/wsgiref/handlers.py	(original)
+++ python/trunk/Lib/wsgiref/handlers.py	Sat Oct 10 00:15:50 2009
@@ -160,7 +160,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):
@@ -195,11 +195,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)

Modified: python/trunk/Lib/wsgiref/validate.py
==============================================================================
--- python/trunk/Lib/wsgiref/validate.py	(original)
+++ python/trunk/Lib/wsgiref/validate.py	Sat Oct 10 00:15:50 2009
@@ -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') != '/',

Modified: python/trunk/Lib/xml/dom/domreg.py
==============================================================================
--- python/trunk/Lib/xml/dom/domreg.py	(original)
+++ python/trunk/Lib/xml/dom/domreg.py	Sat Oct 10 00:15:50 2009
@@ -57,7 +57,7 @@
         return mod.getDOMImplementation()
     elif name:
         return registered[name]()
-    elif os.environ.has_key("PYTHON_DOM"):
+    elif "PYTHON_DOM" in os.environ:
         return getDOMImplementation(name = os.environ["PYTHON_DOM"])
 
     # User did not specify a name, try implementations in arbitrary

Modified: python/trunk/Lib/xml/dom/minidom.py
==============================================================================
--- python/trunk/Lib/xml/dom/minidom.py	(original)
+++ python/trunk/Lib/xml/dom/minidom.py	Sat Oct 10 00:15:50 2009
@@ -491,9 +491,9 @@
 
     def has_key(self, key):
         if isinstance(key, StringTypes):
-            return self._attrs.has_key(key)
+            return key in self._attrs
         else:
-            return self._attrsNS.has_key(key)
+            return key in self._attrsNS
 
     def keys(self):
         return self._attrs.keys()
@@ -775,10 +775,10 @@
     removeAttributeNodeNS = removeAttributeNode
 
     def hasAttribute(self, name):
-        return self._attrs.has_key(name)
+        return name in self._attrs
 
     def hasAttributeNS(self, namespaceURI, localName):
-        return self._attrsNS.has_key((namespaceURI, localName))
+        return (namespaceURI, localName) in self._attrsNS
 
     def getElementsByTagName(self, name):
         return _get_elements_by_tagName_helper(self, name, NodeList())

Modified: python/trunk/Lib/xml/dom/xmlbuilder.py
==============================================================================
--- python/trunk/Lib/xml/dom/xmlbuilder.py	(original)
+++ python/trunk/Lib/xml/dom/xmlbuilder.py	Sat Oct 10 00:15:50 2009
@@ -91,7 +91,7 @@
 
     def canSetFeature(self, name, state):
         key = (_name_xform(name), state and 1 or 0)
-        return self._settings.has_key(key)
+        return key in self._settings
 
     # This dictionary maps from (feature,value) to a list of
     # (option,value) pairs that should be set on the Options object.
@@ -247,7 +247,7 @@
 
     def _guess_media_encoding(self, source):
         info = source.byteStream.info()
-        if info.has_key("Content-Type"):
+        if "Content-Type" in info:
             for param in info.getplist():
                 if param.startswith("charset="):
                     return param.split("=", 1)[1].lower()

Modified: python/trunk/Lib/xml/sax/__init__.py
==============================================================================
--- python/trunk/Lib/xml/sax/__init__.py	(original)
+++ python/trunk/Lib/xml/sax/__init__.py	Sat Oct 10 00:15:50 2009
@@ -59,7 +59,7 @@
     import xml.sax.expatreader
 
 import os, sys
-if os.environ.has_key("PY_SAX_PARSER"):
+if "PY_SAX_PARSER" in os.environ:
     default_parser_list = os.environ["PY_SAX_PARSER"].split(",")
 del os
 


More information about the Python-checkins mailing list