[Python-checkins] r58777 - in python/branches/ctypes-branch: Doc/README.txt Doc/library/functions.rst Doc/library/marshal.rst Doc/library/os.rst Doc/library/shutil.rst Doc/library/stdtypes.rst Doc/tutorial/controlflow.rst Doc/using/cmdline.rst Doc/whatsnew/2.6.rst Lib/bsddb/dbtables.py Lib/bsddb/test/test_misc.py Lib/collections.py Lib/contextlib.py Lib/ctypes/test/test_prototypes.py Lib/idlelib/IOBinding.py Lib/idlelib/NEWS.txt Lib/idlelib/WidgetRedirector.py Lib/idlelib/configDialog.py Lib/idlelib/tabbedpages.py Lib/logging/handlers.py Lib/mimetypes.py Lib/os.py Lib/plat-freebsd6/IN.py Lib/plat-freebsd7/IN.py Lib/plat-freebsd8 Lib/posixfile.py Lib/smtpd.py Lib/test/regrtest.py Lib/test/test_collections.py Lib/test/test_fcntl.py Lib/test/test_import.py Lib/test/test_socket.py Lib/test/test_with.py Lib/xml/dom/minidom.py Misc/NEWS Misc/developers.txt Modules/_bsddb.c Modules/_ctypes/cfield.c Modules/mmapmodule.c Objects/stringobject.c Objects/unicodeobject.c Python/bltinmodule.c configure configure.in setup.py

thomas.heller python-checkins at python.org
Fri Nov 2 17:45:30 CET 2007


Author: thomas.heller
Date: Fri Nov  2 17:45:27 2007
New Revision: 58777

Added:
   python/branches/ctypes-branch/Lib/idlelib/tabbedpages.py
      - copied unchanged from r58766, python/trunk/Lib/idlelib/tabbedpages.py
   python/branches/ctypes-branch/Lib/plat-freebsd8/   (props changed)
      - copied from r58766, python/trunk/Lib/plat-freebsd8/
Modified:
   python/branches/ctypes-branch/   (props changed)
   python/branches/ctypes-branch/Doc/README.txt
   python/branches/ctypes-branch/Doc/library/functions.rst
   python/branches/ctypes-branch/Doc/library/marshal.rst
   python/branches/ctypes-branch/Doc/library/os.rst
   python/branches/ctypes-branch/Doc/library/shutil.rst
   python/branches/ctypes-branch/Doc/library/stdtypes.rst
   python/branches/ctypes-branch/Doc/tutorial/controlflow.rst
   python/branches/ctypes-branch/Doc/using/cmdline.rst
   python/branches/ctypes-branch/Doc/whatsnew/2.6.rst
   python/branches/ctypes-branch/Lib/bsddb/dbtables.py
   python/branches/ctypes-branch/Lib/bsddb/test/test_misc.py
   python/branches/ctypes-branch/Lib/collections.py
   python/branches/ctypes-branch/Lib/contextlib.py
   python/branches/ctypes-branch/Lib/ctypes/test/test_prototypes.py
   python/branches/ctypes-branch/Lib/idlelib/IOBinding.py
   python/branches/ctypes-branch/Lib/idlelib/NEWS.txt
   python/branches/ctypes-branch/Lib/idlelib/WidgetRedirector.py
   python/branches/ctypes-branch/Lib/idlelib/configDialog.py
   python/branches/ctypes-branch/Lib/logging/handlers.py
   python/branches/ctypes-branch/Lib/mimetypes.py
   python/branches/ctypes-branch/Lib/os.py
   python/branches/ctypes-branch/Lib/plat-freebsd6/IN.py
   python/branches/ctypes-branch/Lib/plat-freebsd7/IN.py
   python/branches/ctypes-branch/Lib/posixfile.py
   python/branches/ctypes-branch/Lib/smtpd.py
   python/branches/ctypes-branch/Lib/test/regrtest.py
   python/branches/ctypes-branch/Lib/test/test_collections.py
   python/branches/ctypes-branch/Lib/test/test_fcntl.py
   python/branches/ctypes-branch/Lib/test/test_import.py
   python/branches/ctypes-branch/Lib/test/test_socket.py
   python/branches/ctypes-branch/Lib/test/test_with.py
   python/branches/ctypes-branch/Lib/xml/dom/minidom.py
   python/branches/ctypes-branch/Misc/NEWS
   python/branches/ctypes-branch/Misc/developers.txt
   python/branches/ctypes-branch/Modules/_bsddb.c
   python/branches/ctypes-branch/Modules/_ctypes/cfield.c
   python/branches/ctypes-branch/Modules/mmapmodule.c
   python/branches/ctypes-branch/Objects/stringobject.c
   python/branches/ctypes-branch/Objects/unicodeobject.c
   python/branches/ctypes-branch/Python/bltinmodule.c
   python/branches/ctypes-branch/configure
   python/branches/ctypes-branch/configure.in
   python/branches/ctypes-branch/setup.py
Log:
Merged revisions 58615-58775 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r58618 | guido.van.rossum | 2007-10-23 21:25:41 +0200 (Tue, 23 Oct 2007) | 3 lines
  
  Issue 1307 by Derek Shockey, fox the same bug for RCPT.
  Neal: please backport!
........
  r58620 | raymond.hettinger | 2007-10-23 22:37:41 +0200 (Tue, 23 Oct 2007) | 1 line
  
  Shorter name for namedtuple()
........
  r58621 | andrew.kuchling | 2007-10-23 22:55:47 +0200 (Tue, 23 Oct 2007) | 1 line
  
  Update name
........
  r58622 | raymond.hettinger | 2007-10-23 23:23:07 +0200 (Tue, 23 Oct 2007) | 1 line
  
  Fixup news entry
........
  r58623 | raymond.hettinger | 2007-10-24 03:28:33 +0200 (Wed, 24 Oct 2007) | 1 line
  
  Optimize sum() for integer and float inputs.
........
  r58624 | raymond.hettinger | 2007-10-24 04:05:51 +0200 (Wed, 24 Oct 2007) | 1 line
  
  Fixup error return and add support for intermixed ints and floats/
........
  r58628 | vinay.sajip | 2007-10-24 12:47:06 +0200 (Wed, 24 Oct 2007) | 1 line
  
  Bug #1321: Fixed logic error in TimedRotatingFileHandler.__init__()
........
  r58641 | facundo.batista | 2007-10-24 21:11:08 +0200 (Wed, 24 Oct 2007) | 4 lines
  
  
  Issue 1290.  CharacterData.__repr__ was constructing a string
  in response that keeped having a non-ascii character.
........
  r58643 | thomas.heller | 2007-10-24 21:50:45 +0200 (Wed, 24 Oct 2007) | 1 line
  
  Added unittest for calling a function with paramflags (backport from py3k branch).
........
  r58645 | matthias.klose | 2007-10-24 22:00:44 +0200 (Wed, 24 Oct 2007) | 2 lines
  
  - Build using system ffi library on arm*-linux*.
........
  r58651 | georg.brandl | 2007-10-24 23:40:38 +0200 (Wed, 24 Oct 2007) | 2 lines
  
  Bug #1287: make os.environ.pop() work as expected.
........
  r58652 | raymond.hettinger | 2007-10-25 04:26:58 +0200 (Thu, 25 Oct 2007) | 1 line
  
  Missing DECREFs
........
  r58653 | matthias.klose | 2007-10-25 08:37:24 +0200 (Thu, 25 Oct 2007) | 2 lines
  
  - Build using system ffi library on arm*-linux*, pass --with-system-ffi to CONFIG_ARGS
........
  r58655 | thomas.heller | 2007-10-25 21:47:32 +0200 (Thu, 25 Oct 2007) | 2 lines
  
  ffi_type_longdouble may be already #defined.
  See issue 1324.
........
  r58656 | kurt.kaiser | 2007-10-26 00:43:45 +0200 (Fri, 26 Oct 2007) | 3 lines
  
  Correct an ancient bug in an unused path by removing that path: register() is
  now idempotent.
........
  r58660 | kurt.kaiser | 2007-10-26 02:10:09 +0200 (Fri, 26 Oct 2007) | 4 lines
  
  1. Add comments to provide top-level documentation.
  2. Refactor to use more descriptive names.
  3. Enhance tests in main().
........
  r58675 | georg.brandl | 2007-10-26 20:30:41 +0200 (Fri, 26 Oct 2007) | 2 lines
  
  Fix new pop() method on os.environ on ignorecase-platforms.
........
  r58696 | neal.norwitz | 2007-10-28 00:32:21 +0200 (Sun, 28 Oct 2007) | 1 line
  
  Update URL for Pygments.  0.8.1 is no longer available
........
  r58697 | hyeshik.chang | 2007-10-28 12:19:02 +0100 (Sun, 28 Oct 2007) | 3 lines
  
  - Add support for FreeBSD 8 which is recently forked from FreeBSD 7.
  - Regenerate IN module for most recent maintenance tree of FreeBSD 6 and 7.
........
  r58698 | hyeshik.chang | 2007-10-28 13:38:09 +0100 (Sun, 28 Oct 2007) | 2 lines
  
  Enable platform-specific tweaks for FreeBSD 8 (exactly same to FreeBSD 7's yet)
........
  r58700 | kurt.kaiser | 2007-10-28 20:03:59 +0100 (Sun, 28 Oct 2007) | 2 lines
  
  Add confirmation dialog before printing.  Patch 1717170 Tal Einat.
........
  r58706 | guido.van.rossum | 2007-10-29 21:52:45 +0100 (Mon, 29 Oct 2007) | 3 lines
  
  Patch 1353 by Jacob Winther.
  Add mp4 mapping to mimetypes.py.
........
  r58709 | guido.van.rossum | 2007-10-29 23:15:05 +0100 (Mon, 29 Oct 2007) | 6 lines
  
  Backport fixes for the code that decodes octal escapes (and for PyString
  also hex escapes) -- this was reaching beyond the end of the input string
  buffer, even though it is not supposed to be \0-terminated.
  This has no visible effect but is clearly the correct thing to do.
  (In 3.0 it had a visible effect after removing ob_sstate from PyString.)
........
  r58710 | kurt.kaiser | 2007-10-30 03:38:54 +0100 (Tue, 30 Oct 2007) | 7 lines
  
  check in Tal Einat's update to tabpage.py
  Patch 1612746 
  
  M    configDialog.py
  M    NEWS.txt
  AM   tabbedpages.py
........
  r58715 | georg.brandl | 2007-10-30 18:51:18 +0100 (Tue, 30 Oct 2007) | 2 lines
  
  Use correct markup.
........
  r58716 | georg.brandl | 2007-10-30 18:57:12 +0100 (Tue, 30 Oct 2007) | 2 lines
  
  Make example about hiding None return values at the prompt clearer.
........
  r58728 | neal.norwitz | 2007-10-31 07:33:20 +0100 (Wed, 31 Oct 2007) | 1 line
  
  Fix some compiler warnings for signed comparisons on Unix and Windows.
........
  r58731 | martin.v.loewis | 2007-10-31 18:19:33 +0100 (Wed, 31 Oct 2007) | 2 lines
  
  Adding Christian Heimes.
........
  r58737 | raymond.hettinger | 2007-10-31 22:57:58 +0100 (Wed, 31 Oct 2007) | 1 line
  
  Clarify the reasons why pickle is almost always better than marshal
........
  r58739 | raymond.hettinger | 2007-10-31 23:15:49 +0100 (Wed, 31 Oct 2007) | 1 line
  
  Sets are marshalable.
........
  r58745 | georg.brandl | 2007-11-01 18:19:33 +0100 (Thu, 01 Nov 2007) | 2 lines
  
  #1364: os.lstat is available on Windows too, as an alias to os.stat.
........
  r58750 | christian.heimes | 2007-11-01 20:48:10 +0100 (Thu, 01 Nov 2007) | 1 line
  
  Backport of import tests for bug http://bugs.python.org/issue1293 and bug http://bugs.python.org/issue1342
........
  r58751 | christian.heimes | 2007-11-01 21:11:06 +0100 (Thu, 01 Nov 2007) | 1 line
  
  Removed non ASCII text from test as requested by Guido. Sorry :/
........
  r58753 | georg.brandl | 2007-11-01 21:37:02 +0100 (Thu, 01 Nov 2007) | 2 lines
  
  Fix markup glitch.
........
  r58757 | gregory.p.smith | 2007-11-01 22:08:14 +0100 (Thu, 01 Nov 2007) | 4 lines
  
  Fix bug introduced in revision 58385.  Database keys could no longer
  have NULL bytes in them.  Replace the errant strdup with a
  malloc+memcpy.  Adds a unit test for the correct behavior.
........
  r58758 | gregory.p.smith | 2007-11-01 22:15:36 +0100 (Thu, 01 Nov 2007) | 3 lines
  
  Undo revision 58533 58534 fixes.  Those were a workaround for
  a problem introduced by 58385.
........
  r58759 | gregory.p.smith | 2007-11-01 22:17:47 +0100 (Thu, 01 Nov 2007) | 2 lines
  
  false "fix" undone as correct problem was found and fixed.
........
  r58765 | mark.summerfield | 2007-11-02 09:24:59 +0100 (Fri, 02 Nov 2007) | 3 lines
  
  Added more file-handling related cross-references.
........
  r58766 | nick.coghlan | 2007-11-02 11:09:12 +0100 (Fri, 02 Nov 2007) | 1 line
  
  Fix for bug 1705170 - contextmanager swallowing StopIteration (2.5 backport candidate)
........


Modified: python/branches/ctypes-branch/Doc/README.txt
==============================================================================
--- python/branches/ctypes-branch/Doc/README.txt	(original)
+++ python/branches/ctypes-branch/Doc/README.txt	Fri Nov  2 17:45:27 2007
@@ -67,7 +67,7 @@
 
 You can optionally also install Pygments, either as a checkout via :: 
 
-   svn co http://svn.python.org/projects/external/Pygments-0.8.1/pygments tools/pygments
+   svn co http://svn.python.org/projects/external/Pygments-0.9/pygments tools/pygments
 
 or from PyPI at http://pypi.python.org/pypi/Pygments.
 

Modified: python/branches/ctypes-branch/Doc/library/functions.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/functions.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/functions.rst	Fri Nov  2 17:45:27 2007
@@ -766,8 +766,9 @@
    Python enforces that the mode, after stripping ``'U'``, begins with ``'r'``,
    ``'w'`` or ``'a'``.
 
-   See also the :mod:`fileinput` module, the :mod:`os` module, and the
-   :mod:`os.path` module.
+   Python provides many file handling modules including
+   :mod:`fileinput`, :mod:`os`, :mod:`os.path`, :mod:`tempfile`, and
+   :mod:`shutil`.
 
    .. versionchanged:: 2.5
       Restriction on first letter of mode string introduced.

Modified: python/branches/ctypes-branch/Doc/library/marshal.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/marshal.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/marshal.rst	Fri Nov  2 17:45:27 2007
@@ -25,7 +25,9 @@
 writing the "pseudo-compiled" code for Python modules of :file:`.pyc` files.
 Therefore, the Python maintainers reserve the right to modify the marshal format
 in backward incompatible ways should the need arise.  If you're serializing and
-de-serializing Python objects, use the :mod:`pickle` module instead.
+de-serializing Python objects, use the :mod:`pickle` module instead -- the
+performance is comparable, version independence is guaranteed, and pickle
+supports a substantially wider range of objects than marshal.
 
 .. warning::
 
@@ -36,13 +38,19 @@
 Not all Python object types are supported; in general, only objects whose value
 is independent from a particular invocation of Python can be written and read by
 this module.  The following types are supported: ``None``, integers, long
-integers, floating point numbers, strings, Unicode objects, tuples, lists,
+integers, floating point numbers, strings, Unicode objects, tuples, lists, sets,
 dictionaries, and code objects, where it should be understood that tuples, lists
 and dictionaries are only supported as long as the values contained therein are
 themselves supported; and recursive lists and dictionaries should not be written
 (they will cause infinite loops).
 
 .. warning::
+
+   Some unsupported types such as subclasses of builtins will appear to marshal
+   and unmarshal correctly, but in fact, their type will change and the
+   additional subclass functionality and instance attributes will be lost.
+
+.. warning::
    
    On machines where C's ``long int`` type has more than 32 bits (such as the
    DEC Alpha), it is possible to create plain Python integers that are longer

Modified: python/branches/ctypes-branch/Doc/library/os.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/os.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/os.rst	Fri Nov  2 17:45:27 2007
@@ -11,7 +11,9 @@
 :mod:`posix` or :mod:`nt`. If you just want to read or write a file see
 :func:`open`, if you want to manipulate paths, see the :mod:`os.path`
 module, and if you want to read all the lines in all the files on the
-command line see the :mod:`fileinput` module.
+command line see the :mod:`fileinput` module. For creating temporary
+files and directories see the :mod:`tempfile` module, and for high-level
+file and directory handling see the :mod:`shutil` module.
 
 This module searches for an operating system dependent built-in module like
 :mod:`mac` or :mod:`posix` and exports the same functions and data as found
@@ -118,10 +120,11 @@
    If the platform supports the :func:`unsetenv` function, you can delete items in
    this mapping to unset environment variables. :func:`unsetenv` will be called
    automatically when an item is deleted from ``os.environ``, and when
-   :meth:`os.environ.clear` is called.
+   one of the :meth:`pop` or :meth:`clear` methods is called.
 
    .. versionchanged:: 2.6
-      Also unset environment variables when calling :meth:`os.environ.clear`.
+      Also unset environment variables when calling :meth:`os.environ.clear`
+      and :meth:`os.environ.pop`.
 
 
 .. function:: chdir(path)
@@ -921,8 +924,9 @@
 
 .. function:: lstat(path)
 
-   Like :func:`stat`, but do not follow symbolic links. Availability: Macintosh,
-   Unix.
+   Like :func:`stat`, but do not follow symbolic links.  This is an alias for
+   :func:`stat` on platforms that do not support symbolic links, such as
+   Windows.
 
 
 .. function:: mkfifo(path[, mode])
@@ -981,6 +985,9 @@
    ``0777`` (octal).  On some systems, *mode* is ignored.  Where it is used, the
    current umask value is first masked out. Availability: Macintosh, Unix, Windows.
 
+   It is also possible to create temporary directories; see the
+   :mod:`tempfile` module's :func:`tempfile.mkdtemp` function.
+
 
 .. function:: makedirs(path[, mode])
 

Modified: python/branches/ctypes-branch/Doc/library/shutil.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/shutil.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/shutil.rst	Fri Nov  2 17:45:27 2007
@@ -15,7 +15,8 @@
 
 The :mod:`shutil` module offers a number of high-level operations on files and
 collections of files.  In particular, functions are provided  which support file
-copying and removal.
+copying and removal. For operations on individual files, see also the
+:mod:`os` module.
 
 .. warning::
    

Modified: python/branches/ctypes-branch/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/stdtypes.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/stdtypes.rst	Fri Nov  2 17:45:27 2007
@@ -938,7 +938,7 @@
    specified, then there is no limit on the number of splits (all possible
    splits are made).
 
-   If *sep is given, consecutive delimiters are not grouped together and are
+   If *sep* is given, consecutive delimiters are not grouped together and are
    deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns
    ``['1', '', '2']``).  The *sep* argument may consist of multiple characters
    (for example, ``'1<>2<>3'.split('<>')`` returns ``['1', '2', '3']``).
@@ -1846,7 +1846,10 @@
 constructors described in the :ref:`built-in-funcs` section. [#]_ File
 objects are also returned by some other built-in functions and methods,
 such as :func:`os.popen` and :func:`os.fdopen` and the :meth:`makefile`
-method of socket objects.
+method of socket objects. Temporary files can be created using the
+:mod:`tempfile` module, and high-level file operations such as copying,
+moving, and deleting files and directories can be achieved with the
+:mod:`shutil` module.
 
 When a file operation fails for an I/O-related reason, the exception
 :exc:`IOError` is raised.  This includes situations where the operation is not

Modified: python/branches/ctypes-branch/Doc/tutorial/controlflow.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/tutorial/controlflow.rst	(original)
+++ python/branches/ctypes-branch/Doc/tutorial/controlflow.rst	Fri Nov  2 17:45:27 2007
@@ -235,8 +235,9 @@
 technically speaking, procedures do return a value, albeit a rather boring one.
 This value is called ``None`` (it's a built-in name).  Writing the value
 ``None`` is normally suppressed by the interpreter if it would be the only value
-written.  You can see it if you really want to::
+written.  You can see it if you really want to using :keyword:`print`::
 
+   >>> fib(0)
    >>> print fib(0)
    None
 

Modified: python/branches/ctypes-branch/Doc/using/cmdline.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/using/cmdline.rst	(original)
+++ python/branches/ctypes-branch/Doc/using/cmdline.rst	Fri Nov  2 17:45:27 2007
@@ -217,10 +217,10 @@
    Force stdin, stdout and stderr to be totally unbuffered.  On systems where it
    matters, also put stdin, stdout and stderr in binary mode.
    
-   Note that there is internal buffering in :func:`file.readlines` and
+   Note that there is internal buffering in :meth:`file.readlines` and
    :ref:`bltin-file-objects` (``for line in sys.stdin``) which is not influenced
    by this option.  To work around this, you will want to use
-   :func:`file.readline` inside a ``while 1:`` loop.
+   :meth:`file.readline` inside a ``while 1:`` loop.
 
    See also :envvar:`PYTHONUNBUFFERED`.
 

Modified: python/branches/ctypes-branch/Doc/whatsnew/2.6.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/whatsnew/2.6.rst	(original)
+++ python/branches/ctypes-branch/Doc/whatsnew/2.6.rst	Fri Nov  2 17:45:27 2007
@@ -520,11 +520,11 @@
 
   .. % Patch 1551443
 
-* A new data type in the :mod:`collections` module: :class:`named_tuple(typename,
+* A new data type in the :mod:`collections` module: :class:`namedtuple(typename,
   fieldnames)` is a factory function that creates subclasses of the standard tuple
   whose fields are accessible by name as well as index.  For example::
 
-     >>> var_type = collections.named_tuple('variable', 
+     >>> var_type = collections.namedtuple('variable', 
      ...             'id name type size')
      # Names are separated by spaces or commas.
      # 'id, name, type, size' would also work.

Modified: python/branches/ctypes-branch/Lib/bsddb/dbtables.py
==============================================================================
--- python/branches/ctypes-branch/Lib/bsddb/dbtables.py	(original)
+++ python/branches/ctypes-branch/Lib/bsddb/dbtables.py	Fri Nov  2 17:45:27 2007
@@ -360,12 +360,11 @@
         unique = 0
         while not unique:
             # Generate a random 64-bit row ID string
-            # (note: this code has <64 bits of randomness
+            # (note: might have <64 bits of true randomness
             # but it's plenty for our database id needs!)
-            # We must ensure that no null bytes are in the id value.
             blist = []
             for x in xrange(_rowid_str_len):
-                blist.append(random.randint(1,255))
+                blist.append(random.randint(0,255))
             newid = struct.pack('B'*_rowid_str_len, *blist)
 
             # Guarantee uniqueness by adding this key to the database

Modified: python/branches/ctypes-branch/Lib/bsddb/test/test_misc.py
==============================================================================
--- python/branches/ctypes-branch/Lib/bsddb/test/test_misc.py	(original)
+++ python/branches/ctypes-branch/Lib/bsddb/test/test_misc.py	Fri Nov  2 17:45:27 2007
@@ -30,10 +30,8 @@
             os.remove(self.filename)
         except OSError:
             pass
-        import glob
-        files = glob.glob(os.path.join(self.homeDir, '*'))
-        for file in files:
-            os.remove(file)
+        import shutil
+        shutil.rmtree(self.homeDir)
 
     def test01_badpointer(self):
         dbs = dbshelve.open(self.filename)
@@ -73,6 +71,25 @@
             db1.close()
             os.unlink(self.filename)
 
+    def test05_key_with_null_bytes(self):
+        try:
+            db1 = db.DB()
+            db1.open(self.filename, None, db.DB_HASH, db.DB_CREATE)
+            db1['a'] = 'eh?'
+            db1['a\x00'] = 'eh zed.'
+            db1['a\x00a'] = 'eh zed eh?'
+            db1['aaa'] = 'eh eh eh!'
+            keys = db1.keys()
+            keys.sort()
+            self.assertEqual(['a', 'a\x00', 'a\x00a', 'aaa'], keys)
+            self.assertEqual(db1['a'], 'eh?')
+            self.assertEqual(db1['a\x00'], 'eh zed.')
+            self.assertEqual(db1['a\x00a'], 'eh zed eh?')
+            self.assertEqual(db1['aaa'], 'eh eh eh!')
+        finally:
+            db1.close()
+            os.unlink(self.filename)
+
 
 #----------------------------------------------------------------------
 

Modified: python/branches/ctypes-branch/Lib/collections.py
==============================================================================
--- python/branches/ctypes-branch/Lib/collections.py	(original)
+++ python/branches/ctypes-branch/Lib/collections.py	Fri Nov  2 17:45:27 2007
@@ -1,14 +1,14 @@
-__all__ = ['deque', 'defaultdict', 'named_tuple']
+__all__ = ['deque', 'defaultdict', 'namedtuple']
 
 from _collections import deque, defaultdict
 from operator import itemgetter as _itemgetter
 from keyword import iskeyword as _iskeyword
 import sys as _sys
 
-def named_tuple(typename, field_names, verbose=False):
+def namedtuple(typename, field_names, verbose=False):
     """Returns a new subclass of tuple with named fields.
 
-    >>> Point = named_tuple('Point', 'x y')
+    >>> Point = namedtuple('Point', 'x y')
     >>> Point.__doc__                   # docstring for the new class
     'Point(x, y)'
     >>> p = Point(11, y=22)             # instantiate with positional args or keywords
@@ -94,10 +94,10 @@
 if __name__ == '__main__':
     # verify that instances can be pickled
     from cPickle import loads, dumps
-    Point = named_tuple('Point', 'x, y', True)
+    Point = namedtuple('Point', 'x, y', True)
     p = Point(x=10, y=20)
     assert p == loads(dumps(p))
 
     import doctest
-    TestResults = named_tuple('TestResults', 'failed attempted')
+    TestResults = namedtuple('TestResults', 'failed attempted')
     print TestResults(*doctest.testmod())

Modified: python/branches/ctypes-branch/Lib/contextlib.py
==============================================================================
--- python/branches/ctypes-branch/Lib/contextlib.py	(original)
+++ python/branches/ctypes-branch/Lib/contextlib.py	Fri Nov  2 17:45:27 2007
@@ -25,6 +25,10 @@
             else:
                 raise RuntimeError("generator didn't stop")
         else:
+            if value is None:
+                # Need to force instantiation so we can reliably
+                # tell if we get the same exception back
+                value = type()
             try:
                 self.gen.throw(type, value, traceback)
                 raise RuntimeError("generator didn't stop after throw()")

Modified: python/branches/ctypes-branch/Lib/ctypes/test/test_prototypes.py
==============================================================================
--- python/branches/ctypes-branch/Lib/ctypes/test/test_prototypes.py	(original)
+++ python/branches/ctypes-branch/Lib/ctypes/test/test_prototypes.py	Fri Nov  2 17:45:27 2007
@@ -48,6 +48,24 @@
         func.restype = c_long
         func.argtypes = None
 
+    def test_paramflags(self):
+        # function returns c_void_p result,
+        # and has a required parameter named 'input'
+        prototype = CFUNCTYPE(c_void_p, c_void_p)
+        func = prototype(("_testfunc_p_p", testdll),
+                         ((1, "input"),))
+
+        try:
+            func()
+        except TypeError as details:
+            self.failUnlessEqual(str(details), "required argument 'input' missing")
+        else:
+            self.fail("TypeError not raised")
+
+        self.failUnlessEqual(func(None), None)
+        self.failUnlessEqual(func(input=None), None)
+
+
     def test_int_pointer_arg(self):
         func = testdll._testfunc_p_p
         func.restype = c_long

Modified: python/branches/ctypes-branch/Lib/idlelib/IOBinding.py
==============================================================================
--- python/branches/ctypes-branch/Lib/idlelib/IOBinding.py	(original)
+++ python/branches/ctypes-branch/Lib/idlelib/IOBinding.py	Fri Nov  2 17:45:27 2007
@@ -465,13 +465,23 @@
             self.text.insert("end-1c", "\n")
 
     def print_window(self, event):
+        m = tkMessageBox.Message(
+            title="Print",
+            message="Print to Default Printer",
+            icon=tkMessageBox.QUESTION,
+            type=tkMessageBox.OKCANCEL,
+            default=tkMessageBox.OK,
+            master=self.text)
+        reply = m.show()
+        if reply != tkMessageBox.OK:
+            self.text.focus_set()
+            return "break"
         tempfilename = None
         saved = self.get_saved()
         if saved:
             filename = self.filename
         # shell undo is reset after every prompt, looks saved, probably isn't
         if not saved or filename is None:
-            # XXX KBK 08Jun03 Wouldn't it be better to ask the user to save?
             (tfd, tempfilename) = tempfile.mkstemp(prefix='IDLE_tmp_')
             filename = tempfilename
             os.close(tfd)

Modified: python/branches/ctypes-branch/Lib/idlelib/NEWS.txt
==============================================================================
--- python/branches/ctypes-branch/Lib/idlelib/NEWS.txt	(original)
+++ python/branches/ctypes-branch/Lib/idlelib/NEWS.txt	Fri Nov  2 17:45:27 2007
@@ -3,6 +3,11 @@
 
 *Release date: XX-XXX-200X*
 
+- tabpage.py updated: tabbedPages.py now supports multiple dynamic rows
+  of tabs.  Patch 1612746 Tal Einat.
+
+- Add confirmation dialog before printing.  Patch 1717170 Tal Einat.
+
 - Show paste position if > 80 col.  Patch 1659326 Tal Einat.
 
 - Update cursor color without restarting.  Patch 1725576 Tal Einat.

Modified: python/branches/ctypes-branch/Lib/idlelib/WidgetRedirector.py
==============================================================================
--- python/branches/ctypes-branch/Lib/idlelib/WidgetRedirector.py	(original)
+++ python/branches/ctypes-branch/Lib/idlelib/WidgetRedirector.py	Fri Nov  2 17:45:27 2007
@@ -1,17 +1,38 @@
 from Tkinter import *
 
-
 class WidgetRedirector:
 
-    """Support for redirecting arbitrary widget subcommands."""
+    """Support for redirecting arbitrary widget subcommands.
+
+    Some Tk operations don't normally pass through Tkinter.  For example, if a
+    character is inserted into a Text widget by pressing a key, a default Tk
+    binding to the widget's 'insert' operation is activated, and the Tk library
+    processes the insert without calling back into Tkinter.
+
+    Although a binding to <Key> could be made via Tkinter, what we really want
+    to do is to hook the Tk 'insert' operation itself.
+
+    When a widget is instantiated, a Tcl command is created whose name is the
+    same as the pathname widget._w.  This command is used to invoke the various
+    widget operations, e.g. insert (for a Text widget). We are going to hook
+    this command and provide a facility ('register') to intercept the widget
+    operation.
+
+    In IDLE, the function being registered provides access to the top of a
+    Percolator chain.  At the bottom of the chain is a call to the original
+    Tk widget operation.
 
+    """
     def __init__(self, widget):
-        self.dict = {}
-        self.widget = widget
-        self.tk = tk = widget.tk
-        w = widget._w
+        self._operations = {}
+        self.widget = widget            # widget instance
+        self.tk = tk = widget.tk        # widget's root
+        w = widget._w                   # widget's (full) Tk pathname
         self.orig = w + "_orig"
+        # Rename the Tcl command within Tcl:
         tk.call("rename", w, self.orig)
+        # Create a new Tcl command whose name is the widget's pathname, and
+        # whose action is to dispatch on the operation passed to the widget:
         tk.createcommand(w, self.dispatch)
 
     def __repr__(self):
@@ -19,74 +40,87 @@
                                              self.widget._w)
 
     def close(self):
-        for name in self.dict.keys():
-            self.unregister(name)
+        for operation in self._operations:
+            self.unregister(operation)
         widget = self.widget; del self.widget
         orig = self.orig; del self.orig
         tk = widget.tk
         w = widget._w
         tk.deletecommand(w)
+        # restore the original widget Tcl command:
         tk.call("rename", orig, w)
 
-    def register(self, name, function):
-        if self.dict.has_key(name):
-            previous = dict[name]
-        else:
-            previous = OriginalCommand(self, name)
-        self.dict[name] = function
-        setattr(self.widget, name, function)
-        return previous
-
-    def unregister(self, name):
-        if self.dict.has_key(name):
-            function = self.dict[name]
-            del self.dict[name]
-            if hasattr(self.widget, name):
-                delattr(self.widget, name)
+    def register(self, operation, function):
+        self._operations[operation] = function
+        setattr(self.widget, operation, function)
+        return OriginalCommand(self, operation)
+
+    def unregister(self, operation):
+        if operation in self._operations:
+            function = self._operations[operation]
+            del self._operations[operation]
+            if hasattr(self.widget, operation):
+                delattr(self.widget, operation)
             return function
         else:
             return None
 
-    def dispatch(self, cmd, *args):
-        m = self.dict.get(cmd)
+    def dispatch(self, operation, *args):
+        '''Callback from Tcl which runs when the widget is referenced.
+
+        If an operation has been registered in self._operations, apply the
+        associated function to the args passed into Tcl. Otherwise, pass the
+        operation through to Tk via the original Tcl function.
+
+        Note that if a registered function is called, the operation is not
+        passed through to Tk.  Apply the function returned by self.register()
+        to *args to accomplish that.  For an example, see ColorDelegator.py.
+
+        '''
+        m = self._operations.get(operation)
         try:
             if m:
                 return m(*args)
             else:
-                return self.tk.call((self.orig, cmd) + args)
+                return self.tk.call((self.orig, operation) + args)
         except TclError:
             return ""
 
 
 class OriginalCommand:
 
-    def __init__(self, redir, name):
+    def __init__(self, redir, operation):
         self.redir = redir
-        self.name = name
+        self.operation = operation
         self.tk = redir.tk
         self.orig = redir.orig
         self.tk_call = self.tk.call
-        self.orig_and_name = (self.orig, self.name)
+        self.orig_and_operation = (self.orig, self.operation)
 
     def __repr__(self):
-        return "OriginalCommand(%r, %r)" % (self.redir, self.name)
+        return "OriginalCommand(%r, %r)" % (self.redir, self.operation)
 
     def __call__(self, *args):
-        return self.tk_call(self.orig_and_name + args)
+        return self.tk_call(self.orig_and_operation + args)
 
 
 def main():
     root = Tk()
+    root.wm_protocol("WM_DELETE_WINDOW", root.quit)
     text = Text()
     text.pack()
     text.focus_set()
     redir = WidgetRedirector(text)
-    global orig_insert
+    global previous_tcl_fcn
     def my_insert(*args):
         print "insert", args
-        orig_insert(*args)
-    orig_insert = redir.register("insert", my_insert)
+        previous_tcl_fcn(*args)
+    previous_tcl_fcn = redir.register("insert", my_insert)
+    root.mainloop()
+    redir.unregister("insert")  # runs after first 'close window'
+    redir.close()
     root.mainloop()
+    root.destroy()
 
 if __name__ == "__main__":
     main()

Modified: python/branches/ctypes-branch/Lib/idlelib/configDialog.py
==============================================================================
--- python/branches/ctypes-branch/Lib/idlelib/configDialog.py	(original)
+++ python/branches/ctypes-branch/Lib/idlelib/configDialog.py	Fri Nov  2 17:45:27 2007
@@ -15,7 +15,7 @@
 
 from configHandler import idleConf
 from dynOptionMenuWidget import DynOptionMenu
-from tabpage import TabPageSet
+from tabbedpages import TabbedPageSet
 from keybindingDialog import GetKeysDialog
 from configSectionNameDialog import GetCfgSectionNameDialog
 from configHelpSourceEdit import GetHelpSourceDialog
@@ -65,10 +65,9 @@
         self.wait_window()
 
     def CreateWidgets(self):
-        self.tabPages = TabPageSet(self,
-                pageNames=['Fonts/Tabs','Highlighting','Keys','General'])
-        self.tabPages.ChangePage()#activates default (first) page
-        frameActionButtons = Frame(self)
+        self.tabPages = TabbedPageSet(self,
+                page_names=['Fonts/Tabs','Highlighting','Keys','General'])
+        frameActionButtons = Frame(self,pady=2)
         #action buttons
         self.buttonHelp = Button(frameActionButtons,text='Help',
                 command=self.Help,takefocus=FALSE,
@@ -103,7 +102,7 @@
         self.editFont=tkFont.Font(self,('courier',10,'normal'))
         ##widget creation
         #body frame
-        frame=self.tabPages.pages['Fonts/Tabs']['page']
+        frame=self.tabPages.pages['Fonts/Tabs'].frame
         #body section frames
         frameFont=LabelFrame(frame,borderwidth=2,relief=GROOVE,
                              text=' Base Editor Font ')
@@ -167,7 +166,7 @@
         self.highlightTarget=StringVar(self)
         ##widget creation
         #body frame
-        frame=self.tabPages.pages['Highlighting']['page']
+        frame=self.tabPages.pages['Highlighting'].frame
         #body section frames
         frameCustom=LabelFrame(frame,borderwidth=2,relief=GROOVE,
                                text=' Custom Highlighting ')
@@ -255,7 +254,7 @@
         self.keyBinding=StringVar(self)
         ##widget creation
         #body frame
-        frame=self.tabPages.pages['Keys']['page']
+        frame=self.tabPages.pages['Keys'].frame
         #body section frames
         frameCustom=LabelFrame(frame,borderwidth=2,relief=GROOVE,
                                text=' Custom Key Bindings ')
@@ -325,7 +324,7 @@
         self.helpBrowser=StringVar(self)
         #widget creation
         #body
-        frame=self.tabPages.pages['General']['page']
+        frame=self.tabPages.pages['General'].frame
         #body section frames
         frameRun=LabelFrame(frame,borderwidth=2,relief=GROOVE,
                             text=' Startup Preferences ')

Modified: python/branches/ctypes-branch/Lib/logging/handlers.py
==============================================================================
--- python/branches/ctypes-branch/Lib/logging/handlers.py	(original)
+++ python/branches/ctypes-branch/Lib/logging/handlers.py	Fri Nov  2 17:45:27 2007
@@ -230,11 +230,11 @@
             #         of days in the next week until the rollover day (3).
             if when.startswith('W'):
                 day = t[6] # 0 is Monday
-                if day > self.dayOfWeek:
-                    daysToWait = (day - self.dayOfWeek) - 1
-                    self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
-                if day < self.dayOfWeek:
-                    daysToWait = (6 - self.dayOfWeek) + day
+                if day != self.dayOfWeek:
+                    if day < self.dayOfWeek:
+                        daysToWait = self.dayOfWeek - day - 1
+                    else:
+                        daysToWait = 6 - day + self.dayOfWeek
                     self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
 
         #print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)

Modified: python/branches/ctypes-branch/Lib/mimetypes.py
==============================================================================
--- python/branches/ctypes-branch/Lib/mimetypes.py	(original)
+++ python/branches/ctypes-branch/Lib/mimetypes.py	Fri Nov  2 17:45:27 2007
@@ -393,6 +393,7 @@
         '.movie'  : 'video/x-sgi-movie',
         '.mp2'    : 'audio/mpeg',
         '.mp3'    : 'audio/mpeg',
+        '.mp4'    : 'video/mp4',
         '.mpa'    : 'video/mpeg',
         '.mpe'    : 'video/mpeg',
         '.mpeg'   : 'video/mpeg',

Modified: python/branches/ctypes-branch/Lib/os.py
==============================================================================
--- python/branches/ctypes-branch/Lib/os.py	(original)
+++ python/branches/ctypes-branch/Lib/os.py	Fri Nov  2 17:45:27 2007
@@ -450,6 +450,9 @@
                     for key in self.data.keys():
                         unsetenv(key)
                         del self.data[key]
+                def pop(self, key, *args):
+                    unsetenv(key)
+                    return self.data.pop(key.upper(), *args)
             def has_key(self, key):
                 return key.upper() in self.data
             def __contains__(self, key):
@@ -511,6 +514,9 @@
                     for key in self.data.keys():
                         unsetenv(key)
                         del self.data[key]
+                def pop(self, key, *args):
+                    unsetenv(key)
+                    return self.data.pop(key, *args)
             def copy(self):
                 return dict(self)
 

Modified: python/branches/ctypes-branch/Lib/plat-freebsd6/IN.py
==============================================================================
--- python/branches/ctypes-branch/Lib/plat-freebsd6/IN.py	(original)
+++ python/branches/ctypes-branch/Lib/plat-freebsd6/IN.py	Fri Nov  2 17:45:27 2007
@@ -1,6 +1,28 @@
 # Generated by h2py from /usr/include/netinet/in.h
 
 # Included from sys/cdefs.h
+__GNUCLIKE_ASM = 3
+__GNUCLIKE_ASM = 2
+__GNUCLIKE___TYPEOF = 1
+__GNUCLIKE___OFFSETOF = 1
+__GNUCLIKE___SECTION = 1
+__GNUCLIKE_ATTRIBUTE_MODE_DI = 1
+__GNUCLIKE_CTOR_SECTION_HANDLING = 1
+__GNUCLIKE_BUILTIN_CONSTANT_P = 1
+__GNUCLIKE_BUILTIN_VARARGS = 1
+__GNUCLIKE_BUILTIN_STDARG = 1
+__GNUCLIKE_BUILTIN_VAALIST = 1
+__GNUC_VA_LIST_COMPATIBILITY = 1
+__GNUCLIKE_BUILTIN_NEXT_ARG = 1
+__GNUCLIKE_BUILTIN_MEMCPY = 1
+__CC_SUPPORTS_INLINE = 1
+__CC_SUPPORTS___INLINE = 1
+__CC_SUPPORTS___INLINE__ = 1
+__CC_SUPPORTS___FUNC__ = 1
+__CC_SUPPORTS_WARNING = 1
+__CC_SUPPORTS_VARADIC_XXX = 1
+__CC_SUPPORTS_DYNAMIC_ARRAY_INIT = 1
+__CC_INT_IS_32BIT = 1
 def __P(protos): return protos
 
 def __STRING(x): return #x
@@ -29,6 +51,8 @@
 
 def __predict_false(exp): return (exp)
 
+def __format_arg(fmtarg): return __attribute__((__format_arg__ (fmtarg)))
+
 def __FBSDID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
 
 def __RCSID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
@@ -86,8 +110,6 @@
 BIG_ENDIAN = _BIG_ENDIAN
 PDP_ENDIAN = _PDP_ENDIAN
 BYTE_ORDER = _BYTE_ORDER
-__INTEL_COMPILER_with_FreeBSD_endian = 1
-__INTEL_COMPILER_with_FreeBSD_endian = 1
 def __word_swap_int_var(x): return \
 
 def __word_swap_int_const(x): return \
@@ -96,12 +118,16 @@
 
 def __byte_swap_int_var(x): return \
 
-def __byte_swap_int_var(x): return \
-
 def __byte_swap_int_const(x): return \
 
 def __byte_swap_int(x): return __byte_swap_int_var(x)
 
+def __byte_swap_long_var(x): return \
+
+def __byte_swap_long_const(x): return \
+
+def __byte_swap_long(x): return __byte_swap_long_var(x)
+
 def __byte_swap_word_var(x): return \
 
 def __byte_swap_word_const(x): return \
@@ -229,47 +255,50 @@
 IPPROTO_APES = 99
 IPPROTO_GMTP = 100
 IPPROTO_IPCOMP = 108
+IPPROTO_SCTP = 132
 IPPROTO_PIM = 103
+IPPROTO_CARP = 112
 IPPROTO_PGM = 113
 IPPROTO_PFSYNC = 240
 IPPROTO_OLD_DIVERT = 254
 IPPROTO_MAX = 256
 IPPROTO_DONE = 257
 IPPROTO_DIVERT = 258
+IPPROTO_SPACER = 32767
 IPPORT_RESERVED = 1024
 IPPORT_HIFIRSTAUTO = 49152
 IPPORT_HILASTAUTO = 65535
 IPPORT_RESERVEDSTART = 600
 IPPORT_MAX = 65535
-def IN_CLASSA(i): return (((u_int32_t)(i) & (-2147483648)) == 0)
+def IN_CLASSA(i): return (((u_int32_t)(i) & 0x80000000) == 0)
 
-IN_CLASSA_NET = (-16777216)
+IN_CLASSA_NET = 0xff000000
 IN_CLASSA_NSHIFT = 24
 IN_CLASSA_HOST = 0x00ffffff
 IN_CLASSA_MAX = 128
-def IN_CLASSB(i): return (((u_int32_t)(i) & (-1073741824)) == (-2147483648))
+def IN_CLASSB(i): return (((u_int32_t)(i) & 0xc0000000) == 0x80000000)
 
-IN_CLASSB_NET = (-65536)
+IN_CLASSB_NET = 0xffff0000
 IN_CLASSB_NSHIFT = 16
 IN_CLASSB_HOST = 0x0000ffff
 IN_CLASSB_MAX = 65536
-def IN_CLASSC(i): return (((u_int32_t)(i) & (-536870912)) == (-1073741824))
+def IN_CLASSC(i): return (((u_int32_t)(i) & 0xe0000000) == 0xc0000000)
 
-IN_CLASSC_NET = (-256)
+IN_CLASSC_NET = 0xffffff00
 IN_CLASSC_NSHIFT = 8
 IN_CLASSC_HOST = 0x000000ff
-def IN_CLASSD(i): return (((u_int32_t)(i) & (-268435456)) == (-536870912))
+def IN_CLASSD(i): return (((u_int32_t)(i) & 0xf0000000) == 0xe0000000)
 
-IN_CLASSD_NET = (-268435456)
+IN_CLASSD_NET = 0xf0000000
 IN_CLASSD_NSHIFT = 28
 IN_CLASSD_HOST = 0x0fffffff
 def IN_MULTICAST(i): return IN_CLASSD(i)
 
-def IN_EXPERIMENTAL(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456))
+def IN_EXPERIMENTAL(i): return (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
 
-def IN_BADCLASS(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456))
+def IN_BADCLASS(i): return (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
 
-INADDR_NONE = (-1)
+INADDR_NONE = 0xffffffff
 IN_LOOPBACKNET = 127
 IP_OPTIONS = 1
 IP_HDRINCL = 2
@@ -311,6 +340,8 @@
 IP_DUMMYNET_FLUSH = 62
 IP_DUMMYNET_GET = 64
 IP_RECVTTL = 65
+IP_MINTTL = 66
+IP_DONTFRAG = 67
 IP_DEFAULT_MULTICAST_TTL = 1
 IP_DEFAULT_MULTICAST_LOOP = 1
 IP_MAX_MEMBERSHIPS = 20
@@ -339,7 +370,7 @@
 
 
 # Included from netinet6/in6.h
-__KAME_VERSION = "20010528/FreeBSD"
+__KAME_VERSION = "FreeBSD"
 IPV6PORT_RESERVED = 1024
 IPV6PORT_ANONMIN = 49152
 IPV6PORT_ANONMAX = 65535
@@ -348,8 +379,8 @@
 INET6_ADDRSTRLEN = 46
 IPV6_ADDR_INT32_ONE = 1
 IPV6_ADDR_INT32_TWO = 2
-IPV6_ADDR_INT32_MNL = (-16711680)
-IPV6_ADDR_INT32_MLL = (-16646144)
+IPV6_ADDR_INT32_MNL = 0xff010000
+IPV6_ADDR_INT32_MLL = 0xff020000
 IPV6_ADDR_INT32_SMP = 0x0000ffff
 IPV6_ADDR_INT16_ULL = 0xfe80
 IPV6_ADDR_INT16_USL = 0xfec0
@@ -358,7 +389,7 @@
 IPV6_ADDR_INT32_TWO = 0x02000000
 IPV6_ADDR_INT32_MNL = 0x000001ff
 IPV6_ADDR_INT32_MLL = 0x000002ff
-IPV6_ADDR_INT32_SMP = (-65536)
+IPV6_ADDR_INT32_SMP = 0xffff0000
 IPV6_ADDR_INT16_ULL = 0x80fe
 IPV6_ADDR_INT16_USL = 0xc0fe
 IPV6_ADDR_INT16_MLL = 0x02ff
@@ -511,5 +542,10 @@
 IPV6CTL_RIP6STATS = 36
 IPV6CTL_PREFER_TEMPADDR = 37
 IPV6CTL_ADDRCTLPOLICY = 38
+IPV6CTL_USE_DEFAULTZONE = 39
 IPV6CTL_MAXFRAGS = 41
-IPV6CTL_MAXID = 42
+IPV6CTL_IFQ = 42
+IPV6CTL_ISATAPRTR = 43
+IPV6CTL_MCAST_PMTU = 44
+IPV6CTL_STEALTH = 45
+IPV6CTL_MAXID = 46

Modified: python/branches/ctypes-branch/Lib/plat-freebsd7/IN.py
==============================================================================
--- python/branches/ctypes-branch/Lib/plat-freebsd7/IN.py	(original)
+++ python/branches/ctypes-branch/Lib/plat-freebsd7/IN.py	Fri Nov  2 17:45:27 2007
@@ -10,9 +10,9 @@
 __GNUCLIKE_CTOR_SECTION_HANDLING = 1
 __GNUCLIKE_BUILTIN_CONSTANT_P = 1
 __GNUCLIKE_BUILTIN_VARARGS = 1
+__GNUCLIKE_BUILTIN_STDARG = 1
 __GNUCLIKE_BUILTIN_VAALIST = 1
 __GNUC_VA_LIST_COMPATIBILITY = 1
-__GNUCLIKE_BUILTIN_STDARG = 1
 __GNUCLIKE_BUILTIN_NEXT_ARG = 1
 __GNUCLIKE_BUILTIN_MEMCPY = 1
 __CC_SUPPORTS_INLINE = 1
@@ -51,6 +51,8 @@
 
 def __predict_false(exp): return (exp)
 
+def __format_arg(fmtarg): return __attribute__((__format_arg__ (fmtarg)))
+
 def __FBSDID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
 
 def __RCSID(s): return __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
@@ -247,6 +249,7 @@
 IPPROTO_APES = 99
 IPPROTO_GMTP = 100
 IPPROTO_IPCOMP = 108
+IPPROTO_SCTP = 132
 IPPROTO_PIM = 103
 IPPROTO_CARP = 112
 IPPROTO_PGM = 113
@@ -289,6 +292,10 @@
 
 def IN_BADCLASS(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456))
 
+def IN_LINKLOCAL(i): return (((u_int32_t)(i) & (-65536)) == (-1442971648))
+
+def IN_LOCAL_GROUP(i): return (((u_int32_t)(i) & (-256)) == (-536870912))
+
 INADDR_NONE = (-1)
 IN_LOOPBACKNET = 127
 IP_OPTIONS = 1
@@ -326,14 +333,35 @@
 IP_FW_ZERO = 53
 IP_FW_GET = 54
 IP_FW_RESETLOG = 55
+IP_FW_NAT_CFG = 56
+IP_FW_NAT_DEL = 57
+IP_FW_NAT_GET_CONFIG = 58
+IP_FW_NAT_GET_LOG = 59
 IP_DUMMYNET_CONFIGURE = 60
 IP_DUMMYNET_DEL = 61
 IP_DUMMYNET_FLUSH = 62
 IP_DUMMYNET_GET = 64
 IP_RECVTTL = 65
+IP_MINTTL = 66
+IP_DONTFRAG = 67
+IP_ADD_SOURCE_MEMBERSHIP = 70
+IP_DROP_SOURCE_MEMBERSHIP = 71
+IP_BLOCK_SOURCE = 72
+IP_UNBLOCK_SOURCE = 73
+IP_MSFILTER = 74
+MCAST_JOIN_GROUP = 80
+MCAST_LEAVE_GROUP = 81
+MCAST_JOIN_SOURCE_GROUP = 82
+MCAST_LEAVE_SOURCE_GROUP = 83
+MCAST_BLOCK_SOURCE = 84
+MCAST_UNBLOCK_SOURCE = 85
 IP_DEFAULT_MULTICAST_TTL = 1
 IP_DEFAULT_MULTICAST_LOOP = 1
-IP_MAX_MEMBERSHIPS = 20
+IP_MIN_MEMBERSHIPS = 31
+IP_MAX_MEMBERSHIPS = 4095
+IP_MAX_SOURCE_FILTER = 1024
+MCAST_INCLUDE = 1
+MCAST_EXCLUDE = 2
 IP_PORTRANGE_DEFAULT = 0
 IP_PORTRANGE_HIGH = 1
 IP_PORTRANGE_LOW = 2
@@ -359,7 +387,7 @@
 
 
 # Included from netinet6/in6.h
-__KAME_VERSION = "20010528/FreeBSD"
+__KAME_VERSION = "FreeBSD"
 IPV6PORT_RESERVED = 1024
 IPV6PORT_ANONMIN = 49152
 IPV6PORT_ANONMAX = 65535
@@ -430,6 +458,8 @@
 
 def IN6_IS_SCOPE_LINKLOCAL(a): return \
 
+def IN6_IS_SCOPE_EMBED(a): return \
+
 def IFA6_IS_DEPRECATED(a): return \
 
 def IFA6_IS_INVALID(a): return \
@@ -488,6 +518,7 @@
 IPV6_TCLASS = 61
 IPV6_DONTFRAG = 62
 IPV6_PREFER_TEMPADDR = 63
+IPV6_MSFILTER = 74
 IPV6_RTHDR_LOOSE = 0
 IPV6_RTHDR_STRICT = 1
 IPV6_RTHDR_TYPE_0 = 0
@@ -531,5 +562,10 @@
 IPV6CTL_RIP6STATS = 36
 IPV6CTL_PREFER_TEMPADDR = 37
 IPV6CTL_ADDRCTLPOLICY = 38
+IPV6CTL_USE_DEFAULTZONE = 39
 IPV6CTL_MAXFRAGS = 41
-IPV6CTL_MAXID = 42
+IPV6CTL_IFQ = 42
+IPV6CTL_ISATAPRTR = 43
+IPV6CTL_MCAST_PMTU = 44
+IPV6CTL_STEALTH = 45
+IPV6CTL_MAXID = 46

Modified: python/branches/ctypes-branch/Lib/posixfile.py
==============================================================================
--- python/branches/ctypes-branch/Lib/posixfile.py	(original)
+++ python/branches/ctypes-branch/Lib/posixfile.py	Fri Nov  2 17:45:27 2007
@@ -181,7 +181,7 @@
         if sys.platform in ('netbsd1',
                             'openbsd2',
                             'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
-                            'freebsd6', 'freebsd7',
+                            'freebsd6', 'freebsd7', 'freebsd8',
                             'bsdos2', 'bsdos3', 'bsdos4'):
             flock = struct.pack('lxxxxlxxxxlhh', \
                   l_start, l_len, os.getpid(), l_type, l_whence)

Modified: python/branches/ctypes-branch/Lib/smtpd.py
==============================================================================
--- python/branches/ctypes-branch/Lib/smtpd.py	(original)
+++ python/branches/ctypes-branch/Lib/smtpd.py	Fri Nov  2 17:45:27 2007
@@ -237,7 +237,7 @@
         if not self.__mailfrom:
             self.push('503 Error: need MAIL command')
             return
-        address = self.__getaddr('TO:', arg)
+        address = self.__getaddr('TO:', arg) if arg else None
         if not address:
             self.push('501 Syntax: RCPT TO: <address>')
             return

Modified: python/branches/ctypes-branch/Lib/test/regrtest.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/regrtest.py	(original)
+++ python/branches/ctypes-branch/Lib/test/regrtest.py	Fri Nov  2 17:45:27 2007
@@ -1104,6 +1104,7 @@
 _expectations['freebsd5'] = _expectations['freebsd4']
 _expectations['freebsd6'] = _expectations['freebsd4']
 _expectations['freebsd7'] = _expectations['freebsd4']
+_expectations['freebsd8'] = _expectations['freebsd4']
 
 class _ExpectedSkips:
     def __init__(self):

Modified: python/branches/ctypes-branch/Lib/test/test_collections.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_collections.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_collections.py	Fri Nov  2 17:45:27 2007
@@ -1,31 +1,31 @@
 import unittest
 from test import test_support
-from collections import named_tuple
+from collections import namedtuple
 
 class TestNamedTuple(unittest.TestCase):
 
     def test_factory(self):
-        Point = named_tuple('Point', 'x y')
+        Point = namedtuple('Point', 'x y')
         self.assertEqual(Point.__name__, 'Point')
         self.assertEqual(Point.__doc__, 'Point(x, y)')
         self.assertEqual(Point.__slots__, ())
         self.assertEqual(Point.__module__, __name__)
         self.assertEqual(Point.__getitem__, tuple.__getitem__)
 
-        self.assertRaises(ValueError, named_tuple, 'abc%', 'efg ghi')       # type has non-alpha char
-        self.assertRaises(ValueError, named_tuple, 'class', 'efg ghi')      # type has keyword
-        self.assertRaises(ValueError, named_tuple, '9abc', 'efg ghi')       # type starts with digit
-
-        self.assertRaises(ValueError, named_tuple, 'abc', 'efg g%hi')       # field with non-alpha char
-        self.assertRaises(ValueError, named_tuple, 'abc', 'abc class')      # field has keyword
-        self.assertRaises(ValueError, named_tuple, 'abc', '8efg 9ghi')      # field starts with digit
-        self.assertRaises(ValueError, named_tuple, 'abc', '__efg__ ghi')    # field with double underscores
-        self.assertRaises(ValueError, named_tuple, 'abc', 'efg efg ghi')    # duplicate field
+        self.assertRaises(ValueError, namedtuple, 'abc%', 'efg ghi')       # type has non-alpha char
+        self.assertRaises(ValueError, namedtuple, 'class', 'efg ghi')      # type has keyword
+        self.assertRaises(ValueError, namedtuple, '9abc', 'efg ghi')       # type starts with digit
+
+        self.assertRaises(ValueError, namedtuple, 'abc', 'efg g%hi')       # field with non-alpha char
+        self.assertRaises(ValueError, namedtuple, 'abc', 'abc class')      # field has keyword
+        self.assertRaises(ValueError, namedtuple, 'abc', '8efg 9ghi')      # field starts with digit
+        self.assertRaises(ValueError, namedtuple, 'abc', '__efg__ ghi')    # field with double underscores
+        self.assertRaises(ValueError, namedtuple, 'abc', 'efg efg ghi')    # duplicate field
 
-        named_tuple('Point0', 'x1 y2')   # Verify that numbers are allowed in names
+        namedtuple('Point0', 'x1 y2')   # Verify that numbers are allowed in names
 
     def test_instance(self):
-        Point = named_tuple('Point', 'x y')
+        Point = namedtuple('Point', 'x y')
         p = Point(11, 22)
         self.assertEqual(p, Point(x=11, y=22))
         self.assertEqual(p, Point(11, y=22))
@@ -44,17 +44,17 @@
         self.assertEqual(p.__asdict__(), dict(x=11, y=22))                  # test __dict__ method
 
         # verify that field string can have commas
-        Point = named_tuple('Point', 'x, y')
+        Point = namedtuple('Point', 'x, y')
         p = Point(x=11, y=22)
         self.assertEqual(repr(p), 'Point(x=11, y=22)')
 
         # verify that fieldspec can be a non-string sequence
-        Point = named_tuple('Point', ('x', 'y'))
+        Point = namedtuple('Point', ('x', 'y'))
         p = Point(x=11, y=22)
         self.assertEqual(repr(p), 'Point(x=11, y=22)')
 
     def test_tupleness(self):
-        Point = named_tuple('Point', 'x y')
+        Point = namedtuple('Point', 'x y')
         p = Point(11, 22)
 
         self.assert_(isinstance(p, tuple))
@@ -73,9 +73,9 @@
         self.assertRaises(AttributeError, eval, 'p.z', locals())
 
     def test_odd_sizes(self):
-        Zero = named_tuple('Zero', '')
+        Zero = namedtuple('Zero', '')
         self.assertEqual(Zero(), ())
-        Dot = named_tuple('Dot', 'd')
+        Dot = namedtuple('Dot', 'd')
         self.assertEqual(Dot(1), (1,))
 
 def test_main(verbose=None):

Modified: python/branches/ctypes-branch/Lib/test/test_fcntl.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_fcntl.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_fcntl.py	Fri Nov  2 17:45:27 2007
@@ -23,7 +23,7 @@
 if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3',
                     'Darwin1.2', 'darwin',
                     'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
-                    'freebsd6', 'freebsd7',
+                    'freebsd6', 'freebsd7', 'freebsd8',
                     'bsdos2', 'bsdos3', 'bsdos4',
                     'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'):
     if struct.calcsize('l') == 8:

Modified: python/branches/ctypes-branch/Lib/test/test_import.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_import.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_import.py	Fri Nov  2 17:45:27 2007
@@ -1,11 +1,13 @@
-from test.test_support import TESTFN, run_unittest, catch_warning
+from test.test_support import TESTFN, run_unittest, catch_warning
 
 import unittest
 import os
 import random
+import shutil
 import sys
 import py_compile
 import warnings
+from test.test_support import unlink, TESTFN, unload
 
 
 def remove_files(name):
@@ -221,8 +223,29 @@
             warnings.simplefilter('error', ImportWarning)
             self.assertRaises(ImportWarning, __import__, "site-packages")
 
+class PathsTests(unittest.TestCase):
+    path = TESTFN
+
+    def setUp(self):
+        os.mkdir(self.path)
+        self.syspath = sys.path[:]
+
+    def tearDown(self):
+        shutil.rmtree(self.path)
+        sys.path = self.syspath
+
+    # http://bugs.python.org/issue1293
+    def test_trailing_slash(self):
+        f = open(os.path.join(self.path, 'test_trailing_slash.py'), 'w')
+        f.write("testdata = 'test_trailing_slash'")
+        f.close()
+        sys.path.append(self.path+'/')
+        mod = __import__("test_trailing_slash")
+        self.assertEqual(mod.testdata, 'test_trailing_slash')
+        unload("test_trailing_slash")
+
 def test_main(verbose=None):
-    run_unittest(ImportTest)
+    run_unittest(ImportTest, PathsTests)
 
 if __name__ == '__main__':
     test_main()

Modified: python/branches/ctypes-branch/Lib/test/test_socket.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_socket.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_socket.py	Fri Nov  2 17:45:27 2007
@@ -330,7 +330,7 @@
         # I've ordered this by protocols that have both a tcp and udp
         # protocol, at least for modern Linuxes.
         if sys.platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
-                            'freebsd7', 'darwin'):
+                            'freebsd7', 'freebsd8', 'darwin'):
             # avoid the 'echo' service on this platform, as there is an
             # assumption breaking non-standard port/protocol entry
             services = ('daytime', 'qotd', 'domain')

Modified: python/branches/ctypes-branch/Lib/test/test_with.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_with.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_with.py	Fri Nov  2 17:45:27 2007
@@ -440,6 +440,7 @@
         self.assertAfterWithGeneratorInvariantsNoError(self.bar)
 
     def testRaisedStopIteration1(self):
+        # From bug 1462485
         @contextmanager
         def cm():
             yield
@@ -451,6 +452,7 @@
         self.assertRaises(StopIteration, shouldThrow)
 
     def testRaisedStopIteration2(self):
+        # From bug 1462485
         class cm(object):
             def __enter__(self):
                 pass
@@ -463,7 +465,21 @@
 
         self.assertRaises(StopIteration, shouldThrow)
 
+    def testRaisedStopIteration3(self):
+        # Another variant where the exception hasn't been instantiated
+        # From bug 1705170
+        @contextmanager
+        def cm():
+            yield
+
+        def shouldThrow():
+            with cm():
+                raise iter([]).next()
+
+        self.assertRaises(StopIteration, shouldThrow)
+
     def testRaisedGeneratorExit1(self):
+        # From bug 1462485
         @contextmanager
         def cm():
             yield
@@ -475,6 +491,7 @@
         self.assertRaises(GeneratorExit, shouldThrow)
 
     def testRaisedGeneratorExit2(self):
+        # From bug 1462485
         class cm (object):
             def __enter__(self):
                 pass

Modified: python/branches/ctypes-branch/Lib/xml/dom/minidom.py
==============================================================================
--- python/branches/ctypes-branch/Lib/xml/dom/minidom.py	(original)
+++ python/branches/ctypes-branch/Lib/xml/dom/minidom.py	Fri Nov  2 17:45:27 2007
@@ -956,7 +956,7 @@
             dotdotdot = "..."
         else:
             dotdotdot = ""
-        return "<DOM %s node \"%s%s\">" % (
+        return '<DOM %s node "%r%s">' % (
             self.__class__.__name__, data[0:10], dotdotdot)
 
     def substringData(self, offset, count):

Modified: python/branches/ctypes-branch/Misc/NEWS
==============================================================================
--- python/branches/ctypes-branch/Misc/NEWS	(original)
+++ python/branches/ctypes-branch/Misc/NEWS	Fri Nov  2 17:45:27 2007
@@ -12,6 +12,8 @@
 Core and builtins
 -----------------
 
+- optimize the performance of builtin.sum().
+
 - Fix warnings found by the new version of the Coverity checker.
 
 - The enumerate() builtin function is no longer bounded to sequences smaller
@@ -272,11 +274,17 @@
 Library
 -------
 
+- IN module for FreeBSD 8 is added and preexisting FreeBSD 6 and 7
+  files are updated.
+
+- Issues #1181, #1287: unsetenv() is now called when the os.environ.pop()
+  and os.environ.clear() methods are used.
+
 - ctypes will now work correctly on 32-bit systems when Python is
   configured with --with-system-ffi.
 
 - Patch #1203: ctypes now does work on OS X when Python is built with
-  --disable-toolbox-glue
+  --disable-toolbox-glue.
 
 - collections.deque() now supports a "maxlen" argument.
 
@@ -550,7 +558,7 @@
 
 - Added heapq.merge() for merging sorted input streams.
 
-- Added collections.named_tuple() for assigning field names to tuples.
+- Added collections.namedtuple() for assigning field names to tuples.
 
 - Added itertools.izip_longest().
 
@@ -811,10 +819,6 @@
 - Bug #1233: fix bsddb.dbshelve.DBShelf append method to work as
   intended for RECNO databases.
 
-- Fix bsddb.dbtables: Don't randomly corrupt newly inserted rows by
-  picking a rowid string with null bytes in it.  Such rows could not
-  later be deleted, modified or individually selected.
-
 - Bug #1686475: Support stat'ing open files on Windows again.
 
 - Patch #1185447: binascii.b2a_qp() now correctly quotes binary characters
@@ -910,6 +914,8 @@
 
 - Fix libffi configure for hppa*-*-linux* | parisc*-*-linux*.
 
+- Build using system ffi library on arm*-linux*.
+
 
 Tests
 -----

Modified: python/branches/ctypes-branch/Misc/developers.txt
==============================================================================
--- python/branches/ctypes-branch/Misc/developers.txt	(original)
+++ python/branches/ctypes-branch/Misc/developers.txt	Fri Nov  2 17:45:27 2007
@@ -17,6 +17,9 @@
 Permissions History
 -------------------
 
+- Christian Heimes was given SVN access on 31 October 2007 by MvL,
+  for general contributions to Python.
+
 - Chris Monson was given SVN access on 20 October 2007 by NCN,
   for his work on editing PEPs.
 

Modified: python/branches/ctypes-branch/Modules/_bsddb.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_bsddb.c	(original)
+++ python/branches/ctypes-branch/Modules/_bsddb.c	Fri Nov  2 17:45:27 2007
@@ -335,11 +335,13 @@
          * the code check for DB_THREAD and forceably set DBT_MALLOC
          * when we otherwise would leave flags 0 to indicate that.
          */
-        key->data = strdup(PyString_AS_STRING(keyobj));
+        key->data = malloc(PyString_GET_SIZE(keyobj));
         if (key->data == NULL) {
             PyErr_SetString(PyExc_MemoryError, "Key memory allocation failed");
             return 0;
         }
+        memcpy(key->data, PyString_AS_STRING(keyobj),
+               PyString_GET_SIZE(keyobj));
         key->flags = DB_DBT_REALLOC;
         key->size = PyString_GET_SIZE(keyobj);
     }
@@ -5795,6 +5797,10 @@
     ADD_INT(d, DB_NOPANIC);
 #endif
 
+#ifdef DB_REGISTER
+    ADD_INT(d, DB_REGISTER);
+#endif
+
 #if (DBVER >= 42)
     ADD_INT(d, DB_TIME_NOTGRANTED);
     ADD_INT(d, DB_TXN_NOT_DURABLE);

Modified: python/branches/ctypes-branch/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/cfield.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/cfield.c	Fri Nov  2 17:45:27 2007
@@ -1753,11 +1753,13 @@
 
 ffi_type ffi_type_float = { sizeof(float), FLOAT_ALIGN, FFI_TYPE_FLOAT };
 ffi_type ffi_type_double = { sizeof(double), DOUBLE_ALIGN, FFI_TYPE_DOUBLE };
+
+#ifdef ffi_type_longdouble
+#undef ffi_type_longdouble
+#endif
 ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN,
 				 FFI_TYPE_LONGDOUBLE };
 
-/* ffi_type ffi_type_longdouble */
-
 ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER };
 
 /*---------------- EOF ----------------*/

Modified: python/branches/ctypes-branch/Modules/mmapmodule.c
==============================================================================
--- python/branches/ctypes-branch/Modules/mmapmodule.c	(original)
+++ python/branches/ctypes-branch/Modules/mmapmodule.c	Fri Nov  2 17:45:27 2007
@@ -710,7 +710,7 @@
 			return NULL;
 		if (i < 0)
 			i += self->size;
-		if (i < 0 || i > self->size) {
+		if (i < 0 || (size_t)i > self->size) {
 			PyErr_SetString(PyExc_IndexError,
 				"mmap index out of range");
 			return NULL;
@@ -851,7 +851,7 @@
 			return -1;
 		if (i < 0)
 			i += self->size;
-		if (i < 0 || i > self->size) {
+		if (i < 0 || (size_t)i > self->size) {
 			PyErr_SetString(PyExc_IndexError,
 				"mmap index out of range");
 			return -1;

Modified: python/branches/ctypes-branch/Objects/stringobject.c
==============================================================================
--- python/branches/ctypes-branch/Objects/stringobject.c	(original)
+++ python/branches/ctypes-branch/Objects/stringobject.c	Fri Nov  2 17:45:27 2007
@@ -616,16 +616,18 @@
 		case '0': case '1': case '2': case '3':
 		case '4': case '5': case '6': case '7':
 			c = s[-1] - '0';
-			if ('0' <= *s && *s <= '7') {
+			if (s < end && '0' <= *s && *s <= '7') {
 				c = (c<<3) + *s++ - '0';
-				if ('0' <= *s && *s <= '7')
+				if (s < end && '0' <= *s && *s <= '7')
 					c = (c<<3) + *s++ - '0';
 			}
 			*p++ = c;
 			break;
 		case 'x':
-			if (isxdigit(Py_CHARMASK(s[0]))
-			    && isxdigit(Py_CHARMASK(s[1]))) {
+			if (s+1 < end &&
+                            isxdigit(Py_CHARMASK(s[0])) &&
+			    isxdigit(Py_CHARMASK(s[1])))
+                        {
 				unsigned int x = 0;
 				c = Py_CHARMASK(*s);
 				s++;

Modified: python/branches/ctypes-branch/Objects/unicodeobject.c
==============================================================================
--- python/branches/ctypes-branch/Objects/unicodeobject.c	(original)
+++ python/branches/ctypes-branch/Objects/unicodeobject.c	Fri Nov  2 17:45:27 2007
@@ -2081,7 +2081,10 @@
         startinpos = s-starts;
         /* \ - Escapes */
         s++;
-        switch (*s++) {
+        c = *s++;
+        if (s > end)
+            c = '\0'; /* Invalid after \ */
+        switch (c) {
 
         /* \x escapes */
         case '\n': break;
@@ -2100,9 +2103,9 @@
         case '0': case '1': case '2': case '3':
         case '4': case '5': case '6': case '7':
             x = s[-1] - '0';
-            if ('0' <= *s && *s <= '7') {
+            if (s < end && '0' <= *s && *s <= '7') {
                 x = (x<<3) + *s++ - '0';
-                if ('0' <= *s && *s <= '7')
+                if (s < end && '0' <= *s && *s <= '7')
                     x = (x<<3) + *s++ - '0';
             }
             *p++ = x;

Modified: python/branches/ctypes-branch/Python/bltinmodule.c
==============================================================================
--- python/branches/ctypes-branch/Python/bltinmodule.c	(original)
+++ python/branches/ctypes-branch/Python/bltinmodule.c	Fri Nov  2 17:45:27 2007
@@ -2066,6 +2066,84 @@
 		Py_INCREF(result);
 	}
 
+#ifndef SLOW_SUM
+	/* Fast addition by keeping temporary sums in C instead of new Python objects.
+           Assumes all inputs are the same type.  If the assumption fails, default
+           to the more general routine.
+	*/
+	if (PyInt_CheckExact(result)) {
+		long i_result = PyInt_AS_LONG(result);
+		Py_DECREF(result);
+		result = NULL;
+		while(result == NULL) {
+			item = PyIter_Next(iter);
+			if (item == NULL) {
+				Py_DECREF(iter);
+				if (PyErr_Occurred())
+					return NULL;
+    				return PyInt_FromLong(i_result);
+			}
+        		if (PyInt_CheckExact(item)) {
+            			long b = PyInt_AS_LONG(item);
+				long x = i_result + b;
+				if ((x^i_result) >= 0 || (x^b) >= 0) {
+					i_result = x;
+					Py_DECREF(item);
+					continue;
+				}
+			}
+			/* Either overflowed or is not an int. Restore real objects and process normally */
+			result = PyInt_FromLong(i_result);
+			temp = PyNumber_Add(result, item);
+			Py_DECREF(result);
+			Py_DECREF(item);
+			result = temp;
+			if (result == NULL) {
+				Py_DECREF(iter);
+				return NULL;
+			}
+		}
+	}
+
+	if (PyFloat_CheckExact(result)) {
+		double f_result = PyFloat_AS_DOUBLE(result);
+		Py_DECREF(result);
+		result = NULL;
+		while(result == NULL) {
+			item = PyIter_Next(iter);
+			if (item == NULL) {
+				Py_DECREF(iter);
+				if (PyErr_Occurred())
+					return NULL;
+    				return PyFloat_FromDouble(f_result);
+			}
+        		if (PyFloat_CheckExact(item)) {
+				PyFPE_START_PROTECT("add", return 0)
+				f_result += PyFloat_AS_DOUBLE(item);
+				PyFPE_END_PROTECT(f_result)
+				Py_DECREF(item);
+				continue;
+			}
+        		if (PyInt_CheckExact(item)) {
+				PyFPE_START_PROTECT("add", return 0)
+				f_result += (double)PyInt_AS_LONG(item);
+				PyFPE_END_PROTECT(f_result)
+				Py_DECREF(item);
+				continue;
+			}
+			result = PyFloat_FromDouble(f_result);
+			temp = PyNumber_Add(result, item);
+			Py_DECREF(result);
+			Py_DECREF(item);
+			result = temp;
+			if (result == NULL) {
+				Py_DECREF(iter);
+				return NULL;
+			}
+		}
+	}
+#endif
+
 	for(;;) {
 		item = PyIter_Next(iter);
 		if (item == NULL) {

Modified: python/branches/ctypes-branch/configure
==============================================================================
--- python/branches/ctypes-branch/configure	(original)
+++ python/branches/ctypes-branch/configure	Fri Nov  2 17:45:27 2007
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 57904 .
+# From configure.in Revision: 58645 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for python 2.6.
 #
@@ -12812,6 +12812,138 @@
 
 
 # Check for use of the system libffi library
+if test "${ac_cv_header_ffi_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for ffi.h" >&5
+echo $ECHO_N "checking for ffi.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_ffi_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_ffi_h" >&5
+echo "${ECHO_T}$ac_cv_header_ffi_h" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking ffi.h usability" >&5
+echo $ECHO_N "checking ffi.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <ffi.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking ffi.h presence" >&5
+echo $ECHO_N "checking ffi.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ffi.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: ffi.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: ffi.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ffi.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: ffi.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: ffi.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: ffi.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ffi.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: ffi.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ffi.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: ffi.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ffi.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: ffi.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ffi.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: ffi.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ffi.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: ffi.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ------------------------------------------------ ##
+## Report this to http://www.python.org/python-bugs ##
+## ------------------------------------------------ ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for ffi.h" >&5
+echo $ECHO_N "checking for ffi.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_ffi_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_ffi_h=$ac_header_preproc
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_ffi_h" >&5
+echo "${ECHO_T}$ac_cv_header_ffi_h" >&6; }
+
+fi
+
+
 { echo "$as_me:$LINENO: checking for --with-system-ffi" >&5
 echo $ECHO_N "checking for --with-system-ffi... $ECHO_C" >&6; }
 
@@ -12821,8 +12953,11 @@
 fi
 
 
-if test -z "$with_system_ffi"
-then with_system_ffi="no"
+if test -z "$with_system_ffi" && test "$ac_cv_header_ffi_h" = yes; then
+	case "$ac_sys_system/`uname -m`" in
+	Linux/arm*)  with_system_ffi="yes"; CONFIG_ARGS="$CONFIG_ARGS --with-system-ffi";;
+	*) with_system_ffi="no"
+	esac
 fi
 { echo "$as_me:$LINENO: result: $with_system_ffi" >&5
 echo "${ECHO_T}$with_system_ffi" >&6; }

Modified: python/branches/ctypes-branch/configure.in
==============================================================================
--- python/branches/ctypes-branch/configure.in	(original)
+++ python/branches/ctypes-branch/configure.in	Fri Nov  2 17:45:27 2007
@@ -1748,12 +1748,16 @@
 [AC_MSG_RESULT(no)])
 
 # Check for use of the system libffi library
+AC_CHECK_HEADER(ffi.h)
 AC_MSG_CHECKING(for --with-system-ffi)
 AC_ARG_WITH(system_ffi,
             AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
 
-if test -z "$with_system_ffi"
-then with_system_ffi="no"
+if test -z "$with_system_ffi" && test "$ac_cv_header_ffi_h" = yes; then
+	case "$ac_sys_system/`uname -m`" in
+	Linux/arm*)  with_system_ffi="yes"; CONFIG_ARGS="$CONFIG_ARGS --with-system-ffi";;
+	*) with_system_ffi="no"
+	esac
 fi
 AC_MSG_RESULT($with_system_ffi)
 

Modified: python/branches/ctypes-branch/setup.py
==============================================================================
--- python/branches/ctypes-branch/setup.py	(original)
+++ python/branches/ctypes-branch/setup.py	Fri Nov  2 17:45:27 2007
@@ -1159,7 +1159,7 @@
             missing.append('linuxaudiodev')
 
         if platform in ('linux2', 'freebsd4', 'freebsd5', 'freebsd6',
-                        'freebsd7'):
+                        'freebsd7', 'freebsd8'):
             exts.append( Extension('ossaudiodev', ['ossaudiodev.c']) )
         else:
             missing.append('ossaudiodev')


More information about the Python-checkins mailing list