[Python-checkins] CVS: python/dist/src/Lib Cookie.py,1.8,1.8.4.1 UserDict.py,1.12,1.12.2.1 UserList.py,1.16,1.16.6.1 UserString.py,1.9,1.9.6.1 anydbm.py,1.10,1.10.6.1 asyncore.py,1.11,1.11.2.1 base64.py,1.11,1.11.6.1 bdb.py,1.31,1.31.4.1 calendar.py,1.21,1.21.6.1 cgi.py,1.63,1.63.4.1 chunk.py,1.10,1.10.4.1 code.py,1.15,1.15.6.1 dbhash.py,1.5,1.5.6.1 dis.py,1.34,1.34.2.1 doctest.py,1.10,1.10.4.1 dumbdbm.py,1.10,1.10.6.1 fnmatch.py,1.11,1.11.4.1 formatter.py,1.17,1.17.6.1 glob.py,1.9,1.9.6.1 htmllib.py,1.17,1.17.6.1 httplib.py,1.34,1.34.4.1 imaplib.py,1.27,1.27.6.1 keyword.py,1.10,1.10.6.1 linecache.py,1.7,1.7.6.1 mailbox.py,1.30,1.30.4.1 mailcap.py,1.9,1.9.6.1 mhlib.py,1.26,1.26.6.1 mimetypes.py,1.13,1.13.6.1 mimify.py,1.20,1.20.4.1 ntpath.py,1.34,1.34.6.1 pipes.py,1.8,1.8.6.1 posixfile.py,1.20,1.20.4.1 pprint.py,1.12,1.12.6.1 pre.py,1.9,1.9.6.1 profile.py,1.27,1.27.4.1 pstats.py,1.15,1.15.4.1 pty.py,1.7,1.7.6.1 pydoc.py,1.38,1.38.4.1 quopri.py,1.11,1.11.4.1 rexec.py,1.28,1.28.6.1 rfc822.py,1.54,1.54.6.1 sgmllib.py,1.30,1.30.4.1 site.py,1.26,1.26.4.1 sre_compile.py,1.37,1.37.4.1 sre_constants.py,1.28,1.28.4.1 tabnanny.py,1.13,1.13.4.1 tokenize.py,1.22,1.22.4.1 traceback.py,1.25,1.25.4.1 types.py,1.14.10.5,1.14.10.6 unittest.py,1.7,1.7.4.1 urllib.py,1.126,1.126.4.1 urllib2.py,1.13,1.13.4.1 weakref.py,1.9,1.9.2.1 zipfile.py,1.13,1.13.4.1

Tim Peters tim_one@users.sourceforge.net
2001年7月07日 15:56:01 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv24450/mergedescr/dist/src/Lib
Modified Files:
 Tag: descr-branch
	Cookie.py UserDict.py UserList.py UserString.py anydbm.py 
	asyncore.py base64.py bdb.py calendar.py cgi.py chunk.py 
	code.py dbhash.py dis.py doctest.py dumbdbm.py fnmatch.py 
	formatter.py glob.py htmllib.py httplib.py imaplib.py 
	keyword.py linecache.py mailbox.py mailcap.py mhlib.py 
	mimetypes.py mimify.py ntpath.py pipes.py posixfile.py 
	pprint.py pre.py profile.py pstats.py pty.py pydoc.py 
	quopri.py rexec.py rfc822.py sgmllib.py site.py sre_compile.py 
	sre_constants.py tabnanny.py tokenize.py traceback.py types.py 
	unittest.py urllib.py urllib2.py weakref.py zipfile.py 
Log Message:
Merge of trunk tag date2001-07-06 into descr-branch.
Index: Cookie.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/Cookie.py,v
retrieving revision 1.8
retrieving revision 1.8.4.1
diff -C2 -r1.8 -r1.8.4.1
*** Cookie.py	2001年04月06日 19:39:11	1.8
--- Cookie.py	2001年07月07日 22:55:27	1.8.4.1
***************
*** 71,76 ****
 >>> C["sugar"] = "wafer"
 >>> print C
- Set-Cookie: sugar=wafer;
 Set-Cookie: fig=newton;
 
 Notice that the printable representation of a Cookie is the
--- 71,76 ----
 >>> C["sugar"] = "wafer"
 >>> print C
 Set-Cookie: fig=newton;
+ Set-Cookie: sugar=wafer;
 
 Notice that the printable representation of a Cookie is the
***************
*** 94,99 ****
 >>> C.load("chips=ahoy; vienna=finger")
 >>> print C
- Set-Cookie: vienna=finger;
 Set-Cookie: chips=ahoy;
 
 The load() method is darn-tootin smart about identifying cookies
--- 94,99 ----
 >>> C.load("chips=ahoy; vienna=finger")
 >>> print C
 Set-Cookie: chips=ahoy;
+ Set-Cookie: vienna=finger;
 
 The load() method is darn-tootin smart about identifying cookies
***************
*** 494,498 ****
 if attrs is None:
 attrs = self._reserved_keys
! for K,V in self.items():
 if V == "": continue
 if K not in attrs: continue
--- 494,500 ----
 if attrs is None:
 attrs = self._reserved_keys
! items = self.items()
! items.sort()
! for K,V in items:
 if V == "": continue
 if K not in attrs: continue
***************
*** 587,591 ****
 """Return a string suitable for HTTP."""
 result = []
! for K,V in self.items():
 result.append( V.output(attrs, header) )
 return string.join(result, sep)
--- 589,595 ----
 """Return a string suitable for HTTP."""
 result = []
! items = self.items()
! items.sort()
! for K,V in items:
 result.append( V.output(attrs, header) )
 return string.join(result, sep)
***************
*** 596,600 ****
 def __repr__(self):
 L = []
! for K,V in self.items():
 L.append( '%s=%s' % (K,repr(V.value) ) )
 return '<%s: %s>' % (self.__class__.__name__, string.join(L))
--- 600,606 ----
 def __repr__(self):
 L = []
! items = self.items()
! items.sort()
! for K,V in items:
 L.append( '%s=%s' % (K,repr(V.value) ) )
 return '<%s: %s>' % (self.__class__.__name__, string.join(L))
***************
*** 603,607 ****
 """Return a string suitable for JavaScript."""
 result = []
! for K,V in self.items():
 result.append( V.js_output(attrs) )
 return string.join(result, "")
--- 609,615 ----
 """Return a string suitable for JavaScript."""
 result = []
! items = self.items()
! items.sort()
! for K,V in items:
 result.append( V.js_output(attrs) )
 return string.join(result, "")
Index: UserDict.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/UserDict.py,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -C2 -r1.12 -r1.12.2.1
*** UserDict.py	2001年04月21日 09:13:15	1.12
--- UserDict.py	2001年07月07日 22:55:27	1.12.2.1
***************
*** 23,26 ****
--- 23,29 ----
 def keys(self): return self.data.keys()
 def items(self): return self.data.items()
+ def iteritems(self): return self.data.iteritems()
+ 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)
***************
*** 32,42 ****
 else:
 for k, v in dict.items():
! self.data[k] = v
 def get(self, key, failobj=None):
! return self.data.get(key, failobj)
 def setdefault(self, key, failobj=None):
! if not self.data.has_key(key):
! self.data[key] = failobj
! return self.data[key]
 def popitem(self):
 return self.data.popitem()
--- 35,47 ----
 else:
 for k, v in dict.items():
! self[k] = v
 def get(self, key, failobj=None):
! if not self.has_key(key):
! return failobj
! return self[key]
 def setdefault(self, key, failobj=None):
! if not self.has_key(key):
! self[key] = failobj
! return self[key]
 def popitem(self):
 return self.data.popitem()
Index: UserList.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/UserList.py,v
retrieving revision 1.16
retrieving revision 1.16.6.1
diff -C2 -r1.16 -r1.16.6.1
*** UserList.py	2001年02月18日 03:30:53	1.16
--- UserList.py	2001年07月07日 22:55:27	1.16.6.1
***************
*** 23,27 ****
 else: return other
 def __cmp__(self, other):
! raise RuntimeError, "UserList.__cmp__() is obsolete"
 def __contains__(self, item): return item in self.data
 def __len__(self): return len(self.data)
--- 23,27 ----
 else: return other
 def __cmp__(self, other):
! return cmp(self.data, self.__cast(other))
 def __contains__(self, item): return item in self.data
 def __len__(self): return len(self.data)
Index: UserString.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/UserString.py,v
retrieving revision 1.9
retrieving revision 1.9.6.1
diff -C2 -r1.9 -r1.9.6.1
*** UserString.py	2001年01月20日 19:54:20	1.9
--- UserString.py	2001年07月07日 22:55:27	1.9.6.1
***************
*** 73,76 ****
--- 73,84 ----
 def count(self, sub, start=0, end=sys.maxint):
 return self.data.count(sub, start, end)
+ def decode(self, encoding=None, errors=None): # XXX improve this?
+ if encoding:
+ if errors:
+ return self.__class__(self.data.decode(encoding, errors))
+ else:
+ return self.__class__(self.data.decode(encoding))
+ else:
+ return self.__class__(self.data.decode())
 def encode(self, encoding=None, errors=None): # XXX improve this?
 if encoding:
Index: anydbm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/anydbm.py,v
retrieving revision 1.10
retrieving revision 1.10.6.1
diff -C2 -r1.10 -r1.10.6.1
*** anydbm.py	2001年02月18日 03:30:53	1.10
--- anydbm.py	2001年07月07日 22:55:27	1.10.6.1
***************
*** 46,50 ****
 class error(Exception):
 pass
! except:
 error = "anydbm.error"
 
--- 46,50 ----
 class error(Exception):
 pass
! except (NameError, TypeError):
 error = "anydbm.error"
 
Index: asyncore.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -C2 -r1.11 -r1.11.2.1
*** asyncore.py	2001年04月20日 19:04:55	1.11
--- asyncore.py	2001年07月07日 22:55:27	1.11.2.1
***************
*** 225,229 ****
 except:
 pass
! 
 try:
 ar = repr (self.addr)
--- 225,229 ----
 except:
 pass
! 
 try:
 ar = repr (self.addr)
***************
*** 267,271 ****
 self.socket.getsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1
 )
! except:
 pass
 
--- 267,271 ----
 self.socket.getsockopt (socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1
 )
! except socket.error:
 pass
 
***************
*** 511,515 ****
 if os.name == 'posix':
 import fcntl
- import FCNTL
 
 class file_wrapper:
--- 511,514 ----
***************
*** 539,545 ****
 self.connected = 1
 # set it to non-blocking mode
! flags = fcntl.fcntl (fd, FCNTL.F_GETFL, 0)
! flags = flags | FCNTL.O_NONBLOCK
! fcntl.fcntl (fd, FCNTL.F_SETFL, flags)
 self.set_file (fd)
 
--- 538,544 ----
 self.connected = 1
 # set it to non-blocking mode
! flags = fcntl.fcntl (fd, fcntl.F_GETFL, 0)
! flags = flags | os.O_NONBLOCK
! fcntl.fcntl (fd, fcntl.F_SETFL, flags)
 self.set_file (fd)
 
Index: base64.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/base64.py,v
retrieving revision 1.11
retrieving revision 1.11.6.1
diff -C2 -r1.11 -r1.11.6.1
*** base64.py	2001年01月20日 19:54:20	1.11
--- base64.py	2001年07月07日 22:55:27	1.11.6.1
***************
*** 34,50 ****
 def encodestring(s):
 """Encode a string."""
! import StringIO
! f = StringIO.StringIO(s)
! g = StringIO.StringIO()
! encode(f, g)
! return g.getvalue()
 
 def decodestring(s):
 """Decode a string."""
! import StringIO
! f = StringIO.StringIO(s)
! g = StringIO.StringIO()
! decode(f, g)
! return g.getvalue()
 
 def test():
--- 34,46 ----
 def encodestring(s):
 """Encode a string."""
! pieces = []
! for i in range(0, len(s), MAXBINSIZE):
! chunk = s[i : i + MAXBINSIZE]
! pieces.append(binascii.b2a_base64(chunk))
! return "".join(pieces)
 
 def decodestring(s):
 """Decode a string."""
! return binascii.a2b_base64(s)
 
 def test():
Index: bdb.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v
retrieving revision 1.31
retrieving revision 1.31.4.1
diff -C2 -r1.31 -r1.31.4.1
*** bdb.py	2001年04月08日 15:05:16	1.31
--- bdb.py	2001年07月07日 22:55:27	1.31.4.1
***************
*** 75,78 ****
--- 75,79 ----
 self.user_return(frame, arg)
 if self.quitting: raise BdbQuit
+ return self.trace_dispatch
 
 def dispatch_exception(self, frame, arg):
Index: calendar.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v
retrieving revision 1.21
retrieving revision 1.21.6.1
diff -C2 -r1.21 -r1.21.6.1
*** calendar.py	2001年01月20日 19:54:20	1.21
--- calendar.py	2001年07月07日 22:55:27	1.21.6.1
***************
*** 9,13 ****
 
 # Import functions and variables from time module
! from time import localtime, mktime
 
 __all__ = ["error","setfirstweekday","firstweekday","isleap",
--- 9,13 ----
 
 # Import functions and variables from time module
! from time import localtime, mktime, strftime
 
 __all__ = ["error","setfirstweekday","firstweekday","isleap",
***************
*** 25,39 ****
 mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
 
 # Full and abbreviated names of weekdays
! day_name = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
! 'Friday', 'Saturday', 'Sunday']
! day_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
 
 # Full and abbreviated names of months (1-based arrays!!!)
! month_name = ['', 'January', 'February', 'March', 'April',
! 'May', 'June', 'July', 'August',
! 'September', 'October', 'November', 'December']
! month_abbr = [' ', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
! 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
 
 # Constants for weekdays
--- 25,41 ----
 mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
 
+ class _localized_name:
+ def __init__(self, format):
+ self.format = format
+ def __getitem__(self, item):
+ return strftime(self.format, (item,)*9).capitalize()
+ 
 # Full and abbreviated names of weekdays
! day_name = _localized_name('%A')
! day_abbr = _localized_name('%a')
 
 # Full and abbreviated names of months (1-based arrays!!!)
! month_name = _localized_name('%B')
! month_abbr = _localized_name('%b')
 
 # Constants for weekdays
Index: cgi.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v
retrieving revision 1.63
retrieving revision 1.63.4.1
diff -C2 -r1.63 -r1.63.4.1
*** cgi.py	2001年03月19日 13:40:44	1.63
--- cgi.py	2001年07月07日 22:55:27	1.63.4.1
***************
*** 29,33 ****
 #
 
! __version__ = "2.5"
 
 
--- 29,33 ----
 #
 
! __version__ = "2.6"
 
 
***************
*** 634,638 ****
 def read_lines(self):
 """Internal: read lines until EOF or outerboundary."""
! self.file = self.make_file('')
 if self.outerboundary:
 self.read_lines_to_outerboundary()
--- 634,638 ----
 def read_lines(self):
 """Internal: read lines until EOF or outerboundary."""
! self.file = self.__file = StringIO()
 if self.outerboundary:
 self.read_lines_to_outerboundary()
***************
*** 640,643 ****
--- 640,651 ----
 self.read_lines_to_eof()
 
+ def __write(self, line):
+ if self.__file is not None:
+ if self.__file.tell() + len(line) > 1000:
+ self.file = self.make_file('')
+ self.file.write(self.__file.getvalue())
+ self.__file = None
+ self.file.write(line)
+ 
 def read_lines_to_eof(self):
 """Internal: read lines until EOF."""
***************
*** 647,651 ****
 self.done = -1
 break
! self.file.write(line)
 
 def read_lines_to_outerboundary(self):
--- 655,659 ----
 self.done = -1
 break
! self.__write(line)
 
 def read_lines_to_outerboundary(self):
***************
*** 675,679 ****
 else:
 delim = ""
! self.file.write(odelim + line)
 
 def skip_lines(self):
--- 683,687 ----
 else:
 delim = ""
! self.__write(odelim + line)
 
 def skip_lines(self):
Index: chunk.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/chunk.py,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -C2 -r1.10 -r1.10.4.1
*** chunk.py	2001年04月15日 12:40:13	1.10
--- chunk.py	2001年07月07日 22:55:27	1.10.4.1
***************
*** 71,75 ****
 try:
 self.offset = self.file.tell()
! except:
 self.seekable = 0
 else:
--- 71,75 ----
 try:
 self.offset = self.file.tell()
! except (AttributeError, IOError):
 self.seekable = 0
 else:
***************
*** 159,163 ****
 self.size_read = self.size_read + n
 return
! except:
 pass
 while self.size_read < self.chunksize:
--- 159,163 ----
 self.size_read = self.size_read + n
 return
! except IOError:
 pass
 while self.size_read < self.chunksize:
Index: code.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/code.py,v
retrieving revision 1.15
retrieving revision 1.15.6.1
diff -C2 -r1.15 -r1.15.6.1
*** code.py	2001年02月09日 08:56:30	1.15
--- code.py	2001年07月07日 22:55:27	1.15.6.1
***************
*** 138,141 ****
--- 138,142 ----
 # If that failed, assume SyntaxError is a string
 value = msg, (filename, lineno, offset, line)
+ sys.last_value = value
 list = traceback.format_exception_only(type, value)
 map(self.write, list)
Index: dbhash.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dbhash.py,v
retrieving revision 1.5
retrieving revision 1.5.6.1
diff -C2 -r1.5 -r1.5.6.1
*** dbhash.py	2001年01月25日 13:47:00	1.5
--- dbhash.py	2001年07月07日 22:55:27	1.5.6.1
***************
*** 13,16 ****
 error = bsddb.error # Exported for anydbm
 
! def open(file, flag, mode=0666):
 return bsddb.hashopen(file, flag, mode)
--- 13,16 ----
 error = bsddb.error # Exported for anydbm
 
! def open(file, flag = 'r', mode=0666):
 return bsddb.hashopen(file, flag, mode)
Index: dis.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dis.py,v
retrieving revision 1.34
retrieving revision 1.34.2.1
diff -C2 -r1.34 -r1.34.2.1
*** dis.py	2001年04月20日 19:13:01	1.34
--- dis.py	2001年07月07日 22:55:27	1.34.2.1
***************
*** 224,227 ****
--- 224,228 ----
 def_op('IMPORT_STAR', 84)
 def_op('EXEC_STMT', 85)
+ def_op('YIELD_STMT', 86)
 
 def_op('POP_BLOCK', 87)
Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -C2 -r1.10 -r1.10.4.1
*** doctest.py	2001年03月21日 23:07:59	1.10
--- doctest.py	2001年07月07日 22:55:27	1.10.4.1
***************
*** 501,506 ****
 # the traceback isn't necessary.
 want = want.split('\n')[-2] + '\n'
! exc_type, exc_val, exc_tb = sys.exc_info()
! got = traceback.format_exception_only(exc_type, exc_val)[0]
 state = OK
 else:
--- 501,506 ----
 # the traceback isn't necessary.
 want = want.split('\n')[-2] + '\n'
! exc_type, exc_val = sys.exc_info()[:2]
! got = traceback.format_exception_only(exc_type, exc_val)[-1]
 state = OK
 else:
***************
*** 530,538 ****
 return failures, len(examples)
 
! # Run list of examples, in context globs. Return (#failures, #tries).
 
 def _run_examples(examples, globs, verbose, name):
 import sys
 saveout = sys.stdout
 try:
 sys.stdout = fakeout = _SpoofOut()
--- 530,540 ----
 return failures, len(examples)
 
! # Run list of examples, in a shallow copy of context (dict) globs.
! # Return (#failures, #tries).
 
 def _run_examples(examples, globs, verbose, name):
 import sys
 saveout = sys.stdout
+ globs = globs.copy()
 try:
 sys.stdout = fakeout = _SpoofOut()
***************
*** 541,544 ****
--- 543,555 ----
 finally:
 sys.stdout = saveout
+ # While Python gc can clean up most cycles on its own, it doesn't
+ # chase frame objects. This is especially irksome when running
+ # generator tests that raise exceptions, because a named generator-
+ # iterator gets an entry in globs, and the generator-iterator
+ # object's frame's traceback info points back to globs. This is
+ # easy to break just by clearing the namespace. This can also
+ # help to break other kinds of cycles, and even for cycles that
+ # gc can break itself it's better to break them ASAP.
+ globs.clear()
 return x
 
***************
*** 546,550 ****
 """f, globs, verbose=0, name="NoName" -> run examples from f.__doc__.
 
! Use dict globs as the globals for execution.
 Return (#failures, #tries).
 
--- 557,561 ----
 """f, globs, verbose=0, name="NoName" -> run examples from f.__doc__.
 
! Use (a shallow copy of) dict globs as the globals for execution.
 Return (#failures, #tries).
 
***************
*** 736,740 ****
 e = _extract_examples(s)
 if e:
! f, t = _run_examples(e, self.globs.copy(), self.verbose, name)
 if self.verbose:
 print f, "of", t, "examples failed in string", name
--- 747,751 ----
 e = _extract_examples(s)
 if e:
! f, t = _run_examples(e, self.globs, self.verbose, name)
 if self.verbose:
 print f, "of", t, "examples failed in string", name
***************
*** 774,779 ****
 if self.verbose:
 print "Running", name + ".__doc__"
! f, t = run_docstring_examples(object, self.globs.copy(),
! self.verbose, name)
 if self.verbose:
 print f, "of", t, "examples failed in", name + ".__doc__"
--- 785,789 ----
 if self.verbose:
 print "Running", name + ".__doc__"
! f, t = run_docstring_examples(object, self.globs, self.verbose, name)
 if self.verbose:
 print f, "of", t, "examples failed in", name + ".__doc__"
Index: dumbdbm.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/dumbdbm.py,v
retrieving revision 1.10
retrieving revision 1.10.6.1
diff -C2 -r1.10 -r1.10.6.1
*** dumbdbm.py	2001年03月02日 06:43:49	1.10
--- dumbdbm.py	2001年07月07日 22:55:27	1.10.6.1
***************
*** 136,139 ****
--- 136,146 ----
 return self._index.has_key(key)
 
+ def __contains__(self, key):
+ return self._index.has_key(key)
+ 
+ def iterkeys(self):
+ return self._index.iterkeys()
+ __iter__ = iterkeys
+ 
 def __len__(self):
 return len(self._index)
***************
*** 144,148 ****
 
 
! def open(file, flag = None, mode = None):
 # flag, mode arguments are currently ignored
 return _Database(file)
--- 151,155 ----
 
 
! def open(file, flag=None, mode=None):
 # flag, mode arguments are currently ignored
 return _Database(file)
Index: fnmatch.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/fnmatch.py,v
retrieving revision 1.11
retrieving revision 1.11.4.1
diff -C2 -r1.11 -r1.11.4.1
*** fnmatch.py	2001年03月21日 18:05:48	1.11
--- fnmatch.py	2001年07月07日 22:55:27	1.11.4.1
***************
*** 38,41 ****
--- 38,61 ----
 return fnmatchcase(name, pat)
 
+ def filter(names, pat):
+ """Return the subset of the list NAMES that match PAT"""
+ import os,posixpath
+ result=[]
+ pat=os.path.normcase(pat)
+ if not _cache.has_key(pat):
+ res = translate(pat)
+ _cache[pat] = re.compile(res)
+ match=_cache[pat].match
+ if os.path is posixpath:
+ # normcase on posix is NOP. Optimize it away from the loop.
+ for name in names:
+ if match(name):
+ result.append(name)
+ else:
+ for name in names:
+ if match(os.path.normcase(name)):
+ result.append(name)
+ return result
+ 
 def fnmatchcase(name, pat):
 """Test whether FILENAME matches PATTERN, including case.
Index: formatter.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/formatter.py,v
retrieving revision 1.17
retrieving revision 1.17.6.1
diff -C2 -r1.17 -r1.17.6.1
*** formatter.py	2001年02月09日 10:58:30	1.17
--- formatter.py	2001年07月07日 22:55:27	1.17.6.1
***************
*** 114,129 ****
 label = ''
 for c in format:
! try:
! if c == '1':
! label = label + ('%d' % counter)
! elif c in 'aA':
! if counter > 0:
! label = label + self.format_letter(c, counter)
! elif c in 'iI':
! if counter > 0:
! label = label + self.format_roman(c, counter)
! else:
! label = label + c
! except:
 label = label + c
 return label
--- 114,126 ----
 label = ''
 for c in format:
! if c == '1':
! label = label + ('%d' % counter)
! elif c in 'aA':
! if counter > 0:
! label = label + self.format_letter(c, counter)
! elif c in 'iI':
! if counter > 0:
! label = label + self.format_roman(c, counter)
! else:
 label = label + c
 return label
***************
*** 133,136 ****
--- 130,136 ----
 while counter > 0:
 counter, x = divmod(counter-1, 26)
+ # This makes a strong assumption that lowercase letters
+ # and uppercase letters form two contiguous blocks, with
+ # letters in order!
 s = chr(ord(case) + x)
 label = s + label
Index: glob.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/glob.py,v
retrieving revision 1.9
retrieving revision 1.9.6.1
diff -C2 -r1.9 -r1.9.6.1
*** glob.py	2001年01月20日 23:34:12	1.9
--- glob.py	2001年07月07日 22:55:27	1.9.6.1
***************
*** 19,23 ****
 return []
 dirname, basename = os.path.split(pathname)
! if has_magic(dirname):
 list = glob(dirname)
 else:
--- 19,25 ----
 return []
 dirname, basename = os.path.split(pathname)
! if not dirname:
! return glob1(os.curdir, basename)
! elif has_magic(dirname):
 list = glob(dirname)
 else:
***************
*** 44,53 ****
 except os.error:
 return []
! result = []
! for name in names:
! if name[0] != '.' or pattern[0] == '.':
! if fnmatch.fnmatch(name, pattern):
! result.append(name)
! return result
 
 
--- 46,52 ----
 except os.error:
 return []
! if pattern[0]!='.':
! names=filter(lambda x: x[0]!='.',names)
! return fnmatch.filter(names,pattern)
 
 
Index: htmllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/htmllib.py,v
retrieving revision 1.17
retrieving revision 1.17.6.1
diff -C2 -r1.17 -r1.17.6.1
*** htmllib.py	2001年02月09日 08:21:17	1.17
--- htmllib.py	2001年07月07日 22:55:27	1.17.6.1
***************
*** 363,370 ****
 if attrname == 'width':
 try: width = int(value)
! except: pass
 if attrname == 'height':
 try: height = int(value)
! except: pass
 self.handle_image(src, alt, ismap, align, width, height)
 
--- 363,370 ----
 if attrname == 'width':
 try: width = int(value)
! except ValueError: pass
 if attrname == 'height':
 try: height = int(value)
! except ValueError: pass
 self.handle_image(src, alt, ismap, align, width, height)
 
Index: httplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v
retrieving revision 1.34
retrieving revision 1.34.4.1
diff -C2 -r1.34 -r1.34.4.1
*** httplib.py	2001年04月13日 14:57:08	1.34
--- httplib.py	2001年07月07日 22:55:27	1.34.4.1
***************
*** 75,79 ****
 from StringIO import StringIO
 
! __all__ = ["HTTP"]
 
 HTTP_PORT = 80
--- 75,84 ----
 from StringIO import StringIO
 
! __all__ = ["HTTP", "HTTPResponse", "HTTPConnection", "HTTPSConnection",
! "HTTPException", "NotConnected", "UnknownProtocol",
! "UnknownTransferEncoding", "IllegalKeywordArgument",
! "UnimplementedFileMode", "IncompleteRead",
! "ImproperConnectionState", "CannotSendRequest", "CannotSendHeader",
! "ResponseNotReady", "BadStatusLine", "error"]
 
 HTTP_PORT = 80
Index: imaplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v
retrieving revision 1.27
retrieving revision 1.27.6.1
diff -C2 -r1.27 -r1.27.6.1
*** imaplib.py	2001年02月22日 13:24:27	1.27
--- imaplib.py	2001年07月07日 22:55:27	1.27.6.1
***************
*** 59,62 ****
--- 59,63 ----
 'UID': ('SELECTED',),
 'UNSUBSCRIBE': ('AUTH', 'SELECTED'),
+ 'NAMESPACE': ('AUTH', 'SELECTED'),
 }
 
***************
*** 572,575 ****
--- 573,582 ----
 return apply(self._simple_command, (name,) + args)
 
+ def namespace(self):
+ """ Returns IMAP namespaces ala rfc2342
+ """
+ name = 'NAMESPACE'
+ typ, dat = self._simple_command(name)
+ return self._untagged_response(typ, dat, name)
 
 
Index: keyword.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/keyword.py,v
retrieving revision 1.10
retrieving revision 1.10.6.1
diff -C2 -r1.10 -r1.10.6.1
*** keyword.py	2001年02月09日 09:10:35	1.10
--- keyword.py	2001年07月07日 22:55:27	1.10.6.1
***************
*** 43,46 ****
--- 43,47 ----
 'try',
 'while',
+ 'yield',
 #--end keywords--
 ]
Index: linecache.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/linecache.py,v
retrieving revision 1.7
retrieving revision 1.7.6.1
diff -C2 -r1.7 -r1.7.6.1
*** linecache.py	2001年01月24日 06:27:27	1.7
--- linecache.py	2001年07月07日 22:55:27	1.7.6.1
***************
*** 70,82 ****
 stat = os.stat(fullname)
 except os.error, msg:
! # Try looking through the module search path
 basename = os.path.split(filename)[1]
 for dirname in sys.path:
! fullname = os.path.join(dirname, basename)
 try:
! stat = os.stat(fullname)
! break
! except os.error:
 pass
 else:
 # No luck
--- 70,89 ----
 stat = os.stat(fullname)
 except os.error, msg:
! # Try looking through the module search path.
 basename = os.path.split(filename)[1]
 for dirname in sys.path:
! # When using imputil, sys.path may contain things other than
! # strings; ignore them when it happens.
 try:
! fullname = os.path.join(dirname, basename)
! except (TypeError, AttributeError):
! # Not sufficiently string-like to do anything useful with.
 pass
+ else:
+ try:
+ stat = os.stat(fullname)
+ break
+ except os.error:
+ pass
 else:
 # No luck
Index: mailbox.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v
retrieving revision 1.30
retrieving revision 1.30.4.1
diff -C2 -r1.30 -r1.30.4.1
*** mailbox.py	2001年04月15日 13:32:27	1.30
--- mailbox.py	2001年07月07日 22:55:27	1.30.4.1
***************
*** 15,18 ****
--- 15,21 ----
 self.factory = factory
 
+ def __iter__(self):
+ return self
+ 
 def next(self):
 while 1:
***************
*** 192,195 ****
--- 195,201 ----
 self.factory = factory
 
+ def __iter__(self):
+ return self
+ 
 def next(self):
 if not self.boxes:
***************
*** 219,222 ****
--- 225,231 ----
 
 self.boxes = boxes
+ 
+ def __iter__(self):
+ return self
 
 def next(self):
Index: mailcap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/mailcap.py,v
retrieving revision 1.9
retrieving revision 1.9.6.1
diff -C2 -r1.9 -r1.9.6.1
*** mailcap.py	2001年02月09日 10:23:55	1.9
--- mailcap.py	2001年07月07日 22:55:27	1.9.6.1
***************
*** 21,25 ****
 try:
 fp = open(mailcap, 'r')
! except:
 continue
 morecaps = readmailcapfile(fp)
--- 21,25 ----
 try:
 fp = open(mailcap, 'r')
! except IOError:
 continue
 morecaps = readmailcapfile(fp)
Index: mhlib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v
retrieving revision 1.26
retrieving revision 1.26.6.1
diff -C2 -r1.26 -r1.26.6.1
*** mhlib.py	2001年02月10日 00:11:08	1.26
--- mhlib.py	2001年07月07日 22:55:27	1.26.6.1
***************
*** 531,535 ****
 toseq = tosequences[name]
 new = 0
! except:
 toseq = []
 new = 1
--- 531,535 ----
 toseq = tosequences[name]
 new = 0
! except KeyError:
 toseq = []
 new = 1
Index: mimetypes.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/mimetypes.py,v
retrieving revision 1.13
retrieving revision 1.13.6.1
diff -C2 -r1.13 -r1.13.6.1
*** mimetypes.py	2001年02月09日 09:44:47	1.13
--- mimetypes.py	2001年07月07日 22:55:28	1.13.6.1
***************
*** 198,204 ****
 '.png': 'image/png',
 '.ppm': 'image/x-portable-pixmap',
 '.py': 'text/x-python',
 '.pyc': 'application/x-python-code',
! '.ps': 'application/postscript',
 '.qt': 'video/quicktime',
 '.ras': 'image/x-cmu-raster',
--- 198,205 ----
 '.png': 'image/png',
 '.ppm': 'image/x-portable-pixmap',
+ '.ps': 'application/postscript',
 '.py': 'text/x-python',
 '.pyc': 'application/x-python-code',
! '.pyo': 'application/x-python-code',
 '.qt': 'video/quicktime',
 '.ras': 'image/x-cmu-raster',
Index: mimify.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/mimify.py,v
retrieving revision 1.20
retrieving revision 1.20.4.1
diff -C2 -r1.20 -r1.20.4.1
*** mimify.py	2001年04月10日 15:42:02	1.20
--- mimify.py	2001年07月07日 22:55:28	1.20.4.1
***************
*** 254,258 ****
 return newline + line
 
! mime_header = re.compile('([ \t(]|^)([-a-zA-Z0-9_+]*[177円-377円][-a-zA-Z0-9_+177円-377円]*)([ \t)]|\n)')
 
 def mime_encode_header(line):
--- 254,258 ----
 return newline + line
 
! mime_header = re.compile('([ \t(]|^)([-a-zA-Z0-9_+]*[177円-377円][-a-zA-Z0-9_+177円-377円]*)(?=[ \t)]|\n)')
 
 def mime_encode_header(line):
***************
*** 264,270 ****
 if res is None:
 break
! newline = '%s%s%s=?%s?Q?%s?=%s' % \
 (newline, line[pos:res.start(0)], res.group(1),
! CHARSET, mime_encode(res.group(2), 1), res.group(3))
 pos = res.end(0)
 return newline + line[pos:]
--- 264,270 ----
 if res is None:
 break
! newline = '%s%s%s=?%s?Q?%s?=' % \
 (newline, line[pos:res.start(0)], res.group(1),
! CHARSET, mime_encode(res.group(2), 1))
 pos = res.end(0)
 return newline + line[pos:]
Index: ntpath.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v
retrieving revision 1.34
retrieving revision 1.34.6.1
diff -C2 -r1.34 -r1.34.6.1
*** ntpath.py	2001年02月06日 01:07:01	1.34
--- ntpath.py	2001年07月07日 22:55:28	1.34.6.1
***************
*** 405,422 ****
 def abspath(path):
 """Return the absolute version of a path"""
- try:
- import win32api
- except ImportError:
- global abspath
- def _abspath(path):
- if not isabs(path):
- path = join(os.getcwd(), path)
- return normpath(path)
- abspath = _abspath
- return _abspath(path)
 if path: # Empty path must return current working directory.
 try:
! path = win32api.GetFullPathName(path)
! except win32api.error:
 pass # Bad path - return unchanged.
 else:
--- 405,413 ----
 def abspath(path):
 """Return the absolute version of a path"""
 if path: # Empty path must return current working directory.
+ from nt import _getfullpathname
 try:
! path = _getfullpathname(path)
! except WindowsError:
 pass # Bad path - return unchanged.
 else:
Index: pipes.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pipes.py,v
retrieving revision 1.8
retrieving revision 1.8.6.1
diff -C2 -r1.8 -r1.8.6.1
*** pipes.py	2001年02月07日 23:14:30	1.8
--- pipes.py	2001年07月07日 22:55:28	1.8.6.1
***************
*** 124,131 ****
 raise ValueError, \
 'Template.append: already ends with SINK'
! if kind[0] == 'f' and not re.search('\$IN\b', cmd):
 raise ValueError, \
 'Template.append: missing $IN in cmd'
! if kind[1] == 'f' and not re.search('\$OUT\b', cmd):
 raise ValueError, \
 'Template.append: missing $OUT in cmd'
--- 124,131 ----
 raise ValueError, \
 'Template.append: already ends with SINK'
! if kind[0] == 'f' and not re.search(r'\$IN\b', cmd):
 raise ValueError, \
 'Template.append: missing $IN in cmd'
! if kind[1] == 'f' and not re.search(r'\$OUT\b', cmd):
 raise ValueError, \
 'Template.append: missing $OUT in cmd'
***************
*** 146,153 ****
 raise ValueError, \
 'Template.prepend: already begins with SOURCE'
! if kind[0] == 'f' and not re.search('\$IN\b', cmd):
 raise ValueError, \
 'Template.prepend: missing $IN in cmd'
! if kind[1] == 'f' and not re.search('\$OUT\b', cmd):
 raise ValueError, \
 'Template.prepend: missing $OUT in cmd'
--- 146,153 ----
 raise ValueError, \
 'Template.prepend: already begins with SOURCE'
! if kind[0] == 'f' and not re.search(r'\$IN\b', cmd):
 raise ValueError, \
 'Template.prepend: missing $IN in cmd'
! if kind[1] == 'f' and not re.search(r'\$OUT\b', cmd):
 raise ValueError, \
 'Template.prepend: missing $OUT in cmd'
Index: posixfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/posixfile.py,v
retrieving revision 1.20
retrieving revision 1.20.4.1
diff -C2 -r1.20 -r1.20.4.1
*** posixfile.py	2001年04月10日 15:44:33	1.20
--- posixfile.py	2001年07月07日 22:55:28	1.20.4.1
***************
*** 108,112 ****
 
 def flags(self, *which):
! import fcntl, FCNTL
 
 if which:
--- 108,112 ----
 
 def flags(self, *which):
! import fcntl
 
 if which:
***************
*** 117,158 ****
 
 l_flags = 0
! if 'n' in which: l_flags = l_flags | FCNTL.O_NDELAY
! if 'a' in which: l_flags = l_flags | FCNTL.O_APPEND
! if 's' in which: l_flags = l_flags | FCNTL.O_SYNC
 
 file = self._file_
 
 if '=' not in which:
! cur_fl = fcntl.fcntl(file.fileno(), FCNTL.F_GETFL, 0)
 if '!' in which: l_flags = cur_fl & ~ l_flags
 else: l_flags = cur_fl | l_flags
 
! l_flags = fcntl.fcntl(file.fileno(), FCNTL.F_SETFL, l_flags)
 
 if 'c' in which:
 arg = ('!' not in which) # 0 is don't, 1 is do close on exec
! l_flags = fcntl.fcntl(file.fileno(), FCNTL.F_SETFD, arg)
 
 if '?' in which:
 which = '' # Return current flags
! l_flags = fcntl.fcntl(file.fileno(), FCNTL.F_GETFL, 0)
! if FCNTL.O_APPEND & l_flags: which = which + 'a'
! if fcntl.fcntl(file.fileno(), FCNTL.F_GETFD, 0) & 1:
 which = which + 'c'
! if FCNTL.O_NDELAY & l_flags: which = which + 'n'
! if FCNTL.O_SYNC & l_flags: which = which + 's'
 return which
 
 def lock(self, how, *args):
! import struct, fcntl, FCNTL
 
! if 'w' in how: l_type = FCNTL.F_WRLCK
! elif 'r' in how: l_type = FCNTL.F_RDLCK
! elif 'u' in how: l_type = FCNTL.F_UNLCK
 else: raise TypeError, 'no type of lock specified'
 
! if '|' in how: cmd = FCNTL.F_SETLKW
! elif '?' in how: cmd = FCNTL.F_GETLK
! else: cmd = FCNTL.F_SETLK
 
 l_whence = 0
--- 117,158 ----
 
 l_flags = 0
! if 'n' in which: l_flags = l_flags | os.O_NDELAY
! if 'a' in which: l_flags = l_flags | os.O_APPEND
! if 's' in which: l_flags = l_flags | os.O_SYNC
 
 file = self._file_
 
 if '=' not in which:
! cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
 if '!' in which: l_flags = cur_fl & ~ l_flags
 else: l_flags = cur_fl | l_flags
 
! l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFL, l_flags)
 
 if 'c' in which:
 arg = ('!' not in which) # 0 is don't, 1 is do close on exec
! l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg)
 
 if '?' in which:
 which = '' # Return current flags
! l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
! if os.O_APPEND & l_flags: which = which + 'a'
! if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1:
 which = which + 'c'
! if os.O_NDELAY & l_flags: which = which + 'n'
! if os.O_SYNC & l_flags: which = which + 's'
 return which
 
 def lock(self, how, *args):
! import struct, fcntl
 
! if 'w' in how: l_type = fcntl.F_WRLCK
! elif 'r' in how: l_type = fcntl.F_RDLCK
! elif 'u' in how: l_type = fcntl.F_UNLCK
 else: raise TypeError, 'no type of lock specified'
 
! if '|' in how: cmd = fcntl.F_SETLKW
! elif '?' in how: cmd = fcntl.F_GETLK
! else: cmd = fcntl.F_SETLK
 
 l_whence = 0
***************
*** 204,209 ****
 struct.unpack('hhllhh', flock)
 
! if l_type != FCNTL.F_UNLCK:
! if l_type == FCNTL.F_RDLCK:
 return 'r', l_len, l_start, l_whence, l_pid
 else:
--- 204,209 ----
 struct.unpack('hhllhh', flock)
 
! if l_type != fcntl.F_UNLCK:
! if l_type == fcntl.F_RDLCK:
 return 'r', l_len, l_start, l_whence, l_pid
 else:
Index: pprint.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pprint.py,v
retrieving revision 1.12
retrieving revision 1.12.6.1
diff -C2 -r1.12 -r1.12.6.1
*** pprint.py	2001年02月12日 02:00:42	1.12
--- pprint.py	2001年07月07日 22:55:28	1.12.6.1
***************
*** 50,74 ****
 printer.pprint(object)
 
- 
 def pformat(object):
 """Format a Python object into a pretty-printed representation."""
 return PrettyPrinter().pformat(object)
 
 
 def isreadable(object):
 """Determine if saferepr(object) is readable by eval()."""
! return PrettyPrinter().isreadable(object)
! 
 
 def isrecursive(object):
 """Determine if object requires a recursive representation."""
! return PrettyPrinter().isrecursive(object)
! 
! 
! def saferepr(object):
! """Version of repr() which can handle recursive data structures."""
! return _safe_repr(object, {})[0]
 
- 
 class PrettyPrinter:
 def __init__(self, indent=1, width=80, depth=None, stream=None):
--- 50,69 ----
 printer.pprint(object)
 
 def pformat(object):
 """Format a Python object into a pretty-printed representation."""
 return PrettyPrinter().pformat(object)
 
+ def saferepr(object):
+ """Version of repr() which can handle recursive data structures."""
+ return _safe_repr(object, {})[0]
 
 def isreadable(object):
 """Determine if saferepr(object) is readable by eval()."""
! return _safe_repr(object, {})[1]
 
 def isrecursive(object):
 """Determine if object requires a recursive representation."""
! return _safe_repr(object, {})[2]
 
 class PrettyPrinter:
 def __init__(self, indent=1, width=80, depth=None, stream=None):
***************
*** 93,97 ****
 width = int(width)
 assert indent >= 0
! assert (not depth) or depth > 0, "depth may not be negative"
 assert width
 self.__depth = depth
--- 88,92 ----
 width = int(width)
 assert indent >= 0
! assert depth is None or depth > 0, "depth must be > 0"
 assert width
 self.__depth = depth
***************
*** 183,243 ****
 
 def __repr(self, object, context, level):
! repr, readable = _safe_repr(object, context, self.__depth, level)
 if not readable:
 self.__readable = 0
 return repr
 
 
 def _safe_repr(object, context, maxlevels=None, level=0):
! level = level + 1
 typ = type(object)
 if not (typ in (DictType, ListType, TupleType) and object):
 rep = `object`
! return rep, (rep and (rep[0] != '<'))
 if context.has_key(id(object)):
! return `_Recursion(object)`, 0
 objid = id(object)
 context[objid] = 1
 readable = 1
! if typ is DictType:
! if maxlevels and level >= maxlevels:
! s = "{...}"
! readable = 0
! else:
! items = object.items()
! k, v = items[0]
! krepr, kreadable = _safe_repr(k, context, maxlevels, level)
! vrepr, vreadable = _safe_repr(v, context, maxlevels, level)
 readable = readable and kreadable and vreadable
! s = "{%s: %s" % (krepr, vrepr)
! for k, v in items[1:]:
! krepr, kreadable = _safe_repr(k, context, maxlevels, level)
! vrepr, vreadable = _safe_repr(v, context, maxlevels, level)
! readable = readable and kreadable and vreadable
! s = "%s, %s: %s" % (s, krepr, vrepr)
! s = s + "}"
! else:
! s, term = (typ is ListType) and ('[', ']') or ('(', ')')
! if maxlevels and level >= maxlevels:
! s = s + "..."
! readable = 0
! else:
! subrepr, subreadable = _safe_repr(
! object[0], context, maxlevels, level)
 readable = readable and subreadable
! s = s + subrepr
! tail = object[1:]
! if not tail:
! if typ is TupleType:
! s = s + ','
! for ent in tail:
! subrepr, subreadable = _safe_repr(
! ent, context, maxlevels, level)
! readable = readable and subreadable
! s = "%s, %s" % (s, subrepr)
! s = s + term
! del context[objid]
! return s, readable
 
 
 class _Recursion:
--- 178,240 ----
 
 def __repr(self, object, context, level):
! repr, readable, recursive = _safe_repr(object, context,
! self.__depth, level)
 if not readable:
 self.__readable = 0
+ if recursive:
+ self.__recursive = 1
 return repr
 
+ # Return triple (repr_string, isreadable, isrecursive).
 
 def _safe_repr(object, context, maxlevels=None, level=0):
! level += 1
 typ = type(object)
 if not (typ in (DictType, ListType, TupleType) and object):
 rep = `object`
! return rep, (rep and (rep[0] != '<')), 0
! 
 if context.has_key(id(object)):
! return `_Recursion(object)`, 0, 1
 objid = id(object)
 context[objid] = 1
+ 
 readable = 1
! recursive = 0
! startchar, endchar = {ListType: "[]",
! TupleType: "()",
! DictType: "{}"}[typ]
! if maxlevels and level > maxlevels:
! with_commas = "..."
! readable = 0
! 
! elif typ is DictType:
! components = []
! for k, v in object.iteritems():
! krepr, kreadable, krecur = _safe_repr(k, context, maxlevels,
! level)
! vrepr, vreadable, vrecur = _safe_repr(v, context, maxlevels,
! level)
! components.append("%s: %s" % (krepr, vrepr))
 readable = readable and kreadable and vreadable
! recursive = recursive or krecur or vrecur
! with_commas = ", ".join(components)
! 
! else: # list or tuple
! assert typ in (ListType, TupleType)
! components = []
! for element in object:
! subrepr, subreadable, subrecur = _safe_repr(
! element, context, maxlevels, level)
! components.append(subrepr)
 readable = readable and subreadable
! recursive = recursive or subrecur
! if len(components) == 1 and typ is TupleType:
! components[0] += ","
! with_commas = ", ".join(components)
 
+ s = "%s%s%s" % (startchar, with_commas, endchar)
+ del context[objid]
+ return s, readable and not recursive, recursive
 
 class _Recursion:
Index: pre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pre.py,v
retrieving revision 1.9
retrieving revision 1.9.6.1
diff -C2 -r1.9 -r1.9.6.1
*** pre.py	2001年03月10日 09:33:14	1.9
--- pre.py	2001年07月07日 22:55:28	1.9.6.1
***************
*** 365,369 ****
 try:
 repl = pcre_expand(_Dummy, repl)
! except:
 m = MatchObject(self, source, 0, end, [])
 repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl)
--- 365,369 ----
 try:
 repl = pcre_expand(_Dummy, repl)
! except error:
 m = MatchObject(self, source, 0, end, [])
 repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl)
Index: profile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v
retrieving revision 1.27
retrieving revision 1.27.4.1
diff -C2 -r1.27 -r1.27.4.1
*** profile.py	2001年03月14日 20:01:19	1.27
--- profile.py	2001年07月07日 22:55:28	1.27.4.1
***************
*** 90,93 ****
--- 90,104 ----
 
 
+ if os.name == "mac":
+ import MacOS
+ def _get_time_mac(timer=MacOS.GetTicks):
+ return timer() / 60.0
+ 
+ if hasattr(os, "times"):
+ def _get_time_times(timer=os.times):
+ t = timer()
+ return t[0] + t[1]
+ 
+ 
 class Profile:
 """Profiler class.
***************
*** 133,142 ****
 self.cmd = ""
 
- self.dispatch = { \
- 'call' : self.trace_dispatch_call, \
- 'return' : self.trace_dispatch_return, \
- 'exception': self.trace_dispatch_exception, \
- }
- 
 if not timer:
 if os.name == 'mac':
--- 144,147 ----
***************
*** 144,156 ****
 self.timer = MacOS.GetTicks
 self.dispatcher = self.trace_dispatch_mac
! self.get_time = self.get_time_mac
 elif hasattr(time, 'clock'):
! self.timer = time.clock
 self.dispatcher = self.trace_dispatch_i
 elif hasattr(os, 'times'):
 self.timer = os.times
 self.dispatcher = self.trace_dispatch
 else:
! self.timer = time.time
 self.dispatcher = self.trace_dispatch_i
 else:
--- 149,162 ----
 self.timer = MacOS.GetTicks
 self.dispatcher = self.trace_dispatch_mac
! self.get_time = _get_time_mac
 elif hasattr(time, 'clock'):
! self.timer = self.get_time = time.clock
 self.dispatcher = self.trace_dispatch_i
 elif hasattr(os, 'times'):
 self.timer = os.times
 self.dispatcher = self.trace_dispatch
+ self.get_time = _get_time_times
 else:
! self.timer = self.get_time = time.time
 self.dispatcher = self.trace_dispatch_i
 else:
***************
*** 158,192 ****
 t = self.timer() # test out timer function
 try:
! if len(t) == 2:
 self.dispatcher = self.trace_dispatch
 else:
 self.dispatcher = self.trace_dispatch_l
! except TypeError:
! self.dispatcher = self.trace_dispatch_i
 self.t = self.get_time()
 self.simulate_call('profiler')
 
- 
- def get_time(self): # slow simulation of method to acquire time
- t = self.timer()
- if type(t) == type(()) or type(t) == type([]):
- t = reduce(lambda x,y: x+y, t, 0)
- return t
- 
- def get_time_mac(self):
- return self.timer()/60.0
- 
 # Heavily optimized dispatch routine for os.times() timer
 
 def trace_dispatch(self, frame, event, arg):
! t = self.timer()
 t = t[0] + t[1] - self.t # No Calibration constant
 # t = t[0] + t[1] - self.t - .00053 # Calibration constant
 
! if self.dispatch[event](frame,t):
! t = self.timer()
 self.t = t[0] + t[1]
 else:
! r = self.timer()
 self.t = r[0] + r[1] - t # put back unrecorded delta
 return
--- 164,201 ----
 t = self.timer() # test out timer function
 try:
! length = len(t)
! except TypeError:
! self.get_time = timer
! self.dispatcher = self.trace_dispatch_i
! else:
! if length == 2:
 self.dispatcher = self.trace_dispatch
 else:
 self.dispatcher = self.trace_dispatch_l
! # This get_time() implementation needs to be defined
! # here to capture the passed-in timer in the parameter
! # list (for performance). Note that we can't assume
! # the timer() result contains two values in all
! # cases.
! def get_time_timer(timer=timer,
! reduce=reduce, reducer=operator.add):
! return reduce(reducer, timer(), 0)
! self.get_time = get_time_timer
 self.t = self.get_time()
 self.simulate_call('profiler')
 
 # Heavily optimized dispatch routine for os.times() timer
 
 def trace_dispatch(self, frame, event, arg):
! timer = self.timer
! t = timer()
 t = t[0] + t[1] - self.t # No Calibration constant
 # t = t[0] + t[1] - self.t - .00053 # Calibration constant
 
! if self.dispatch[event](self, frame,t):
! t = timer()
 self.t = t[0] + t[1]
 else:
! r = timer()
 self.t = r[0] + r[1] - t # put back unrecorded delta
 return
***************
*** 197,215 ****
 
 def trace_dispatch_i(self, frame, event, arg):
! t = self.timer() - self.t # - 1 # Integer calibration constant
! if self.dispatch[event](frame,t):
! self.t = self.timer()
 else:
! self.t = self.timer() - t # put back unrecorded delta
 return
 
! # Dispatch routine for macintosh (timer returns time in ticks of 1/60th second)
 
 def trace_dispatch_mac(self, frame, event, arg):
! t = self.timer()/60.0 - self.t # - 1 # Integer calibration constant
! if self.dispatch[event](frame,t):
! self.t = self.timer()/60.0
 else:
! self.t = self.timer()/60.0 - t # put back unrecorded delta
 return
 
--- 206,227 ----
 
 def trace_dispatch_i(self, frame, event, arg):
! timer = self.timer
! t = timer() - self.t # - 1 # Integer calibration constant
! if self.dispatch[event](self, frame,t):
! self.t = timer()
 else:
! self.t = timer() - t # put back unrecorded delta
 return
 
! # Dispatch routine for macintosh (timer returns time in ticks of
! # 1/60th second)
 
 def trace_dispatch_mac(self, frame, event, arg):
! timer = self.timer
! t = timer()/60.0 - self.t # - 1 # Integer calibration constant
! if self.dispatch[event](self, frame,t):
! self.t = timer()/60.0
 else:
! self.t = timer()/60.0 - t # put back unrecorded delta
 return
 
***************
*** 218,227 ****
 
 def trace_dispatch_l(self, frame, event, arg):
! t = self.get_time() - self.t
 
! if self.dispatch[event](frame,t):
! self.t = self.get_time()
 else:
! self.t = self.get_time()-t # put back unrecorded delta
 return
 
--- 230,240 ----
 
 def trace_dispatch_l(self, frame, event, arg):
! get_time = self.get_time
! t = get_time() - self.t
 
! if self.dispatch[event](self, frame,t):
! self.t = get_time()
 else:
! self.t = get_time() - t # put back unrecorded delta
 return
 
***************
*** 238,246 ****
 fn = (fcode.co_filename, fcode.co_firstlineno, fcode.co_name)
 self.cur = (t, 0, 0, fn, frame, self.cur)
! if self.timings.has_key(fn):
! cc, ns, tt, ct, callers = self.timings[fn]
! self.timings[fn] = cc, ns + 1, tt, ct, callers
 else:
! self.timings[fn] = 0, 0, 0, 0, {}
 return 1
 
--- 251,260 ----
 fn = (fcode.co_filename, fcode.co_firstlineno, fcode.co_name)
 self.cur = (t, 0, 0, fn, frame, self.cur)
! timings = self.timings
! if timings.has_key(fn):
! cc, ns, tt, ct, callers = timings[fn]
! timings[fn] = cc, ns + 1, tt, ct, callers
 else:
! timings[fn] = 0, 0, 0, 0, {}
 return 1
 
***************
*** 258,262 ****
 self.cur = pt, ptt+rt, pct+sft, pfn, pframe, pcur
 
! cc, ns, tt, ct, callers = self.timings[rfn]
 if not ns:
 ct = ct + sft
--- 272,277 ----
 self.cur = pt, ptt+rt, pct+sft, pfn, pframe, pcur
 
! timings = self.timings
! cc, ns, tt, ct, callers = timings[rfn]
 if not ns:
 ct = ct + sft
***************
*** 269,276 ****
 else:
 callers[pfn] = 1
! self.timings[rfn] = cc, ns - 1, tt+rtt, ct, callers
 
 return 1
 
 # The next few function play with self.cmd. By carefully preloading
 # our parallel stack, we can force the profiled result to include
--- 284,299 ----
 else:
 callers[pfn] = 1
! timings[rfn] = cc, ns - 1, tt+rtt, ct, callers
 
 return 1
 
+ 
+ dispatch = {
+ "call": trace_dispatch_call,
+ "exception": trace_dispatch_exception,
+ "return": trace_dispatch_return,
+ }
+ 
+ 
 # The next few function play with self.cmd. By carefully preloading
 # our parallel stack, we can force the profiled result to include
***************
*** 306,310 ****
 pframe = None
 frame = self.fake_frame(code, pframe)
! a = self.dispatch['call'](frame, 0)
 return
 
--- 329,333 ----
 pframe = None
 frame = self.fake_frame(code, pframe)
! a = self.dispatch['call'](self, frame, 0)
 return
 
***************
*** 313,323 ****
 
 def simulate_cmd_complete(self):
! t = self.get_time() - self.t
 while self.cur[-1]:
 # We *can* cause assertion errors here if
 # dispatch_trace_return checks for a frame match!
! a = self.dispatch['return'](self.cur[-2], t)
 t = 0
! self.t = self.get_time() - t
 
 
--- 336,347 ----
 
 def simulate_cmd_complete(self):
! get_time = self.get_time
! t = get_time() - self.t
 while self.cur[-1]:
 # We *can* cause assertion errors here if
 # dispatch_trace_return checks for a frame match!
! a = self.dispatch['return'](self, self.cur[-2], t)
 t = 0
! self.t = get_time() - t
 
 
***************
*** 366,374 ****
 
 # This method is more useful to profile a single function call.
! def runcall(self, func, *args):
 self.set_cmd(`func`)
 sys.setprofile(self.dispatcher)
 try:
! return apply(func, args)
 finally:
 sys.setprofile(None)
--- 390,398 ----
 
 # This method is more useful to profile a single function call.
! def runcall(self, func, *args, **kw):
 self.set_cmd(`func`)
 sys.setprofile(self.dispatcher)
 try:
! return apply(func, args, kw)
 finally:
 sys.setprofile(None)
***************
*** 420,438 ****
 def calibrate(self, m):
 # Modified by Tim Peters
 n = m
! s = self.get_time()
 while n:
 self.simple()
 n = n - 1
! f = self.get_time()
 my_simple = f - s
 #print "Simple =", my_simple,
 
 n = m
! s = self.get_time()
 while n:
 self.instrumented()
 n = n - 1
! f = self.get_time()
 my_inst = f - s
 # print "Instrumented =", my_inst
--- 444,463 ----
 def calibrate(self, m):
 # Modified by Tim Peters
+ get_time = self.get_time
 n = m
! s = get_time()
 while n:
 self.simple()
 n = n - 1
! f = get_time()
 my_simple = f - s
 #print "Simple =", my_simple,
 
 n = m
! s = get_time()
 while n:
 self.instrumented()
 n = n - 1
! f = get_time()
 my_inst = f - s
 # print "Instrumented =", my_inst
***************
*** 504,507 ****
--- 529,539 ----
 
 
+ dispatch = {
+ "call": trace_dispatch_call,
+ "exception": trace_dispatch_exception,
+ "return": trace_dispatch_return,
+ }
+ 
+ 
 def snapshot_stats(self):
 self.stats = {}
***************
*** 550,553 ****
--- 582,592 ----
 
 
+ dispatch = {
+ "call": trace_dispatch_call,
+ "exception": trace_dispatch_exception,
+ "return": trace_dispatch_return,
+ }
+ 
+ 
 def snapshot_stats(self):
 self.stats = {}
***************
*** 565,570 ****
 # When invoked as main program, invoke the profiler on a script
 if __name__ == '__main__':
- import sys
- import os
 if not sys.argv[1:]:
 print "usage: profile.py scriptfile [arg] ..."
--- 604,607 ----
Index: pstats.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pstats.py,v
retrieving revision 1.15
retrieving revision 1.15.4.1
diff -C2 -r1.15 -r1.15.4.1
*** pstats.py	2001年04月14日 15:16:05	1.15
--- pstats.py	2001年07月07日 22:55:28	1.15.4.1
***************
*** 534,538 ****
 try:
 import readline
! except:
 pass
 
--- 534,538 ----
 try:
 import readline
! except ImportError:
 pass
 
***************
*** 569,572 ****
--- 569,579 ----
 print "No statistics object is loaded."
 return 0
+ def generic_help(self):
+ print "Arguments may be:"
+ print "* An integer maximum number of entries to print."
+ print "* A decimal fractional number between 0 and 1, controlling"
+ print " what fraction of selected entries to print."
+ print "* A regular expression; only entries with function names"
+ print " that match it are printed."
 
 def do_add(self, line):
***************
*** 574,578 ****
 return 0
 def help_add(self):
! print "Add profile info from given file to current stastics object."
 
 def do_callees(self, line):
--- 581,585 ----
 return 0
 def help_add(self):
! print "Add profile info from given file to current statistics object."
 
 def do_callees(self, line):
***************
*** 580,583 ****
--- 587,591 ----
 def help_callees(self):
 print "Print callees statistics from the current stat object."
+ self.generic_help()
 
 def do_callers(self, line):
***************
*** 585,588 ****
--- 593,597 ----
 def help_callers(self):
 print "Print callers statistics from the current stat object."
+ self.generic_help()
 
 def do_EOF(self, line):
***************
*** 605,609 ****
 return
 self.prompt = line + "% "
! elif len(self.prompt > 2):
 line = self.prompt[-2:]
 else:
--- 614,618 ----
 return
 self.prompt = line + "% "
! elif len(self.prompt) > 2:
 line = self.prompt[-2:]
 else:
***************
*** 620,627 ****
 
 def do_sort(self, line):
! apply(self.stats.sort_stats, line.split())
 return 0
 def help_sort(self):
 print "Sort profile data according to specified keys."
 
 def do_stats(self, line):
--- 629,643 ----
 
 def do_sort(self, line):
! abbrevs = self.stats.get_sort_arg_defs().keys()
! if line and not filter(lambda x,a=abbrevs: x not in a,line.split()):
! apply(self.stats.sort_stats, line.split())
! else:
! print "Valid sort keys (unique prefixes are accepted):"
! for (key, value) in Stats.sort_arg_dict_default.items():
! print "%s -- %s" % (key, value[1])
 return 0
 def help_sort(self):
 print "Sort profile data according to specified keys."
+ print "(Typing `sort' without arguments lists valid keys.)"
 
 def do_stats(self, line):
***************
*** 629,632 ****
--- 645,649 ----
 def help_stats(self):
 print "Print statistics from the current stat object."
+ self.generic_help()
 
 def do_strip(self, line):
Index: pty.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pty.py,v
retrieving revision 1.7
retrieving revision 1.7.6.1
diff -C2 -r1.7 -r1.7.6.1
*** pty.py	2001年02月12日 02:00:42	1.7
--- pty.py	2001年07月07日 22:55:28	1.7.6.1
***************
*** 8,12 ****
 
 from select import select
! import os, FCNTL
 import tty
 
--- 8,23 ----
 
 from select import select
! import os
! 
! # Absurd: import termios and then delete it. This is to force an attempt
! # to import pty to raise an ImportError on platforms that lack termios.
! # Without this explicit import of termios here, some other module may
! # import tty first, which in turn imports termios and dies with an
! # ImportError then. But since tty *does* exist across platforms, that
! # leaves a damaged module object for tty in sys.modules, and the import
! # of tty here then appears to work despite that the tty imported is junk.
! import termios
! del termios
! 
 import tty
 
***************
*** 56,60 ****
 else:
 try:
! tty_name, master_fd = sgi._getpty(FCNTL.O_RDWR, 0666, 0)
 except IOError, msg:
 raise os.error, msg
--- 67,71 ----
 else:
 try:
! tty_name, master_fd = sgi._getpty(os.O_RDWR, 0666, 0)
 except IOError, msg:
 raise os.error, msg
***************
*** 64,68 ****
 pty_name = '/dev/pty' + x + y
 try:
! fd = os.open(pty_name, FCNTL.O_RDWR)
 except os.error:
 continue
--- 75,79 ----
 pty_name = '/dev/pty' + x + y
 try:
! fd = os.open(pty_name, os.O_RDWR)
 except os.error:
 continue
***************
*** 76,80 ****
 Deprecated, use openpty() instead."""
 
! return os.open(tty_name, FCNTL.O_RDWR)
 
 def fork():
--- 87,91 ----
 Deprecated, use openpty() instead."""
 
! return os.open(tty_name, os.O_RDWR)
 
 def fork():
***************
*** 148,151 ****
 try:
 _copy(master_fd, master_read, stdin_read)
! except:
 tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)
--- 159,162 ----
 try:
 _copy(master_fd, master_read, stdin_read)
! except IOError:
 tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)
Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v
retrieving revision 1.38
retrieving revision 1.38.4.1
diff -C2 -r1.38 -r1.38.4.1
*** pydoc.py	2001年04月13日 15:04:32	1.38
--- pydoc.py	2001年07月07日 22:55:28	1.38.4.1
***************
*** 1285,1289 ****
 self.interact()
 self.output.write('''
! You're now leaving help and returning to the Python interpreter.
 If you want to ask for help on a particular object directly from the
 interpreter, you can type "help(object)". Executing "help('string')"
--- 1285,1289 ----
 self.interact()
 self.output.write('''
! You are now leaving help and returning to the Python interpreter.
 If you want to ask for help on a particular object directly from the
 interpreter, you can type "help(object)". Executing "help('string')"
Index: quopri.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/quopri.py,v
retrieving revision 1.11
retrieving revision 1.11.4.1
diff -C2 -r1.11 -r1.11.4.1
*** quopri.py	2001年03月22日 22:30:21	1.11
--- quopri.py	2001年07月07日 22:55:28	1.11.4.1
***************
*** 1,21 ****
 #! /usr/bin/env python
 
! """Conversions to/from quoted-printable transport encoding as per RFC-1521."""
 
 # (Dec 1991 version).
 
! __all__ = ["encode","decode"]
 
 ESCAPE = '='
 MAXLINESIZE = 76
 HEX = '0123456789ABCDEF'
 
 def needsquoting(c, quotetabs):
 """Decide whether a particular character needs to be quoted.
 
! The 'quotetabs' flag indicates whether tabs should be quoted."""
! if c == '\t':
! return not quotetabs
! return c == ESCAPE or not(' ' <= c <= '~')
 
 def quote(c):
--- 1,27 ----
 #! /usr/bin/env python
 
! """Conversions to/from quoted-printable transport encoding as per RFC 1521."""
 
 # (Dec 1991 version).
 
! __all__ = ["encode", "decode", "encodestring", "decodestring"]
 
 ESCAPE = '='
 MAXLINESIZE = 76
 HEX = '0123456789ABCDEF'
+ EMPTYSTRING = ''
 
+ 
+ 
 def needsquoting(c, quotetabs):
 """Decide whether a particular character needs to be quoted.
 
! The 'quotetabs' flag indicates whether embedded tabs and spaces should be
! quoted. Note that line-ending tabs and spaces are always encoded, as per
! RFC 1521.
! """
! if c in ' \t':
! return quotetabs
! return c == ESCAPE or not (' ' <= c <= '~')
 
 def quote(c):
***************
*** 24,57 ****
 return ESCAPE + HEX[i/16] + HEX[i%16]
 
 def encode(input, output, quotetabs):
 """Read 'input', apply quoted-printable encoding, and write to 'output'.
 
 'input' and 'output' are files with readline() and write() methods.
! The 'quotetabs' flag indicates whether tabs should be quoted.
! """
 while 1:
 line = input.readline()
 if not line:
 break
! new = ''
! last = line[-1:]
! if last == '\n':
 line = line[:-1]
! else:
! last = ''
! prev = ''
 for c in line:
 if needsquoting(c, quotetabs):
 c = quote(c)
! if len(new) + len(c) >= MAXLINESIZE:
! output.write(new + ESCAPE + '\n')
! new = ''
! new = new + c
! prev = c
! if prev in (' ', '\t'):
! output.write(new + ESCAPE + '\n\n')
! else:
! output.write(new + '\n')
 
 def decode(input, output):
 """Read 'input', apply quoted-printable decoding, and write to 'output'.
--- 30,93 ----
 return ESCAPE + HEX[i/16] + HEX[i%16]
 
+ 
+ 
 def encode(input, output, quotetabs):
 """Read 'input', apply quoted-printable encoding, and write to 'output'.
 
 'input' and 'output' are files with readline() and write() methods.
! The 'quotetabs' flag indicates whether embedded tabs and spaces should be
! quoted. Note that line-ending tabs and spaces are always encoded, as per
! RFC 1521.
! """
! def write(s, output=output, lineEnd='\n'):
! # RFC 1521 requires that the line ending in a space or tab must have
! # that trailing character encoded.
! if s and s[-1:] in ' \t':
! output.write(s[:-1] + quote(s[-1]) + lineEnd)
! else:
! output.write(s + lineEnd)
! 
! prevline = None
 while 1:
 line = input.readline()
 if not line:
 break
! outline = []
! # Strip off any readline induced trailing newline
! stripped = ''
! if line[-1:] == '\n':
 line = line[:-1]
! stripped = '\n'
! # Calculate the un-length-limited encoded line
 for c in line:
 if needsquoting(c, quotetabs):
 c = quote(c)
! outline.append(c)
! # First, write out the previous line
! if prevline is not None:
! write(prevline)
! # Now see if we need any soft line breaks because of RFC-imposed
! # length limitations. Then do the thisline->prevline dance.
! thisline = EMPTYSTRING.join(outline)
! while len(thisline) > MAXLINESIZE:
! # Don't forget to include the soft line break `=' sign in the
! # length calculation!
! write(thisline[:MAXLINESIZE-1], lineEnd='=\n')
! thisline = thisline[MAXLINESIZE-1:]
! # Write out the current line
! prevline = thisline
! # Write out the last line, without a trailing newline
! if prevline is not None:
! write(prevline, lineEnd=stripped)
! 
! def encodestring(s, quotetabs=0):
! from cStringIO import StringIO
! infp = StringIO(s)
! outfp = StringIO()
! encode(infp, outfp, quotetabs)
! return outfp.getvalue()
 
+ 
+ 
 def decode(input, output):
 """Read 'input', apply quoted-printable decoding, and write to 'output'.
***************
*** 88,91 ****
--- 124,137 ----
 output.write(new)
 
+ def decodestring(s):
+ from cStringIO import StringIO
+ infp = StringIO(s)
+ outfp = StringIO()
+ decode(infp, outfp)
+ return outfp.getvalue()
+ 
+ 
+ 
+ # Other helper functions
 def ishex(c):
 """Return true if the character 'c' is a hexadecimal digit."""
***************
*** 107,111 ****
 return bits
 
! def test():
 import sys
 import getopt
--- 153,159 ----
 return bits
 
! 
! 
! def main():
 import sys
 import getopt
***************
*** 149,152 ****
 sys.exit(sts)
 
 if __name__ == '__main__':
! test()
--- 197,202 ----
 sys.exit(sts)
 
+ 
+ 
 if __name__ == '__main__':
! main()
Index: rexec.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v
retrieving revision 1.28
retrieving revision 1.28.6.1
diff -C2 -r1.28 -r1.28.6.1
*** rexec.py	2001年02月15日 22:15:13	1.28
--- rexec.py	2001年07月07日 22:55:28	1.28.6.1
***************
*** 124,128 ****
 'marshal', 'math', 'md5', 'operator',
 'parser', 'regex', 'pcre', 'rotor', 'select',
! 'strop', 'struct', 'time')
 
 ok_posix_names = ('error', 'fstat', 'listdir', 'lstat', 'readlink',
--- 124,128 ----
 'marshal', 'math', 'md5', 'operator',
 'parser', 'regex', 'pcre', 'rotor', 'select',
! 'sha', '_sre', 'strop', 'struct', 'time')
 
 ok_posix_names = ('error', 'fstat', 'listdir', 'lstat', 'readlink',
***************
*** 333,354 ****
 finally:
 self.restore_files()
 
 def s_exec(self, *args):
! self.s_apply(self.r_exec, args)
 
 def s_eval(self, *args):
! self.s_apply(self.r_eval, args)
 
 def s_execfile(self, *args):
! self.s_apply(self.r_execfile, args)
 
 def s_import(self, *args):
! self.s_apply(self.r_import, args)
 
 def s_reload(self, *args):
! self.s_apply(self.r_reload, args)
 
 def s_unload(self, *args):
! self.s_apply(self.r_unload, args)
 
 # Restricted open(...)
--- 333,355 ----
 finally:
 self.restore_files()
+ return r
 
 def s_exec(self, *args):
! return self.s_apply(self.r_exec, args)
 
 def s_eval(self, *args):
! return self.s_apply(self.r_eval, args)
 
 def s_execfile(self, *args):
! return self.s_apply(self.r_execfile, args)
 
 def s_import(self, *args):
! return self.s_apply(self.r_import, args)
 
 def s_reload(self, *args):
! return self.s_apply(self.r_reload, args)
 
 def s_unload(self, *args):
! return self.s_apply(self.r_unload, args)
 
 # Restricted open(...)
Index: rfc822.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v
retrieving revision 1.54
retrieving revision 1.54.6.1
diff -C2 -r1.54 -r1.54.6.1
*** rfc822.py	2001年02月15日 22:15:13	1.54
--- rfc822.py	2001年07月07日 22:55:28	1.54.6.1
***************
*** 75,79 ****
 try:
 fp.tell()
! except:
 seekable = 0
 else:
--- 75,79 ----
 try:
 fp.tell()
! except (AttributeError, IOError):
 seekable = 0
 else:
***************
*** 421,424 ****
--- 421,443 ----
 for i in list:
 del self.headers[i]
+ 
+ def get(self, name, default=""):
+ name = name.lower()
+ if self.dict.has_key(name):
+ return self.dict[name]
+ else:
+ return default
+ 
+ def setdefault(self, name, default=""):
+ lowername = name.lower()
+ if self.dict.has_key(lowername):
+ return self.dict[lowername]
+ else:
+ text = name + ": " + default
+ lines = text.split("\n")
+ for line in lines:
+ self.headers.append(line + "\n")
+ self.dict[lowername] = default
+ return default
 
 def has_key(self, name):
Index: sgmllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v
retrieving revision 1.30
retrieving revision 1.30.4.1
diff -C2 -r1.30 -r1.30.4.1
*** sgmllib.py	2001年04月15日 13:01:41	1.30
--- sgmllib.py	2001年07月07日 22:55:28	1.30.4.1
***************
*** 35,44 ****
 commentopen = re.compile('<!--')
 commentclose = re.compile(r'--\s*>')
! tagfind = re.compile('[a-zA-Z][-.a-zA-Z0-9]*')
 attrfind = re.compile(
 r'\s*([a-zA-Z_][-.a-zA-Z_0-9]*)(\s*=\s*'
! r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:;+*%?!&$\(\)_#=~]*))?')
 
! declname = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*')
 declstringlit = re.compile(r'(\'[^\']*\'|"[^"]*")\s*')
 
--- 35,44 ----
 commentopen = re.compile('<!--')
 commentclose = re.compile(r'--\s*>')
! tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*')
 attrfind = re.compile(
 r'\s*([a-zA-Z_][-.a-zA-Z_0-9]*)(\s*=\s*'
! r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:;+*%?!&$\(\)_#=~\'"]*))?')
 
! decldata = re.compile(r'[^>\'\"]+')
 declstringlit = re.compile(r'(\'[^\']*\'|"[^"]*")\s*')
 
***************
*** 213,218 ****
 rawdata = self.rawdata
 j = i + 2
! # in practice, this should look like: ((name|stringlit) S*)+ '>'
! while 1:
 c = rawdata[j:j+1]
 if c == ">":
--- 213,218 ----
 rawdata = self.rawdata
 j = i + 2
! n = len(rawdata)
! while j < n:
 c = rawdata[j:j+1]
 if c == ">":
***************
*** 226,242 ****
 return -1
 j = m.end()
! elif c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
! m = declname.match(rawdata, j)
 if not m:
 # incomplete or an error?
 return -1
 j = m.end()
! elif i == len(rawdata):
! # end of buffer between tokens
! return -1
! else:
! raise SGMLParseError(
! "unexpected char in declaration: %s" % `rawdata[i]`)
! assert 0, "can't get here!"
 
 # Internal -- parse processing instr, return length or -1 if not terminated
--- 226,237 ----
 return -1
 j = m.end()
! else:
! m = decldata.match(rawdata, j)
 if not m:
 # incomplete or an error?
 return -1
 j = m.end()
! # end of buffer between tokens
! return -1
 
 # Internal -- parse processing instr, return length or -1 if not terminated
Index: site.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v
retrieving revision 1.26
retrieving revision 1.26.4.1
diff -C2 -r1.26 -r1.26.4.1
*** site.py	2001年03月23日 17:53:49	1.26
--- site.py	2001年07月07日 22:55:28	1.26.4.1
***************
*** 67,86 ****
 
 def makepath(*paths):
! dir = os.path.join(*paths)
! return os.path.normcase(os.path.abspath(dir))
 
! L = sys.modules.values()
! for m in L:
 if hasattr(m, "__file__") and m.__file__:
! m.__file__ = makepath(m.__file__)
! del m, L
 
 # This ensures that the initial path provided by the interpreter contains
 # only absolute pathnames, even if we're running from the build directory.
 L = []
 for dir in sys.path:
! dir = makepath(dir)
! if dir not in L:
 L.append(dir)
 sys.path[:] = L
 del dir, L
--- 67,87 ----
 
 def makepath(*paths):
! dir = os.path.abspath(os.path.join(*paths))
! return dir, os.path.normcase(dir)
 
! for m in sys.modules.values():
 if hasattr(m, "__file__") and m.__file__:
! m.__file__ = os.path.abspath(m.__file__)
! del m
 
 # This ensures that the initial path provided by the interpreter contains
 # only absolute pathnames, even if we're running from the build directory.
 L = []
+ dirs_in_sys_path = {}
 for dir in sys.path:
! dir, dircase = makepath(dir)
! if not dirs_in_sys_path.has_key(dircase):
 L.append(dir)
+ dirs_in_sys_path[dircase] = 1
 sys.path[:] = L
 del dir, L
***************
*** 96,101 ****
 
 def addsitedir(sitedir):
! sitedir = makepath(sitedir)
! if sitedir not in sys.path:
 sys.path.append(sitedir) # Add path component
 try:
--- 97,102 ----
 
 def addsitedir(sitedir):
! sitedir, sitedircase = makepath(sitedir)
! if not dirs_in_sys_path.has_key(sitedircase):
 sys.path.append(sitedir) # Add path component
 try:
***************
*** 103,107 ****
 except os.error:
 return
- names = map(os.path.normcase, names)
 names.sort()
 for name in names:
--- 104,107 ----
***************
*** 126,132 ****
 if dir[-1] == '\n':
 dir = dir[:-1]
! dir = makepath(sitedir, dir)
! if dir not in sys.path and os.path.exists(dir):
 sys.path.append(dir)
 
 prefixes = [sys.prefix]
--- 126,133 ----
 if dir[-1] == '\n':
 dir = dir[:-1]
! dir, dircase = makepath(sitedir, dir)
! if not dirs_in_sys_path.has_key(dircase) and os.path.exists(dir):
 sys.path.append(dir)
+ dirs_in_sys_path[dircase] = 1
 
 prefixes = [sys.prefix]
***************
*** 136,146 ****
 if prefix:
 if os.sep == '/':
! sitedirs = [makepath(prefix,
! "lib",
! "python" + sys.version[:3],
! "site-packages"),
! makepath(prefix, "lib", "site-python")]
 elif os.sep == ':':
! sitedirs = [makepath(prefix, "lib", "site-packages")]
 else:
 sitedirs = [prefix]
--- 137,147 ----
 if prefix:
 if os.sep == '/':
! sitedirs = [os.path.join(prefix,
! "lib",
! "python" + sys.version[:3],
! "site-packages"),
! os.path.join(prefix, "lib", "site-python")]
 elif os.sep == ':':
! sitedirs = [os.path.join(prefix, "lib", "site-packages")]
 else:
 sitedirs = [prefix]
***************
*** 149,152 ****
--- 150,155 ----
 addsitedir(sitedir)
 
+ del dirs_in_sys_path
+ 
 # Define new built-ins 'quit' and 'exit'.
 # These are simply strings that display a hint on how to exit.
***************
*** 235,238 ****
--- 238,255 ----
 ["LICENSE.txt", "LICENSE"],
 [os.path.join(here, os.pardir), here, os.curdir])
+ 
+ 
+ # Define new built-in 'help'.
+ # This is a wrapper around pydoc.help (with a twist).
+ 
+ class _Helper:
+ def __repr__(self):
+ return "Type help() for interactive help, " \
+ "or help(object) for help about object."
+ def __call__(self, *args, **kwds):
+ import pydoc
+ return pydoc.help(*args, **kwds)
+ 
+ __builtin__.help = _Helper()
 
 
Index: sre_compile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v
retrieving revision 1.37
retrieving revision 1.37.4.1
diff -C2 -r1.37 -r1.37.4.1
*** sre_compile.py	2001年03月22日 15:50:10	1.37
--- sre_compile.py	2001年07月07日 22:55:28	1.37.4.1
***************
*** 157,160 ****
--- 157,162 ----
 elif op is CHARSET:
 code.extend(av)
+ elif op is BIGCHARSET:
+ code.extend(av)
 elif op is CATEGORY:
 if flags & SRE_FLAG_LOCALE:
***************
*** 186,190 ****
 except IndexError:
 # character set contains unicode characters
! return charset
 # compress character map
 i = p = n = 0
--- 188,192 ----
 except IndexError:
 # character set contains unicode characters
! return _optimize_unicode(charset, fixup)
 # compress character map
 i = p = n = 0
***************
*** 212,227 ****
 else:
 # use bitmap
! data = []
! m = 1; v = 0
! for c in charmap:
! if c:
! v = v + m
! m = m << 1
! if m > MAXCODE:
! data.append(v)
! m = 1; v = 0
 out.append((CHARSET, data))
 return out
 return charset
 
 def _simple(av):
--- 214,288 ----
 else:
 # use bitmap
! data = _mk_bitmap(charmap)
 out.append((CHARSET, data))
 return out
 return charset
+ 
+ def _mk_bitmap(bits):
+ data = []
+ m = 1; v = 0
+ for c in bits:
+ if c:
+ v = v + m
+ m = m << 1
+ if m > MAXCODE:
+ data.append(v)
+ m = 1; v = 0
+ return data
+ 
+ # To represent a big charset, first a bitmap of all characters in the
+ # set is constructed. Then, this bitmap is sliced into chunks of 256
+ # characters, duplicate chunks are eliminitated, and each chunk is
+ # given a number. In the compiled expression, the charset is
+ # represented by a 16-bit word sequence, consisting of one word for
+ # the number of different chunks, a sequence of 256 bytes (128 words)
+ # of chunk numbers indexed by their original chunk position, and a
+ # sequence of chunks (16 words each).
+ 
+ # Compression is normally good: in a typical charset, large ranges of
+ # Unicode will be either completely excluded (e.g. if only cyrillic
+ # letters are to be matched), or completely included (e.g. if large
+ # subranges of Kanji match). These ranges will be represented by
+ # chunks of all one-bits or all zero-bits.
+ 
+ # Matching can be also done efficiently: the more significant byte of
+ # the Unicode character is an index into the chunk number, and the
+ # less significant byte is a bit index in the chunk (just like the
+ # CHARSET matching).
+ 
+ def _optimize_unicode(charset, fixup):
+ charmap = [0]*65536
+ negate = 0
+ for op, av in charset:
+ if op is NEGATE:
+ negate = 1
+ elif op is LITERAL:
+ charmap[fixup(av)] = 1
+ elif op is RANGE:
+ for i in range(fixup(av[0]), fixup(av[1])+1):
+ charmap[i] = 1
+ elif op is CATEGORY:
+ # XXX: could expand category
+ return charset # cannot compress
+ if negate:
+ for i in range(65536):
+ charmap[i] = not charmap[i]
+ comps = {}
+ mapping = [0]*256
+ block = 0
+ data = []
+ for i in range(256):
+ chunk = tuple(charmap[i*256:(i+1)*256])
+ new = comps.setdefault(chunk, block)
+ mapping[i] = new
+ if new == block:
+ block += 1
+ data += _mk_bitmap(chunk)
+ header = [block]
+ assert MAXCODE == 65535
+ for i in range(128):
+ header.append(mapping[2*i]+256*mapping[2*i+1])
+ data[0:0] = header
+ return [(BIGCHARSET, data)] 
 
 def _simple(av):
Index: sre_constants.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v
retrieving revision 1.28
retrieving revision 1.28.4.1
diff -C2 -r1.28 -r1.28.4.1
*** sre_constants.py	2001年03月22日 15:50:10	1.28
--- sre_constants.py	2001年07月07日 22:55:28	1.28.4.1
***************
*** 12,16 ****
 # update when constants are added or removed
 
! MAGIC = 20010320
 
 # max code word in this release
--- 12,16 ----
 # update when constants are added or removed
 
! MAGIC = 20010701
 
 # max code word in this release
***************
*** 34,37 ****
--- 34,38 ----
 ASSERT_NOT = "assert_not"
 AT = "at"
+ BIGCHARSET = "bigcharset"
 BRANCH = "branch"
 CALL = "call"
***************
*** 104,108 ****
 CALL,
 CATEGORY,
! CHARSET,
 GROUPREF, GROUPREF_IGNORE,
 IN, IN_IGNORE,
--- 105,109 ----
 CALL,
 CATEGORY,
! CHARSET, BIGCHARSET,
 GROUPREF, GROUPREF_IGNORE,
 IN, IN_IGNORE,
Index: tabnanny.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tabnanny.py,v
retrieving revision 1.13
retrieving revision 1.13.4.1
diff -C2 -r1.13 -r1.13.4.1
*** tabnanny.py	2001年04月08日 00:38:42	1.13
--- tabnanny.py	2001年07月07日 22:55:28	1.13.4.1
***************
*** 15,18 ****
--- 15,20 ----
 import getopt
 import tokenize
+ if not hasattr(tokenize, 'NL'):
+ raise ValueError("tokenize.NL doesn't exist -- tokenize module too old")
 
 __all__ = ["check"]
***************
*** 78,84 ****
 print "checking", `file`, "..."
 
- reset_globals()
 try:
! tokenize.tokenize(f.readline, tokeneater)
 
 except tokenize.TokenError, msg:
--- 80,85 ----
 print "checking", `file`, "..."
 
 try:
! process_tokens(tokenize.generate_tokens(f.readline))
 
 except tokenize.TokenError, msg:
***************
*** 245,270 ****
 return prefix + " " + string.join(firsts, ', ')
 
! # The collection of globals, the reset_globals() function, and the
! # tokeneater() function, depend on which version of tokenize is
! # in use.
! 
! if hasattr(tokenize, 'NL'):
! # take advantage of Guido's patch!
! 
! indents = []
 check_equal = 0
 
! def reset_globals():
! global indents, check_equal
! check_equal = 0
! indents = [Whitespace("")]
! 
! def tokeneater(type, token, start, end, line,
! INDENT=tokenize.INDENT,
! DEDENT=tokenize.DEDENT,
! NEWLINE=tokenize.NEWLINE,
! JUNK=(tokenize.COMMENT, tokenize.NL) ):
! global indents, check_equal
! 
 if type == NEWLINE:
 # a program statement, or ENDMARKER, will eventually follow,
--- 246,258 ----
 return prefix + " " + string.join(firsts, ', ')
 
! def process_tokens(tokens):
! INDENT = tokenize.INDENT
! DEDENT = tokenize.DEDENT
! NEWLINE = tokenize.NEWLINE
! JUNK = tokenize.COMMENT, tokenize.NL
! indents = [Whitespace("")]
 check_equal = 0
 
! for (type, token, start, end, line) in tokens:
 if type == NEWLINE:
 # a program statement, or ENDMARKER, will eventually follow,
***************
*** 312,371 ****
 raise NannyNag(start[0], msg, line)
 
- else:
- # unpatched version of tokenize
- 
- nesting_level = 0
- indents = []
- check_equal = 0
- 
- def reset_globals():
- global nesting_level, indents, check_equal
- nesting_level = check_equal = 0
- indents = [Whitespace("")]
- 
- def tokeneater(type, token, start, end, line,
- INDENT=tokenize.INDENT,
- DEDENT=tokenize.DEDENT,
- NEWLINE=tokenize.NEWLINE,
- COMMENT=tokenize.COMMENT,
- OP=tokenize.OP):
- global nesting_level, indents, check_equal
- 
- if type == INDENT:
- check_equal = 0
- thisguy = Whitespace(token)
- if not indents[-1].less(thisguy):
- witness = indents[-1].not_less_witness(thisguy)
- msg = "indent not greater e.g. " + format_witnesses(witness)
- raise NannyNag(start[0], msg, line)
- indents.append(thisguy)
- 
- elif type == DEDENT:
- del indents[-1]
- 
- elif type == NEWLINE:
- if nesting_level == 0:
- check_equal = 1
- 
- elif type == COMMENT:
- pass
- 
- elif check_equal:
- check_equal = 0
- thisguy = Whitespace(line)
- if not indents[-1].equal(thisguy):
- witness = indents[-1].not_equal_witness(thisguy)
- msg = "indent not equal e.g. " + format_witnesses(witness)
- raise NannyNag(start[0], msg, line)
- 
- if type == OP and token in ('{', '[', '('):
- nesting_level = nesting_level + 1
- 
- elif type == OP and token in ('}', ']', ')'):
- if nesting_level == 0:
- raise NannyNag(start[0],
- "unbalanced bracket '" + token + "'",
- line)
- nesting_level = nesting_level - 1
 
 if __name__ == '__main__':
--- 300,303 ----
Index: tokenize.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tokenize.py,v
retrieving revision 1.22
retrieving revision 1.22.4.1
diff -C2 -r1.22 -r1.22.4.1
*** tokenize.py	2001年03月23日 05:22:49	1.22
--- tokenize.py	2001年07月07日 22:55:28	1.22.4.1
***************
*** 1,13 ****
 """Tokenization help for Python programs.
 
! This module exports a function called 'tokenize()' that breaks a stream of
 text into Python tokens. It accepts a readline-like method which is called
! repeatedly to get the next line of input (or "" for EOF) and a "token-eater"
! function which is called once for each token found. The latter function is
! passed the token type, a string containing the token, the starting and
! ending (row, column) coordinates of the token, and the original line. It is
! designed to match the working of the Python tokenizer exactly, except that
! it produces COMMENT tokens for comments and gives type OP for all operators."""
 
 __author__ = 'Ka-Ping Yee <ping@lfw.org>'
 __credits__ = \
--- 1,26 ----
 """Tokenization help for Python programs.
 
! generate_tokens(readline) is a generator that breaks a stream of
 text into Python tokens. It accepts a readline-like method which is called
! repeatedly to get the next line of input (or "" for EOF). It generates
! 5-tuples with these members:
 
+ the token type (see token.py)
+ the token (a string)
+ the starting (row, column) indices of the token (a 2-tuple of ints)
+ the ending (row, column) indices of the token (a 2-tuple of ints)
+ the original line (string)
+ 
+ It is designed to match the working of the Python tokenizer exactly, except
+ that it produces COMMENT tokens for comments and gives type OP for all
+ operators
+ 
+ Older entry points
+ tokenize_loop(readline, tokeneater)
+ tokenize(readline, tokeneater=printtoken)
+ are the same, except instead of generating tokens, tokeneater is a callback
+ function to which the 5 fields described above are passed as 5 arguments,
+ each time a new token is found."""
+ 
 __author__ = 'Ka-Ping Yee <ping@lfw.org>'
 __credits__ = \
***************
*** 112,116 ****
--- 125,134 ----
 pass
 
+ # backwards compatible interface
 def tokenize_loop(readline, tokeneater):
+ for token_info in generate_tokens(readline):
+ apply(tokeneater, token_info)
+ 
+ def generate_tokens(readline):
 lnum = parenlev = continued = 0
 namechars, numchars = string.letters + '_', string.digits
***************
*** 130,139 ****
 if endmatch:
 pos = end = endmatch.end(0)
! tokeneater(STRING, contstr + line[:end],
 strstart, (lnum, end), contline + line)
 contstr, needcont = '', 0
 contline = None
 elif needcont and line[-2:] != '\\\n' and line[-3:] != '\\\r\n':
! tokeneater(ERRORTOKEN, contstr + line,
 strstart, (lnum, len(line)), contline)
 contstr = ''
--- 148,157 ----
 if endmatch:
 pos = end = endmatch.end(0)
! yield (STRING, contstr + line[:end],
 strstart, (lnum, end), contline + line)
 contstr, needcont = '', 0
 contline = None
 elif needcont and line[-2:] != '\\\n' and line[-3:] != '\\\r\n':
! yield (ERRORTOKEN, contstr + line,
 strstart, (lnum, len(line)), contline)
 contstr = ''
***************
*** 157,161 ****
 
 if line[pos] in '#\r\n': # skip comments or blank lines
! tokeneater((NL, COMMENT)[line[pos] == '#'], line[pos:],
 (lnum, pos), (lnum, len(line)), line)
 continue
--- 175,179 ----
 
 if line[pos] in '#\r\n': # skip comments or blank lines
! yield ((NL, COMMENT)[line[pos] == '#'], line[pos:],
 (lnum, pos), (lnum, len(line)), line)
 continue
***************
*** 163,170 ****
 if column > indents[-1]: # count indents or dedents
 indents.append(column)
! tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line)
 while column < indents[-1]:
 indents = indents[:-1]
! tokeneater(DEDENT, '', (lnum, pos), (lnum, pos), line)
 
 else: # continued statement
--- 181,188 ----
 if column > indents[-1]: # count indents or dedents
 indents.append(column)
! yield (INDENT, line[:pos], (lnum, 0), (lnum, pos), line)
 while column < indents[-1]:
 indents = indents[:-1]
! yield (DEDENT, '', (lnum, pos), (lnum, pos), line)
 
 else: # continued statement
***************
*** 182,191 ****
 if initial in numchars or \
 (initial == '.' and token != '.'): # ordinary number
! tokeneater(NUMBER, token, spos, epos, line)
 elif initial in '\r\n':
! tokeneater(parenlev > 0 and NL or NEWLINE,
 token, spos, epos, line)
 elif initial == '#':
! tokeneater(COMMENT, token, spos, epos, line)
 elif token in ("'''", '"""', # triple-quoted
 "r'''", 'r"""', "R'''", 'R"""',
--- 200,209 ----
 if initial in numchars or \
 (initial == '.' and token != '.'): # ordinary number
! yield (NUMBER, token, spos, epos, line)
 elif initial in '\r\n':
! yield (parenlev > 0 and NL or NEWLINE,
 token, spos, epos, line)
 elif initial == '#':
! yield (COMMENT, token, spos, epos, line)
 elif token in ("'''", '"""', # triple-quoted
 "r'''", 'r"""', "R'''", 'R"""',
***************
*** 198,202 ****
 pos = endmatch.end(0)
 token = line[start:pos]
! tokeneater(STRING, token, spos, (lnum, pos), line)
 else:
 strstart = (lnum, start) # multiple lines
--- 216,220 ----
 pos = endmatch.end(0)
 token = line[start:pos]
! yield (STRING, token, spos, (lnum, pos), line)
 else:
 strstart = (lnum, start) # multiple lines
***************
*** 217,223 ****
 break
 else: # ordinary string
! tokeneater(STRING, token, spos, epos, line)
 elif initial in namechars: # ordinary name
! tokeneater(NAME, token, spos, epos, line)
 elif initial == '\\': # continued stmt
 continued = 1
--- 235,241 ----
 break
 else: # ordinary string
! yield (STRING, token, spos, epos, line)
 elif initial in namechars: # ordinary name
! yield (NAME, token, spos, epos, line)
 elif initial == '\\': # continued stmt
 continued = 1
***************
*** 225,237 ****
 if initial in '([{': parenlev = parenlev + 1
 elif initial in ')]}': parenlev = parenlev - 1
! tokeneater(OP, token, spos, epos, line)
 else:
! tokeneater(ERRORTOKEN, line[pos],
 (lnum, pos), (lnum, pos+1), line)
 pos = pos + 1
 
 for indent in indents[1:]: # pop remaining indent levels
! tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
! tokeneater(ENDMARKER, '', (lnum, 0), (lnum, 0), '')
 
 if __name__ == '__main__': # testing
--- 243,255 ----
 if initial in '([{': parenlev = parenlev + 1
 elif initial in ')]}': parenlev = parenlev - 1
! yield (OP, token, spos, epos, line)
 else:
! yield (ERRORTOKEN, line[pos],
 (lnum, pos), (lnum, pos+1), line)
 pos = pos + 1
 
 for indent in indents[1:]: # pop remaining indent levels
! yield (DEDENT, '', (lnum, 0), (lnum, 0), '')
! yield (ENDMARKER, '', (lnum, 0), (lnum, 0), '')
 
 if __name__ == '__main__': # testing
Index: traceback.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/traceback.py,v
retrieving revision 1.25
retrieving revision 1.25.4.1
diff -C2 -r1.25 -r1.25.4.1
*** traceback.py	2001年03月29日 04:36:08	1.25
--- traceback.py	2001年07月07日 22:55:28	1.25.4.1
***************
*** 172,188 ****
 list.append(' File "%s", line %d\n' %
 (filename, lineno))
! i = 0
! while i < len(line) and line[i].isspace():
! i = i+1
! list.append(' %s\n' % line.strip())
! if offset is not None:
! s = ' '
! for c in line[i:offset-1]:
! if c.isspace():
! s = s + c
! else:
! s = s + ' '
! list.append('%s^\n' % s)
! value = msg
 s = _some_str(value)
 if s:
--- 172,189 ----
 list.append(' File "%s", line %d\n' %
 (filename, lineno))
! if line is not None:
! i = 0
! while i < len(line) and line[i].isspace():
! i = i+1
! list.append(' %s\n' % line.strip())
! if offset is not None:
! s = ' '
! for c in line[i:offset-1]:
! if c.isspace():
! s = s + c
! else:
! s = s + ' '
! list.append('%s^\n' % s)
! value = msg
 s = _some_str(value)
 if s:
Index: types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/types.py,v
retrieving revision 1.14.10.5
retrieving revision 1.14.10.6
diff -C2 -r1.14.10.5 -r1.14.10.6
*** types.py	2001年06月14日 17:47:21	1.14.10.5
--- types.py	2001年07月07日 22:55:28	1.14.10.6
***************
*** 34,37 ****
--- 34,42 ----
 pass
 
+ def g():
+ yield 1
+ GeneratorType = type(g())
+ del g
+ 
 class _C:
 def _m(self): pass
Index: unittest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/unittest.py,v
retrieving revision 1.7
retrieving revision 1.7.4.1
diff -C2 -r1.7 -r1.7.4.1
*** unittest.py	2001年04月15日 09:18:32	1.7
--- unittest.py	2001年07月07日 22:55:28	1.7.4.1
***************
*** 444,448 ****
 not isinstance(test, TestSuite):
 raise ValueError, \
! "calling %s returned %s, not a test" % obj,test
 return test
 else:
--- 444,448 ----
 not isinstance(test, TestSuite):
 raise ValueError, \
! "calling %s returned %s, not a test" % (obj,test)
 return test
 else:
Index: urllib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v
retrieving revision 1.126
retrieving revision 1.126.4.1
diff -C2 -r1.126 -r1.126.4.1
*** urllib.py	2001年04月15日 20:47:33	1.126
--- urllib.py	2001年07月07日 22:55:28	1.126.4.1
***************
*** 287,291 ****
 h.endheaders()
 if data is not None:
! h.send(data + '\r\n')
 errcode, errmsg, headers = h.getreply()
 fp = h.getfile()
--- 287,291 ----
 h.endheaders()
 if data is not None:
! h.send(data)
 errcode, errmsg, headers = h.getreply()
 fp = h.getfile()
***************
*** 365,369 ****
 h.endheaders()
 if data is not None:
! h.send(data + '\r\n')
 errcode, errmsg, headers = h.getreply()
 fp = h.getfile()
--- 365,369 ----
 h.endheaders()
 if data is not None:
! h.send(data)
 errcode, errmsg, headers = h.getreply()
 fp = h.getfile()
Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.13
retrieving revision 1.13.4.1
diff -C2 -r1.13 -r1.13.4.1
*** urllib2.py	2001年04月15日 13:08:01	1.13
--- urllib2.py	2001年07月07日 22:55:28	1.13.4.1
***************
*** 218,222 ****
 if self.type is None:
 self.type, self.__r_type = splittype(self.__original)
! assert self.type is not None, self.__original
 return self.type
 
--- 218,223 ----
 if self.type is None:
 self.type, self.__r_type = splittype(self.__original)
! if self.type is None:
! raise ValueError, "unknown url type: %s" % self.__original
 return self.type
 
***************
*** 809,813 ****
 h.endheaders()
 if req.has_data():
! h.send(data + '\r\n')
 
 code, msg, hdrs = h.getreply()
--- 810,814 ----
 h.endheaders()
 if req.has_data():
! h.send(data)
 
 code, msg, hdrs = h.getreply()
Index: weakref.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -C2 -r1.9 -r1.9.2.1
*** weakref.py	2001年04月19日 16:26:06	1.9
--- weakref.py	2001年07月07日 22:55:28	1.9.2.1
***************
*** 85,88 ****
--- 85,98 ----
 return L
 
+ def iteritems(self):
+ return WeakValuedItemIterator(self)
+ 
+ def iterkeys(self):
+ return self.data.iterkeys()
+ __iter__ = iterkeys
+ 
+ def itervalues(self):
+ return WeakValuedValueIterator(self)
+ 
 def popitem(self):
 while 1:
***************
*** 168,171 ****
--- 178,191 ----
 return L
 
+ def iteritems(self):
+ return WeakKeyedItemIterator(self)
+ 
+ def iterkeys(self):
+ return WeakKeyedKeyIterator(self)
+ __iter__ = iterkeys
+ 
+ def itervalues(self):
+ return self.data.itervalues()
+ 
 def keys(self):
 L = []
***************
*** 190,193 ****
--- 210,266 ----
 for key, value in dict.items():
 d[ref(key, self._remove)] = value
+ 
+ 
+ class BaseIter:
+ def __iter__(self):
+ return self
+ 
+ 
+ class WeakKeyedKeyIterator(BaseIter):
+ def __init__(self, weakdict):
+ self._next = weakdict.data.iterkeys().next
+ 
+ def next(self):
+ while 1:
+ wr = self._next()
+ obj = wr()
+ if obj is not None:
+ return obj
+ 
+ 
+ class WeakKeyedItemIterator(BaseIter):
+ def __init__(self, weakdict):
+ self._next = weakdict.data.iteritems().next
+ 
+ def next(self):
+ while 1:
+ wr, value = self._next()
+ key = wr()
+ if key is not None:
+ return key, value
+ 
+ 
+ class WeakValuedValueIterator(BaseIter):
+ def __init__(self, weakdict):
+ self._next = weakdict.data.itervalues().next
+ 
+ def next(self):
+ while 1:
+ wr = self._next()
+ obj = wr()
+ if obj is not None:
+ return obj
+ 
+ 
+ class WeakValuedItemIterator(BaseIter):
+ def __init__(self, weakdict):
+ self._next = weakdict.data.iteritems().next
+ 
+ def next(self):
+ while 1:
+ key, wr = self._next()
+ value = wr()
+ if value is not None:
+ return key, value
 
 
Index: zipfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v
retrieving revision 1.13
retrieving revision 1.13.4.1
diff -C2 -r1.13 -r1.13.4.1
*** zipfile.py	2001年04月14日 16:45:14	1.13
--- zipfile.py	2001年07月07日 22:55:28	1.13.4.1
***************
*** 82,86 ****
 if endrec[0:4] == "PK005円006円" and endrec[-2:] == "000円000円":
 return 1 # file has correct magic number
! except:
 pass
 
--- 82,86 ----
 if endrec[0:4] == "PK005円006円" and endrec[-2:] == "000円000円":
 return 1 # file has correct magic number
! except IOError:
 pass
 

AltStyle によって変換されたページ (->オリジナル) /