[Python-3000-checkins] r55469 - in python/branches/p3yk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libcollections.tex Doc/lib/libcontextlib.tex Doc/lib/libgopherlib.tex Doc/lib/librgbimg.tex Doc/lib/libsets.tex Doc/lib/liburllib.tex Doc/lib/liburllib2.tex Lib/bsddb/test/test_recno.py Lib/cgitb.py Lib/collections.py Lib/gopherlib.py Lib/site.py Lib/test/regrtest.py Lib/test/test___all__.py Lib/test/test_collections.py Lib/test/test_marshal.py Lib/test/test_rgbimg.py Lib/test/test_sundry.py Lib/test/test_urllib2net.py Lib/urllib.py Lib/urllib2.py Misc/ACKS Misc/BeOS-NOTES Modules/Setup.dist Modules/_bsddb.c Modules/rgbimgmodule.c Objects/intobject.c Python/ast.c Python/marshal.c README

neal.norwitz python-3000-checkins at python.org
Sun May 20 20:28:42 CEST 2007


Author: neal.norwitz
Date: Sun May 20 20:28:20 2007
New Revision: 55469

Removed:
   python/branches/p3yk/Doc/lib/libgopherlib.tex
   python/branches/p3yk/Doc/lib/librgbimg.tex
   python/branches/p3yk/Doc/lib/libsets.tex
   python/branches/p3yk/Lib/gopherlib.py
   python/branches/p3yk/Lib/test/test_rgbimg.py
   python/branches/p3yk/Modules/rgbimgmodule.c
Modified:
   python/branches/p3yk/   (props changed)
   python/branches/p3yk/Doc/Makefile.deps
   python/branches/p3yk/Doc/lib/lib.tex
   python/branches/p3yk/Doc/lib/libcollections.tex
   python/branches/p3yk/Doc/lib/libcontextlib.tex
   python/branches/p3yk/Doc/lib/liburllib.tex
   python/branches/p3yk/Doc/lib/liburllib2.tex
   python/branches/p3yk/Lib/bsddb/test/test_recno.py
   python/branches/p3yk/Lib/cgitb.py
   python/branches/p3yk/Lib/collections.py
   python/branches/p3yk/Lib/site.py
   python/branches/p3yk/Lib/test/regrtest.py
   python/branches/p3yk/Lib/test/test___all__.py
   python/branches/p3yk/Lib/test/test_collections.py
   python/branches/p3yk/Lib/test/test_marshal.py
   python/branches/p3yk/Lib/test/test_sundry.py
   python/branches/p3yk/Lib/test/test_urllib2net.py
   python/branches/p3yk/Lib/urllib.py
   python/branches/p3yk/Lib/urllib2.py
   python/branches/p3yk/Misc/ACKS
   python/branches/p3yk/Misc/BeOS-NOTES
   python/branches/p3yk/Modules/Setup.dist
   python/branches/p3yk/Modules/_bsddb.c
   python/branches/p3yk/Objects/intobject.c
   python/branches/p3yk/Python/ast.c
   python/branches/p3yk/Python/marshal.c
   python/branches/p3yk/README
Log:
Merged revisions 55324-55467 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r55348 | georg.brandl | 2007-05-15 13:19:34 -0700 (Tue, 15 May 2007) | 4 lines
  
  HTML-escape the plain traceback in cgitb's HTML output, to prevent
  the traceback inadvertently or maliciously closing the comment and
  injecting HTML into the error page.
........
  r55372 | neal.norwitz | 2007-05-15 21:33:50 -0700 (Tue, 15 May 2007) | 6 lines
  
  Port rev 55353 from Guido:
  Add what looks like a necessary call to PyErr_NoMemory() when PyMem_MALLOC()
  fails.
  
  Will backport.
........
  r55377 | neal.norwitz | 2007-05-15 22:06:33 -0700 (Tue, 15 May 2007) | 1 line
  
  Mention removal of some directories for obsolete platforms
........
  r55380 | brett.cannon | 2007-05-15 22:50:03 -0700 (Tue, 15 May 2007) | 2 lines
  
  Change the maintainer of the BeOS port.
........
  r55383 | georg.brandl | 2007-05-16 06:44:18 -0700 (Wed, 16 May 2007) | 2 lines
  
  Bug #1719995: don't use deprecated method in sets example.
........
  r55386 | neal.norwitz | 2007-05-16 13:05:11 -0700 (Wed, 16 May 2007) | 5 lines
  
  Fix bug in marshal where bad data would cause a segfault due to
  lack of an infinite recursion check.
  
  Contributed by Damien Miller at Google.
........
  r55389 | brett.cannon | 2007-05-16 15:42:29 -0700 (Wed, 16 May 2007) | 6 lines
  
  Remove the gopherlib module.  It has been raising a DeprecationWarning since
  Python 2.5.
  
  Also remove gopher support from urllib/urllib2.  As both imported gopherlib the
  usage of the support would have raised a DeprecationWarning.
........
  r55394 | raymond.hettinger | 2007-05-16 18:08:04 -0700 (Wed, 16 May 2007) | 1 line
  
  calendar.py gets no benefit from xrange() instead of range()
........
  r55395 | brett.cannon | 2007-05-16 19:02:56 -0700 (Wed, 16 May 2007) | 3 lines
  
  Complete deprecation of BaseException.message.  Some subclasses were directly
  accessing the message attribute instead of using the descriptor.
........
  r55396 | neal.norwitz | 2007-05-16 23:11:36 -0700 (Wed, 16 May 2007) | 4 lines
  
  Reduce the max stack depth to see if this fixes the segfaults on
  Windows and some other boxes.  If this is successful, this rev should
  be backported.  I'm not sure how close to the limit we should push this.
........
  r55397 | neal.norwitz | 2007-05-16 23:23:50 -0700 (Wed, 16 May 2007) | 4 lines
  
  Set the depth to something very small to try to determine if the
  crashes on Windows are really due to the stack size or possibly
  some other problem.
........
  r55398 | neal.norwitz | 2007-05-17 00:04:46 -0700 (Thu, 17 May 2007) | 4 lines
  
  Last try for tweaking the max stack depth.  5000 was the original value,
  4000 didn't work either.  1000 does work on Windows.  If 2000 works,
  that will hopefully be a reasonable balance.
........
  r55412 | fred.drake | 2007-05-17 12:29:58 -0700 (Thu, 17 May 2007) | 1 line
  
  fix argument name in documentation; match the implementation
........
  r55427 | neal.norwitz | 2007-05-17 22:47:16 -0700 (Thu, 17 May 2007) | 1 line
  
  Verify neither dumps or loads overflow the stack and segfault.
........
  r55446 | collin.winter | 2007-05-18 16:11:24 -0700 (Fri, 18 May 2007) | 1 line
  
  Backport PEP 3110's new 'except' syntax to 2.6.
........
  r55448 | raymond.hettinger | 2007-05-18 18:11:16 -0700 (Fri, 18 May 2007) | 1 line
  
  Improvements to NamedTuple's implementation, tests, and documentation
........
  r55449 | raymond.hettinger | 2007-05-18 18:50:11 -0700 (Fri, 18 May 2007) | 1 line
  
  Fix beginner mistake -- don't mix spaces and tabs.
........
  r55450 | neal.norwitz | 2007-05-18 20:48:47 -0700 (Fri, 18 May 2007) | 1 line
  
  Clear data so random memory does not get freed.  Will backport.
........
  r55452 | neal.norwitz | 2007-05-18 21:34:55 -0700 (Fri, 18 May 2007) | 3 lines
  
  Whoops, need to pay attention to those test failures.
  Move the clear to *before* the first use, not after.
........
  r55453 | neal.norwitz | 2007-05-18 21:35:52 -0700 (Fri, 18 May 2007) | 1 line
  
  Give some clue as to what happened if the test fails.
........
  r55455 | georg.brandl | 2007-05-19 11:09:26 -0700 (Sat, 19 May 2007) | 2 lines
  
  Fix docstring for add_package in site.py.
........
  r55458 | brett.cannon | 2007-05-20 00:09:50 -0700 (Sun, 20 May 2007) | 2 lines
  
  Remove the rgbimg module.  It has been deprecated since Python 2.5.
........
  r55465 | nick.coghlan | 2007-05-20 04:12:49 -0700 (Sun, 20 May 2007) | 1 line
  
  Fix typo in example (should be backported, but my maintenance branch is woefully out of date)
........


Modified: python/branches/p3yk/Doc/Makefile.deps
==============================================================================
--- python/branches/p3yk/Doc/Makefile.deps	(original)
+++ python/branches/p3yk/Doc/Makefile.deps	Sun May 20 20:28:20 2007
@@ -185,7 +185,6 @@
 	lib/liburllib2.tex \
 	lib/libhttplib.tex \
 	lib/libftplib.tex \
-	lib/libgopherlib.tex \
 	lib/libnntplib.tex \
 	lib/liburlparse.tex \
 	lib/libhtmlparser.tex \
@@ -198,7 +197,6 @@
 	lib/libmm.tex \
 	lib/libaudioop.tex \
 	lib/libaifc.tex \
-	lib/librgbimg.tex \
 	lib/libossaudiodev.tex \
 	lib/libcrypto.tex \
 	lib/libhashlib.tex \

Modified: python/branches/p3yk/Doc/lib/lib.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/lib.tex	(original)
+++ python/branches/p3yk/Doc/lib/lib.tex	Sun May 20 20:28:20 2007
@@ -292,7 +292,6 @@
 \input{liburllib2}
 \input{libhttplib}
 \input{libftplib}
-\input{libgopherlib}
 \input{libpoplib}
 \input{libimaplib}
 \input{libnntplib}
@@ -322,7 +321,6 @@
 \input{libwave}
 \input{libchunk}
 \input{libcolorsys}
-\input{librgbimg}
 \input{libimghdr}
 \input{libsndhdr}
 \input{libossaudiodev}

Modified: python/branches/p3yk/Doc/lib/libcollections.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libcollections.tex	(original)
+++ python/branches/p3yk/Doc/lib/libcollections.tex	Sun May 20 20:28:20 2007
@@ -378,14 +378,25 @@
   The use cases are the same as those for tuples.  The named factories
   assign meaning to each tuple position and allow for more readable,
   self-documenting code.  Named tuples can also be used to assign field names 
-  to tuples
-  returned by the \module{csv} or \module{sqlite3} modules.  For example:
+  to tuples returned by the \module{csv} or \module{sqlite3} modules.
+  For example:
 
   \begin{verbatim}
+from itertools import starmap
 import csv
 EmployeeRecord = NamedTuple('EmployeeRecord', 'name age title department paygrade')
-for tup in csv.reader(open("employees.csv", "rb")):
-    print EmployeeRecord(*tup)
+for record in starmap(EmployeeRecord, csv.reader(open("employees.csv", "rb"))):
+    print record
+\end{verbatim}
+
+  To cast an individual record stored as \class{list}, \class{tuple}, or some other
+  iterable type, use the star-operator to unpack the values:
+
+  \begin{verbatim}
+>>> Color = NamedTuple('Color', 'name code')
+>>> m = dict(red=1, green=2, blue=3)
+>>> print Color(*m.popitem())
+Color(name='blue', code=3)
 \end{verbatim}
 
 \end{funcdesc}

Modified: python/branches/p3yk/Doc/lib/libcontextlib.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libcontextlib.tex	(original)
+++ python/branches/p3yk/Doc/lib/libcontextlib.tex	Sun May 20 20:28:20 2007
@@ -111,7 +111,7 @@
 \begin{verbatim}
 from __future__ import with_statement
 from contextlib import closing
-import codecs
+import urllib
 
 with closing(urllib.urlopen('http://www.python.org')) as page:
     for line in page:

Deleted: /python/branches/p3yk/Doc/lib/libgopherlib.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/libgopherlib.tex	Sun May 20 20:28:20 2007
+++ (empty file)
@@ -1,36 +0,0 @@
-\section{\module{gopherlib} ---
-         Gopher protocol client}
-
-\declaremodule{standard}{gopherlib}
-\modulesynopsis{Gopher protocol client (requires sockets).}
-
-\deprecated{2.5}{The \code{gopher} protocol is not in active use
-                 anymore.}
-
-\indexii{Gopher}{protocol}
-
-This module provides a minimal implementation of client side of the
-Gopher protocol.  It is used by the module \refmodule{urllib} to
-handle URLs that use the Gopher protocol.
-
-The module defines the following functions:
-
-\begin{funcdesc}{send_selector}{selector, host\optional{, port}}
-Send a \var{selector} string to the gopher server at \var{host} and
-\var{port} (default \code{70}).  Returns an open file object from
-which the returned document can be read.
-\end{funcdesc}
-
-\begin{funcdesc}{send_query}{selector, query, host\optional{, port}}
-Send a \var{selector} string and a \var{query} string to a gopher
-server at \var{host} and \var{port} (default \code{70}).  Returns an
-open file object from which the returned document can be read.
-\end{funcdesc}
-
-Note that the data returned by the Gopher server can be of any type,
-depending on the first character of the selector string.  If the data
-is text (first character of the selector is \samp{0}), lines are
-terminated by CRLF, and the data is terminated by a line consisting of
-a single \samp{.}, and a leading \samp{.} should be stripped from
-lines that begin with \samp{..}.  Directory listings (first character
-of the selector is \samp{1}) are transferred using the same protocol.

Deleted: /python/branches/p3yk/Doc/lib/librgbimg.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/librgbimg.tex	Sun May 20 20:28:20 2007
+++ (empty file)
@@ -1,54 +0,0 @@
-\section{\module{rgbimg} ---
-         Read and write ``SGI RGB'' files}
-
-\declaremodule{builtin}{rgbimg}
-\modulesynopsis{Read and write image files in ``SGI RGB'' format (the module
-                is \emph{not} SGI specific though!).}
-
-\deprecated{2.5}{This module is not maintained anymore and seems to be
-                 unused.}
-
-The \module{rgbimg} module allows Python programs to access SGI imglib image
-files (also known as \file{.rgb} files).  The module is far from
-complete, but is provided anyway since the functionality that there is
-enough in some cases.  Currently, colormap files are not supported.
-
-\note{This module is only built by default for 32-bit platforms; it is
-not expected to work properly on other systems.}
-
-The module defines the following variables and functions:
-
-\begin{excdesc}{error}
-This exception is raised on all errors, such as unsupported file type, etc.
-\end{excdesc}
-
-\begin{funcdesc}{sizeofimage}{file}
-This function returns a tuple \code{(\var{x}, \var{y})} where
-\var{x} and \var{y} are the size of the image in pixels.
-Only 4 byte RGBA pixels, 3 byte RGB pixels, and 1 byte greyscale pixels
-are currently supported.
-\end{funcdesc}
-
-\begin{funcdesc}{longimagedata}{file}
-This function reads and decodes the image on the specified file, and
-returns it as a Python string. The string has 4 byte RGBA pixels.
-The bottom left pixel is the first in
-the string. This format is suitable to pass to \function{gl.lrectwrite()},
-for instance.
-\end{funcdesc}
-
-\begin{funcdesc}{longstoimage}{data, x, y, z, file}
-This function writes the RGBA data in \var{data} to image
-file \var{file}. \var{x} and \var{y} give the size of the image.
-\var{z} is 1 if the saved image should be 1 byte greyscale, 3 if the
-saved image should be 3 byte RGB data, or 4 if the saved images should
-be 4 byte RGBA data.  The input data always contains 4 bytes per pixel.
-These are the formats returned by \function{gl.lrectread()}.
-\end{funcdesc}
-
-\begin{funcdesc}{ttob}{flag}
-This function sets a global flag which defines whether the scan lines
-of the image are read or written from bottom to top (flag is zero,
-compatible with SGI GL) or from top to bottom (flag is one,
-compatible with X).  The default is zero.
-\end{funcdesc}

Deleted: /python/branches/p3yk/Doc/lib/libsets.tex
==============================================================================

Modified: python/branches/p3yk/Doc/lib/liburllib.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/liburllib.tex	(original)
+++ python/branches/p3yk/Doc/lib/liburllib.tex	Sun May 20 20:28:20 2007
@@ -70,8 +70,8 @@
 
 The \function{urlopen()} function works transparently with proxies
 which do not require authentication.  In a \UNIX{} or Windows
-environment, set the \envvar{http_proxy}, \envvar{ftp_proxy} or
-\envvar{gopher_proxy} environment variables to a URL that identifies
+environment, set the \envvar{http_proxy}, or \envvar{ftp_proxy}
+environment variables to a URL that identifies
 the proxy server before starting the Python interpreter.  For example
 (the \character{\%} is the command prompt):
 
@@ -253,7 +253,7 @@
 \begin{classdesc}{URLopener}{\optional{proxies\optional{, **x509}}}
 Base class for opening and reading URLs.  Unless you need to support
 opening objects using schemes other than \file{http:}, \file{ftp:},
-\file{gopher:} or \file{file:}, you probably want to use
+or \file{file:}, you probably want to use
 \class{FancyURLopener}.
 
 By default, the \class{URLopener} class sends a
@@ -324,9 +324,8 @@
 
 \item
 Currently, only the following protocols are supported: HTTP, (versions
-0.9 and 1.0), Gopher (but not Gopher-+), FTP, and local files.
+0.9 and 1.0),  FTP, and local files.
 \indexii{HTTP}{protocol}
-\indexii{Gopher}{protocol}
 \indexii{FTP}{protocol}
 
 \item
@@ -355,9 +354,7 @@
 (such as an image), plain text or (for example) HTML\index{HTML}.  The
 HTTP\indexii{HTTP}{protocol} protocol provides type information in the
 reply header, which can be inspected by looking at the
-\mailheader{Content-Type} header.  For the
-Gopher\indexii{Gopher}{protocol} protocol, type information is encoded
-in the URL; there is currently no easy way to extract it.  If the
+\mailheader{Content-Type} header.  If the
 returned data is HTML, you can use the module
 \refmodule{htmllib}\refstmodindex{htmllib} to parse it.
 

Modified: python/branches/p3yk/Doc/lib/liburllib2.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/liburllib2.tex	(original)
+++ python/branches/p3yk/Doc/lib/liburllib2.tex	Sun May 20 20:28:20 2007
@@ -86,11 +86,6 @@
 HTTP errors, such as requests for authentication.
 \end{excdesc}
 
-\begin{excdesc}{GopherError}
-A subclass of \exception{URLError}, this is the error raised by the
-Gopher handler.
-\end{excdesc}
-
 
 The following classes are provided:
 
@@ -241,10 +236,6 @@
 delays.
 \end{classdesc}
 
-\begin{classdesc}{GopherHandler}{}
-Open gopher URLs.
-\end{classdesc}
-
 \begin{classdesc}{UnknownHandler}{}
 A catch-all class to handle unknown URLs.
 \end{classdesc}
@@ -744,13 +735,6 @@
 \end{methoddesc}
 
 
-\subsection{GopherHandler Objects \label{gopher-handler}}
-
-\begin{methoddesc}[GopherHandler]{gopher_open}{req}
-Open the gopher resource indicated by \var{req}.
-\end{methoddesc}
-
-
 \subsection{UnknownHandler Objects \label{unknown-handler-objects}}
 
 \begin{methoddesc}[UnknownHandler]{unknown_open}{}

Modified: python/branches/p3yk/Lib/bsddb/test/test_recno.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/test/test_recno.py	(original)
+++ python/branches/p3yk/Lib/bsddb/test/test_recno.py	Sun May 20 20:28:20 2007
@@ -118,7 +118,7 @@
         assert not d.has_key(13)
 
         data = d.get_both(26, "z" * 60)
-        assert data == "z" * 60
+        assert data == "z" * 60, 'was %r' % data
         if verbose:
             print(data)
 

Modified: python/branches/p3yk/Lib/cgitb.py
==============================================================================
--- python/branches/p3yk/Lib/cgitb.py	(original)
+++ python/branches/p3yk/Lib/cgitb.py	Sun May 20 20:28:20 2007
@@ -183,7 +183,8 @@
 
 %s
 -->
-''' % ''.join(traceback.format_exception(etype, evalue, etb))
+''' % pydoc.html.escape(
+          ''.join(traceback.format_exception(etype, evalue, etb)))
 
 def text(einfo, context=5):
     """Return a plain text document describing a given traceback."""

Modified: python/branches/p3yk/Lib/collections.py
==============================================================================
--- python/branches/p3yk/Lib/collections.py	(original)
+++ python/branches/p3yk/Lib/collections.py	Sun May 20 20:28:20 2007
@@ -24,30 +24,28 @@
     """
 
     field_names = s.split()
-    nargs = len(field_names)
+    assert ''.join(field_names).replace('_', '').isalpha()      # protect against exec attacks
+    argtxt = ', '.join(field_names)
+    reprtxt = ', '.join('%s=%%r' % name for name in field_names)
+    template = '''class %(typename)s(tuple):
+        '%(typename)s(%(argtxt)s)'
+        __slots__ = ()
+        def __new__(cls, %(argtxt)s):
+            return tuple.__new__(cls, (%(argtxt)s,))
+        def __repr__(self):
+            return '%(typename)s(%(reprtxt)s)' %% self
+    ''' % locals()
+    for i, name in enumerate(field_names):
+        template += '\n        %s = property(itemgetter(%d))\n' % (name, i)
+    m = dict(itemgetter=_itemgetter)
+    exec(template, m)
+    result = m[typename]
+    if hasattr(_sys, '_getframe'):
+        result.__module__ = _sys._getframe(1).f_globals['__name__']
+    return result
+
 
-    def __new__(cls, *args, **kwds):
-        if kwds:
-            try:
-                args += tuple(kwds[name] for name in field_names[len(args):])
-            except KeyError as name:
-                raise TypeError('%s missing required argument: %s' % (typename, name))
-        if len(args) != nargs:
-            raise TypeError('%s takes exactly %d arguments (%d given)' % (typename, nargs, len(args)))
-        return tuple.__new__(cls, args)
-
-    repr_template = '%s(%s)' % (typename, ', '.join('%s=%%r' % name for name in field_names))
-
-    m = dict(vars(tuple))       # pre-lookup superclass methods (for faster lookup)
-    m.update(__doc__= '%s(%s)' % (typename, ', '.join(field_names)),
-             __slots__ = (),    # no per-instance dict (so instances are same size as tuples)
-             __new__ = __new__,
-             __repr__ = lambda self, _format=repr_template.__mod__: _format(self),
-             __module__ = _sys._getframe(1).f_globals['__name__'],
-             )
-    m.update((name, property(_itemgetter(index))) for index, name in enumerate(field_names))
 
-    return type(typename, (tuple,), m)
 
 
 if __name__ == '__main__':

Deleted: /python/branches/p3yk/Lib/gopherlib.py
==============================================================================
--- /python/branches/p3yk/Lib/gopherlib.py	Sun May 20 20:28:20 2007
+++ (empty file)
@@ -1,209 +0,0 @@
-"""Gopher protocol client interface."""
-
-__all__ = ["send_selector","send_query"]
-
-import warnings
-warnings.warn("the gopherlib module is deprecated", DeprecationWarning,
-              stacklevel=2)
-
-# Default selector, host and port
-DEF_SELECTOR = '1/'
-DEF_HOST     = 'gopher.micro.umn.edu'
-DEF_PORT     = 70
-
-# Recognized file types
-A_TEXT       = '0'
-A_MENU       = '1'
-A_CSO        = '2'
-A_ERROR      = '3'
-A_MACBINHEX  = '4'
-A_PCBINHEX   = '5'
-A_UUENCODED  = '6'
-A_INDEX      = '7'
-A_TELNET     = '8'
-A_BINARY     = '9'
-A_DUPLICATE  = '+'
-A_SOUND      = 's'
-A_EVENT      = 'e'
-A_CALENDAR   = 'c'
-A_HTML       = 'h'
-A_TN3270     = 'T'
-A_MIME       = 'M'
-A_IMAGE      = 'I'
-A_WHOIS      = 'w'
-A_QUERY      = 'q'
-A_GIF        = 'g'
-A_HTML       = 'h'          # HTML file
-A_WWW        = 'w'          # WWW address
-A_PLUS_IMAGE = ':'
-A_PLUS_MOVIE = ';'
-A_PLUS_SOUND = '<'
-
-
-_names = dir()
-_type_to_name_map = {}
-def type_to_name(gtype):
-    """Map all file types to strings; unknown types become TYPE='x'."""
-    global _type_to_name_map
-    if _type_to_name_map=={}:
-        for name in _names:
-            if name[:2] == 'A_':
-                _type_to_name_map[eval(name)] = name[2:]
-    if gtype in _type_to_name_map:
-        return _type_to_name_map[gtype]
-    return 'TYPE=%r' % (gtype,)
-
-# Names for characters and strings
-CRLF = '\r\n'
-TAB = '\t'
-
-def send_selector(selector, host, port = 0):
-    """Send a selector to a given host and port, return a file with the reply."""
-    import socket
-    if not port:
-        i = host.find(':')
-        if i >= 0:
-            host, port = host[:i], int(host[i+1:])
-    if not port:
-        port = DEF_PORT
-    elif type(port) == type(''):
-        port = int(port)
-    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-    s.connect((host, port))
-    s.sendall(selector + CRLF)
-    s.shutdown(1)
-    return s.makefile('rb')
-
-def send_query(selector, query, host, port = 0):
-    """Send a selector and a query string."""
-    return send_selector(selector + '\t' + query, host, port)
-
-def path_to_selector(path):
-    """Takes a path as returned by urlparse and returns the appropriate selector."""
-    if path=="/":
-        return "/"
-    else:
-        return path[2:] # Cuts initial slash and data type identifier
-
-def path_to_datatype_name(path):
-    """Takes a path as returned by urlparse and maps it to a string.
-    See section 3.4 of RFC 1738 for details."""
-    if path=="/":
-        # No way to tell, although "INDEX" is likely
-        return "TYPE='unknown'"
-    else:
-        return type_to_name(path[1])
-
-# The following functions interpret the data returned by the gopher
-# server according to the expected type, e.g. textfile or directory
-
-def get_directory(f):
-    """Get a directory in the form of a list of entries."""
-    entries = []
-    while 1:
-        line = f.readline()
-        if not line:
-            print('(Unexpected EOF from server)')
-            break
-        if line[-2:] == CRLF:
-            line = line[:-2]
-        elif line[-1:] in CRLF:
-            line = line[:-1]
-        if line == '.':
-            break
-        if not line:
-            print('(Empty line from server)')
-            continue
-        gtype = line[0]
-        parts = line[1:].split(TAB)
-        if len(parts) < 4:
-            print('(Bad line from server: %r)' % (line,))
-            continue
-        if len(parts) > 4:
-            if parts[4:] != ['+']:
-                print('(Extra info from server:', end=' ')
-                print(parts[4:], ')')
-        else:
-            parts.append('')
-        parts.insert(0, gtype)
-        entries.append(parts)
-    return entries
-
-def get_textfile(f):
-    """Get a text file as a list of lines, with trailing CRLF stripped."""
-    lines = []
-    get_alt_textfile(f, lines.append)
-    return lines
-
-def get_alt_textfile(f, func):
-    """Get a text file and pass each line to a function, with trailing CRLF stripped."""
-    while 1:
-        line = f.readline()
-        if not line:
-            print('(Unexpected EOF from server)')
-            break
-        if line[-2:] == CRLF:
-            line = line[:-2]
-        elif line[-1:] in CRLF:
-            line = line[:-1]
-        if line == '.':
-            break
-        if line[:2] == '..':
-            line = line[1:]
-        func(line)
-
-def get_binary(f):
-    """Get a binary file as one solid data block."""
-    data = f.read()
-    return data
-
-def get_alt_binary(f, func, blocksize):
-    """Get a binary file and pass each block to a function."""
-    while 1:
-        data = f.read(blocksize)
-        if not data:
-            break
-        func(data)
-
-def test():
-    """Trivial test program."""
-    import sys
-    import getopt
-    opts, args = getopt.getopt(sys.argv[1:], '')
-    selector = DEF_SELECTOR
-    type = selector[0]
-    host = DEF_HOST
-    if args:
-        host = args[0]
-        args = args[1:]
-    if args:
-        type = args[0]
-        args = args[1:]
-        if len(type) > 1:
-            type, selector = type[0], type
-        else:
-            selector = ''
-            if args:
-                selector = args[0]
-                args = args[1:]
-        query = ''
-        if args:
-            query = args[0]
-            args = args[1:]
-    if type == A_INDEX:
-        f = send_query(selector, query, host)
-    else:
-        f = send_selector(selector, host)
-    if type == A_TEXT:
-        lines = get_textfile(f)
-        for item in lines: print(item)
-    elif type in (A_MENU, A_INDEX):
-        entries = get_directory(f)
-        for item in entries: print(item)
-    else:
-        data = get_binary(f)
-        print('binary data:', len(data), 'bytes:', repr(data[:100])[:40])
-
-# Run the test when run as script
-if __name__ == '__main__':
-    test()

Modified: python/branches/p3yk/Lib/site.py
==============================================================================
--- python/branches/p3yk/Lib/site.py	(original)
+++ python/branches/p3yk/Lib/site.py	Sun May 20 20:28:20 2007
@@ -118,8 +118,10 @@
     return d
 
 def addpackage(sitedir, name, known_paths):
-    """Add a new path to known_paths by combining sitedir and 'name' or execute
-    sitedir if it starts with 'import'"""
+    """Process a .pth file within the site-packages directory:
+       For each line in the file, either combine it with sitedir to a path
+       and add that to known_paths, or execute it if it starts with 'import '.
+    """
     if known_paths is None:
         _init_pathinfo()
         reset = 1

Modified: python/branches/p3yk/Lib/test/regrtest.py
==============================================================================
--- python/branches/p3yk/Lib/test/regrtest.py	(original)
+++ python/branches/p3yk/Lib/test/regrtest.py	Sun May 20 20:28:20 2007
@@ -1241,6 +1241,11 @@
                 for skip in WIN_ONLY:
                     self.expected.add(skip)
 
+            if sys.platform != 'irix':
+                IRIX_ONLY =["test_imageop"]
+                for skip in IRIX_ONLY:
+                    self.expected.add(skip)
+
             self.valid = True
 
     def isvalid(self):

Modified: python/branches/p3yk/Lib/test/test___all__.py
==============================================================================
--- python/branches/p3yk/Lib/test/test___all__.py	(original)
+++ python/branches/p3yk/Lib/test/test___all__.py	Sun May 20 20:28:20 2007
@@ -3,10 +3,6 @@
 import sys
 import warnings
 
-warnings.filterwarnings("ignore",
-                        "the gopherlib module is deprecated",
-                        DeprecationWarning,
-                        "<string>")
 
 class AllTest(unittest.TestCase):
 
@@ -78,7 +74,6 @@
         self.check_all("getpass")
         self.check_all("gettext")
         self.check_all("glob")
-        self.check_all("gopherlib")
         self.check_all("gzip")
         self.check_all("heapq")
         self.check_all("htmllib")

Modified: python/branches/p3yk/Lib/test/test_collections.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_collections.py	(original)
+++ python/branches/p3yk/Lib/test/test_collections.py	Sun May 20 20:28:20 2007
@@ -11,7 +11,6 @@
         self.assertEqual(Point.__slots__, ())
         self.assertEqual(Point.__module__, __name__)
         self.assertEqual(Point.__getitem__, tuple.__getitem__)
-        self.assert_('__getitem__' in Point.__dict__)                       # superclass methods localized
 
     def test_instance(self):
         Point = NamedTuple('Point', 'x y')
@@ -50,8 +49,10 @@
 
 
 def test_main(verbose=None):
+    import collections as CollectionsModule
     test_classes = [TestNamedTuple]
     test_support.run_unittest(*test_classes)
+    test_support.run_doctest(CollectionsModule, verbose)
 
 if __name__ == "__main__":
     test_main(verbose=True)

Modified: python/branches/p3yk/Lib/test/test_marshal.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_marshal.py	(original)
+++ python/branches/p3yk/Lib/test/test_marshal.py	Sun May 20 20:28:20 2007
@@ -220,6 +220,30 @@
             except Exception:
                 pass
 
+    def test_loads_recursion(self):
+        s = 'c' + ('X' * 4*4) + '{' * 2**20
+        self.assertRaises(ValueError, marshal.loads, s)
+
+    def test_recursion_limit(self):
+        # Create a deeply nested structure.
+        head = last = []
+        # The max stack depth should match the value in Python/marshal.c.
+        MAX_MARSHAL_STACK_DEPTH = 2000
+        for i in range(MAX_MARSHAL_STACK_DEPTH - 2):
+            last.append([0])
+            last = last[-1]
+
+        # Verify we don't blow out the stack with dumps/load.
+        data = marshal.dumps(head)
+        new_head = marshal.loads(data)
+        # Don't use == to compare objects, it can exceed the recursion limit.
+        self.assertEqual(len(new_head), len(head))
+        self.assertEqual(len(new_head[0]), len(head[0]))
+        self.assertEqual(len(new_head[-1]), len(head[-1]))
+
+        last.append([0])
+        self.assertRaises(ValueError, marshal.dumps, head)
+
 def test_main():
     test_support.run_unittest(IntTestCase,
                               FloatTestCase,

Deleted: /python/branches/p3yk/Lib/test/test_rgbimg.py
==============================================================================
--- /python/branches/p3yk/Lib/test/test_rgbimg.py	Sun May 20 20:28:20 2007
+++ (empty file)
@@ -1,70 +0,0 @@
-# Testing rgbimg module
-
-import warnings
-warnings.filterwarnings("ignore",
-                        "the rgbimg module is deprecated",
-                        DeprecationWarning,
-                        ".*test_rgbimg$")
-import rgbimg
-
-import os, uu
-
-from test.test_support import verbose, unlink, findfile
-
-class error(Exception):
-    pass
-
-print('RGBimg test suite:')
-
-def testimg(rgb_file, raw_file):
-    rgb_file = findfile(rgb_file)
-    raw_file = findfile(raw_file)
-    width, height = rgbimg.sizeofimage(rgb_file)
-    rgb = rgbimg.longimagedata(rgb_file)
-    if len(rgb) != width * height * 4:
-        raise error, 'bad image length'
-    raw = open(raw_file, 'rb').read()
-    if rgb != raw:
-        raise error, \
-              'images don\'t match for '+rgb_file+' and '+raw_file
-    for depth in [1, 3, 4]:
-        rgbimg.longstoimage(rgb, width, height, depth, '@.rgb')
-    os.unlink('@.rgb')
-
-table = [
-    ('testrgb'+os.extsep+'uue', 'test'+os.extsep+'rgb'),
-    ('testimg'+os.extsep+'uue', 'test'+os.extsep+'rawimg'),
-    ('testimgr'+os.extsep+'uue', 'test'+os.extsep+'rawimg'+os.extsep+'rev'),
-    ]
-for source, target in table:
-    source = findfile(source)
-    target = findfile(target)
-    if verbose:
-        print("uudecoding", source, "->", target, "...")
-    uu.decode(source, target)
-
-if verbose:
-    print("testing...")
-
-ttob = rgbimg.ttob(0)
-if ttob != 0:
-    raise error, 'ttob should start out as zero'
-
-testimg('test'+os.extsep+'rgb', 'test'+os.extsep+'rawimg')
-
-ttob = rgbimg.ttob(1)
-if ttob != 0:
-    raise error, 'ttob should be zero'
-
-testimg('test'+os.extsep+'rgb', 'test'+os.extsep+'rawimg'+os.extsep+'rev')
-
-ttob = rgbimg.ttob(0)
-if ttob != 1:
-    raise error, 'ttob should be one'
-
-ttob = rgbimg.ttob(0)
-if ttob != 0:
-    raise error, 'ttob should be zero'
-
-for source, target in table:
-    unlink(findfile(target))

Modified: python/branches/p3yk/Lib/test/test_sundry.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_sundry.py	(original)
+++ python/branches/p3yk/Lib/test/test_sundry.py	Sun May 20 20:28:20 2007
@@ -4,11 +4,6 @@
 warnings.filterwarnings('ignore', r".*posixfile module",
                         DeprecationWarning, 'posixfile$')
 
-warnings.filterwarnings("ignore",
-                        "the gopherlib module is deprecated",
-                        DeprecationWarning,
-                        ".*test_sundry")
-
 from test.test_support import verbose
 
 import BaseHTTPServer
@@ -27,7 +22,6 @@
 import formatter
 import ftplib
 import getpass
-import gopherlib
 import htmlentitydefs
 import ihooks
 import imghdr

Modified: python/branches/p3yk/Lib/test/test_urllib2net.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_urllib2net.py	(original)
+++ python/branches/p3yk/Lib/test/test_urllib2net.py	Sun May 20 20:28:20 2007
@@ -173,19 +173,6 @@
             ]
         self._test_urls(urls, self._extra_handlers())
 
-    def test_gopher(self):
-        import warnings
-        warnings.filterwarnings("ignore",
-                                "the gopherlib module is deprecated",
-                                DeprecationWarning,
-                                "urllib2$")
-        urls = [
-            # Thanks to Fred for finding these!
-            'gopher://gopher.lib.ncsu.edu./11/library/stacks/Alex',
-            'gopher://gopher.vt.edu.:10010/10/33',
-            ]
-        self._test_urls(urls, self._extra_handlers())
-
     def test_file(self):
         TESTFN = test_support.TESTFN
         f = open(TESTFN, 'w')
@@ -274,8 +261,6 @@
     def _extra_handlers(self):
         handlers = []
 
-        handlers.append(urllib2.GopherHandler)
-
         cfh = urllib2.CacheFTPHandler()
         cfh.setTimeout(1)
         handlers.append(cfh)

Modified: python/branches/p3yk/Lib/urllib.py
==============================================================================
--- python/branches/p3yk/Lib/urllib.py	(original)
+++ python/branches/p3yk/Lib/urllib.py	Sun May 20 20:28:20 2007
@@ -34,7 +34,7 @@
            "localhost", "thishost", "ftperrors", "basejoin", "unwrap",
            "splittype", "splithost", "splituser", "splitpasswd", "splitport",
            "splitnport", "splitquery", "splitattr", "splitvalue",
-           "splitgophertype", "getproxies"]
+           "getproxies"]
 
 __version__ = '1.17'    # XXX This version is not always updated :-(
 
@@ -432,24 +432,6 @@
                     return self.http_error(url, fp, errcode, errmsg, headers,
                                            data)
 
-    def open_gopher(self, url):
-        """Use Gopher protocol."""
-        if not isinstance(url, str):
-            raise IOError, ('gopher error', 'proxy support for gopher protocol currently not implemented')
-        import gopherlib
-        host, selector = splithost(url)
-        if not host: raise IOError, ('gopher error', 'no host given')
-        host = unquote(host)
-        type, selector = splitgophertype(selector)
-        selector, query = splitquery(selector)
-        selector = unquote(selector)
-        if query:
-            query = unquote(query)
-            fp = gopherlib.send_query(selector, query, host)
-        else:
-            fp = gopherlib.send_selector(selector, host)
-        return addinfourl(fp, noheaders(), "gopher:" + url)
-
     def open_file(self, url):
         """Use local file or FTP depending on form of URL."""
         if not isinstance(url, str):
@@ -979,7 +961,6 @@
 # splitattr('/path;attr1=value1;attr2=value2;...') ->
 #   '/path', ['attr1=value1', 'attr2=value2', ...]
 # splitvalue('attr=value') --> 'attr', 'value'
-# splitgophertype('/Xselector') --> 'X', 'selector'
 # unquote('abc%20def') -> 'abc def'
 # quote('abc def') -> 'abc%20def')
 
@@ -1139,12 +1120,6 @@
     if match: return match.group(1, 2)
     return attr, None
 
-def splitgophertype(selector):
-    """splitgophertype('/Xselector') --> 'X', 'selector'."""
-    if selector[:1] == '/' and selector[1:2]:
-        return selector[1], selector[2:]
-    return None, selector
-
 _hextochr = dict(('%02x' % i, chr(i)) for i in range(256))
 _hextochr.update(('%02X' % i, chr(i)) for i in range(256))
 
@@ -1481,7 +1456,6 @@
             'file:/etc/passwd',
             'file://localhost/etc/passwd',
             'ftp://ftp.gnu.org/pub/README',
-##          'gopher://gopher.micro.umn.edu/1/',
             'http://www.python.org/index.html',
             ]
         if hasattr(URLopener, "open_https"):

Modified: python/branches/p3yk/Lib/urllib2.py
==============================================================================
--- python/branches/p3yk/Lib/urllib2.py	(original)
+++ python/branches/p3yk/Lib/urllib2.py	Sun May 20 20:28:20 2007
@@ -107,7 +107,7 @@
     from StringIO import StringIO
 
 from urllib import (unwrap, unquote, splittype, splithost, quote,
-     addinfourl, splitport, splitgophertype, splitquery,
+     addinfourl, splitport, splitquery,
      splitattr, ftpwrapper, noheaders, splituser, splitpasswd, splitvalue)
 
 # support for FileHandler, proxies via environment variables
@@ -164,9 +164,6 @@
     def __str__(self):
         return 'HTTP Error %s: %s' % (self.code, self.msg)
 
-class GopherError(URLError):
-    pass
-
 # copied from cookielib.py
 _cut_port_re = re.compile(r":\d+$")
 def request_host(request):
@@ -1342,22 +1339,3 @@
                     del self.timeout[k]
                     break
             self.soonest = min(list(self.timeout.values()))
-
-class GopherHandler(BaseHandler):
-    def gopher_open(self, req):
-        # XXX can raise socket.error
-        import gopherlib  # this raises DeprecationWarning in 2.5
-        host = req.get_host()
-        if not host:
-            raise GopherError('no host given')
-        host = unquote(host)
-        selector = req.get_selector()
-        type, selector = splitgophertype(selector)
-        selector, query = splitquery(selector)
-        selector = unquote(selector)
-        if query:
-            query = unquote(query)
-            fp = gopherlib.send_query(selector, query, host)
-        else:
-            fp = gopherlib.send_selector(selector, host)
-        return addinfourl(fp, noheaders(), req.get_full_url())

Modified: python/branches/p3yk/Misc/ACKS
==============================================================================
--- python/branches/p3yk/Misc/ACKS	(original)
+++ python/branches/p3yk/Misc/ACKS	Sun May 20 20:28:20 2007
@@ -429,6 +429,7 @@
 Greg McFarlane
 Michael McLay
 Gordon McMillan
+Damien Miller
 Jay T. Miller
 Chris McDonough
 Andrew McNamara

Modified: python/branches/p3yk/Misc/BeOS-NOTES
==============================================================================
--- python/branches/p3yk/Misc/BeOS-NOTES	(original)
+++ python/branches/p3yk/Misc/BeOS-NOTES	Sun May 20 20:28:20 2007
@@ -39,5 +39,4 @@
    make install
 
 
-- Donn Cave (donn at oz.net)
-  October 4, 2000
+Maintainer: Mikael Jansson (mail at mikael.jansson.be)

Modified: python/branches/p3yk/Modules/Setup.dist
==============================================================================
--- python/branches/p3yk/Modules/Setup.dist	(original)
+++ python/branches/p3yk/Modules/Setup.dist	Sun May 20 20:28:20 2007
@@ -218,7 +218,6 @@
 # These represent audio samples or images as strings:
 
 #audioop audioop.c	# Operations on audio samples
-#rgbimg rgbimgmodule.c	# Read SGI RGB image files (but coded portably)
 
 
 # Note that the _md5 and _sha modules are normally only built if the

Modified: python/branches/p3yk/Modules/_bsddb.c
==============================================================================
--- python/branches/p3yk/Modules/_bsddb.c	(original)
+++ python/branches/p3yk/Modules/_bsddb.c	Sun May 20 20:28:20 2007
@@ -1724,6 +1724,7 @@
     CHECK_DB_NOT_CLOSED(self);
     if (!make_key_dbt(self, keyobj, &key, NULL))
         return NULL;
+    CLEAR_DBT(data);
     if ( !make_dbt(dataobj, &data) ||
          !checkTxnObj(txnobj, &txn) )
     {

Deleted: /python/branches/p3yk/Modules/rgbimgmodule.c
==============================================================================
--- /python/branches/p3yk/Modules/rgbimgmodule.c	Sun May 20 20:28:20 2007
+++ (empty file)
@@ -1,780 +0,0 @@
-/*
- *   	fastimg -
- *		Faster reading and writing of image files.
- *
- *      This code should work on machines with any byte order.
- *
- *	Could someone make this run real fast using multiple processors 
- *	or how about using memory mapped files to speed it up?
- *
- *				Paul Haeberli - 1991
- *
- *	Changed to return sizes.
- *				Sjoerd Mullender - 1993
- *	Changed to incorporate into Python.
- *				Sjoerd Mullender - 1993
- */
-#include "Python.h"
-
-#if SIZEOF_INT == 4
-typedef int Py_Int32;
-typedef unsigned int Py_UInt32;
-#else
-#if SIZEOF_LONG == 4
-typedef long Py_Int32;
-typedef unsigned long Py_UInt32;
-#else
-#error "No 4-byte integral type"
-#endif
-#endif
-
-#include <string.h>
-
-/*
- *	from image.h
- *
- */
-typedef struct {
-	unsigned short	imagic;		/* stuff saved on disk . . */
-	unsigned short 	type;
-	unsigned short 	dim;
-	unsigned short 	xsize;
-	unsigned short 	ysize;
-	unsigned short 	zsize;
-	Py_UInt32 	min;
-	Py_UInt32 	max;
-	Py_UInt32	wastebytes;	
-	char 		name[80];
-	Py_UInt32	colormap;
-
-	Py_Int32	file;		/* stuff used in core only */
-	unsigned short 	flags;
-	short		dorev;
-	short		x;
-	short		y;
-	short		z;
-	short		cnt;
-	unsigned short	*ptr;
-	unsigned short	*base;
-	unsigned short	*tmpbuf;
-	Py_UInt32	offset;
-	Py_UInt32	rleend;		/* for rle images */
-	Py_UInt32	*rowstart;	/* for rle images */
-	Py_Int32	*rowsize;	/* for rle images */
-} IMAGE;
-
-#define IMAGIC 	0732
-
-#define TYPEMASK		0xff00
-#define BPPMASK			0x00ff
-#define ITYPE_VERBATIM		0x0000
-#define ITYPE_RLE		0x0100
-#define ISRLE(type)		(((type) & 0xff00) == ITYPE_RLE)
-#define ISVERBATIM(type)	(((type) & 0xff00) == ITYPE_VERBATIM)
-#define BPP(type)		((type) & BPPMASK)
-#define RLE(bpp)		(ITYPE_RLE | (bpp))
-#define VERBATIM(bpp)		(ITYPE_VERBATIM | (bpp))
-/*
- *	end of image.h stuff
- *
- */
-
-#define RINTLUM (79)
-#define GINTLUM (156)
-#define BINTLUM (21)
-
-#define ILUM(r,g,b)     ((int)(RINTLUM*(r)+GINTLUM*(g)+BINTLUM*(b))>>8)
-
-#define OFFSET_R	3	/* this is byte order dependent */
-#define OFFSET_G	2
-#define OFFSET_B	1
-#define OFFSET_A	0
-
-#define CHANOFFSET(z)	(3-(z))	/* this is byte order dependent */
-
-static void expandrow(unsigned char *, unsigned char *, int);
-static void setalpha(unsigned char *, int);
-static void copybw(Py_Int32 *, int);
-static void interleaverow(unsigned char*, unsigned char*, int, int);
-static int compressrow(unsigned char *, unsigned char *, int, int);
-static void lumrow(unsigned char *, unsigned char *, int);
-
-#ifdef ADD_TAGS
-#define TAGLEN	(5)
-#else
-#define TAGLEN	(0)
-#endif
-
-static PyObject *ImgfileError;
-
-static int reverse_order;
-
-#ifdef ADD_TAGS
-/*
- *	addlongimgtag - 
- *		this is used to extract image data from core dumps.
- *
- */
-static void 
-addlongimgtag(Py_UInt32 *dptr, int xsize, int ysize)
-{
-	dptr = dptr + (xsize * ysize);
-	dptr[0] = 0x12345678;
-	dptr[1] = 0x59493333;
-	dptr[2] = 0x69434222;
-	dptr[3] = xsize;
-	dptr[4] = ysize;
-}
-#endif
-
-/*
- *	byte order independent read/write of shorts and longs.
- *
- */
-static unsigned short
-getshort(FILE *inf)
-{
-	unsigned char buf[2];
-
-	fread(buf, 2, 1, inf);
-	return (buf[0] << 8) + (buf[1] << 0);
-}
-
-static Py_UInt32
-getlong(FILE *inf)
-{
-	unsigned char buf[4];
-
-	fread(buf, 4, 1, inf);
-	return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3] << 0);
-}
-
-static void
-putshort(FILE *outf, unsigned short val)
-{
-	unsigned char buf[2];
-
-	buf[0] = (val >> 8);
-	buf[1] = (val >> 0);
-	fwrite(buf, 2, 1, outf);
-}
-
-static int
-putlong(FILE *outf, Py_UInt32 val)
-{
-	unsigned char buf[4];
-
-	buf[0] = (unsigned char) (val >> 24);
-	buf[1] = (unsigned char) (val >> 16);
-	buf[2] = (unsigned char) (val >> 8);
-	buf[3] = (unsigned char) (val >> 0);
-	return (int)fwrite(buf, 4, 1, outf);
-}
-
-static void
-readheader(FILE *inf, IMAGE *image)
-{
-	memset(image ,0, sizeof(IMAGE));
-	image->imagic = getshort(inf);
-	image->type   = getshort(inf);
-	image->dim    = getshort(inf);
-	image->xsize  = getshort(inf);
-	image->ysize  = getshort(inf);
-	image->zsize  = getshort(inf);
-}
-
-static int
-writeheader(FILE *outf, IMAGE *image)
-{
-	IMAGE t;
-
-	memset(&t, 0, sizeof(IMAGE));
-	fwrite(&t, sizeof(IMAGE), 1, outf);
-	fseek(outf, 0, SEEK_SET);
-	putshort(outf, image->imagic);
-	putshort(outf, image->type);
-	putshort(outf, image->dim);
-	putshort(outf, image->xsize);
-	putshort(outf, image->ysize);
-	putshort(outf, image->zsize);
-	putlong(outf, image->min);
-	putlong(outf, image->max);
-	putlong(outf, 0);
-	return (int)fwrite("no name", 8, 1, outf);
-}
-
-static int
-writetab(FILE *outf, /*unsigned*/ Py_Int32 *tab, int len)
-{
-	int r = 0;
-
-	while(len) {
-		r = putlong(outf, *tab++);
-		len--;
-	}
-	return r;
-}
-
-static void
-readtab(FILE *inf, /*unsigned*/ Py_Int32 *tab, int len)
-{
-	while(len) {
-		*tab++ = getlong(inf);
-		len--;
-	}
-}
-
-/*
- *	sizeofimage - 
- *		return the xsize and ysize of an iris image file.
- *
- */
-static PyObject *
-sizeofimage(PyObject *self, PyObject *args)
-{
-	char *name;
-	IMAGE image;
-	FILE *inf;
-
-	if (!PyArg_ParseTuple(args, "s:sizeofimage", &name))
-		return NULL;
-
-	inf = fopen(name, "rb");
-	if (!inf) {
-		PyErr_SetString(ImgfileError, "can't open image file");
-		return NULL;
-	}
-	readheader(inf, &image);
-	fclose(inf);
-	if (image.imagic != IMAGIC) {
-		PyErr_SetString(ImgfileError,
-				"bad magic number in image file");
-		return NULL;
-	}
-	return Py_BuildValue("(ii)", image.xsize, image.ysize);
-}
-
-/*
- *	longimagedata - 
- *		read in a B/W RGB or RGBA iris image file and return a 
- *	pointer to an array of longs.
- *
- */
-static PyObject *
-longimagedata(PyObject *self, PyObject *args)
-{
-	char *name;
-	unsigned char *base, *lptr;
-	unsigned char *rledat = NULL, *verdat = NULL;
-	Py_Int32 *starttab = NULL, *lengthtab = NULL;
-	FILE *inf = NULL;
-	IMAGE image;
-	int y, z, tablen;
-	int xsize, ysize, zsize;
-	int bpp, rle, cur, badorder;
-	int rlebuflen;
-	PyObject *rv = NULL;
-
-	if (!PyArg_ParseTuple(args, "s:longimagedata", &name))
-		return NULL;
-
-	inf = fopen(name,"rb");
-	if (!inf) {
-		PyErr_SetString(ImgfileError, "can't open image file");
-		return NULL;
-	}
-	readheader(inf,&image);
-	if (image.imagic != IMAGIC) {
-		PyErr_SetString(ImgfileError,
-				"bad magic number in image file");
-		goto finally;
-	}
-	rle = ISRLE(image.type);
-	bpp = BPP(image.type);
-	if (bpp != 1) {
-		PyErr_SetString(ImgfileError,
-				"image must have 1 byte per pix chan");
-		goto finally;
-	}
-	xsize = image.xsize;
-	ysize = image.ysize;
-	zsize = image.zsize;
-	if (rle) {
-		tablen = ysize * zsize * sizeof(Py_Int32);
-		starttab = (Py_Int32 *)malloc(tablen);
-		lengthtab = (Py_Int32 *)malloc(tablen);
-		rlebuflen = (int) (1.05 * xsize +10);
-		rledat = (unsigned char *)malloc(rlebuflen);
-		if (!starttab || !lengthtab || !rledat) {
-			PyErr_NoMemory();
-			goto finally;
-		}
-		
-		fseek(inf, 512, SEEK_SET);
-		readtab(inf, starttab, ysize*zsize);
-		readtab(inf, lengthtab, ysize*zsize);
-
-		/* check data order */
-		cur = 0;
-		badorder = 0;
-		for(y = 0; y < ysize; y++) {
-			for(z = 0; z < zsize; z++) {
-				if (starttab[y + z * ysize] < cur) {
-					badorder = 1;
-					break;
-				}
-				cur = starttab[y +z * ysize];
-			}
-			if (badorder)
-				break;
-		}
-
-		fseek(inf, 512 + 2 * tablen, SEEK_SET);
-		cur = 512 + 2 * tablen;
-		rv = PyString_FromStringAndSize((char *)NULL,
-				      (xsize * ysize + TAGLEN) * sizeof(Py_Int32));
-		if (rv == NULL)
-			goto finally;
-
-		base = (unsigned char *) PyString_AsString(rv);
-#ifdef ADD_TAGS
-		addlongimgtag(base,xsize,ysize);
-#endif
-		if (badorder) {
-			for (z = 0; z < zsize; z++) {
-				lptr = base;
-				if (reverse_order)
-					lptr += (ysize - 1) * xsize
-						* sizeof(Py_UInt32);
-				for (y = 0; y < ysize; y++) {
-					int idx = y + z * ysize;
-					if (cur != starttab[idx]) {
-						fseek(inf,starttab[idx],
-						      SEEK_SET);
-						cur = starttab[idx];
-					}
-					if (lengthtab[idx] > rlebuflen) {
-						PyErr_SetString(ImgfileError,
-							"rlebuf is too small");
-						Py_DECREF(rv);
-						rv = NULL;
-						goto finally;
-					}
-					fread(rledat, lengthtab[idx], 1, inf);
-					cur += lengthtab[idx];
-					expandrow(lptr, rledat, 3-z);
-					if (reverse_order)
-						lptr -= xsize
-						      * sizeof(Py_UInt32);
-					else
-						lptr += xsize
-						      * sizeof(Py_UInt32);
-				}
-			}
-		} else {
-			lptr = base;
-			if (reverse_order)
-				lptr += (ysize - 1) * xsize
-					* sizeof(Py_UInt32);
-			for (y = 0; y < ysize; y++) {
-				for(z = 0; z < zsize; z++) {
-					int idx = y + z * ysize;
-					if (cur != starttab[idx]) {
-						fseek(inf, starttab[idx],
-						      SEEK_SET);
-						cur = starttab[idx];
-					}
-					fread(rledat, lengthtab[idx], 1, inf);
-					cur += lengthtab[idx];
-					expandrow(lptr, rledat, 3-z);
-				}
-				if (reverse_order)
-					lptr -= xsize * sizeof(Py_UInt32);
-				else
-					lptr += xsize * sizeof(Py_UInt32);
-			}
-		}
-		if (zsize == 3) 
-			setalpha(base, xsize * ysize);
-		else if (zsize < 3) 
-			copybw((Py_Int32 *) base, xsize * ysize);
-	}
-	else {
-		rv = PyString_FromStringAndSize((char *) 0,
-					   (xsize*ysize+TAGLEN)*sizeof(Py_Int32));
-		if (rv == NULL)
-			goto finally;
-
-		base = (unsigned char *) PyString_AsString(rv);
-#ifdef ADD_TAGS
-		addlongimgtag(base, xsize, ysize);
-#endif
-		verdat = (unsigned char *)malloc(xsize);
-		if (!verdat) {
-			Py_CLEAR(rv);
-			goto finally;
-		}
-
-		fseek(inf, 512, SEEK_SET);
-		for (z = 0; z < zsize; z++) {
-			lptr = base;
-			if (reverse_order)
-				lptr += (ysize - 1) * xsize
-				        * sizeof(Py_UInt32);
-			for (y = 0; y < ysize; y++) {
-				fread(verdat, xsize, 1, inf);
-				interleaverow(lptr, verdat, 3-z, xsize);
-				if (reverse_order)
-					lptr -= xsize * sizeof(Py_UInt32);
-				else
-					lptr += xsize * sizeof(Py_UInt32);
-			}
-		}
-		if (zsize == 3)
-			setalpha(base, xsize * ysize);
-		else if (zsize < 3) 
-			copybw((Py_Int32 *) base, xsize * ysize);
-	}
-  finally:
-	if (starttab)
-		free(starttab);
-	if (lengthtab)
-		free(lengthtab);
-	if (rledat)
-		free(rledat);
-	if (verdat)
-		free(verdat);
-	fclose(inf);
-	return rv;
-}
-
-/* static utility functions for longimagedata */
-
-static void
-interleaverow(unsigned char *lptr, unsigned char *cptr, int z, int n)
-{
-	lptr += z;
-	while (n--) {
-		*lptr = *cptr++;
-		lptr += 4;
-	}
-}
-
-static void
-copybw(Py_Int32 *lptr, int n)
-{
-	while (n >= 8) {
-		lptr[0] = 0xff000000 + (0x010101 * (lptr[0] & 0xff));
-		lptr[1] = 0xff000000 + (0x010101 * (lptr[1] & 0xff));
-		lptr[2] = 0xff000000 + (0x010101 * (lptr[2] & 0xff));
-		lptr[3] = 0xff000000 + (0x010101 * (lptr[3] & 0xff));
-		lptr[4] = 0xff000000 + (0x010101 * (lptr[4] & 0xff));
-		lptr[5] = 0xff000000 + (0x010101 * (lptr[5] & 0xff));
-		lptr[6] = 0xff000000 + (0x010101 * (lptr[6] & 0xff));
-		lptr[7] = 0xff000000 + (0x010101 * (lptr[7] & 0xff));
-		lptr += 8;
-		n -= 8;
-	}
-	while (n--) {
-		*lptr = 0xff000000 + (0x010101 * (*lptr&0xff));
-		lptr++;
-	}
-}
-
-static void
-setalpha(unsigned char *lptr, int n)
-{
-	while (n >= 8) {
-		lptr[0 * 4] = 0xff;
-		lptr[1 * 4] = 0xff;
-		lptr[2 * 4] = 0xff;
-		lptr[3 * 4] = 0xff;
-		lptr[4 * 4] = 0xff;
-		lptr[5 * 4] = 0xff;
-		lptr[6 * 4] = 0xff;
-		lptr[7 * 4] = 0xff;
-		lptr += 4 * 8;
-		n -= 8;
-	}
-	while (n--) {
-		*lptr = 0xff;
-		lptr += 4;
-	}
-}
-
-static void
-expandrow(unsigned char *optr, unsigned char *iptr, int z)
-{
-	unsigned char pixel, count;
-
-	optr += z;
-	while (1) {
-		pixel = *iptr++;
-		if (!(count = (pixel & 0x7f)))
-			return;
-		if (pixel & 0x80) {
-			while (count >= 8) {
-				optr[0 * 4] = iptr[0];
-				optr[1 * 4] = iptr[1];
-				optr[2 * 4] = iptr[2];
-				optr[3 * 4] = iptr[3];
-				optr[4 * 4] = iptr[4];
-				optr[5 * 4] = iptr[5];
-				optr[6 * 4] = iptr[6];
-				optr[7 * 4] = iptr[7];
-				optr += 8 * 4;
-				iptr += 8;
-				count -= 8;
-			}
-			while (count--) {
-				*optr = *iptr++;
-				optr += 4;
-			}
-		}
-		else {
-			pixel = *iptr++;
-			while (count >= 8) {
-				optr[0 * 4] = pixel;
-				optr[1 * 4] = pixel;
-				optr[2 * 4] = pixel;
-				optr[3 * 4] = pixel;
-				optr[4 * 4] = pixel;
-				optr[5 * 4] = pixel;
-				optr[6 * 4] = pixel;
-				optr[7 * 4] = pixel;
-				optr += 8 * 4;
-				count -= 8;
-			}
-			while (count--) {
-				*optr = pixel;
-				optr += 4;
-			}
-		}
-	}
-}
-
-/*
- *	longstoimage -
- *		copy an array of longs to an iris image file.  Each long
- *	represents one pixel.  xsize and ysize specify the dimensions of
- *	the pixel array.  zsize specifies what kind of image file to
- *	write out.  if zsize is 1, the luminance of the pixels are
- *	calculated, and a single channel black and white image is saved.
- *	If zsize is 3, an RGB image file is saved.  If zsize is 4, an
- *	RGBA image file is saved.
- *
- */
-static PyObject *
-longstoimage(PyObject *self, PyObject *args)
-{
-	unsigned char *lptr;
-	char *name;
-	int xsize, ysize, zsize;
-	FILE *outf = NULL;
-	IMAGE image;
-	int tablen, y, z, pos, len;
-	Py_Int32 *starttab = NULL, *lengthtab = NULL;
-	unsigned char *rlebuf = NULL;
-	unsigned char *lumbuf = NULL;
-	int rlebuflen;
-	Py_ssize_t goodwrite;
-	PyObject *retval = NULL;
-
-	if (!PyArg_ParseTuple(args, "s#iiis:longstoimage", &lptr, &len,
-			      &xsize, &ysize, &zsize, &name))
-		return NULL;
-
-	goodwrite = 1;
-	outf = fopen(name, "wb");
-	if (!outf) {
-		PyErr_SetString(ImgfileError, "can't open output file");
-		return NULL;
-	}
-	tablen = ysize * zsize * sizeof(Py_Int32);
-
-	starttab = (Py_Int32 *)malloc(tablen);
-	lengthtab = (Py_Int32 *)malloc(tablen);
-	rlebuflen = (int) (1.05 * xsize + 10);
-	rlebuf = (unsigned char *)malloc(rlebuflen);
-	lumbuf = (unsigned char *)malloc(xsize * sizeof(Py_Int32));
-	if (!starttab || !lengthtab || !rlebuf || !lumbuf) {
-		PyErr_NoMemory();
-		goto finally;
-	}
-	
-	memset(&image, 0, sizeof(IMAGE));
-	image.imagic = IMAGIC; 
-	image.type = RLE(1);
-	if (zsize>1)
-		image.dim = 3;
-	else
-		image.dim = 2;
-	image.xsize = xsize;
-	image.ysize = ysize;
-	image.zsize = zsize;
-	image.min = 0;
-	image.max = 255;
-	goodwrite *= writeheader(outf, &image);
-	pos = 512 + 2 * tablen;
-	fseek(outf, pos, SEEK_SET);
-	if (reverse_order)
-		lptr += (ysize - 1) * xsize * sizeof(Py_UInt32);
-	for (y = 0; y < ysize; y++) {
-		for (z = 0; z < zsize; z++) {
-			if (zsize == 1) {
-				lumrow(lptr, lumbuf, xsize);
-				len = compressrow(lumbuf, rlebuf,
-						  CHANOFFSET(z), xsize);
-			} else {
-				len = compressrow(lptr, rlebuf,
-						  CHANOFFSET(z), xsize);
-			}
-			if(len > rlebuflen) {
-				PyErr_SetString(ImgfileError,
-						"rlebuf is too small");
-				goto finally;
-			}
-			goodwrite *= fwrite(rlebuf, len, 1, outf);
-			starttab[y + z * ysize] = pos;
-			lengthtab[y + z * ysize] = len;
-			pos += len;
-		}
-		if (reverse_order)
-			lptr -= xsize * sizeof(Py_UInt32);
-		else
-			lptr += xsize * sizeof(Py_UInt32);
-	}
-
-	fseek(outf, 512, SEEK_SET);
-	goodwrite *= writetab(outf, starttab, ysize*zsize);
-	goodwrite *= writetab(outf, lengthtab, ysize*zsize);
-	if (goodwrite) {
-		Py_INCREF(Py_None);
-		retval = Py_None;
-	} else
-		PyErr_SetString(ImgfileError, "not enough space for image");
-
-  finally:
-	fclose(outf);
-	free(starttab);
-	free(lengthtab);
-	free(rlebuf);
-	free(lumbuf);
-	return retval;
-}
-
-/* static utility functions for longstoimage */
-
-static void
-lumrow(unsigned char *rgbptr, unsigned char *lumptr, int n)
-{
-	lumptr += CHANOFFSET(0);
-	while (n--) {
-		*lumptr = ILUM(rgbptr[OFFSET_R],
-			       rgbptr[OFFSET_G],
-			       rgbptr[OFFSET_B]);
-		lumptr += 4;
-		rgbptr += 4;
-	}
-}
-
-static int
-compressrow(unsigned char *lbuf, unsigned char *rlebuf, int z, int cnt)
-{
-	unsigned char *iptr, *ibufend, *sptr, *optr;
-	short todo, cc;							
-	Py_Int32 count;
-
-	lbuf += z;
-	iptr = lbuf;
-	ibufend = iptr + cnt * 4;
-	optr = rlebuf;
-
-	while(iptr < ibufend) {
-		sptr = iptr;
-		iptr += 8;
-		while ((iptr<ibufend) &&
-		       ((iptr[-8]!=iptr[-4]) ||(iptr[-4]!=iptr[0])))
-		{
-			iptr += 4;
-		}
-		iptr -= 8;
-		count = (iptr - sptr) / 4;
-		while (count) {
-			todo = count > 126 ? 126 : (short)count;
-			count -= todo;
-			*optr++ = 0x80 | todo;
-			while (todo > 8) {
-				optr[0] = sptr[0 * 4];
-				optr[1] = sptr[1 * 4];
-				optr[2] = sptr[2 * 4];
-				optr[3] = sptr[3 * 4];
-				optr[4] = sptr[4 * 4];
-				optr[5] = sptr[5 * 4];
-				optr[6] = sptr[6 * 4];
-				optr[7] = sptr[7 * 4];
-				optr += 8;
-				sptr += 8 * 4;
-				todo -= 8;
-			}
-			while (todo--) {
-				*optr++ = *sptr;
-				sptr += 4;
-			}
-		}
-		sptr = iptr;
-		cc = *iptr;
-		iptr += 4;
-		while ((iptr < ibufend) && (*iptr == cc))
-			iptr += 4;
-		count = (iptr - sptr) / 4;
-		while (count) {
-			todo = count > 126 ? 126 : (short)count;
-			count -= todo;
-			*optr++ = (unsigned char) todo;
-			*optr++ = (unsigned char) cc;
-		}
-	}
-	*optr++ = 0;
-	return optr - (unsigned char *)rlebuf;
-}
-
-static PyObject *
-ttob(PyObject *self, PyObject *args)
-{
-	int order, oldorder;
-
-	if (!PyArg_ParseTuple(args, "i:ttob", &order))
-		return NULL;
-	oldorder = reverse_order;
-	reverse_order = order;
-	return PyInt_FromLong(oldorder);
-}
-
-static PyMethodDef
-rgbimg_methods[] = {
-	{"sizeofimage",	   sizeofimage, METH_VARARGS},
-	{"longimagedata",  longimagedata, METH_VARARGS},
-	{"longstoimage",   longstoimage, METH_VARARGS},
-	{"ttob",	   ttob, METH_VARARGS},
-	{NULL,             NULL}	     /* sentinel */
-};
-
-
-PyMODINIT_FUNC
-initrgbimg(void)
-{
-	PyObject *m, *d;
-	m = Py_InitModule("rgbimg", rgbimg_methods);
-	if (m == NULL)
-		return;
-
-	if (PyErr_Warn(PyExc_DeprecationWarning, 
-				"the rgbimg module is deprecated"))
-		return;
-	
-	d = PyModule_GetDict(m);
-	ImgfileError = PyErr_NewException("rgbimg.error", NULL, NULL);
-	if (ImgfileError != NULL)
-		PyDict_SetItemString(d, "error", ImgfileError);
-}

Modified: python/branches/p3yk/Objects/intobject.c
==============================================================================
--- python/branches/p3yk/Objects/intobject.c	(original)
+++ python/branches/p3yk/Objects/intobject.c	Sun May 20 20:28:20 2007
@@ -394,7 +394,7 @@
 	char *buffer = (char *)PyMem_MALLOC(length+1);
 
 	if (buffer == NULL)
-		return NULL;
+		return PyErr_NoMemory();
 
 	if (PyUnicode_EncodeDecimal(s, length, buffer, NULL)) {
 		PyMem_FREE(buffer);

Modified: python/branches/p3yk/Python/ast.c
==============================================================================
--- python/branches/p3yk/Python/ast.c	(original)
+++ python/branches/p3yk/Python/ast.c	Sun May 20 20:28:20 2007
@@ -2707,7 +2707,7 @@
 static excepthandler_ty
 ast_for_except_clause(struct compiling *c, const node *exc, node *body)
 {
-    /* except_clause: 'except' [test [',' test]] */
+    /* except_clause: 'except' [test ['as' test]] */
     REQ(exc, except_clause);
     REQ(body, suite);
 

Modified: python/branches/p3yk/Python/marshal.c
==============================================================================
--- python/branches/p3yk/Python/marshal.c	(original)
+++ python/branches/p3yk/Python/marshal.c	Sun May 20 20:28:20 2007
@@ -15,7 +15,7 @@
  * and risks coring the interpreter.  When the object stack gets this deep,
  * raise an exception instead of continuing.
  */
-#define MAX_MARSHAL_STACK_DEPTH 5000
+#define MAX_MARSHAL_STACK_DEPTH 2000
 
 #define TYPE_NULL		'0'
 #define TYPE_NONE		'N'
@@ -235,9 +235,16 @@
 				goto exit;
 			}
 			else {
+				int ok;
 				o = PyInt_FromSsize_t(PyDict_Size(p->strings));
-				PyDict_SetItem(p->strings, v, o);
-				Py_DECREF(o);
+				ok = o &&
+				     PyDict_SetItem(p->strings, v, o) >= 0;
+				Py_XDECREF(o);
+				if (!ok) {
+					p->depth--;
+					p->error = 1;
+					return;
+				}
 				w_byte(TYPE_INTERNED, p);
 			}
 		}
@@ -403,7 +410,7 @@
 
 typedef WFILE RFILE; /* Same struct with different invariants */
 
-#define rs_byte(p) (((p)->ptr != (p)->end) ? (unsigned char)*(p)->ptr++ : EOF)
+#define rs_byte(p) (((p)->ptr < (p)->end) ? (unsigned char)*(p)->ptr++ : EOF)
 
 #define r_byte(p) ((p)->fp ? getc((p)->fp) : rs_byte(p))
 
@@ -494,42 +501,60 @@
 	PyObject *v, *v2, *v3;
 	long i, n;
 	int type = r_byte(p);
+	PyObject *retval;
+
+	p->depth++;
+
+	if (p->depth > MAX_MARSHAL_STACK_DEPTH) {
+		p->depth--;
+		PyErr_SetString(PyExc_ValueError, "recursion limit exceeded");
+		return NULL;
+	}
 
 	switch (type) {
 
 	case EOF:
 		PyErr_SetString(PyExc_EOFError,
 				"EOF read where object expected");
-		return NULL;
+		retval = NULL;
+		break;
 
 	case TYPE_NULL:
-		return NULL;
+		retval = NULL;
+		break;
 
 	case TYPE_NONE:
 		Py_INCREF(Py_None);
-		return Py_None;
+		retval = Py_None;
+		break;
 
 	case TYPE_STOPITER:
 		Py_INCREF(PyExc_StopIteration);
-		return PyExc_StopIteration;
+		retval = PyExc_StopIteration;
+		break;
 
 	case TYPE_ELLIPSIS:
 		Py_INCREF(Py_Ellipsis);
-		return Py_Ellipsis;
+		retval = Py_Ellipsis;
+		break;
 
 	case TYPE_FALSE:
 		Py_INCREF(Py_False);
-		return Py_False;
+		retval = Py_False;
+		break;
 
 	case TYPE_TRUE:
 		Py_INCREF(Py_True);
-		return Py_True;
+		retval = Py_True;
+		break;
 
 	case TYPE_INT:
-		return PyInt_FromLong(r_long(p));
+		retval = PyInt_FromLong(r_long(p));
+		break;
 
 	case TYPE_INT64:
-		return r_long64(p);
+		retval = r_long64(p);
+		break;
 
 	case TYPE_LONG:
 		{
@@ -539,12 +564,15 @@
 			if (n < -INT_MAX || n > INT_MAX) {
 				PyErr_SetString(PyExc_ValueError,
 						"bad marshal data");
-				return NULL;
+				retval = NULL;
+				break;
 			}
 			size = n<0 ? -n : n;
 			ob = _PyLong_New(size);
-			if (ob == NULL)
-				return NULL;
+			if (ob == NULL) {
+				retval = NULL;
+				break;
+			}
 			ob->ob_size = n;
 			for (i = 0; i < size; i++) {
 				int digit = r_short(p);
@@ -552,11 +580,14 @@
 					Py_DECREF(ob);
 					PyErr_SetString(PyExc_ValueError,
 							"bad marshal data");
-					return NULL;
+					ob = NULL;
+					break;
 				}
-				ob->ob_digit[i] = digit;
+				if (ob != NULL)
+					ob->ob_digit[i] = digit;
 			}
-			return (PyObject *)ob;
+			retval = (PyObject *)ob;
+			break;
 		}
 
 	case TYPE_FLOAT:
@@ -567,13 +598,16 @@
 			if (n == EOF || r_string(buf, (int)n, p) != n) {
 				PyErr_SetString(PyExc_EOFError,
 					"EOF read where object expected");
-				return NULL;
+				retval = NULL;
+				break;
 			}
 			buf[n] = '\0';
-			PyFPE_START_PROTECT("atof", return 0)
+			retval = NULL;
+			PyFPE_START_PROTECT("atof", break)
 			dx = PyOS_ascii_atof(buf);
 			PyFPE_END_PROTECT(dx)
-			return PyFloat_FromDouble(dx);
+			retval = PyFloat_FromDouble(dx);
+			break;
 		}
 
 	case TYPE_BINARY_FLOAT:
@@ -583,13 +617,16 @@
 			if (r_string((char*)buf, 8, p) != 8) {
 				PyErr_SetString(PyExc_EOFError,
 					"EOF read where object expected");
-				return NULL;
+				retval = NULL;
+				break;
 			}
 			x = _PyFloat_Unpack8(buf, 1);
 			if (x == -1.0 && PyErr_Occurred()) {
-				return NULL;
+				retval = NULL;
+				break;
 			}
-			return PyFloat_FromDouble(x);
+			retval = PyFloat_FromDouble(x);
+			break;
 		}
 
 #ifndef WITHOUT_COMPLEX
@@ -601,23 +638,27 @@
 			if (n == EOF || r_string(buf, (int)n, p) != n) {
 				PyErr_SetString(PyExc_EOFError,
 					"EOF read where object expected");
-				return NULL;
+				retval = NULL;
+				break;
 			}
 			buf[n] = '\0';
-			PyFPE_START_PROTECT("atof", return 0)
+			retval = NULL;
+			PyFPE_START_PROTECT("atof", break;)
 			c.real = PyOS_ascii_atof(buf);
 			PyFPE_END_PROTECT(c)
 			n = r_byte(p);
 			if (n == EOF || r_string(buf, (int)n, p) != n) {
 				PyErr_SetString(PyExc_EOFError,
 					"EOF read where object expected");
-				return NULL;
+				retval = NULL;
+				break;
 			}
 			buf[n] = '\0';
-			PyFPE_START_PROTECT("atof", return 0)
+			PyFPE_START_PROTECT("atof", break)
 			c.imag = PyOS_ascii_atof(buf);
 			PyFPE_END_PROTECT(c)
-			return PyComplex_FromCComplex(c);
+			retval = PyComplex_FromCComplex(c);
+			break;
 		}
 
 	case TYPE_BINARY_COMPLEX:
@@ -627,22 +668,27 @@
 			if (r_string((char*)buf, 8, p) != 8) {
 				PyErr_SetString(PyExc_EOFError,
 					"EOF read where object expected");
-				return NULL;
+				retval = NULL;
+				break;
 			}
 			c.real = _PyFloat_Unpack8(buf, 1);
 			if (c.real == -1.0 && PyErr_Occurred()) {
-				return NULL;
+				retval = NULL;
+				break;
 			}
 			if (r_string((char*)buf, 8, p) != 8) {
 				PyErr_SetString(PyExc_EOFError,
 					"EOF read where object expected");
-				return NULL;
+				retval = NULL;
+				break;
 			}
 			c.imag = _PyFloat_Unpack8(buf, 1);
 			if (c.imag == -1.0 && PyErr_Occurred()) {
-				return NULL;
+				retval = NULL;
+				break;
 			}
-			return PyComplex_FromCComplex(c);
+			retval = PyComplex_FromCComplex(c);
+			break;
 		}
 #endif
 
@@ -651,32 +697,42 @@
 		n = r_long(p);
 		if (n < 0 || n > INT_MAX) {
 			PyErr_SetString(PyExc_ValueError, "bad marshal data");
-			return NULL;
+			retval = NULL;
+			break;
 		}
 		v = PyString_FromStringAndSize((char *)NULL, n);
-		if (v == NULL)
-			return v;
+		if (v == NULL) {
+			retval = NULL;
+			break;
+		}
 		if (r_string(PyString_AS_STRING(v), (int)n, p) != n) {
 			Py_DECREF(v);
 			PyErr_SetString(PyExc_EOFError,
 					"EOF read where object expected");
-			return NULL;
+			retval = NULL;
+			break;
 		}
 		if (type == TYPE_INTERNED) {
 			PyString_InternInPlace(&v);
-			PyList_Append(p->strings, v);
+			if (PyList_Append(p->strings, v) < 0) {
+				retval = NULL;
+				break;
+			}
 		}
-		return v;
+		retval = v;
+		break;
 
 	case TYPE_STRINGREF:
 		n = r_long(p);
 		if (n < 0 || n >= PyList_GET_SIZE(p->strings)) {
 			PyErr_SetString(PyExc_ValueError, "bad marshal data");
-			return NULL;
+			retval = NULL;
+			break;
 		}
 		v = PyList_GET_ITEM(p->strings, n);
 		Py_INCREF(v);
-		return v;
+		retval = v;
+		break;
 
 #ifdef Py_USING_UNICODE
 	case TYPE_UNICODE:
@@ -686,20 +742,25 @@
 		n = r_long(p);
 		if (n < 0 || n > INT_MAX) {
 			PyErr_SetString(PyExc_ValueError, "bad marshal data");
-			return NULL;
+			retval = NULL;
+			break;
 		}
 		buffer = PyMem_NEW(char, n);
-		if (buffer == NULL)
-			return PyErr_NoMemory();
+		if (buffer == NULL) {
+			retval = PyErr_NoMemory();
+			break;
+		}
 		if (r_string(buffer, (int)n, p) != n) {
 			PyMem_DEL(buffer);
 			PyErr_SetString(PyExc_EOFError,
 				"EOF read where object expected");
-			return NULL;
+			retval = NULL;
+			break;
 		}
 		v = PyUnicode_DecodeUTF8(buffer, n, NULL);
 		PyMem_DEL(buffer);
-		return v;
+		retval = v;
+		break;
 	    }
 #endif
 
@@ -707,11 +768,14 @@
 		n = r_long(p);
 		if (n < 0 || n > INT_MAX) {
 			PyErr_SetString(PyExc_ValueError, "bad marshal data");
-			return NULL;
+			retval = NULL;
+			break;
 		}
 		v = PyTuple_New((int)n);
-		if (v == NULL)
-			return v;
+		if (v == NULL) {
+			retval = NULL;
+			break;
+		}
 		for (i = 0; i < n; i++) {
 			v2 = r_object(p);
 			if ( v2 == NULL ) {
@@ -724,17 +788,21 @@
 			}
 			PyTuple_SET_ITEM(v, (int)i, v2);
 		}
-		return v;
+		retval = v;
+		break;
 
 	case TYPE_LIST:
 		n = r_long(p);
 		if (n < 0 || n > INT_MAX) {
 			PyErr_SetString(PyExc_ValueError, "bad marshal data");
-			return NULL;
+			retval = NULL;
+			break;
 		}
 		v = PyList_New((int)n);
-		if (v == NULL)
-			return v;
+		if (v == NULL) {
+			retval = NULL;
+			break;
+		}
 		for (i = 0; i < n; i++) {
 			v2 = r_object(p);
 			if ( v2 == NULL ) {
@@ -745,14 +813,17 @@
 				v = NULL;
 				break;
 			}
-			PyList_SetItem(v, (int)i, v2);
+			PyList_SET_ITEM(v, (int)i, v2);
 		}
-		return v;
+		retval = v;
+		break;
 
 	case TYPE_DICT:
 		v = PyDict_New();
-		if (v == NULL)
-			return NULL;
+		if (v == NULL) {
+			retval = NULL;
+			break;
+		}
 		for (;;) {
 			PyObject *key, *val;
 			key = r_object(p);
@@ -768,18 +839,22 @@
 			Py_DECREF(v);
 			v = NULL;
 		}
-		return v;
+		retval = v;
+		break;
 
 	case TYPE_SET:
 	case TYPE_FROZENSET:
 		n = r_long(p);
-		if (n < 0) {
+		if (n < 0 || n > INT_MAX) {
 			PyErr_SetString(PyExc_ValueError, "bad marshal data");
-			return NULL;
+			retval = NULL;
+			break;
 		}
 		v = PyTuple_New((int)n);
-		if (v == NULL)
-			return v;
+		if (v == NULL) {
+			retval = NULL;
+			break;
+		}
 		for (i = 0; i < n; i++) {
 			v2 = r_object(p);
 			if ( v2 == NULL ) {
@@ -792,14 +867,17 @@
 			}
 			PyTuple_SET_ITEM(v, (int)i, v2);
 		}
-		if (v == NULL)
-			return v;
+		if (v == NULL) {
+			retval = NULL;
+			break;
+		}
 		if (type == TYPE_SET)
 			v3 = PySet_New(v);
 		else
 			v3 = PyFrozenSet_New(v);
 		Py_DECREF(v);
-		return v3;
+		retval = v3;
+		break;
 
 	case TYPE_CODE:
 		{
@@ -876,14 +954,19 @@
 
 			return v;
 		}
+		retval = v;
+		break;
 
 	default:
 		/* Bogus data got written, which isn't ideal.
 		   This will let you keep working and recover. */
 		PyErr_SetString(PyExc_ValueError, "bad marshal data");
-		return NULL;
+		retval = NULL;
+		break;
 
 	}
+	p->depth--;
+	return retval;
 }
 
 static PyObject *
@@ -989,6 +1072,7 @@
 	PyObject *result;
 	rf.fp = fp;
 	rf.strings = PyList_New(0);
+	rf.depth = 0;
 	result = r_object(&rf);
 	Py_DECREF(rf.strings);
 	return result;
@@ -1003,6 +1087,7 @@
 	rf.ptr = str;
 	rf.end = str + len;
 	rf.strings = PyList_New(0);
+	rf.depth = 0;
 	result = r_object(&rf);
 	Py_DECREF(rf.strings);
 	return result;
@@ -1096,6 +1181,7 @@
 	}
 	rf.fp = PyFile_AsFile(f);
 	rf.strings = PyList_New(0);
+	rf.depth = 0;
 	result = read_object(&rf);
 	Py_DECREF(rf.strings);
 	return result;
@@ -1124,6 +1210,7 @@
 	rf.ptr = s;
 	rf.end = s + n;
 	rf.strings = PyList_New(0);
+	rf.depth = 0;
 	result = read_object(&rf);
 	Py_DECREF(rf.strings);
 	return result;

Modified: python/branches/p3yk/README
==============================================================================
--- python/branches/p3yk/README	(original)
+++ python/branches/p3yk/README	Sun May 20 20:28:20 2007
@@ -464,7 +464,7 @@
                 array, audioop, binascii, cPickle, cStringIO, cmath,
                 crypt, curses, errno, fcntl, gdbm, grp,
                 _locale, math, md5, new, operator, parser, pcre,
-                posix, pwd, readline, regex, reop, rgbimg, rotor,
+                posix, pwd, readline, regex, reop, rotor,
                 select, signal, socket, soundex, struct,
                 syslog, termios, time, timing, zlib, audioop
 


More information about the Python-3000-checkins mailing list