[Python-checkins] r81796 - in python/branches/py3k-cdecimal: Doc/c-api/init.rst Doc/c-api/sys.rst Doc/distutils/builtdist.rst Doc/extending/newtypes.rst Doc/howto/descriptor.rst Doc/howto/index.rst Doc/library/argparse.rst Doc/library/datetime.rst Doc/library/decimal.rst Doc/library/dis.rst Doc/library/fcntl.rst Doc/library/ftplib.rst Doc/library/functions.rst Doc/library/getopt.rst Doc/library/hashlib.rst Doc/library/io.rst Doc/library/json.rst Doc/library/multiprocessing.rst Doc/library/optparse.rst Doc/library/os.rst Doc/library/socket.rst Doc/library/sqlite3.rst Doc/library/ssl.rst Doc/library/stdtypes.rst Doc/library/subprocess.rst Doc/library/symtable.rst Doc/library/sys.rst Doc/library/sysconfig.rst Doc/library/syslog.rst Doc/library/telnetlib.rst Doc/library/tempfile.rst Doc/library/time.rst Doc/library/unittest.rst Doc/library/urllib.parse.rst Doc/library/urllib.request.rst Doc/library/winreg.rst Doc/reference/datamodel.rst Doc/tools/sphinxext/pyspecific.py Doc/tutorial/datastructures.rst Doc/whatsnew/3.2.rst Include/longobject.h Include/pyport.h Include/sysmodule.h Lib/_abcoll.py Lib/argparse.py Lib/base64.py Lib/codecs.py Lib/decimal.py Lib/distutils/log.py Lib/distutils/tests/test_log.py Lib/distutils/unixccompiler.py Lib/email/charset.py Lib/email/encoders.py Lib/email/test/test_email.py Lib/encodings/utf_16.py Lib/encodings/utf_32.py Lib/fractions.py Lib/ftplib.py Lib/functools.py Lib/html/parser.py Lib/http/client.py Lib/lib2to3/refactor.py Lib/linecache.py Lib/pipes.py Lib/sqlite3/test/dbapi.py Lib/ssl.py Lib/subprocess.py Lib/sysconfig.py Lib/tabnanny.py Lib/tarfile.py Lib/test/regrtest.py Lib/test/test_argparse.py Lib/test/test_base64.py Lib/test/test_builtin.py Lib/test/test_codecs.py Lib/test/test_collections.py Lib/test/test_complex.py Lib/test/test_datetime.py Lib/test/test_decimal.py Lib/test/test_descr.py Lib/test/test_enumerate.py Lib/test/test_float.py Lib/test/test_ftplib.py Lib/test/test_gdb.py Lib/test/test_htmlparser.py Lib/test/test_httplib.py Lib/test/test_linecache.py Lib/test/test_long.py Lib/test/test_numeric_tower.py Lib/test/test_os.py Lib/test/test_pipes.py Lib/test/test_socketserver.py Lib/test/test_ssl.py Lib/test/test_subprocess.py Lib/test/test_sys.py Lib/test/test_sysconfig.py Lib/test/test_tarfile.py Lib/test/test_tcl.py Lib/test/test_urllib2.py Lib/test/test_warnings.py Lib/test/test_winreg.py Lib/test/test_winsound.py Lib/test/testtar.tar Lib/tkinter/_fix.py Lib/unittest/case.py Lib/unittest/loader.py Lib/unittest/suite.py Lib/unittest/test/test_case.py Lib/unittest/test/test_setups.py Lib/unittest/util.py Lib/urllib/request.py Lib/webbrowser.py Mac/Tools/pythonw.c Misc/ACKS Misc/NEWS Misc/developers.txt Modules/_multiprocessing/multiprocessing.h Modules/_sqlite/connection.c Modules/_ssl.c Modules/config.c.in Modules/datetimemodule.c Modules/main.c Modules/timemodule.c Objects/abstract.c Objects/complexobject.c Objects/longobject.c Objects/object.c Objects/typeobject.c PC/winreg.c Python/_warnings.c Python/ceval.c Python/getargs.c Python/pythonrun.c Python/sysmodule.c Tools/gdb/libpython.py Tools/i18n/msgfmt.py Tools/scripts/serve.py configure configure.in setup.py

stefan.krah python-checkins at python.org
Mon Jun 7 12:46:04 CEST 2010


Author: stefan.krah
Date: Mon Jun  7 12:46:02 2010
New Revision: 81796

Log:
Merged revisions 81352,81356,81358-81361,81364-81368,81370,81372,81375,81378,81387,81392-81393,81397,81400,81403,81406,81410,81417-81418,81421,81424,81427,81435,81438,81442,81446,81452,81455,81457,81461,81470,81474,81476,81481,81485-81486,81491,81493,81495,81498,81504,81511,81513-81514,81519,81522,81526,81528,81532-81533,81535,81538,81541,81545,81547-81548,81550,81553,81556-81557,81560,81564-81565,81568,81572,81575,81581,81583,81585,81588,81590,81595,81600,81604,81607,81609,81611-81613,81623,81625,81628,81630,81632,81638,81642,81647,81650,81654,81656,81660,81665,81670,81673,81682,81685,81689,81694-81695,81698-81699,81703,81708,81711,81713,81725,81730-81731,81737,81742-81743,81746,81748,81751,81754-81755,81757,81762,81765-81766,81768,81771,81778-81782,81790,81792,81794 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r81352 | stefan.krah | 2010-05-19 17:52:31 +0200 (Wed, 19 May 2010) | 9 lines
  
  Merged revisions 81350 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81350 | stefan.krah | 2010-05-19 17:46:39 +0200 (Wed, 19 May 2010) | 1 line
    
    Fix typos in docstrings.
  ........
................
  r81356 | stefan.krah | 2010-05-19 18:09:41 +0200 (Wed, 19 May 2010) | 9 lines
  
  Merged revisions 81354 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81354 | stefan.krah | 2010-05-19 17:59:40 +0200 (Wed, 19 May 2010) | 3 lines
    
    Fix typo.
  ........
................
  r81358 | victor.stinner | 2010-05-19 18:53:30 +0200 (Wed, 19 May 2010) | 4 lines
  
  Issue #8589: Decode PYTHONWARNINGS environment variable with the file system
  encoding and surrogateespace error handler instead of the locale encoding to be
  consistent with os.environ. Add PySys_AddWarnOptionUnicode() function.
................
  r81359 | victor.stinner | 2010-05-19 19:00:07 +0200 (Wed, 19 May 2010) | 4 lines
  
  Issue #8663: distutils.log emulates backslashreplace error handler. Fix
  compilation in a non-ASCII directory if stdout encoding is ASCII (eg. if stdout
  is not a TTY).
................
  r81360 | victor.stinner | 2010-05-19 19:11:19 +0200 (Wed, 19 May 2010) | 5 lines
  
  regrtest.py: call replace_stdout() before the first call to print()
  
  print("==  ", os.getcwd()) fails if the current working directory is not ASCII
  whereas sys.stdout encoding is ASCII.
................
  r81361 | victor.stinner | 2010-05-19 19:15:50 +0200 (Wed, 19 May 2010) | 2 lines
  
  Oops, add the new test_log.py for distutils test suite (missing part of r81359)
................
  r81364 | victor.stinner | 2010-05-19 22:40:50 +0200 (Wed, 19 May 2010) | 3 lines
  
  Issue #8766: Initialize _warnings module before importing the first module.
  Fix a crash if an empty directory called "encodings" exists in sys.path.
................
  r81365 | georg.brandl | 2010-05-19 22:57:08 +0200 (Wed, 19 May 2010) | 77 lines
  
  Merged revisions 80030,80067,80069,80080-80081,80084,80432-80433,80465-80470,81059,81065-81067 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80030 | georg.brandl | 2010-04-13 08:43:54 +0200 (Di, 13 Apr 2010) | 1 line
    
    Get rid of multi-row cells.
  ........
    r80067 | georg.brandl | 2010-04-14 10:53:38 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5341: typo.
  ........
    r80069 | georg.brandl | 2010-04-14 15:50:31 +0200 (Mi, 14 Apr 2010) | 1 line
    
    Add an x-ref to where the O_ constants are documented and move the SEEK_ constants after lseek().
  ........
    r80080 | georg.brandl | 2010-04-14 21:16:38 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #8399: add note about Windows and O_BINARY.
  ........
    r80081 | georg.brandl | 2010-04-14 23:34:44 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5250: document __instancecheck__ and __subclasscheck__.  I hope the part about the class/metaclass distinction is understandable.
  ........
    r80084 | georg.brandl | 2010-04-14 23:46:45 +0200 (Mi, 14 Apr 2010) | 1 line
    
    Fix missing.
  ........
    r80432 | georg.brandl | 2010-04-24 10:56:58 +0200 (Sa, 24 Apr 2010) | 1 line
    
    Markup fixes.
  ........
    r80433 | georg.brandl | 2010-04-24 11:08:10 +0200 (Sa, 24 Apr 2010) | 1 line
    
    #7507: quote "!" in pipes.quote(); it is a special character for some shells.
  ........
    r80465 | georg.brandl | 2010-04-25 12:29:17 +0200 (So, 25 Apr 2010) | 1 line
    
    Remove LaTeXy index entry syntax.
  ........
    r80466 | georg.brandl | 2010-04-25 12:54:42 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Better cross-referencing in socket and winreg docs.
  ........
    r80467 | georg.brandl | 2010-04-25 12:55:16 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Remove reference to winreg being the fabled high-level registry interface.
  ........
    r80468 | georg.brandl | 2010-04-25 12:55:58 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Minor spelling changes to _winreg docs.
  ........
    r80469 | georg.brandl | 2010-04-25 12:56:41 +0200 (So, 25 Apr 2010) | 1 line
    
    Fix code example to have valid syntax so that it can be highlighted.
  ........
    r80470 | georg.brandl | 2010-04-25 12:57:15 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Make socket setblocking <-> settimeout examples symmetric.
  ........
    r81059 | georg.brandl | 2010-05-10 23:02:51 +0200 (Mo, 10 Mai 2010) | 1 line
    
    #8642: fix wrong function name.
  ........
    r81065 | georg.brandl | 2010-05-10 23:46:50 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Fix reference direction.
  ........
    r81066 | georg.brandl | 2010-05-10 23:50:57 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Consolidate deprecation messages.
  ........
    r81067 | georg.brandl | 2010-05-10 23:51:33 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Fix typo.
  ........
................
  r81366 | georg.brandl | 2010-05-19 22:58:02 +0200 (Wed, 19 May 2010) | 61 lines
  
  Recorded merge of revisions 80030,80067,80069,80080-80081,80084,80432-80433,80465,80470,81059,81065-81067 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80030 | georg.brandl | 2010-04-13 08:43:54 +0200 (Di, 13 Apr 2010) | 1 line
    
    Get rid of multi-row cells.
  ........
    r80067 | georg.brandl | 2010-04-14 10:53:38 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5341: typo.
  ........
    r80069 | georg.brandl | 2010-04-14 15:50:31 +0200 (Mi, 14 Apr 2010) | 1 line
    
    Add an x-ref to where the O_ constants are documented and move the SEEK_ constants after lseek().
  ........
    r80080 | georg.brandl | 2010-04-14 21:16:38 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #8399: add note about Windows and O_BINARY.
  ........
    r80081 | georg.brandl | 2010-04-14 23:34:44 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5250: document __instancecheck__ and __subclasscheck__.  I hope the part about the class/metaclass distinction is understandable.
  ........
    r80084 | georg.brandl | 2010-04-14 23:46:45 +0200 (Mi, 14 Apr 2010) | 1 line
    
    Fix missing.
  ........
    r80432 | georg.brandl | 2010-04-24 10:56:58 +0200 (Sa, 24 Apr 2010) | 1 line
    
    Markup fixes.
  ........
    r80433 | georg.brandl | 2010-04-24 11:08:10 +0200 (Sa, 24 Apr 2010) | 1 line
    
    #7507: quote "!" in pipes.quote(); it is a special character for some shells.
  ........
    r80465 | georg.brandl | 2010-04-25 12:29:17 +0200 (So, 25 Apr 2010) | 1 line
    
    Remove LaTeXy index entry syntax.
  ........
    r80470 | georg.brandl | 2010-04-25 12:57:15 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Make socket setblocking <-> settimeout examples symmetric.
  ........
    r81059 | georg.brandl | 2010-05-10 23:02:51 +0200 (Mo, 10 Mai 2010) | 1 line
    
    #8642: fix wrong function name.
  ........
    r81065 | georg.brandl | 2010-05-10 23:46:50 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Fix reference direction.
  ........
    r81066 | georg.brandl | 2010-05-10 23:50:57 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Consolidate deprecation messages.
  ........
    r81067 | georg.brandl | 2010-05-10 23:51:33 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Fix typo.
  ........
................
  r81367 | georg.brandl | 2010-05-19 23:03:51 +0200 (Wed, 19 May 2010) | 21 lines
  
  Recorded merge of revisions 80466-80469 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80466 | georg.brandl | 2010-04-25 12:54:42 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Better cross-referencing in socket and winreg docs.
  ........
    r80467 | georg.brandl | 2010-04-25 12:55:16 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Remove reference to winreg being the fabled high-level registry interface.
  ........
    r80468 | georg.brandl | 2010-04-25 12:55:58 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Minor spelling changes to _winreg docs.
  ........
    r80469 | georg.brandl | 2010-04-25 12:56:41 +0200 (So, 25 Apr 2010) | 1 line
    
    Fix code example to have valid syntax so that it can be highlighted.
  ........
................
  r81368 | georg.brandl | 2010-05-19 23:06:36 +0200 (Wed, 19 May 2010) | 9 lines
  
  Merged revisions 80068 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80068 | georg.brandl | 2010-04-14 10:56:01 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5341: fix typo and adapt docstring syntax.
  ........
................
  r81370 | georg.brandl | 2010-05-19 23:39:51 +0200 (Wed, 19 May 2010) | 1 line
  
  Add descriptor HOWTO to py3k docs.
................
  r81372 | tarek.ziade | 2010-05-20 00:25:00 +0200 (Thu, 20 May 2010) | 9 lines
  
  Merged revisions 81371 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81371 | tarek.ziade | 2010-05-20 00:20:14 +0200 (Thu, 20 May 2010) | 1 line
    
    #8759: Fixed user paths in sysconfig for posix and os2 schemes
  ........
................
  r81375 | victor.stinner | 2010-05-20 01:04:56 +0200 (Thu, 20 May 2010) | 9 lines
  
  Issue #8559: improve unicode support of (gdb) libpython.py
  
   * Escape non printable characters (use locale.getpreferredencoding())
   * Fix support of surrogate pairs
   * test_gdb.py: use ascii() instead of repr() in gdb program arguments to avoid
     encoding issues
   * Fix test_strings() of test_gdb.py for encoding different than UTF-8
     (eg. ACSII)
................
  r81378 | victor.stinner | 2010-05-20 13:30:37 +0200 (Thu, 20 May 2010) | 14 lines
  
  Blocked revisions 81377 via svnmerge
  
  ........
    r81377 | victor.stinner | 2010-05-20 13:29:45 +0200 (jeu., 20 mai 2010) | 8 lines
    
    libpython.py: fix support of non-BMP unicode characters
    
    Forward port some code from Python3:
    
     * join surrogate pairs if sizeof(Py_UNICODE)==2
     * Enable non-BMP test on narrow builds using u"\U0001D121" instead of
       unichr(0x1D121)
  ........
................
  r81387 | benjamin.peterson | 2010-05-21 00:29:43 +0200 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81385 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81385 | benjamin.peterson | 2010-05-20 17:23:37 -0500 (Thu, 20 May 2010) | 1 line
    
    fix extra 't' #8778
  ........
................
  r81392 | antoine.pitrou | 2010-05-21 11:56:06 +0200 (Fri, 21 May 2010) | 5 lines
  
  Issue #4870: Add an `options` attribute to SSL contexts, as well as 
  several ``OP_*`` constants to the `ssl` module.  This allows to selectively
  disable protocol versions, when used in combination with `PROTOCOL_SSLv23`.
................
  r81393 | victor.stinner | 2010-05-21 12:52:08 +0200 (Fri, 21 May 2010) | 3 lines
  
  Issue #8774: tabnanny uses the encoding cookie (#coding:...) to use the correct
  encoding
................
  r81397 | mark.dickinson | 2010-05-21 16:55:26 +0200 (Fri, 21 May 2010) | 10 lines
  
  Issue #8748: Fix two issues with comparisons between complex and integer
  objects.  (1) The comparison could incorrectly return True in some cases
  (2**53+1 == complex(2**53) == 2**53), breaking transivity of equality.
  (2) The comparison raised an OverflowError for large integers, leading
  to unpredictable exceptions when combining integers and complex objects
  in sets or dicts.
  
  Patch by Meador Inge.
................
  r81400 | antoine.pitrou | 2010-05-21 19:25:34 +0200 (Fri, 21 May 2010) | 12 lines
  
  Merged revisions 81398 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81398 | antoine.pitrou | 2010-05-21 19:12:38 +0200 (ven., 21 mai 2010) | 6 lines
    
    Issue #5753: A new C API function, :cfunc:`PySys_SetArgvEx`, allows
    embedders of the interpreter to set sys.argv without also modifying
    sys.path.  This helps fix `CVE-2008-5983
    <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
  ........
................
  r81403 | victor.stinner | 2010-05-21 22:13:12 +0200 (Fri, 21 May 2010) | 5 lines
  
  Issue #8780: Fix a regression introduced by r78946 in subprocess on Windows
  
  Ensure that stdout / stderr is inherited from the parent if stdout=PIPE /
  stderr=PIPE is not used.
................
  r81406 | georg.brandl | 2010-05-21 22:28:13 +0200 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81404 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81404 | georg.brandl | 2010-05-21 22:24:45 +0200 (Fr, 21 Mai 2010) | 1 line
    
    #8783: replace link to now dead hash collision FAQ.
  ........
................
  r81410 | georg.brandl | 2010-05-21 22:45:12 +0200 (Fri, 21 May 2010) | 1 line
  
  Remove redundant example.
................
  r81417 | benjamin.peterson | 2010-05-21 22:55:22 +0200 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81414 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81414 | benjamin.peterson | 2010-05-21 15:51:45 -0500 (Fri, 21 May 2010) | 1 line
    
    return NotImplemented from Mapping when comparing to a non-mapping #8729
  ........
................
  r81418 | georg.brandl | 2010-05-21 22:57:33 +0200 (Fri, 21 May 2010) | 9 lines
  
  Recorded merge of revisions 81415 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81415 | georg.brandl | 2010-05-21 22:52:46 +0200 (Fr, 21 Mai 2010) | 1 line
    
    typo
  ........
................
  r81421 | georg.brandl | 2010-05-21 23:01:32 +0200 (Fri, 21 May 2010) | 1 line
  
  Fix variable name in example.
................
  r81424 | georg.brandl | 2010-05-21 23:03:02 +0200 (Fri, 21 May 2010) | 8 lines
  
  Blocked revisions 81419 via svnmerge
  
  ........
    r81419 | georg.brandl | 2010-05-21 22:58:12 +0200 (Fr, 21 Mai 2010) | 1 line
    
    Add missing parameter in SimpleXMLRPCServer signature.
  ........
................
  r81427 | georg.brandl | 2010-05-21 23:12:07 +0200 (Fri, 21 May 2010) | 1 line
  
  Fix signatures for the various TemporaryFile class^Wfunctions.
................
  r81435 | georg.brandl | 2010-05-21 23:33:23 +0200 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81431 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81431 | georg.brandl | 2010-05-21 23:30:47 +0200 (Fr, 21 Mai 2010) | 1 line
    
    #8707: remove duplicate paragraph part.
  ........
................
  r81438 | benjamin.peterson | 2010-05-21 23:45:06 +0200 (Fri, 21 May 2010) | 25 lines
  
  Merged revisions 81428-81429,81432-81433,81437 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81428 | benjamin.peterson | 2010-05-21 16:16:12 -0500 (Fri, 21 May 2010) | 1 line
    
    use addCleanup
  ........
    r81429 | benjamin.peterson | 2010-05-21 16:17:22 -0500 (Fri, 21 May 2010) | 1 line
    
    fix name
  ........
    r81432 | benjamin.peterson | 2010-05-21 16:31:24 -0500 (Fri, 21 May 2010) | 1 line
    
    ensure the last line has a trailing newline #8782
  ........
    r81433 | benjamin.peterson | 2010-05-21 16:32:49 -0500 (Fri, 21 May 2010) | 1 line
    
    remove debugging rubish
  ........
    r81437 | benjamin.peterson | 2010-05-21 16:35:44 -0500 (Fri, 21 May 2010) | 1 line
    
    simplify and modernize updatecache()
  ........
................
  r81442 | georg.brandl | 2010-05-21 23:48:27 +0200 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81440 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81440 | georg.brandl | 2010-05-21 23:47:05 +0200 (Fr, 21 Mai 2010) | 1 line
    
    Correct info for Semaphore.acquire() semantics under OSX.
  ........
................
  r81446 | georg.brandl | 2010-05-21 23:49:47 +0200 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81443 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81443 | georg.brandl | 2010-05-21 23:48:57 +0200 (Fr, 21 Mai 2010) | 1 line
    
    typo
  ........
................
  r81452 | georg.brandl | 2010-05-22 00:04:32 +0200 (Sat, 22 May 2010) | 9 lines
  
  Merged revisions 81450 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81450 | georg.brandl | 2010-05-22 00:03:29 +0200 (Sa, 22 Mai 2010) | 1 line
    
    #8709: mention Windows support for os.devnull.
  ........
................
  r81455 | victor.stinner | 2010-05-22 00:52:10 +0200 (Sat, 22 May 2010) | 9 lines
  
  Blocked revisions 81454 via svnmerge
  
  ........
    r81454 | victor.stinner | 2010-05-22 00:50:28 +0200 (sam., 22 mai 2010) | 3 lines
    
    Issue #5640: Fix Shift-JIS incremental encoder for error handlers different
    than strict
  ........
................
  r81457 | victor.stinner | 2010-05-22 01:45:42 +0200 (Sat, 22 May 2010) | 3 lines
  
  Issue #3798: sys.exit(message) writes the message to sys.stderr file, instead
  of the C file stderr, to use stderr encoding and error handler
................
  r81461 | victor.stinner | 2010-05-22 04:16:27 +0200 (Sat, 22 May 2010) | 10 lines
  
  Merged revisions 81459 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81459 | victor.stinner | 2010-05-22 04:11:07 +0200 (sam., 22 mai 2010) | 3 lines
    
    Issue #6268: Fix seek() method of codecs.open(), don't read the BOM twice
    after seek(0)
  ........
................
  r81470 | mark.dickinson | 2010-05-22 14:02:35 +0200 (Sat, 22 May 2010) | 1 line
  
  Issue #8749: remove unused code in Objects/object.c.  Thanks Yaniv Aknin.
................
  r81474 | victor.stinner | 2010-05-22 18:59:09 +0200 (Sat, 22 May 2010) | 20 lines
  
  Merged revisions 81471-81472 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81471 | victor.stinner | 2010-05-22 15:37:56 +0200 (sam., 22 mai 2010) | 7 lines
    
    Issue #6268: More bugfixes about BOM, UTF-16 and UTF-32
    
     * Fix seek() method of codecs.open(), don't write the BOM twice after seek(0)
     * Fix reset() method of codecs, UTF-16, UTF-32 and StreamWriter classes
     * test_codecs: use "w+" mode instead of "wt+". "t" mode is not supported by
       Solaris or Windows, but does it really exist? I found it the in the issue.
  ........
    r81472 | victor.stinner | 2010-05-22 15:44:25 +0200 (sam., 22 mai 2010) | 4 lines
    
    Fix my last commit (r81471) about codecs
    
    Rememder: don't touch the code just before a commit
  ........
................
  r81476 | mark.dickinson | 2010-05-22 20:35:36 +0200 (Sat, 22 May 2010) | 2 lines
  
  #Issue 8540: Make Context._clamp attribute public in decimal module.
................
  r81481 | benjamin.peterson | 2010-05-22 20:59:24 +0200 (Sat, 22 May 2010) | 20 lines
  
  Merged revisions 81479 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ................
    r81479 | benjamin.peterson | 2010-05-22 13:52:21 -0500 (Sat, 22 May 2010) | 13 lines
    
    Merged revisions 80937,81478 via svnmerge from 
    svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
    
    ........
      r80937 | benjamin.peterson | 2010-05-07 14:10:58 -0500 (Fri, 07 May 2010) | 1 line
      
      remove redundant unicode call
    ........
      r81478 | benjamin.peterson | 2010-05-22 13:47:39 -0500 (Sat, 22 May 2010) | 1 line
      
      ensure doctests have some future_features
    ........
  ................
................
  r81485 | mark.dickinson | 2010-05-23 15:26:48 +0200 (Sun, 23 May 2010) | 1 line
  
  Remove duplicate NEWS entry.
................
  r81486 | mark.dickinson | 2010-05-23 15:33:13 +0200 (Sun, 23 May 2010) | 6 lines
  
  Issue #8188: Introduce a new scheme for computing hashes of numbers
  (instances of int, float, complex, decimal.Decimal and
  fractions.Fraction) that makes it easy to maintain the invariant that
  hash(x) == hash(y) whenever x and y have equal value.
................
  r81491 | steven.bethard | 2010-05-24 05:21:08 +0200 (Mon, 24 May 2010) | 9 lines
  
  Merged revisions 81490 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81490 | steven.bethard | 2010-05-23 19:38:00 -0700 (Sun, 23 May 2010) | 1 line
    
    argparse documentation updates (including updates to optparse and getopt documentation that were promised in the PEP)
  ........
................
  r81493 | steven.bethard | 2010-05-24 05:47:38 +0200 (Mon, 24 May 2010) | 9 lines
  
  Merged revisions 81492 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81492 | steven.bethard | 2010-05-23 20:45:26 -0700 (Sun, 23 May 2010) | 1 line
    
    Fix default value for version help. Approved by Benjamin on python-dev: http://mail.python.org/pipermail/python-dev/2010-May/100231.html
  ........
................
  r81495 | antoine.pitrou | 2010-05-24 17:58:43 +0200 (Mon, 24 May 2010) | 3 lines
  
  Add a versionadded tag for SSL contexts.
................
  r81498 | antoine.pitrou | 2010-05-24 23:20:20 +0200 (Mon, 24 May 2010) | 3 lines
  
  Document the context attribute of SSL sockets
................
  r81504 | victor.stinner | 2010-05-24 23:46:25 +0200 (Mon, 24 May 2010) | 13 lines
  
  Recorded merge of revisions 81500-81501 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81500 | victor.stinner | 2010-05-24 23:33:24 +0200 (lun., 24 mai 2010) | 2 lines
    
    Issue #6662: Fix parsing of malformatted charref (&#bad;)
  ........
    r81501 | victor.stinner | 2010-05-24 23:37:28 +0200 (lun., 24 mai 2010) | 2 lines
    
    Add the author of the last fix (Issue #6662)
  ........
................
  r81511 | benjamin.peterson | 2010-05-25 04:27:55 +0200 (Tue, 25 May 2010) | 8 lines
  
  Blocked revisions 81509 via svnmerge
  
  ........
    r81509 | benjamin.peterson | 2010-05-24 21:23:32 -0500 (Mon, 24 May 2010) | 1 line
    
    correct default docs
  ........
................
  r81513 | tarek.ziade | 2010-05-25 11:44:36 +0200 (Tue, 25 May 2010) | 1 line
  
  Made sysconfig a script that displays useful information - #8770
................
  r81514 | tarek.ziade | 2010-05-25 11:47:06 +0200 (Tue, 25 May 2010) | 1 line
  
  added the list of public APIs in sysconfig
................
  r81519 | r.david.murray | 2010-05-25 17:26:21 +0200 (Tue, 25 May 2010) | 13 lines
  
  Blocked revisions 81518 via svnmerge
  
  ........
    r81518 | r.david.murray | 2010-05-25 11:20:46 -0400 (Tue, 25 May 2010) | 8 lines
    
    Issue 8143: sync unquote in urlparse with urllib; add comment about doing so.
    
    unquote is duplicated in the two files to avoid a circular reference.
    (This is fixed in Python3.)  Updates keep getting made to the public unquote
    without fixing the urlparse one, however, so this fix syncs the two
    and adds a comment to both to make sure changes are applied to both.
  ........
................
  r81522 | r.david.murray | 2010-05-25 17:36:46 +0200 (Tue, 25 May 2010) | 9 lines
  
  Recorded merge of revisions 81521 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81521 | r.david.murray | 2010-05-25 11:32:06 -0400 (Tue, 25 May 2010) | 2 lines
    
    Issue 8818: urlparse/urlsplit keyword is 'scheme', not 'default_scheme'.
  ........
................
  r81526 | mark.dickinson | 2010-05-25 21:06:24 +0200 (Tue, 25 May 2010) | 10 lines
  
  Merged revisions 81525 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81525 | mark.dickinson | 2010-05-25 20:01:08 +0100 (Tue, 25 May 2010) | 3 lines
    
    Issue #8816: Extra tests for some built-in functions.  These tests are
    ports of IronPython tests.  Thanks Gregory Nofi.
  ........
................
  r81528 | mark.dickinson | 2010-05-25 21:46:20 +0200 (Tue, 25 May 2010) | 9 lines
  
  Merged revisions 81527 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81527 | mark.dickinson | 2010-05-25 20:44:49 +0100 (Tue, 25 May 2010) | 1 line
    
    Fix a NameError in test_enumerate.
  ........
................
  r81532 | martin.v.loewis | 2010-05-25 22:07:11 +0200 (Tue, 25 May 2010) | 9 lines
  
  Merged revisions 81531 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81531 | martin.v.loewis | 2010-05-25 22:06:02 +0200 (Di, 25 Mai 2010) | 2 lines
    
    Add Alexander Belopolsky.
  ........
................
  r81533 | victor.stinner | 2010-05-25 23:12:34 +0200 (Tue, 25 May 2010) | 3 lines
  
  Issue #4769: Fix main() function of the base64 module, use sys.stdin.buffer and
  sys.stdout.buffer (instead of sys.stdin and sys.stdout) to use the bytes API
................
  r81535 | victor.stinner | 2010-05-26 00:17:22 +0200 (Wed, 26 May 2010) | 2 lines
  
  Fix the new TestMain.test_decode() of test_base64 for Windows
................
  r81538 | victor.stinner | 2010-05-26 00:35:40 +0200 (Wed, 26 May 2010) | 11 lines
  
  Blocked revisions 81537 via svnmerge
  
  ........
    r81537 | victor.stinner | 2010-05-26 00:30:32 +0200 (mer., 26 mai 2010) | 3 lines
  
    Issue #3798: Write sys.exit() message to sys.stderr to use stderr encoding and
    error handler, instead of writing to the C stderr file in utf-8
  ........
  
  py3k was already fixed by r81252.
................
  r81541 | mark.dickinson | 2010-05-26 18:02:59 +0200 (Wed, 26 May 2010) | 4 lines
  
  Issue #8817: Expose round-to-nearest variant of divmod in _PyLong_Divmod_Near
  for use by the datetime module; also refactor long_round to use this function.
................
  r81545 | victor.stinner | 2010-05-26 19:33:03 +0200 (Wed, 26 May 2010) | 9 lines
  
  Merged revisions 81543 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81543 | victor.stinner | 2010-05-26 19:25:28 +0200 (mer., 26 mai 2010) | 2 lines
    
    Issue #7449: Skip test_socketserver if threading support is disabled
  ........
................
  r81547 | brian.curtin | 2010-05-26 19:43:50 +0200 (Wed, 26 May 2010) | 6 lines
  
  Fix #2810 - handle the case where some registry calls return
  ERROR_MORE_DATA, requiring another call to get the remaining data.
  
  Patch by Daniel Stutzbach
................
  r81548 | giampaolo.rodola | 2010-05-26 20:06:04 +0200 (Wed, 26 May 2010) | 1 line
  
  Fix issue #8806: add SSL contexts support to ftplib
................
  r81550 | giampaolo.rodola | 2010-05-26 20:21:26 +0200 (Wed, 26 May 2010) | 1 line
  
  fix wrong assertIs context
................
  r81553 | mark.dickinson | 2010-05-26 21:14:01 +0200 (Wed, 26 May 2010) | 9 lines
  
  Merged revisions 81551 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81551 | mark.dickinson | 2010-05-26 20:06:33 +0100 (Wed, 26 May 2010) | 1 line
    
    Issue #8825: additional testcases for int(string, 0) and long(string, 0).
  ........
................
  r81556 | alexander.belopolsky | 2010-05-26 22:00:12 +0200 (Wed, 26 May 2010) | 10 lines
  
  Merged revisions 81555 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81555 | alexander.belopolsky | 2010-05-26 15:43:16 -0400 (Wed, 26 May 2010) | 3 lines
    
    Issue #7879: Do not test negative timestamps on any Windows platform
    including Windows CE.
  ........
................
  r81557 | mark.dickinson | 2010-05-26 22:07:58 +0200 (Wed, 26 May 2010) | 4 lines
  
  Issue #2844: Make int('42', n) consistently raise ValueError for
  invalid integers n (including n = -909).
................
  r81560 | alexander.belopolsky | 2010-05-26 22:48:30 +0200 (Wed, 26 May 2010) | 10 lines
  
  Merged revisions 81559 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81559 | alexander.belopolsky | 2010-05-26 16:45:37 -0400 (Wed, 26 May 2010) | 3 lines
    
    Issue #7879: Skip negative timestamps test on any Windows platform
    using unittest.skipIf decorator.
  ........
................
  r81564 | mark.dickinson | 2010-05-27 21:45:50 +0200 (Thu, 27 May 2010) | 9 lines
  
  Merged revisions 81512 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81512 | brett.cannon | 2010-05-25 03:53:04 +0100 (Tue, 25 May 2010) | 1 line
    
    Make the contributor list alphabetical again.
  ........
................
  r81565 | mark.dickinson | 2010-05-27 21:47:53 +0200 (Thu, 27 May 2010) | 1 line
  
  Stefan Krah was missing from Misc/ACKS in the py3k branch.
................
  r81568 | alexander.belopolsky | 2010-05-27 23:42:58 +0200 (Thu, 27 May 2010) | 10 lines
  
  Merged revisions 81566 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81566 | alexander.belopolsky | 2010-05-27 16:55:27 -0400 (Thu, 27 May 2010) | 3 lines
    
    Issue #7150: Raise OverflowError if the result of adding or subtracting
    timedelta from date or datetime falls outside of the MINYEAR:MAXYEAR range.
  ........
................
  r81572 | benjamin.peterson | 2010-05-28 00:32:22 +0200 (Fri, 28 May 2010) | 1 line
  
  correct default value in signature
................
  r81575 | ezio.melotti | 2010-05-28 00:38:16 +0200 (Fri, 28 May 2010) | 9 lines
  
  Merged revisions 81318 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81318 | ezio.melotti | 2010-05-19 03:32:52 +0300 (Wed, 19 May 2010) | 1 line
    
    Fix typo in argparse doc.
  ........
................
  r81581 | benjamin.peterson | 2010-05-28 05:23:57 +0200 (Fri, 28 May 2010) | 12 lines
  
  Blocked revisions 81578-81579 via svnmerge
  
  ........
    r81578 | benjamin.peterson | 2010-05-27 21:12:36 -0500 (Thu, 27 May 2010) | 1 line
    
    remove non-ascii coding per PEP 8
  ........
    r81579 | benjamin.peterson | 2010-05-27 22:10:31 -0500 (Thu, 27 May 2010) | 1 line
    
    2to3 doesn't fix test_support #6583
  ........
................
  r81583 | martin.v.loewis | 2010-05-28 17:44:20 +0200 (Fri, 28 May 2010) | 9 lines
  
  Merged revisions 81582 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81582 | martin.v.loewis | 2010-05-28 17:28:47 +0200 (Fr, 28 Mai 2010) | 2 lines
    
    Issue #1759169: Drop _XOPEN_SOURCE on Solaris.
  ........
................
  r81585 | brian.curtin | 2010-05-28 18:08:40 +0200 (Fri, 28 May 2010) | 10 lines
  
  Merged revisions 81584 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81584 | brian.curtin | 2010-05-28 10:49:21 -0500 (Fri, 28 May 2010) | 3 lines
    
    Fix #8405 for slow buildbots. Remove the sleep on startup and move the
    pipe communication into a loop to retry in case a buildbot gets even slower.
  ........
................
  r81588 | victor.stinner | 2010-05-28 23:55:10 +0200 (Fri, 28 May 2010) | 3 lines
  
  Issue #8837: Remove "O?" format of PyArg_Parse*() functions. The format is no
  used anymore and it was never documented.
................
  r81590 | victor.stinner | 2010-05-29 02:13:06 +0200 (Sat, 29 May 2010) | 2 lines
  
  Remove dead code
................
  r81595 | antoine.pitrou | 2010-05-29 14:08:25 +0200 (Sat, 29 May 2010) | 9 lines
  
  Merged revisions 81594 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81594 | antoine.pitrou | 2010-05-29 14:06:13 +0200 (sam., 29 mai 2010) | 3 lines
    
    Issue #8840: Make documentation for truncate() clearer
  ........
................
  r81600 | stefan.krah | 2010-05-29 14:59:18 +0200 (Sat, 29 May 2010) | 9 lines
  
  Merged revisions 81598 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81598 | stefan.krah | 2010-05-29 14:54:35 +0200 (Sat, 29 May 2010) | 1 line
    
    Fix typo
  ........
................
  r81604 | mark.dickinson | 2010-05-29 23:05:27 +0200 (Sat, 29 May 2010) | 9 lines
  
  Merged revisions 81602 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81602 | mark.dickinson | 2010-05-29 22:00:52 +0100 (Sat, 29 May 2010) | 1 line
    
    Untabify Modules/config.c.in.
  ........
................
  r81607 | mark.dickinson | 2010-05-30 14:12:56 +0200 (Sun, 30 May 2010) | 10 lines
  
  Blocked revisions 81606 via svnmerge
  
  ........
    r81606 | mark.dickinson | 2010-05-30 13:12:25 +0100 (Sun, 30 May 2010) | 4 lines
    
    Issue #5211: Complete removal of implicit coercions for the complex
    type.  Coercion for arithmetic operations was already removed in
    r78280, but that commit didn't remove coercion for rich comparisons.
  ........
................
  r81609 | mark.dickinson | 2010-05-30 14:17:39 +0200 (Sun, 30 May 2010) | 8 lines
  
  Blocked revisions 81608 via svnmerge
  
  ........
    r81608 | mark.dickinson | 2010-05-30 13:17:11 +0100 (Sun, 30 May 2010) | 1 line
    
    Remove declaration for unused variable.
  ........
................
  r81611 | mark.dickinson | 2010-05-30 15:18:47 +0200 (Sun, 30 May 2010) | 10 lines
  
  Recorded merge of revisions 81610 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81610 | mark.dickinson | 2010-05-30 14:18:10 +0100 (Sun, 30 May 2010) | 3 lines
    
    Issue #8748: Fix incorrect results from comparisons between an integer
    and a complex instance.  Based on a patch by Meador Inge.
  ........
................
  r81612 | benjamin.peterson | 2010-05-30 16:49:32 +0200 (Sun, 30 May 2010) | 1 line
  
  use atomic structures in non-thread version
................
  r81613 | ronald.oussoren | 2010-05-30 17:46:48 +0200 (Sun, 30 May 2010) | 4 lines
  
  Remove conditional import of 'ic', that module
  was removed in the transition from python 2.x to
  python 3.x.
................
  r81623 | antoine.pitrou | 2010-05-31 19:04:40 +0200 (Mon, 31 May 2010) | 9 lines
  
  Merged revisions 81621 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81621 | antoine.pitrou | 2010-05-31 19:01:01 +0200 (lun., 31 mai 2010) | 4 lines
    
    Improve documentation for getaddrinfo() (part of #8857)
  ........
................
  r81625 | alexander.belopolsky | 2010-05-31 19:33:47 +0200 (Mon, 31 May 2010) | 3 lines
  
  Issue #1289118: datetime.timedelta objects can now be multiplied by float
  and divided by float and int objects.
................
  r81628 | r.david.murray | 2010-06-01 01:23:50 +0200 (Tue, 01 Jun 2010) | 9 lines
  
  Merged revisions 81587 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81587 | r.david.murray | 2010-05-28 14:17:20 -0400 (Fri, 28 May 2010) | 2 lines
    
    Make the ctl-C shutdown of serve.py prettier.
  ........
................
  r81630 | r.david.murray | 2010-06-01 03:11:18 +0200 (Tue, 01 Jun 2010) | 9 lines
  
  Merged revisions 81586 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81586 | r.david.murray | 2010-05-28 14:08:11 -0400 (Fri, 28 May 2010) | 2 lines
    
    Make reference to Generic Attribute Management a hyperlink.
  ........
................
  r81632 | r.david.murray | 2010-06-01 03:32:12 +0200 (Tue, 01 Jun 2010) | 4 lines
  
  #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
  
  Patch by R. David Murray, unit tests by Shashwat Anand.
................
  r81638 | senthil.kumaran | 2010-06-01 14:53:48 +0200 (Tue, 01 Jun 2010) | 9 lines
  
  Merged revisions 81636 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81636 | senthil.kumaran | 2010-06-01 18:10:07 +0530 (Tue, 01 Jun 2010) | 3 lines
    
    Fix Issue8797 - urllib2 basic authentication fix for wrong passwords. It fails after 5 retries.
  ........
................
  r81642 | brian.curtin | 2010-06-01 15:49:19 +0200 (Tue, 01 Jun 2010) | 10 lines
  
  Merged revisions 81640 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81640 | brian.curtin | 2010-06-01 08:29:13 -0500 (Tue, 01 Jun 2010) | 3 lines
    
    Fix #8618. Ask the Windows mixer API if there are any playback devices
    configured before attempting to test PlaySound.
  ........
................
  r81647 | senthil.kumaran | 2010-06-02 04:29:00 +0200 (Wed, 02 Jun 2010) | 9 lines
  
  Merged revisions 81645 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81645 | senthil.kumaran | 2010-06-02 07:49:15 +0530 (Wed, 02 Jun 2010) | 3 lines
    
    Fix issue8788 - description of doseq parameter in urllib.urlencode
  ........
................
  r81650 | ronald.oussoren | 2010-06-02 05:50:56 +0200 (Wed, 02 Jun 2010) | 11 lines
  
  Merged revisions 81649 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81649 | ronald.oussoren | 2010-06-02 05:47:14 +0200 (Wed, 02 Jun 2010) | 5 lines
    
    Fix for issue8868: without this patch 'MacOS.WMAvailable()' will return
    False on MacOSX 10.5 or earlier and scripts won't be able to access GUI
    functionality.
  ........
................
  r81654 | antoine.pitrou | 2010-06-02 19:10:49 +0200 (Wed, 02 Jun 2010) | 10 lines
  
  Merged revisions 81652 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81652 | antoine.pitrou | 2010-06-02 19:08:47 +0200 (mer., 02 juin 2010) | 4 lines
    
    Issue #8873: add a documentation note about possible performance issues with the
    default of unbuffered IO in subprocess.Popen.
  ........
................
  r81656 | benjamin.peterson | 2010-06-02 20:10:09 +0200 (Wed, 02 Jun 2010) | 1 line
  
  remove description of LOAD_LOCALS #8874
................
  r81660 | r.david.murray | 2010-06-03 03:58:28 +0200 (Thu, 03 Jun 2010) | 25 lines
  
  Fix Charset.body_encode to encode to output_charset before calling base64mime.
  
  This means that what gets encoded in base64 is the encoded version of the
  unicode payload.  This bug was revealed by a forward port of the tests from
  Issue 1368247, but the fix was completely different.
  
  Note that the merge is only of the tests, the doc changes were inappropriate
  since email5 expects unicode, not bytes.  I'm also not convinced that
  quopri works correctly in email5, but that's a different issue.
  
  Merged revisions 81658 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81658 | r.david.murray | 2010-06-02 18:03:15 -0400 (Wed, 02 Jun 2010) | 9 lines
    
    #1368247: make set_charset/MIMEText automatically encode unicode _payload.
    
    Fixes (mysterious, to the end user) UnicodeErrors when using utf-8 as
    the charset and unicode as the _text argument.  Also makes the way in
    which unicode gets encoded to quoted printable for other charsets more
    sane (it only worked by accident previously).  The _payload now is encoded
    to the charset.output_charset if it is unicode.
  ........
................
  r81665 | lars.gustaebel | 2010-06-03 12:11:52 +0200 (Thu, 03 Jun 2010) | 11 lines
  
  Merged revisions 81663 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81663 | lars.gustaebel | 2010-06-03 11:56:22 +0200 (Thu, 03 Jun 2010) | 4 lines
    
    Issue #8833: tarfile created hard link entries with a size
    field != 0 by mistake. The associated testcase did not
    expose this bug because it was broken too.
  ........
................
  r81670 | lars.gustaebel | 2010-06-03 14:45:16 +0200 (Thu, 03 Jun 2010) | 14 lines
  
  Merged revisions 81667 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81667 | lars.gustaebel | 2010-06-03 14:34:14 +0200 (Thu, 03 Jun 2010) | 8 lines
    
    Issue #8741: Fixed the TarFile.makelink() method that is responsible
    for extracting symbolic and hard link entries as regular files as a
    work-around on platforms that do not support filesystem links.
    
    This stopped working reliably after a change in r74571. I also added
    a few tests for this functionality.
  ........
................
  r81673 | ronald.oussoren | 2010-06-03 16:42:25 +0200 (Thu, 03 Jun 2010) | 16 lines
  
  Merged revisions 81662 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81662 | ronald.oussoren | 2010-06-03 11:47:21 +0200 (Thu, 03 Jun 2010) | 9 lines
    
    Fix for issue #7724: ensure that distutils and python's own setup.py
    honor the MacOSX SDK when one is specified.
    
    This is needed to be able to build using the 10.4u SDK while running
    on OSX 10.6.
    
    This is a fixed version of the patch in r80963, I've tested this patch
    on OSX and Linux.
  ........
................
  r81682 | sean.reifschneider | 2010-06-04 03:51:38 +0200 (Fri, 04 Jun 2010) | 2 lines
  
  Issue8810: Clearing up docstring for tzinfo.utcoffset.
................
  r81685 | r.david.murray | 2010-06-04 18:11:08 +0200 (Fri, 04 Jun 2010) | 4 lines
  
  #4768: store base64 encoded email body parts as text, not binary.
  
  Patch and tests by Forest Bond.
................
  r81689 | senthil.kumaran | 2010-06-04 18:38:00 +0200 (Fri, 04 Jun 2010) | 9 lines
  
  Merged revisions 81687 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81687 | senthil.kumaran | 2010-06-04 22:02:14 +0530 (Fri, 04 Jun 2010) | 3 lines
    
    Fix issue6312 - close the resp object for HEAD response.
  ........
................
  r81694 | martin.v.loewis | 2010-06-04 19:20:56 +0200 (Fri, 04 Jun 2010) | 10 lines
  
  Merged revisions 81692 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81692 | martin.v.loewis | 2010-06-04 19:18:42 +0200 (Fr, 04 Jun 2010) | 3 lines
    
    Issue #8864: Define _XOPEN_SOURCE on Solaris for the 
    multiprocessing module.
  ........
................
  r81695 | senthil.kumaran | 2010-06-04 19:27:11 +0200 (Fri, 04 Jun 2010) | 9 lines
  
  Merged revisions 81691 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81691 | senthil.kumaran | 2010-06-04 22:47:09 +0530 (Fri, 04 Jun 2010) | 3 lines
    
    test verifying the resp object is closed for HEAD response.
  ........
................
  r81698 | martin.v.loewis | 2010-06-04 20:14:42 +0200 (Fri, 04 Jun 2010) | 9 lines
  
  Merged revisions 81697 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81697 | martin.v.loewis | 2010-06-04 20:04:42 +0200 (Fr, 04 Jun 2010) | 2 lines
    
    Issue #5464: Implement plural forms in msgfmt.py.
  ........
................
  r81699 | martin.v.loewis | 2010-06-04 20:40:55 +0200 (Fri, 04 Jun 2010) | 2 lines
  
  Port to Python 3.
................
  r81703 | martin.v.loewis | 2010-06-04 21:50:26 +0200 (Fri, 04 Jun 2010) | 10 lines
  
  Merged revisions 81701 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81701 | martin.v.loewis | 2010-06-04 21:39:07 +0200 (Fr, 04 Jun 2010) | 2 lines
    
    Issue #6470: Drop UNC prefix in FixTk.py
    Patch by Christop Gohlke and Amaury Forgeot d'Arc.
  ........
................
  r81708 | benjamin.peterson | 2010-06-05 02:45:37 +0200 (Sat, 05 Jun 2010) | 13 lines
  
  Merged revisions 81706-81707 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81706 | benjamin.peterson | 2010-06-04 19:32:50 -0500 (Fri, 04 Jun 2010) | 1 line
    
    properly lookup the __format__ special method
  ........
    r81707 | benjamin.peterson | 2010-06-04 19:38:22 -0500 (Fri, 04 Jun 2010) | 1 line
    
    remove PyType_Ready call; float should be initialized in interpreter startup
  ........
................
  r81711 | benjamin.peterson | 2010-06-05 03:03:24 +0200 (Sat, 05 Jun 2010) | 13 lines
  
  Merged revisions 81709-81710 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81709 | benjamin.peterson | 2010-06-04 19:56:46 -0500 (Fri, 04 Jun 2010) | 1 line
    
    implement object.__format__ with PyObject_Format
  ........
    r81710 | benjamin.peterson | 2010-06-04 20:00:10 -0500 (Fri, 04 Jun 2010) | 1 line
    
    fix ref counting
  ........
................
  r81713 | benjamin.peterson | 2010-06-05 04:11:45 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81712 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81712 | benjamin.peterson | 2010-06-04 21:07:01 -0500 (Fri, 04 Jun 2010) | 1 line
    
    _PyObject_LookupSpecial returns a new reference
  ........
................
  r81725 | michael.foord | 2010-06-05 12:45:41 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81724 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81724 | michael.foord | 2010-06-05 11:39:42 +0100 (Sat, 05 Jun 2010) | 1 line
    
    unittest TestLoader test discovery filename matching done in a method. This makes it easier to override the matching strategy in subclasses. No behaviour change in actual implementation.
  ........
................
  r81730 | michael.foord | 2010-06-05 13:27:52 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81728 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81728 | michael.foord | 2010-06-05 12:23:51 +0100 (Sat, 05 Jun 2010) | 1 line
    
    Issue 8351. Suppress large diffs in unittest.TestCase.assertSequenceEqual.
  ........
................
  r81731 | michael.foord | 2010-06-05 13:30:23 +0200 (Sat, 05 Jun 2010) | 1 line
  
  Test fix to use floor division. Correction from merge in previous commit.
................
  r81737 | mark.dickinson | 2010-06-05 13:53:11 +0200 (Sat, 05 Jun 2010) | 8 lines
  
  Blocked revisions 81736 via svnmerge
  
  ........
    r81736 | mark.dickinson | 2010-06-05 12:52:24 +0100 (Sat, 05 Jun 2010) | 1 line
    
    Issue #8627: remove out-of-date warning about overriding __cmp__
  ........
................
  r81742 | michael.foord | 2010-06-05 14:17:02 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81739 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81739 | michael.foord | 2010-06-05 13:10:52 +0100 (Sat, 05 Jun 2010) | 1 line
    
    Removed the new max_diff argument to assertSequenceEqual. All unittest.TestCase assert methods that use difflib to produce failure messages now truncate overly long messages. New class attribute unittest.TestCase.maxDiff to configure this if necessary. Issue 8351.
  ........
................
  r81743 | mark.dickinson | 2010-06-05 14:38:00 +0200 (Sat, 05 Jun 2010) | 10 lines
  
  Blocked revisions 81740 via svnmerge
  
  ........
    r81740 | mark.dickinson | 2010-06-05 13:14:43 +0100 (Sat, 05 Jun 2010) | 5 lines
    
    Issue #8627: Fix "XXX undetected error" from unchecked PyErr_WarnPy3k return.
    This is just a quick fix:  if the warning is turned into an exception, the
    exception simply gets ignored.
  ........
................
  r81746 | mark.dickinson | 2010-06-05 14:52:23 +0200 (Sat, 05 Jun 2010) | 8 lines
  
  Blocked revisions 81744 via svnmerge
  
  ........
    r81744 | mark.dickinson | 2010-06-05 13:51:21 +0100 (Sat, 05 Jun 2010) | 1 line
    
    Fix comment typo.
  ........
................
  r81748 | michael.foord | 2010-06-05 15:14:43 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81747 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81747 | michael.foord | 2010-06-05 13:58:39 +0100 (Sat, 05 Jun 2010) | 1 line
    
    unittest.TestCase.assertDictEqual and assertMultilineEqual provide better default failure messages in the event of long diffs.
  ........
................
  r81751 | mark.dickinson | 2010-06-05 15:27:17 +0200 (Sat, 05 Jun 2010) | 8 lines
  
  Blocked revisions 81749 via svnmerge
  
  ........
    r81749 | mark.dickinson | 2010-06-05 14:18:33 +0100 (Sat, 05 Jun 2010) | 2 lines
    
    Fix test_py3kwarn not to test for __cmp__-related DeprecationWarning.
  ........
................
  r81754 | michael.foord | 2010-06-05 15:49:56 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81752 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81752 | michael.foord | 2010-06-05 14:38:16 +0100 (Sat, 05 Jun 2010) | 1 line
    
    unittest.TestCase assertion methods inform you when they have omitted an over long diff on failure. Issue 8351.
  ........
................
  r81755 | michael.foord | 2010-06-05 15:57:23 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81753 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81753 | michael.foord | 2010-06-05 14:48:27 +0100 (Sat, 05 Jun 2010) | 1 line
    
    Fix unittest tests after previous commit.
  ........
................
  r81757 | alexander.belopolsky | 2010-06-05 17:04:51 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81756 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81756 | alexander.belopolsky | 2010-06-05 10:54:26 -0400 (Sat, 05 Jun 2010) | 1 line
    
    Issue #8899: time.struct_time now has class and atribute docstrings.
  ........
................
  r81762 | michael.foord | 2010-06-05 21:58:25 +0200 (Sat, 05 Jun 2010) | 8 lines
  
  Blocked revisions 81761 via svnmerge
  
  ........
    r81761 | michael.foord | 2010-06-05 20:51:38 +0100 (Sat, 05 Jun 2010) | 1 line
    
    Updated NEWS file.
  ........
................
  r81765 | michael.foord | 2010-06-05 23:01:08 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81763 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81763 | michael.foord | 2010-06-05 21:33:43 +0100 (Sat, 05 Jun 2010) | 1 line
    
    Tests for unittest.TestCase.maxDiff.
  ........
................
  r81766 | michael.foord | 2010-06-05 23:12:23 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81764 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81764 | michael.foord | 2010-06-05 21:59:00 +0100 (Sat, 05 Jun 2010) | 1 line
    
    Tests for issue 8302, skipped test in a setUpClass or a setUpModule are reported as skips rather than errors.
  ........
................
  r81768 | michael.foord | 2010-06-05 23:59:55 +0200 (Sat, 05 Jun 2010) | 9 lines
  
  Merged revisions 81767 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81767 | michael.foord | 2010-06-05 22:57:03 +0100 (Sat, 05 Jun 2010) | 1 line
    
    Documentation updates for issues 8302 and 8351 (truncating excessive diffs in unittest failure messages and reporting SkipTest exceptions in setUpClass and setUpModule as skips rather than errors).
  ........
................
  r81771 | michael.foord | 2010-06-06 01:59:34 +0200 (Sun, 06 Jun 2010) | 9 lines
  
  Merged revisions 81770 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81770 | michael.foord | 2010-06-06 00:58:40 +0100 (Sun, 06 Jun 2010) | 1 line
    
    Code formatting change.
  ........
................
  r81778 | benjamin.peterson | 2010-06-06 04:14:27 +0200 (Sun, 06 Jun 2010) | 16 lines
  
  Blocked revisions 81772-81773,81777 via svnmerge
  
  ........
    r81772 | benjamin.peterson | 2010-06-05 19:22:09 -0500 (Sat, 05 Jun 2010) | 1 line
    
    bump version to 2.7 rc1
  ........
    r81773 | benjamin.peterson | 2010-06-05 19:49:27 -0500 (Sat, 05 Jun 2010) | 1 line
    
    update pydoc-topics
  ........
    r81777 | benjamin.peterson | 2010-06-05 21:09:33 -0500 (Sat, 05 Jun 2010) | 1 line
    
    careening towards 2.7rc2 we go
  ........
................
  r81779 | benjamin.peterson | 2010-06-06 04:32:09 +0200 (Sun, 06 Jun 2010) | 13 lines
  
  Merged revisions 81774-81775 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81774 | benjamin.peterson | 2010-06-05 19:50:58 -0500 (Sat, 05 Jun 2010) | 1 line
    
    remove extra space
  ........
    r81775 | benjamin.peterson | 2010-06-05 19:54:29 -0500 (Sat, 05 Jun 2010) | 1 line
    
    fix sphinx warning with an extra space
  ........
................
  r81780 | benjamin.peterson | 2010-06-06 04:40:38 +0200 (Sun, 06 Jun 2010) | 1 line
  
  fix typo
................
  r81781 | benjamin.peterson | 2010-06-06 04:41:24 +0200 (Sun, 06 Jun 2010) | 1 line
  
  reST indentation nit
................
  r81782 | benjamin.peterson | 2010-06-06 04:44:41 +0200 (Sun, 06 Jun 2010) | 1 line
  
  bltn-file-objects don't exist in python3
................
  r81790 | tarek.ziade | 2010-06-06 22:18:42 +0200 (Sun, 06 Jun 2010) | 9 lines
  
  Merged revisions 81788 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81788 | tarek.ziade | 2010-06-06 22:05:20 +0200 (Sun, 06 Jun 2010) | 1 line
    
    Fixed #8909: now the doc details the size of the bitmap used in distutils' bdist_wininst
  ........
................
  r81792 | victor.stinner | 2010-06-06 22:27:51 +0200 (Sun, 06 Jun 2010) | 2 lines
  
  Simplify getbuffer(): convertbuffer() fails anyway if bf_getbuffer is NULL
................
  r81794 | victor.stinner | 2010-06-06 22:38:02 +0200 (Sun, 06 Jun 2010) | 4 lines
  
  convertsimple(): call PyErr_NoMemory() on PyMem_NEW() failure
  
  Raise a more revelant error (MemoryError instead of TypeError)
................


Added:
   python/branches/py3k-cdecimal/Doc/howto/descriptor.rst
      - copied unchanged from r81794, /python/branches/py3k/Doc/howto/descriptor.rst
   python/branches/py3k-cdecimal/Lib/distutils/tests/test_log.py
      - copied unchanged from r81794, /python/branches/py3k/Lib/distutils/tests/test_log.py
   python/branches/py3k-cdecimal/Lib/test/test_numeric_tower.py
      - copied unchanged from r81794, /python/branches/py3k/Lib/test/test_numeric_tower.py
Modified:
   python/branches/py3k-cdecimal/   (props changed)
   python/branches/py3k-cdecimal/Doc/c-api/init.rst
   python/branches/py3k-cdecimal/Doc/c-api/sys.rst
   python/branches/py3k-cdecimal/Doc/distutils/builtdist.rst
   python/branches/py3k-cdecimal/Doc/extending/newtypes.rst
   python/branches/py3k-cdecimal/Doc/howto/index.rst
   python/branches/py3k-cdecimal/Doc/library/argparse.rst
   python/branches/py3k-cdecimal/Doc/library/datetime.rst
   python/branches/py3k-cdecimal/Doc/library/decimal.rst
   python/branches/py3k-cdecimal/Doc/library/dis.rst
   python/branches/py3k-cdecimal/Doc/library/fcntl.rst
   python/branches/py3k-cdecimal/Doc/library/ftplib.rst
   python/branches/py3k-cdecimal/Doc/library/functions.rst
   python/branches/py3k-cdecimal/Doc/library/getopt.rst
   python/branches/py3k-cdecimal/Doc/library/hashlib.rst
   python/branches/py3k-cdecimal/Doc/library/io.rst
   python/branches/py3k-cdecimal/Doc/library/json.rst
   python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst
   python/branches/py3k-cdecimal/Doc/library/optparse.rst
   python/branches/py3k-cdecimal/Doc/library/os.rst
   python/branches/py3k-cdecimal/Doc/library/socket.rst
   python/branches/py3k-cdecimal/Doc/library/sqlite3.rst
   python/branches/py3k-cdecimal/Doc/library/ssl.rst
   python/branches/py3k-cdecimal/Doc/library/stdtypes.rst
   python/branches/py3k-cdecimal/Doc/library/subprocess.rst
   python/branches/py3k-cdecimal/Doc/library/symtable.rst
   python/branches/py3k-cdecimal/Doc/library/sys.rst
   python/branches/py3k-cdecimal/Doc/library/sysconfig.rst
   python/branches/py3k-cdecimal/Doc/library/syslog.rst
   python/branches/py3k-cdecimal/Doc/library/telnetlib.rst
   python/branches/py3k-cdecimal/Doc/library/tempfile.rst
   python/branches/py3k-cdecimal/Doc/library/time.rst
   python/branches/py3k-cdecimal/Doc/library/unittest.rst
   python/branches/py3k-cdecimal/Doc/library/urllib.parse.rst
   python/branches/py3k-cdecimal/Doc/library/urllib.request.rst
   python/branches/py3k-cdecimal/Doc/library/winreg.rst
   python/branches/py3k-cdecimal/Doc/reference/datamodel.rst
   python/branches/py3k-cdecimal/Doc/tools/sphinxext/pyspecific.py
   python/branches/py3k-cdecimal/Doc/tutorial/datastructures.rst
   python/branches/py3k-cdecimal/Doc/whatsnew/3.2.rst
   python/branches/py3k-cdecimal/Include/longobject.h
   python/branches/py3k-cdecimal/Include/pyport.h
   python/branches/py3k-cdecimal/Include/sysmodule.h
   python/branches/py3k-cdecimal/Lib/_abcoll.py
   python/branches/py3k-cdecimal/Lib/argparse.py
   python/branches/py3k-cdecimal/Lib/base64.py
   python/branches/py3k-cdecimal/Lib/codecs.py
   python/branches/py3k-cdecimal/Lib/decimal.py
   python/branches/py3k-cdecimal/Lib/distutils/log.py
   python/branches/py3k-cdecimal/Lib/distutils/unixccompiler.py
   python/branches/py3k-cdecimal/Lib/email/charset.py
   python/branches/py3k-cdecimal/Lib/email/encoders.py
   python/branches/py3k-cdecimal/Lib/email/test/test_email.py
   python/branches/py3k-cdecimal/Lib/encodings/utf_16.py
   python/branches/py3k-cdecimal/Lib/encodings/utf_32.py
   python/branches/py3k-cdecimal/Lib/fractions.py
   python/branches/py3k-cdecimal/Lib/ftplib.py
   python/branches/py3k-cdecimal/Lib/functools.py
   python/branches/py3k-cdecimal/Lib/html/parser.py
   python/branches/py3k-cdecimal/Lib/http/client.py
   python/branches/py3k-cdecimal/Lib/lib2to3/refactor.py
   python/branches/py3k-cdecimal/Lib/linecache.py
   python/branches/py3k-cdecimal/Lib/pipes.py
   python/branches/py3k-cdecimal/Lib/sqlite3/test/dbapi.py
   python/branches/py3k-cdecimal/Lib/ssl.py
   python/branches/py3k-cdecimal/Lib/subprocess.py
   python/branches/py3k-cdecimal/Lib/sysconfig.py
   python/branches/py3k-cdecimal/Lib/tabnanny.py
   python/branches/py3k-cdecimal/Lib/tarfile.py
   python/branches/py3k-cdecimal/Lib/test/regrtest.py
   python/branches/py3k-cdecimal/Lib/test/test_argparse.py
   python/branches/py3k-cdecimal/Lib/test/test_base64.py
   python/branches/py3k-cdecimal/Lib/test/test_builtin.py
   python/branches/py3k-cdecimal/Lib/test/test_codecs.py
   python/branches/py3k-cdecimal/Lib/test/test_collections.py
   python/branches/py3k-cdecimal/Lib/test/test_complex.py
   python/branches/py3k-cdecimal/Lib/test/test_datetime.py
   python/branches/py3k-cdecimal/Lib/test/test_decimal.py
   python/branches/py3k-cdecimal/Lib/test/test_descr.py
   python/branches/py3k-cdecimal/Lib/test/test_enumerate.py
   python/branches/py3k-cdecimal/Lib/test/test_float.py
   python/branches/py3k-cdecimal/Lib/test/test_ftplib.py
   python/branches/py3k-cdecimal/Lib/test/test_gdb.py
   python/branches/py3k-cdecimal/Lib/test/test_htmlparser.py
   python/branches/py3k-cdecimal/Lib/test/test_httplib.py
   python/branches/py3k-cdecimal/Lib/test/test_linecache.py
   python/branches/py3k-cdecimal/Lib/test/test_long.py
   python/branches/py3k-cdecimal/Lib/test/test_os.py
   python/branches/py3k-cdecimal/Lib/test/test_pipes.py
   python/branches/py3k-cdecimal/Lib/test/test_socketserver.py
   python/branches/py3k-cdecimal/Lib/test/test_ssl.py
   python/branches/py3k-cdecimal/Lib/test/test_subprocess.py
   python/branches/py3k-cdecimal/Lib/test/test_sys.py
   python/branches/py3k-cdecimal/Lib/test/test_sysconfig.py
   python/branches/py3k-cdecimal/Lib/test/test_tarfile.py
   python/branches/py3k-cdecimal/Lib/test/test_tcl.py
   python/branches/py3k-cdecimal/Lib/test/test_urllib2.py
   python/branches/py3k-cdecimal/Lib/test/test_warnings.py
   python/branches/py3k-cdecimal/Lib/test/test_winreg.py
   python/branches/py3k-cdecimal/Lib/test/test_winsound.py
   python/branches/py3k-cdecimal/Lib/test/testtar.tar
   python/branches/py3k-cdecimal/Lib/tkinter/_fix.py
   python/branches/py3k-cdecimal/Lib/unittest/case.py
   python/branches/py3k-cdecimal/Lib/unittest/loader.py
   python/branches/py3k-cdecimal/Lib/unittest/suite.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_case.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_setups.py
   python/branches/py3k-cdecimal/Lib/unittest/util.py
   python/branches/py3k-cdecimal/Lib/urllib/request.py
   python/branches/py3k-cdecimal/Lib/webbrowser.py
   python/branches/py3k-cdecimal/Mac/Tools/pythonw.c
   python/branches/py3k-cdecimal/Misc/ACKS
   python/branches/py3k-cdecimal/Misc/NEWS
   python/branches/py3k-cdecimal/Misc/developers.txt
   python/branches/py3k-cdecimal/Modules/_multiprocessing/multiprocessing.h
   python/branches/py3k-cdecimal/Modules/_sqlite/connection.c
   python/branches/py3k-cdecimal/Modules/_ssl.c
   python/branches/py3k-cdecimal/Modules/config.c.in
   python/branches/py3k-cdecimal/Modules/datetimemodule.c
   python/branches/py3k-cdecimal/Modules/main.c
   python/branches/py3k-cdecimal/Modules/timemodule.c
   python/branches/py3k-cdecimal/Objects/abstract.c
   python/branches/py3k-cdecimal/Objects/complexobject.c
   python/branches/py3k-cdecimal/Objects/longobject.c
   python/branches/py3k-cdecimal/Objects/object.c
   python/branches/py3k-cdecimal/Objects/typeobject.c
   python/branches/py3k-cdecimal/PC/winreg.c
   python/branches/py3k-cdecimal/Python/_warnings.c
   python/branches/py3k-cdecimal/Python/ceval.c
   python/branches/py3k-cdecimal/Python/getargs.c
   python/branches/py3k-cdecimal/Python/pythonrun.c
   python/branches/py3k-cdecimal/Python/sysmodule.c
   python/branches/py3k-cdecimal/Tools/gdb/libpython.py
   python/branches/py3k-cdecimal/Tools/i18n/msgfmt.py
   python/branches/py3k-cdecimal/Tools/scripts/serve.py
   python/branches/py3k-cdecimal/configure
   python/branches/py3k-cdecimal/configure.in
   python/branches/py3k-cdecimal/setup.py

Modified: python/branches/py3k-cdecimal/Doc/c-api/init.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/init.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/init.rst	Mon Jun  7 12:46:02 2010
@@ -22,6 +22,7 @@
       module: sys
       triple: module; search; path
       single: PySys_SetArgv()
+      single: PySys_SetArgvEx()
       single: Py_Finalize()
 
    Initialize the Python interpreter.  In an application embedding  Python, this
@@ -31,7 +32,7 @@
    the table of loaded modules (``sys.modules``), and creates the fundamental
    modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`.  It also initializes
    the module search path (``sys.path``). It does not set ``sys.argv``; use
-   :cfunc:`PySys_SetArgv` for that.  This is a no-op when called for a second time
+   :cfunc:`PySys_SetArgvEx` for that.  This is a no-op when called for a second time
    (without calling :cfunc:`Py_Finalize` first).  There is no return value; it is a
    fatal error if the initialization fails.
 
@@ -337,7 +338,7 @@
    ``sys.version``.
 
 
-.. cfunction:: void PySys_SetArgv(int argc, wchar_t **argv)
+.. cfunction:: void PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
 
    .. index::
       single: main()
@@ -352,14 +353,41 @@
    string.  If this function fails to initialize :data:`sys.argv`, a fatal
    condition is signalled using :cfunc:`Py_FatalError`.
 
-   This function also prepends the executed script's path to :data:`sys.path`.
-   If no script is executed (in the case of calling ``python -c`` or just the
-   interactive interpreter), the empty string is used instead.
+   If *updatepath* is zero, this is all the function does.  If *updatepath*
+   is non-zero, the function also modifies :data:`sys.path` according to the
+   following algorithm:
+
+   - If the name of an existing script is passed in ``argv[0]``, the absolute
+     path of the directory where the script is located is prepended to
+     :data:`sys.path`.
+   - Otherwise (that is, if *argc* is 0 or ``argv[0]`` doesn't point
+     to an existing file name), an empty string is prepended to
+     :data:`sys.path`, which is the same as prepending the current working
+     directory (``"."``).
+
+   .. note::
+      It is recommended that applications embedding the Python interpreter
+      for purposes other than executing a single script pass 0 as *updatepath*,
+      and update :data:`sys.path` themselves if desired.
+      See `CVE-2008-5983 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
+
+      On versions before 3.1.3, you can achieve the same effect by manually
+      popping the first :data:`sys.path` element after having called
+      :cfunc:`PySys_SetArgv`, for example using::
+
+         PyRun_SimpleString("import sys; sys.path.pop(0)\n");
+
+   .. versionadded:: 3.1.3
 
    .. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
       check w/ Guido.
 
 
+.. cfunction:: void PySys_SetArgv(int argc, wchar_t **argv)
+
+   This function works like :cfunc:`PySys_SetArgv` with *updatepath* set to 1.
+
+
 .. cfunction:: void Py_SetPythonHome(wchar_t *home)
 
    Set the default "home" directory, that is, the location of the standard

Modified: python/branches/py3k-cdecimal/Doc/c-api/sys.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/sys.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/sys.rst	Mon Jun  7 12:46:02 2010
@@ -81,6 +81,10 @@
 
    Append *s* to :data:`sys.warnoptions`.
 
+.. cfunction:: void PySys_AddWarnOptionUnicode(PyObject *unicode)
+
+   Append *unicode* to :data:`sys.warnoptions`.
+
 .. cfunction:: void PySys_SetPath(wchar_t *path)
 
    Set :data:`sys.path` to a list object of paths found in *path* which should

Modified: python/branches/py3k-cdecimal/Doc/distutils/builtdist.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/distutils/builtdist.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/distutils/builtdist.rst	Mon Jun  7 12:46:02 2010
@@ -322,7 +322,7 @@
 option.
 
 By default the installer will display the cool "Python Powered" logo when it is
-run, but you can also supply your own bitmap which must be a Windows
+run, but you can also supply your own 152x161 bitmap which must be a Windows
 :file:`.bmp` file with the :option:`--bitmap` option.
 
 The installer will also display a large title on the desktop background window

Modified: python/branches/py3k-cdecimal/Doc/extending/newtypes.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/extending/newtypes.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/extending/newtypes.rst	Mon Jun  7 12:46:02 2010
@@ -430,7 +430,7 @@
    Noddy_members,             /* tp_members */
 
 Each member definition has a member name, type, offset, access flags and
-documentation string. See the "Generic Attribute Management" section below for
+documentation string. See the :ref:`Generic-Attribute-Management` section below for
 details.
 
 A disadvantage of this approach is that it doesn't provide a way to restrict the
@@ -1078,6 +1078,8 @@
 not been updated to use some of the new generic mechanism that is available.
 
 
+.. _generic-attribute-management:
+
 Generic Attribute Management
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

Modified: python/branches/py3k-cdecimal/Doc/howto/index.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/howto/index.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/howto/index.rst	Mon Jun  7 12:46:02 2010
@@ -16,6 +16,7 @@
    advocacy.rst
    cporting.rst
    curses.rst
+   descriptor.rst
    doanddont.rst
    functional.rst
    regex.rst

Modified: python/branches/py3k-cdecimal/Doc/library/argparse.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/argparse.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/argparse.rst	Mon Jun  7 12:46:02 2010
@@ -452,7 +452,7 @@
 
 By default, :class:`ArgumentParser` objects uses ``sys.argv[0]`` to determine
 how to display the name of the program in help messages.  This default is almost
-always desirable because it will make the help messages match how the pgoram was
+always desirable because it will make the help messages match how the program was
 invoked on the command line.  For example, consider a file named
 ``myprogram.py`` with the following code::
 
@@ -672,8 +672,8 @@
 
     >>> import argparse
     >>> parser = argparse.ArgumentParser(prog='PROG')
-    >>> parser.add_argument('-v', '--version', action='version', version='%(prog)s 2.0')
-    >>> parser.parse_args(['-v'])
+    >>> parser.add_argument('--version', action='version', version='%(prog)s 2.0')
+    >>> parser.parse_args(['--version'])
     PROG 2.0
 
 You can also specify an arbitrary action by passing an object that implements
@@ -1725,3 +1725,6 @@
 * Replace strings with implicit arguments such as ``%default`` or ``%prog`` with
   the standard python syntax to use dictionaries to format strings, that is,
   ``%(default)s`` and ``%(prog)s``.
+
+* Replace the OptionParser constructor ``version`` argument with a call to
+  ``parser.add_argument('--version', action='version', version='<the version>')``

Modified: python/branches/py3k-cdecimal/Doc/library/datetime.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/datetime.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/datetime.rst	Mon Jun  7 12:46:02 2010
@@ -220,12 +220,20 @@
 |                                | In general, *t1* \* i == *t1* \* (i-1) + *t1* |
 |                                | is true. (1)                                  |
 +--------------------------------+-----------------------------------------------+
+| ``t1 = t2 * f or t1 = f * t2`` | Delta multiplied by a float. The result is    |
+|                                | rounded to the nearest multiple of            |
+|                                | timedelta.resolution using round-half-to-even.|
++--------------------------------+-----------------------------------------------+
 | ``f = t2 / t3``                | Division (3) of *t2* by *t3*.  Returns a      |
 |                                | :class:`float` object.                        |
 +--------------------------------+-----------------------------------------------+
+| ``t1 = t2 / f or t1 = t2 / i`` | Delta divided by a float or an int. The result|
+|                                | is rounded to the nearest multiple of         |
+|                                | timedelta.resolution using round-half-to-even.|
++--------------------------------+-----------------------------------------------+
 | ``t1 = t2 // i`` or            | The floor is computed and the remainder (if   |
 | ``t1 = t2 // t3``              | any) is thrown away.  In the second case, an  |
-|                                | integer is returned (3)                       |
+|                                | integer is returned. (3)                      |
 +--------------------------------+-----------------------------------------------+
 | ``t1 = t2 % t3``               | The remainder is computed as a                |
 |                                | :class:`timedelta` object. (3)                |
@@ -267,7 +275,9 @@
 .. versionadded:: 3.2
    Floor division and true division of a :class:`timedelta` object by
    another :class:`timedelta` object are now supported, as are
-   remainder operations and the :func:`divmod` function.
+   remainder operations and the :func:`divmod` function.  True
+   division and multiplication of a :class:`timedelta` object by
+   a :class:`float` object are now supported.
 
 
 Comparisons of :class:`timedelta` objects are supported with the

Modified: python/branches/py3k-cdecimal/Doc/library/decimal.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/decimal.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/decimal.rst	Mon Jun  7 12:46:02 2010
@@ -122,7 +122,7 @@
    >>> from decimal import *
    >>> getcontext()
    Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999,
-           capitals=1, flags=[], traps=[Overflow, DivisionByZero,
+           capitals=1, clamp=0, flags=[], traps=[Overflow, DivisionByZero,
            InvalidOperation])
 
    >>> getcontext().prec = 7       # Set a new precision
@@ -244,7 +244,7 @@
 
    >>> ExtendedContext
    Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999,
-           capitals=1, flags=[], traps=[])
+           capitals=1, clamp=0, flags=[], traps=[])
    >>> setcontext(ExtendedContext)
    >>> Decimal(1) / Decimal(7)
    Decimal('0.142857143')
@@ -269,7 +269,7 @@
    Decimal('3.14159292')
    >>> getcontext()
    Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999,
-           capitals=1, flags=[Inexact, Rounded], traps=[])
+           capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[])
 
 The *flags* entry shows that the rational approximation to :const:`Pi` was
 rounded (digits beyond the context precision were thrown away) and that the
@@ -874,7 +874,7 @@
 
    This context is used by the :class:`Context` constructor as a prototype for new
    contexts.  Changing a field (such a precision) has the effect of changing the
-   default for new contexts creating by the :class:`Context` constructor.
+   default for new contexts created by the :class:`Context` constructor.
 
    This context is most useful in multi-threaded environments.  Changing one of the
    fields before threads are started has the effect of setting system-wide
@@ -891,7 +891,7 @@
 :class:`Context` constructor.
 
 
-.. class:: Context(prec=None, rounding=None, traps=None, flags=None, Emin=None, Emax=None, capitals=1)
+.. class:: Context(prec=None, rounding=None, traps=None, flags=None, Emin=None, Emax=None, capitals=None, clamp=None)
 
    Creates a new context.  If a field is not specified or is :const:`None`, the
    default values are copied from the :const:`DefaultContext`.  If the *flags*
@@ -922,6 +922,23 @@
    :const:`1`, exponents are printed with a capital :const:`E`; otherwise, a
    lowercase :const:`e` is used: :const:`Decimal('6.02e+23')`.
 
+   The *clamp* field is either :const:`0` (the default) or :const:`1`.
+   If set to :const:`1`, the exponent ``e`` of a :class:`Decimal`
+   instance representable in this context is strictly limited to the
+   range ``Emin - prec + 1 <= e <= Emax - prec + 1``.  If *clamp* is
+   :const:`0` then a weaker condition holds: the adjusted exponent of
+   the :class:`Decimal` instance is at most ``Emax``.  When *clamp* is
+   :const:`1`, a large normal number will, where possible, have its
+   exponent reduced and a corresponding number of zeros added to its
+   coefficient, in order to fit the exponent constraints; this
+   preserves the value of the number but loses information about
+   significant trailing zeros.  For example::
+
+      >>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
+      Decimal('1.23000E+999')
+
+   A *clamp* value of :const:`1` allows compatibility with the
+   fixed-width decimal interchange formats specified in IEEE 754.
 
    The :class:`Context` class defines several general purpose methods as well as
    a large number of methods for doing arithmetic directly in a given context.

Modified: python/branches/py3k-cdecimal/Doc/library/dis.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/dis.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/dis.rst	Mon Jun  7 12:46:02 2010
@@ -383,13 +383,6 @@
 the stack so that it is available for further iterations of the loop.
 
 
-.. opcode:: LOAD_LOCALS ()
-
-   Pushes a reference to the locals of the current scope on the stack. This is used
-   in the code for a class definition: After the class body is evaluated, the
-   locals are passed to the class definition.
-
-
 .. opcode:: RETURN_VALUE ()
 
    Returns with TOS to the caller of the function.

Modified: python/branches/py3k-cdecimal/Doc/library/fcntl.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/fcntl.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/fcntl.rst	Mon Jun  7 12:46:02 2010
@@ -8,8 +8,8 @@
 
 
 .. index::
-   pair: UNIX at Unix; file control
-   pair: UNIX at Unix; I/O control
+   pair: UNIX; file control
+   pair: UNIX; I/O control
 
 This module performs file control and I/O control on file descriptors. It is an
 interface to the :cfunc:`fcntl` and :cfunc:`ioctl` Unix routines.

Modified: python/branches/py3k-cdecimal/Doc/library/ftplib.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/ftplib.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/ftplib.rst	Mon Jun  7 12:46:02 2010
@@ -65,7 +65,7 @@
       Support for the :keyword:`with` statement was added.
 
 
-.. class:: FTP_TLS(host='', user='', passwd='', acct='', [keyfile[, certfile[, timeout]]])
+.. class:: FTP_TLS(host='', user='', passwd='', acct='', [keyfile[, certfile[, context[, timeout]]]])
 
    A :class:`FTP` subclass which adds TLS support to FTP as described in
    :rfc:`4217`.
@@ -74,6 +74,9 @@
    explicitly ask for it by calling the :meth:`prot_p` method.
    *keyfile* and *certfile* are optional -- they can contain a PEM formatted
    private key and certificate chain file name for the SSL connection.
+   *context* parameter is a :class:`ssl.SSLContext` object which allows
+   bundling SSL configuration options, certificates and private keys into a
+   single (potentially long-lived) structure.
 
    .. versionadded:: 3.2
 
@@ -122,7 +125,7 @@
    The set of all exceptions (as a tuple) that methods of :class:`FTP`
    instances may raise as a result of problems with the FTP connection (as
    opposed to programming errors made by the caller).  This set includes the
-   four exceptions listed below as well as :exc:`socket.error` and
+   four exceptions listed above as well as :exc:`socket.error` and
    :exc:`IOError`.
 
 .. seealso::

Modified: python/branches/py3k-cdecimal/Doc/library/functions.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/functions.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/functions.rst	Mon Jun  7 12:46:02 2010
@@ -1227,7 +1227,7 @@
       True
 
 
-.. function:: __import__(name, globals={}, locals={}, fromlist=[], level=-1)
+.. function:: __import__(name, globals={}, locals={}, fromlist=[], level=0)
 
    .. index::
       statement: import

Modified: python/branches/py3k-cdecimal/Doc/library/getopt.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/getopt.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/getopt.rst	Mon Jun  7 12:46:02 2010
@@ -5,6 +5,12 @@
    :synopsis: Portable parser for command line options; support both short and
               long option names.
 
+.. note::
+   The :mod:`getopt` module is a parser for command line options whose API is
+   designed to be familiar to users of the C :cfunc:`getopt` function. Users who
+   are unfamiliar with the C :cfunc:`getopt` function or who would like to write
+   less code and get better help and error messages should consider using the
+   :mod:`argparse` module instead.
 
 This module helps scripts to parse the command line arguments in ``sys.argv``.
 It supports the same conventions as the Unix :cfunc:`getopt` function (including
@@ -136,9 +142,21 @@
    if __name__ == "__main__":
        main()
 
+Note that an equivalent command line interface could be produced with less code
+and more informative help and error messages by using the :mod:`argparse` module::
+
+   import argparse
+
+   if __name__ == '__main__':
+       parser = argparse.ArgumentParser()
+       parser.add_argument('-o', '--output')
+       parser.add_argument('-v', dest='verbose', action='store_true')
+       args = parser.parse_args()
+       # ... do something with args.output ...
+       # ... do something with args.verbose ..
 
 .. seealso::
 
-   Module :mod:`optparse`
-      More object-oriented command line option parsing.
+   Module :mod:`argparse`
+      Alternative command line option and argument parsing library.
 

Modified: python/branches/py3k-cdecimal/Doc/library/hashlib.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/hashlib.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/hashlib.rst	Mon Jun  7 12:46:02 2010
@@ -151,7 +151,7 @@
    http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
       The FIPS 180-2 publication on Secure Hash Algorithms.
 
-   http://www.cryptography.com/cnews/hash.html
-      Hash Collision FAQ with information on which algorithms have known issues and
+   http://en.wikipedia.org/wiki/Cryptographic_hash_function#Cryptographic_hash_algorithms
+      Wikipedia article with information on which algorithms have known issues and
       what that means regarding their use.
 

Modified: python/branches/py3k-cdecimal/Doc/library/io.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/io.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/io.rst	Mon Jun  7 12:46:02 2010
@@ -240,7 +240,7 @@
 
       Flush and close this stream. This method has no effect if the file is
       already closed. Once the file is closed, any operation on the file
-      (e.g. reading or writing) will raise an :exc:`ValueError`.
+      (e.g. reading or writing) will raise a :exc:`ValueError`.
 
       As a convenience, it is allowed to call this method more than once;
       only the first call, however, will have an effect.
@@ -314,10 +314,12 @@
 
    .. method:: truncate(size=None)
 
-      Truncate the file to at most *size* bytes.  *size* defaults to the current
-      file position, as returned by :meth:`tell`.  Note that the current file
-      position isn't changed; if you want to change it to the new end of
-      file, you have to :meth:`seek()` explicitly.
+      Resize the stream to the given *size* in bytes (or the current position
+      if *size* is not specified).  The current stream position isn't changed.
+      This resizing can extend or reduce the current file size.  In case of
+      extension, the contents of the new file area depend on the platform
+      (on most systems, additional bytes are zero-filled, on Windows they're
+      undetermined).  The new file size is returned.
 
    .. method:: writable()
 

Modified: python/branches/py3k-cdecimal/Doc/library/json.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/json.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/json.rst	Mon Jun  7 12:46:02 2010
@@ -209,7 +209,7 @@
    specified.  Encodings that are not ASCII based (such as UCS-2) are not
    allowed and should be decoded to :class:`str` first.
 
-   The other arguments have the same meaning as in :func:`dump`.
+   The other arguments have the same meaning as in :func:`load`.
 
 
 Encoders and decoders

Modified: python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst	Mon Jun  7 12:46:02 2010
@@ -837,7 +837,7 @@
 
    A bounded semaphore object: a clone of :class:`threading.BoundedSemaphore`.
 
-   (On Mac OS X this is indistinguishable from :class:`Semaphore` because
+   (On Mac OS X, this is indistinguishable from :class:`Semaphore` because
    ``sem_getvalue()`` is not implemented on that platform).
 
 .. class:: Condition([lock])
@@ -879,9 +879,8 @@
    specifies a timeout in seconds.  If *block* is ``False`` then *timeout* is
    ignored.
 
-.. note::
-   On OS/X ``sem_timedwait`` is unsupported, so timeout arguments for the
-   aforementioned :meth:`acquire` methods will be ignored on OS/X.
+   On Mac OS X, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with
+   a timeout will emulate that function's behavior using a sleeping loop.
 
 .. note::
 

Modified: python/branches/py3k-cdecimal/Doc/library/optparse.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/optparse.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/optparse.rst	Mon Jun  7 12:46:02 2010
@@ -3,6 +3,12 @@
 
 .. module:: optparse
    :synopsis: Command-line option parsing library.
+   :deprecated:
+
+.. deprecated:: 2.7
+   The :mod:`optparse` module is deprecated and will not be developed further;
+   development will continue with the :mod:`argparse` module.
+
 .. moduleauthor:: Greg Ward <gward at python.net>
 .. sectionauthor:: Greg Ward <gward at python.net>
 

Modified: python/branches/py3k-cdecimal/Doc/library/os.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/os.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/os.rst	Mon Jun  7 12:46:02 2010
@@ -697,6 +697,14 @@
    Availability: Unix, Windows.
 
 
+.. data:: SEEK_SET
+          SEEK_CUR
+          SEEK_END
+
+   Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
+   respectively. Availability: Windows, Unix.
+
+
 .. function:: open(file, flags[, mode])
 
    Open the file *file* and set various flags according to *flags* and possibly
@@ -706,7 +714,8 @@
 
    For a description of the flag and mode values, see the C run-time documentation;
    flag constants (like :const:`O_RDONLY` and :const:`O_WRONLY`) are defined in
-   this module too (see below).
+   this module too (see :ref:`open-constants`).  In particular, on Windows adding
+   :const:`O_BINARY` is needed to open files in binary mode.
 
    Availability: Unix, Windows.
 
@@ -794,6 +803,12 @@
       :func:`fdopen`, or :data:`sys.stdout` or :data:`sys.stderr`, use its
       :meth:`~file.write` method.
 
+
+.. _open-constants:
+
+``open()`` flag constants
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
 The following constants are options for the *flags* parameter to the
 :func:`~os.open` function.  They can be combined using the bitwise OR operator
 ``|``.  Some of them are not available on all platforms.  For descriptions of
@@ -845,14 +860,6 @@
    the C library.
 
 
-.. data:: SEEK_SET
-          SEEK_CUR
-          SEEK_END
-
-   Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
-   respectively. Availability: Windows, Unix.
-
-
 .. _os-file-dir:
 
 Files and Directories
@@ -2187,8 +2194,8 @@
 
 .. data:: devnull
 
-   The file path of the null device. For example: ``'/dev/null'`` for POSIX.
-   Also available via :mod:`os.path`.
+   The file path of the null device. For example: ``'/dev/null'`` for
+   POSIX, ``'nul'`` for Windows.  Also available via :mod:`os.path`.
 
 
 .. _os-miscfunc:

Modified: python/branches/py3k-cdecimal/Doc/library/socket.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/socket.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/socket.rst	Mon Jun  7 12:46:02 2010
@@ -89,8 +89,9 @@
 and out-of-memory conditions can be raised; errors related to socket or address
 semantics raise the error :exc:`socket.error`.
 
-Non-blocking mode is supported through :meth:`setblocking`.  A generalization of
-this based on timeouts is supported through :meth:`settimeout`.
+Non-blocking mode is supported through :meth:`~socket.setblocking`.  A
+generalization of this based on timeouts is supported through
+:meth:`~socket.settimeout`.
 
 The module :mod:`socket` exports the following constants and functions:
 
@@ -210,27 +211,44 @@
       *source_address* was added.
 
 
-.. function:: getaddrinfo(host, port[, family[, socktype[, proto[, flags]]]])
+.. function:: getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0)
 
-   Resolves the *host*/*port* argument, into a sequence of 5-tuples that contain
-   all the necessary arguments for creating the corresponding socket. *host* is a domain
-   name, a string representation of an IPv4/v6 address or ``None``. *port* is a string
-   service name such as ``'http'``, a numeric port number or ``None``.
-   The rest of the arguments are optional and must be numeric if specified.
-   By passing ``None`` as the value of *host* and *port*, , you can pass ``NULL`` to the C API.
+   Translate the *host*/*port* argument into a sequence of 5-tuples that contain
+   all the necessary arguments for creating a socket connected to that service.
+   *host* is a domain name, a string representation of an IPv4/v6 address
+   or ``None``. *port* is a string service name such as ``'http'``, a numeric
+   port number or ``None``.  By passing ``None`` as the value of *host*
+   and *port*, you can pass ``NULL`` to the underlying C API.
+
+   The *family*, *socktype* and *proto* arguments can be optionally specified
+   in order to narrow the list of addresses returned.  Passing zero as a
+   value for each of these arguments selects the full range of results.
+   The *flags* argument can be one or several of the ``AI_*`` constants,
+   and will influence how results are computed and returned.
+   For example, :const:`AI_NUMERICHOST` will disable domain name resolution
+   and will raise an error if *host* is a domain name.
 
-   The :func:`getaddrinfo` function returns a list of 5-tuples with the following
-   structure:
+   The function returns a list of 5-tuples with the following structure:
 
    ``(family, socktype, proto, canonname, sockaddr)``
 
-   *family*, *socktype*, *proto* are all integers and are meant to be passed to the
-   :func:`socket` function. *canonname* is a string representing the canonical name
-   of the *host*. It can be a numeric IPv4/v6 address when :const:`AI_CANONNAME` is
-   specified for a numeric *host*. *sockaddr* is a tuple describing a socket
-   address, as described above. See the source for :mod:`socket` and other
-   library modules for a typical usage of the function.
-
+   In these tuples, *family*, *socktype*, *proto* are all integers and are
+   meant to be passed to the :func:`socket` function.  *canonname* will be
+   a string representing the canonical name of the *host* if
+   :const:`AI_CANONNAME` is part of the *flags* argument; else *canonname*
+   will be empty.  *sockaddr* is a tuple describing a socket address, whose
+   format depends on the returned *family* (a ``(address, port)`` 2-tuple for
+   :const:`AF_INET`, a ``(address, port, flow info, scope id)`` 4-tuple for
+   :const:`AF_INET6`), and is meant to be passed to the :meth:`socket.connect`
+   method.
+
+   The following example fetches address information for a hypothetical TCP
+   connection to ``www.python.org`` on port 80 (results may differ on your
+   system if IPv6 isn't enabled)::
+
+      >>> socket.getaddrinfo("www.python.org", 80, 0, 0, socket.SOL_TCP)
+      [(2, 1, 6, '', ('82.94.164.162', 80)),
+       (10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]
 
 .. function:: getfqdn([name])
 
@@ -559,7 +577,9 @@
    :platform: Windows
 
    The :meth:`ioctl` method is a limited interface to the WSAIoctl system
-   interface. Please refer to the MSDN documentation for more information.
+   interface.  Please refer to the `Win32 documentation
+   <http://msdn.microsoft.com/en-us/library/ms741621%28VS.85%29.aspx>`_ for more
+   information.
 
    On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl`
    functions may be used; they accept a socket object as their first argument.
@@ -662,7 +682,7 @@
    blocking mode.  In non-blocking mode, if a :meth:`recv` call doesn't find any
    data, or if a :meth:`send` call can't immediately dispose of the data, a
    :exc:`error` exception is raised; in blocking mode, the calls block until they
-   can proceed. ``s.setblocking(0)`` is equivalent to ``s.settimeout(0)``;
+   can proceed. ``s.setblocking(0)`` is equivalent to ``s.settimeout(0.0)``;
    ``s.setblocking(1)`` is equivalent to ``s.settimeout(None)``.
 
 
@@ -691,21 +711,21 @@
 non-blocking mode, operations fail (with an error that is unfortunately
 system-dependent) if they cannot be completed immediately.  In timeout mode,
 operations fail if they cannot be completed within the timeout specified for the
-socket or if the system returns an error.  The :meth:`setblocking` method is simply
-a shorthand for certain :meth:`settimeout` calls.
+socket or if the system returns an error.  The :meth:`~socket.setblocking`
+method is simply a shorthand for certain :meth:`~socket.settimeout` calls.
 
 Timeout mode internally sets the socket in non-blocking mode.  The blocking and
 timeout modes are shared between file descriptors and socket objects that refer
 to the same network endpoint.  A consequence of this is that file objects
-returned by the :meth:`makefile` method must only be used when the socket is in
-blocking mode; in timeout or non-blocking mode file operations that cannot be
-completed immediately will fail.
-
-Note that the :meth:`connect` operation is subject to the timeout setting, and
-in general it is recommended to call :meth:`settimeout` before calling
-:meth:`connect` or pass a timeout parameter to :meth:`create_connection`.
-The system network stack may return a connection timeout error
-of its own regardless of any Python socket timeout setting.
+returned by the :meth:`~socket.makefile` method must only be used when the
+socket is in blocking mode; in timeout or non-blocking mode file operations
+that cannot be completed immediately will fail.
+
+Note that the :meth:`~socket.connect` operation is subject to the timeout
+setting, and in general it is recommended to call :meth:`~socket.settimeout`
+before calling :meth:`~socket.connect` or pass a timeout parameter to
+:meth:`create_connection`.  The system network stack may return a connection
+timeout error of its own regardless of any Python socket timeout setting.
 
 
 .. method:: socket.setsockopt(level, optname, value)
@@ -727,8 +747,8 @@
    are disallowed.  If *how* is :const:`SHUT_RDWR`, further sends and receives are
    disallowed.
 
-Note that there are no methods :meth:`read` or :meth:`write`; use :meth:`recv`
-and :meth:`send` without *flags* argument instead.
+Note that there are no methods :meth:`read` or :meth:`write`; use
+:meth:`~socket.recv` and :meth:`~socket.send` without *flags* argument instead.
 
 Socket objects also have these (read-only) attributes that correspond to the
 values given to the :class:`socket` constructor.
@@ -757,11 +777,12 @@
 Here are four minimal example programs using the TCP/IP protocol: a server that
 echoes all data that it receives back (servicing only one client), and a client
 using it.  Note that a server must perform the sequence :func:`socket`,
-:meth:`bind`, :meth:`listen`, :meth:`accept` (possibly repeating the
-:meth:`accept` to service more than one client), while a client only needs the
-sequence :func:`socket`, :meth:`connect`.  Also note that the server does not
-:meth:`send`/:meth:`recv` on the  socket it is listening on but on the new
-socket returned by :meth:`accept`.
+:meth:`~socket.bind`, :meth:`~socket.listen`, :meth:`~socket.accept` (possibly
+repeating the :meth:`~socket.accept` to service more than one client), while a
+client only needs the sequence :func:`socket`, :meth:`~socket.connect`.  Also
+note that the server does not :meth:`~socket.send`/:meth:`~socket.recv` on the
+socket it is listening on but on the new socket returned by
+:meth:`~socket.accept`.
 
 The first two examples support IPv4 only. ::
 

Modified: python/branches/py3k-cdecimal/Doc/library/sqlite3.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/sqlite3.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/sqlite3.rst	Mon Jun  7 12:46:02 2010
@@ -227,6 +227,13 @@
    one of "DEFERRED", "IMMEDIATE" or "EXCLUSIVE". See section
    :ref:`sqlite3-controlling-transactions` for a more detailed explanation.
 
+.. attribute:: Connection.in_transaction
+
+   .. versionadded:: 3.2
+
+   :const:`True` if a transaction is active (there are uncommitted changes),
+   :const:`False` otherwise.  Read-only attribute.
+
 
 .. method:: Connection.cursor([cursorClass])
 
@@ -806,7 +813,8 @@
 before executing that command. There are two reasons for doing that. The first
 is that some of these commands don't work within transactions. The other reason
 is that sqlite3 needs to keep track of the transaction state (if a transaction
-is active or not).
+is active or not).  The current transaction state is exposed through the
+:attr:`Connection.in_transaction` attribute of the connection object.
 
 You can control which kind of ``BEGIN`` statements sqlite3 implicitly executes
 (or none at all) via the *isolation_level* parameter to the :func:`connect`

Modified: python/branches/py3k-cdecimal/Doc/library/ssl.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/ssl.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/ssl.rst	Mon Jun  7 12:46:02 2010
@@ -257,6 +257,37 @@
    modern version, and probably the best choice for maximum protection, if both
    sides can speak it.
 
+.. data:: OP_ALL
+
+   Enables workarounds for various bugs present in other SSL implementations.
+   This option is set by default.
+
+   .. versionadded:: 3.2
+
+.. data:: OP_NO_SSLv2
+
+   Prevents an SSLv2 connection.  This option is only applicable in
+   conjunction with :const:`PROTOCOL_SSLv23`.  It prevents the peers from
+   choosing SSLv2 as the protocol version.
+
+   .. versionadded:: 3.2
+
+.. data:: OP_NO_SSLv3
+
+   Prevents an SSLv3 connection.  This option is only applicable in
+   conjunction with :const:`PROTOCOL_SSLv23`.  It prevents the peers from
+   choosing SSLv3 as the protocol version.
+
+   .. versionadded:: 3.2
+
+.. data:: OP_NO_TLSv1
+
+   Prevents a TLSv1 connection.  This option is only applicable in
+   conjunction with :const:`PROTOCOL_SSLv23`.  It prevents the peers from
+   choosing TLSv1 as the protocol version.
+
+   .. versionadded:: 3.2
+
 .. data:: OPENSSL_VERSION
 
    The version string of the OpenSSL library loaded by the interpreter::
@@ -376,9 +407,21 @@
    other side of the connection, rather than the original socket.
 
 
+.. attribute:: SSLSocket.context
+
+   The :class:`SSLContext` object this SSL socket is tied to.  If the SSL
+   socket was created using the top-level :func:`wrap_socket` function
+   (rather than :meth:`SSLContext.wrap_socket`), this is a custom context
+   object created for this SSL socket.
+
+   .. versionadded:: 3.2
+
+
 SSL Contexts
 ------------
 
+.. versionadded:: 3.2
+
 .. class:: SSLContext(protocol)
 
    An object holding various data longer-lived than single SSL connections,
@@ -440,6 +483,17 @@
    and *suppress_ragged_eofs* have the same meaning as in the top-level
    :func:`wrap_socket` function.
 
+.. attribute:: SSLContext.options
+
+   An integer representing the set of SSL options enabled on this context.
+   The default value is :data:`OP_ALL`, but you can specify other options
+   such as :data:`OP_NO_SSLv2` by ORing them together.
+
+   .. note::
+      With versions of OpenSSL older than 0.9.8m, it is only possible
+      to set options, not to clear them.  Attempting to clear an option
+      (by resetting the corresponding bits) will raise a ``ValueError``.
+
 .. attribute:: SSLContext.protocol
 
    The protocol version chosen when constructing the context.  This attribute
@@ -794,6 +848,20 @@
       equivalent unless anonymous ciphers are enabled (they are disabled
       by default).
 
+Protocol versions
+^^^^^^^^^^^^^^^^^
+
+SSL version 2 is considered insecure and is therefore dangerous to use.  If
+you want maximum compatibility between clients and servers, it is recommended
+to use :const:`PROTOCOL_SSLv23` as the protocol version and then disable
+SSLv2 explicitly using the :data:`SSLContext.options` attribute::
+
+   context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+   context.options |= ssl.OP_NO_SSLv2
+
+The SSL context created above will allow SSLv3 and TLSv1 connections, but
+not SSLv2.
+
 
 .. seealso::
 

Modified: python/branches/py3k-cdecimal/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/stdtypes.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/stdtypes.rst	Mon Jun  7 12:46:02 2010
@@ -595,6 +595,109 @@
    '0x1.d380000000000p+11'
 
 
+.. _numeric-hash:
+
+Hashing of numeric types
+------------------------
+
+For numbers ``x`` and ``y``, possibly of different types, it's a requirement
+that ``hash(x) == hash(y)`` whenever ``x == y`` (see the :meth:`__hash__`
+method documentation for more details).  For ease of implementation and
+efficiency across a variety of numeric types (including :class:`int`,
+:class:`float`, :class:`decimal.Decimal` and :class:`fractions.Fraction`)
+Python's hash for numeric types is based on a single mathematical function
+that's defined for any rational number, and hence applies to all instances of
+:class:`int` and :class:`fraction.Fraction`, and all finite instances of
+:class:`float` and :class:`decimal.Decimal`.  Essentially, this function is
+given by reduction modulo ``P`` for a fixed prime ``P``.  The value of ``P`` is
+made available to Python as the :attr:`modulus` attribute of
+:data:`sys.hash_info`.
+
+.. impl-detail::
+
+   Currently, the prime used is ``P = 2**31 - 1`` on machines with 32-bit C
+   longs and ``P = 2**61 - 1`` on machines with 64-bit C longs.
+
+Here are the rules in detail:
+
+ - If ``x = m / n`` is a nonnegative rational number and ``n`` is not divisible
+   by ``P``, define ``hash(x)`` as ``m * invmod(n, P) % P``, where ``invmod(n,
+   P)`` gives the inverse of ``n`` modulo ``P``.
+
+ - If ``x = m / n`` is a nonnegative rational number and ``n`` is
+   divisible by ``P`` (but ``m`` is not) then ``n`` has no inverse
+   modulo ``P`` and the rule above doesn't apply; in this case define
+   ``hash(x)`` to be the constant value ``sys.hash_info.inf``.
+
+ - If ``x = m / n`` is a negative rational number define ``hash(x)``
+   as ``-hash(-x)``.  If the resulting hash is ``-1``, replace it with
+   ``-2``.
+
+ - The particular values ``sys.hash_info.inf``, ``-sys.hash_info.inf``
+   and ``sys.hash_info.nan`` are used as hash values for positive
+   infinity, negative infinity, or nans (respectively).  (All hashable
+   nans have the same hash value.)
+
+ - For a :class:`complex` number ``z``, the hash values of the real
+   and imaginary parts are combined by computing ``hash(z.real) +
+   sys.hash_info.imag * hash(z.imag)``, reduced modulo
+   ``2**sys.hash_info.width`` so that it lies in
+   ``range(-2**(sys.hash_info.width - 1), 2**(sys.hash_info.width -
+   1))``.  Again, if the result is ``-1``, it's replaced with ``-2``.
+
+
+To clarify the above rules, here's some example Python code,
+equivalent to the builtin hash, for computing the hash of a rational
+number, :class:`float`, or :class:`complex`::
+
+
+   import sys, math
+
+   def hash_fraction(m, n):
+       """Compute the hash of a rational number m / n.
+
+       Assumes m and n are integers, with n positive.
+       Equivalent to hash(fractions.Fraction(m, n)).
+
+       """
+       P = sys.hash_info.modulus
+       # Remove common factors of P.  (Unnecessary if m and n already coprime.)
+       while m % P == n % P == 0:
+           m, n = m // P, n // P
+
+       if n % P == 0:
+           hash_ = sys.hash_info.inf
+       else:
+           # Fermat's Little Theorem: pow(n, P-1, P) is 1, so
+           # pow(n, P-2, P) gives the inverse of n modulo P.
+           hash_ = (abs(m) % P) * pow(n, P - 2, P) % P
+       if m < 0:
+           hash_ = -hash_
+       if hash_ == -1:
+           hash_ = -2
+       return hash_
+
+   def hash_float(x):
+       """Compute the hash of a float x."""
+
+       if math.isnan(x):
+           return sys.hash_info.nan
+       elif math.isinf(x):
+           return sys.hash_info.inf if x > 0 else -sys.hash_info.inf
+       else:
+           return hash_fraction(*x.as_integer_ratio())
+
+   def hash_complex(z):
+       """Compute the hash of a complex number z."""
+
+       hash_ = hash_float(z.real) + sys.hash_info.imag * hash_float(z.imag)
+       # do a signed reduction modulo 2**sys.hash_info.width
+       M = 2**(sys.hash_info.width - 1)
+       hash_ = (hash_ & (M - 1)) - (hash & M)
+       if hash_ == -1:
+           hash_ == -2
+       return hash_
+
 .. _typeiter:
 
 Iterator Types

Modified: python/branches/py3k-cdecimal/Doc/library/subprocess.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/subprocess.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/subprocess.rst	Mon Jun  7 12:46:02 2010
@@ -89,6 +89,12 @@
    size.  A negative *bufsize* means to use the system default, which usually means
    fully buffered.  The default value for *bufsize* is :const:`0` (unbuffered).
 
+   .. note::
+
+      If you experience performance issues, it is recommended that you try to
+      enable buffering by setting *bufsize* to either -1 or a large enough
+      positive value (such as 4096).
+
    The *executable* argument specifies the program to execute. It is very seldom
    needed: Usually, the program to execute is defined by the *args* argument. If
    ``shell=True``, the *executable* argument specifies which shell to use. On Unix,

Modified: python/branches/py3k-cdecimal/Doc/library/symtable.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/symtable.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/symtable.rst	Mon Jun  7 12:46:02 2010
@@ -67,7 +67,7 @@
 
       Return ``True`` if the block uses ``exec``.
 
-   .. method:: has_import_start()
+   .. method:: has_import_star()
 
       Return ``True`` if the block uses a starred from-import.
 

Modified: python/branches/py3k-cdecimal/Doc/library/sys.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/sys.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/sys.rst	Mon Jun  7 12:46:02 2010
@@ -446,6 +446,30 @@
       Changed to a named tuple and added *service_pack_minor*,
       *service_pack_major*, *suite_mask*, and *product_type*.
 
+
+.. data:: hash_info
+
+   A structseq giving parameters of the numeric hash implementation.  For
+   more details about hashing of numeric types, see :ref:`numeric-hash`.
+
+   +---------------------+--------------------------------------------------+
+   | attribute           | explanation                                      |
+   +=====================+==================================================+
+   | :const:`width`      | width in bits used for hash values               |
+   +---------------------+--------------------------------------------------+
+   | :const:`modulus`    | prime modulus P used for numeric hash scheme     |
+   +---------------------+--------------------------------------------------+
+   | :const:`inf`        | hash value returned for a positive infinity      |
+   +---------------------+--------------------------------------------------+
+   | :const:`nan`        | hash value returned for a nan                    |
+   +---------------------+--------------------------------------------------+
+   | :const:`imag`       | multiplier used for the imaginary part of a      |
+   |                     | complex number                                   |
+   +---------------------+--------------------------------------------------+
+
+   .. versionadded:: 3.2
+
+
 .. data:: hexversion
 
    The version number encoded as a single integer.  This is guaranteed to increase

Modified: python/branches/py3k-cdecimal/Doc/library/sysconfig.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/sysconfig.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/sysconfig.rst	Mon Jun  7 12:46:02 2010
@@ -216,3 +216,35 @@
 .. function:: get_config_h_filename()
 
    Return the path of :file:`pyconfig.h`.
+
+Using :mod:`sysconfig` as a script
+----------------------------------
+
+You can use :mod:`sysconfig` as a script with Python's *-m* option::
+
+    $ python -m sysconfig
+    Platform: "macosx-10.4-i386"
+    Python version: "3.2"
+    Current installation scheme: "posix_prefix"
+
+    Paths:
+            data = "/usr/local"
+            include = "/Users/tarek/Dev/svn.python.org/py3k/Include"
+            platinclude = "."
+            platlib = "/usr/local/lib/python3.2/site-packages"
+            platstdlib = "/usr/local/lib/python3.2"
+            purelib = "/usr/local/lib/python3.2/site-packages"
+            scripts = "/usr/local/bin"
+            stdlib = "/usr/local/lib/python3.2"
+
+    Variables:
+            AC_APPLE_UNIVERSAL_BUILD = "0"
+            AIX_GENUINE_CPLUSPLUS = "0"
+            AR = "ar"
+            ARFLAGS = "rc"
+            ASDLGEN = "./Parser/asdl_c.py"
+            ...
+
+This call will print in the standard output the information returned by
+:func:`get_platform`, :func:`get_python_version`, :func:`get_path` and
+:func:`get_config_vars`.

Modified: python/branches/py3k-cdecimal/Doc/library/syslog.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/syslog.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/syslog.rst	Mon Jun  7 12:46:02 2010
@@ -10,66 +10,63 @@
 Refer to the Unix manual pages for a detailed description of the ``syslog``
 facility.
 
-This module wraps the system ``syslog`` module.  A pure Python
-library that can speak to a syslog server is available in
-the :mod:`logging.handlers` module as :class:`SysLogHandler`.
+This module wraps the system ``syslog`` family of routines.  A pure Python
+library that can speak to a syslog server is available in the
+:mod:`logging.handlers` module as :class:`SysLogHandler`.
 
 The module defines the following functions:
 
 
 .. function:: syslog([priority,] message)
 
-   Send the string *message* to the system logger.  A trailing newline is
-   added if necessary.  Each message is tagged with a priority composed
-   of a *facility* and a *level*.  The optional *priority* argument, which
-   defaults to :const:`LOG_INFO`, determines the message priority.  If the
-   facility is not encoded in *priority* using logical-or (``LOG_INFO |
-   LOG_USER``), the value given in the :func:`openlog` call is used.
+   Send the string *message* to the system logger.  A trailing newline is added
+   if necessary.  Each message is tagged with a priority composed of a
+   *facility* and a *level*.  The optional *priority* argument, which defaults
+   to :const:`LOG_INFO`, determines the message priority.  If the facility is
+   not encoded in *priority* using logical-or (``LOG_INFO | LOG_USER``), the
+   value given in the :func:`openlog` call is used.
 
-   If :func:`openlog` has not been called prior to the call to
-   :func:'syslog', ``openlog()`` will be called with no arguments.
+   If :func:`openlog` has not been called prior to the call to :func:`syslog`,
+   ``openlog()`` will be called with no arguments.
 
 
 .. function:: openlog([ident[, logopt[, facility]]])
 
-   Logging options of subsequent :func:`syslog` calls can be set by
-   calling :func:`openlog`.  :func:`syslog` will call :func:`openlog`
-   with no arguments if the log is not currently open.
-
-   The optional *ident* keyword argument is a string which is prepended
-   to every message, and defaults to ''sys.argv[0]'' with leading
-   path components stripped.  The optional *logopt* keyword argument
-   (default=0) is a bit field - see below for possible values to combine.
-   The optional *facility* keyword argument (default=:const:`LOG_USER`)
-   sets the default facility for messages which do not have a facility
-   explicitly encoded.
-
-   .. versionchanged::3.2
-      In previous versions, keyword arguments were not allowed, and *ident*
-      was required.  The default for *ident* was dependent on the system
-      libraries, and often was ''python'' instead of the name of the
-      python program file.
+   Logging options of subsequent :func:`syslog` calls can be set by calling
+   :func:`openlog`.  :func:`syslog` will call :func:`openlog` with no arguments
+   if the log is not currently open.
+
+   The optional *ident* keyword argument is a string which is prepended to every
+   message, and defaults to ``sys.argv[0]`` with leading path components
+   stripped.  The optional *logopt* keyword argument (default is 0) is a bit
+   field -- see below for possible values to combine.  The optional *facility*
+   keyword argument (default is :const:`LOG_USER`) sets the default facility for
+   messages which do not have a facility explicitly encoded.
+
+   .. versionchanged:: 3.2
+      In previous versions, keyword arguments were not allowed, and *ident* was
+      required.  The default for *ident* was dependent on the system libraries,
+      and often was ``python`` instead of the name of the python program file.
 
 
 .. function:: closelog()
 
-   Reset the syslog module values and call the system library
-   ''closelog()''.
+   Reset the syslog module values and call the system library ``closelog()``.
 
-   This causes the module to behave as it does when initially imported.
-   For example, :func:'openlog' will be called on the first :func:'syslog'
-   call (if :func:'openlog' hasn't already been called), and *ident*
-   and other :func:'openlog' parameters are reset to defaults.
+   This causes the module to behave as it does when initially imported.  For
+   example, :func:`openlog` will be called on the first :func:`syslog` call (if
+   :func:`openlog` hasn't already been called), and *ident* and other
+   :func:`openlog` parameters are reset to defaults.
 
 
 .. function:: setlogmask(maskpri)
 
-   Set the priority mask to *maskpri* and return the previous mask value.
-   Calls to :func:`syslog` with a priority level not set in *maskpri*
-   are ignored.  The default is to log all priorities.  The function
-   ``LOG_MASK(pri)`` calculates the mask for the individual priority
-   *pri*.  The function ``LOG_UPTO(pri)`` calculates the mask for all
-   priorities up to and including *pri*.
+   Set the priority mask to *maskpri* and return the previous mask value.  Calls
+   to :func:`syslog` with a priority level not set in *maskpri* are ignored.
+   The default is to log all priorities.  The function ``LOG_MASK(pri)``
+   calculates the mask for the individual priority *pri*.  The function
+   ``LOG_UPTO(pri)`` calculates the mask for all priorities up to and including
+   *pri*.
 
 The module defines the following constants:
 
@@ -100,11 +97,11 @@
 
    syslog.syslog('Processing started')
    if error:
-      syslog.syslog(syslog.LOG_ERR, 'Processing started')
+       syslog.syslog(syslog.LOG_ERR, 'Processing started')
 
-An example of setting some log options, these would include the process ID
-in logged messages, and write the messages to the destination facility
-used for mail logging::
+An example of setting some log options, these would include the process ID in
+logged messages, and write the messages to the destination facility used for
+mail logging::
 
    syslog.openlog(logopt=syslog.LOG_PID, facility=syslog.LOG_MAIL)
    syslog.syslog('E-mail processing initiated...')

Modified: python/branches/py3k-cdecimal/Doc/library/telnetlib.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/telnetlib.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/telnetlib.rst	Mon Jun  7 12:46:02 2010
@@ -27,16 +27,11 @@
    :class:`Telnet` represents a connection to a Telnet server. The instance is
    initially not connected by default; the :meth:`open` method must be used to
    establish a connection.  Alternatively, the host name and optional port
-   and timeout can be passed to the constructor, in which case the connection to
-   the server will be established before the constructor returns.  The optional
-   *timeout* parameter specifies a timeout in seconds for the connection attempt (if
-   not specified, the global default timeout setting will be used).
-
    number can be passed to the constructor, to, in which case the connection to
-   the server will be established before the constructor returns. The optional
+   the server will be established before the constructor returns.  The optional
    *timeout* parameter specifies a timeout in seconds for blocking operations
-   like the connection attempt (if not specified, or passed as None, the global
-   default timeout setting will be used).
+   like the connection attempt (if not specified, the global default timeout
+   setting will be used).
 
    Do not reopen an already connected instance.
 

Modified: python/branches/py3k-cdecimal/Doc/library/tempfile.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/tempfile.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/tempfile.rst	Mon Jun  7 12:46:02 2010
@@ -27,8 +27,7 @@
 
 The module defines the following user-callable functions:
 
-
-.. function:: TemporaryFile(mode='w+b', bufsize=-1, suffix='', prefix='tmp', dir=None)
+.. function:: TemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix='', prefix='tmp', dir=None)
 
    Return a file-like object that can be used as a temporary storage area.
    The file is created using :func:`mkstemp`. It will be destroyed as soon
@@ -41,8 +40,8 @@
    The *mode* parameter defaults to ``'w+b'`` so that the file created can
    be read and written without being closed.  Binary mode is used so that it
    behaves consistently on all platforms without regard for the data that is
-   stored.  *bufsize* defaults to ``-1``, meaning that the operating system
-   default is used.
+   stored.  *buffering*, *encoding* and *newline* are interpreted as for
+   :func:`open`.
 
    The *dir*, *prefix* and *suffix* parameters are passed to :func:`mkstemp`.
 
@@ -52,7 +51,7 @@
    :keyword:`with` statement, just like a normal file.
 
 
-.. function:: NamedTemporaryFile(mode='w+b', bufsize=-1, suffix='', prefix='tmp', dir=None, delete=True)
+.. function:: NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix='', prefix='tmp', dir=None, delete=True)
 
    This function operates exactly as :func:`TemporaryFile` does, except that
    the file is guaranteed to have a visible name in the file system (on
@@ -67,7 +66,7 @@
    be used in a :keyword:`with` statement, just like a normal file.
 
 
-.. function:: SpooledTemporaryFile(max_size=0, mode='w+b', bufsize=-1, suffix='', prefix='tmp', dir=None)
+.. function:: SpooledTemporaryFile(max_size=0, mode='w+b', buffering=None, encoding=None, newline=None, suffix='', prefix='tmp', dir=None)
 
    This function operates exactly as :func:`TemporaryFile` does, except that
    data is spooled in memory until the file size exceeds *max_size*, or

Modified: python/branches/py3k-cdecimal/Doc/library/time.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/time.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/time.rst	Mon Jun  7 12:46:02 2010
@@ -81,30 +81,31 @@
   :func:`gmtime`, :func:`localtime`, and :func:`strptime` also offer attribute
   names for individual fields.
 
-  +-------+------------------+------------------------------+
-  | Index | Attribute        | Values                       |
-  +=======+==================+==============================+
-  | 0     | :attr:`tm_year`  | (for example, 1993)          |
-  +-------+------------------+------------------------------+
-  | 1     | :attr:`tm_mon`   | range [1,12]                 |
-  +-------+------------------+------------------------------+
-  | 2     | :attr:`tm_mday`  | range [1,31]                 |
-  +-------+------------------+------------------------------+
-  | 3     | :attr:`tm_hour`  | range [0,23]                 |
-  +-------+------------------+------------------------------+
-  | 4     | :attr:`tm_min`   | range [0,59]                 |
-  +-------+------------------+------------------------------+
-  | 5     | :attr:`tm_sec`   | range [0,61]; see **(1)** in |
-  |       |                  | :func:`strftime` description |
-  +-------+------------------+------------------------------+
-  | 6     | :attr:`tm_wday`  | range [0,6], Monday is 0     |
-  +-------+------------------+------------------------------+
-  | 7     | :attr:`tm_yday`  | range [1,366]                |
-  +-------+------------------+------------------------------+
-  | 8     | :attr:`tm_isdst` | 0, 1 or -1; see below        |
-  +-------+------------------+------------------------------+
+  +-------+-------------------+---------------------------------+
+  | Index | Attribute         | Values                          |
+  +=======+===================+=================================+
+  | 0     | :attr:`tm_year`   | (for example, 1993)             |
+  +-------+-------------------+---------------------------------+
+  | 1     | :attr:`tm_mon`    | range [1, 12]                   |
+  +-------+-------------------+---------------------------------+
+  | 2     | :attr:`tm_mday`   | range [1, 31]                   |
+  +-------+-------------------+---------------------------------+
+  | 3     | :attr:`tm_hour`   | range [0, 23]                   |
+  +-------+-------------------+---------------------------------+
+  | 4     | :attr:`tm_min`    | range [0, 59]                   |
+  +-------+-------------------+---------------------------------+
+  | 5     | :attr:`tm_sec`    | range [0, 61]; see **(1)** in   |
+  |       |                   | :func:`strftime` description    |
+  +-------+-------------------+---------------------------------+
+  | 6     | :attr:`tm_wday`   | range [0, 6], Monday is 0       |
+  +-------+-------------------+---------------------------------+
+  | 7     | :attr:`tm_yday`   | range [1, 366]                  |
+  +-------+-------------------+---------------------------------+
+  | 8     | :attr:`tm_isdst`  | 0, 1 or -1; see below           |
+  +-------+-------------------+---------------------------------+
 
-  Note that unlike the C structure, the month value is a range of 1-12, not 0-11.
+  Note that unlike the C structure, the month value is a range of [1, 12],
+  not [0, 11].
   A year value will be handled as described under "Year 2000 (Y2K) issues" above.
   A ``-1`` argument as the daylight savings flag, passed to :func:`mktime` will
   usually result in the correct daylight savings state to be filled in.

Modified: python/branches/py3k-cdecimal/Doc/library/unittest.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/unittest.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/unittest.rst	Mon Jun  7 12:46:02 2010
@@ -749,7 +749,7 @@
 
    .. method:: skipTest(reason)
 
-      Calling this during the a test method or :meth:`setUp` skips the current
+      Calling this during a test method or :meth:`setUp` skips the current
       test.  See :ref:`unittest-skipping` for more information.
 
       .. versionadded:: 3.1
@@ -773,8 +773,7 @@
       will be *msg* if given, otherwise it will be :const:`None`.
 
       .. deprecated:: 3.1
-         :meth:`failUnless`; use one of the ``assert`` variants.
-         :meth:`assert_`; use :meth:`assertTrue`.
+         :meth:`failUnless` and :meth:`assert_`; use :meth:`assertTrue`.
 
 
    .. method:: assertEqual(first, second, msg=None)
@@ -1169,6 +1168,21 @@
       .. versionadded:: 3.1
 
 
+   .. attribute:: maxDiff
+
+      This attribute controls the maximum length of diffs output by assert
+      methods that report diffs on failure. It defaults to 80*8 characters.
+      Assert methods affected by this attribute are
+      :meth:`assertSequenceEqual` (including all the sequence comparison
+      methods that delegate to it), :meth:`assertDictEqual` and
+      :meth:`assertMultiLineEqual`.
+
+      Setting ``maxDiff`` to None means that there is no maximum length of
+      diffs.
+
+      .. versionadded:: 3.2
+
+
    Testing frameworks can use the following methods to collect information on
    the test:
 
@@ -1863,7 +1877,9 @@
 
 If an exception is raised during a ``setUpClass`` then the tests in the class
 are not run and the ``tearDownClass`` is not run. Skipped classes will not
-have ``setUpClass`` or ``tearDownClass`` run.
+have ``setUpClass`` or ``tearDownClass`` run. If the exception is a
+``SkipTest`` exception then the class will be reported as having been skipped
+instead of as an error.
 
 
 setUpModule and tearDownModule
@@ -1878,7 +1894,9 @@
         closeConnection()
 
 If an exception is raised in a ``setUpModule`` then none of the tests in the
-module will be run and the ``tearDownModule`` will not be run.
+module will be run and the ``tearDownModule`` will not be run. If the exception is a
+``SkipTest`` exception then the module will be reported as having been skipped
+instead of as an error.
 
 
 Signal Handling

Modified: python/branches/py3k-cdecimal/Doc/library/urllib.parse.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/urllib.parse.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/urllib.parse.rst	Mon Jun  7 12:46:02 2010
@@ -26,7 +26,7 @@
 
 The :mod:`urllib.parse` module defines the following functions:
 
-.. function:: urlparse(urlstring, default_scheme='', allow_fragments=True)
+.. function:: urlparse(urlstring, scheme='', allow_fragments=True)
 
    Parse a URL into six components, returning a 6-tuple.  This corresponds to the
    general structure of a URL: ``scheme://netloc/path;parameters?query#fragment``.
@@ -48,7 +48,7 @@
       >>> o.geturl()
       'http://www.cwi.nl:80/%7Eguido/Python.html'
 
-   If the *default_scheme* argument is specified, it gives the default addressing
+   If the *scheme* argument is specified, it gives the default addressing
    scheme, to be used only if the URL does not specify one.  The default value for
    this argument is the empty string.
 
@@ -142,7 +142,7 @@
    states that these are equivalent).
 
 
-.. function:: urlsplit(urlstring, default_scheme='', allow_fragments=True)
+.. function:: urlsplit(urlstring, scheme='', allow_fragments=True)
 
    This is similar to :func:`urlparse`, but does not split the params from the URL.
    This should generally be used instead of :func:`urlparse` if the more recent URL
@@ -312,19 +312,21 @@
 
 .. function:: urlencode(query, doseq=False)
 
-   Convert a mapping object or a sequence of two-element tuples  to a "url-encoded"
-   string, suitable to pass to :func:`urlopen` above as the optional *data*
-   argument.  This is useful to pass a dictionary of form fields to a ``POST``
-   request.  The resulting string is a series of ``key=value`` pairs separated by
-   ``'&'`` characters, where both *key* and *value* are quoted using
-   :func:`quote_plus` above.  If the optional parameter *doseq* is present and
-   evaluates to true, individual ``key=value`` pairs are generated for each element
-   of the sequence. When a sequence of two-element tuples is used as the *query*
-   argument, the first element of each tuple is a key and the second is a value.
-   The order of parameters in the encoded string will match the order of parameter
-   tuples in the sequence. This module provides the functions
-   :func:`parse_qs` and :func:`parse_qsl` which are used to parse query strings
-   into Python data structures.
+   Convert a mapping object or a sequence of two-element tuples to a
+   "url-encoded" string, suitable to pass to :func:`urlopen` above as the
+   optional *data* argument.  This is useful to pass a dictionary of form
+   fields to a ``POST`` request.  The resulting string is a series of
+   ``key=value`` pairs separated by ``'&'`` characters, where both *key* and
+   *value* are quoted using :func:`quote_plus` above. When a sequence of
+   two-element tuples is used as the *query* argument, the first element of
+   each tuple is a key and the second is a value. The value element in itself
+   can be a sequence and in that case, if the optional parameter *doseq* is
+   evaluates to *True*, individual ``key=value`` pairs separated by ``'&'`` are
+   generated for each element of the value sequence for the key.  The order of
+   parameters in the encoded string will match the order of parameter tuples in
+   the sequence. This module provides the functions :func:`parse_qs` and
+   :func:`parse_qsl` which are used to parse query strings into Python data
+   structures.
 
 
 .. seealso::

Modified: python/branches/py3k-cdecimal/Doc/library/urllib.request.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/urllib.request.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/urllib.request.rst	Mon Jun  7 12:46:02 2010
@@ -604,7 +604,7 @@
    method on the currently installed global :class:`OpenerDirector`).  The
    optional *timeout* parameter specifies a timeout in seconds for blocking
    operations like the connection attempt (if not specified, the global default
-   timeout setting will be usedi). The timeout feature actually works only for
+   timeout setting will be used). The timeout feature actually works only for
    HTTP, HTTPS, FTP and FTPS connections).
 
 
@@ -1079,7 +1079,7 @@
 
    >>> import urllib.request
    >>> f = urllib.request.urlopen('http://www.python.org/')
-   >>> print(fp.read(100).decode('utf-8'))
+   >>> print(f.read(100).decode('utf-8'))
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtm
 

Modified: python/branches/py3k-cdecimal/Doc/library/winreg.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/winreg.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/winreg.rst	Mon Jun  7 12:46:02 2010
@@ -8,21 +8,23 @@
 
 
 These functions expose the Windows registry API to Python.  Instead of using an
-integer as the registry handle, a handle object is used to ensure that the
-handles are closed correctly, even if the programmer neglects to explicitly
-close them.
+integer as the registry handle, a :ref:`handle object <handle-object>` is used
+to ensure that the handles are closed correctly, even if the programmer neglects
+to explicitly close them.
 
 This module offers the following functions:
 
 
 .. function:: CloseKey(hkey)
 
-   Closes a previously opened registry key. The hkey argument specifies a
+   Closes a previously opened registry key.  The *hkey* argument specifies a
    previously opened key.
 
    .. note::
-      If *hkey* is not closed using this method (or via :meth:`hkey.Close() <PyHKEY.Close>`),
-      it is closed when the *hkey* object is destroyed by Python.
+
+      If *hkey* is not closed using this method (or via :meth:`hkey.Close()
+      <PyHKEY.Close>`), it is closed when the *hkey* object is destroyed by
+      Python.
 
 
 .. function:: ConnectRegistry(computer_name, key)
@@ -109,7 +111,7 @@
       The :func:`DeleteKeyEx` function is implemented with the RegDeleteKeyEx
       Windows API function, which is specific to 64-bit versions of Windows.
       See the `RegDeleteKeyEx documentation
-     <http://msdn.microsoft.com/en-us/library/ms724847%28VS.85%29.aspx>`__.
+      <http://msdn.microsoft.com/en-us/library/ms724847%28VS.85%29.aspx>`__.
 
    *key* is an already open key, or one of the predefined
    :ref:`HKEY_* constants <hkey-constants>`.
@@ -120,7 +122,7 @@
 
    *res* is a reserved integer, and must be zero. The default is zero.
 
-   *sam* is an integer that specifies an access mask that describes the
+   *sam* is an integer that specifies an access mask that describes the desired
    security access for the key.  Default is :const:`KEY_ALL_ACCESS`.  See
    :ref:`Access Rights <access-rights>` for other allowed values.
 
@@ -183,13 +185,15 @@
    |       | registry type                              |
    +-------+--------------------------------------------+
    | ``2`` | An integer that identifies the type of the |
-   |       | value data                                 |
+   |       | value data (see table in docs for          |
+   |       | :meth:`SetValueEx`)                        |
    +-------+--------------------------------------------+
 
 
 .. function:: ExpandEnvironmentStrings(str)
 
-   Expands environment strings %NAME% in unicode string like :const:`REG_EXPAND_SZ`::
+   Expands environment variable placeholders ``%NAME%`` in strings like
+   :const:`REG_EXPAND_SZ`::
 
       >>> ExpandEnvironmentStrings('%windir%')
       'C:\\Windows'
@@ -223,23 +227,20 @@
    *key* is a handle returned by :func:`ConnectRegistry` or one of the constants
    :const:`HKEY_USERS` or :const:`HKEY_LOCAL_MACHINE`.
 
-   *sub_key* is a string that identifies the sub_key to load.
+   *sub_key* is a string that identifies the subkey to load.
 
    *file_name* is the name of the file to load registry data from. This file must
    have been created with the :func:`SaveKey` function. Under the file allocation
    table (FAT) file system, the filename may not have an extension.
 
-   A call to LoadKey() fails if the calling process does not have the
-   :const:`SE_RESTORE_PRIVILEGE` privilege. Note that privileges are different than
+   A call to :func:`LoadKey` fails if the calling process does not have the
+   :const:`SE_RESTORE_PRIVILEGE` privilege.  Note that privileges are different
    from permissions -- see the `RegLoadKey documentation
    <http://msdn.microsoft.com/en-us/library/ms724889%28v=VS.85%29.aspx>`__ for
    more details.
 
    If *key* is a handle returned by :func:`ConnectRegistry`, then the path
-   specified in *fileName* is relative to the remote computer.
-
-   The Win32 documentation implies *key* must be in the :const:`HKEY_USER` or
-   :const:`HKEY_LOCAL_MACHINE` tree. This may or may not be true.
+   specified in *file_name* is relative to the remote computer.
 
 
 .. function:: OpenKey(key, sub_key[, res[, sam]])
@@ -254,8 +255,8 @@
    *res* is a reserved integer, and must be zero.  The default is zero.
 
    *sam* is an integer that specifies an access mask that describes the desired
-   security access for the key.  Default is :const:`KEY_READ`.  See
-   :ref:`Access Rights <access-rights>` for other allowed values.
+   security access for the key.  Default is :const:`KEY_READ`.  See :ref:`Access
+   Rights <access-rights>` for other allowed values.
 
    The result is a new handle to the specified key.
 
@@ -327,7 +328,8 @@
    | ``0`` | The value of the registry item.         |
    +-------+-----------------------------------------+
    | ``1`` | An integer giving the registry type for |
-   |       | this value.                             |
+   |       | this value (see table in docs for       |
+   |       | :meth:`SetValueEx`)                     |
    +-------+-----------------------------------------+
 
 
@@ -338,10 +340,10 @@
    *key* is an already open key, or one of the predefined
    :ref:`HKEY_* constants <hkey-constants>`.
 
-   *file_name* is the name of the file to save registry data to. This file cannot
-   already exist. If this filename includes an extension, it cannot be used on file
-   allocation table (FAT) file systems by the :meth:`LoadKey`, :meth:`ReplaceKey`
-   or :meth:`RestoreKey` methods.
+   *file_name* is the name of the file to save registry data to.  This file
+   cannot already exist. If this filename includes an extension, it cannot be
+   used on file allocation table (FAT) file systems by the :meth:`LoadKey`
+   method.
 
    If *key* represents a key on a remote computer, the path described by
    *file_name* is relative to the remote computer. The caller of this method must
@@ -411,16 +413,16 @@
 .. function:: DisableReflectionKey(key)
 
    Disables registry reflection for 32-bit processes running on a 64-bit
-   Operating System.
+   operating system.
 
-   *key* is an already open key, or one of the predefined
-   :ref:`HKEY_* constants <hkey-constants>`.
+   *key* is an already open key, or one of the predefined :ref:`HKEY_* constants
+   <hkey-constants>`.
 
-   Will generally raise :exc:`NotImplemented` if executed on a 32-bit
-   Operating System.
+   Will generally raise :exc:`NotImplemented` if executed on a 32-bit operating
+   system.
 
    If the key is not on the reflection list, the function succeeds but has no
-   effect. Disabling reflection for a key does not affect reflection of any
+   effect.  Disabling reflection for a key does not affect reflection of any
    subkeys.
 
 
@@ -428,11 +430,11 @@
 
    Restores registry reflection for the specified disabled key.
 
-   *key* is an already open key, or one of the predefined
-   :ref:`HKEY_* constants <hkey-constants>`.
+   *key* is an already open key, or one of the predefined :ref:`HKEY_* constants
+   <hkey-constants>`.
 
-   Will generally raise :exc:`NotImplemented` if executed on a 32-bit
-   Operating System.
+   Will generally raise :exc:`NotImplemented` if executed on a 32-bit operating
+   system.
 
    Restoring reflection for a key does not affect reflection of any subkeys.
 
@@ -447,7 +449,7 @@
    Returns ``True`` if reflection is disabled.
 
    Will generally raise :exc:`NotImplemented` if executed on a 32-bit
-   Operating System.
+   operating system.
 
 
 .. _constants:
@@ -646,7 +648,7 @@
 
 This object wraps a Windows HKEY object, automatically closing it when the
 object is destroyed.  To guarantee cleanup, you can call either the
-:meth:`Close` method on the object, or the :func:`CloseKey` function.
+:meth:`~PyHKEY.Close` method on the object, or the :func:`CloseKey` function.
 
 All registry functions in this module return one of these objects.
 
@@ -666,8 +668,8 @@
 
 Handle objects can be converted to an integer (e.g., using the built-in
 :func:`int` function), in which case the underlying Windows handle value is
-returned.  You can also use the :meth:`Detach` method to return the integer
-handle, and also disconnect the Windows handle from the handle object.
+returned.  You can also use the :meth:`~PyHKEY.Detach` method to return the
+integer handle, and also disconnect the Windows handle from the handle object.
 
 
 .. method:: PyHKEY.Close()
@@ -692,11 +694,12 @@
 .. method:: PyHKEY.__enter__()
             PyHKEY.__exit__(\*exc_info)
 
-   The HKEY object implements :meth:`__enter__` and :meth:`__exit__` and thus
-   supports the context protocol for the :keyword:`with` statement::
+   The HKEY object implements :meth:`~object.__enter__` and
+   :meth:`~object.__exit__` and thus supports the context protocol for the
+   :keyword:`with` statement::
 
       with OpenKey(HKEY_LOCAL_MACHINE, "foo") as key:
-          # ... work with key ...
+          ...  # work with key
 
    will automatically close *key* when control leaves the :keyword:`with` block.
 

Modified: python/branches/py3k-cdecimal/Doc/reference/datamodel.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/reference/datamodel.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/reference/datamodel.rst	Mon Jun  7 12:46:02 2010
@@ -1587,6 +1587,46 @@
 called *members*.
 
 
+Customizing instance and subclass checks
+----------------------------------------
+
+The following methods are used to override the default behavior of the
+:func:`isinstance` and :func:`issubclass` built-in functions.
+
+In particular, the metaclass :class:`abc.ABCMeta` implements these methods in
+order to allow the addition of Abstract Base Classes (ABCs) as "virtual base
+classes" to any class or type (including built-in types), and including to other
+ABCs.
+
+.. method:: class.__instancecheck__(self, instance)
+
+   Return true if *instance* should be considered a (direct or indirect)
+   instance of *class*. If defined, called to implement ``isinstance(instance,
+   class)``.
+
+
+.. method:: class.__subclasscheck__(self, subclass)
+
+   Return true if *subclass* should be considered a (direct or indirect)
+   subclass of *class*.  If defined, called to implement ``issubclass(subclass,
+   class)``.
+
+
+Note that these methods are looked up on the type (metaclass) of a class.  They
+cannot be defined as class methods in the actual class.  This is consistent with
+the lookup of special methods that are called on instances, only that in this
+case the instance is itself a class.
+
+.. seealso::
+
+   :pep:`3119` - Introducing Abstract Base Classes
+      Includes the specification for customizing :func:`isinstance` and
+      :func:`issubclass` behavior through :meth:`__instancecheck__` and
+      :meth:`__subclasscheck__`, with motivation for this functionality in the
+      context of adding Abstract Base Classes (see the :mod:`abc` module) to the
+      language.
+
+
 .. _callable-types:
 
 Emulating callable objects

Modified: python/branches/py3k-cdecimal/Doc/tools/sphinxext/pyspecific.py
==============================================================================
--- python/branches/py3k-cdecimal/Doc/tools/sphinxext/pyspecific.py	(original)
+++ python/branches/py3k-cdecimal/Doc/tools/sphinxext/pyspecific.py	Mon Jun  7 12:46:02 2010
@@ -78,7 +78,7 @@
     'assert', 'assignment', 'atom-identifiers', 'atom-literals',
     'attribute-access', 'attribute-references', 'augassign', 'binary',
     'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object',
-    'bltin-file-objects', 'bltin-null-object', 'bltin-type-objects', 'booleans',
+    'bltin-null-object', 'bltin-type-objects', 'booleans',
     'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound',
     'context-managers', 'continue', 'conversions', 'customization', 'debugger',
     'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel',

Modified: python/branches/py3k-cdecimal/Doc/tutorial/datastructures.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/tutorial/datastructures.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/tutorial/datastructures.rst	Mon Jun  7 12:46:02 2010
@@ -377,10 +377,7 @@
 
 Here is a brief demonstration::
 
-   >>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
-   >>> print(basket)
-   {'orange', 'banana', 'pear', 'apple'}
-   >>> fruit = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
+   >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
    >>> fruit = set(basket)               # create a set without duplicates
    >>> fruit
    {'orange', 'pear', 'apple', 'banana'}

Modified: python/branches/py3k-cdecimal/Doc/whatsnew/3.2.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/whatsnew/3.2.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/whatsnew/3.2.rst	Mon Jun  7 12:46:02 2010
@@ -100,6 +100,18 @@
 
   (Contributed by Tarek Ziade.)
 
+* The *sqlite3* module has some new features:
+
+  * XXX *enable_load_extension*
+
+  * XXX *load_extension*
+
+  * New :class:`~sqlite3.Connection` attribute
+    :attr:`~sqlite3.Connection.in_transaction` is :const:`True` when there
+    are uncommitted changes, and :const:`False` otherwise.  (Contributed
+    by R. David Murray and Shashwat Anand, :issue:`8845`.)
+
+
 Multi-threading
 ===============
 

Modified: python/branches/py3k-cdecimal/Include/longobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/longobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/longobject.h	Mon Jun  7 12:46:02 2010
@@ -101,6 +101,14 @@
 */
 PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
 
+/* _PyLong_Divmod_Near.  Given integers a and b, compute the nearest
+   integer q to the exact quotient a / b, rounding to the nearest even integer
+   in the case of a tie.  Return (q, r), where r = a - q*b.  The remainder r
+   will satisfy abs(r) <= abs(b)/2, with equality possible only if q is
+   even.
+*/
+PyAPI_FUNC(PyObject *) _PyLong_Divmod_Near(PyObject *, PyObject *);
+
 /* _PyLong_FromByteArray:  View the n unsigned bytes as a binary integer in
    base 256, and return a Python long with the same numeric value.
    If n is 0, the integer is 0.  Else:

Modified: python/branches/py3k-cdecimal/Include/pyport.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pyport.h	(original)
+++ python/branches/py3k-cdecimal/Include/pyport.h	Mon Jun  7 12:46:02 2010
@@ -126,6 +126,20 @@
 #endif
 #endif
 
+/* Parameters used for the numeric hash implementation.  See notes for
+   _PyHash_Double in Objects/object.c.  Numeric hashes are based on
+   reduction modulo the prime 2**_PyHASH_BITS - 1. */
+
+#if SIZEOF_LONG >= 8
+#define _PyHASH_BITS 61
+#else
+#define _PyHASH_BITS 31
+#endif
+#define _PyHASH_MODULUS ((1UL << _PyHASH_BITS) - 1)
+#define _PyHASH_INF 314159
+#define _PyHASH_NAN 0
+#define _PyHASH_IMAG 1000003UL
+
 /* uintptr_t is the C9X name for an unsigned integral type such that a
  * legitimate void* can be cast to uintptr_t and then back to void* again
  * without loss of information.  Similarly for intptr_t, wrt a signed

Modified: python/branches/py3k-cdecimal/Include/sysmodule.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/sysmodule.h	(original)
+++ python/branches/py3k-cdecimal/Include/sysmodule.h	Mon Jun  7 12:46:02 2010
@@ -10,6 +10,7 @@
 PyAPI_FUNC(PyObject *) PySys_GetObject(const char *);
 PyAPI_FUNC(int) PySys_SetObject(const char *, PyObject *);
 PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **);
+PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
 PyAPI_FUNC(void) PySys_SetPath(const wchar_t *);
 
 PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
@@ -21,6 +22,7 @@
 
 PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
 PyAPI_FUNC(void) PySys_AddWarnOption(const wchar_t *);
+PyAPI_FUNC(void) PySys_AddWarnOptionUnicode(PyObject *);
 PyAPI_FUNC(int) PySys_HasWarnOptions(void);
 
 #ifdef __cplusplus

Modified: python/branches/py3k-cdecimal/Lib/_abcoll.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/_abcoll.py	(original)
+++ python/branches/py3k-cdecimal/Lib/_abcoll.py	Mon Jun  7 12:46:02 2010
@@ -376,8 +376,9 @@
         return ValuesView(self)
 
     def __eq__(self, other):
-        return isinstance(other, Mapping) and \
-               dict(self.items()) == dict(other.items())
+        if not isinstance(other, Mapping):
+            return NotImplemented
+        return dict(self.items()) == dict(other.items())
 
     def __ne__(self, other):
         return not (self == other)

Modified: python/branches/py3k-cdecimal/Lib/argparse.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/argparse.py	(original)
+++ python/branches/py3k-cdecimal/Lib/argparse.py	Mon Jun  7 12:46:02 2010
@@ -987,7 +987,7 @@
                  version=None,
                  dest=SUPPRESS,
                  default=SUPPRESS,
-                 help=None):
+                 help="show program's version number and exit"):
         super(_VersionAction, self).__init__(
             option_strings=option_strings,
             dest=dest,

Modified: python/branches/py3k-cdecimal/Lib/base64.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/base64.py	(original)
+++ python/branches/py3k-cdecimal/Lib/base64.py	Mon Jun  7 12:46:02 2010
@@ -383,9 +383,9 @@
         if o == '-u': func = decode
         if o == '-t': test(); return
     if args and args[0] != '-':
-        func(open(args[0], 'rb'), sys.stdout)
+        func(open(args[0], 'rb'), sys.stdout.buffer)
     else:
-        func(sys.stdin, sys.stdout)
+        func(sys.stdin.buffer, sys.stdout.buffer)
 
 
 def test():

Modified: python/branches/py3k-cdecimal/Lib/codecs.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/codecs.py	(original)
+++ python/branches/py3k-cdecimal/Lib/codecs.py	Mon Jun  7 12:46:02 2010
@@ -374,6 +374,11 @@
         """
         pass
 
+    def seek(self, offset, whence=0):
+        self.stream.seek(offset, whence)
+        if whence == 0 and offset == 0:
+            self.reset()
+
     def __getattr__(self, name,
                     getattr=getattr):
 
@@ -606,8 +611,8 @@
 
             Resets the codec buffers used for keeping state.
         """
-        self.reset()
         self.stream.seek(offset, whence)
+        self.reset()
 
     def __next__(self):
 
@@ -699,6 +704,12 @@
         self.reader.reset()
         self.writer.reset()
 
+    def seek(self, offset, whence=0):
+        self.stream.seek(offset, whence)
+        self.reader.reset()
+        if whence == 0 and offset == 0:
+            self.writer.reset()
+
     def __getattr__(self, name,
                     getattr=getattr):
 

Modified: python/branches/py3k-cdecimal/Lib/decimal.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/decimal.py	(original)
+++ python/branches/py3k-cdecimal/Lib/decimal.py	Mon Jun  7 12:46:02 2010
@@ -164,7 +164,7 @@
     anything, though.
 
     handle  -- Called when context._raise_error is called and the
-               trap_enabler is set.  First argument is self, second is the
+               trap_enabler is not set.  First argument is self, second is the
                context.  More arguments can be given, those being after
                the explanation in _raise_error (For example,
                context._raise_error(NewError, '(-x)!', self._sign) would
@@ -862,7 +862,7 @@
     # that specified by IEEE 754.
 
     def __eq__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         if self._check_nans(other, context):
@@ -870,7 +870,7 @@
         return self._cmp(other) == 0
 
     def __ne__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         if self._check_nans(other, context):
@@ -879,7 +879,7 @@
 
 
     def __lt__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -888,7 +888,7 @@
         return self._cmp(other) < 0
 
     def __le__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -897,7 +897,7 @@
         return self._cmp(other) <= 0
 
     def __gt__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -906,7 +906,7 @@
         return self._cmp(other) > 0
 
     def __ge__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -935,55 +935,28 @@
 
     def __hash__(self):
         """x.__hash__() <==> hash(x)"""
-        # Decimal integers must hash the same as the ints
-        #
-        # The hash of a nonspecial noninteger Decimal must depend only
-        # on the value of that Decimal, and not on its representation.
-        # For example: hash(Decimal('100E-1')) == hash(Decimal('10')).
-
-        # Equality comparisons involving signaling nans can raise an
-        # exception; since equality checks are implicitly and
-        # unpredictably used when checking set and dict membership, we
-        # prevent signaling nans from being used as set elements or
-        # dict keys by making __hash__ raise an exception.
+
+        # In order to make sure that the hash of a Decimal instance
+        # agrees with the hash of a numerically equal integer, float
+        # or Fraction, we follow the rules for numeric hashes outlined
+        # in the documentation.  (See library docs, 'Built-in Types').
         if self._is_special:
             if self.is_snan():
                 raise TypeError('Cannot hash a signaling NaN value.')
             elif self.is_nan():
-                # 0 to match hash(float('nan'))
-                return 0
+                return _PyHASH_NAN
             else:
-                # values chosen to match hash(float('inf')) and
-                # hash(float('-inf')).
                 if self._sign:
-                    return -271828
+                    return -_PyHASH_INF
                 else:
-                    return 314159
+                    return _PyHASH_INF
 
-        # In Python 2.7, we're allowing comparisons (but not
-        # arithmetic operations) between floats and Decimals;  so if
-        # a Decimal instance is exactly representable as a float then
-        # its hash should match that of the float.
-        self_as_float = float(self)
-        if Decimal.from_float(self_as_float) == self:
-            return hash(self_as_float)
-
-        if self._isinteger():
-            op = _WorkRep(self.to_integral_value())
-            # to make computation feasible for Decimals with large
-            # exponent, we use the fact that hash(n) == hash(m) for
-            # any two nonzero integers n and m such that (i) n and m
-            # have the same sign, and (ii) n is congruent to m modulo
-            # 2**64-1.  So we can replace hash((-1)**s*c*10**e) with
-            # hash((-1)**s*c*pow(10, e, 2**64-1).
-            return hash((-1)**op.sign*op.int*pow(10, op.exp, 2**64-1))
-        # The value of a nonzero nonspecial Decimal instance is
-        # faithfully represented by the triple consisting of its sign,
-        # its adjusted exponent, and its coefficient with trailing
-        # zeros removed.
-        return hash((self._sign,
-                     self._exp+len(self._int),
-                     self._int.rstrip('0')))
+        if self._exp >= 0:
+            exp_hash = pow(10, self._exp, _PyHASH_MODULUS)
+        else:
+            exp_hash = pow(_PyHASH_10INV, -self._exp, _PyHASH_MODULUS)
+        hash_ = int(self._int) * exp_hash % _PyHASH_MODULUS
+        return hash_ if self >= 0 else -hash_
 
     def as_tuple(self):
         """Represents the number as a triple tuple.
@@ -1611,9 +1584,9 @@
         """Decapitate the payload of a NaN to fit the context"""
         payload = self._int
 
-        # maximum length of payload is precision if _clamp=0,
-        # precision-1 if _clamp=1.
-        max_payload_len = context.prec - context._clamp
+        # maximum length of payload is precision if clamp=0,
+        # precision-1 if clamp=1.
+        max_payload_len = context.prec - context.clamp
         if len(payload) > max_payload_len:
             payload = payload[len(payload)-max_payload_len:].lstrip('0')
             return _dec_from_triple(self._sign, payload, self._exp, True)
@@ -1638,11 +1611,11 @@
                 return Decimal(self)
 
         # if self is zero then exponent should be between Etiny and
-        # Emax if _clamp==0, and between Etiny and Etop if _clamp==1.
+        # Emax if clamp==0, and between Etiny and Etop if clamp==1.
         Etiny = context.Etiny()
         Etop = context.Etop()
         if not self:
-            exp_max = [context.Emax, Etop][context._clamp]
+            exp_max = [context.Emax, Etop][context.clamp]
             new_exp = min(max(self._exp, Etiny), exp_max)
             if new_exp != self._exp:
                 context._raise_error(Clamped)
@@ -1702,8 +1675,8 @@
         if self_is_subnormal:
             context._raise_error(Subnormal)
 
-        # fold down if _clamp == 1 and self has too few digits
-        if context._clamp == 1 and self._exp > Etop:
+        # fold down if clamp == 1 and self has too few digits
+        if context.clamp == 1 and self._exp > Etop:
             context._raise_error(Clamped)
             self_padded = self._int + '0'*(self._exp - Etop)
             return _dec_from_triple(self._sign, self_padded, Etop)
@@ -2451,7 +2424,7 @@
 
         if not dup:
             return _dec_from_triple(dup._sign, '0', 0)
-        exp_max = [context.Emax, context.Etop()][context._clamp]
+        exp_max = [context.Emax, context.Etop()][context.clamp]
         end = len(dup._int)
         exp = dup._exp
         while dup._int[end-1] == '0' and exp < exp_max:
@@ -3828,13 +3801,13 @@
     Emax -   Maximum exponent
     capitals -      If 1, 1*10^1 is printed as 1E+1.
                     If 0, printed as 1e1
-    _clamp - If 1, change exponents if too high (Default 0)
+    clamp -  If 1, change exponents if too high (Default 0)
     """
 
     def __init__(self, prec=None, rounding=None,
                  traps=None, flags=None,
                  Emin=None, Emax=None,
-                 capitals=None, _clamp=0,
+                 capitals=None, clamp=None,
                  _ignored_flags=None):
         if flags is None:
             flags = []
@@ -3855,7 +3828,8 @@
         """Show the current context."""
         s = []
         s.append('Context(prec=%(prec)d, rounding=%(rounding)s, '
-                 'Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d'
+                 'Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, '
+                 'clamp=%(clamp)d'
                  % vars(self))
         names = [f.__name__ for f, v in self.flags.items() if v]
         s.append('flags=[' + ', '.join(names) + ']')
@@ -3872,23 +3846,45 @@
         """Returns a shallow copy from self."""
         nc = Context(self.prec, self.rounding, self.traps,
                      self.flags, self.Emin, self.Emax,
-                     self.capitals, self._clamp, self._ignored_flags)
+                     self.capitals, self.clamp, self._ignored_flags)
         return nc
 
     def copy(self):
         """Returns a deep copy from self."""
         nc = Context(self.prec, self.rounding, self.traps.copy(),
                      self.flags.copy(), self.Emin, self.Emax,
-                     self.capitals, self._clamp, self._ignored_flags)
+                     self.capitals, self.clamp, self._ignored_flags)
         return nc
     __copy__ = copy
 
+    # _clamp is provided for backwards compatibility with third-party
+    # code.  May be removed in Python >= 3.3.
+    def _get_clamp(self):
+        "_clamp mirrors the clamp attribute.  Its use is deprecated."
+        import warnings
+        warnings.warn('Use of the _clamp attribute is deprecated. '
+                      'Please use clamp instead.',
+                      DeprecationWarning)
+        return self.clamp
+
+    def _set_clamp(self, clamp):
+        "_clamp mirrors the clamp attribute.  Its use is deprecated."
+        import warnings
+        warnings.warn('Use of the _clamp attribute is deprecated. '
+                      'Please use clamp instead.',
+                      DeprecationWarning)
+        self.clamp = clamp
+
+    # don't bother with _del_clamp;  no sane 3rd party code should
+    # be deleting the _clamp attribute
+    _clamp = property(_get_clamp, _set_clamp)
+
     def _raise_error(self, condition, explanation = None, *args):
         """Handles an error
 
         If the flag is in _ignored_flags, returns the default response.
         Otherwise, it sets the flag, then, if the corresponding
-        trap_enabler is set, it reaises the exception.  Otherwise, it returns
+        trap_enabler is set, it reraises the exception.  Otherwise, it returns
         the default value after setting the flag.
         """
         error = _condition_map.get(condition, condition)
@@ -3965,7 +3961,7 @@
                                      "permitted.")
 
         d = Decimal(num, context=self)
-        if d._isnan() and len(d._int) > self.prec - self._clamp:
+        if d._isnan() and len(d._int) > self.prec - self.clamp:
             return self._raise_error(ConversionSyntax,
                                      "diagnostic info too long in NaN")
         return d._fix(self)
@@ -5875,7 +5871,8 @@
         flags=[],
         Emax=999999999,
         Emin=-999999999,
-        capitals=1
+        capitals=1,
+        clamp=0
 )
 
 # Pre-made alternate contexts offered by the specification
@@ -6194,6 +6191,17 @@
 # _SignedInfinity[sign] is infinity w/ that sign
 _SignedInfinity = (_Infinity, _NegativeInfinity)
 
+# Constants related to the hash implementation;  hash(x) is based
+# on the reduction of x modulo _PyHASH_MODULUS
+import sys
+_PyHASH_MODULUS = sys.hash_info.modulus
+# hash values to use for positive and negative infinities, and nans
+_PyHASH_INF = sys.hash_info.inf
+_PyHASH_NAN = sys.hash_info.nan
+del sys
+
+# _PyHASH_10INV is the inverse of 10 modulo the prime _PyHASH_MODULUS
+_PyHASH_10INV = pow(10, _PyHASH_MODULUS - 2, _PyHASH_MODULUS)
 
 
 if __name__ == '__main__':

Modified: python/branches/py3k-cdecimal/Lib/distutils/log.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/distutils/log.py	(original)
+++ python/branches/py3k-cdecimal/Lib/distutils/log.py	Mon Jun  7 12:46:02 2010
@@ -27,6 +27,10 @@
                 stream = sys.stderr
             else:
                 stream = sys.stdout
+            if stream.errors == 'strict':
+                # emulate backslashreplace error handler
+                encoding = stream.encoding
+                msg = msg.encode(encoding, "backslashreplace").decode(encoding)
             stream.write('%s\n' % msg)
             stream.flush()
 

Modified: python/branches/py3k-cdecimal/Lib/distutils/unixccompiler.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/distutils/unixccompiler.py	(original)
+++ python/branches/py3k-cdecimal/Lib/distutils/unixccompiler.py	Mon Jun  7 12:46:02 2010
@@ -15,7 +15,7 @@
 
 __revision__ = "$Id$"
 
-import os, sys
+import os, sys, re
 
 from distutils.dep_util import newer
 from distutils.ccompiler import \
@@ -320,10 +320,31 @@
         dylib_f = self.library_filename(lib, lib_type='dylib')
         static_f = self.library_filename(lib, lib_type='static')
 
+        if sys.platform == 'darwin':
+            # On OSX users can specify an alternate SDK using
+            # '-isysroot', calculate the SDK root if it is specified
+            # (and use it further on)
+            _sysconfig = __import__('sysconfig')
+            cflags = _sysconfig.get_config_var('CFLAGS')
+            m = re.search(r'-isysroot\s+(\S+)', cflags)
+            if m is None:
+                sysroot = '/'
+            else:
+                sysroot = m.group(1)
+
+
+
         for dir in dirs:
             shared = os.path.join(dir, shared_f)
             dylib = os.path.join(dir, dylib_f)
             static = os.path.join(dir, static_f)
+
+            if sys.platform == 'darwin' and (
+                    dir.startswith('/System/') or dir.startswith('/usr/')):
+                shared = os.path.join(sysroot, dir[1:], shared_f)
+                dylib = os.path.join(sysroot, dir[1:], dylib_f)
+                static = os.path.join(sysroot, dir[1:], static_f)
+
             # We're second-guessing the linker here, with not much hard
             # data to go on: GCC seems to prefer the shared library, so I'm
             # assuming that *all* Unix C compilers do.  And of course I'm

Modified: python/branches/py3k-cdecimal/Lib/email/charset.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/email/charset.py	(original)
+++ python/branches/py3k-cdecimal/Lib/email/charset.py	Mon Jun  7 12:46:02 2010
@@ -377,6 +377,8 @@
         """
         # 7bit/8bit encodings return the string unchanged (module conversions)
         if self.body_encoding is BASE64:
+            if isinstance(string, str):
+                string = string.encode(self.output_charset)
             return email.base64mime.body_encode(string)
         elif self.body_encoding is QP:
             return email.quoprimime.body_encode(string)

Modified: python/branches/py3k-cdecimal/Lib/email/encoders.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/email/encoders.py	(original)
+++ python/branches/py3k-cdecimal/Lib/email/encoders.py	Mon Jun  7 12:46:02 2010
@@ -29,7 +29,7 @@
     Also, add an appropriate Content-Transfer-Encoding header.
     """
     orig = msg.get_payload()
-    encdata = _bencode(orig)
+    encdata = str(_bencode(orig), 'ascii')
     msg.set_payload(encdata)
     msg['Content-Transfer-Encoding'] = 'base64'
 

Modified: python/branches/py3k-cdecimal/Lib/email/test/test_email.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/email/test/test_email.py	(original)
+++ python/branches/py3k-cdecimal/Lib/email/test/test_email.py	Mon Jun  7 12:46:02 2010
@@ -535,7 +535,7 @@
         # whose output character set is 7bit gets a transfer-encoding
         # of 7bit.
         eq = self.assertEqual
-        msg = MIMEText('\xca\xb8', _charset='euc-jp')
+        msg = MIMEText('文', _charset='euc-jp')
         eq(msg['content-transfer-encoding'], '7bit')
 
 
@@ -970,7 +970,8 @@
 
     def test_encoding(self):
         payload = self._au.get_payload()
-        self.assertEqual(base64.decodebytes(payload), self._audiodata)
+        self.assertEqual(base64.decodebytes(bytes(payload, 'ascii')),
+                self._audiodata)
 
     def test_checkSetMinor(self):
         au = MIMEAudio(self._audiodata, 'fish')
@@ -1010,7 +1011,8 @@
 
     def test_encoding(self):
         payload = self._im.get_payload()
-        self.assertEqual(base64.decodebytes(payload), self._imgdata)
+        self.assertEqual(base64.decodebytes(bytes(payload, 'ascii')),
+                self._imgdata)
 
     def test_checkSetMinor(self):
         im = MIMEImage(self._imgdata, 'fish')
@@ -1050,7 +1052,7 @@
         eq = self.assertEqual
         bytes = b'\xfa\xfb\xfc\xfd\xfe\xff'
         msg = MIMEApplication(bytes)
-        eq(msg.get_payload(), b'+vv8/f7/')
+        eq(msg.get_payload(), '+vv8/f7/')
         eq(msg.get_payload(decode=True), bytes)
 
 
@@ -1080,6 +1082,33 @@
         eq(msg.get_charset().input_charset, 'us-ascii')
         eq(msg['content-type'], 'text/plain; charset="us-ascii"')
 
+    def test_7bit_input(self):
+        eq = self.assertEqual
+        msg = MIMEText('hello there', _charset='us-ascii')
+        eq(msg.get_charset().input_charset, 'us-ascii')
+        eq(msg['content-type'], 'text/plain; charset="us-ascii"')
+
+    def test_7bit_input_no_charset(self):
+        eq = self.assertEqual
+        msg = MIMEText('hello there')
+        eq(msg.get_charset(), 'us-ascii')
+        eq(msg['content-type'], 'text/plain; charset="us-ascii"')
+        self.assertTrue('hello there' in msg.as_string())
+
+    def test_utf8_input(self):
+        teststr = '\u043a\u0438\u0440\u0438\u043b\u0438\u0446\u0430'
+        eq = self.assertEqual
+        msg = MIMEText(teststr, _charset='utf-8')
+        eq(msg.get_charset().output_charset, 'utf-8')
+        eq(msg['content-type'], 'text/plain; charset="utf-8"')
+        eq(msg.get_payload(decode=True), teststr.encode('utf-8'))
+
+    @unittest.skip("can't fix because of backward compat in email5, "
+        "will fix in email6")
+    def test_utf8_input_no_charset(self):
+        teststr = '\u043a\u0438\u0440\u0438\u043b\u0438\u0446\u0430'
+        self.assertRaises(UnicodeEncodeError, MIMEText, teststr)
+
 
 
 # Test complicated multipart/* messages

Modified: python/branches/py3k-cdecimal/Lib/encodings/utf_16.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/encodings/utf_16.py	(original)
+++ python/branches/py3k-cdecimal/Lib/encodings/utf_16.py	Mon Jun  7 12:46:02 2010
@@ -103,17 +103,23 @@
 
 class StreamWriter(codecs.StreamWriter):
     def __init__(self, stream, errors='strict'):
-        self.bom_written = False
         codecs.StreamWriter.__init__(self, stream, errors)
+        self.encoder = None
+
+    def reset(self):
+        codecs.StreamWriter.reset(self)
+        self.encoder = None
 
     def encode(self, input, errors='strict'):
-        self.bom_written = True
-        result = codecs.utf_16_encode(input, errors)
-        if sys.byteorder == 'little':
-            self.encode = codecs.utf_16_le_encode
+        if self.encoder is None:
+            result = codecs.utf_16_encode(input, errors)
+            if sys.byteorder == 'little':
+                self.encoder = codecs.utf_16_le_encode
+            else:
+                self.encoder = codecs.utf_16_be_encode
+            return result
         else:
-            self.encode = codecs.utf_16_be_encode
-        return result
+            return self.encoder(input, errors)
 
 class StreamReader(codecs.StreamReader):
 

Modified: python/branches/py3k-cdecimal/Lib/encodings/utf_32.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/encodings/utf_32.py	(original)
+++ python/branches/py3k-cdecimal/Lib/encodings/utf_32.py	Mon Jun  7 12:46:02 2010
@@ -98,17 +98,23 @@
 
 class StreamWriter(codecs.StreamWriter):
     def __init__(self, stream, errors='strict'):
-        self.bom_written = False
+        self.encoder = None
         codecs.StreamWriter.__init__(self, stream, errors)
 
+    def reset(self):
+        codecs.StreamWriter.reset(self)
+        self.encoder = None
+
     def encode(self, input, errors='strict'):
-        self.bom_written = True
-        result = codecs.utf_32_encode(input, errors)
-        if sys.byteorder == 'little':
-            self.encode = codecs.utf_32_le_encode
+        if self.encoder is None:
+            result = codecs.utf_32_encode(input, errors)
+            if sys.byteorder == 'little':
+                self.encoder = codecs.utf_32_le_encode
+            else:
+                self.encoder = codecs.utf_32_be_encode
+            return result
         else:
-            self.encode = codecs.utf_32_be_encode
-        return result
+            return self.encoder(input, errors)
 
 class StreamReader(codecs.StreamReader):
 

Modified: python/branches/py3k-cdecimal/Lib/fractions.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/fractions.py	(original)
+++ python/branches/py3k-cdecimal/Lib/fractions.py	Mon Jun  7 12:46:02 2010
@@ -8,6 +8,7 @@
 import numbers
 import operator
 import re
+import sys
 
 __all__ = ['Fraction', 'gcd']
 
@@ -23,6 +24,12 @@
         a, b = b, a%b
     return a
 
+# Constants related to the hash implementation;  hash(x) is based
+# on the reduction of x modulo the prime _PyHASH_MODULUS.
+_PyHASH_MODULUS = sys.hash_info.modulus
+# Value to be used for rationals that reduce to infinity modulo
+# _PyHASH_MODULUS.
+_PyHASH_INF = sys.hash_info.inf
 
 _RATIONAL_FORMAT = re.compile(r"""
     \A\s*                      # optional whitespace at the start, then
@@ -528,16 +535,22 @@
 
         """
         # XXX since this method is expensive, consider caching the result
-        if self._denominator == 1:
-            # Get integers right.
-            return hash(self._numerator)
-        # Expensive check, but definitely correct.
-        if self == float(self):
-            return hash(float(self))
+
+        # In order to make sure that the hash of a Fraction agrees
+        # with the hash of a numerically equal integer, float or
+        # Decimal instance, we follow the rules for numeric hashes
+        # outlined in the documentation.  (See library docs, 'Built-in
+        # Types').
+
+        # dinv is the inverse of self._denominator modulo the prime
+        # _PyHASH_MODULUS, or 0 if self._denominator is divisible by
+        # _PyHASH_MODULUS.
+        dinv = pow(self._denominator, _PyHASH_MODULUS - 2, _PyHASH_MODULUS)
+        if not dinv:
+            hash_ = _PyHASH_INF
         else:
-            # Use tuple's hash to avoid a high collision rate on
-            # simple fractions.
-            return hash((self._numerator, self._denominator))
+            hash_ = abs(self._numerator) * dinv % _PyHASH_MODULUS
+        return hash_ if self >= 0 else -hash_
 
     def __eq__(a, b):
         """a == b"""

Modified: python/branches/py3k-cdecimal/Lib/ftplib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/ftplib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/ftplib.py	Mon Jun  7 12:46:02 2010
@@ -638,9 +638,17 @@
         ssl_version = ssl.PROTOCOL_TLSv1
 
         def __init__(self, host='', user='', passwd='', acct='', keyfile=None,
-                     certfile=None, timeout=_GLOBAL_DEFAULT_TIMEOUT):
+                     certfile=None, context=None,
+                     timeout=_GLOBAL_DEFAULT_TIMEOUT):
+            if context is not None and keyfile is not None:
+                raise ValueError("context and keyfile arguments are mutually "
+                                 "exclusive")
+            if context is not None and certfile is not None:
+                raise ValueError("context and certfile arguments are mutually "
+                                 "exclusive")
             self.keyfile = keyfile
             self.certfile = certfile
+            self.context = context
             self._prot_p = False
             FTP.__init__(self, host, user, passwd, acct, timeout)
 
@@ -657,8 +665,12 @@
                 resp = self.voidcmd('AUTH TLS')
             else:
                 resp = self.voidcmd('AUTH SSL')
-            self.sock = ssl.wrap_socket(self.sock, self.keyfile, self.certfile,
-                                        ssl_version=self.ssl_version)
+            if self.context is not None:
+                self.sock = self.context.wrap_socket(self.sock)
+            else:
+                self.sock = ssl.wrap_socket(self.sock, self.keyfile,
+                                            self.certfile,
+                                            ssl_version=self.ssl_version)
             self.file = self.sock.makefile(mode='r', encoding=self.encoding)
             return resp
 
@@ -689,8 +701,11 @@
         def ntransfercmd(self, cmd, rest=None):
             conn, size = FTP.ntransfercmd(self, cmd, rest)
             if self._prot_p:
-                conn = ssl.wrap_socket(conn, self.keyfile, self.certfile,
-                                       ssl_version=self.ssl_version)
+                if self.context is not None:
+                    conn = self.context.wrap_socket(conn)
+                else:
+                    conn = ssl.wrap_socket(conn, self.keyfile, self.certfile,
+                                           ssl_version=self.ssl_version)
             return conn, size
 
         def retrbinary(self, cmd, callback, blocksize=8192, rest=None):

Modified: python/branches/py3k-cdecimal/Lib/functools.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/functools.py	(original)
+++ python/branches/py3k-cdecimal/Lib/functools.py	Mon Jun  7 12:46:02 2010
@@ -51,7 +51,7 @@
                    assigned=assigned, updated=updated)
 
 def total_ordering(cls):
-    'Class decorator that fills-in missing ordering methods'
+    """Class decorator that fills in missing ordering methods"""
     convert = {
         '__lt__': [('__gt__', lambda self, other: other < self),
                    ('__le__', lambda self, other: not other < self),
@@ -78,7 +78,7 @@
     return cls
 
 def cmp_to_key(mycmp):
-    'Convert a cmp= function into a key= function'
+    """Convert a cmp= function into a key= function"""
     class K(object):
         def __init__(self, obj, *args):
             self.obj = obj

Modified: python/branches/py3k-cdecimal/Lib/html/parser.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/html/parser.py	(original)
+++ python/branches/py3k-cdecimal/Lib/html/parser.py	Mon Jun  7 12:46:02 2010
@@ -175,6 +175,9 @@
                     i = self.updatepos(i, k)
                     continue
                 else:
+                    if ";" in rawdata[i:]: #bail by consuming &#
+                        self.handle_data(rawdata[0:2])
+                        i = self.updatepos(i, 2)
                     break
             elif startswith('&', i):
                 match = entityref.match(rawdata, i)

Modified: python/branches/py3k-cdecimal/Lib/http/client.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/http/client.py	(original)
+++ python/branches/py3k-cdecimal/Lib/http/client.py	Mon Jun  7 12:46:02 2010
@@ -488,6 +488,7 @@
             return b""
 
         if self._method == "HEAD":
+            self.close()
             return b""
 
         if self.chunked:

Modified: python/branches/py3k-cdecimal/Lib/lib2to3/refactor.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/lib2to3/refactor.py	(original)
+++ python/branches/py3k-cdecimal/Lib/lib2to3/refactor.py	Mon Jun  7 12:46:02 2010
@@ -564,7 +564,9 @@
         This is necessary to get correct line number / offset information
         in the parser diagnostics and embedded into the parse tree.
         """
-        return self.driver.parse_tokens(self.wrap_toks(block, lineno, indent))
+        tree = self.driver.parse_tokens(self.wrap_toks(block, lineno, indent))
+        tree.future_features = frozenset()
+        return tree
 
     def wrap_toks(self, block, lineno, indent):
         """Wraps a tokenize stream to systematically modify start/end."""

Modified: python/branches/py3k-cdecimal/Lib/linecache.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/linecache.py	(original)
+++ python/branches/py3k-cdecimal/Lib/linecache.py	Mon Jun  7 12:46:02 2010
@@ -73,13 +73,13 @@
 
     if filename in cache:
         del cache[filename]
-    if not filename or filename[0] + filename[-1] == '<>':
+    if not filename or (filename.startswith('<') and filename.endswith('>')):
         return []
 
     fullname = filename
     try:
         stat = os.stat(fullname)
-    except os.error as msg:
+    except OSError:
         basename = filename
 
         # Try for a __loader__, if available
@@ -114,20 +114,23 @@
                 fullname = os.path.join(dirname, basename)
             except (TypeError, AttributeError):
                 # Not sufficiently string-like to do anything useful with.
+                continue
+            try:
+                stat = os.stat(fullname)
+                break
+            except os.error:
                 pass
-            else:
-                try:
-                    stat = os.stat(fullname)
-                    break
-                except os.error:
-                    pass
         else:
-            # No luck
             return []
-    with open(fullname, 'rb') as fp:
-        coding, line = tokenize.detect_encoding(fp.readline)
-    with open(fullname, 'r', encoding=coding) as fp:
-        lines = fp.readlines()
+    try:
+        with open(fullname, 'rb') as fp:
+            coding, line = tokenize.detect_encoding(fp.readline)
+        with open(fullname, 'r', encoding=coding) as fp:
+            lines = fp.readlines()
+    except IOError:
+        pass
+    if lines and not lines[-1].endswith('\n'):
+        lines[-1] += '\n'
     size, mtime = stat.st_size, stat.st_mtime
     cache[filename] = size, mtime, lines, fullname
     return lines

Modified: python/branches/py3k-cdecimal/Lib/pipes.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/pipes.py	(original)
+++ python/branches/py3k-cdecimal/Lib/pipes.py	Mon Jun  7 12:46:02 2010
@@ -249,11 +249,11 @@
 
 # Reliably quote a string as a single argument for /bin/sh
 
-_safechars = string.ascii_letters + string.digits + '!@%_-+=:,./' # Safe unquoted
-_funnychars = '"`$\\'                           # Unsafe inside "double quotes"
+# Safe unquoted
+_safechars = frozenset(string.ascii_letters + string.digits + '@%_-+=:,./')
 
 def quote(file):
-    ''' return a shell-escaped version of the file string '''
+    """Return a shell-escaped version of the file string."""
     for c in file:
         if c not in _safechars:
             break
@@ -261,11 +261,6 @@
         if not file:
             return "''"
         return file
-    if '\'' not in file:
-        return '\'' + file + '\''
-    res = ''
-    for c in file:
-        if c in _funnychars:
-            c = '\\' + c
-        res = res + c
-    return '"' + res + '"'
+    # use single quotes, and put single quotes into double quotes
+    # the string $'b is then quoted as '$'"'"'b'
+    return "'" + file.replace("'", "'\"'\"'") + "'"

Modified: python/branches/py3k-cdecimal/Lib/sqlite3/test/dbapi.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/sqlite3/test/dbapi.py	(original)
+++ python/branches/py3k-cdecimal/Lib/sqlite3/test/dbapi.py	Mon Jun  7 12:46:02 2010
@@ -84,6 +84,7 @@
                         "NotSupportedError is not a subclass of DatabaseError")
 
 class ConnectionTests(unittest.TestCase):
+
     def setUp(self):
         self.cx = sqlite.connect(":memory:")
         cu = self.cx.cursor()
@@ -140,6 +141,28 @@
         self.assertEqual(self.cx.ProgrammingError, sqlite.ProgrammingError)
         self.assertEqual(self.cx.NotSupportedError, sqlite.NotSupportedError)
 
+    def CheckInTransaction(self):
+        # Can't use db from setUp because we want to test initial state.
+        cx = sqlite.connect(":memory:")
+        cu = cx.cursor()
+        self.assertEqual(cx.in_transaction, False)
+        cu.execute("create table transactiontest(id integer primary key, name text)")
+        self.assertEqual(cx.in_transaction, False)
+        cu.execute("insert into transactiontest(name) values (?)", ("foo",))
+        self.assertEqual(cx.in_transaction, True)
+        cu.execute("select name from transactiontest where name=?", ["foo"])
+        row = cu.fetchone()
+        self.assertEqual(cx.in_transaction, True)
+        cx.commit()
+        self.assertEqual(cx.in_transaction, False)
+        cu.execute("select name from transactiontest where name=?", ["foo"])
+        row = cu.fetchone()
+        self.assertEqual(cx.in_transaction, False)
+
+    def CheckInTransactionRO(self):
+        with self.assertRaises(AttributeError):
+            self.cx.in_transaction = True
+
 class CursorTests(unittest.TestCase):
     def setUp(self):
         self.cx = sqlite.connect(":memory:")

Modified: python/branches/py3k-cdecimal/Lib/ssl.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/ssl.py	(original)
+++ python/branches/py3k-cdecimal/Lib/ssl.py	Mon Jun  7 12:46:02 2010
@@ -63,6 +63,7 @@
 from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
 from _ssl import (PROTOCOL_SSLv2, PROTOCOL_SSLv3, PROTOCOL_SSLv23,
                   PROTOCOL_TLSv1)
+from _ssl import OP_ALL, OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1
 from _ssl import RAND_status, RAND_egd, RAND_add
 from _ssl import (
     SSL_ERROR_ZERO_RETURN,

Modified: python/branches/py3k-cdecimal/Lib/subprocess.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/subprocess.py	(original)
+++ python/branches/py3k-cdecimal/Lib/subprocess.py	Mon Jun  7 12:46:02 2010
@@ -843,7 +843,7 @@
             # Process startup details
             if startupinfo is None:
                 startupinfo = STARTUPINFO()
-            if None not in (p2cread, c2pwrite, errwrite):
+            if -1 not in (p2cread, c2pwrite, errwrite):
                 startupinfo.dwFlags |= _subprocess.STARTF_USESTDHANDLES
                 startupinfo.hStdInput = p2cread
                 startupinfo.hStdOutput = c2pwrite

Modified: python/branches/py3k-cdecimal/Lib/sysconfig.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/sysconfig.py	(original)
+++ python/branches/py3k-cdecimal/Lib/sysconfig.py	Mon Jun  7 12:46:02 2010
@@ -5,6 +5,10 @@
 import os
 from os.path import pardir, realpath
 
+__all__ = ['parse_config_h', 'get_config_h_filename', 'get_scheme_names',
+           'get_path_names', 'get_paths', 'get_path', 'get_config_vars',
+           'get_config_var', 'get_platform', 'get_python_version']
+
 _INSTALL_SCHEMES = {
     'posix_prefix': {
         'stdlib': '{base}/lib/python{py_version_short}',
@@ -47,10 +51,10 @@
         'data'   : '{base}',
         },
     'os2_home': {
-        'stdlib': '{userbase}/lib/python/{py_version_short}',
-        'platstdlib': '{userbase}/lib/python/{py_version_short}',
-        'purelib': '{userbase}/lib/python/{py_version_short}/site-packages',
-        'platlib': '{userbase}/lib/python/{py_version_short}/site-packages',
+        'stdlib': '{userbase}/lib/python{py_version_short}',
+        'platstdlib': '{userbase}/lib/python{py_version_short}',
+        'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
+        'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
         'include': '{userbase}/include/python{py_version_short}',
         'scripts': '{userbase}/bin',
         'data'   : '{userbase}',
@@ -65,10 +69,10 @@
         'data'   : '{userbase}',
         },
     'posix_user': {
-        'stdlib': '{userbase}/lib/python/{py_version_short}',
-        'platstdlib': '{userbase}/lib/python/{py_version_short}',
-        'purelib': '{userbase}/lib/python/{py_version_short}/site-packages',
-        'platlib': '{userbase}/lib/python/{py_version_short}/site-packages',
+        'stdlib': '{userbase}/lib/python{py_version_short}',
+        'platstdlib': '{userbase}/lib/python{py_version_short}',
+        'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
+        'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
         'include': '{userbase}/include/python{py_version_short}',
         'scripts': '{userbase}/bin',
         'data'   : '{userbase}',
@@ -686,3 +690,22 @@
 
 def get_python_version():
     return _PY_VERSION_SHORT
+
+def _print_dict(title, data):
+    for index, (key, value) in enumerate(sorted(data.items())):
+        if index == 0:
+            print('{0}: '.format(title))
+        print('\t{0} = "{1}"'.format(key, value))
+
+def _main():
+    """Displays all information sysconfig detains."""
+    print('Platform: "{0}"'.format(get_platform()))
+    print('Python version: "{0}"'.format(get_python_version()))
+    print('Current installation scheme: "{0}"'.format(_get_default_scheme()))
+    print('')
+    _print_dict('Paths', get_paths())
+    print('')
+    _print_dict('Variables', get_config_vars())
+
+if __name__ == '__main__':
+    _main()

Modified: python/branches/py3k-cdecimal/Lib/tabnanny.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tabnanny.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tabnanny.py	Mon Jun  7 12:46:02 2010
@@ -93,8 +93,11 @@
                 check(fullname)
         return
 
+    with open(file, 'rb') as f:
+        encoding, lines = tokenize.detect_encoding(f.readline)
+
     try:
-        f = open(file)
+        f = open(file, encoding=encoding)
     except IOError as msg:
         errprint("%r: I/O Error: %s" % (file, msg))
         return

Modified: python/branches/py3k-cdecimal/Lib/tarfile.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tarfile.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tarfile.py	Mon Jun  7 12:46:02 2010
@@ -1920,7 +1920,7 @@
         tarinfo.mode = stmd
         tarinfo.uid = statres.st_uid
         tarinfo.gid = statres.st_gid
-        if stat.S_ISREG(stmd):
+        if type == REGTYPE:
             tarinfo.size = statres.st_size
         else:
             tarinfo.size = 0
@@ -2163,8 +2163,7 @@
                 raise StreamError("cannot extract (sym)link as file object")
             else:
                 # A (sym)link's file object is its target's file object.
-                return self.extractfile(self._getmember(tarinfo.linkname,
-                                                        tarinfo))
+                return self.extractfile(self._find_link_target(tarinfo))
         else:
             # If there's no data associated with the member (directory, chrdev,
             # blkdev, etc.), return None instead of a file object.
@@ -2273,27 +2272,21 @@
           (platform limitation), we try to make a copy of the referenced file
           instead of a link.
         """
-        try:
+        if hasattr(os, "symlink") and hasattr(os, "link"):
+            # For systems that support symbolic and hard links.
             if tarinfo.issym():
                 os.symlink(tarinfo.linkname, targetpath)
             else:
                 # See extract().
-                os.link(tarinfo._link_target, targetpath)
-        except AttributeError:
-            if tarinfo.issym():
-                linkpath = os.path.dirname(tarinfo.name) + "/" + \
-                                        tarinfo.linkname
-            else:
-                linkpath = tarinfo.linkname
-
+                if os.path.exists(tarinfo._link_target):
+                    os.link(tarinfo._link_target, targetpath)
+                else:
+                    self._extract_member(self._find_link_target(tarinfo), targetpath)
+        else:
             try:
-                self._extract_member(self.getmember(linkpath), targetpath)
-            except (EnvironmentError, KeyError) as e:
-                linkpath = linkpath.replace("/", os.sep)
-                try:
-                    shutil.copy2(linkpath, targetpath)
-                except EnvironmentError as e:
-                    raise IOError("link could not be created")
+                self._extract_member(self._find_link_target(tarinfo), targetpath)
+            except KeyError:
+                raise ExtractError("unable to resolve link inside archive")
 
     def chown(self, tarinfo, targetpath):
         """Set owner of targetpath according to tarinfo.
@@ -2392,21 +2385,28 @@
     #--------------------------------------------------------------------------
     # Little helper methods:
 
-    def _getmember(self, name, tarinfo=None):
+    def _getmember(self, name, tarinfo=None, normalize=False):
         """Find an archive member by name from bottom to top.
            If tarinfo is given, it is used as the starting point.
         """
         # Ensure that all members have been loaded.
         members = self.getmembers()
 
-        if tarinfo is None:
-            end = len(members)
-        else:
-            end = members.index(tarinfo)
+        # Limit the member search list up to tarinfo.
+        if tarinfo is not None:
+            members = members[:members.index(tarinfo)]
 
-        for i in range(end - 1, -1, -1):
-            if name == members[i].name:
-                return members[i]
+        if normalize:
+            name = os.path.normpath(name)
+
+        for member in reversed(members):
+            if normalize:
+                member_name = os.path.normpath(member.name)
+            else:
+                member_name = member.name
+
+            if name == member_name:
+                return member
 
     def _load(self):
         """Read through the entire archive file and look for readable
@@ -2427,6 +2427,25 @@
         if mode is not None and self.mode not in mode:
             raise IOError("bad operation for mode %r" % self.mode)
 
+    def _find_link_target(self, tarinfo):
+        """Find the target member of a symlink or hardlink member in the
+           archive.
+        """
+        if tarinfo.issym():
+            # Always search the entire archive.
+            linkname = os.path.dirname(tarinfo.name) + "/" + tarinfo.linkname
+            limit = None
+        else:
+            # Search the archive before the link, because a hard link is
+            # just a reference to an already archived file.
+            linkname = tarinfo.linkname
+            limit = tarinfo
+
+        member = self._getmember(linkname, tarinfo=limit, normalize=True)
+        if member is None:
+            raise KeyError("linkname %r not found" % linkname)
+        return member
+
     def __iter__(self):
         """Provide an iterator object.
         """

Modified: python/branches/py3k-cdecimal/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/regrtest.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/regrtest.py	Mon Jun  7 12:46:02 2010
@@ -258,6 +258,8 @@
     on the command line.
     """
 
+    replace_stdout()
+
     support.record_original_stdout(sys.stdout)
     try:
         opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:nj:',
@@ -376,7 +378,6 @@
         elif o in ('-j', '--multiprocess'):
             use_mp = int(a)
         elif o == '--slaveargs':
-            replace_stdout()
             args, kwargs = json.loads(a)
             try:
                 result = runtest(*args, **kwargs)
@@ -515,8 +516,6 @@
     else:
         tests = iter(selected)
 
-    replace_stdout()
-
     if use_mp:
         try:
             from threading import Thread

Modified: python/branches/py3k-cdecimal/Lib/test/test_argparse.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_argparse.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_argparse.py	Mon Jun  7 12:46:02 2010
@@ -3688,6 +3688,25 @@
         '''
     version = ''
 
+class TestHelpVersionAction(HelpTestCase):
+    """Test the default help for the version action"""
+
+    parser_signature = Sig(prog='PROG', description='description')
+    argument_signatures = [Sig('-V', '--version', action='version', version='3.6')]
+    argument_group_signatures = []
+    usage = '''\
+        usage: PROG [-h] [-V]
+        '''
+    help = usage + '''\
+
+        description
+
+        optional arguments:
+          -h, --help     show this help message and exit
+          -V, --version  show program's version number and exit
+        '''
+    version = ''
+
 # =====================================
 # Optional/Positional constructor tests
 # =====================================

Modified: python/branches/py3k-cdecimal/Lib/test/test_base64.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_base64.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_base64.py	Mon Jun  7 12:46:02 2010
@@ -2,6 +2,8 @@
 from test import support
 import base64
 import binascii
+import sys
+import subprocess
 
 
 
@@ -208,6 +210,38 @@
 
 
 
+class TestMain(unittest.TestCase):
+    def get_output(self, *args, **options):
+        args = (sys.executable, '-m', 'base64') + args
+        return subprocess.check_output(args, **options)
+
+    def test_encode_decode(self):
+        output = self.get_output('-t')
+        self.assertSequenceEqual(output.splitlines(), (
+            b"b'Aladdin:open sesame'",
+            br"b'QWxhZGRpbjpvcGVuIHNlc2FtZQ==\n'",
+            b"b'Aladdin:open sesame'",
+        ))
+
+    def test_encode_file(self):
+        with open(support.TESTFN, 'wb') as fp:
+            fp.write(b'a\xffb\n')
+
+        output = self.get_output('-e', support.TESTFN)
+        self.assertEquals(output.rstrip(), b'Yf9iCg==')
+
+        with open(support.TESTFN, 'rb') as fp:
+            output = self.get_output('-e', stdin=fp)
+        self.assertEquals(output.rstrip(), b'Yf9iCg==')
+
+    def test_decode(self):
+        with open(support.TESTFN, 'wb') as fp:
+            fp.write(b'Yf9iCg==')
+        output = self.get_output('-d', support.TESTFN)
+        self.assertEquals(output.rstrip(), b'a\xffb')
+
+
+
 def test_main():
     support.run_unittest(__name__)
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_builtin.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_builtin.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_builtin.py	Mon Jun  7 12:46:02 2010
@@ -124,6 +124,16 @@
         self.assertEqual(abs(-3.14), 3.14)
         # str
         self.assertRaises(TypeError, abs, 'a')
+        # bool
+        self.assertEqual(abs(True), 1)
+        self.assertEqual(abs(False), 0)
+        # other
+        self.assertRaises(TypeError, abs)
+        self.assertRaises(TypeError, abs, None)
+        class AbsClass(object):
+            def __abs__(self):
+                return -5
+        self.assertEqual(abs(AbsClass()), -5)
 
     def test_all(self):
         self.assertEqual(all([2, 4, 6]), True)
@@ -600,6 +610,8 @@
             def __len__(self):
                 return sys.maxsize + 1
         self.assertRaises(OverflowError, len, HugeLen())
+        class NoLenMethod(object): pass
+        self.assertRaises(TypeError, len, NoLenMethod())
 
     def test_map(self):
         self.assertEqual(
@@ -1187,6 +1199,11 @@
         b = 2
         return vars()
 
+    class C_get_vars(object):
+        def getDict(self):
+            return {'a':2}
+        __dict__ = property(fget=getDict)
+
     def test_vars(self):
         self.assertEqual(set(vars()), set(dir()))
         import sys
@@ -1195,6 +1212,7 @@
         self.assertEqual(self.get_vars_f2(), {'a': 1, 'b': 2})
         self.assertRaises(TypeError, vars, 42, 42)
         self.assertRaises(TypeError, vars, 42)
+        self.assertEqual(vars(self.C_get_vars()), {'a':2})
 
     def test_zip(self):
         a = (1, 2, 3)

Modified: python/branches/py3k-cdecimal/Lib/test/test_codecs.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_codecs.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_codecs.py	Mon Jun  7 12:46:02 2010
@@ -1594,6 +1594,62 @@
                          b"\xe4\xeb\xef\xf6\xfc")
 
 
+class BomTest(unittest.TestCase):
+    def test_seek0(self):
+        data = "1234567890"
+        tests = ("utf-16",
+                 "utf-16-le",
+                 "utf-16-be",
+                 "utf-32",
+                 "utf-32-le",
+                 "utf-32-be")
+        for encoding in tests:
+            # Check if the BOM is written only once
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.write(data)
+                f.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data * 2)
+                f.seek(0)
+                self.assertEquals(f.read(), data * 2)
+
+            # Check that the BOM is written after a seek(0)
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.write(data[0])
+                self.assertNotEquals(f.tell(), 0)
+                f.seek(0)
+                f.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data)
+
+            # (StreamWriter) Check that the BOM is written after a seek(0)
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.writer.write(data[0])
+                self.assertNotEquals(f.writer.tell(), 0)
+                f.writer.seek(0)
+                f.writer.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data)
+
+            # Check that the BOM is not written after a seek() at a position
+            # different than the start
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.write(data)
+                f.seek(f.tell())
+                f.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data * 2)
+
+            # (StreamWriter) Check that the BOM is not written after a seek()
+            # at a position different than the start
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.writer.write(data)
+                f.writer.seek(f.writer.tell())
+                f.writer.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data * 2)
+
+
 def test_main():
     support.run_unittest(
         UTF32Test,
@@ -1621,6 +1677,7 @@
         WithStmtTest,
         TypesTest,
         SurrogateEscapeTest,
+        BomTest,
     )
 
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_collections.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_collections.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_collections.py	Mon Jun  7 12:46:02 2010
@@ -1,6 +1,6 @@
 """Unit tests for collections.py."""
 
-import unittest, doctest
+import unittest, doctest, operator
 import inspect
 from test import support
 from collections import namedtuple, Counter, OrderedDict
@@ -246,6 +246,37 @@
         self.assertNotIsInstance(C(), abc)
         self.assertFalse(issubclass(C, abc))
 
+    def validate_comparison(self, instance):
+        ops = ['lt', 'gt', 'le', 'ge', 'ne', 'or', 'and', 'xor', 'sub']
+        operators = {}
+        for op in ops:
+            name = '__' + op + '__'
+            operators[name] = getattr(operator, name)
+
+        class Other:
+            def __init__(self):
+                self.right_side = False
+            def __eq__(self, other):
+                self.right_side = True
+                return True
+            __lt__ = __eq__
+            __gt__ = __eq__
+            __le__ = __eq__
+            __ge__ = __eq__
+            __ne__ = __eq__
+            __ror__ = __eq__
+            __rand__ = __eq__
+            __rxor__ = __eq__
+            __rsub__ = __eq__
+
+        for name, op in operators.items():
+            if not hasattr(instance, name):
+                continue
+            other = Other()
+            op(instance, other)
+            self.assertTrue(other.right_side,'Right side not called for %s.%s'
+                            % (type(instance), name))
+
 class TestOneTrickPonyABCs(ABCTestCase):
 
     def test_Hashable(self):
@@ -420,6 +451,14 @@
             self.assertIsInstance(sample(), Set)
             self.assertTrue(issubclass(sample, Set))
         self.validate_abstract_methods(Set, '__contains__', '__iter__', '__len__')
+        class MySet(Set):
+            def __contains__(self, x):
+                return False
+            def __len__(self):
+                return 0
+            def __iter__(self):
+                return iter([])
+        self.validate_comparison(MySet())
 
     def test_hash_Set(self):
         class OneTwoThreeSet(Set):
@@ -483,6 +522,14 @@
             self.assertTrue(issubclass(sample, Mapping))
         self.validate_abstract_methods(Mapping, '__contains__', '__iter__', '__len__',
             '__getitem__')
+        class MyMapping(collections.Mapping):
+            def __len__(self):
+                return 0
+            def __getitem__(self, i):
+                raise IndexError
+            def __iter__(self):
+                return iter(())
+        self.validate_comparison(MyMapping())
 
     def test_MutableMapping(self):
         for sample in [dict]:

Modified: python/branches/py3k-cdecimal/Lib/test/test_complex.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_complex.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_complex.py	Mon Jun  7 12:46:02 2010
@@ -110,12 +110,18 @@
         self.assertRaises(TypeError, complex.__floordiv__, 3+0j, 0+0j)
 
     def test_richcompare(self):
-        self.assertRaises(OverflowError, complex.__eq__, 1+1j, 1<<10000)
+        self.assertIs(complex.__eq__(1+1j, 1<<10000), False)
         self.assertIs(complex.__lt__(1+1j, None), NotImplemented)
         self.assertIs(complex.__eq__(1+1j, 1+1j), True)
         self.assertIs(complex.__eq__(1+1j, 2+2j), False)
         self.assertIs(complex.__ne__(1+1j, 1+1j), False)
         self.assertIs(complex.__ne__(1+1j, 2+2j), True)
+        for i in range(1, 100):
+            f = i / 100.0
+            self.assertIs(complex.__eq__(f+0j, f), True)
+            self.assertIs(complex.__ne__(f+0j, f), False)
+            self.assertIs(complex.__eq__(complex(f, f), f), False)
+            self.assertIs(complex.__ne__(complex(f, f), f), True)
         self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented)
         self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented)
         self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented)
@@ -129,6 +135,23 @@
         self.assertIs(operator.ne(1+1j, 1+1j), False)
         self.assertIs(operator.ne(1+1j, 2+2j), True)
 
+    def test_richcompare_boundaries(self):
+        def check(n, deltas, is_equal, imag = 0.0):
+            for delta in deltas:
+                i = n + delta
+                z = complex(i, imag)
+                self.assertIs(complex.__eq__(z, i), is_equal(delta))
+                self.assertIs(complex.__ne__(z, i), not is_equal(delta))
+        # For IEEE-754 doubles the following should hold:
+        #    x in [2 ** (52 + i), 2 ** (53 + i + 1)] -> x mod 2 ** i == 0
+        # where the interval is representable, of course.
+        for i in range(1, 10):
+            pow = 52 + i
+            mult = 2 ** i
+            check(2 ** pow, range(1, 101), lambda delta: delta % mult == 0)
+            check(2 ** pow, range(1, 101), lambda delta: False, float(i))
+        check(2 ** 53, range(-100, 0), lambda delta: True)
+
     def test_mod(self):
         # % is no longer supported on complex numbers
         self.assertRaises(TypeError, (1+1j).__mod__, 0+0j)

Modified: python/branches/py3k-cdecimal/Lib/test/test_datetime.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_datetime.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_datetime.py	Mon Jun  7 12:46:02 2010
@@ -3,7 +3,7 @@
 See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
 """
 
-import os
+import sys
 import pickle
 import unittest
 
@@ -25,6 +25,16 @@
 OTHERSTUFF = (10, 34.5, "abc", {}, [], ())
 
 
+# XXX Copied from test_float.
+INF = float("inf")
+NAN = float("nan")
+
+# decorator for skipping tests on non-IEEE 754 platforms
+requires_IEEE_754 = unittest.skipUnless(
+    float.__getformat__("double").startswith("IEEE"),
+    "test requires IEEE 754 doubles")
+
+
 #############################################################################
 # module tests
 
@@ -225,6 +235,36 @@
         eq(c//1000, td(0, 0, 1))
         eq(a//10, td(0, 7*24*360))
         eq(a//3600000, td(0, 0, 7*24*1000))
+        eq(a/0.5, td(14))
+        eq(b/0.5, td(0, 120))
+        eq(a/7, td(1))
+        eq(b/10, td(0, 6))
+        eq(c/1000, td(0, 0, 1))
+        eq(a/10, td(0, 7*24*360))
+        eq(a/3600000, td(0, 0, 7*24*1000))
+
+        # Multiplication by float
+        us = td(microseconds=1)
+        eq((3*us) * 0.5, 2*us)
+        eq((5*us) * 0.5, 2*us)
+        eq(0.5 * (3*us), 2*us)
+        eq(0.5 * (5*us), 2*us)
+        eq((-3*us) * 0.5, -2*us)
+        eq((-5*us) * 0.5, -2*us)
+
+        # Division by int and float
+        eq((3*us) / 2, 2*us)
+        eq((5*us) / 2, 2*us)
+        eq((-3*us) / 2.0, -2*us)
+        eq((-5*us) / 2.0, -2*us)
+        eq((3*us) / -2, -2*us)
+        eq((5*us) / -2, -2*us)
+        eq((3*us) / -2.0, -2*us)
+        eq((5*us) / -2.0, -2*us)
+        for i in range(-10, 10):
+            eq((i*us/3)//us, round(i/3))
+        for i in range(-10, 10):
+            eq((i*us/-3)//us, round(i/-3))
 
     def test_disallowed_computations(self):
         a = timedelta(42)
@@ -236,20 +276,19 @@
             self.assertRaises(TypeError, lambda: i+a)
             self.assertRaises(TypeError, lambda: i-a)
 
-        # Mul/div by float isn't supported.
-        x = 2.3
-        self.assertRaises(TypeError, lambda: a*x)
-        self.assertRaises(TypeError, lambda: x*a)
-        self.assertRaises(TypeError, lambda: a/x)
-        self.assertRaises(TypeError, lambda: x/a)
-        self.assertRaises(TypeError, lambda: a // x)
-        self.assertRaises(TypeError, lambda: x // a)
-
         # Division of int by timedelta doesn't make sense.
         # Division by zero doesn't make sense.
         zero = 0
         self.assertRaises(TypeError, lambda: zero // a)
         self.assertRaises(ZeroDivisionError, lambda: a // zero)
+        self.assertRaises(ZeroDivisionError, lambda: a / zero)
+        self.assertRaises(ZeroDivisionError, lambda: a / 0.0)
+
+    @requires_IEEE_754
+    def test_disallowed_special(self):
+        a = timedelta(42)
+        self.assertRaises(ValueError, a.__mul__, NAN)
+        self.assertRaises(ValueError, a.__truediv__, NAN)
 
     def test_basic_attributes(self):
         days, seconds, us = 1, 7, 31
@@ -410,6 +449,19 @@
 
         self.assertRaises(OverflowError, lambda: -timedelta.max)
 
+        day = timedelta(1)
+        self.assertRaises(OverflowError, day.__mul__, 10**9)
+        self.assertRaises(OverflowError, day.__mul__, 1e9)
+        self.assertRaises(OverflowError, day.__truediv__, 1e-20)
+        self.assertRaises(OverflowError, day.__truediv__, 1e-10)
+        self.assertRaises(OverflowError, day.__truediv__, 9e-10)
+
+    @requires_IEEE_754
+    def _test_overflow_special(self):
+        day = timedelta(1)
+        self.assertRaises(OverflowError, day.__mul__, INF)
+        self.assertRaises(OverflowError, day.__mul__, -INF)
+
     def test_microsecond_rounding(self):
         td = timedelta
         eq = self.assertEqual
@@ -489,7 +541,7 @@
         self.assertRaises(ZeroDivisionError, truediv, t, zerotd)
         self.assertRaises(ZeroDivisionError, floordiv, t, zerotd)
 
-        self.assertRaises(TypeError, truediv, t, 2)
+        # self.assertRaises(TypeError, truediv, t, 2)
         # note: floor division of a timedelta by an integer *is*
         # currently permitted.
 
@@ -761,15 +813,16 @@
     def test_overflow(self):
         tiny = self.theclass.resolution
 
-        dt = self.theclass.min + tiny
-        dt -= tiny  # no problem
-        self.assertRaises(OverflowError, dt.__sub__, tiny)
-        self.assertRaises(OverflowError, dt.__add__, -tiny)
-
-        dt = self.theclass.max - tiny
-        dt += tiny  # no problem
-        self.assertRaises(OverflowError, dt.__add__, tiny)
-        self.assertRaises(OverflowError, dt.__sub__, -tiny)
+        for delta in [tiny, timedelta(1), timedelta(2)]:
+            dt = self.theclass.min + delta
+            dt -= delta  # no problem
+            self.assertRaises(OverflowError, dt.__sub__, delta)
+            self.assertRaises(OverflowError, dt.__add__, -delta)
+
+            dt = self.theclass.max - delta
+            dt += delta  # no problem
+            self.assertRaises(OverflowError, dt.__add__, delta)
+            self.assertRaises(OverflowError, dt.__sub__, -delta)
 
     def test_fromtimestamp(self):
         import time
@@ -1554,19 +1607,14 @@
         for insane in -1e200, 1e200:
             self.assertRaises(ValueError, self.theclass.utcfromtimestamp,
                               insane)
-
+    @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
     def test_negative_float_fromtimestamp(self):
-        # Windows doesn't accept negative timestamps
-        if os.name == "nt":
-            return
         # The result is tz-dependent; at least test that this doesn't
         # fail (like it did before bug 1646728 was fixed).
         self.theclass.fromtimestamp(-1.05)
 
+    @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
     def test_negative_float_utcfromtimestamp(self):
-        # Windows doesn't accept negative timestamps
-        if os.name == "nt":
-            return
         d = self.theclass.utcfromtimestamp(-1.05)
         self.assertEquals(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000))
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_decimal.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_decimal.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_decimal.py	Mon Jun  7 12:46:02 2010
@@ -27,11 +27,13 @@
 import math
 import os, sys
 import operator
+import warnings
 import pickle, copy
 import unittest
 from decimal import *
 import numbers
 from test.support import run_unittest, run_doctest, is_resource_enabled
+from test.support import check_warnings
 import random
 try:
     import threading
@@ -412,7 +414,7 @@
     def change_max_exponent(self, exp):
         self.context.Emax = exp
     def change_clamp(self, clamp):
-        self.context._clamp = clamp
+        self.context.clamp = clamp
 
 
 
@@ -1815,6 +1817,26 @@
         self.assertNotEqual(id(c.flags), id(d.flags))
         self.assertNotEqual(id(c.traps), id(d.traps))
 
+    def test__clamp(self):
+        # In Python 3.2, the private attribute `_clamp` was made
+        # public (issue 8540), with the old `_clamp` becoming a
+        # property wrapping `clamp`.  For the duration of Python 3.2
+        # only, the attribute should be gettable/settable via both
+        # `clamp` and `_clamp`; in Python 3.3, `_clamp` should be
+        # removed.
+        c = Context(clamp = 0)
+        self.assertEqual(c.clamp, 0)
+
+        with check_warnings(("", DeprecationWarning)):
+            c._clamp = 1
+        self.assertEqual(c.clamp, 1)
+        with check_warnings(("", DeprecationWarning)):
+            self.assertEqual(c._clamp, 1)
+        c.clamp = 0
+        self.assertEqual(c.clamp, 0)
+        with check_warnings(("", DeprecationWarning)):
+            self.assertEqual(c._clamp, 0)
+
     def test_abs(self):
         c = Context()
         d = c.abs(Decimal(-1))

Modified: python/branches/py3k-cdecimal/Lib/test/test_descr.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_descr.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_descr.py	Mon Jun  7 12:46:02 2010
@@ -1557,6 +1557,8 @@
             self.assertEqual(key, "hi")
             return 4
         def swallow(*args): pass
+        def format_impl(self, spec):
+            return "hello"
 
         # It would be nice to have every special method tested here, but I'm
         # only listing the ones I can remember outside of typeobject.c, since it
@@ -1575,6 +1577,7 @@
             ("__enter__", run_context, iden, set(), {"__exit__" : swallow}),
             ("__exit__", run_context, swallow, set(), {"__enter__" : iden}),
             ("__complex__", complex, complex_num, set(), {}),
+            ("__format__", format, format_impl, set(), {}),
             ]
 
         class Checker(object):

Modified: python/branches/py3k-cdecimal/Lib/test/test_enumerate.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_enumerate.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_enumerate.py	Mon Jun  7 12:46:02 2010
@@ -198,6 +198,18 @@
                 self.fail("non-callable __reversed__ didn't raise!")
         self.assertEqual(rc, sys.getrefcount(r))
 
+    def test_objmethods(self):
+        # Objects must have __len__() and __getitem__() implemented.
+        class NoLen(object):
+            def __getitem__(self): return 1
+        nl = NoLen()
+        self.assertRaises(TypeError, reversed, nl)
+
+        class NoGetItem(object):
+            def __len__(self): return 2
+        ngi = NoGetItem()
+        self.assertRaises(TypeError, reversed, ngi)
+
 
 class EnumerateStartTestCase(EnumerateTestCase):
 
@@ -227,7 +239,7 @@
     if verbose and hasattr(sys, "gettotalrefcount"):
         counts = [None] * 5
         for i in range(len(counts)):
-            support.run_unittest(*testclasses)
+            support.run_unittest(__name__)
             counts[i] = sys.gettotalrefcount()
         print(counts)
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_float.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_float.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_float.py	Mon Jun  7 12:46:02 2010
@@ -914,15 +914,6 @@
         self.assertFalse(NAN.is_inf())
         self.assertFalse((0.).is_inf())
 
-    def test_hash_inf(self):
-        # the actual values here should be regarded as an
-        # implementation detail, but they need to be
-        # identical to those used in the Decimal module.
-        self.assertEqual(hash(float('inf')), 314159)
-        self.assertEqual(hash(float('-inf')), -271828)
-        self.assertEqual(hash(float('nan')), 0)
-
-
 fromHex = float.fromhex
 toHex = float.hex
 class HexFloatTestCase(unittest.TestCase):

Modified: python/branches/py3k-cdecimal/Lib/test/test_ftplib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_ftplib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_ftplib.py	Mon Jun  7 12:46:02 2010
@@ -719,6 +719,29 @@
         finally:
             self.client.ssl_version = ssl.PROTOCOL_TLSv1
 
+    def test_context(self):
+        self.client.quit()
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
+                          context=ctx)
+        self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
+                          context=ctx)
+        self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
+                          keyfile=CERTFILE, context=ctx)
+
+        self.client = ftplib.FTP_TLS(context=ctx, timeout=2)
+        self.client.connect(self.server.host, self.server.port)
+        self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
+        self.client.auth()
+        self.assertIs(self.client.sock.context, ctx)
+        self.assertIsInstance(self.client.sock, ssl.SSLSocket)
+
+        self.client.prot_p()
+        sock = self.client.transfercmd('list')
+        self.assertIs(sock.context, ctx)
+        self.assertIsInstance(sock, ssl.SSLSocket)
+        sock.close()
+
 
 class TestTimeouts(TestCase):
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_gdb.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_gdb.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_gdb.py	Mon Jun  7 12:46:02 2010
@@ -8,6 +8,7 @@
 import subprocess
 import sys
 import unittest
+import locale
 
 from test.support import run_unittest, findfile
 
@@ -177,7 +178,7 @@
     def assertGdbRepr(self, val, exp_repr=None, cmds_after_breakpoint=None):
         # Ensure that gdb's rendering of the value in a debugged process
         # matches repr(value) in this process:
-        gdb_repr, gdb_output = self.get_gdb_repr('id(' + repr(val) + ')',
+        gdb_repr, gdb_output = self.get_gdb_repr('id(' + ascii(val) + ')',
                                                  cmds_after_breakpoint)
         if not exp_repr:
             exp_repr = repr(val)
@@ -226,31 +227,35 @@
 
     def test_strings(self):
         'Verify the pretty-printing of unicode strings'
+        encoding = locale.getpreferredencoding()
+        def check_repr(text):
+            try:
+                text.encode(encoding)
+                printable = True
+            except UnicodeEncodeError:
+                self.assertGdbRepr(text, ascii(text))
+            else:
+                self.assertGdbRepr(text)
+
         self.assertGdbRepr('')
         self.assertGdbRepr('And now for something hopefully the same')
         self.assertGdbRepr('string with embedded NUL here \0 and then some more text')
 
         # Test printing a single character:
         #    U+2620 SKULL AND CROSSBONES
-        self.assertGdbRepr('\u2620')
+        check_repr('\u2620')
 
         # Test printing a Japanese unicode string
         # (I believe this reads "mojibake", using 3 characters from the CJK
         # Unified Ideographs area, followed by U+3051 HIRAGANA LETTER KE)
-        self.assertGdbRepr('\u6587\u5b57\u5316\u3051')
+        check_repr('\u6587\u5b57\u5316\u3051')
 
         # Test a character outside the BMP:
         #    U+1D121 MUSICAL SYMBOL C CLEF
         # This is:
         # UTF-8: 0xF0 0x9D 0x84 0xA1
         # UTF-16: 0xD834 0xDD21
-        if sys.maxunicode == 0x10FFFF:
-            # wide unicode:
-            self.assertGdbRepr(chr(0x1D121))
-        else:
-            # narrow unicode:
-            self.assertGdbRepr(chr(0x1D121),
-                               "'\\U0000d834\\U0000dd21'")
+        check_repr(chr(0x1D121))
 
     def test_tuples(self):
         'Verify the pretty-printing of tuples'

Modified: python/branches/py3k-cdecimal/Lib/test/test_htmlparser.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_htmlparser.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_htmlparser.py	Mon Jun  7 12:46:02 2010
@@ -136,6 +136,13 @@
     ("data", "\n"),
     ])
 
+    def test_malformatted_charref(self):
+        self._run_check("<p>&#bad;</p>", [
+            ("starttag", "p", []),
+            ("data", "&#bad;"),
+            ("endtag", "p"),
+        ])
+
     def test_unclosed_entityref(self):
         self._run_check("&entityref foo", [
             ("entityref", "entityref"),

Modified: python/branches/py3k-cdecimal/Lib/test/test_httplib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_httplib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_httplib.py	Mon Jun  7 12:46:02 2010
@@ -239,7 +239,7 @@
         self.assertEquals(resp.read(), b'')
         self.assertEquals(resp.status, 200)
         self.assertEquals(resp.reason, 'OK')
-        resp.close()
+        self.assertTrue(resp.isclosed())
 
     def test_negative_content_length(self):
         sock = FakeSocket(

Modified: python/branches/py3k-cdecimal/Lib/test/test_linecache.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_linecache.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_linecache.py	Mon Jun  7 12:46:02 2010
@@ -31,6 +31,11 @@
 
 '''
 
+SOURCE_3 = '''
+def f():
+    return 3''' # No ending newline
+
+
 class LineCacheTests(unittest.TestCase):
 
     def test_getline(self):
@@ -63,6 +68,13 @@
         empty = linecache.getlines('a/b/c/__init__.py')
         self.assertEquals(empty, [])
 
+    def test_no_ending_newline(self):
+        self.addCleanup(support.unlink, support.TESTFN)
+        with open(support.TESTFN, "w") as fp:
+            fp.write(SOURCE_3)
+        lines = linecache.getlines(support.TESTFN)
+        self.assertEqual(lines, ["\n", "def f():\n", "    return 3\n"])
+
     def test_clearcache(self):
         cached = []
         for entry in TESTS:
@@ -81,39 +93,36 @@
 
     def test_checkcache(self):
         getline = linecache.getline
-        try:
-            # Create a source file and cache its contents
-            source_name = support.TESTFN + '.py'
-            with open(source_name, 'w') as source:
-                source.write(SOURCE_1)
-            getline(source_name, 1)
-
-            # Keep a copy of the old contents
-            source_list = []
-            with open(source_name) as source:
-                for index, line in enumerate(source):
-                    self.assertEquals(line, getline(source_name, index + 1))
-                    source_list.append(line)
+        # Create a source file and cache its contents
+        source_name = support.TESTFN + '.py'
+        self.addCleanup(support.unlink, source_name)
+        with open(source_name, 'w') as source:
+            source.write(SOURCE_1)
+        getline(source_name, 1)
+
+        # Keep a copy of the old contents
+        source_list = []
+        with open(source_name) as source:
+            for index, line in enumerate(source):
+                self.assertEquals(line, getline(source_name, index + 1))
+                source_list.append(line)
 
-            with open(source_name, 'w') as source:
-                source.write(SOURCE_2)
+        with open(source_name, 'w') as source:
+            source.write(SOURCE_2)
 
-            # Try to update a bogus cache entry
-            linecache.checkcache('dummy')
+        # Try to update a bogus cache entry
+        linecache.checkcache('dummy')
 
-            # Check that the cache matches the old contents
-            for index, line in enumerate(source_list):
+        # Check that the cache matches the old contents
+        for index, line in enumerate(source_list):
+            self.assertEquals(line, getline(source_name, index + 1))
+
+        # Update the cache and check whether it matches the new source file
+        linecache.checkcache(source_name)
+        with open(source_name) as source:
+            for index, line in enumerate(source):
                 self.assertEquals(line, getline(source_name, index + 1))
-
-            # Update the cache and check whether it matches the new source file
-            linecache.checkcache(source_name)
-            with open(source_name) as source:
-                for index, line in enumerate(source):
-                    self.assertEquals(line, getline(source_name, index + 1))
-                    source_list.append(line)
-
-        finally:
-            support.unlink(source_name)
+                source_list.append(line)
 
 def test_main():
     support.run_unittest(LineCacheTests)

Modified: python/branches/py3k-cdecimal/Lib/test/test_long.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_long.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_long.py	Mon Jun  7 12:46:02 2010
@@ -330,6 +330,31 @@
         # ... but it's just a normal digit if base >= 22
         self.assertEqual(int('1L', 22), 43)
 
+        # tests with base 0
+        self.assertEqual(int('000', 0), 0)
+        self.assertEqual(int('0o123', 0), 83)
+        self.assertEqual(int('0x123', 0), 291)
+        self.assertEqual(int('0b100', 0), 4)
+        self.assertEqual(int(' 0O123   ', 0), 83)
+        self.assertEqual(int(' 0X123  ', 0), 291)
+        self.assertEqual(int(' 0B100 ', 0), 4)
+        self.assertEqual(int('0', 0), 0)
+        self.assertEqual(int('+0', 0), 0)
+        self.assertEqual(int('-0', 0), 0)
+        self.assertEqual(int('00', 0), 0)
+        self.assertRaises(ValueError, int, '08', 0)
+        self.assertRaises(ValueError, int, '-012395', 0)
+
+        # invalid bases
+        invalid_bases = [-909,
+                          2**31-1, 2**31, -2**31, -2**31-1,
+                          2**63-1, 2**63, -2**63, -2**63-1,
+                          2**100, -2**100,
+                          ]
+        for base in invalid_bases:
+            self.assertRaises(ValueError, int, '42', base)
+
+
     def test_conversion(self):
 
         class JustLong:

Modified: python/branches/py3k-cdecimal/Lib/test/test_os.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_os.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_os.py	Mon Jun  7 12:46:02 2010
@@ -933,20 +933,64 @@
 
 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
 class Win32KillTests(unittest.TestCase):
-    def _kill(self, sig, *args):
-        # Send a subprocess a signal (or in some cases, just an int to be
-        # the return value)
-        proc = subprocess.Popen(*args)
+    def _kill(self, sig):
+        # Start sys.executable as a subprocess and communicate from the
+        # subprocess to the parent that the interpreter is ready. When it
+        # becomes ready, send *sig* via os.kill to the subprocess and check
+        # that the return code is equal to *sig*.
+        import ctypes
+        from ctypes import wintypes
+        import msvcrt
+
+        # Since we can't access the contents of the process' stdout until the
+        # process has exited, use PeekNamedPipe to see what's inside stdout
+        # without waiting. This is done so we can tell that the interpreter
+        # is started and running at a point where it could handle a signal.
+        PeekNamedPipe = ctypes.windll.kernel32.PeekNamedPipe
+        PeekNamedPipe.restype = wintypes.BOOL
+        PeekNamedPipe.argtypes = (wintypes.HANDLE, # Pipe handle
+                                  ctypes.POINTER(ctypes.c_char), # stdout buf
+                                  wintypes.DWORD, # Buffer size
+                                  ctypes.POINTER(wintypes.DWORD), # bytes read
+                                  ctypes.POINTER(wintypes.DWORD), # bytes avail
+                                  ctypes.POINTER(wintypes.DWORD)) # bytes left
+        msg = "running"
+        proc = subprocess.Popen([sys.executable, "-c",
+                                 "import sys;"
+                                 "sys.stdout.write('{}');"
+                                 "sys.stdout.flush();"
+                                 "input()".format(msg)],
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE,
+                                stdin=subprocess.PIPE)
+
+        count, max = 0, 100
+        while count < max and proc.poll() is None:
+            # Create a string buffer to store the result of stdout from the pipe
+            buf = ctypes.create_string_buffer(len(msg))
+            # Obtain the text currently in proc.stdout
+            # Bytes read/avail/left are left as NULL and unused
+            rslt = PeekNamedPipe(msvcrt.get_osfhandle(proc.stdout.fileno()),
+                                 buf, ctypes.sizeof(buf), None, None, None)
+            self.assertNotEqual(rslt, 0, "PeekNamedPipe failed")
+            if buf.value:
+                self.assertEqual(msg, buf.value.decode())
+                break
+            time.sleep(0.1)
+            count += 1
+        else:
+            self.fail("Did not receive communication from the subprocess")
+
         os.kill(proc.pid, sig)
         self.assertEqual(proc.wait(), sig)
 
     def test_kill_sigterm(self):
         # SIGTERM doesn't mean anything special, but make sure it works
-        self._kill(signal.SIGTERM, [sys.executable])
+        self._kill(signal.SIGTERM)
 
     def test_kill_int(self):
         # os.kill on Windows can take an int which gets set as the exit code
-        self._kill(100, [sys.executable])
+        self._kill(100)
 
     def _kill_with_event(self, event, name):
         # Run a script which has console control handling enabled.

Modified: python/branches/py3k-cdecimal/Lib/test/test_pipes.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_pipes.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_pipes.py	Mon Jun  7 12:46:02 2010
@@ -70,9 +70,10 @@
         self.assertEqual(open(TESTFN).read(), d)
 
     def testQuoting(self):
-        safeunquoted = string.ascii_letters + string.digits + '!@%_-+=:,./'
-        unsafe = '"`$\\'
+        safeunquoted = string.ascii_letters + string.digits + '@%_-+=:,./'
+        unsafe = '"`$\\!'
 
+        self.assertEqual(pipes.quote(''), "''")
         self.assertEqual(pipes.quote(safeunquoted), safeunquoted)
         self.assertEqual(pipes.quote('test file name'), "'test file name'")
         for u in unsafe:
@@ -80,9 +81,7 @@
                               "'test%sname'" % u)
         for u in unsafe:
             self.assertEqual(pipes.quote("test%s'name'" % u),
-                              '"test\\%s\'name\'"' % u)
-
-        self.assertEqual(pipes.quote(''), "''")
+                             "'test%s'\"'\"'name'\"'\"''" % u)
 
     def testRepr(self):
         t = pipes.Template()

Modified: python/branches/py3k-cdecimal/Lib/test/test_socketserver.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_socketserver.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_socketserver.py	Mon Jun  7 12:46:02 2010
@@ -61,6 +61,7 @@
     testcase.assertEquals(72 << 8, status)
 
 
+ at unittest.skipUnless(threading, 'Threading required for this test.')
 class SocketServerTest(unittest.TestCase):
     """Test all socket servers."""
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_ssl.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_ssl.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_ssl.py	Mon Jun  7 12:46:02 2010
@@ -57,6 +57,14 @@
     if support.verbose:
         sys.stdout.write(prefix + exc_format)
 
+def can_clear_options():
+    # 0.9.8m or higher
+    return ssl.OPENSSL_VERSION_INFO >= (0, 9, 8, 13, 15)
+
+def no_sslv2_implies_sslv3_hello():
+    # 0.9.7h or higher
+    return ssl.OPENSSL_VERSION_INFO >= (0, 9, 7, 8, 15)
+
 
 class BasicSocketTests(unittest.TestCase):
 
@@ -189,6 +197,26 @@
         with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"):
             ctx.set_ciphers("^$:,;?*'dorothyx")
 
+    def test_options(self):
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        # OP_ALL is the default value
+        self.assertEqual(ssl.OP_ALL, ctx.options)
+        ctx.options |= ssl.OP_NO_SSLv2
+        self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2,
+                         ctx.options)
+        ctx.options |= ssl.OP_NO_SSLv3
+        self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3,
+                         ctx.options)
+        if can_clear_options():
+            ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1
+            self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3,
+                             ctx.options)
+            ctx.options = 0
+            self.assertEqual(0, ctx.options)
+        else:
+            with self.assertRaises(ValueError):
+                ctx.options = 0
+
     def test_verify(self):
         ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
         # Default value
@@ -445,12 +473,8 @@
 
             def wrap_conn(self):
                 try:
-                    self.sslconn = ssl.wrap_socket(self.sock, server_side=True,
-                                                   certfile=self.server.certificate,
-                                                   ssl_version=self.server.protocol,
-                                                   ca_certs=self.server.cacerts,
-                                                   cert_reqs=self.server.certreqs,
-                                                   ciphers=self.server.ciphers)
+                    self.sslconn = self.server.context.wrap_socket(
+                        self.sock, server_side=True)
                 except ssl.SSLError:
                     # XXX Various errors can have happened here, for example
                     # a mismatching protocol version, an invalid certificate,
@@ -462,7 +486,7 @@
                     self.close()
                     return False
                 else:
-                    if self.server.certreqs == ssl.CERT_REQUIRED:
+                    if self.server.context.verify_mode == ssl.CERT_REQUIRED:
                         cert = self.sslconn.getpeercert()
                         if support.verbose and self.server.chatty:
                             sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n")
@@ -542,19 +566,24 @@
                         # harness, we want to stop the server
                         self.server.stop()
 
-        def __init__(self, certificate, ssl_version=None,
+        def __init__(self, certificate=None, ssl_version=None,
                      certreqs=None, cacerts=None,
                      chatty=True, connectionchatty=False, starttls_server=False,
-                     ciphers=None):
-            if ssl_version is None:
-                ssl_version = ssl.PROTOCOL_TLSv1
-            if certreqs is None:
-                certreqs = ssl.CERT_NONE
-            self.certificate = certificate
-            self.protocol = ssl_version
-            self.certreqs = certreqs
-            self.cacerts = cacerts
-            self.ciphers = ciphers
+                     ciphers=None, context=None):
+            if context:
+                self.context = context
+            else:
+                self.context = ssl.SSLContext(ssl_version
+                                              if ssl_version is not None
+                                              else ssl.PROTOCOL_TLSv1)
+                self.context.verify_mode = (certreqs if certreqs is not None
+                                            else ssl.CERT_NONE)
+                if cacerts:
+                    self.context.load_verify_locations(cacerts)
+                if certificate:
+                    self.context.load_cert_chain(certificate)
+                if ciphers:
+                    self.context.set_ciphers(ciphers)
             self.chatty = chatty
             self.connectionchatty = connectionchatty
             self.starttls_server = starttls_server
@@ -820,18 +849,13 @@
             server.stop()
             server.join()
 
-    def server_params_test(certfile, protocol, certreqs, cacertsfile,
-                           client_certfile, client_protocol=None, indata=b"FOO\n",
-                           ciphers=None, chatty=True, connectionchatty=False):
+    def server_params_test(client_context, server_context, indata=b"FOO\n",
+                           chatty=True, connectionchatty=False):
         """
         Launch a server, connect a client to it and try various reads
         and writes.
         """
-        server = ThreadedEchoServer(certfile,
-                                    certreqs=certreqs,
-                                    ssl_version=protocol,
-                                    cacerts=cacertsfile,
-                                    ciphers=ciphers,
+        server = ThreadedEchoServer(context=server_context,
                                     chatty=chatty,
                                     connectionchatty=False)
         flag = threading.Event()
@@ -839,15 +863,8 @@
         # wait for it to start
         flag.wait()
         # try to connect
-        if client_protocol is None:
-            client_protocol = protocol
         try:
-            s = ssl.wrap_socket(socket.socket(),
-                                certfile=client_certfile,
-                                ca_certs=cacertsfile,
-                                ciphers=ciphers,
-                                cert_reqs=certreqs,
-                                ssl_version=client_protocol)
+            s = client_context.wrap_socket(socket.socket())
             s.connect((HOST, server.port))
             for arg in [indata, bytearray(indata), memoryview(indata)]:
                 if connectionchatty:
@@ -873,10 +890,8 @@
             server.stop()
             server.join()
 
-    def try_protocol_combo(server_protocol,
-                           client_protocol,
-                           expect_success,
-                           certsreqs=None):
+    def try_protocol_combo(server_protocol, client_protocol, expect_success,
+                           certsreqs=None, server_options=0, client_options=0):
         if certsreqs is None:
             certsreqs = ssl.CERT_NONE
         certtype = {
@@ -890,14 +905,21 @@
                              (ssl.get_protocol_name(client_protocol),
                               ssl.get_protocol_name(server_protocol),
                               certtype))
-        try:
+        client_context = ssl.SSLContext(client_protocol)
+        client_context.options = ssl.OP_ALL | client_options
+        server_context = ssl.SSLContext(server_protocol)
+        server_context.options = ssl.OP_ALL | server_options
+        for ctx in (client_context, server_context):
+            ctx.verify_mode = certsreqs
             # NOTE: we must enable "ALL" ciphers, otherwise an SSLv23 client
             # will send an SSLv3 hello (rather than SSLv2) starting from
             # OpenSSL 1.0.0 (see issue #8322).
-            server_params_test(CERTFILE, server_protocol, certsreqs,
-                               CERTFILE, CERTFILE, client_protocol,
-                               ciphers="ALL", chatty=False,
-                               connectionchatty=False)
+            ctx.set_ciphers("ALL")
+            ctx.load_cert_chain(CERTFILE)
+            ctx.load_verify_locations(CERTFILE)
+        try:
+            server_params_test(client_context, server_context,
+                               chatty=False, connectionchatty=False)
         # Protocol mismatch can result in either an SSLError, or a
         # "Connection reset by peer" error.
         except ssl.SSLError:
@@ -920,30 +942,27 @@
             """Basic test of an SSL client connecting to a server"""
             if support.verbose:
                 sys.stdout.write("\n")
-            server_params_test(CERTFILE, ssl.PROTOCOL_TLSv1, ssl.CERT_NONE,
-                               CERTFILE, CERTFILE, ssl.PROTOCOL_TLSv1,
-                               chatty=True, connectionchatty=True)
+            for protocol in PROTOCOLS:
+                context = ssl.SSLContext(protocol)
+                context.load_cert_chain(CERTFILE)
+                server_params_test(context, context,
+                                   chatty=True, connectionchatty=True)
 
         def test_getpeercert(self):
             if support.verbose:
                 sys.stdout.write("\n")
-            s2 = socket.socket()
-            server = ThreadedEchoServer(CERTFILE,
-                                        certreqs=ssl.CERT_NONE,
-                                        ssl_version=ssl.PROTOCOL_SSLv23,
-                                        cacerts=CERTFILE,
-                                        chatty=False)
+            context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+            context.verify_mode = ssl.CERT_REQUIRED
+            context.load_verify_locations(CERTFILE)
+            context.load_cert_chain(CERTFILE)
+            server = ThreadedEchoServer(context=context, chatty=False)
             flag = threading.Event()
             server.start(flag)
             # wait for it to start
             flag.wait()
             # try to connect
             try:
-                s = ssl.wrap_socket(socket.socket(),
-                                    certfile=CERTFILE,
-                                    ca_certs=CERTFILE,
-                                    cert_reqs=ssl.CERT_REQUIRED,
-                                    ssl_version=ssl.PROTOCOL_SSLv23)
+                s = context.wrap_socket(socket.socket())
                 s.connect((HOST, server.port))
                 cert = s.getpeercert()
                 self.assertTrue(cert, "Can't get peer certificate.")
@@ -1031,6 +1050,15 @@
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True)
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False)
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False)
+            # SSLv23 client with specific SSL options
+            if no_sslv2_implies_sslv3_hello():
+                # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
+                try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False,
+                                   client_options=ssl.OP_NO_SSLv2)
+            try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True,
+                               client_options=ssl.OP_NO_SSLv3)
+            try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True,
+                               client_options=ssl.OP_NO_TLSv1)
 
         def test_protocol_sslv23(self):
             """Connecting to an SSLv23 server with various client options"""
@@ -1056,6 +1084,16 @@
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED)
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED)
 
+            # Server with specific SSL options
+            try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False,
+                               server_options=ssl.OP_NO_SSLv3)
+            # Will choose TLSv1
+            try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True,
+                               server_options=ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3)
+            try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, False,
+                               server_options=ssl.OP_NO_TLSv1)
+
+
         def test_protocol_sslv3(self):
             """Connecting to an SSLv3 server with various client options"""
             if support.verbose:
@@ -1066,6 +1104,10 @@
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False)
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False)
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False)
+            if no_sslv2_implies_sslv3_hello():
+                # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
+                try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, True,
+                                   client_options=ssl.OP_NO_SSLv2)
 
         def test_protocol_tlsv1(self):
             """Connecting to a TLSv1 server with various client options"""

Modified: python/branches/py3k-cdecimal/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_subprocess.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_subprocess.py	Mon Jun  7 12:46:02 2010
@@ -535,6 +535,17 @@
             if c.exception.errno != 2:  # ignore "no such file"
                 raise c.exception
 
+    def test_issue8780(self):
+        # Ensure that stdout is inherited from the parent
+        # if stdout=PIPE is not used
+        code = ';'.join((
+            'import subprocess, sys',
+            'retcode = subprocess.call('
+                "[sys.executable, '-c', 'print(\"Hello World!\")'])",
+            'assert retcode == 0'))
+        output = subprocess.check_output([sys.executable, '-c', code])
+        self.assert_(output.startswith(b'Hello World!'), ascii(output))
+
 
 # context manager
 class _SuppressCoreFiles(object):

Modified: python/branches/py3k-cdecimal/Lib/test/test_sys.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_sys.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_sys.py	Mon Jun  7 12:46:02 2010
@@ -146,9 +146,9 @@
                               "raise SystemExit(47)"])
         self.assertEqual(rc, 47)
 
-        def check_exit_message(code, expected):
+        def check_exit_message(code, expected, env=None):
             process = subprocess.Popen([sys.executable, "-c", code],
-                                       stderr=subprocess.PIPE)
+                                       stderr=subprocess.PIPE, env=env)
             stdout, stderr = process.communicate()
             self.assertEqual(process.returncode, 1)
             self.assertTrue(stderr.startswith(expected),
@@ -166,6 +166,14 @@
             r'import sys; sys.exit("surrogates:\uDCFF")',
             b"surrogates:\\udcff")
 
+        # test that the unicode message is encoded to the stderr encoding
+        # instead of the default encoding (utf8)
+        env = os.environ.copy()
+        env['PYTHONIOENCODING'] = 'latin-1'
+        check_exit_message(
+            r'import sys; sys.exit("h\xe9")',
+            b"h\xe9", env=env)
+
     def test_getdefaultencoding(self):
         self.assertRaises(TypeError, sys.getdefaultencoding, 42)
         # can't check more than the type, as the user might have changed it
@@ -418,6 +426,23 @@
         self.assertEqual(type(sys.int_info.bits_per_digit), int)
         self.assertEqual(type(sys.int_info.sizeof_digit), int)
         self.assertIsInstance(sys.hexversion, int)
+
+        self.assertEqual(len(sys.hash_info), 5)
+        self.assertLess(sys.hash_info.modulus, 2**sys.hash_info.width)
+        # sys.hash_info.modulus should be a prime; we do a quick
+        # probable primality test (doesn't exclude the possibility of
+        # a Carmichael number)
+        for x in range(1, 100):
+            self.assertEqual(
+                pow(x, sys.hash_info.modulus-1, sys.hash_info.modulus),
+                1,
+                "sys.hash_info.modulus {} is a non-prime".format(
+                    sys.hash_info.modulus)
+                )
+        self.assertIsInstance(sys.hash_info.inf, int)
+        self.assertIsInstance(sys.hash_info.nan, int)
+        self.assertIsInstance(sys.hash_info.imag, int)
+
         self.assertIsInstance(sys.maxsize, int)
         self.assertIsInstance(sys.maxunicode, int)
         self.assertIsInstance(sys.platform, str)

Modified: python/branches/py3k-cdecimal/Lib/test/test_sysconfig.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_sysconfig.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_sysconfig.py	Mon Jun  7 12:46:02 2010
@@ -11,13 +11,14 @@
 import shutil
 from copy import copy, deepcopy
 
-from test.support import run_unittest, TESTFN, unlink, get_attribute
+from test.support import (run_unittest, TESTFN, unlink, get_attribute,
+                          captured_stdout)
 
 import sysconfig
 from sysconfig import (get_paths, get_platform, get_config_vars,
                        get_path, get_path_names, _INSTALL_SCHEMES,
                        _get_default_scheme, _expand_vars,
-                       get_scheme_names)
+                       get_scheme_names, get_config_var, _main)
 
 class TestSysConfig(unittest.TestCase):
 
@@ -254,6 +255,22 @@
         finally:
             unlink(link)
 
+    def test_user_similar(self):
+        # Issue 8759 : make sure the posix scheme for the users
+        # is similar to the global posix_prefix one
+        base = get_config_var('base')
+        user = get_config_var('userbase')
+        for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
+            global_path = get_path(name, 'posix_prefix')
+            user_path = get_path(name, 'posix_user')
+            self.assertEquals(user_path, global_path.replace(base, user))
+
+    def test_main(self):
+        # just making sure _main() runs and returns things in the stdout
+        with captured_stdout() as output:
+            _main()
+        self.assertTrue(len(output.getvalue().split('\n')) > 0)
+
 
 def test_main():
     run_unittest(TestSysConfig)

Modified: python/branches/py3k-cdecimal/Lib/test/test_tarfile.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_tarfile.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_tarfile.py	Mon Jun  7 12:46:02 2010
@@ -133,6 +133,26 @@
                      "read() after readline() failed")
         fobj.close()
 
+    # Test if symbolic and hard links are resolved by extractfile().  The
+    # test link members each point to a regular member whose data is
+    # supposed to be exported.
+    def _test_fileobj_link(self, lnktype, regtype):
+        a = self.tar.extractfile(lnktype)
+        b = self.tar.extractfile(regtype)
+        self.assertEqual(a.name, b.name)
+
+    def test_fileobj_link1(self):
+        self._test_fileobj_link("ustar/lnktype", "ustar/regtype")
+
+    def test_fileobj_link2(self):
+        self._test_fileobj_link("./ustar/linktest2/lnktype", "ustar/linktest1/regtype")
+
+    def test_fileobj_symlink1(self):
+        self._test_fileobj_link("ustar/symtype", "ustar/regtype")
+
+    def test_fileobj_symlink2(self):
+        self._test_fileobj_link("./ustar/linktest2/symtype", "ustar/linktest1/regtype")
+
 
 class CommonReadTest(ReadTest):
 
@@ -661,10 +681,14 @@
         if hasattr(os, "link"):
             link = os.path.join(TEMPDIR, "link")
             target = os.path.join(TEMPDIR, "link_target")
-            open(target, "wb").close()
+            fobj = open(target, "wb")
+            fobj.write(b"aaa")
+            fobj.close()
             os.link(target, link)
             try:
                 tar = tarfile.open(tmpname, self.mode)
+                # Record the link target in the inodes list.
+                tar.gettarinfo(target)
                 tarinfo = tar.gettarinfo(link)
                 self.assertEqual(tarinfo.size, 0)
             finally:
@@ -1374,6 +1398,29 @@
         fobj.close()
 
 
+class LinkEmulationTest(ReadTest):
+
+    # Test for issue #8741 regression. On platforms that do not support
+    # symbolic or hard links tarfile tries to extract these types of members as
+    # the regular files they point to.
+    def _test_link_extraction(self, name):
+        self.tar.extract(name, TEMPDIR)
+        data = open(os.path.join(TEMPDIR, name), "rb").read()
+        self.assertEqual(md5sum(data), md5_regtype)
+
+    def test_hardlink_extraction1(self):
+        self._test_link_extraction("ustar/lnktype")
+
+    def test_hardlink_extraction2(self):
+        self._test_link_extraction("./ustar/linktest2/lnktype")
+
+    def test_symlink_extraction1(self):
+        self._test_link_extraction("ustar/symtype")
+
+    def test_symlink_extraction2(self):
+        self._test_link_extraction("./ustar/linktest2/symtype")
+
+
 class GzipMiscReadTest(MiscReadTest):
     tarname = gzipname
     mode = "r:gz"
@@ -1459,6 +1506,8 @@
 
     if hasattr(os, "link"):
         tests.append(HardlinkTest)
+    else:
+        tests.append(LinkEmulationTest)
 
     fobj = open(tarname, "rb")
     data = fobj.read()

Modified: python/branches/py3k-cdecimal/Lib/test/test_tcl.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_tcl.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_tcl.py	Mon Jun  7 12:46:02 2010
@@ -127,6 +127,31 @@
         tcl = self.interp
         self.assertRaises(TclError,tcl.eval,'package require DNE')
 
+    def testLoadWithUNC(self):
+        import sys
+        if sys.platform != 'win32':
+            return
+
+        # Build a UNC path from the regular path.
+        # Something like
+        #   \\%COMPUTERNAME%\c$\python27\python.exe
+
+        fullname = os.path.abspath(sys.executable)
+        if fullname[1] != ':':
+            return
+        unc_name = r'\\%s\%s$\%s' % (os.environ['COMPUTERNAME'],
+                                    fullname[0],
+                                    fullname[3:])
+
+        with test_support.EnvironmentVarGuard() as env:
+            env.unset("TCL_LIBRARY")
+            f = os.popen('%s -c "import Tkinter; print Tkinter"' % (unc_name,))
+
+        self.assert_('Tkinter.py' in f.read())
+        # exit code must be zero
+        self.assertEqual(f.close(), None)
+
+
 
 def test_main():
     support.run_unittest(TclTest, TkinterTest)

Modified: python/branches/py3k-cdecimal/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_urllib2.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_urllib2.py	Mon Jun  7 12:46:02 2010
@@ -1151,7 +1151,6 @@
         self.assertEqual(len(http_handler.requests), 1)
         self.assertFalse(http_handler.requests[0].has_header(auth_header))
 
-
 class MiscTests(unittest.TestCase):
 
     def test_build_opener(self):

Modified: python/branches/py3k-cdecimal/Lib/test/test_warnings.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_warnings.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_warnings.py	Mon Jun  7 12:46:02 2010
@@ -738,20 +738,38 @@
     module = py_warnings
 
 
+class BootstrapTest(unittest.TestCase):
+    def test_issue_8766(self):
+        # "import encodings" emits a warning whereas the warnings is not loaded
+        # or not completly loaded (warnings imports indirectly encodings by
+        # importing linecache) yet
+        with support.temp_cwd() as cwd, support.temp_cwd('encodings'):
+            env = os.environ.copy()
+            env['PYTHONPATH'] = cwd
+
+            # encodings loaded by initfsencoding()
+            retcode = subprocess.call([sys.executable, '-c', 'pass'], env=env)
+            self.assertEqual(retcode, 0)
+
+            # Use -W to load warnings module at startup
+            retcode = subprocess.call(
+                [sys.executable, '-c', 'pass', '-W', 'always'],
+                env=env)
+            self.assertEqual(retcode, 0)
+
 def test_main():
     py_warnings.onceregistry.clear()
     c_warnings.onceregistry.clear()
-    support.run_unittest(CFilterTests,
-                                PyFilterTests,
-                                CWarnTests,
-                                PyWarnTests,
-                                CWCmdLineTests, PyWCmdLineTests,
-                                _WarningsTests,
-                                CWarningsDisplayTests, PyWarningsDisplayTests,
-                                CCatchWarningTests, PyCatchWarningTests,
-                                CEnvironmentVariableTests,
-                                PyEnvironmentVariableTests
-                             )
+    support.run_unittest(
+        CFilterTests, PyFilterTests,
+        CWarnTests, PyWarnTests,
+        CWCmdLineTests, PyWCmdLineTests,
+        _WarningsTests,
+        CWarningsDisplayTests, PyWarningsDisplayTests,
+        CCatchWarningTests, PyCatchWarningTests,
+        CEnvironmentVariableTests, PyEnvironmentVariableTests,
+        BootstrapTest,
+    )
 
 
 if __name__ == "__main__":

Modified: python/branches/py3k-cdecimal/Lib/test/test_winreg.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_winreg.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_winreg.py	Mon Jun  7 12:46:02 2010
@@ -5,6 +5,7 @@
 import os, sys
 import unittest
 from test import support
+threading = support.import_module("threading")
 from platform import machine
 
 # Do this first so test will be skipped if module doesn't exist
@@ -227,6 +228,58 @@
         except WindowsError:
             self.assertEqual(h.handle, 0)
 
+    def test_changing_value(self):
+        # Issue2810: A race condition in 2.6 and 3.1 may cause
+        # EnumValue or QueryValue to throw "WindowsError: More data is
+        # available"
+        done = False
+
+        class VeryActiveThread(threading.Thread):
+            def run(self):
+                with CreateKey(HKEY_CURRENT_USER, test_key_name) as key:
+                    use_short = True
+                    long_string = 'x'*2000
+                    while not done:
+                        s = 'x' if use_short else long_string
+                        use_short = not use_short
+                        SetValue(key, 'changing_value', REG_SZ, s)
+
+        thread = VeryActiveThread()
+        thread.start()
+        try:
+            with CreateKey(HKEY_CURRENT_USER,
+                           test_key_name+'\\changing_value') as key:
+                for _ in range(1000):
+                    num_subkeys, num_values, t = QueryInfoKey(key)
+                    for i in range(num_values):
+                        name = EnumValue(key, i)
+                        QueryValue(key, name[0])
+        finally:
+            done = True
+            thread.join()
+            DeleteKey(HKEY_CURRENT_USER, test_key_name+'\\changing_value')
+            DeleteKey(HKEY_CURRENT_USER, test_key_name)
+
+    def test_long_key(self):
+        # Issue2810, in 2.6 and 3.1 when the key name was exactly 256
+        # characters, EnumKey threw "WindowsError: More data is
+        # available"
+        name = 'x'*256
+        try:
+            with CreateKey(HKEY_CURRENT_USER, test_key_name) as key:
+                SetValue(key, name, REG_SZ, 'x')
+                num_subkeys, num_values, t = QueryInfoKey(key)
+                EnumKey(key, 0)
+        finally:
+            DeleteKey(HKEY_CURRENT_USER, '\\'.join((test_key_name, name)))
+            DeleteKey(HKEY_CURRENT_USER, test_key_name)
+
+    def test_dynamic_key(self):
+        # Issue2810, when the value is dynamically generated, these
+        # throw "WindowsError: More data is available" in 2.6 and 3.1
+        EnumValue(HKEY_PERFORMANCE_DATA, 0)
+        QueryValueEx(HKEY_PERFORMANCE_DATA, "")
+
     # Reflection requires XP x64/Vista at a minimum. XP doesn't have this stuff
     # or DeleteKeyEx so make sure their use raises NotImplementedError
     @unittest.skipUnless(WIN_VER < (5, 2), "Requires Windows XP")

Modified: python/branches/py3k-cdecimal/Lib/test/test_winsound.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_winsound.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_winsound.py	Mon Jun  7 12:46:02 2010
@@ -6,6 +6,7 @@
 import time
 import os
 import subprocess
+import ctypes
 
 winsound = support.import_module('winsound')
 import winreg
@@ -13,6 +14,11 @@
 def has_sound(sound):
     """Find out if a particular event is configured with a default sound"""
     try:
+        # Ask the mixer API for the number of devices it knows about.
+        # When there are no devices, PlaySound will fail.
+        if ctypes.windll.winmm.mixerGetNumDevs() is 0:
+            return False
+
         key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER,
                 "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
         value = winreg.EnumValue(key, 0)[1]

Modified: python/branches/py3k-cdecimal/Lib/test/testtar.tar
==============================================================================
Binary files. No diff available.

Modified: python/branches/py3k-cdecimal/Lib/tkinter/_fix.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tkinter/_fix.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tkinter/_fix.py	Mon Jun  7 12:46:02 2010
@@ -42,6 +42,8 @@
         # Ignore leading \\?\
         if s.startswith("\\\\?\\"):
             s = s[4:]
+        if s.startswith("UNC"):
+            s = "\\" + s[3:]
         return s
 
 prefix = os.path.join(sys.prefix,"tcl")

Modified: python/branches/py3k-cdecimal/Lib/unittest/case.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/case.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/case.py	Mon Jun  7 12:46:02 2010
@@ -14,6 +14,9 @@
 __unittest = True
 
 
+DIFF_OMITTED = ('\nDiff is %s characters long. '
+                 'Set self.maxDiff to None to see it.')
+
 class SkipTest(Exception):
     """
     Raise this exception in a test to skip it.
@@ -169,6 +172,12 @@
 
     longMessage = False
 
+    # This attribute sets the maximum length of a diff in failure messsages
+    # by assert methods using difflib. It is looked up as an instance attribute
+    # so can be configured by individual tests if required.
+
+    maxDiff = 80*8
+
     # Attribute used by TestSuite for classSetUp
 
     _classSetupFailed = False
@@ -694,12 +703,21 @@
                 except (TypeError, IndexError, NotImplementedError):
                     differing += ('Unable to index element %d '
                                   'of second %s\n' % (len1, seq_type_name))
-        standardMsg = differing + '\n' + '\n'.join(
+        standardMsg = differing
+        diffMsg = '\n' + '\n'.join(
             difflib.ndiff(pprint.pformat(seq1).splitlines(),
                           pprint.pformat(seq2).splitlines()))
+
+        standardMsg = self._truncateMessage(standardMsg, diffMsg)
         msg = self._formatMessage(msg, standardMsg)
         self.fail(msg)
 
+    def _truncateMessage(self, message, diff):
+        max_diff = self.maxDiff
+        if max_diff is None or len(diff) <= max_diff:
+            return message + diff
+        return message + (DIFF_OMITTED % len(diff))
+
     def assertListEqual(self, list1, list2, msg=None):
         """A list-specific equality assertion.
 
@@ -798,9 +816,11 @@
         self.assert_(isinstance(d2, dict), 'Second argument is not a dictionary')
 
         if d1 != d2:
-            standardMsg = ('\n' + '\n'.join(difflib.ndiff(
+            standardMsg = '%s != %s' % (safe_repr(d1, True), safe_repr(d2, True))
+            diff = ('\n' + '\n'.join(difflib.ndiff(
                            pprint.pformat(d1).splitlines(),
                            pprint.pformat(d2).splitlines())))
+            standardMsg = self._truncateMessage(standardMsg, diff)
             self.fail(self._formatMessage(msg, standardMsg))
 
     def assertDictContainsSubset(self, expected, actual, msg=None):
@@ -917,8 +937,10 @@
                 'Second argument is not a string'))
 
         if first != second:
-            standardMsg = '\n' + ''.join(difflib.ndiff(first.splitlines(True),
+            standardMsg = '%s != %s' % (safe_repr(first, True), safe_repr(second, True))
+            diff = '\n' + ''.join(difflib.ndiff(first.splitlines(True),
                                                        second.splitlines(True)))
+            standardMsg = self._truncateMessage(standardMsg, diff)
             self.fail(self._formatMessage(msg, standardMsg))
 
     def assertLess(self, a, b, msg=None):

Modified: python/branches/py3k-cdecimal/Lib/unittest/loader.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/loader.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/loader.py	Mon Jun  7 12:46:02 2010
@@ -235,6 +235,10 @@
         __import__(name)
         return sys.modules[name]
 
+    def _match_path(self, path, full_path, pattern):
+        # override this method to use alternative matching strategy
+        return fnmatch(path, pattern)
+
     def _find_tests(self, start_dir, pattern):
         """Used by discovery. Yields test suites it loads."""
         paths = os.listdir(start_dir)
@@ -245,26 +249,26 @@
                 if not VALID_MODULE_NAME.match(path):
                     # valid Python identifiers only
                     continue
-
-                if fnmatch(path, pattern):
-                    # if the test file matches, load it
-                    name = self._get_name_from_path(full_path)
-                    try:
-                        module = self._get_module_from_name(name)
-                    except:
-                        yield _make_failed_import_test(name, self.suiteClass)
-                    else:
-                        mod_file = os.path.abspath(getattr(module, '__file__', full_path))
-                        realpath = os.path.splitext(mod_file)[0]
-                        fullpath_noext = os.path.splitext(full_path)[0]
-                        if realpath.lower() != fullpath_noext.lower():
-                            module_dir = os.path.dirname(realpath)
-                            mod_name = os.path.splitext(os.path.basename(full_path))[0]
-                            expected_dir = os.path.dirname(full_path)
-                            msg = ("%r module incorrectly imported from %r. Expected %r. "
-                                   "Is this module globally installed?")
-                            raise ImportError(msg % (mod_name, module_dir, expected_dir))
-                        yield self.loadTestsFromModule(module)
+                if not self._match_path(path, full_path, pattern):
+                    continue
+                # if the test file matches, load it
+                name = self._get_name_from_path(full_path)
+                try:
+                    module = self._get_module_from_name(name)
+                except:
+                    yield _make_failed_import_test(name, self.suiteClass)
+                else:
+                    mod_file = os.path.abspath(getattr(module, '__file__', full_path))
+                    realpath = os.path.splitext(mod_file)[0]
+                    fullpath_noext = os.path.splitext(full_path)[0]
+                    if realpath.lower() != fullpath_noext.lower():
+                        module_dir = os.path.dirname(realpath)
+                        mod_name = os.path.splitext(os.path.basename(full_path))[0]
+                        expected_dir = os.path.dirname(full_path)
+                        msg = ("%r module incorrectly imported from %r. Expected %r. "
+                               "Is this module globally installed?")
+                        raise ImportError(msg % (mod_name, module_dir, expected_dir))
+                    yield self.loadTestsFromModule(module)
             elif os.path.isdir(full_path):
                 if not os.path.isfile(os.path.join(full_path, '__init__.py')):
                     continue

Modified: python/branches/py3k-cdecimal/Lib/unittest/suite.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/suite.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/suite.py	Mon Jun  7 12:46:02 2010
@@ -127,9 +127,11 @@
         if setUpClass is not None:
             try:
                 setUpClass()
-            except:
+            except Exception as e:
                 currentClass._classSetupFailed = True
-                self._addClassSetUpError(result, currentClass)
+                className = util.strclass(currentClass)
+                errorName = 'setUpClass (%s)' % className
+                self._addClassOrModuleLevelException(result, e, errorName)
 
     def _get_previous_module(self, result):
         previousModule = None
@@ -157,10 +159,18 @@
         if setUpModule is not None:
             try:
                 setUpModule()
-            except:
+            except Exception as e:
                 result._moduleSetUpFailed = True
-                error = _ErrorHolder('setUpModule (%s)' % currentModule)
-                result.addError(error, sys.exc_info())
+                errorName = 'setUpModule (%s)' % currentModule
+                self._addClassOrModuleLevelException(result, e, errorName)
+
+    def _addClassOrModuleLevelException(self, result, exception, errorName):
+        error = _ErrorHolder(errorName)
+        addSkip = getattr(result, 'addSkip', None)
+        if addSkip is not None and isinstance(exception, case.SkipTest):
+            addSkip(error, str(exception))
+        else:
+            result.addError(error, sys.exc_info())
 
     def _handleModuleTearDown(self, result):
         previousModule = self._get_previous_module(result)
@@ -178,9 +188,9 @@
         if tearDownModule is not None:
             try:
                 tearDownModule()
-            except:
-                error = _ErrorHolder('tearDownModule (%s)' % previousModule)
-                result.addError(error, sys.exc_info())
+            except Exception as e:
+                errorName = 'tearDownModule (%s)' % previousModule
+                self._addClassOrModuleLevelException(result, e, errorName)
 
     def _tearDownPreviousClass(self, test, result):
         previousClass = getattr(result, '_previousTestClass', None)
@@ -198,18 +208,11 @@
         if tearDownClass is not None:
             try:
                 tearDownClass()
-            except:
-                self._addClassTearDownError(result)
+            except Exception as e:
+                className = util.strclass(previousClass)
+                errorName = 'tearDownClass (%s)' % className
+                self._addClassOrModuleLevelException(result, e, errorName)
 
-    def _addClassTearDownError(self, result):
-        className = util.strclass(result._previousTestClass)
-        error = _ErrorHolder('classTearDown (%s)' % className)
-        result.addError(error, sys.exc_info())
-
-    def _addClassSetUpError(self, result, klass):
-        className = util.strclass(klass)
-        error = _ErrorHolder('classSetUp (%s)' % className)
-        result.addError(error, sys.exc_info())
 
 
 class _ErrorHolder(object):

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_case.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_case.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_case.py	Mon Jun  7 12:46:02 2010
@@ -1,3 +1,5 @@
+import difflib
+import pprint
 import re
 import sys
 
@@ -589,6 +591,84 @@
         self.assertRaises(self.failureException, self.assertDictEqual, [], d)
         self.assertRaises(self.failureException, self.assertDictEqual, 1, 1)
 
+    def testAssertSequenceEqualMaxDiff(self):
+        self.assertEqual(self.maxDiff, 80*8)
+        seq1 = 'a' + 'x' * 80**2
+        seq2 = 'b' + 'x' * 80**2
+        diff = '\n'.join(difflib.ndiff(pprint.pformat(seq1).splitlines(),
+                                       pprint.pformat(seq2).splitlines()))
+        # the +1 is the leading \n added by assertSequenceEqual
+        omitted = unittest.case.DIFF_OMITTED % (len(diff) + 1,)
+
+        self.maxDiff = len(diff)//2
+        try:
+
+            self.assertSequenceEqual(seq1, seq2)
+        except self.failureException as e:
+            msg = e.args[0]
+        else:
+            self.fail('assertSequenceEqual did not fail.')
+        self.assertTrue(len(msg) < len(diff))
+        self.assertIn(omitted, msg)
+
+        self.maxDiff = len(diff) * 2
+        try:
+            self.assertSequenceEqual(seq1, seq2)
+        except self.failureException as e:
+            msg = e.args[0]
+        else:
+            self.fail('assertSequenceEqual did not fail.')
+        self.assertTrue(len(msg) > len(diff))
+        self.assertNotIn(omitted, msg)
+
+        self.maxDiff = None
+        try:
+            self.assertSequenceEqual(seq1, seq2)
+        except self.failureException as e:
+            msg = e.args[0]
+        else:
+            self.fail('assertSequenceEqual did not fail.')
+        self.assertTrue(len(msg) > len(diff))
+        self.assertNotIn(omitted, msg)
+
+    def testTruncateMessage(self):
+        self.maxDiff = 1
+        message = self._truncateMessage('foo', 'bar')
+        omitted = unittest.case.DIFF_OMITTED % len('bar')
+        self.assertEqual(message, 'foo' + omitted)
+
+        self.maxDiff = None
+        message = self._truncateMessage('foo', 'bar')
+        self.assertEqual(message, 'foobar')
+
+        self.maxDiff = 4
+        message = self._truncateMessage('foo', 'bar')
+        self.assertEqual(message, 'foobar')
+
+    def testAssertDictEqualTruncates(self):
+        test = unittest.TestCase('assertEqual')
+        def truncate(msg, diff):
+            return 'foo'
+        test._truncateMessage = truncate
+        try:
+            test.assertDictEqual({}, {1: 0})
+        except self.failureException as e:
+            self.assertEqual(str(e), 'foo')
+        else:
+            self.fail('assertDictEqual did not fail')
+
+    def testAssertMultiLineEqualTruncates(self):
+        test = unittest.TestCase('assertEqual')
+        def truncate(msg, diff):
+            return 'foo'
+        test._truncateMessage = truncate
+        try:
+            test.assertMultiLineEqual('foo', 'bar')
+        except self.failureException as e:
+            self.assertEqual(str(e), 'foo')
+        else:
+            self.fail('assertMultiLineEqual did not fail')
+
     def testAssertItemsEqual(self):
         a = object()
         self.assertItemsEqual([1, 2, 3], [3, 2, 1])
@@ -739,7 +819,7 @@
     A test case is the smallest unit of testing. [...] You may provide your
     own implementation that does not subclass from TestCase, of course.
 """
-        sample_text_error = """
+        sample_text_error = """\
 - http://www.python.org/doc/2.3/lib/module-unittest.html
 ?                             ^
 + http://www.python.org/doc/2.4.1/lib/module-unittest.html
@@ -750,13 +830,16 @@
 ?                                                       +++++++++++++++++++++
 +     own implementation that does not subclass from TestCase, of course.
 """
-
+        self.maxDiff = None
         try:
             self.assertMultiLineEqual(sample_text, revised_sample_text)
         except self.failureException as e:
+            # need to remove the first line of the error message
+            error = str(e).split('\n', 1)[1]
+
             # no fair testing ourself with ourself, and assertEqual is used for strings
             # so can't use assertEqual either. Just use assertTrue.
-            self.assertTrue(sample_text_error == str(e))
+            self.assertTrue(sample_text_error == error)
 
     def testAssertIsNone(self):
         self.assertIsNone(None)

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_setups.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_setups.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_setups.py	Mon Jun  7 12:46:02 2010
@@ -111,7 +111,7 @@
         self.assertEqual(len(result.errors), 1)
         error, _ = result.errors[0]
         self.assertEqual(str(error),
-                    'classSetUp (%s.BrokenTest)' % __name__)
+                    'setUpClass (%s.BrokenTest)' % __name__)
 
     def test_error_in_teardown_class(self):
         class Test(unittest.TestCase):
@@ -144,7 +144,7 @@
 
         error, _ = result.errors[0]
         self.assertEqual(str(error),
-                    'classTearDown (%s.Test)' % __name__)
+                    'tearDownClass (%s.Test)' % __name__)
 
     def test_class_not_torndown_when_setup_fails(self):
         class Test(unittest.TestCase):
@@ -398,3 +398,46 @@
         self.assertEqual(len(result.errors), 1)
         error, _ = result.errors[0]
         self.assertEqual(str(error), 'tearDownModule (Module)')
+
+    def test_skiptest_in_setupclass(self):
+        class Test(unittest.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                raise unittest.SkipTest('foo')
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+
+        result = self.runTests(Test)
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.skipped), 1)
+        skipped = result.skipped[0][0]
+        self.assertEqual(str(skipped), 'setUpClass (%s.Test)' % __name__)
+
+    def test_skiptest_in_setupmodule(self):
+        class Test(unittest.TestCase):
+            def test_one(self):
+                pass
+            def test_two(self):
+                pass
+
+        class Module(object):
+            @staticmethod
+            def setUpModule():
+                raise unittest.SkipTest('foo')
+
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+
+        result = self.runTests(Test)
+        self.assertEqual(result.testsRun, 0)
+        self.assertEqual(len(result.errors), 0)
+        self.assertEqual(len(result.skipped), 1)
+        skipped = result.skipped[0][0]
+        self.assertEqual(str(skipped), 'setUpModule (Module)')
+
+
+if __name__ == '__main__':
+    unittest.main()

Modified: python/branches/py3k-cdecimal/Lib/unittest/util.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/util.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/util.py	Mon Jun  7 12:46:02 2010
@@ -2,12 +2,16 @@
 
 __unittest = True
 
-
-def safe_repr(obj):
+_MAX_LENGTH = 80
+def safe_repr(obj, short=False):
     try:
-        return repr(obj)
+        result = repr(obj)
     except Exception:
-        return object.__repr__(obj)
+        result = object.__repr__(obj)
+    if not short or len(result) < _MAX_LENGTH:
+        return result
+    return result[:_MAX_LENGTH] + ' [truncated]...'
+
 
 def strclass(cls):
     return "%s.%s" % (cls.__module__, cls.__name__)

Modified: python/branches/py3k-cdecimal/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/urllib/request.py	(original)
+++ python/branches/py3k-cdecimal/Lib/urllib/request.py	Mon Jun  7 12:46:02 2010
@@ -775,12 +775,21 @@
             password_mgr = HTTPPasswordMgr()
         self.passwd = password_mgr
         self.add_password = self.passwd.add_password
+        self.retried = 0
 
     def http_error_auth_reqed(self, authreq, host, req, headers):
         # host may be an authority (without userinfo) or a URL with an
         # authority
         # XXX could be multiple headers
         authreq = headers.get(authreq, None)
+
+        if self.retried > 5:
+            # retry sending the username:password 5 times before failing.
+            raise HTTPError(req.get_full_url(), 401, "basic auth failed",
+                    headers, None)
+        else:
+            self.retried += 1
+
         if authreq:
             mo = AbstractBasicAuthHandler.rx.search(authreq)
             if mo:

Modified: python/branches/py3k-cdecimal/Lib/webbrowser.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/webbrowser.py	(original)
+++ python/branches/py3k-cdecimal/Lib/webbrowser.py	Mon Jun  7 12:46:02 2010
@@ -540,18 +540,6 @@
 # Platform support for MacOS
 #
 
-try:
-    import ic
-except ImportError:
-    pass
-else:
-    class InternetConfig(BaseBrowser):
-        def open(self, url, new=0, autoraise=True):
-            ic.launchurl(url)
-            return True # Any way to get status?
-
-    register("internet-config", InternetConfig, update_tryorder=-1)
-
 if sys.platform == 'darwin':
     # Adapted from patch submitted to SourceForge by Steven J. Burr
     class MacOSX(BaseBrowser):

Modified: python/branches/py3k-cdecimal/Mac/Tools/pythonw.c
==============================================================================
--- python/branches/py3k-cdecimal/Mac/Tools/pythonw.c	(original)
+++ python/branches/py3k-cdecimal/Mac/Tools/pythonw.c	Mon Jun  7 12:46:02 2010
@@ -151,6 +151,14 @@
 main(int argc, char **argv) {
     char* exec_path = get_python_path();
 
+    /*
+     * Let argv[0] refer to the new interpreter. This is needed to
+     * get the effect we want on OSX 10.5 or earlier. That is, without
+     * changing argv[0] the real interpreter won't have access to
+     * the Window Server.
+     */
+    argv[0] = exec_path;
+
 #ifdef HAVE_SPAWN_H
     /* We're weak-linking to posix-spawnv to ensure that
      * an executable build on 10.5 can work on 10.4.

Modified: python/branches/py3k-cdecimal/Misc/ACKS
==============================================================================
--- python/branches/py3k-cdecimal/Misc/ACKS	(original)
+++ python/branches/py3k-cdecimal/Misc/ACKS	Mon Jun  7 12:46:02 2010
@@ -19,6 +19,7 @@
 Kevin Altis
 Joe Amenta
 Mark Anacker
+Shashwat Anand
 Anders Andersen
 John Anderson
 Erik Andersén
@@ -82,6 +83,7 @@
 Paul Boddie
 Matthew Boedicker
 David Bolen
+Forest Bond
 Gawain Bolton
 Gregory Bond
 Jurjen Bos
@@ -363,6 +365,7 @@
 Eric Huss
 Jeremy Hylton
 Gerhard Häring
+Fredrik Håård
 Mihai Ibanescu
 Lars Immisch
 Meador Inge
@@ -424,6 +427,7 @@
 Damon Kohler
 Joseph Koshy
 Maksim Kozyarchuk
+Stefan Krah
 Bob Kras
 Holger Krekel
 Michael Kremer

Modified: python/branches/py3k-cdecimal/Misc/NEWS
==============================================================================
--- python/branches/py3k-cdecimal/Misc/NEWS	(original)
+++ python/branches/py3k-cdecimal/Misc/NEWS	Mon Jun  7 12:46:02 2010
@@ -12,6 +12,31 @@
 Core and Builtins
 -----------------
 
+- Issue #8837: Remove "O?" format of PyArg_Parse*() functions. The format is no
+  used anymore and it was never documented.
+
+- Issue #2844: Make int('42', n) consistently raise ValueError for
+  invalid integers n (including n = -909).
+
+- Issue #8188: Introduce a new scheme for computing hashes of numbers
+  (instances of int, float, complex, decimal.Decimal and
+  fractions.Fraction) that makes it easy to maintain the invariant
+  that hash(x) == hash(y) whenever x and y have equal value.
+
+- Issue #8748: Fix two issues with comparisons between complex and integer
+  objects.  (1) The comparison could incorrectly return True in some cases
+  (2**53+1 == complex(2**53) == 2**53), breaking transivity of equality.
+  (2) The comparison raised an OverflowError for large integers, leading
+  to unpredictable exceptions when combining integers and complex objects
+  in sets or dicts.
+
+- Issue #8766: Initialize _warnings module before importing the first module.
+  Fix a crash if an empty directory called "encodings" exists in sys.path.
+
+- Issue #8589: Decode PYTHONWARNINGS environment variable with the file system
+  encoding and surrogateespace error handler instead of the locale encoding to
+  be consistent with os.environ. Add PySys_AddWarnOptionUnicode() function.
+
 - PyObject_Dump() encodes unicode objects to utf8 with backslashreplace
   (instead of strict) error handler to escape surrogates
 
@@ -31,6 +56,8 @@
   PyUnicode_FromString() to support surrogates in the filename and use the
   right encoding
 
+- Issue #7507: Quote "!" in pipes.quote(); it is special to some shells.
+
 - PyUnicode_DecodeFSDefaultAndSize() uses surrogateescape error handler
 
 - Issue #8419: Prevent the dict constructor from accepting non-string keyword
@@ -312,6 +339,11 @@
 C-API
 -----
 
+- Issue #5753: A new C API function, :cfunc:`PySys_SetArgvEx`, allows
+  embedders of the interpreter to set sys.argv without also modifying
+  sys.path.  This helps fix `CVE-2008-5983
+  <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
+
 - Add PyArg_ValidateKeywordArguments, which checks if all keyword arguments are
   strings in an efficient manner.
 
@@ -366,6 +398,74 @@
 Library
 -------
 
+- Issue #8899: time.struct_time now has class and atribute docstrings.
+
+- Issue #6470: Drop UNC prefix in FixTk.
+
+- Issue #4768: base64 encoded email body parts were incorrectly stored as
+  binary strings.  They are now correctly converted to strings.
+
+- Issue #8833: tarfile created hard link entries with a size field != 0 by
+  mistake.
+
+- Charset.body_encode now correctly handles base64 encoding by encoding
+  with the output_charset before calling base64mime.encode.  Passes the
+  tests from 2.x issue 1368247.
+
+- Issue #8845: sqlite3 Connection objects now have a read-only in_transaction
+  attribute that is True iff there are uncommitted changes.
+
+- Issue #1289118: datetime.timedelta objects can now be multiplied by float
+  and divided by float and int objects.  Results are rounded to the nearest
+  multiple of timedelta.resolution with ties resolved using round-half-to-even
+  method.
+
+- Issue #7150: Raise OverflowError if the result of adding or subtracting
+  timedelta from date or datetime falls outside of the MINYEAR:MAXYEAR range.
+
+- Issue #8806: add SSL contexts support to ftplib.
+
+- Issue #4769: Fix main() function of the base64 module, use sys.stdin.buffer
+  and sys.stdout.buffer (instead of sys.stdin and sys.stdout) to use the bytes
+  API
+
+- Issue #8770: now sysconfig displays information when it's called as
+  a script. Initial idea by Sridhar Ratnakumar.
+
+- Issue #6662: Fix parsing of malformatted charref (&#bad;), patch written by
+  Fredrik Håård
+
+- Issue #8540: Decimal module: rename the Context._clamp attribute to
+  Context.clamp and make it public.  This is useful in creating
+  contexts that correspond to the decimal interchange formats
+  specified in IEEE 754.
+
+- Issue #6268: Fix seek() method of codecs.open(), don't read or write the BOM
+  twice after seek(0). Fix also reset() method of codecs, UTF-16, UTF-32 and
+  StreamWriter classes.
+
+- Issue #3798: sys.exit(message) writes the message to sys.stderr file, instead
+  of the C file stderr, to use stderr encoding and error handler
+
+- Issue #8782: Add a trailing newline in linecache.updatecache to the last line
+  of files without one.
+
+- Issue #8729: Return NotImplemented from collections.Mapping.__eq__ when
+  comparing to a non-mapping.
+
+- Issue #8774: tabnanny uses the encoding cookie (#coding:...) to use the
+  correct encoding
+
+- Issue #4870: Add an `options` attribute to SSL contexts, as well as
+  several ``OP_*`` constants to the `ssl` module.  This allows to selectively
+  disable protocol versions, when used in combination with `PROTOCOL_SSLv23`.
+
+- Issue #8759: Fixed user paths in sysconfig for posix and os2 schemes.
+
+- Issue #8663: distutils.log emulates backslashreplace error handler. Fix
+  compilation in a non-ASCII directory if stdout encoding is ASCII (eg. if
+  stdout is not a TTY).
+
 - Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value.
   subprocess.Popen() and os._execvpe() support bytes program name. Add
   os.supports_bytes_environ flag: True if the native OS type of the environment
@@ -442,7 +542,7 @@
 - Issue #8354: The siginterrupt setting is now preserved for all signals,
   not just SIGCHLD.
 
-- Issue #7192: webbrowser.get("firefox") now wors on Mac OS X, as does
+- Issue #7192: webbrowser.get("firefox") now works on Mac OS X, as does
   webbrowser.get("safari").
 
 - Issue #8464: tarfile no longer creates files with execute permissions set
@@ -1153,6 +1253,9 @@
 Extension Modules
 -----------------
 
+- Issue #2810: Fix cases where the Windows registry API returns
+  ERROR_MORE_DATA, requiring a re-try in order to get the complete result.
+
 - Issue #8692: Optimize math.factorial: replace the previous naive
   algorithm with an improved 'binary-split' algorithm that uses fewer
   multiplications and allows many of the multiplications to be
@@ -1229,6 +1332,9 @@
 Build
 -----
 
+- Issue #1759169, #8864: Drop _XOPEN_SOURCE on Solaris, define it for
+  multiprocessing only.
+
 - Issue #8625: Turn off optimization in --with-pydebug builds with
   gcc.  (Optimization was unintentionally turned on in gcc
   --with-pydebug builds as a result of the issue #1628484 fix,
@@ -1315,9 +1421,14 @@
 - Update python manual page (options -B, -O0, -s, environment variables
   PYTHONDONTWRITEBYTECODE, PYTHONNOUSERSITE).
 
+- Issue #8909: Added the size of the bitmap used in the installer created by
+  distutils' bdist_wininst. Patch by Anatoly Techtonik.
+
 Tests
 -----
 
+- Issue #7449: Skip test_socketserver if threading support is disabled
+
 - Issue #8672: Add a zlib test ensuring that an incomplete stream can be
   handled by a decompressor object without errors (it returns incomplete
   uncompressed data).
@@ -1444,6 +1555,8 @@
 Tools/Demos
 -----------
 
+- Issue #5464: Implement plural forms in msgfmt.py.
+
 - iobench (a file I/O benchmark) and ccbench (a concurrency benchmark) were
   added to the `Tools/` directory.  They were previously living in the
   sandbox.

Modified: python/branches/py3k-cdecimal/Misc/developers.txt
==============================================================================
--- python/branches/py3k-cdecimal/Misc/developers.txt	(original)
+++ python/branches/py3k-cdecimal/Misc/developers.txt	Mon Jun  7 12:46:02 2010
@@ -20,6 +20,9 @@
 Permissions History
 -------------------
 
+- Alexander Belopolsky was given commit access on May 25 2010
+  by MvL at suggestion of Mark Dickinson.
+
 - Tim Golden was given commit access on April 21 2010 by MvL,
   at suggestion of Michael Foord.
 

Modified: python/branches/py3k-cdecimal/Modules/_multiprocessing/multiprocessing.h
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_multiprocessing/multiprocessing.h	(original)
+++ python/branches/py3k-cdecimal/Modules/_multiprocessing/multiprocessing.h	Mon Jun  7 12:46:02 2010
@@ -3,6 +3,12 @@
 
 #define PY_SSIZE_T_CLEAN
 
+#ifdef __sun
+/* The control message API is only available on Solaris 
+   if XPG 4.2 or later is requested. */
+#define _XOPEN_SOURCE 500
+#endif
+
 #include "Python.h"
 #include "structmember.h"
 #include "pythread.h"

Modified: python/branches/py3k-cdecimal/Modules/_sqlite/connection.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_sqlite/connection.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_sqlite/connection.c	Mon Jun  7 12:46:02 2010
@@ -23,6 +23,7 @@
 
 #include "cache.h"
 #include "module.h"
+#include "structmember.h"
 #include "connection.h"
 #include "statement.h"
 #include "cursor.h"
@@ -1551,6 +1552,7 @@
     {"NotSupportedError", T_OBJECT, offsetof(pysqlite_Connection, NotSupportedError), READONLY},
     {"row_factory", T_OBJECT, offsetof(pysqlite_Connection, row_factory)},
     {"text_factory", T_OBJECT, offsetof(pysqlite_Connection, text_factory)},
+    {"in_transaction", T_BOOL, offsetof(pysqlite_Connection, inTransaction), READONLY},
     {NULL}
 };
 

Modified: python/branches/py3k-cdecimal/Modules/_ssl.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_ssl.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_ssl.c	Mon Jun  7 12:46:02 2010
@@ -113,6 +113,13 @@
 # undef HAVE_OPENSSL_RAND
 #endif
 
+/* SSL_CTX_clear_options() and SSL_clear_options() were first added in OpenSSL 0.9.8m */
+#if OPENSSL_VERSION_NUMBER >= 0x009080dfL
+# define HAVE_SSL_CTX_CLEAR_OPTIONS
+#else
+# undef HAVE_SSL_CTX_CLEAR_OPTIONS
+#endif
+
 typedef struct {
     PyObject_HEAD
     SSL_CTX *ctx;
@@ -1514,6 +1521,35 @@
 }
 
 static PyObject *
+get_options(PySSLContext *self, void *c)
+{
+    return PyLong_FromLong(SSL_CTX_get_options(self->ctx));
+}
+
+static int
+set_options(PySSLContext *self, PyObject *arg, void *c)
+{
+    long new_opts, opts, set, clear;
+    if (!PyArg_Parse(arg, "l", &new_opts))
+        return -1;
+    opts = SSL_CTX_get_options(self->ctx);
+    clear = opts & ~new_opts;
+    set = ~opts & new_opts;
+    if (clear) {
+#ifdef HAVE_SSL_CTX_CLEAR_OPTIONS
+        SSL_CTX_clear_options(self->ctx, clear);
+#else
+        PyErr_SetString(PyExc_ValueError,
+                        "can't clear options before OpenSSL 0.9.8m");
+        return -1;
+#endif
+    }
+    if (set)
+        SSL_CTX_set_options(self->ctx, set);
+    return 0;
+}
+
+static PyObject *
 load_cert_chain(PySSLContext *self, PyObject *args, PyObject *kwds)
 {
     char *kwlist[] = {"certfile", "keyfile", NULL};
@@ -1636,6 +1672,8 @@
 }
 
 static PyGetSetDef context_getsetlist[] = {
+    {"options", (getter) get_options,
+                (setter) set_options, NULL},
     {"verify_mode", (getter) get_verify_mode,
                     (setter) set_verify_mode, NULL},
     {NULL},            /* sentinel */
@@ -1953,6 +1991,12 @@
     PyModule_AddIntConstant(m, "PROTOCOL_TLSv1",
                             PY_SSL_VERSION_TLS1);
 
+    /* protocol options */
+    PyModule_AddIntConstant(m, "OP_ALL", SSL_OP_ALL);
+    PyModule_AddIntConstant(m, "OP_NO_SSLv2", SSL_OP_NO_SSLv2);
+    PyModule_AddIntConstant(m, "OP_NO_SSLv3", SSL_OP_NO_SSLv3);
+    PyModule_AddIntConstant(m, "OP_NO_TLSv1", SSL_OP_NO_TLSv1);
+
     /* OpenSSL version */
     /* SSLeay() gives us the version of the library linked against,
        which could be different from the headers version.

Modified: python/branches/py3k-cdecimal/Modules/config.c.in
==============================================================================
--- python/branches/py3k-cdecimal/Modules/config.c.in	(original)
+++ python/branches/py3k-cdecimal/Modules/config.c.in	Mon Jun  7 12:46:02 2010
@@ -34,28 +34,28 @@
 
 /* -- ADDMODULE MARKER 2 -- */
 
-	/* This module lives in marshal.c */
-	{"marshal", PyMarshal_Init},
+    /* This module lives in marshal.c */
+    {"marshal", PyMarshal_Init},
 
-	/* This lives in import.c */
-	{"imp", PyInit_imp},
+    /* This lives in import.c */
+    {"imp", PyInit_imp},
 
-	/* This lives in Python/Python-ast.c */
-	{"_ast", PyInit__ast},
+    /* This lives in Python/Python-ast.c */
+    {"_ast", PyInit__ast},
 
-	/* These entries are here for sys.builtin_module_names */
-	{"__main__", NULL},
-	{"builtins", NULL},
-	{"sys", NULL},
+    /* These entries are here for sys.builtin_module_names */
+    {"__main__", NULL},
+    {"builtins", NULL},
+    {"sys", NULL},
 
-	/* This lives in gcmodule.c */
-	{"gc", PyInit_gc},
+    /* This lives in gcmodule.c */
+    {"gc", PyInit_gc},
 
-	/* This lives in _warnings.c */
-	{"_warnings", _PyWarnings_Init},
+    /* This lives in _warnings.c */
+    {"_warnings", _PyWarnings_Init},
 
-	/* Sentinel */
-	{0, 0}
+    /* Sentinel */
+    {0, 0}
 };
 
 

Modified: python/branches/py3k-cdecimal/Modules/datetimemodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/datetimemodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/datetimemodule.c	Mon Jun  7 12:46:02 2010
@@ -30,6 +30,7 @@
 
 #define MINYEAR 1
 #define MAXYEAR 9999
+#define MAXORDINAL 3652059 /* date(9999,12,31).toordinal() */
 
 /* Nine decimal digits is easy to communicate, and leaves enough room
  * so that two delta days can be added w/o fear of overflowing a signed
@@ -151,6 +152,25 @@
     return (long)x;
 }
 
+/* Nearest integer to m / n for integers m and n. Half-integer results
+ * are rounded to even.
+ */
+static PyObject *
+divide_nearest(PyObject *m, PyObject *n)
+{
+    PyObject *result;
+    PyObject *temp;
+
+    temp = _PyLong_Divmod_Near(m, n);
+    if (temp == NULL)
+        return NULL;
+    result = PyTuple_GET_ITEM(temp, 0);
+    Py_INCREF(result);
+    Py_DECREF(temp);
+
+    return result;
+}
+
 /* ---------------------------------------------------------------------------
  * General calendrical helper functions
  */
@@ -480,7 +500,7 @@
  * The input values must be such that the internals don't overflow.
  * The way this routine is used, we don't get close.
  */
-static void
+static int
 normalize_y_m_d(int *y, int *m, int *d)
 {
     int dim;            /* # of days in month */
@@ -534,11 +554,23 @@
         else {
             int ordinal = ymd_to_ord(*y, *m, 1) +
                                       *d - 1;
-            ord_to_ymd(ordinal, y, m, d);
+            if (ordinal < 1 || ordinal > MAXORDINAL) {
+                goto error;
+            } else {
+                ord_to_ymd(ordinal, y, m, d);
+                return 0;
+            }
         }
     }
     assert(*m > 0);
     assert(*d > 0);
+    if (MINYEAR <= *y && *y <= MAXYEAR)
+        return 0;
+ error:
+    PyErr_SetString(PyExc_OverflowError,
+            "date value out of range");
+    return -1;
+
 }
 
 /* Fiddle out-of-bounds months and days so that the result makes some kind
@@ -548,17 +580,7 @@
 static int
 normalize_date(int *year, int *month, int *day)
 {
-    int result;
-
-    normalize_y_m_d(year, month, day);
-    if (MINYEAR <= *year && *year <= MAXYEAR)
-        result = 0;
-    else {
-        PyErr_SetString(PyExc_OverflowError,
-                        "date value out of range");
-        result = -1;
-    }
-    return result;
+    return normalize_y_m_d(year, month, day);
 }
 
 /* Force all the datetime fields into range.  The parameters are both
@@ -1645,6 +1667,37 @@
 }
 
 static PyObject *
+multiply_float_timedelta(PyObject *floatobj, PyDateTime_Delta *delta)
+{
+    PyObject *result = NULL;
+    PyObject *pyus_in = NULL, *temp, *pyus_out;
+    PyObject *ratio = NULL;
+
+    pyus_in = delta_to_microseconds(delta);
+    if (pyus_in == NULL)
+        return NULL;
+    ratio = PyObject_CallMethod(floatobj, "as_integer_ratio", NULL);
+    if (ratio == NULL)
+        goto error;
+    temp = PyNumber_Multiply(pyus_in, PyTuple_GET_ITEM(ratio, 0));
+    Py_DECREF(pyus_in);
+    pyus_in = NULL;
+    if (temp == NULL)
+        goto error;
+    pyus_out = divide_nearest(temp, PyTuple_GET_ITEM(ratio, 1));
+    Py_DECREF(temp);
+    if (pyus_out == NULL)
+        goto error;
+    result = microseconds_to_delta(pyus_out);
+    Py_DECREF(pyus_out);
+ error:
+    Py_XDECREF(pyus_in);
+    Py_XDECREF(ratio);
+
+    return result;
+}
+
+static PyObject *
 divide_timedelta_int(PyDateTime_Delta *delta, PyObject *intobj)
 {
     PyObject *pyus_in;
@@ -1712,6 +1765,55 @@
 }
 
 static PyObject *
+truedivide_timedelta_float(PyDateTime_Delta *delta, PyObject *f)
+{
+    PyObject *result = NULL;
+    PyObject *pyus_in = NULL, *temp, *pyus_out;
+    PyObject *ratio = NULL;
+
+    pyus_in = delta_to_microseconds(delta);
+    if (pyus_in == NULL)
+        return NULL;
+    ratio = PyObject_CallMethod(f, "as_integer_ratio", NULL);
+    if (ratio == NULL)
+        goto error;
+    temp = PyNumber_Multiply(pyus_in, PyTuple_GET_ITEM(ratio, 1));
+    Py_DECREF(pyus_in);
+    pyus_in = NULL;
+    if (temp == NULL)
+        goto error;
+    pyus_out = divide_nearest(temp, PyTuple_GET_ITEM(ratio, 0));
+    Py_DECREF(temp);
+    if (pyus_out == NULL)
+        goto error;
+    result = microseconds_to_delta(pyus_out);
+    Py_DECREF(pyus_out);
+ error:
+    Py_XDECREF(pyus_in);
+    Py_XDECREF(ratio);
+
+    return result;
+}
+
+static PyObject *
+truedivide_timedelta_int(PyDateTime_Delta *delta, PyObject *i)
+{
+    PyObject *result;
+    PyObject *pyus_in, *pyus_out;
+    pyus_in = delta_to_microseconds(delta);
+    if (pyus_in == NULL)
+        return NULL;
+    pyus_out = divide_nearest(pyus_in, i);
+    Py_DECREF(pyus_in);
+    if (pyus_out == NULL)
+        return NULL;
+    result = microseconds_to_delta(pyus_out);
+    Py_DECREF(pyus_out);
+
+    return result;
+}
+
+static PyObject *
 delta_add(PyObject *left, PyObject *right)
 {
     PyObject *result = Py_NotImplemented;
@@ -1835,10 +1937,16 @@
         if (PyLong_Check(right))
             result = multiply_int_timedelta(right,
                             (PyDateTime_Delta *) left);
+        else if (PyFloat_Check(right))
+            result = multiply_float_timedelta(right,
+                            (PyDateTime_Delta *) left);
     }
     else if (PyLong_Check(left))
         result = multiply_int_timedelta(left,
-                                        (PyDateTime_Delta *) right);
+                        (PyDateTime_Delta *) right);
+    else if (PyFloat_Check(left))
+        result = multiply_float_timedelta(left,
+                        (PyDateTime_Delta *) right);
 
     if (result == Py_NotImplemented)
         Py_INCREF(result);
@@ -1877,6 +1985,12 @@
             result = truedivide_timedelta_timedelta(
                             (PyDateTime_Delta *)left,
                             (PyDateTime_Delta *)right);
+        else if (PyFloat_Check(right))
+            result = truedivide_timedelta_float(
+                            (PyDateTime_Delta *)left, right);
+        else if (PyLong_Check(right))
+            result = truedivide_timedelta_int(
+                            (PyDateTime_Delta *)left, right);
     }
 
     if (result == Py_NotImplemented)
@@ -3109,8 +3223,8 @@
      PyDoc_STR("datetime -> string name of time zone.")},
 
     {"utcoffset",       (PyCFunction)tzinfo_utcoffset,          METH_O,
-     PyDoc_STR("datetime -> minutes east of UTC (negative for "
-               "west of UTC).")},
+     PyDoc_STR("datetime -> timedelta showing offset from UTC, negative "
+           "values indicating West of UTC")},
 
     {"dst",             (PyCFunction)tzinfo_dst,                METH_O,
      PyDoc_STR("datetime -> DST offset in minutes east of UTC.")},

Modified: python/branches/py3k-cdecimal/Modules/main.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/main.c	(original)
+++ python/branches/py3k-cdecimal/Modules/main.c	Mon Jun  7 12:46:02 2010
@@ -425,7 +425,7 @@
 #else
     if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') {
         char *buf, *oldloc;
-        wchar_t *warning;
+        PyObject *warning;
 
         /* settle for strtok here as there's no one standard
            C89 wcstok */
@@ -437,9 +437,10 @@
         oldloc = strdup(setlocale(LC_ALL, NULL));
         setlocale(LC_ALL, "");
         for (p = strtok(buf, ","); p != NULL; p = strtok(NULL, ",")) {
-            if ((warning = _Py_char2wchar(p)) != NULL) {
-                PySys_AddWarnOption(warning);
-                PyMem_Free(warning);
+            warning = PyUnicode_DecodeFSDefault(p);
+            if (warning != NULL) {
+                PySys_AddWarnOptionUnicode(warning);
+                Py_DECREF(warning);
             }
         }
         setlocale(LC_ALL, oldloc);

Modified: python/branches/py3k-cdecimal/Modules/timemodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/timemodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/timemodule.c	Mon Jun  7 12:46:02 2010
@@ -208,21 +208,27 @@
 a floating point number for subsecond precision.");
 
 static PyStructSequence_Field struct_time_type_fields[] = {
-    {"tm_year", NULL},
-    {"tm_mon", NULL},
-    {"tm_mday", NULL},
-    {"tm_hour", NULL},
-    {"tm_min", NULL},
-    {"tm_sec", NULL},
-    {"tm_wday", NULL},
-    {"tm_yday", NULL},
-    {"tm_isdst", NULL},
+    {"tm_year", "year, for example, 1993"},
+    {"tm_mon", "month of year, range [1, 12]"},
+    {"tm_mday", "day of month, range [1, 31]"},
+    {"tm_hour", "hours, range [0, 23]"},
+    {"tm_min", "minutes, range [0, 59]"},
+    {"tm_sec", "seconds, range [0, 61])"},
+    {"tm_wday", "day of week, range [0, 6], Monday is 0"},
+    {"tm_yday", "day of year, range [1, 366]"},
+    {"tm_isdst", "1 if summer time is in effect, 0 if not, and -1 if unknown"},
     {0}
 };
 
 static PyStructSequence_Desc struct_time_type_desc = {
     "time.struct_time",
-    NULL,
+    "The time value as returned by gmtime(), localtime(), and strptime(), and\n"
+    " accepted by asctime(), mktime() and strftime().  May be considered as a\n"
+    " sequence of 9 integers.\n\n"
+    " Note that several fields' values are not the same as those defined by\n"
+    " the C language standard for struct tm.  For example, the value of the\n"
+    " field tm_year is the actual year, not year - 1900.  See individual\n"
+    " fields' descriptions for details.",
     struct_time_type_fields,
     9,
 };

Modified: python/branches/py3k-cdecimal/Objects/abstract.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/abstract.c	(original)
+++ python/branches/py3k-cdecimal/Objects/abstract.c	Mon Jun  7 12:46:02 2010
@@ -693,48 +693,37 @@
 PyObject *
 PyObject_Format(PyObject *obj, PyObject *format_spec)
 {
-    static PyObject * str__format__ = NULL;
     PyObject *meth;
     PyObject *empty = NULL;
     PyObject *result = NULL;
-
-    /* Initialize cached value */
-    if (str__format__ == NULL) {
-    /* Initialize static variable needed by _PyType_Lookup */
-    str__format__ = PyUnicode_FromString("__format__");
-    if (str__format__ == NULL)
-        goto done;
-    }
+    static PyObject *format_cache = NULL;
 
     /* If no format_spec is provided, use an empty string */
     if (format_spec == NULL) {
-    empty = PyUnicode_FromUnicode(NULL, 0);
-    format_spec = empty;
+        empty = PyUnicode_FromUnicode(NULL, 0);
+        format_spec = empty;
     }
 
-    /* Make sure the type is initialized.  float gets initialized late */
-    if (Py_TYPE(obj)->tp_dict == NULL)
-    if (PyType_Ready(Py_TYPE(obj)) < 0)
-        goto done;
-
     /* Find the (unbound!) __format__ method (a borrowed reference) */
-    meth = _PyType_Lookup(Py_TYPE(obj), str__format__);
+    meth = _PyObject_LookupSpecial(obj, "__format__", &format_cache);
     if (meth == NULL) {
-    PyErr_Format(PyExc_TypeError,
-        "Type %.100s doesn't define __format__",
-        Py_TYPE(obj)->tp_name);
+        if (!PyErr_Occurred())
+            PyErr_Format(PyExc_TypeError,
+                         "Type %.100s doesn't define __format__",
+                         Py_TYPE(obj)->tp_name);
         goto done;
     }
 
-    /* And call it, binding it to the value */
-    result = PyObject_CallFunctionObjArgs(meth, obj, format_spec, NULL);
+    /* And call it. */
+    result = PyObject_CallFunctionObjArgs(meth, format_spec, NULL);
+    Py_DECREF(meth);
 
     if (result && !PyUnicode_Check(result)) {
-    PyErr_SetString(PyExc_TypeError,
-        "__format__ method did not return string");
-    Py_DECREF(result);
-    result = NULL;
-    goto done;
+        PyErr_SetString(PyExc_TypeError,
+                        "__format__ method did not return string");
+        Py_DECREF(result);
+        result = NULL;
+        goto done;
     }
 
 done:

Modified: python/branches/py3k-cdecimal/Objects/complexobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/complexobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/complexobject.c	Mon Jun  7 12:46:02 2010
@@ -403,12 +403,12 @@
 static long
 complex_hash(PyComplexObject *v)
 {
-    long hashreal, hashimag, combined;
-    hashreal = _Py_HashDouble(v->cval.real);
-    if (hashreal == -1)
+    unsigned long hashreal, hashimag, combined;
+    hashreal = (unsigned long)_Py_HashDouble(v->cval.real);
+    if (hashreal == (unsigned long)-1)
         return -1;
-    hashimag = _Py_HashDouble(v->cval.imag);
-    if (hashimag == -1)
+    hashimag = (unsigned long)_Py_HashDouble(v->cval.imag);
+    if (hashimag == (unsigned long)-1)
         return -1;
     /* Note:  if the imaginary part is 0, hashimag is 0 now,
      * so the following returns hashreal unchanged.  This is
@@ -416,10 +416,10 @@
      * compare equal must have the same hash value, so that
      * hash(x + 0*j) must equal hash(x).
      */
-    combined = hashreal + 1000003 * hashimag;
-    if (combined == -1)
-        combined = -2;
-    return combined;
+    combined = hashreal + _PyHASH_IMAG * hashimag;
+    if (combined == (unsigned long)-1)
+        combined = (unsigned long)-2;
+    return (long)combined;
 }
 
 /* This macro may return! */
@@ -620,22 +620,58 @@
 complex_richcompare(PyObject *v, PyObject *w, int op)
 {
     PyObject *res;
-    Py_complex i, j;
-    TO_COMPLEX(v, i);
-    TO_COMPLEX(w, j);
+    Py_complex i;
+    int equal;
 
     if (op != Py_EQ && op != Py_NE) {
-        Py_INCREF(Py_NotImplemented);
-        return Py_NotImplemented;
+        goto Unimplemented;
+    }
+
+    assert(PyComplex_Check(v));
+    TO_COMPLEX(v, i);
+
+    if (PyLong_Check(w)) {
+        /* Check for 0.0 imaginary part first to avoid the rich
+         * comparison when possible.
+         */
+        if (i.imag == 0.0) {
+            PyObject *j, *sub_res;
+            j = PyFloat_FromDouble(i.real);
+            if (j == NULL)
+                return NULL;
+
+            sub_res = PyObject_RichCompare(j, w, op);
+            Py_DECREF(j);
+            return sub_res;
+        }
+        else {
+            equal = 0;
+        }
     }
+    else if (PyFloat_Check(w)) {
+        equal = (i.real == PyFloat_AsDouble(w) && i.imag == 0.0);
+    }
+    else if (PyComplex_Check(w)) {
+        Py_complex j;
 
-    if ((i.real == j.real && i.imag == j.imag) == (op == Py_EQ))
-        res = Py_True;
+        TO_COMPLEX(w, j);
+        equal = (i.real == j.real && i.imag == j.imag);
+    }
+    else {
+        goto Unimplemented;
+    }
+
+    if (equal == (op == Py_EQ))
+         res = Py_True;
     else
-        res = Py_False;
+         res = Py_False;
 
     Py_INCREF(res);
     return res;
+
+Unimplemented:
+    Py_INCREF(Py_NotImplemented);
+    return Py_NotImplemented;
 }
 
 static PyObject *

Modified: python/branches/py3k-cdecimal/Objects/longobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/longobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/longobject.c	Mon Jun  7 12:46:02 2010
@@ -2571,18 +2571,37 @@
         sign = -1;
         i = -(i);
     }
-    /* The following loop produces a C unsigned long x such that x is
-       congruent to the absolute value of v modulo ULONG_MAX.  The
-       resulting x is nonzero if and only if v is. */
     while (--i >= 0) {
-        /* Force a native long #-bits (32 or 64) circular shift */
-        x = (x >> (8*SIZEOF_LONG-PyLong_SHIFT)) | (x << PyLong_SHIFT);
+        /* Here x is a quantity in the range [0, _PyHASH_MODULUS); we
+           want to compute x * 2**PyLong_SHIFT + v->ob_digit[i] modulo
+           _PyHASH_MODULUS.
+
+           The computation of x * 2**PyLong_SHIFT % _PyHASH_MODULUS
+           amounts to a rotation of the bits of x.  To see this, write
+
+             x * 2**PyLong_SHIFT = y * 2**_PyHASH_BITS + z
+
+           where y = x >> (_PyHASH_BITS - PyLong_SHIFT) gives the top
+           PyLong_SHIFT bits of x (those that are shifted out of the
+           original _PyHASH_BITS bits, and z = (x << PyLong_SHIFT) &
+           _PyHASH_MODULUS gives the bottom _PyHASH_BITS - PyLong_SHIFT
+           bits of x, shifted up.  Then since 2**_PyHASH_BITS is
+           congruent to 1 modulo _PyHASH_MODULUS, y*2**_PyHASH_BITS is
+           congruent to y modulo _PyHASH_MODULUS.  So
+
+             x * 2**PyLong_SHIFT = y + z (mod _PyHASH_MODULUS).
+
+           The right-hand side is just the result of rotating the
+           _PyHASH_BITS bits of x left by PyLong_SHIFT places; since
+           not all _PyHASH_BITS bits of x are 1s, the same is true
+           after rotation, so 0 <= y+z < _PyHASH_MODULUS and y + z is
+           the reduction of x*2**PyLong_SHIFT modulo
+           _PyHASH_MODULUS. */
+        x = ((x << PyLong_SHIFT) & _PyHASH_MODULUS) |
+            (x >> (_PyHASH_BITS - PyLong_SHIFT));
         x += v->ob_digit[i];
-        /* If the addition above overflowed we compensate by
-           incrementing.  This preserves the value modulo
-           ULONG_MAX. */
-        if (x < v->ob_digit[i])
-            x++;
+        if (x >= _PyHASH_MODULUS)
+            x -= _PyHASH_MODULUS;
     }
     x = x * sign;
     if (x == (unsigned long)-1)
@@ -4079,23 +4098,34 @@
 static PyObject *
 long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-    PyObject *x = NULL;
-    int base = -909;                         /* unlikely! */
+    PyObject *obase = NULL, *x = NULL;
+    long base;
+    int overflow;
     static char *kwlist[] = {"x", "base", 0};
 
     if (type != &PyLong_Type)
         return long_subtype_new(type, args, kwds); /* Wimp out */
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:int", kwlist,
-                                     &x, &base))
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:int", kwlist,
+                                     &x, &obase))
         return NULL;
     if (x == NULL)
         return PyLong_FromLong(0L);
-    if (base == -909)
+    if (obase == NULL)
         return PyNumber_Long(x);
-    else if (PyUnicode_Check(x))
+
+    base = PyLong_AsLongAndOverflow(obase, &overflow);
+    if (base == -1 && PyErr_Occurred())
+        return NULL;
+    if (overflow || (base != 0 && base < 2) || base > 36) {
+        PyErr_SetString(PyExc_ValueError,
+                        "int() arg 2 must be >= 2 and <= 36");
+        return NULL;
+    }
+
+    if (PyUnicode_Check(x))
         return PyLong_FromUnicode(PyUnicode_AS_UNICODE(x),
                                   PyUnicode_GET_SIZE(x),
-                                  base);
+                                  (int)base);
     else if (PyByteArray_Check(x) || PyBytes_Check(x)) {
         /* Since PyLong_FromString doesn't have a length parameter,
          * check here for possible NULs in the string. */
@@ -4110,10 +4140,10 @@
                x is a bytes or buffer, *and* a base is given. */
             PyErr_Format(PyExc_ValueError,
                          "invalid literal for int() with base %d: %R",
-                         base, x);
+                         (int)base, x);
             return NULL;
         }
-        return PyLong_FromString(string, NULL, base);
+        return PyLong_FromString(string, NULL, (int)base);
     }
     else {
         PyErr_SetString(PyExc_TypeError,
@@ -4182,140 +4212,169 @@
                                   PyUnicode_GET_SIZE(format_spec));
 }
 
+/* Return a pair (q, r) such that a = b * q + r, and
+   abs(r) <= abs(b)/2, with equality possible only if q is even.
+   In other words, q == a / b, rounded to the nearest integer using
+   round-half-to-even. */
+
+PyObject *
+_PyLong_Divmod_Near(PyObject *a, PyObject *b)
+{
+    PyLongObject *quo = NULL, *rem = NULL;
+    PyObject *one = NULL, *twice_rem, *result, *temp;
+    int cmp, quo_is_odd, quo_is_neg;
+
+    /* Equivalent Python code:
+
+       def divmod_near(a, b):
+           q, r = divmod(a, b)
+           # round up if either r / b > 0.5, or r / b == 0.5 and q is odd.
+           # The expression r / b > 0.5 is equivalent to 2 * r > b if b is
+           # positive, 2 * r < b if b negative.
+           greater_than_half = 2*r > b if b > 0 else 2*r < b
+           exactly_half = 2*r == b
+           if greater_than_half or exactly_half and q % 2 == 1:
+               q += 1
+               r -= b
+           return q, r
+
+    */
+    if (!PyLong_Check(a) || !PyLong_Check(b)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "non-integer arguments in division");
+        return NULL;
+    }
+
+    /* Do a and b have different signs?  If so, quotient is negative. */
+    quo_is_neg = (Py_SIZE(a) < 0) != (Py_SIZE(b) < 0);
+
+    one = PyLong_FromLong(1L);
+    if (one == NULL)
+        return NULL;
+
+    if (long_divrem((PyLongObject*)a, (PyLongObject*)b, &quo, &rem) < 0)
+        goto error;
+
+    /* compare twice the remainder with the divisor, to see
+       if we need to adjust the quotient and remainder */
+    twice_rem = long_lshift((PyObject *)rem, one);
+    if (twice_rem == NULL)
+        goto error;
+    if (quo_is_neg) {
+        temp = long_neg((PyLongObject*)twice_rem);
+        Py_DECREF(twice_rem);
+        twice_rem = temp;
+        if (twice_rem == NULL)
+            goto error;
+    }
+    cmp = long_compare((PyLongObject *)twice_rem, (PyLongObject *)b);
+    Py_DECREF(twice_rem);
+
+    quo_is_odd = Py_SIZE(quo) != 0 && ((quo->ob_digit[0] & 1) != 0);
+    if ((Py_SIZE(b) < 0 ? cmp < 0 : cmp > 0) || (cmp == 0 && quo_is_odd)) {
+        /* fix up quotient */
+        if (quo_is_neg)
+            temp = long_sub(quo, (PyLongObject *)one);
+        else
+            temp = long_add(quo, (PyLongObject *)one);
+        Py_DECREF(quo);
+        quo = (PyLongObject *)temp;
+        if (quo == NULL)
+            goto error;
+        /* and remainder */
+        if (quo_is_neg)
+            temp = long_add(rem, (PyLongObject *)b);
+        else
+            temp = long_sub(rem, (PyLongObject *)b);
+        Py_DECREF(rem);
+        rem = (PyLongObject *)temp;
+        if (rem == NULL)
+            goto error;
+    }
+
+    result = PyTuple_New(2);
+    if (result == NULL)
+        goto error;
+
+    /* PyTuple_SET_ITEM steals references */
+    PyTuple_SET_ITEM(result, 0, (PyObject *)quo);
+    PyTuple_SET_ITEM(result, 1, (PyObject *)rem);
+    Py_DECREF(one);
+    return result;
+
+  error:
+    Py_XDECREF(quo);
+    Py_XDECREF(rem);
+    Py_XDECREF(one);
+    return NULL;
+}
+
 static PyObject *
 long_round(PyObject *self, PyObject *args)
 {
-    PyObject *o_ndigits=NULL, *temp;
-    PyLongObject *pow=NULL, *q=NULL, *r=NULL, *ndigits=NULL, *one;
-    int errcode;
-    digit q_mod_4;
-
-    /* Notes on the algorithm: to round to the nearest 10**n (n positive),
-       the straightforward method is:
-
-          (1) divide by 10**n
-          (2) round to nearest integer (round to even in case of tie)
-          (3) multiply result by 10**n.
-
-       But the rounding step involves examining the fractional part of the
-       quotient to see whether it's greater than 0.5 or not.  Since we
-       want to do the whole calculation in integer arithmetic, it's
-       simpler to do:
-
-          (1) divide by (10**n)/2
-          (2) round to nearest multiple of 2 (multiple of 4 in case of tie)
-          (3) multiply result by (10**n)/2.
-
-       Then all we need to know about the fractional part of the quotient
-       arising in step (2) is whether it's zero or not.
-
-       Doing both a multiplication and division is wasteful, and is easily
-       avoided if we just figure out how much to adjust the original input
-       by to do the rounding.
-
-       Here's the whole algorithm expressed in Python.
-
-        def round(self, ndigits = None):
-        """round(int, int) -> int"""
-        if ndigits is None or ndigits >= 0:
-            return self
-        pow = 10**-ndigits >> 1
-        q, r = divmod(self, pow)
-        self -= r
-        if (q & 1 != 0):
-            if (q & 2 == r == 0):
-            self -= pow
-            else:
-            self += pow
-        return self
+    PyObject *o_ndigits=NULL, *temp, *result, *ndigits;
 
-    */
+    /* To round an integer m to the nearest 10**n (n positive), we make use of
+     * the divmod_near operation, defined by:
+     *
+     *   divmod_near(a, b) = (q, r)
+     *
+     * where q is the nearest integer to the quotient a / b (the
+     * nearest even integer in the case of a tie) and r == a - q * b.
+     * Hence q * b = a - r is the nearest multiple of b to a,
+     * preferring even multiples in the case of a tie.
+     *
+     * So the nearest multiple of 10**n to m is:
+     *
+     *   m - divmod_near(m, 10**n)[1].
+     */
     if (!PyArg_ParseTuple(args, "|O", &o_ndigits))
         return NULL;
     if (o_ndigits == NULL)
         return long_long(self);
 
-    ndigits = (PyLongObject *)PyNumber_Index(o_ndigits);
+    ndigits = PyNumber_Index(o_ndigits);
     if (ndigits == NULL)
         return NULL;
 
+    /* if ndigits >= 0 then no rounding is necessary; return self unchanged */
     if (Py_SIZE(ndigits) >= 0) {
         Py_DECREF(ndigits);
         return long_long(self);
     }
 
-    Py_INCREF(self); /* to keep refcounting simple */
-    /* we now own references to self, ndigits */
-
-    /* pow = 10 ** -ndigits >> 1 */
-    pow = (PyLongObject *)PyLong_FromLong(10L);
-    if (pow == NULL)
-        goto error;
-    temp = long_neg(ndigits);
+    /* result = self - divmod_near(self, 10 ** -ndigits)[1] */
+    temp = long_neg((PyLongObject*)ndigits);
     Py_DECREF(ndigits);
-    ndigits = (PyLongObject *)temp;
+    ndigits = temp;
     if (ndigits == NULL)
-        goto error;
-    temp = long_pow((PyObject *)pow, (PyObject *)ndigits, Py_None);
-    Py_DECREF(pow);
-    pow = (PyLongObject *)temp;
-    if (pow == NULL)
-        goto error;
-    assert(PyLong_Check(pow)); /* check long_pow returned a long */
-    one = (PyLongObject *)PyLong_FromLong(1L);
-    if (one == NULL)
-        goto error;
-    temp = long_rshift(pow, one);
-    Py_DECREF(one);
-    Py_DECREF(pow);
-    pow = (PyLongObject *)temp;
-    if (pow == NULL)
-        goto error;
+        return NULL;
 
-    /* q, r = divmod(self, pow) */
-    errcode = l_divmod((PyLongObject *)self, pow, &q, &r);
-    if (errcode == -1)
-        goto error;
+    result = PyLong_FromLong(10L);
+    if (result == NULL) {
+        Py_DECREF(ndigits);
+        return NULL;
+    }
 
-    /* self -= r */
-    temp = long_sub((PyLongObject *)self, r);
-    Py_DECREF(self);
-    self = temp;
-    if (self == NULL)
-        goto error;
+    temp = long_pow(result, ndigits, Py_None);
+    Py_DECREF(ndigits);
+    Py_DECREF(result);
+    result = temp;
+    if (result == NULL)
+        return NULL;
 
-    /* get value of quotient modulo 4 */
-    if (Py_SIZE(q) == 0)
-        q_mod_4 = 0;
-    else if (Py_SIZE(q) > 0)
-        q_mod_4 = q->ob_digit[0] & 3;
-    else
-        q_mod_4 = (PyLong_BASE-q->ob_digit[0]) & 3;
+    temp = _PyLong_Divmod_Near(self, result);
+    Py_DECREF(result);
+    result = temp;
+    if (result == NULL)
+        return NULL;
 
-    if ((q_mod_4 & 1) == 1) {
-        /* q is odd; round self up or down by adding or subtracting pow */
-        if (q_mod_4 == 1 && Py_SIZE(r) == 0)
-            temp = (PyObject *)long_sub((PyLongObject *)self, pow);
-        else
-            temp = (PyObject *)long_add((PyLongObject *)self, pow);
-        Py_DECREF(self);
-        self = temp;
-        if (self == NULL)
-            goto error;
-    }
-    Py_DECREF(q);
-    Py_DECREF(r);
-    Py_DECREF(pow);
-    Py_DECREF(ndigits);
-    return self;
+    temp = long_sub((PyLongObject *)self,
+                    (PyLongObject *)PyTuple_GET_ITEM(result, 1));
+    Py_DECREF(result);
+    result = temp;
 
-  error:
-    Py_XDECREF(q);
-    Py_XDECREF(r);
-    Py_XDECREF(pow);
-    Py_XDECREF(self);
-    Py_XDECREF(ndigits);
-    return NULL;
+    return result;
 }
 
 static PyObject *

Modified: python/branches/py3k-cdecimal/Objects/object.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/object.c	(original)
+++ python/branches/py3k-cdecimal/Objects/object.c	Mon Jun  7 12:46:02 2010
@@ -647,63 +647,101 @@
    All the utility functions (_Py_Hash*()) return "-1" to signify an error.
 */
 
+/* For numeric types, the hash of a number x is based on the reduction
+   of x modulo the prime P = 2**_PyHASH_BITS - 1.  It's designed so that
+   hash(x) == hash(y) whenever x and y are numerically equal, even if
+   x and y have different types.
+
+   A quick summary of the hashing strategy:
+
+   (1) First define the 'reduction of x modulo P' for any rational
+   number x; this is a standard extension of the usual notion of
+   reduction modulo P for integers.  If x == p/q (written in lowest
+   terms), the reduction is interpreted as the reduction of p times
+   the inverse of the reduction of q, all modulo P; if q is exactly
+   divisible by P then define the reduction to be infinity.  So we've
+   got a well-defined map
+
+      reduce : { rational numbers } -> { 0, 1, 2, ..., P-1, infinity }.
+
+   (2) Now for a rational number x, define hash(x) by:
+
+      reduce(x)   if x >= 0
+      -reduce(-x) if x < 0
+
+   If the result of the reduction is infinity (this is impossible for
+   integers, floats and Decimals) then use the predefined hash value
+   _PyHASH_INF for x >= 0, or -_PyHASH_INF for x < 0, instead.
+   _PyHASH_INF, -_PyHASH_INF and _PyHASH_NAN are also used for the
+   hashes of float and Decimal infinities and nans.
+
+   A selling point for the above strategy is that it makes it possible
+   to compute hashes of decimal and binary floating-point numbers
+   efficiently, even if the exponent of the binary or decimal number
+   is large.  The key point is that
+
+      reduce(x * y) == reduce(x) * reduce(y) (modulo _PyHASH_MODULUS)
+
+   provided that {reduce(x), reduce(y)} != {0, infinity}.  The reduction of a
+   binary or decimal float is never infinity, since the denominator is a power
+   of 2 (for binary) or a divisor of a power of 10 (for decimal).  So we have,
+   for nonnegative x,
+
+      reduce(x * 2**e) == reduce(x) * reduce(2**e) % _PyHASH_MODULUS
+
+      reduce(x * 10**e) == reduce(x) * reduce(10**e) % _PyHASH_MODULUS
+
+   and reduce(10**e) can be computed efficiently by the usual modular
+   exponentiation algorithm.  For reduce(2**e) it's even better: since
+   P is of the form 2**n-1, reduce(2**e) is 2**(e mod n), and multiplication
+   by 2**(e mod n) modulo 2**n-1 just amounts to a rotation of bits.
+
+   */
+
 long
 _Py_HashDouble(double v)
 {
-    double intpart, fractpart;
-    int expo;
-    long hipart;
-    long x;             /* the final hash value */
-    /* This is designed so that Python numbers of different types
-     * that compare equal hash to the same value; otherwise comparisons
-     * of mapping keys will turn out weird.
-     */
+    int e, sign;
+    double m;
+    unsigned long x, y;
 
     if (!Py_IS_FINITE(v)) {
         if (Py_IS_INFINITY(v))
-            return v < 0 ? -271828 : 314159;
+            return v > 0 ? _PyHASH_INF : -_PyHASH_INF;
         else
-            return 0;
+            return _PyHASH_NAN;
     }
-    fractpart = modf(v, &intpart);
-    if (fractpart == 0.0) {
-        /* This must return the same hash as an equal int or long. */
-        if (intpart > LONG_MAX/2 || -intpart > LONG_MAX/2) {
-            /* Convert to long and use its hash. */
-            PyObject *plong;                    /* converted to Python long */
-            plong = PyLong_FromDouble(v);
-            if (plong == NULL)
-                return -1;
-            x = PyObject_Hash(plong);
-            Py_DECREF(plong);
-            return x;
-        }
-        /* Fits in a C long == a Python int, so is its own hash. */
-        x = (long)intpart;
-        if (x == -1)
-            x = -2;
-        return x;
-    }
-    /* The fractional part is non-zero, so we don't have to worry about
-     * making this match the hash of some other type.
-     * Use frexp to get at the bits in the double.
-     * Since the VAX D double format has 56 mantissa bits, which is the
-     * most of any double format in use, each of these parts may have as
-     * many as (but no more than) 56 significant bits.
-     * So, assuming sizeof(long) >= 4, each part can be broken into two
-     * longs; frexp and multiplication are used to do that.
-     * Also, since the Cray double format has 15 exponent bits, which is
-     * the most of any double format in use, shifting the exponent field
-     * left by 15 won't overflow a long (again assuming sizeof(long) >= 4).
-     */
-    v = frexp(v, &expo);
-    v *= 2147483648.0;          /* 2**31 */
-    hipart = (long)v;           /* take the top 32 bits */
-    v = (v - (double)hipart) * 2147483648.0; /* get the next 32 bits */
-    x = hipart + (long)v + (expo << 15);
-    if (x == -1)
-        x = -2;
-    return x;
+
+    m = frexp(v, &e);
+
+    sign = 1;
+    if (m < 0) {
+        sign = -1;
+        m = -m;
+    }
+
+    /* process 28 bits at a time;  this should work well both for binary
+       and hexadecimal floating point. */
+    x = 0;
+    while (m) {
+        x = ((x << 28) & _PyHASH_MODULUS) | x >> (_PyHASH_BITS - 28);
+        m *= 268435456.0;  /* 2**28 */
+        e -= 28;
+        y = (unsigned long)m;  /* pull out integer part */
+        m -= y;
+        x += y;
+        if (x >= _PyHASH_MODULUS)
+            x -= _PyHASH_MODULUS;
+    }
+
+    /* adjust for the exponent;  first reduce it modulo _PyHASH_BITS */
+    e = e >= 0 ? e % _PyHASH_BITS : _PyHASH_BITS-1-((-1-e) % _PyHASH_BITS);
+    x = ((x << e) & _PyHASH_MODULUS) | x >> (_PyHASH_BITS - e);
+
+    x = x * sign;
+    if (x == (unsigned long)-1)
+        x = (unsigned long)-2;
+    return (long)x;
 }
 
 long
@@ -950,31 +988,7 @@
             goto done;
     }
 
-#if 0 /* XXX this is not quite _PyType_Lookup anymore */
-    /* Inline _PyType_Lookup */
-    {
-        Py_ssize_t i, n;
-        PyObject *mro, *base, *dict;
-
-        /* Look in tp_dict of types in MRO */
-        mro = tp->tp_mro;
-        assert(mro != NULL);
-        assert(PyTuple_Check(mro));
-        n = PyTuple_GET_SIZE(mro);
-        for (i = 0; i < n; i++) {
-            base = PyTuple_GET_ITEM(mro, i);
-            assert(PyType_Check(base));
-            dict = ((PyTypeObject *)base)->tp_dict;
-            assert(dict && PyDict_Check(dict));
-            descr = PyDict_GetItem(dict, name);
-            if (descr != NULL)
-                break;
-        }
-    }
-#else
     descr = _PyType_Lookup(tp, name);
-#endif
-
     Py_XINCREF(descr);
 
     f = NULL;

Modified: python/branches/py3k-cdecimal/Objects/typeobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/typeobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/typeobject.c	Mon Jun  7 12:46:02 2010
@@ -3310,23 +3310,15 @@
     PyObject *format_spec;
     PyObject *self_as_str = NULL;
     PyObject *result = NULL;
-    PyObject *format_meth = NULL;
 
     if (!PyArg_ParseTuple(args, "U:__format__", &format_spec))
         return NULL;
 
     self_as_str = PyObject_Str(self);
-    if (self_as_str != NULL) {
-        /* find the format function */
-        format_meth = PyObject_GetAttrString(self_as_str, "__format__");
-        if (format_meth != NULL) {
-               /* and call it */
-            result = PyObject_CallFunctionObjArgs(format_meth, format_spec, NULL);
-        }
-    }
+    if (self_as_str != NULL)
+        result = PyObject_Format(self_as_str, format_spec);
 
     Py_XDECREF(self_as_str);
-    Py_XDECREF(format_meth);
 
     return result;
 }
@@ -4921,6 +4913,7 @@
     PyObject *func, *res;
     static PyObject *hash_str;
     long h;
+    int overflow;
 
     func = lookup_method(self, "__hash__", &hash_str);
 
@@ -4937,14 +4930,27 @@
     Py_DECREF(func);
     if (res == NULL)
         return -1;
-    if (PyLong_Check(res))
+
+    if (!PyLong_Check(res)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "__hash__ method should return an integer");
+        return -1;
+    }
+    /* Transform the PyLong `res` to a C long `h`.  For an existing
+       hashable Python object x, hash(x) will always lie within the range
+       of a C long.  Therefore our transformation must preserve values
+       that already lie within this range, to ensure that if x.__hash__()
+       returns hash(y) then hash(x) == hash(y). */
+    h = PyLong_AsLongAndOverflow(res, &overflow);
+    if (overflow)
+        /* res was not within the range of a C long, so we're free to
+           use any sufficiently bit-mixing transformation;
+           long.__hash__ will do nicely. */
         h = PyLong_Type.tp_hash(res);
-    else
-        h = PyLong_AsLong(res);
     Py_DECREF(res);
-           if (h == -1 && !PyErr_Occurred())
-           h = -2;
-           return h;
+    if (h == -1 && !PyErr_Occurred())
+        h = -2;
+    return h;
 }
 
 static PyObject *

Modified: python/branches/py3k-cdecimal/PC/winreg.c
==============================================================================
--- python/branches/py3k-cdecimal/PC/winreg.c	(original)
+++ python/branches/py3k-cdecimal/PC/winreg.c	Mon Jun  7 12:46:02 2010
@@ -1096,7 +1096,14 @@
     int index;
     long rc;
     PyObject *retStr;
-    wchar_t tmpbuf[256]; /* max key name length is 255 */
+
+    /* The Windows docs claim that the max key name length is 255
+     * characters, plus a terminating nul character.  However,
+     * empirical testing demonstrates that it is possible to
+     * create a 256 character key that is missing the terminating
+     * nul.  RegEnumKeyEx requires a 257 character buffer to
+     * retrieve such a key name. */
+    wchar_t tmpbuf[257];
     DWORD len = sizeof(tmpbuf); /* includes NULL terminator */
 
     if (!PyArg_ParseTuple(args, "Oi:EnumKey", &obKey, &index))
@@ -1123,8 +1130,8 @@
     long rc;
     wchar_t *retValueBuf;
     BYTE *retDataBuf;
-    DWORD retValueSize;
-    DWORD retDataSize;
+    DWORD retValueSize, bufValueSize;
+    DWORD retDataSize, bufDataSize;
     DWORD typ;
     PyObject *obData;
     PyObject *retVal;
@@ -1142,6 +1149,8 @@
                                                    "RegQueryInfoKey");
     ++retValueSize;    /* include null terminators */
     ++retDataSize;
+    bufDataSize = retDataSize;
+    bufValueSize = retValueSize;
     retValueBuf = (wchar_t *)PyMem_Malloc(sizeof(wchar_t) * retValueSize);
     if (retValueBuf == NULL)
         return PyErr_NoMemory();
@@ -1151,16 +1160,33 @@
         return PyErr_NoMemory();
     }
 
-    Py_BEGIN_ALLOW_THREADS
-    rc = RegEnumValueW(hKey,
-                      index,
-                      retValueBuf,
-                      &retValueSize,
-                      NULL,
-                      &typ,
-                      retDataBuf,
-                      &retDataSize);
-    Py_END_ALLOW_THREADS
+    while (1) {
+        wchar_t *tmp;
+        Py_BEGIN_ALLOW_THREADS
+        rc = RegEnumValueW(hKey,
+                  index,
+                  retValueBuf,
+                  &retValueSize,
+                  NULL,
+                  &typ,
+                  (BYTE *)retDataBuf,
+                  &retDataSize);
+        Py_END_ALLOW_THREADS
+
+        if (rc != ERROR_MORE_DATA)
+            break;
+
+        bufDataSize *= 2;
+        tmp = (char *)PyMem_Realloc(retDataBuf, bufDataSize);
+        if (tmp == NULL) {
+            PyErr_NoMemory();
+            retVal = NULL;
+            goto fail;
+        }
+        retDataBuf = tmp;
+        retDataSize = bufDataSize;
+        retValueSize = bufValueSize;
+    }
 
     if (rc != ERROR_SUCCESS) {
         retVal = PyErr_SetFromWindowsErrWithFunction(rc,
@@ -1317,23 +1343,44 @@
     long rc;
     PyObject *retStr;
     wchar_t *retBuf;
-    long bufSize = 0;
+    DWORD bufSize = 0;
+    DWORD retSize = 0;
+    wchar_t *tmp;
 
     if (!PyArg_ParseTuple(args, "OZ:QueryValue", &obKey, &subKey))
         return NULL;
 
     if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
         return NULL;
-    if ((rc = RegQueryValueW(hKey, subKey, NULL, &bufSize))
-        != ERROR_SUCCESS)
+
+    rc = RegQueryValueW(hKey, subKey, NULL, &retSize);
+    if (rc == ERROR_MORE_DATA)
+        retSize = 256;
+    else if (rc != ERROR_SUCCESS)
         return PyErr_SetFromWindowsErrWithFunction(rc,
                                                    "RegQueryValue");
-    retBuf = (wchar_t *)PyMem_Malloc(bufSize);
+
+    bufSize = retSize;
+    retBuf = (wchar_t *) PyMem_Malloc(bufSize);
     if (retBuf == NULL)
         return PyErr_NoMemory();
 
-    if ((rc = RegQueryValueW(hKey, subKey, retBuf, &bufSize))
-        != ERROR_SUCCESS) {
+    while (1) {
+        retSize = bufSize;
+        rc = RegQueryValueW(hKey, subKey, retBuf, &retSize);
+        if (rc != ERROR_MORE_DATA)
+            break;
+
+        bufSize *= 2;
+        tmp = (wchar_t *) PyMem_Realloc(retBuf, bufSize);
+        if (tmp == NULL) {
+            PyMem_Free(retBuf);
+            return PyErr_NoMemory();
+        }
+        retBuf = tmp;
+    }
+
+    if (rc != ERROR_SUCCESS) {
         PyMem_Free(retBuf);
         return PyErr_SetFromWindowsErrWithFunction(rc,
                                                    "RegQueryValue");
@@ -1352,8 +1399,8 @@
     wchar_t *valueName;
 
     long rc;
-    BYTE *retBuf;
-    DWORD bufSize = 0;
+    BYTE *retBuf, *tmp;
+    DWORD bufSize = 0, retSize;
     DWORD typ;
     PyObject *obData;
     PyObject *result;
@@ -1363,18 +1410,34 @@
 
     if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
         return NULL;
-    if ((rc = RegQueryValueExW(hKey, valueName,
-                              NULL, NULL, NULL,
-                              &bufSize))
-        != ERROR_SUCCESS)
+
+    rc = RegQueryValueExW(hKey, valueName, NULL, NULL, NULL, &bufSize);
+    if (rc == ERROR_MORE_DATA)
+        bufSize = 256;
+    else if (rc != ERROR_SUCCESS)
         return PyErr_SetFromWindowsErrWithFunction(rc,
                                                    "RegQueryValueEx");
     retBuf = (BYTE *)PyMem_Malloc(bufSize);
     if (retBuf == NULL)
         return PyErr_NoMemory();
-    if ((rc = RegQueryValueExW(hKey, valueName, NULL,
-                              &typ, retBuf, &bufSize))
-        != ERROR_SUCCESS) {
+
+    while (1) {
+        retSize = bufSize;
+        rc = RegQueryValueExW(hKey, valueName, NULL, &typ,
+                             (BYTE *)retBuf, &retSize);
+        if (rc != ERROR_MORE_DATA)
+            break;
+
+        bufSize *= 2;
+        tmp = (char *) PyMem_Realloc(retBuf, bufSize);
+        if (tmp == NULL) {
+            PyMem_Free(retBuf);
+            return PyErr_NoMemory();
+        }
+       retBuf = tmp;
+    }
+
+    if (rc != ERROR_SUCCESS) {
         PyMem_Free(retBuf);
         return PyErr_SetFromWindowsErrWithFunction(rc,
                                                    "RegQueryValueEx");

Modified: python/branches/py3k-cdecimal/Python/_warnings.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/_warnings.c	(original)
+++ python/branches/py3k-cdecimal/Python/_warnings.c	Mon Jun  7 12:46:02 2010
@@ -116,7 +116,7 @@
         _filters = warnings_filters;
     }
 
-    if (!PyList_Check(_filters)) {
+    if (_filters == NULL || !PyList_Check(_filters)) {
         PyErr_SetString(PyExc_ValueError,
                         MODULE_NAME ".filters must be a list");
         return NULL;

Modified: python/branches/py3k-cdecimal/Python/ceval.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/ceval.c	(original)
+++ python/branches/py3k-cdecimal/Python/ceval.c	Mon Jun  7 12:46:02 2010
@@ -598,7 +598,7 @@
 } pendingcalls[NPENDINGCALLS];
 static volatile int pendingfirst = 0;
 static volatile int pendinglast = 0;
-static volatile int pendingcalls_to_do = 0;
+static _Py_atomic_int pendingcalls_to_do = {0};
 
 int
 Py_AddPendingCall(int (*func)(void *), void *arg)

Modified: python/branches/py3k-cdecimal/Python/getargs.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/getargs.c	(original)
+++ python/branches/py3k-cdecimal/Python/getargs.c	Mon Jun  7 12:46:02 2010
@@ -1029,18 +1029,7 @@
             else
                 return converterr("string or None",
                                   arg, msgbuf, bufsize);
-            if (*format == '#') {
-                FETCH_SIZE;
-                assert(0); /* XXX redundant with if-case */
-                if (arg == Py_None) {
-                    STORE_SIZE(0);
-                }
-                else {
-                    STORE_SIZE(PyBytes_Size(arg));
-                }
-                format++;
-            }
-            else if (*p != NULL && uarg != NULL &&
+            if (*p != NULL && uarg != NULL &&
                 (Py_ssize_t) strlen(*p) != PyBytes_GET_SIZE(uarg))
                 return converterr(
                     "string without null bytes or None",
@@ -1183,6 +1172,7 @@
                 *buffer = PyMem_NEW(char, size + 1);
                 if (*buffer == NULL) {
                     Py_DECREF(s);
+                    PyErr_NoMemory();
                     return converterr(
                         "(memory error)",
                         arg, msgbuf, bufsize);
@@ -1226,6 +1216,7 @@
             *buffer = PyMem_NEW(char, size + 1);
             if (*buffer == NULL) {
                 Py_DECREF(s);
+                PyErr_NoMemory();
                 return converterr("(memory error)",
                                   arg, msgbuf, bufsize);
             }
@@ -1293,17 +1284,6 @@
                 return converterr(type->tp_name, arg, msgbuf, bufsize);
 
         }
-        else if (*format == '?') {
-            inquiry pred = va_arg(*p_va, inquiry);
-            p = va_arg(*p_va, PyObject **);
-            format++;
-            if ((*pred)(arg))
-                *p = arg;
-            else
-                return converterr("(unspecified)",
-                                  arg, msgbuf, bufsize);
-
-        }
         else if (*format == '&') {
             typedef int (*converter)(PyObject *, void *);
             converter convert = va_arg(*p_va, converter);
@@ -1432,7 +1412,7 @@
 static Py_ssize_t
 convertbuffer(PyObject *arg, void **p, char **errmsg)
 {
-    PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
+    PyBufferProcs *pb = Py_TYPE(arg)->tp_as_buffer;
     Py_ssize_t count;
     Py_buffer view;
 
@@ -1460,31 +1440,23 @@
 static int
 getbuffer(PyObject *arg, Py_buffer *view, char **errmsg)
 {
-    void *buf;
-    Py_ssize_t count;
-    PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
+    PyBufferProcs *pb = Py_TYPE(arg)->tp_as_buffer;
     if (pb == NULL) {
         *errmsg = "bytes or buffer";
         return -1;
     }
-    if (pb->bf_getbuffer) {
-        if (PyObject_GetBuffer(arg, view, 0) < 0) {
-            *errmsg = "convertible to a buffer";
-            return -1;
-        }
-        if (!PyBuffer_IsContiguous(view, 'C')) {
-            *errmsg = "contiguous buffer";
-            return -1;
-        }
-        return 0;
+    if (pb->bf_getbuffer == NULL) {
+        *errmsg = "convertible to a buffer";
+        return -1;
     }
-
-    count = convertbuffer(arg, &buf, errmsg);
-    if (count < 0) {
+    if (PyObject_GetBuffer(arg, view, 0) < 0) {
         *errmsg = "convertible to a buffer";
-        return count;
+        return -1;
+    }
+    if (!PyBuffer_IsContiguous(view, 'C')) {
+        *errmsg = "contiguous buffer";
+        return -1;
     }
-    PyBuffer_FillInfo(view, NULL, buf, count, 1, 0);
     return 0;
 }
 

Modified: python/branches/py3k-cdecimal/Python/pythonrun.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/pythonrun.c	(original)
+++ python/branches/py3k-cdecimal/Python/pythonrun.c	Mon Jun  7 12:46:02 2010
@@ -265,13 +265,15 @@
 
     _PyImportHooks_Init();
 
+    /* Initialize _warnings. */
+    _PyWarnings_Init();
+
     initfsencoding();
 
     if (install_sigs)
         initsigs(); /* Signal handling stuff, including initintr() */
 
     /* Initialize warnings. */
-    _PyWarnings_Init();
     if (PySys_HasWarnOptions()) {
         PyObject *warnings_module = PyImport_ImportModule("warnings");
         if (!warnings_module)
@@ -1384,10 +1386,12 @@
         exitcode = (int)PyLong_AsLong(value);
     else {
         PyObject *sys_stderr = PySys_GetObject("stderr");
-        if (sys_stderr != NULL)
-            PyObject_CallMethod(sys_stderr, "flush", NULL);
-        PyObject_Print(value, stderr, Py_PRINT_RAW);
-        fflush(stderr);
+        if (sys_stderr != NULL && sys_stderr != Py_None) {
+            PyFile_WriteObject(value, sys_stderr, Py_PRINT_RAW);
+        } else {
+            PyObject_Print(value, stderr, Py_PRINT_RAW);
+            fflush(stderr);
+        }
         PySys_WriteStderr("\n");
         exitcode = 1;
     }

Modified: python/branches/py3k-cdecimal/Python/sysmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/sysmodule.c	(original)
+++ python/branches/py3k-cdecimal/Python/sysmodule.c	Mon Jun  7 12:46:02 2010
@@ -570,6 +570,57 @@
     return Py_None;
 }
 
+static PyTypeObject Hash_InfoType;
+
+PyDoc_STRVAR(hash_info_doc,
+"hash_info\n\
+\n\
+A struct sequence providing parameters used for computing\n\
+numeric hashes.  The attributes are read only.");
+
+static PyStructSequence_Field hash_info_fields[] = {
+    {"width", "width of the type used for hashing, in bits"},
+    {"modulus", "prime number giving the modulus on which the hash "
+                "function is based"},
+    {"inf", "value to be used for hash of a positive infinity"},
+    {"nan", "value to be used for hash of a nan"},
+    {"imag", "multiplier used for the imaginary part of a complex number"},
+    {NULL, NULL}
+};
+
+static PyStructSequence_Desc hash_info_desc = {
+    "sys.hash_info",
+    hash_info_doc,
+    hash_info_fields,
+    5,
+};
+
+PyObject *
+get_hash_info(void)
+{
+    PyObject *hash_info;
+    int field = 0;
+    hash_info = PyStructSequence_New(&Hash_InfoType);
+    if (hash_info == NULL)
+        return NULL;
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(8*sizeof(long)));
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(_PyHASH_MODULUS));
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(_PyHASH_INF));
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(_PyHASH_NAN));
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(_PyHASH_IMAG));
+    if (PyErr_Occurred()) {
+        Py_CLEAR(hash_info);
+        return NULL;
+    }
+    return hash_info;
+}
+
+
 PyDoc_STRVAR(setrecursionlimit_doc,
 "setrecursionlimit(n)\n\
 \n\
@@ -1048,21 +1099,26 @@
 }
 
 void
-PySys_AddWarnOption(const wchar_t *s)
+PySys_AddWarnOptionUnicode(PyObject *unicode)
 {
-    PyObject *str;
-
     if (warnoptions == NULL || !PyList_Check(warnoptions)) {
         Py_XDECREF(warnoptions);
         warnoptions = PyList_New(0);
         if (warnoptions == NULL)
             return;
     }
-    str = PyUnicode_FromWideChar(s, -1);
-    if (str != NULL) {
-        PyList_Append(warnoptions, str);
-        Py_DECREF(str);
-    }
+    PyList_Append(warnoptions, unicode);
+}
+
+void
+PySys_AddWarnOption(const wchar_t *s)
+{
+    PyObject *unicode;
+    unicode = PyUnicode_FromWideChar(s, -1);
+    if (unicode == NULL)
+        return;
+    PySys_AddWarnOptionUnicode(unicode);
+    Py_DECREF(unicode);
 }
 
 int
@@ -1477,6 +1533,11 @@
                         PyFloat_GetInfo());
     SET_SYS_FROM_STRING("int_info",
                         PyLong_GetInfo());
+    /* initialize hash_info */
+    if (Hash_InfoType.tp_name == 0)
+        PyStructSequence_InitType(&Hash_InfoType, &hash_info_desc);
+    SET_SYS_FROM_STRING("hash_info",
+                        get_hash_info());
     SET_SYS_FROM_STRING("maxunicode",
                         PyLong_FromLong(PyUnicode_GetMax()));
     SET_SYS_FROM_STRING("builtin_module_names",
@@ -1663,7 +1724,7 @@
 #endif
 
 void
-PySys_SetArgv(int argc, wchar_t **argv)
+PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
 {
 #if defined(HAVE_REALPATH)
     wchar_t fullpath[MAXPATHLEN];
@@ -1676,7 +1737,7 @@
         Py_FatalError("no mem for sys.argv");
     if (PySys_SetObject("argv", av) != 0)
         Py_FatalError("can't assign sys.argv");
-    if (path != NULL) {
+    if (updatepath && path != NULL) {
         wchar_t *argv0 = argv[0];
         wchar_t *p = NULL;
         Py_ssize_t n = 0;
@@ -1763,6 +1824,12 @@
     Py_DECREF(av);
 }
 
+void
+PySys_SetArgv(int argc, wchar_t **argv)
+{
+    PySys_SetArgvEx(argc, argv, 1);
+}
+
 /* Reimplementation of PyFile_WriteString() no calling indirectly
    PyErr_CheckSignals(): avoid the call to PyObject_Str(). */
 

Modified: python/branches/py3k-cdecimal/Tools/gdb/libpython.py
==============================================================================
--- python/branches/py3k-cdecimal/Tools/gdb/libpython.py	(original)
+++ python/branches/py3k-cdecimal/Tools/gdb/libpython.py	Mon Jun  7 12:46:02 2010
@@ -42,6 +42,7 @@
 '''
 from __future__ import with_statement
 import gdb
+import locale
 
 # Look up the gdb.Type for some standard types:
 _type_char_ptr = gdb.lookup_type('char').pointer() # char*
@@ -69,6 +70,7 @@
 
 hexdigits = "0123456789abcdef"
 
+ENCODING = locale.getpreferredencoding()
 
 class NullPyObjectPtr(RuntimeError):
     pass
@@ -1128,53 +1130,68 @@
 
             # Non-ASCII characters
             else:
-                ucs = ch;
-
-                if self.char_width == 2:
-                    ch2 = 0
+                ucs = ch
+                orig_ucs = None
+                if self.char_width() == 2:
                     # Get code point from surrogate pair
-                    if i < len(proxy):
+                    if (i < len(proxy)
+                    and 0xD800 <= ord(ch) < 0xDC00 \
+                    and 0xDC00 <= ord(proxy[i]) <= 0xDFFF):
                         ch2 = proxy[i]
-                        if (ord(ch) >= 0xD800 and ord(ch) < 0xDC00
-                            and ord(ch2) >= 0xDC00 and ord(ch2) <= 0xDFFF):
-                            ucs = (((ch & 0x03FF) << 10) | (ch2 & 0x03FF)) + 0x00010000;
-                            i += 1
+                        code = (ord(ch) & 0x03FF) << 10
+                        code |= ord(ch2) & 0x03FF
+                        code += 0x00010000
+                        orig_ucs = ucs
+                        ucs = unichr(code)
+                        i += 1
+                    else:
+                        ch2 = None
+
+                printable = _unichr_is_printable(ucs)
+                if printable:
+                    try:
+                        ucs.encode(ENCODING)
+                    except UnicodeEncodeError:
+                        printable = False
+                        if orig_ucs is not None:
+                            ucs = orig_ucs
+                            i -= 1
 
                 # Map Unicode whitespace and control characters
                 # (categories Z* and C* except ASCII space)
-                if not _unichr_is_printable(ucs):
+                if not printable:
                     # Unfortuately, Python 2's unicode type doesn't seem
                     # to expose the "isprintable" method
+                    code = ord(ucs)
 
                     # Map 8-bit characters to '\\xhh'
-                    if ucs <= 0xff:
+                    if code <= 0xff:
                         out.write('\\x')
-                        out.write(hexdigits[(ord(ucs) >> 4) & 0x000F])
-                        out.write(hexdigits[ord(ucs) & 0x000F])
+                        out.write(hexdigits[(code >> 4) & 0x000F])
+                        out.write(hexdigits[code & 0x000F])
                     # Map 21-bit characters to '\U00xxxxxx'
-                    elif ucs >= 0x10000:
+                    elif code >= 0x10000:
                         out.write('\\U')
-                        out.write(hexdigits[(ord(ucs) >> 28) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 24) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 20) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 16) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 12) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 8) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 4) & 0x0000000F])
-                        out.write(hexdigits[ord(ucs) & 0x0000000F])
+                        out.write(hexdigits[(code >> 28) & 0x0000000F])
+                        out.write(hexdigits[(code >> 24) & 0x0000000F])
+                        out.write(hexdigits[(code >> 20) & 0x0000000F])
+                        out.write(hexdigits[(code >> 16) & 0x0000000F])
+                        out.write(hexdigits[(code >> 12) & 0x0000000F])
+                        out.write(hexdigits[(code >> 8) & 0x0000000F])
+                        out.write(hexdigits[(code >> 4) & 0x0000000F])
+                        out.write(hexdigits[code & 0x0000000F])
                     # Map 16-bit characters to '\uxxxx'
                     else:
                         out.write('\\u')
-                        out.write(hexdigits[(ord(ucs) >> 12) & 0x000F])
-                        out.write(hexdigits[(ord(ucs) >> 8) & 0x000F])
-                        out.write(hexdigits[(ord(ucs) >> 4) & 0x000F])
-                        out.write(hexdigits[ord(ucs) & 0x000F])
+                        out.write(hexdigits[(code >> 12) & 0x000F])
+                        out.write(hexdigits[(code >> 8) & 0x000F])
+                        out.write(hexdigits[(code >> 4) & 0x000F])
+                        out.write(hexdigits[code & 0x000F])
                 else:
                     # Copy characters as-is
                     out.write(ch)
-                    if self.char_width == 2:
-                        if ord(ucs) >= 0x10000:
-                            out.write(ch2)
+                    if self.char_width() == 2 and (ch2 is not None):
+                        out.write(ch2)
 
         out.write(quote)
 

Modified: python/branches/py3k-cdecimal/Tools/i18n/msgfmt.py
==============================================================================
--- python/branches/py3k-cdecimal/Tools/i18n/msgfmt.py	(original)
+++ python/branches/py3k-cdecimal/Tools/i18n/msgfmt.py	Mon Jun  7 12:46:02 2010
@@ -30,6 +30,7 @@
 import getopt
 import struct
 import array
+from email.parser import HeaderParser
 
 __version__ = "1.1"
 
@@ -59,13 +60,13 @@
     # the keys are sorted in the .mo file
     keys = sorted(MESSAGES.keys())
     offsets = []
-    ids = strs = ''
+    ids = strs = b''
     for id in keys:
         # For each string, we need size and file offset.  Each string is NUL
         # terminated; the NUL does not count into the size.
         offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id])))
-        ids += id + '\0'
-        strs += MESSAGES[id] + '\0'
+        ids += id + b'\0'
+        strs += MESSAGES[id] + b'\0'
     output = ''
     # The header is 7 32-bit unsigned integers.  We don't use hash tables, so
     # the keys start right after the index tables.
@@ -108,7 +109,7 @@
         outfile = os.path.splitext(infile)[0] + '.mo'
 
     try:
-        lines = open(infile).readlines()
+        lines = open(infile, 'rb').readlines()
     except IOError as msg:
         print(msg, file=sys.stderr)
         sys.exit(1)
@@ -116,9 +117,14 @@
     section = None
     fuzzy = 0
 
+    # Start off assuming Latin-1, so everything decodes without failure,
+    # until we know the exact encoding
+    encoding = 'latin-1'
+
     # Parse the catalog
     lno = 0
     for l in lines:
+        l = l.decode(encoding)
         lno += 1
         # If we get a comment line after a msgstr, this is a new entry
         if l[0] == '#' and section == STR:
@@ -132,16 +138,45 @@
         if l[0] == '#':
             continue
         # Now we are in a msgid section, output previous section
-        if l.startswith('msgid'):
+        if l.startswith('msgid') and not l.startswith('msgid_plural'):
             if section == STR:
                 add(msgid, msgstr, fuzzy)
+                if not msgid:
+                    # See whether there is an encoding declaration
+                    p = HeaderParser()
+                    charset = p.parsestr(msgstr.decode(encoding)).get_content_charset()
+                    if charset:
+                        encoding = charset
             section = ID
             l = l[5:]
-            msgid = msgstr = ''
+            msgid = msgstr = b''
+            is_plural = False
+        # This is a message with plural forms
+        elif l.startswith('msgid_plural'):
+            if section != ID:
+                print('msgid_plural not preceeded by msgid on %s:%d' % (infile, lno),
+                      file=sys.stderr)
+                sys.exit(1)
+            l = l[12:]
+            msgid += b'\0' # separator of singular and plural
+            is_plural = True
         # Now we are in a msgstr section
         elif l.startswith('msgstr'):
             section = STR
-            l = l[6:]
+            if l.startswith('msgstr['):
+                if not is_plural:
+                    print(sys.stderr, 'plural without msgid_plural on %s:%d' % (infile, lno),
+                          file=sys.stderr)
+                    sys.exit(1)
+                l = l.split(']', 1)[1]
+                if msgstr:
+                    msgstr += b'\0' # Separator of the various plural forms
+            else:
+                if is_plural:
+                    print(sys.stderr, 'indexed msgstr required for plural on  %s:%d' % (infile, lno),
+                          file=sys.stderr)
+                    sys.exit(1)
+                l = l[6:]
         # Skip empty lines
         l = l.strip()
         if not l:
@@ -149,9 +184,9 @@
         # XXX: Does this always follow Python escape semantics?
         l = eval(l)
         if section == ID:
-            msgid += l
+            msgid += l.encode(encoding)
         elif section == STR:
-            msgstr += l
+            msgstr += l.encode(encoding)
         else:
             print('Syntax error on %s:%d' % (infile, lno), \
                   'before:', file=sys.stderr)

Modified: python/branches/py3k-cdecimal/Tools/scripts/serve.py
==============================================================================
--- python/branches/py3k-cdecimal/Tools/scripts/serve.py	(original)
+++ python/branches/py3k-cdecimal/Tools/scripts/serve.py	Mon Jun  7 12:46:02 2010
@@ -28,5 +28,8 @@
     path = sys.argv[1]
     port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000
     httpd = simple_server.make_server('', port, app)
-    print("Serving {} on port {}".format(path, port))
-    httpd.serve_forever()
+    print("Serving {} on port {}, control-C to stop".format(path, port))
+    try:
+        httpd.serve_forever()
+    except KeyboardInterrupt:
+        print("\b\bShutting down.")

Modified: python/branches/py3k-cdecimal/configure
==============================================================================
--- python/branches/py3k-cdecimal/configure	(original)
+++ python/branches/py3k-cdecimal/configure	Mon Jun  7 12:46:02 2010
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 80834 .
+# From configure.in Revision: 81078 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.65 for python 3.2.
 #
@@ -1929,11 +1929,11 @@
        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_includes_default
-	     enum { N = $2 / 2 - 1 };
 int
 main ()
 {
-static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))];
+static int test_array [1 - 2 * !(enum { N = $2 / 2 - 1 };
+	     0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))];
 test_array [0] = 0
 
   ;
@@ -1944,11 +1944,11 @@
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 $ac_includes_default
-	        enum { N = $2 / 2 - 1 };
 int
 main ()
 {
-static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)
+static int test_array [1 - 2 * !(enum { N = $2 / 2 - 1 };
+		($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)
 		 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))];
 test_array [0] = 0
 
@@ -3013,9 +3013,12 @@
   # Marc Recht
   NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S])
     define_xopen_source=no;;
-  # On Solaris 2.6, sys/wait.h is inconsistent in the usage
-  # of union __?sigval. Reported by Stuart Bishop.
-  SunOS/5.6)
+  # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
+  # request to enable features supported by the standard as a request
+  # to disable features not supported by the standard.  The best way
+  # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
+  # entirely and define __EXTENSIONS__ instead.
+  SunOS/*)
     define_xopen_source=no;;
   # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
   # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
@@ -3061,38 +3064,17 @@
 
 if test $define_xopen_source = yes
 then
-  # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
-  # defined precisely as g++ defines it
-  # Furthermore, on Solaris 10, XPG6 requires the use of a C99
-  # compiler
-  case $ac_sys_system/$ac_sys_release in
-    SunOS/5.8|SunOS/5.9|SunOS/5.10)
-
-$as_echo "#define _XOPEN_SOURCE 500" >>confdefs.h
-
-      ;;
-    *)
 
 $as_echo "#define _XOPEN_SOURCE 600" >>confdefs.h
 
-      ;;
-  esac
 
   # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
   # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
   # several APIs are not declared. Since this is also needed in some
   # cases for HP-UX, we define it globally.
-  # except for Solaris 10, where it must not be defined,
-  # as it implies XPG4.2
-  case $ac_sys_system/$ac_sys_release in
-    SunOS/5.10)
-      ;;
-    *)
 
 $as_echo "#define _XOPEN_SOURCE_EXTENDED 1" >>confdefs.h
 
-      ;;
-  esac
 
 
 $as_echo "#define _POSIX_C_SOURCE 200112L" >>confdefs.h

Modified: python/branches/py3k-cdecimal/configure.in
==============================================================================
--- python/branches/py3k-cdecimal/configure.in	(original)
+++ python/branches/py3k-cdecimal/configure.in	Mon Jun  7 12:46:02 2010
@@ -330,9 +330,12 @@
   # Marc Recht
   NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
     define_xopen_source=no;;
-  # On Solaris 2.6, sys/wait.h is inconsistent in the usage
-  # of union __?sigval. Reported by Stuart Bishop.
-  SunOS/5.6)
+  # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
+  # request to enable features supported by the standard as a request
+  # to disable features not supported by the standard.  The best way
+  # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
+  # entirely and define __EXTENSIONS__ instead.
+  SunOS/*)
     define_xopen_source=no;;
   # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
   # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
@@ -378,35 +381,15 @@
 
 if test $define_xopen_source = yes
 then
-  # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
-  # defined precisely as g++ defines it
-  # Furthermore, on Solaris 10, XPG6 requires the use of a C99
-  # compiler
-  case $ac_sys_system/$ac_sys_release in
-    SunOS/5.8|SunOS/5.9|SunOS/5.10)
-      AC_DEFINE(_XOPEN_SOURCE, 500, 
-                Define to the level of X/Open that your system supports)
-      ;;
-    *)
-      AC_DEFINE(_XOPEN_SOURCE, 600, 
-                Define to the level of X/Open that your system supports)
-      ;;
-  esac
+  AC_DEFINE(_XOPEN_SOURCE, 600, 
+            Define to the level of X/Open that your system supports)
 
   # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
   # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
   # several APIs are not declared. Since this is also needed in some
   # cases for HP-UX, we define it globally.
-  # except for Solaris 10, where it must not be defined, 
-  # as it implies XPG4.2
-  case $ac_sys_system/$ac_sys_release in
-    SunOS/5.10)
-      ;;
-    *)
-      AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
-      		Define to activate Unix95-and-earlier features)
-      ;;
-  esac
+  AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
+   	    Define to activate Unix95-and-earlier features)
 
   AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
   

Modified: python/branches/py3k-cdecimal/setup.py
==============================================================================
--- python/branches/py3k-cdecimal/setup.py	(original)
+++ python/branches/py3k-cdecimal/setup.py	Mon Jun  7 12:46:02 2010
@@ -28,6 +28,25 @@
     if dir is not None and os.path.isdir(dir) and dir not in dirlist:
         dirlist.insert(0, dir)
 
+def macosx_sdk_root():
+    """
+    Return the directory of the current OSX SDK,
+    or '/' if no SDK was specified.
+    """
+    cflags = sysconfig.get_config_var('CFLAGS')
+    m = re.search(r'-isysroot\s+(\S+)', cflags)
+    if m is None:
+        sysroot = '/'
+    else:
+        sysroot = m.group(1)
+    return sysroot
+
+def is_macosx_sdk_path(path):
+    """
+    Returns True if 'path' can be located in an OSX SDK
+    """
+    return path.startswith('/usr/') or path.startswith('/System/')
+
 def find_file(filename, std_dirs, paths):
     """Searches for the directory where a given file is located,
     and returns a possibly-empty list of additional directories, or None
@@ -39,15 +58,28 @@
     'paths' is a list of additional locations to check; if the file is
         found in one of them, the resulting list will contain the directory.
     """
+    if sys.platform == 'darwin':
+        # Honor the MacOSX SDK setting when one was specified.
+        # An SDK is a directory with the same structure as a real
+        # system, but with only header files and libraries.
+        sysroot = macosx_sdk_root()
 
     # Check the standard locations
     for dir in std_dirs:
         f = os.path.join(dir, filename)
+
+        if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
+            f = os.path.join(sysroot, dir[1:], filename)
+
         if os.path.exists(f): return []
 
     # Check the additional directories
     for dir in paths:
         f = os.path.join(dir, filename)
+
+        if sys.platform == 'darwin' and is_macosx_sdk_path(dir):
+            f = os.path.join(sysroot, dir[1:], filename)
+
         if os.path.exists(f):
             return [dir]
 
@@ -59,11 +91,19 @@
     if result is None:
         return None
 
+    if sys.platform == 'darwin':
+        sysroot = macosx_sdk_root()
+
     # Check whether the found file is in one of the standard directories
     dirname = os.path.dirname(result)
     for p in std_dirs:
         # Ensure path doesn't end with path separator
         p = p.rstrip(os.sep)
+
+        if sys.platform == 'darwin' and is_macosx_sdk_path(p):
+            if os.path.join(sysroot, p[1:]) == dirname:
+                return [ ]
+
         if p == dirname:
             return [ ]
 
@@ -72,6 +112,11 @@
     for p in paths:
         # Ensure path doesn't end with path separator
         p = p.rstrip(os.sep)
+
+        if sys.platform == 'darwin' and is_macosx_sdk_path(p):
+            if os.path.join(sysroot, p[1:]) == dirname:
+                return [ p ]
+
         if p == dirname:
             return [p]
     else:
@@ -497,7 +542,7 @@
                 # library and then a static library, instead of first looking
                 # for dynamic libraries on the entire path.
                 # This way a staticly linked custom readline gets picked up
-                # before the (broken) dynamic library in /usr/lib.
+                # before the (possibly broken) dynamic library in /usr/lib.
                 readline_extra_link_args = ('-Wl,-search_paths_first',)
             else:
                 readline_extra_link_args = ()
@@ -571,22 +616,23 @@
         openssl_ver = 0
         openssl_ver_re = re.compile(
             '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' )
-        for ssl_inc_dir in inc_dirs + search_for_ssl_incs_in:
-            name = os.path.join(ssl_inc_dir, 'openssl', 'opensslv.h')
-            if os.path.isfile(name):
-                try:
-                    incfile = open(name, 'r')
-                    for line in incfile:
-                        m = openssl_ver_re.match(line)
-                        if m:
-                            openssl_ver = eval(m.group(1))
-                            break
-                except IOError:
-                    pass
 
-            # first version found is what we'll use (as the compiler should)
-            if openssl_ver:
-                break
+        # look for the openssl version header on the compiler search path.
+        opensslv_h = find_file('openssl/opensslv.h', [],
+                inc_dirs + search_for_ssl_incs_in)
+        if opensslv_h:
+            name = os.path.join(opensslv_h[0], 'openssl/opensslv.h')
+            if sys.platform == 'darwin' and is_macosx_sdk_path(name):
+                name = os.path.join(macosx_sdk_root(), name[1:])
+            try:
+                incfile = open(name, 'r')
+                for line in incfile:
+                    m = openssl_ver_re.match(line)
+                    if m:
+                        openssl_ver = eval(m.group(1))
+            except IOError as msg:
+                print("IOError while reading opensshv.h:", msg)
+                pass
 
         #print('openssl_ver = 0x%08x' % openssl_ver)
         min_openssl_ver = 0x00907000
@@ -715,12 +761,18 @@
 
         db_ver_inc_map = {}
 
+        if sys.platform == 'darwin':
+            sysroot = macosx_sdk_root()
+
         class db_found(Exception): pass
         try:
             # See whether there is a Sleepycat header in the standard
             # search path.
             for d in inc_dirs + db_inc_paths:
                 f = os.path.join(d, "db.h")
+                if sys.platform == 'darwin' and is_macosx_sdk_path(d):
+                    f = os.path.join(sysroot, d[1:], "db.h")
+
                 if db_setup_debug: print("db: looking for db.h in", f)
                 if os.path.exists(f):
                     f = open(f, "rb").read()
@@ -767,7 +819,22 @@
                     db_incdir.replace("include", 'lib64'),
                     db_incdir.replace("include", 'lib'),
                 ]
-                db_dirs_to_check = list(filter(os.path.isdir, db_dirs_to_check))
+
+                if sys.platform != 'darwin':
+                    db_dirs_to_check = list(filter(os.path.isdir, db_dirs_to_check))
+
+                else:
+                    # Same as other branch, but takes OSX SDK into account
+                    tmp = []
+                    for dn in db_dirs_to_check:
+                        if is_macosx_sdk_path(dn):
+                            if os.path.isdir(os.path.join(sysroot, dn[1:])):
+                                tmp.append(dn)
+                        else:
+                            if os.path.isdir(dn):
+                                tmp.append(dn)
+
+                    db_dirs_to_check = tmp
 
                 # Look for a version specific db-X.Y before an ambiguoius dbX
                 # XXX should we -ever- look for a dbX name?  Do any
@@ -816,8 +883,15 @@
         # Scan the default include directories before the SQLite specific
         # ones. This allows one to override the copy of sqlite on OSX,
         # where /usr/include contains an old version of sqlite.
+        if sys.platform == 'darwin':
+            sysroot = macosx_sdk_root()
+
         for d in inc_dirs + sqlite_inc_paths:
             f = os.path.join(d, "sqlite3.h")
+
+            if sys.platform == 'darwin' and is_macosx_sdk_path(d):
+                f = os.path.join(sysroot, d[1:], "sqlite3.h")
+
             if os.path.exists(f):
                 if sqlite_setup_debug: print("sqlite: found %s"%f)
                 incf = open(f).read()
@@ -1256,14 +1330,22 @@
             join(os.getenv('HOME'), '/Library/Frameworks')
         ]
 
+        sysroot = macosx_sdk_root()
+
         # Find the directory that contains the Tcl.framework and Tk.framework
         # bundles.
         # XXX distutils should support -F!
         for F in framework_dirs:
             # both Tcl.framework and Tk.framework should be present
+
+
             for fw in 'Tcl', 'Tk':
-                if not exists(join(F, fw + '.framework')):
-                    break
+                if is_macosx_sdk_path(F):
+                    if not exists(join(sysroot, F[1:], fw + '.framework')):
+                        break
+                else:
+                    if not exists(join(F, fw + '.framework')):
+                        break
             else:
                 # ok, F is now directory with both frameworks. Continure
                 # building
@@ -1300,8 +1382,12 @@
 
         # Note: cannot use os.popen or subprocess here, that
         # requires extensions that are not available here.
-        os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%(F, tmpfile))
+        if is_macosx_sdk_path(F):
+            os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%(os.path.join(sysroot, F[1:]), tmpfile))
+        else:
+            os.system("file %s/Tk.framework/Tk | grep 'for architecture' > %s"%(F, tmpfile))
         fp = open(tmpfile)
+
         detected_archs = []
         for ln in fp:
             a = ln.split()[-1]


More information about the Python-checkins mailing list