Merged revisions 57778-58052 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r57820 | georg.brandl | 2007-08-31 08:59:27 +0200 (Fri, 31 Aug 2007) | 2 lines

  Document new shorthand notation for index entries.
........
  r57827 | georg.brandl | 2007-08-31 10:47:51 +0200 (Fri, 31 Aug 2007) | 2 lines

  Fix subitem markup.
........
  r57833 | martin.v.loewis | 2007-08-31 12:01:07 +0200 (Fri, 31 Aug 2007) | 1 line

  Mark registry components as 64-bit on Win64.
........
  r57854 | bill.janssen | 2007-08-31 21:02:23 +0200 (Fri, 31 Aug 2007) | 1 line

  deprecate use of FakeSocket
........
  r57855 | bill.janssen | 2007-08-31 21:02:46 +0200 (Fri, 31 Aug 2007) | 1 line

  remove mentions of socket.ssl in comments
........
  r57856 | bill.janssen | 2007-08-31 21:03:31 +0200 (Fri, 31 Aug 2007) | 1 line

  remove use of non-existent SSLFakeSocket in apparently untested code
........
  r57859 | martin.v.loewis | 2007-09-01 08:36:03 +0200 (Sat, 01 Sep 2007) | 3 lines

  Bug #1737210: Change Manufacturer of Windows installer to PSF.
  Will backport to 2.5.
........
  r57865 | georg.brandl | 2007-09-01 09:51:24 +0200 (Sat, 01 Sep 2007) | 2 lines

  Fix RST link (backport from Py3k).
........
  r57876 | georg.brandl | 2007-09-01 17:49:49 +0200 (Sat, 01 Sep 2007) | 2 lines

  Document sets' ">" and "<" operations (backport from py3k).
........
  r57878 | skip.montanaro | 2007-09-01 19:40:03 +0200 (Sat, 01 Sep 2007) | 4 lines

  Added a note and examples to explain that re.split does not split on an
  empty pattern match. (issue 852532).
........
  r57879 | walter.doerwald | 2007-09-01 20:18:09 +0200 (Sat, 01 Sep 2007) | 2 lines

  Fix wrong function names.
........
  r57880 | walter.doerwald | 2007-09-01 20:34:05 +0200 (Sat, 01 Sep 2007) | 2 lines

  Fix typo.
........
  r57889 | andrew.kuchling | 2007-09-01 22:31:59 +0200 (Sat, 01 Sep 2007) | 1 line

  Markup fix
........
  r57892 | andrew.kuchling | 2007-09-01 22:43:36 +0200 (Sat, 01 Sep 2007) | 1 line

  Add various items
........
  r57895 | andrew.kuchling | 2007-09-01 23:17:58 +0200 (Sat, 01 Sep 2007) | 1 line

  Wording change
........
  r57896 | andrew.kuchling | 2007-09-01 23:18:31 +0200 (Sat, 01 Sep 2007) | 1 line

  Add more items
........
  r57904 | ronald.oussoren | 2007-09-02 11:46:07 +0200 (Sun, 02 Sep 2007) | 3 lines

  Macosx: this patch ensures that the value of MACOSX_DEPLOYMENT_TARGET used
  by the Makefile is also used at configure-time.
........
  r57925 | georg.brandl | 2007-09-03 09:16:46 +0200 (Mon, 03 Sep 2007) | 2 lines

  Fix #883466: don't allow Unicode as arguments to quopri and uu codecs.
........
  r57936 | matthias.klose | 2007-09-04 01:33:04 +0200 (Tue, 04 Sep 2007) | 2 lines

  - Added support for linking the bsddb module against BerkeleyDB 4.6.x.
........
  r57954 | mark.summerfield | 2007-09-04 10:16:15 +0200 (Tue, 04 Sep 2007) | 3 lines

  Added cross-references plus a note about dict & list shallow copying.
........
  r57958 | martin.v.loewis | 2007-09-04 11:51:57 +0200 (Tue, 04 Sep 2007) | 3 lines

  Document that we rely on the OS to release the crypto
  context. Fixes #1626801.
........
  r57960 | martin.v.loewis | 2007-09-04 15:13:14 +0200 (Tue, 04 Sep 2007) | 3 lines

  Patch #1388440: Add set_completion_display_matches_hook and
  get_completion_type to readline.
........
  r57961 | martin.v.loewis | 2007-09-04 16:19:28 +0200 (Tue, 04 Sep 2007) | 3 lines

  Patch #1031213: Decode source line in SyntaxErrors back to its original
  source encoding. Will backport to 2.5.
........
  r57972 | matthias.klose | 2007-09-04 20:17:36 +0200 (Tue, 04 Sep 2007) | 3 lines

  - Makefile.pre.in(buildbottest): Run an optional script pybuildbot.identify
    to include some information about the build environment.
........
  r57973 | matthias.klose | 2007-09-04 21:05:38 +0200 (Tue, 04 Sep 2007) | 2 lines

  - Makefile.pre.in(buildbottest): Remove whitespace at eol.
........
  r57975 | matthias.klose | 2007-09-04 22:46:02 +0200 (Tue, 04 Sep 2007) | 2 lines

  - Fix libffi configure for hppa*-*-linux* | parisc*-*-linux*.
........
  r57980 | bill.janssen | 2007-09-05 02:46:27 +0200 (Wed, 05 Sep 2007) | 1 line

  SSL certificate distinguished names should be represented by tuples
........
  r57985 | martin.v.loewis | 2007-09-05 08:39:17 +0200 (Wed, 05 Sep 2007) | 3 lines

  Patch #1105: Explain that one needs to build the solution
  to get dependencies right.
........
  r57987 | armin.rigo | 2007-09-05 09:51:21 +0200 (Wed, 05 Sep 2007) | 4 lines

  PyDict_GetItem() returns a borrowed reference.
  There are probably a number of places that are open to attacks
  such as the following one, in bltinmodule.c:min_max().
........
  r57991 | martin.v.loewis | 2007-09-05 13:47:34 +0200 (Wed, 05 Sep 2007) | 3 lines

  Patch #786737: Allow building in a tree of symlinks pointing to
  a readonly source.
........
  r57993 | georg.brandl | 2007-09-05 15:36:44 +0200 (Wed, 05 Sep 2007) | 2 lines

  Backport from Py3k: Bug #1684991: explain lookup semantics for __special__ methods (new-style classes only).
........
  r58004 | armin.rigo | 2007-09-06 10:30:51 +0200 (Thu, 06 Sep 2007) | 4 lines

  Patch #1733973 by peaker:
  ptrace_enter_call() assumes no exception is currently set.
  This assumption is broken when throwing into a generator.
........
  r58006 | armin.rigo | 2007-09-06 11:30:38 +0200 (Thu, 06 Sep 2007) | 4 lines

  PyDict_GetItem() returns a borrowed reference.
  This attack is against ceval.c:IMPORT_NAME, which calls an
  object (__builtin__.__import__) without holding a reference to it.
........
  r58013 | georg.brandl | 2007-09-06 16:49:56 +0200 (Thu, 06 Sep 2007) | 2 lines

  Backport from 3k: #1116: fix reference to old filename.
........
  r58021 | thomas.heller | 2007-09-06 22:26:20 +0200 (Thu, 06 Sep 2007) | 1 line

  Fix typo:  c_float represents to C float type.
........
  r58022 | skip.montanaro | 2007-09-07 00:29:06 +0200 (Fri, 07 Sep 2007) | 3 lines

  If this is correct for py3k branch and it's already in the release25-maint
  branch, seems like it ought to be on the trunk as well.
........
  r58023 | gregory.p.smith | 2007-09-07 00:59:59 +0200 (Fri, 07 Sep 2007) | 4 lines

  Apply the fix from Issue1112 to make this test more robust and keep
  windows happy.
........
  r58031 | brett.cannon | 2007-09-07 05:17:50 +0200 (Fri, 07 Sep 2007) | 4 lines

  Make uuid1 and uuid4 tests conditional on whether ctypes can be imported;
  implementation of either function depends on ctypes but uuid as a whole does
  not.
........
  r58032 | brett.cannon | 2007-09-07 06:18:30 +0200 (Fri, 07 Sep 2007) | 6 lines

  Fix a crasher where Python code managed to infinitely recurse in C code without
  ever going back out to Python code in PyObject_Call().  Required introducing a
  static RuntimeError instance so that normalizing an exception there is no
  reliance on a recursive call that would put the exception system over the
  recursion check itself.
........
  r58034 | thomas.heller | 2007-09-07 08:32:17 +0200 (Fri, 07 Sep 2007) | 1 line

  Add a 'c_longdouble' type to the ctypes module.
........
  r58035 | thomas.heller | 2007-09-07 11:30:40 +0200 (Fri, 07 Sep 2007) | 1 line

  Remove unneeded #include.
........
  r58036 | thomas.heller | 2007-09-07 11:33:24 +0200 (Fri, 07 Sep 2007) | 6 lines

  Backport from py3k branch:

  Add a workaround for a strange bug on win64, when _ctypes is compiled
  with the SDK compiler.  This should fix the failing
  Lib\ctypes\test\test_as_parameter.py test.
........
  r58037 | georg.brandl | 2007-09-07 16:14:40 +0200 (Fri, 07 Sep 2007) | 2 lines

  Fix a wrong indentation for sublists.
........
  r58043 | georg.brandl | 2007-09-07 22:10:49 +0200 (Fri, 07 Sep 2007) | 2 lines

  #1095: ln -f doesn't work portably, fix in Makefile.
........
  r58049 | skip.montanaro | 2007-09-08 02:34:17 +0200 (Sat, 08 Sep 2007) | 1 line

  be explicit about the actual location of the missing file
........
diff --git a/Doc/documenting/markup.rst b/Doc/documenting/markup.rst
index 1bb2185..f85158b 100644
--- a/Doc/documenting/markup.rst
+++ b/Doc/documenting/markup.rst
@@ -707,7 +707,7 @@
 For example::
 
    .. index::
-      single: execution!context
+      single: execution; context
       module: __main__
       module: sys
       triple: module; search; path
@@ -720,8 +720,8 @@
 
 single
    Creates a single index entry.  Can be made a subentry by separating the
-   subentry text with a semicolon (this is also used below to describe what
-   entries are created).
+   subentry text with a semicolon (this notation is also used below to describe
+   what entries are created).
 pair
    ``pair: loop; statement`` is a shortcut that creates two index entries,
    namely ``loop; statement`` and ``statement; loop``.
@@ -733,6 +733,13 @@
    These all create two index entries.  For example, ``module: hashlib`` creates
    the entries ``module; hashlib`` and ``hashlib; module``.
 
+For index directives containing only "single" entries, there is a shorthand
+notation::
+
+   .. index:: BNF, grammar, syntax, notation
+
+This creates four index entries.
+
 
 Grammar production displays
 ---------------------------
diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst
index f35ef76..238c80e 100644
--- a/Doc/library/codecs.rst
+++ b/Doc/library/codecs.rst
@@ -186,12 +186,12 @@
    Implements the ``ignore`` error handling.
 
 
-.. function:: xmlcharrefreplace_errors_errors(exception)
+.. function:: xmlcharrefreplace_errors(exception)
 
    Implements the ``xmlcharrefreplace`` error handling.
 
 
-.. function:: backslashreplace_errors_errors(exception)
+.. function:: backslashreplace_errors(exception)
 
    Implements the ``backslashreplace`` error handling.
 
@@ -833,7 +833,7 @@
 encoding was used for encoding a Unicode string. Each charmap encoding can
 decode any random byte sequence. However that's not possible with UTF-8, as
 UTF-8 byte sequences have a structure that doesn't allow arbitrary byte
-sequence. To increase the reliability with which a UTF-8 encoding can be
+sequences. To increase the reliability with which a UTF-8 encoding can be
 detected, Microsoft invented a variant of UTF-8 (that Python 2.5 calls
 ``"utf-8-sig"``) for its Notepad program: Before any of the Unicode characters
 is written to the file, a UTF-8 encoded BOM (which looks like this as a byte
diff --git a/Doc/library/copy.rst b/Doc/library/copy.rst
index ea59613..0abee4d 100644
--- a/Doc/library/copy.rst
+++ b/Doc/library/copy.rst
@@ -54,6 +54,10 @@
 classes (shallow and deeply), by returning the original object unchanged; this
 is compatible with the way these are treated by the :mod:`pickle` module.
 
+Shallow copies of dictionaries can be made using :meth:`dict.copy`, and
+of lists by assigning a slice of the entire list, for example,
+``copied_list = original_list[:]``.
+
 .. index:: module: pickle
 
 Classes can use the same interfaces to control copying that they use to control
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index e9acedf..4b1934d 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -247,6 +247,8 @@
    +----------------------+--------------------------------+----------------------------+
    | :class:`c_double`    | ``double``                     | float                      |
    +----------------------+--------------------------------+----------------------------+
+   | :class:`c_longdouble`| ``long double``                | float                      |
+   +----------------------+--------------------------------+----------------------------+
    | :class:`c_char_p`    | ``char *`` (NUL terminated)    | string or ``None``         |
    +----------------------+--------------------------------+----------------------------+
    | :class:`c_wchar_p`   | ``wchar_t *`` (NUL terminated) | unicode or ``None``        |
@@ -2065,9 +2067,16 @@
    initializer.
 
 
+.. class:: c_longdouble
+
+   Represents the C long double datatype. The constructor accepts an
+   optional float initializer.  On platforms where ``sizeof(long
+   double) == sizeof(double)`` it is an alias to :class:`c_double`.
+
+
 .. class:: c_float
 
-   Represents the C double datatype. The constructor accepts an optional float
+   Represents the C float datatype. The constructor accepts an optional float
    initializer.
 
 
diff --git a/Doc/library/mutex.rst b/Doc/library/mutex.rst
index 523692f..151f0c1 100644
--- a/Doc/library/mutex.rst
+++ b/Doc/library/mutex.rst
@@ -8,8 +8,9 @@
 
 
 The :mod:`mutex` module defines a class that allows mutual-exclusion via
-acquiring and releasing locks. It does not require (or imply) threading or
-multi-tasking, though it could be useful for those purposes.
+acquiring and releasing locks. It does not require (or imply)
+:mod:`threading` or multi-tasking, though it could be useful for those
+purposes.
 
 The :mod:`mutex` module defines the following class:
 
diff --git a/Doc/library/queue.rst b/Doc/library/queue.rst
index c183860..e9da905 100644
--- a/Doc/library/queue.rst
+++ b/Doc/library/queue.rst
@@ -7,10 +7,11 @@
 
 
 The :mod:`Queue` module implements a multi-producer, multi-consumer FIFO queue.
-It is especially useful in threads programming when information must be
+It is especially useful in threaded programming when information must be
 exchanged safely between multiple threads.  The :class:`Queue` class in this
 module implements all the required locking semantics.  It depends on the
-availability of thread support in Python.
+availability of thread support in Python; see the :mod:`threading`
+module.
 
 The :mod:`Queue` module defines the following class and exception:
 
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index fef6d2d..a3d3dea 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -546,6 +546,13 @@
       >>> re.split('\W+', 'Words, words, words.', 1)
       ['Words', 'words, words.']
 
+   Note that *split* will never split a string on an empty pattern match.
+   For example ::
+
+      >>> re.split('x*', 'foo')
+      ['foo']
+      >>> re.split("(?m)^$", "foo\n\nbar\n")
+      ['foo\n\nbar\n']
 
 .. function:: findall(pattern, string[, flags])
 
diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst
index 7727c3b..7e6eccf 100644
--- a/Doc/library/readline.rst
+++ b/Doc/library/readline.rst
@@ -128,6 +128,12 @@
    Get the completer function, or ``None`` if no completer function has been set.
 
 
+.. function:: get_completion_type()
+
+   Get the type of completion being attempted.
+
+   .. versionadded:: 2.6
+
 .. function:: get_begidx()
 
    Get the beginning index of the readline tab-completion scope.
@@ -147,6 +153,16 @@
 
    Get the readline word delimiters for tab-completion.
 
+.. function:: set_completion_display_matches_hook([function])
+
+   Set or remove the completion display function.  If *function* is
+   specified, it will be used as the new completion display function;
+   if omitted or ``None``, any completion display function already
+   installed is removed.  The completion display function is called as
+   ``function(substitution, [matches], longest_match_length)`` once
+   each time matches need to be displayed.
+
+   .. versionadded:: 2.6
 
 .. function:: add_history(line)
 
diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst
index 3173f35..286a725 100644
--- a/Doc/library/smtplib.rst
+++ b/Doc/library/smtplib.rst
@@ -47,7 +47,7 @@
 .. class:: LMTP([host[, port[, local_hostname]]])
 
    The LMTP protocol, which is very similar to ESMTP, is heavily based on the
-   standard SMTP client. It's common to use Unix sockets for LMTP, so our connect()
+   standard SMTP client. It's common to use Unix sockets for LMTP, so our :meth:`connect`
    method must support that as well as a regular host:port server. To specify a
    Unix socket, you must use an absolute path for *host*, starting with a '/'.
 
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index a445b54..758cfb1 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -165,7 +165,7 @@
 .. function:: create_connection(address[, timeout])
 
    Connects to the *address* received (as usual, a ``(host, port)`` pair), with an
-   optional timeout for the connection.  Specially useful for higher-level
+   optional timeout for the connection.  Especially useful for higher-level
    protocols, it is not normally used directly from application-level code.
    Passing the optional *timeout* parameter will set the timeout on the socket
    instance (if it is not given or ``None``, the global default timeout setting is
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst
index 5072caf..852a905 100644
--- a/Doc/library/ssl.rst
+++ b/Doc/library/ssl.rst
@@ -170,6 +170,8 @@
 Some "standard" root certificates are available at
 http://www.thawte.com/roots/  (for Thawte roots) and
 http://www.verisign.com/support/roots.html  (for Verisign roots).
+See also :rfc:`4158` for more discussion of the way in which 
+certification chains can be built.
 
 
 sslsocket Objects
@@ -239,23 +241,23 @@
    the certificate), ``notBefore`` (the time before which the certificate should not be trusted),
    and ``notAfter`` (the time after which the certificate should not be trusted) filled in.
 
-   The "subject" and "issuer" fields are themselves dictionaries containing the fields given
-   in the certificate's data structure for each principal::
+   The "subject" and "issuer" fields are tuples containing the name-value fields
+   given in the certificate's data structure for each principal::
 
-      {'issuer': {'commonName': u'somemachine.python.org',
-                  'countryName': u'US',
-                  'localityName': u'Wilmington',
-                  'organizationName': u'Python Software Foundation',
-                  'organizationalUnitName': u'SSL',
-                  'stateOrProvinceName': u'Delaware'},
-       'subject': {'commonName': u'somemachine.python.org',
-                   'countryName': u'US',
-                   'localityName': u'Wilmington',
-                   'organizationName': u'Python Software Foundation',
-                   'organizationalUnitName': u'SSL',
-                   'stateOrProvinceName': u'Delaware'},
-       'notAfter': 'Sep  4 21:54:26 2007 GMT',
-       'notBefore': 'Aug 25 21:54:26 2007 GMT',
+      {'issuer': (('countryName', u'US'),
+                  ('stateOrProvinceName', u'Delaware'),
+                  ('localityName', u'Wilmington'),
+                  ('organizationName', u'Python Software Foundation'),
+                  ('organizationalUnitName', u'SSL'),
+                  ('commonName', u'somemachine.python.org')),
+       'notAfter': 'Feb 16 16:54:50 2013 GMT',
+       'notBefore': 'Aug 27 16:54:50 2007 GMT',
+       'subject': (('countryName', u'US'),
+                   ('stateOrProvinceName', u'Delaware'),
+                   ('localityName', u'Wilmington'),
+                   ('organizationName', u'Python Software Foundation'),
+                   ('organizationalUnitName', u'SSL'),
+                   ('commonName', u'somemachine.python.org')),
        'version': 2}
 
    This certificate is said to be *self-signed*, because the subject
@@ -311,27 +313,32 @@
    # note that closing the sslsocket will also close the underlying socket
    ssl_sock.close()
 
-As of August 25, 2007, the certificate printed by this program
+As of September 4, 2007, the certificate printed by this program
 looked like this::
 
-   {'issuer': {'commonName': u'VeriSign Class 3 Extended Validation SSL SGC CA',
-               'countryName': u'US',
-               'organizationName': u'VeriSign, Inc.',
-               'organizationalUnitName': u'Terms of use at https://www.verisign.com/rpa (c)06'},
-    'subject': {'1.3.6.1.4.1.311.60.2.1.2': u'Delaware',
-                '1.3.6.1.4.1.311.60.2.1.3': u'US',
-                'commonName': u'www.verisign.com',
-                'countryName': u'US',
-                'localityName': u'Mountain View',
-                'organizationName': u'VeriSign, Inc.',
-                'organizationalUnitName': u'Terms of use at www.verisign.com/rpa (c)06',
-                'postalCode': u'94043',
-                'serialNumber': u'2497886',
-                'stateOrProvinceName': u'California',
-                'streetAddress': u'487 East Middlefield Road'},
-    'notAfter': 'May  8 23:59:59 2009 GMT',
-    'notBefore': 'May  9 00:00:00 2007 GMT',
-    'version': 2}
+  {'issuer': (('countryName', u'US'),
+              ('organizationName', u'VeriSign, Inc.'),
+              ('organizationalUnitName', u'VeriSign Trust Network'),
+              ('organizationalUnitName',
+               u'Terms of use at https://www.verisign.com/rpa (c)06'),
+              ('commonName',
+               u'VeriSign Class 3 Extended Validation SSL SGC CA')),
+   'notAfter': 'May  8 23:59:59 2009 GMT',
+   'notBefore': 'May  9 00:00:00 2007 GMT',
+   'subject': (('serialNumber', u'2497886'),
+               ('1.3.6.1.4.1.311.60.2.1.3', u'US'),
+               ('1.3.6.1.4.1.311.60.2.1.2', u'Delaware'),
+               ('countryName', u'US'),
+               ('postalCode', u'94043'),
+               ('stateOrProvinceName', u'California'),
+               ('localityName', u'Mountain View'),
+               ('streetAddress', u'487 East Middlefield Road'),
+               ('organizationName', u'VeriSign, Inc.'),
+               ('organizationalUnitName', u'Production Security Services'),
+               ('organizationalUnitName',
+                u'Terms of use at www.verisign.com/rpa (c)06'),
+               ('commonName', u'www.verisign.com')),
+   'version': 2}
 
 Server-side operation
 ^^^^^^^^^^^^^^^^^^^^^
@@ -383,3 +390,5 @@
 `Introducing SSL and Certificates using OpenSSL <http://old.pseudonym.org/ssl/wwwj-index.html>`_, by Frederick J. Hirsch
 
 `Privacy Enhancement for Internet Electronic Mail: Part II: Certificate-Based Key Management`, :rfc:`1422`, by Steve Kent
+
+`Internet X.509 Public Key Infrastructure Certificate and CRL Profile`, :rfc:`3280`, Housley et. al.
diff --git a/Doc/library/thread.rst b/Doc/library/thread.rst
index 32437dc..6c59954 100644
--- a/Doc/library/thread.rst
+++ b/Doc/library/thread.rst
@@ -13,9 +13,11 @@
    single: semaphores, binary
 
 This module provides low-level primitives for working with multiple threads
-(a.k.a. :dfn:`light-weight processes` or :dfn:`tasks`) --- multiple threads of
+(also called :dfn:`light-weight processes` or :dfn:`tasks`) --- multiple threads of
 control sharing their global data space.  For synchronization, simple locks
-(a.k.a. :dfn:`mutexes` or :dfn:`binary semaphores`) are provided.
+(also called :dfn:`mutexes` or :dfn:`binary semaphores`) are provided.
+The :mod:`threading` module provides an easier to use and higher-level
+threading API built on top of this module.
 
 .. index::
    single: pthreads
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index 828d42b..1b82e4b 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -8,6 +8,7 @@
 
 This module constructs higher-level threading interfaces on top of the  lower
 level :mod:`thread` module.
+See also the :mod:`mutex` and :mod:`Queue` modules.
 
 The :mod:`dummy_threading` module is provided for situations where
 :mod:`threading` cannot be used because :mod:`thread` is missing.
diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst
index b0e731a..dd537d3 100644
--- a/Doc/whatsnew/2.6.rst
+++ b/Doc/whatsnew/2.6.rst
@@ -73,6 +73,20 @@
 
 Here are all of the changes that Python 2.6 makes to the core Python language.
 
+* The :func:`complex` constructor now accepts strings containing 
+  parenthesized complex numbers, letting ``complex(repr(cmplx))``
+  will now round-trip values.  For example, ``complex('(3+4j)')``
+  now returns the value (3+4j).
+
+  .. % Patch 1491866
+
+* The string :meth:`translate` method now accepts ``None`` as the 
+  translation table parameter, which is treated as the identity 
+  transformation.   This makes it easier to carry out operations
+  that only delete characters.  (Contributed by Bengt Richter.)
+
+  .. % Patch 1193128
+
 * An obscure change: when you use the the :func:`locals` function inside a
   :keyword:`class` statement, the resulting dictionary no longer returns free
   variables.  (Free variables, in this case, are variables referred to in the
@@ -124,6 +138,11 @@
 
   (Contributed by Fabian Kreutz.)
 
+* An optional ``timeout`` parameter was added to the
+  :class:`ftplib.FTP` class constructor as well as the :meth:`connect`
+  method, specifying a timeout measured in seconds.  (Added by Facundo
+  Batista.)
+
 * The :func:`glob.glob` function can now return Unicode filenames if 
   a Unicode path was used and Unicode filenames are matched within the directory.
 
@@ -157,6 +176,21 @@
 
   .. % Patch #1490190
 
+* In the :mod:`os.path` module, the :func:`splitext` function
+  has been changed to not split on leading period characters.
+  This produces better results when operating on Unix's dot-files.
+  For example, ``os.path.splitext('.ipython')``
+  now returns ``('.ipython', '')`` instead of ``('', '.ipython')``.
+
+  .. % Bug #115886
+
+  A new function, :func:`relpath(path, start)` returns a relative path
+  from the ``start`` path, if it's supplied, or from the current
+  working directory to the destination ``path``.  (Contributed by
+  Richard Barran.)
+
+  .. % Patch 1339796
+
 * New functions in the :mod:`posix` module: :func:`chflags` and :func:`lchflags`
   are wrappers for the corresponding system calls (where they're available).
   Constants for the flag values are defined in the :mod:`stat` module; some
@@ -166,14 +200,41 @@
 
 * The :mod:`rgbimg` module has been removed.
 
-* The :mod:`smtplib` module now supports SMTP over  SSL thanks to the addition
-  of the :class:`SMTP_SSL` class. This class supports an interface identical to
-  the existing :class:`SMTP`  class. (Contributed by Monty Taylor.)
+* The :mod:`smtplib` module now supports SMTP over SSL thanks to the
+  addition of the :class:`SMTP_SSL` class. This class supports an
+  interface identical to the existing :class:`SMTP` class.   Both 
+  class constructors also have an optional ``timeout`` parameter
+  that specifies a timeout for the initial connection attempt, measured in
+  seconds.
+
+  An implementation of the LMTP protocol (:rfc:`2033`) was also added to
+  the module.  LMTP is used in place of SMTP when transferring e-mail
+  between agents that don't manage a mail queue.
+
+  (SMTP over SSL contributed by Monty Taylor; timeout parameter
+  added by Facundo Batista; LMTP implemented by Leif
+  Hedstrom.)
+
+  .. % Patch #957003
+
+* An optional ``timeout`` parameter was added to the
+  :class:`telnetlib.Telnet` class constructor, specifying a timeout
+  measured in seconds.  (Added by Facundo Batista.)
 
 * The :mod:`test.test_support` module now contains a :func:`EnvironmentVarGuard`
   context manager that  supports temporarily changing environment variables and
   automatically restores them to their old values. (Contributed by Brett Cannon.)
 
+* The :mod:`timeit` module now accepts callables as well as strings 
+  for the statement being timed and for the setup code.
+  Two convenience functions were added for creating 
+  :class:`Timer` instances: 
+  ``repeat(stmt, setup, time, repeat, number)`` and 
+  ``timeit(stmt, setup, time, number)`` create an instance and call
+  the corresponding method. (Contributed by Erik Demaine.)
+
+  .. % Patch #1533909
+
 .. % ======================================================================
 .. % whole new modules get described in \subsections here
 
diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index 1e1cf5b..6e2f5cf 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -153,6 +153,7 @@
 #endif
 
 PyAPI_DATA(PyObject *) PyExc_MemoryErrorInst;
+PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst;
 
 /* Predefined warning categories */
 PyAPI_DATA(PyObject *) PyExc_Warning;
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index f55d194..c413127 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -188,6 +188,11 @@
     _type_ = "d"
 _check_size(c_double)
 
+class c_longdouble(_SimpleCData):
+    _type_ = "D"
+if sizeof(c_longdouble) == sizeof(c_double):
+    c_longdouble = c_double
+
 if _calcsize("l") == _calcsize("q"):
     # if long and long long have the same size, make c_longlong an alias for c_long
     c_longlong = c_long
diff --git a/Lib/ctypes/test/test_arrays.py b/Lib/ctypes/test/test_arrays.py
index f487013..f8bce5a 100644
--- a/Lib/ctypes/test/test_arrays.py
+++ b/Lib/ctypes/test/test_arrays.py
@@ -4,7 +4,7 @@
 formats = "bBhHiIlLqQfd"
 
 formats = c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, \
-          c_long, c_ulonglong, c_float, c_double
+          c_long, c_ulonglong, c_float, c_double, c_longdouble
 
 class ArrayTestCase(unittest.TestCase):
     def test_simple(self):
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
index 9b2ea8c..d870eb4 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -77,6 +77,10 @@
         self.check_type(c_double, 3.14)
         self.check_type(c_double, -3.14)
 
+    def test_longdouble(self):
+        self.check_type(c_longdouble, 3.14)
+        self.check_type(c_longdouble, -3.14)
+
     def test_char(self):
         self.check_type(c_char, b"x")
         self.check_type(c_char, b"a")
diff --git a/Lib/ctypes/test/test_cfuncs.py b/Lib/ctypes/test/test_cfuncs.py
index 63564a8..8f97fc4 100644
--- a/Lib/ctypes/test/test_cfuncs.py
+++ b/Lib/ctypes/test/test_cfuncs.py
@@ -158,6 +158,18 @@
         self.failUnlessEqual(self._dll.tf_bd(0, 42.), 14.)
         self.failUnlessEqual(self.S(), 42)
 
+    def test_longdouble(self):
+        self._dll.tf_D.restype = c_longdouble
+        self._dll.tf_D.argtypes = (c_longdouble,)
+        self.failUnlessEqual(self._dll.tf_D(42.), 14.)
+        self.failUnlessEqual(self.S(), 42)
+
+    def test_longdouble_plus(self):
+        self._dll.tf_bD.restype = c_longdouble
+        self._dll.tf_bD.argtypes = (c_byte, c_longdouble)
+        self.failUnlessEqual(self._dll.tf_bD(0, 42.), 14.)
+        self.failUnlessEqual(self.S(), 42)
+
     def test_callwithresult(self):
         def process_result(result):
             return result * 2
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
index d7a3edf..3af11cc 100644
--- a/Lib/ctypes/test/test_functions.py
+++ b/Lib/ctypes/test/test_functions.py
@@ -143,6 +143,18 @@
         self.failUnlessEqual(result, -21)
         self.failUnlessEqual(type(result), float)
 
+    def test_longdoubleresult(self):
+        f = dll._testfunc_D_bhilfD
+        f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_longdouble]
+        f.restype = c_longdouble
+        result = f(1, 2, 3, 4, 5.0, 6.0)
+        self.failUnlessEqual(result, 21)
+        self.failUnlessEqual(type(result), float)
+
+        result = f(-1, -2, -3, -4, -5.0, -6.0)
+        self.failUnlessEqual(result, -21)
+        self.failUnlessEqual(type(result), float)
+
     def test_longlongresult(self):
         try:
             c_longlong
diff --git a/Lib/ctypes/test/test_repr.py b/Lib/ctypes/test/test_repr.py
index 8e69444..3f1e819 100644
--- a/Lib/ctypes/test/test_repr.py
+++ b/Lib/ctypes/test/test_repr.py
@@ -4,7 +4,7 @@
 subclasses = []
 for base in [c_byte, c_short, c_int, c_long, c_longlong,
         c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong,
-        c_float, c_double, c_bool]:
+        c_float, c_double, c_longdouble, c_bool]:
     class X(base):
         pass
     subclasses.append(X)
diff --git a/Lib/distutils/dep_util.py b/Lib/distutils/dep_util.py
index a9d589a..07b3549 100644
--- a/Lib/distutils/dep_util.py
+++ b/Lib/distutils/dep_util.py
@@ -17,7 +17,8 @@
     Raise DistutilsFileError if 'source' does not exist.
     """
     if not os.path.exists(source):
-        raise DistutilsFileError("file '%s' does not exist" % source)
+        raise DistutilsFileError("file '%s' does not exist" %
+                                 os.path.abspath(source))
     if not os.path.exists(target):
         return 1
 
diff --git a/Lib/httplib.py b/Lib/httplib.py
index a6ac4e3..3a83018 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -71,6 +71,7 @@
 import mimetools
 import socket
 from urlparse import urlsplit
+import warnings
 
 __all__ = ["HTTPResponse", "HTTPConnection",
            "HTTPException", "NotConnected", "UnknownProtocol",
@@ -988,6 +989,9 @@
 
 
     def FakeSocket (sock, sslobj):
+        warnings.warn("FakeSocket is deprecated, and won't be in 3.x.  " +
+                      "Use the result of ssl.sslsocket directly instead.",
+                      DeprecationWarning, stacklevel=2)
         return sslobj
 
     __all__.append("HTTPSConnection")
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index 0a97372..78d17f8 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -1165,7 +1165,6 @@
 
         def readline(self):
             """Read line from remote."""
-            # NB: socket.ssl needs a "readline" method, or perhaps a "makefile" method.
             line = []
             while 1:
                 char = self.sslobj.read(1)
@@ -1175,7 +1174,6 @@
 
         def send(self, data):
             """Send data to remote."""
-            # NB: socket.ssl needs a "sendall" method to match socket objects.
             bytes = len(data)
             while bytes > 0:
                 sent = self.sslobj.write(data)
@@ -1201,7 +1199,7 @@
         def ssl(self):
             """Return SSLObject instance used to communicate with the IMAP4 server.
 
-            ssl = <instance>.socket.ssl()
+            ssl = ssl.sslsocket(<instance>.socket)
             """
             return self.sslobj
 
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 7423ae0..5e4ebe8 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -161,7 +161,6 @@
 except ImportError:
     _have_ssl = False
 else:
-
     class SSLFakeFile:
         """A fake file like object that really wraps a SSLObject.
 
@@ -722,9 +721,8 @@
         def _get_socket(self, host, port, timeout):
             if self.debuglevel > 0: print('connect:', (host, port), file=stderr)
             self.sock = socket.create_connection((host, port), timeout)
-            sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)
-            self.sock = SSLFakeSocket(self.sock, sslobj)
-            self.file = SSLFakeFile(sslobj)
+            self.sock = ssl.sslsocket(self.sock, self.keyfile, self.certfile)
+            self.file = SSLFakeFile(self.sock)
 
     __all__.append("SMTP_SSL")
 
diff --git a/Lib/test/crashers/infinite_rec_1.py b/Lib/test/crashers/infinite_rec_1.py
deleted file mode 100644
index 573a509..0000000
--- a/Lib/test/crashers/infinite_rec_1.py
+++ /dev/null
@@ -1,11 +0,0 @@
-
-# http://python.org/sf/1202533
-
-import new, operator
-
-class A:
-    pass
-A.__mul__ = new.instancemethod(operator.mul, None, A)
-
-if __name__ == '__main__':
-    A()*2   # segfault: infinite recursion in C
diff --git a/Lib/test/crashers/infinite_rec_2.py b/Lib/test/crashers/infinite_rec_2.py
deleted file mode 100644
index 5a14b33..0000000
--- a/Lib/test/crashers/infinite_rec_2.py
+++ /dev/null
@@ -1,10 +0,0 @@
-
-# http://python.org/sf/1202533
-
-class A(str):
-    __get__ = getattr
-
-if __name__ == '__main__':
-    a = A('a')
-    A.a = a
-    a.a   # segfault: infinite recursion in C
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index bfa6a64..12bec1a 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4,6 +4,7 @@
 from test.test_support import get_original_stdout
 from copy import deepcopy
 import types
+import new
 
 def veris(a, b):
     if a is not b:
@@ -1834,6 +1835,10 @@
 ##     unsafecmp(1, 1L)
 ##     unsafecmp(1L, 1)
 
+def recursions():
+    if verbose:
+        print("Testing recursion checks ...")
+
 ##     class Letter(str):
 ##         def __new__(cls, letter):
 ##             if letter == 'EPS':
@@ -1843,7 +1848,6 @@
 ##             if not self:
 ##                 return 'EPS'
 ##             return self
-
 ##     # sys.stdout needs to be the original to trigger the recursion bug
 ##     import sys
 ##     test_stdout = sys.stdout
@@ -1857,6 +1861,17 @@
 ##         raise TestFailed, "expected a RuntimeError for print recursion"
 ##     sys.stdout = test_stdout
 
+    # Bug #1202533.
+    class A(object):
+        pass
+    A.__mul__ = new.instancemethod(lambda self, x: self * x, None, A)
+    try:
+        A()*2
+    except RuntimeError:
+        pass
+    else:
+        raise TestFailed("expected a RuntimeError")
+
 def weakrefs():
     if verbose: print("Testing weak references...")
     import weakref
@@ -4153,6 +4168,7 @@
     overloading()
     methods()
     specials()
+    recursions()
     weakrefs()
     properties()
     supers()
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 35c6af9..04daab2 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -137,18 +137,15 @@
                 cert = c2.getpeercert()
                 if not cert:
                     raise test_support.TestFailed("Can't get peer certificate.")
+                if test_support.verbose:
+                    sys.stdout.write(pprint.pformat(cert) + '\n')
                 if not cert.has_key('subject'):
                     raise test_support.TestFailed(
                         "No subject field in certificate: %s." %
                         pprint.pformat(cert))
-                if not (cert['subject'].has_key('organizationName')):
+                if not ('organizationName', 'Python Software Foundation') in cert['subject']:
                     raise test_support.TestFailed(
-                        "No 'organizationName' field in certificate subject: %s." %
-                        pprint.pformat(cert))
-                if (cert['subject']['organizationName'] !=
-                      "Python Software Foundation"):
-                    raise test_support.TestFailed(
-                        "Invalid 'organizationName' field in certificate subject; "
+                        "Missing or invalid 'organizationName' field in certificate subject; "
                         "should be 'Python Software Foundation'.");
                 c2.close()
 
@@ -336,7 +333,7 @@
 
 def test_main(verbose=False):
     if skip_expected:
-        raise test_support.TestSkipped("socket module has no ssl support")
+        raise test_support.TestSkipped("No SSL support")
 
     global CERTFILE
     CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py
index 5ccdcb1..92d6294 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -364,6 +364,12 @@
         self.assertEqual(node1, node2)
 
     def test_uuid1(self):
+        # uuid1 requires ctypes.
+        try:
+            import ctypes
+        except ImportError:
+            return
+
         equal = self.assertEqual
 
         # Make sure uuid1() generates UUIDs that are actually version 1.
@@ -417,6 +423,12 @@
             equal(str(u), v)
 
     def test_uuid4(self):
+        # uuid4 requires ctypes.
+        try:
+            import ctypes
+        except ImportError:
+            return
+
         equal = self.assertEqual
 
         # Make sure uuid4() generates UUIDs that are actually version 4.
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 1942f88..aa280c0 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -61,7 +61,7 @@
 # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
 # be able to build extension modules using the directories specified in the
 # environment variables
-CPPFLAGS=	-I. -I$(srcdir)/Include @CPPFLAGS@
+CPPFLAGS=	-I. -IInclude -I$(srcdir)/Include @CPPFLAGS@
 LDFLAGS=	@LDFLAGS@
 LDLAST=		@LDLAST@
 SGI_ABI=	@SGI_ABI@
@@ -473,6 +473,7 @@
 
 
 $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
+		-@ mkdir Include
 		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
 
 $(PGEN):	$(PGENOBJS)
@@ -619,7 +620,11 @@
 
 
 # Like testall, but with a single pass only
+# run an optional script to include some information about the build environment
 buildbottest:	all platform
+		-@if which pybuildbot.identify >/dev/null 2>&1; then \
+			pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
+		fi
 		$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall -rw
 
 QUICKTESTOPTS=	$(TESTOPTS) -x test_thread test_signal test_strftime \
@@ -673,7 +678,8 @@
 	else true; \
 	fi
 	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
-	(cd $(DESTDIR)$(BINDIR); $(LN) -sf python$(VERSION)-config python-config)
+	-rm -f $(DESTDIR)$(BINDIR)/python-config
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python-config)
 
 # Install the interpreter with $(VERSION) affixed
 # This goes into $(exec_prefix)
diff --git a/Misc/ACKS b/Misc/ACKS
index a86f92e..b9c8fd4 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -80,6 +80,7 @@
 Peter Bosch
 Eric Bouck
 Thierry Bousch
+Sebastian Boving
 Monty Brandenberg
 Georg Brandl
 Terrence Brannon
@@ -320,6 +321,7 @@
 Tony Ingraldi
 John Interrante
 Bob Ippolito
+Atsuo Ishimoto
 Ben Jackson
 Paul Jackson
 David Jacobs
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 75792ad..071f4c8 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1104,7 +1104,7 @@
 
 */
 
-static char *SIMPLE_TYPE_CHARS = "cbBhHiIlLdfuzZqQPXOvt";
+static char *SIMPLE_TYPE_CHARS = "cbBhHiIlLdfuzZqQPXOvtD";
 
 static PyObject *
 c_wchar_p_from_param(PyObject *type, PyObject *value)
diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c
index 39d9232..7048a2e 100644
--- a/Modules/_ctypes/_ctypes_test.c
+++ b/Modules/_ctypes/_ctypes_test.c
@@ -12,6 +12,29 @@
 
 /* some functions handy for testing */
 
+EXPORT(long double)testfunc_Ddd(double a, double b)
+{
+	long double result = (long double)(a * b);
+	printf("testfunc_Ddd(%p, %p)\n", &a, &b);
+	printf("testfunc_Ddd(%g, %g)\n", a, b);
+	return result;
+}
+
+EXPORT(long double)testfunc_DDD(long double a, long double b)
+{
+	long double result = a * b;
+	printf("testfunc_DDD(%p, %p)\n", &a, &b);
+	printf("testfunc_DDD(%Lg, %Lg)\n", a, b);
+	return result;
+}
+
+EXPORT(int)testfunc_iii(int a, int b)
+{
+	int result = a * b;
+	printf("testfunc_iii(%p, %p)\n", &a, &b);
+	return result;
+}
+
 EXPORT(int)myprintf(char *fmt, ...)
 {
 	int result;
@@ -77,6 +100,14 @@
 	return (double)(b + h + i + l + f + d);
 }
 
+EXPORT(long double) _testfunc_D_bhilfD(signed char b, short h, int i, long l, float f, long double d)
+{
+/*	printf("_testfunc_d_bhilfd got %d %d %d %ld %f %f\n",
+	       b, h, i, l, f, d);
+*/
+	return (long double)(b + h + i + l + f + d);
+}
+
 EXPORT(char *) _testfunc_p_p(void *s)
 {
 	return (char *)s;
@@ -391,6 +422,7 @@
 EXPORT(unsigned PY_LONG_LONG) tf_Q(unsigned PY_LONG_LONG c) { U; return c/3; }
 EXPORT(float) tf_f(float c) { S; return c/3; }
 EXPORT(double) tf_d(double c) { S; return c/3; }
+EXPORT(long double) tf_D(long double c) { S; return c/3; }
 
 #ifdef MS_WIN32
 EXPORT(signed char) __stdcall s_tf_b(signed char c) { S; return c/3; }
@@ -405,6 +437,7 @@
 EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_Q(unsigned PY_LONG_LONG c) { U; return c/3; }
 EXPORT(float) __stdcall s_tf_f(float c) { S; return c/3; }
 EXPORT(double) __stdcall s_tf_d(double c) { S; return c/3; }
+EXPORT(long double) __stdcall s_tf_D(long double c) { S; return c/3; }
 #endif
 /*******/
 
@@ -420,6 +453,7 @@
 EXPORT(unsigned PY_LONG_LONG) tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
 EXPORT(float) tf_bf(signed char x, float c) { S; return c/3; }
 EXPORT(double) tf_bd(signed char x, double c) { S; return c/3; }
+EXPORT(long double) tf_bD(signed char x, long double c) { S; return c/3; }
 EXPORT(void) tv_i(int c) { S; return; }
 
 #ifdef MS_WIN32
@@ -435,6 +469,7 @@
 EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
 EXPORT(float) __stdcall s_tf_bf(signed char x, float c) { S; return c/3; }
 EXPORT(double) __stdcall s_tf_bd(signed char x, double c) { S; return c/3; }
+EXPORT(long double) __stdcall s_tf_bD(signed char x, long double c) { S; return c/3; }
 EXPORT(void) __stdcall s_tv_i(int c) { S; return; }
 #endif
 
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index 3a98a74..1c66c48 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -444,6 +444,7 @@
 #ifdef HAVE_LONG_LONG
 	PY_LONG_LONG q;
 #endif
+	long double D;
 	double d;
 	float f;
 	void *p;
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index f60dede..c36798a 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -977,6 +977,29 @@
  */
 
 
+static PyObject *
+D_set(void *ptr, PyObject *value, Py_ssize_t size)
+{
+	long double x;
+
+	x = PyFloat_AsDouble(value);
+	if (x == -1 && PyErr_Occurred()) {
+		PyErr_Format(PyExc_TypeError,
+			     " float expected instead of %s instance",
+			     value->ob_type->tp_name);
+		return NULL;
+	}
+	memcpy(ptr, &x, sizeof(long double));
+	_RET(value);
+}
+
+static PyObject *
+D_get(void *ptr, Py_ssize_t size)
+{
+	long double val;
+	memcpy(&val, ptr, sizeof(long double));
+	return PyFloat_FromDouble(val);
+}
 
 static PyObject *
 d_set(void *ptr, PyObject *value, Py_ssize_t size)
@@ -1591,6 +1614,7 @@
 	{ 'B', B_set, B_get, &ffi_type_uchar},
 	{ 'c', c_set, c_get, &ffi_type_schar},
 	{ 'd', d_set, d_get, &ffi_type_double, d_set_sw, d_get_sw},
+	{ 'D', D_set, D_get, &ffi_type_longdouble},
 	{ 'f', f_set, f_get, &ffi_type_float, f_set_sw, f_get_sw},
 	{ 'h', h_set, h_get, &ffi_type_sshort, h_set_sw, h_get_sw},
 	{ 'H', H_set, H_get, &ffi_type_ushort, H_set_sw, H_get_sw},
@@ -1673,6 +1697,7 @@
 typedef struct { char c; long x; } s_long;
 typedef struct { char c; float x; } s_float;
 typedef struct { char c; double x; } s_double;
+typedef struct { char c; long double x; } s_long_double;
 typedef struct { char c; char *x; } s_char_p;
 typedef struct { char c; void *x; } s_void_p;
 
@@ -1684,6 +1709,8 @@
 */
 #define FLOAT_ALIGN (sizeof(s_float) - sizeof(float))
 #define DOUBLE_ALIGN (sizeof(s_double) - sizeof(double))
+#define LONGDOUBLE_ALIGN (sizeof(s_long_double) - sizeof(long double))
+
 /* #define CHAR_P_ALIGN (sizeof(s_char_p) - sizeof(char*)) */
 #define VOID_P_ALIGN (sizeof(s_void_p) - sizeof(void*))
 
@@ -1729,6 +1756,8 @@
 
 ffi_type ffi_type_float = { sizeof(float), FLOAT_ALIGN, FFI_TYPE_FLOAT };
 ffi_type ffi_type_double = { sizeof(double), DOUBLE_ALIGN, FFI_TYPE_DOUBLE };
+ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN,
+				 FFI_TYPE_LONGDOUBLE };
 
 /* ffi_type ffi_type_longdouble */
 
diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
index 52f6065..c78a6ea 100644
--- a/Modules/_ctypes/ctypes.h
+++ b/Modules/_ctypes/ctypes.h
@@ -30,6 +30,7 @@
 #ifdef HAVE_LONG_LONG
 		PY_LONG_LONG ll;
 #endif
+		long double D;
 };
 
 /*
@@ -283,6 +284,7 @@
 #ifdef HAVE_LONG_LONG
 		PY_LONG_LONG q;
 #endif
+		long double D;
 		double d;
 		float f;
 		void *p;
diff --git a/Modules/_ctypes/libffi/configure b/Modules/_ctypes/libffi/configure
index f65669e..bc7e474 100755
--- a/Modules/_ctypes/libffi/configure
+++ b/Modules/_ctypes/libffi/configure
@@ -3533,7 +3533,7 @@
 sh-*-linux* | sh[34]*-*-linux*) TARGET=SH; TARGETDIR=sh;;
 sh-*-rtems*) TARGET=SH; TARGETDIR=sh;;
 sh64-*-linux* | sh5*-*-linux*) TARGET=SH64; TARGETDIR=sh64;;
-hppa-*-linux* | parisc-*-linux*) TARGET=PA; TARGETDIR=pa;;
+hppa*-*-linux* | parisc*-*-linux*) TARGET=PA; TARGETDIR=pa;;
 esac
 
 if test $TARGETDIR = unknown; then
diff --git a/Modules/_ctypes/libffi/configure.ac b/Modules/_ctypes/libffi/configure.ac
index 8870fcb..10b04dc 100644
--- a/Modules/_ctypes/libffi/configure.ac
+++ b/Modules/_ctypes/libffi/configure.ac
@@ -71,7 +71,7 @@
 sh-*-linux* | sh[[34]]*-*-linux*) TARGET=SH; TARGETDIR=sh;;
 sh-*-rtems*) TARGET=SH; TARGETDIR=sh;;
 sh64-*-linux* | sh5*-*-linux*) TARGET=SH64; TARGETDIR=sh64;;
-hppa-*-linux* | parisc-*-linux*) TARGET=PA; TARGETDIR=pa;;
+hppa*-*-linux* | parisc*-*-linux*) TARGET=PA; TARGETDIR=pa;;
 esac
 
 if test $TARGETDIR = unknown; then
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index dd74a43..a5740e7 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -372,11 +372,20 @@
 	ProfilerEntry *profEntry;
 	ProfilerContext *pContext;
 
+	/* In the case of entering a generator expression frame via a
+	 * throw (gen_send_ex(.., 1)), we may already have an
+	 * Exception set here. We must not mess around with this
+	 * exception, and some of the code under here assumes that
+	 * PyErr_* is its own to mess around with, so we have to
+	 * save and restore any current exception. */
+	PyObject *last_type, *last_value, *last_tb;
+	PyErr_Fetch(&last_type, &last_value, &last_tb);
+
 	profEntry = getEntry(pObj, key);
 	if (profEntry == NULL) {
 		profEntry = newProfilerEntry(pObj, key, userObj);
 		if (profEntry == NULL)
-			return;
+			goto restorePyerr;
 	}
 	/* grab a ProfilerContext out of the free list */
 	pContext = pObj->freelistProfilerContext;
@@ -389,10 +398,13 @@
 			malloc(sizeof(ProfilerContext));
 		if (pContext == NULL) {
 			pObj->flags |= POF_NOMEMORY;
-			return;
+			goto restorePyerr;
 		}
 	}
 	initContext(pObj, pContext, profEntry);
+
+restorePyerr:
+	PyErr_Restore(last_type, last_value, last_tb);
 }
 
 static void
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index a31030a..ae0c34a 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -437,12 +437,15 @@
 }
 
 static PyObject *
-_create_dict_for_X509_NAME (X509_NAME *xname)
+_create_tuple_for_X509_NAME (X509_NAME *xname)
 {
-	PyObject *pd = PyDict_New();
+	PyObject *pt = NULL;
+        PyObject *entry_tuple = NULL;
+        int entry_count = X509_NAME_entry_count(xname);
 	int index_counter;
 
-	if (pd == NULL)
+        pt = PyTuple_New(entry_count);
+	if (pt == NULL)
 		return NULL;
 
 	for (index_counter = 0;
@@ -480,18 +483,20 @@
 			Py_DECREF(name_obj);
 			goto fail0;
 		}
-		if (PyDict_SetItem(pd, name_obj, value_obj) < 0) {
+                entry_tuple = PyTuple_New(2);
+                if (entry_tuple == NULL) {
 			Py_DECREF(name_obj);
 			Py_DECREF(value_obj);
 			goto fail0;
 		}
-		Py_DECREF(name_obj);
-		Py_DECREF(value_obj);
+                PyTuple_SET_ITEM(entry_tuple, 0, name_obj);
+                PyTuple_SET_ITEM(entry_tuple, 1, value_obj);
+                PyTuple_SET_ITEM(pt, index_counter, entry_tuple);
 	}
-	return pd;
+	return pt;
 
   fail0:
-	Py_XDECREF(pd);
+	Py_XDECREF(pt);
 	return NULL;
 }
 
@@ -520,7 +525,7 @@
 	if ((verification & SSL_VERIFY_PEER) == 0)
 		return retval;
 
-	peer = _create_dict_for_X509_NAME(
+	peer = _create_tuple_for_X509_NAME(
 		X509_get_subject_name(self->peer_cert));
 	if (peer == NULL)
 		goto fail0;
@@ -530,7 +535,7 @@
 	}
 	Py_DECREF(peer);
 
-	issuer = _create_dict_for_X509_NAME(
+	issuer = _create_tuple_for_X509_NAME(
 		X509_get_issuer_name(self->peer_cert));
 	if (issuer == NULL)
 		goto fail0;
diff --git a/Modules/makesetup b/Modules/makesetup
index bc1b1b9..8862c36 100755
--- a/Modules/makesetup
+++ b/Modules/makesetup
@@ -238,7 +238,7 @@
 			no)	SHAREDMODS="$SHAREDMODS $file";;
 			esac
 			rule="$file: $objs"
-			rule="$rule; \$(LDSHARED) $objs $libs $ExtraLibs -o $file"
+			rule="$rule; \$(BLDSHARED) $objs $libs $ExtraLibs -o $file"
 			echo "$rule" >>$rulesf
 		done
 	done
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 770679e..75ce991 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -6540,6 +6540,8 @@
               BYTE *pbBuffer );
 
 static CRYPTGENRANDOM pCryptGenRandom = NULL;
+/* This handle is never explicitly released. Instead, the operating
+   system will release it when the process terminates. */
 static HCRYPTPROV hCryptProv = 0;
 
 static PyObject*
diff --git a/Modules/readline.c b/Modules/readline.c
index fd800ff..f620f62 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -198,6 +198,7 @@
 
 /* Exported functions to specify hook functions in Python */
 
+static PyObject *completion_display_matches_hook = NULL;
 static PyObject *startup_hook = NULL;
 
 #ifdef HAVE_RL_PRE_INPUT_HOOK
@@ -205,6 +206,20 @@
 #endif
 
 static PyObject *
+set_completion_display_matches_hook(PyObject *self, PyObject *args)
+{
+	return set_hook("completion_display_matches_hook",
+			&completion_display_matches_hook, args);
+}
+
+PyDoc_STRVAR(doc_set_completion_display_matches_hook,
+"set_completion_display_matches_hook([function]) -> None\n\
+Set or remove the completion display function.\n\
+The function is called as\n\
+  function(substitution, [matches], longest_match_length)\n\
+once each time matches need to be displayed.");
+
+static PyObject *
 set_startup_hook(PyObject *self, PyObject *args)
 {
 	return set_hook("startup_hook", &startup_hook, args);
@@ -245,6 +260,18 @@
 static PyObject *endidx = NULL;
 
 
+/* Get the completion type for the scope of the tab-completion */
+static PyObject *
+get_completion_type(PyObject *self, PyObject *noarg)
+{
+  return PyInt_FromLong(rl_completion_type);
+}
+
+PyDoc_STRVAR(doc_get_completion_type,
+"get_completion_type() -> int\n\
+Get the type of completion being attempted.");
+
+
 /* Get the beginning index for the scope of the tab-completion */
 
 static PyObject *
@@ -557,6 +584,8 @@
 	 METH_NOARGS, get_history_length_doc},
 	{"set_completer", set_completer, METH_VARARGS, doc_set_completer},
 	{"get_completer", get_completer, METH_NOARGS, doc_get_completer},
+	{"get_completion_type", get_completion_type,
+	 METH_NOARGS, doc_get_completion_type},
 	{"get_begidx", get_begidx, METH_NOARGS, doc_get_begidx},
 	{"get_endidx", get_endidx, METH_NOARGS, doc_get_endidx},
 
@@ -568,6 +597,8 @@
 	{"get_completer_delims", get_completer_delims,
 	 METH_NOARGS, doc_get_completer_delims},
 
+	{"set_completion_display_matches_hook", set_completion_display_matches_hook,
+	 METH_VARARGS, doc_set_completion_display_matches_hook},
 	{"set_startup_hook", set_startup_hook,
 	 METH_VARARGS, doc_set_startup_hook},
 #ifdef HAVE_RL_PRE_INPUT_HOOK
@@ -631,6 +662,48 @@
 #endif
 
 
+/* C function to call the Python completion_display_matches */
+
+static void
+on_completion_display_matches_hook(char **matches,
+				   int num_matches, int max_length)
+{
+	if (completion_display_matches_hook != NULL) {
+	        int i;
+	        PyObject *m, *s;
+	        PyObject *r;
+#ifdef WITH_THREAD	      
+		PyGILState_STATE gilstate = PyGILState_Ensure();
+#endif
+		m = PyList_New(num_matches);
+		for (i = 0; i < num_matches; i++) {
+		  s = PyString_FromString(matches[i+1]);
+		  PyList_SetItem(m, i, s);
+		}
+
+		r = PyObject_CallFunction(completion_display_matches_hook,
+					  "sOi", matches[0], m, max_length);
+
+		Py_DECREF(m);
+
+		if (r == NULL ||
+		    (r != Py_None && PyInt_AsLong(r) == -1 && PyErr_Occurred())) {
+		  goto error;
+		}
+
+		Py_DECREF(r);
+		goto done;
+	  error:
+		PyErr_Clear();
+		Py_XDECREF(r);
+	  done:
+#ifdef WITH_THREAD	      
+		PyGILState_Release(gilstate);
+#endif
+	}
+}
+
+
 /* C function to call the Python completer. */
 
 static char *
@@ -708,6 +781,10 @@
 	rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap);
 	rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap);
 	/* Set our hook functions */
+#ifdef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK
+	rl_completion_display_matches_hook =
+	  (rl_compdisp_func_t *)on_completion_display_matches_hook;
+#endif
 	rl_startup_hook = (Function *)on_startup_hook;
 #ifdef HAVE_RL_PRE_INPUT_HOOK
 	rl_pre_input_hook = (Function *)on_pre_input_hook;
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 8d213b2..cdd3706 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2047,7 +2047,11 @@
         ternaryfunc call;
 
 	if ((call = func->ob_type->tp_call) != NULL) {
-		PyObject *result = (*call)(func, arg, kw);
+		PyObject *result;
+		if (Py_EnterRecursiveCall(" while calling a Python object"))
+		    return NULL;
+		result = (*call)(func, arg, kw);
+		Py_LeaveRecursiveCall();
 		if (result == NULL && !PyErr_Occurred())
 			PyErr_SetString(
 				PyExc_SystemError,
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index ce536fd..041cf9d 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -1715,6 +1715,12 @@
  */
 PyObject *PyExc_MemoryErrorInst=NULL;
 
+/* Pre-computed RuntimeError instance for when recursion depth is reached.
+   Meant to be used when normalizing the exception for exceeding the recursion
+   depth will cause its own infinite recursion.
+*/
+PyObject *PyExc_RecursionErrorInst = NULL;
+
 #define PRE_INIT(TYPE) if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \
     Py_FatalError("exceptions bootstrapping error.");
 
@@ -1867,6 +1873,29 @@
     if (!PyExc_MemoryErrorInst)
         Py_FatalError("Cannot pre-allocate MemoryError instance\n");
 
+    PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RuntimeError, NULL, NULL);
+    if (!PyExc_RecursionErrorInst)
+	Py_FatalError("Cannot pre-allocate RuntimeError instance for "
+			"recursion errors");
+    else {
+	PyBaseExceptionObject *err_inst =
+	    (PyBaseExceptionObject *)PyExc_RecursionErrorInst;
+	PyObject *args_tuple;
+	PyObject *exc_message;
+	exc_message = PyString_FromString("maximum recursion depth exceeded");
+	if (!exc_message)
+	    Py_FatalError("cannot allocate argument for RuntimeError "
+			    "pre-allocation");
+	args_tuple = PyTuple_Pack(1, exc_message);
+	if (!args_tuple)
+	    Py_FatalError("cannot allocate tuple for RuntimeError "
+			    "pre-allocation");
+	Py_DECREF(exc_message);
+	if (BaseException_init(err_inst, args_tuple, NULL))
+	    Py_FatalError("init of pre-allocated RuntimeError failed");
+	Py_DECREF(args_tuple);
+    }
+
     Py_DECREF(bltinmod);
 
 #if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index ae48e75..de31ebf 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4647,16 +4647,7 @@
 	if (meth == NULL)
 		return NULL;
 
-	/* PyObject_Call() will end up calling slot_tp_call() again if
-	   the object returned for __call__ has __call__ itself defined
-	   upon it.  This can be an infinite recursion if you set
-	   __call__ in a class to an instance of it. */
-	if (Py_EnterRecursiveCall(" in __call__")) {
-		Py_DECREF(meth);
-		return NULL;
-	}
 	res = PyObject_Call(meth, args, kwds);
-	Py_LeaveRecursiveCall();
 
 	Py_DECREF(meth);
 	return res;
diff --git a/PCbuild8/readme.txt b/PCbuild8/readme.txt
index eb8cd31..eb15dc8 100644
--- a/PCbuild8/readme.txt
+++ b/PCbuild8/readme.txt
@@ -90,6 +90,13 @@
     large tables of Unicode data
 winsound
     play sounds (typically .wav files) under Windows
+    
+Note: Check the dependencies of subprojects when building a subproject.  You 
+need to manually build each of the dependencies, in order, first.  A good 
+example of this is the pythoncore subproject.  It is dependent on both the 
+make_versioninfo and the make_buildinfo subprojects.  You can check the build 
+order by right clicking on the project name, in the solution explorer, and 
+selecting the project build order item.
 
 The following subprojects will generally NOT build out of the box.  They
 wrap code Python doesn't control, and you'll need to download the base
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index 708c26d..8d0704a 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -213,16 +213,24 @@
 			err_ret->error = E_EOF;
 		err_ret->lineno = tok->lineno;
 		if (tok->buf != NULL) {
+			char *text = NULL;
 			size_t len;
 			assert(tok->cur - tok->buf < INT_MAX);
 			err_ret->offset = (int)(tok->cur - tok->buf);
 			len = tok->inp - tok->buf;
-			err_ret->text = (char *) PyObject_MALLOC(len + 1);
-			if (err_ret->text != NULL) {
-				if (len > 0)
-					strncpy(err_ret->text, tok->buf, len);
-				err_ret->text[len] = '\0';
+#ifdef Py_USING_UNICODE
+			text = PyTokenizer_RestoreEncoding(tok, len, &err_ret->offset);
+
+#endif
+			if (text == NULL) {
+				text = (char *) PyObject_MALLOC(len + 1);
+				if (text != NULL) {
+					if (len > 0)
+						strncpy(text, tok->buf, len);
+					text[len] = '\0';
+				}
 			}
+			err_ret->text = text;
 		}
 	} else if (tok->encoding != NULL) {
 		node* r = PyNode_New(encoding_decl);
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 7f51e14..e01c03e 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1536,6 +1536,68 @@
 	return result;
 }
 
+/* This function is only called from parsetok. However, it cannot live
+   there, as it must be empty for PGEN, and we can check for PGEN only
+   in this file. */
+
+#ifdef PGEN
+char*
+PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int* offset)
+{
+	return NULL;
+}
+#else
+static PyObject *
+dec_utf8(const char *enc, const char *text, size_t len) {
+	PyObject *ret = NULL;	
+	PyObject *unicode_text = PyUnicode_DecodeUTF8(text, len, "replace");
+	if (unicode_text) {
+		ret = PyUnicode_AsEncodedString(unicode_text, enc, "replace");
+		Py_DECREF(unicode_text);
+	}
+	if (!ret) {
+		PyErr_Print();
+	}
+	return ret;
+}
+
+char *
+PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int *offset)
+{
+	char *text = NULL;
+	if (tok->encoding) {
+		/* convert source to original encondig */
+		PyObject *lineobj = dec_utf8(tok->encoding, tok->buf, len);
+		if (lineobj != NULL) {
+			int linelen = PyString_Size(lineobj);
+			const char *line = PyString_AsString(lineobj);
+			text = PyObject_MALLOC(linelen + 1);
+			if (text != NULL && line != NULL) {
+				if (linelen)
+					strncpy(text, line, linelen);
+				text[linelen] = '\0';
+			}
+			Py_DECREF(lineobj);
+					
+			/* adjust error offset */
+			if (*offset > 1) {
+				PyObject *offsetobj = dec_utf8(tok->encoding, 
+							       tok->buf, *offset-1);
+				if (offsetobj) {
+					*offset = PyString_Size(offsetobj) + 1;
+					Py_DECREF(offsetobj);
+				}
+			}
+			
+		}
+	}
+	return text;
+
+}
+#endif
+
+			   
+
 #ifdef Py_DEBUG
 
 void
diff --git a/Parser/tokenizer.h b/Parser/tokenizer.h
index ba90a5f..f38ad60 100644
--- a/Parser/tokenizer.h
+++ b/Parser/tokenizer.h
@@ -59,6 +59,8 @@
 					      char *, char *);
 extern void PyTokenizer_Free(struct tok_state *);
 extern int PyTokenizer_Get(struct tok_state *, char **, char **);
+extern char * PyTokenizer_RestoreEncoding(struct tok_state* tok, 
+					  int len, int *offset);
 
 #ifdef __cplusplus
 }
diff --git a/Python/errors.c b/Python/errors.c
index ef035f0..b1a70ef 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -139,6 +139,7 @@
 	PyObject *value = *val;
 	PyObject *inclass = NULL;
 	PyObject *initial_tb = NULL;
+	PyThreadState *tstate = NULL;
 
 	if (type == NULL) {
 		/* There was no exception, so nothing to do. */
@@ -214,7 +215,14 @@
 			Py_DECREF(initial_tb);
 	}
 	/* normalize recursively */
+	tstate = PyThreadState_GET();
+	if (++tstate->recursion_depth > Py_GetRecursionLimit()) {
+	    --tstate->recursion_depth;
+	    PyErr_SetObject(PyExc_RuntimeError, PyExc_RecursionErrorInst);
+	    return;
+	}
 	PyErr_NormalizeException(exc, val, tb);
+	--tstate->recursion_depth;
 }
 
 
diff --git a/configure b/configure
index 205071d..578512c 100755
--- a/configure
+++ b/configure
@@ -12002,6 +12002,14 @@
 			cur_target=10.3
 		fi
 		CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
+
+		# Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
+		# environment with a value that is the same as what we'll use
+		# in the Makefile to ensure that we'll get the same compiler
+		# environment during configure and build time.
+		MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
+		export MACOSX_DEPLOYMENT_TARGET
+
 		EXPORT_MACOSX_DEPLOYMENT_TARGET=''
 		if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2
 		then
@@ -21442,6 +21450,77 @@
 fi
 
 
+# also in 4.0
+{ echo "$as_me:$LINENO: checking for rl_completion_display_matches_hook in -lreadline" >&5
+echo $ECHO_N "checking for rl_completion_display_matches_hook in -lreadline... $ECHO_C" >&6; }
+if test "${ac_cv_lib_readline_rl_completion_display_matches_hook+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lreadline  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char rl_completion_display_matches_hook ();
+int
+main ()
+{
+return rl_completion_display_matches_hook ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+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_link") 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_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_readline_rl_completion_display_matches_hook=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_readline_rl_completion_display_matches_hook=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_readline_rl_completion_display_matches_hook" >&5
+echo "${ECHO_T}$ac_cv_lib_readline_rl_completion_display_matches_hook" >&6; }
+if test $ac_cv_lib_readline_rl_completion_display_matches_hook = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK 1
+_ACEOF
+
+fi
+
+
 # check for readline 4.2
 { echo "$as_me:$LINENO: checking for rl_completion_matches in -lreadline" >&5
 echo $ECHO_N "checking for rl_completion_matches in -lreadline... $ECHO_C" >&6; }
diff --git a/configure.in b/configure.in
index f23d77f..4d09bed 100644
--- a/configure.in
+++ b/configure.in
@@ -1480,6 +1480,14 @@
 			cur_target=10.3
 		fi
 		CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
+
+		# Make sure that MACOSX_DEPLOYMENT_TARGET is set in the 
+		# environment with a value that is the same as what we'll use
+		# in the Makefile to ensure that we'll get the same compiler
+		# environment during configure and build time.
+		MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
+		export MACOSX_DEPLOYMENT_TARGET
+
 		EXPORT_MACOSX_DEPLOYMENT_TARGET=''
 		if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2
 		then
@@ -3087,6 +3095,11 @@
 	AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
         [Define if you have readline 4.0]), , )
 
+# also in 4.0
+AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
+	AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
+        [Define if you have readline 4.0]), , )
+
 # check for readline 4.2
 AC_CHECK_LIB(readline, rl_completion_matches,
 	AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
diff --git a/pyconfig.h.in b/pyconfig.h.in
index e08cb0f..502c3ab 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -429,6 +429,9 @@
 /* Define if you have readline 2.2 */
 #undef HAVE_RL_COMPLETION_APPEND_CHARACTER
 
+/* Define if you have readline 4.0 */
+#undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK
+
 /* Define if you have readline 4.2 */
 #undef HAVE_RL_COMPLETION_MATCHES