[Python-checkins] python/dist/src/Lib cgitb.py, 1.15, 1.16 cookielib.py, 1.5, 1.6 decimal.py, 1.32, 1.33 inspect.py, 1.59, 1.60 mhlib.py, 1.38, 1.39 posixfile.py, 1.27, 1.28 pydoc.py, 1.102, 1.103 smtplib.py, 1.68, 1.69 urllib2.py, 1.80, 1.81 warnings.py, 1.25, 1.26 whichdb.py, 1.19, 1.20

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sun Feb 6 07:57:27 CET 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12661

Modified Files:
	cgitb.py cookielib.py decimal.py inspect.py mhlib.py 
	posixfile.py pydoc.py smtplib.py urllib2.py warnings.py 
	whichdb.py 
Log Message:
Replace list of constants with tuples of constants.

Index: cgitb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/cgitb.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- cgitb.py	18 Jul 2004 06:14:41 -0000	1.15
+++ cgitb.py	6 Feb 2005 06:57:07 -0000	1.16
@@ -146,7 +146,7 @@
             if name in done: continue
             done[name] = 1
             if value is not __UNDEF__:
-                if where in ['global', 'builtin']:
+                if where in ('global', 'builtin'):
                     name = ('<em>%s</em> ' % where) + strong(name)
                 elif where == 'local':
                     name = strong(name)

Index: cookielib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cookielib.py	5 Feb 2005 01:31:17 -0000	1.5
+++ cookielib.py	6 Feb 2005 06:57:07 -0000	1.6
@@ -783,12 +783,12 @@
 
     def __repr__(self):
         args = []
-        for name in ["version", "name", "value",
+        for name in ("version", "name", "value",
                      "port", "port_specified",
                      "domain", "domain_specified", "domain_initial_dot",
                      "path", "path_specified",
                      "secure", "expires", "discard", "comment", "comment_url",
-                     ]:
+                     ):
             attr = getattr(self, name)
             args.append("%s=%s" % (name, repr(attr)))
         args.append("rest=%s" % repr(self._rest))
@@ -981,9 +981,9 @@
                 if j == 0:  # domain like .foo.bar
                     tld = domain[i+1:]
                     sld = domain[j+1:i]
-                    if (sld.lower() in [
+                    if (sld.lower() in (
                         "co", "ac",
-                        "com", "edu", "org", "net", "gov", "mil", "int"] and
+                        "com", "edu", "org", "net", "gov", "mil", "int") and
                         len(tld) == 2):
                         # domain like .co.uk
                         debug("   country-code second level domain %s", domain)
@@ -1415,7 +1415,7 @@
                     v = self._now + v
                 if (k in value_attrs) or (k in boolean_attrs):
                     if (v is None and
-                        k not in ["port", "comment", "commenturl"]):
+                        k not in ("port", "comment", "commenturl")):
                         debug("   missing value for %s attribute" % k)
                         bad_cookie = True
                         break

Index: decimal.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- decimal.py	18 Dec 2004 19:07:15 -0000	1.32
+++ decimal.py	6 Feb 2005 06:57:07 -0000	1.33
@@ -515,7 +515,7 @@
         if isinstance(value, (list,tuple)):
             if len(value) != 3:
                 raise ValueError, 'Invalid arguments'
-            if value[0] not in [0,1]:
+            if value[0] not in (0,1):
                 raise ValueError, 'Invalid sign'
             for digit in value[1]:
                 if not isinstance(digit, (int,long)) or digit < 0:

Index: inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- inspect.py	12 Dec 2004 16:46:28 -0000	1.59
+++ inspect.py	6 Feb 2005 06:57:07 -0000	1.60
@@ -346,7 +346,7 @@
 def getsourcefile(object):
     """Return the Python source file an object was defined in, if it exists."""
     filename = getfile(object)
-    if string.lower(filename[-4:]) in ['.pyc', '.pyo']:
+    if string.lower(filename[-4:]) in ('.pyc', '.pyo'):
         filename = filename[:-4] + '.py'
     for suffix, mode, kind in imp.get_suffixes():
         if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix:
@@ -453,7 +453,7 @@
         # Look for a comment block at the top of the file.
         start = 0
         if lines and lines[0][:2] == '#!': start = 1
-        while start < len(lines) and string.strip(lines[start]) in ['', '#']:
+        while start < len(lines) and string.strip(lines[start]) in ('', '#'):
             start = start + 1
         if start < len(lines) and lines[start][:1] == '#':
             comments = []
@@ -621,7 +621,7 @@
 
     # The following acrobatics are for anonymous (tuple) arguments.
     for i in range(nargs):
-        if args[i][:1] in ['', '.']:
+        if args[i][:1] in ('', '.'):
             stack, remain, count = [], [], []
             while step < len(code):
                 op = ord(code[step])
@@ -630,7 +630,7 @@
                     opname = dis.opname[op]
                     value = ord(code[step]) + ord(code[step+1])*256
                     step = step + 2
-                    if opname in ['UNPACK_TUPLE', 'UNPACK_SEQUENCE']:
+                    if opname in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'):
                         remain.append(value)
                         count.append(value)
                     elif opname == 'STORE_FAST':
@@ -696,7 +696,7 @@
 
 def strseq(object, convert, join=joinseq):
     """Recursively walk a sequence, stringifying each element."""
-    if type(object) in [types.ListType, types.TupleType]:
+    if type(object) in (list, tuple):
         return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object))
     else:
         return convert(object)

Index: mhlib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- mhlib.py	31 Dec 2004 19:15:26 -0000	1.38
+++ mhlib.py	6 Feb 2005 06:57:07 -0000	1.39
@@ -982,11 +982,11 @@
     context = mh.getcontext()
     f = mh.openfolder(context)
     do('f.getcurrent()')
-    for seq in ['first', 'last', 'cur', '.', 'prev', 'next',
+    for seq in ('first', 'last', 'cur', '.', 'prev', 'next',
                 'first:3', 'last:3', 'cur:3', 'cur:-3',
                 'prev:3', 'next:3',
                 '1:3', '1:-3', '100:3', '100:-3', '10000:3', '10000:-3',
-                'all']:
+                'all'):
         try:
             do('f.parsesequence(%r)' % (seq,))
         except Error, msg:

Index: posixfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/posixfile.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- posixfile.py	5 Dec 2004 04:55:09 -0000	1.27
+++ posixfile.py	6 Feb 2005 06:57:07 -0000	1.28
@@ -182,7 +182,7 @@
                             'freebsd6', 'bsdos2', 'bsdos3', 'bsdos4'):
             flock = struct.pack('lxxxxlxxxxlhh', \
                   l_start, l_len, os.getpid(), l_type, l_whence)
-        elif sys.platform in ['aix3', 'aix4']:
+        elif sys.platform in ('aix3', 'aix4'):
             flock = struct.pack('hhlllii', \
                   l_type, l_whence, l_start, l_len, 0, 0, 0)
         else:
@@ -198,7 +198,7 @@
                                 'bsdos2', 'bsdos3', 'bsdos4'):
                 l_start, l_len, l_pid, l_type, l_whence = \
                     struct.unpack('lxxxxlxxxxlhh', flock)
-            elif sys.platform in ['aix3', 'aix4']:
+            elif sys.platform in ('aix3', 'aix4'):
                 l_type, l_whence, l_start, l_len, l_sysid, l_pid, l_vfs = \
                     struct.unpack('hhlllii', flock)
             elif sys.platform == "linux2":

Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- pydoc.py	8 Jan 2005 20:16:43 -0000	1.102
+++ pydoc.py	6 Feb 2005 06:57:07 -0000	1.103
@@ -153,8 +153,8 @@
 def visiblename(name, all=None):
     """Decide whether to show documentation on a variable."""
     # Certain special names are redundant.
-    if name in ['__builtins__', '__doc__', '__file__', '__path__',
-                '__module__', '__name__', '__slots__']: return 0
+    if name in ('__builtins__', '__doc__', '__file__', '__path__',
+                '__module__', '__name__', '__slots__'): return 0
     # Private names are hidden, but special names are displayed.
     if name.startswith('__') and name.endswith('__'): return 1
     if all is not None:
@@ -176,7 +176,7 @@
 def ispackage(path):
     """Guess whether a path refers to a package directory."""
     if os.path.isdir(path):
-        for ext in ['.py', '.pyc', '.pyo']:
+        for ext in ('.py', '.pyc', '.pyo'):
             if os.path.isfile(os.path.join(path, '__init__' + ext)):
                 return True
     return False
@@ -1298,12 +1298,12 @@
         return plainpager
     if not sys.stdin.isatty() or not sys.stdout.isatty():
         return plainpager
-    if os.environ.get('TERM') in ['dumb', 'emacs']:
+    if os.environ.get('TERM') in ('dumb', 'emacs'):
         return plainpager
     if 'PAGER' in os.environ:
         if sys.platform == 'win32': # pipes completely broken in Windows
             return lambda text: tempfilepager(plain(text), os.environ['PAGER'])
-        elif os.environ.get('TERM') in ['dumb', 'emacs']:
+        elif os.environ.get('TERM') in ('dumb', 'emacs'):
             return lambda text: pipepager(plain(text), os.environ['PAGER'])
         else:
             return lambda text: pipepager(text, os.environ['PAGER'])
@@ -1369,14 +1369,14 @@
             sys.stdout.flush()
             c = getchar()
 
-            if c in ['q', 'Q']:
+            if c in ('q', 'Q'):
                 sys.stdout.write('\r          \r')
                 break
-            elif c in ['\r', '\n']:
+            elif c in ('\r', '\n'):
                 sys.stdout.write('\r          \r' + lines[r] + '\n')
                 r = r + 1
                 continue
-            if c in ['b', 'B', '\x1b']:
+            if c in ('b', 'B', '\x1b'):
                 r = r - inc - inc
                 if r < 0: r = 0
             sys.stdout.write('\n' + join(lines[r:r+inc], '\n') + '\n')
@@ -1646,7 +1646,7 @@
             except (KeyboardInterrupt, EOFError):
                 break
             request = strip(replace(request, '"', '', "'", ''))
-            if lower(request) in ['q', 'quit']: break
+            if lower(request) in ('q', 'quit'): break
             self.help(request)
 
     def getline(self, prompt):

Index: smtplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- smtplib.py	16 Jan 2005 13:04:30 -0000	1.68
+++ smtplib.py	6 Feb 2005 06:57:08 -0000	1.69
@@ -578,7 +578,7 @@
             (code, resp) = self.docmd(encode_base64(password, eol=""))
         elif authmethod is None:
             raise SMTPException("No suitable authentication method found.")
-        if code not in [235, 503]:
+        if code not in (235, 503):
             # 235 == 'Authentication successful'
             # 503 == 'Error: already authenticated'
             raise SMTPAuthenticationError(code, resp)

Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- urllib2.py	5 Feb 2005 14:37:06 -0000	1.80
+++ urllib2.py	6 Feb 2005 06:57:08 -0000	1.81
@@ -384,7 +384,7 @@
                                 'unknown_open', req)
 
     def error(self, proto, *args):
-        if proto in ['http', 'https']:
+        if proto in ('http', 'https'):
             # XXX http[s] protocols are special-cased
             dict = self.handle_error['http'] # https is not different than http
             proto = args[2]  # YUCK!

Index: warnings.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/warnings.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- warnings.py	29 Dec 2004 15:28:09 -0000	1.25
+++ warnings.py	6 Feb 2005 06:57:08 -0000	1.26
@@ -216,7 +216,7 @@
     if not action:
         return "default"
     if action == "all": return "always" # Alias
-    for a in ['default', 'always', 'ignore', 'module', 'once', 'error']:
+    for a in ('default', 'always', 'ignore', 'module', 'once', 'error'):
         if a.startswith(action):
             return a
     raise _OptionError("invalid action: %r" % (action,))

Index: whichdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/whichdb.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- whichdb.py	20 Oct 2004 07:17:16 -0000	1.19
+++ whichdb.py	6 Feb 2005 06:57:08 -0000	1.20
@@ -62,7 +62,7 @@
             return "dumbdbm"
         f = open(filename + os.extsep + "dir", "rb")
         try:
-            if f.read(1) in ["'", '"']:
+            if f.read(1) in ("'", '"'):
                 return "dumbdbm"
         finally:
             f.close()



More information about the Python-checkins mailing list