[Python-checkins] r81980 - in python/branches/py3k-cdecimal: Doc/c-api/arg.rst Doc/c-api/buffer.rst Doc/library/datetime.rst Doc/library/decimal.rst Doc/library/doctest.rst Doc/library/os.rst Doc/library/struct.rst Doc/library/tarfile.rst Doc/library/xml.dom.minidom.rst Doc/whatsnew/3.2.rst Include/longobject.h Lib/ctypes/test/test_bytes.py Lib/ctypes/test/test_structures.py Lib/decimal.py Lib/doctest.py Lib/logging/config.py Lib/os.py Lib/struct.py Lib/sunau.py Lib/tarfile.py Lib/test/math_testcases.txt Lib/test/regrtest.py Lib/test/test_capi.py Lib/test/test_codecs.py Lib/test/test_curses.py Lib/test/test_doctest.py Lib/test/test_fractions.py Lib/test/test_getargs2.py Lib/test/test_math.py Lib/test/test_minidom.py Lib/test/test_numeric_tower.py Lib/test/test_ssl.py Lib/test/test_struct.py Lib/test/test_sunau.py Lib/test/test_sundry.py Lib/test/test_sys.py Lib/test/test_unicode.py Lib/unittest/case.py Lib/unittest/suite.py Lib/unittest/test/test_runner.py Lib/unittest/test/test_setups.py Lib/xml/dom/minidom.py Misc/ACKS Misc/NEWS Misc/maintainers.rst Modules/_codecsmodule.c Modules/_ctypes/_ctypes.c Modules/_ctypes/cfield.c Modules/_localemodule.c Modules/_struct.c Modules/_testcapimodule.c Modules/datetimemodule.c Modules/itertoolsmodule.c Modules/mathmodule.c Modules/readline.c Objects/bytearrayobject.c Objects/bytesobject.c Objects/exceptions.c Objects/longobject.c Objects/stringlib/formatter.h Objects/stringlib/string_format.h Objects/unicodeobject.c PC/winreg.c Parser/asdl_c.py Python/Python-ast.c Python/errors.c Python/getargs.c Python/modsupport.c Python/pythonrun.c Python/symtable.c Python/sysmodule.c setup.py

stefan.krah python-checkins at python.org
Mon Jun 14 11:30:16 CEST 2010


Author: stefan.krah
Date: Mon Jun 14 11:30:15 2010
New Revision: 81980

Log:
Merged revisions 81806-81807,81809,81811,81814,81816,81818,81821,81823,81826-81827,81829-81832,81835,81838,81840-81841,81843-81844,81849,81851,81854,81856-81857,81862,81865,81869,81871,81873-81875,81877,81879,81883,81885,81891,81893-81898,81901-81902,81905,81908,81911-81912,81914,81916,81918,81920,81923,81925,81927,81929-81930,81936-81938,81944,81946-81952,81954-81956,81958,81961,81965,81968,81970,81972-81974 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r81806 | mark.dickinson | 2010-06-07 20:47:09 +0200 (Mon, 07 Jun 2010) | 1 line
  
  Fix naming inconsistency.
................
  r81807 | victor.stinner | 2010-06-07 21:57:46 +0200 (Mon, 07 Jun 2010) | 2 lines
  
  Issue #8848: U / U# formats of Py_BuildValue() are just alias to s / s#
................
  r81809 | victor.stinner | 2010-06-07 22:14:04 +0200 (Mon, 07 Jun 2010) | 3 lines
  
  Issue #8897: Fix sunau module, use bytes to write the header. Patch written by
  Thomas Jollans.
................
  r81811 | victor.stinner | 2010-06-07 23:20:41 +0200 (Mon, 07 Jun 2010) | 9 lines
  
  Issue #8925: fix types of Py_Parse*() and Py_BuildValue() functions
  
   * Add links to Python types
   * Replace "string" by bytes or str
   * Replace "long" by "int"
   * Specify the default encoding
   * Fix reST syntax ("..note ::")
   * etc.
................
  r81814 | benjamin.peterson | 2010-06-07 23:41:35 +0200 (Mon, 07 Jun 2010) | 9 lines
  
  Merged revisions 81813 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81813 | benjamin.peterson | 2010-06-07 16:37:09 -0500 (Mon, 07 Jun 2010) | 2 lines
    
    locale grouping strings should end in '\0'
  ........
................
  r81816 | ezio.melotti | 2010-06-07 23:57:18 +0200 (Mon, 07 Jun 2010) | 8 lines
  
  Blocked revisions 81769 via svnmerge
  
  ........
    r81769 | ezio.melotti | 2010-06-06 01:28:10 +0300 (Sun, 06 Jun 2010) | 1 line
    
    Replace deprecated fail* methods with the equivalent assert* ones.
  ........
................
  r81818 | ezio.melotti | 2010-06-08 00:02:50 +0200 (Tue, 08 Jun 2010) | 8 lines
  
  Blocked revisions 81817 via svnmerge
  
  ........
    r81817 | ezio.melotti | 2010-06-08 01:00:18 +0300 (Tue, 08 Jun 2010) | 1 line
    
    Silence deprecation warning in test___all__ caused by an import bsddb.
  ........
................
  r81821 | benjamin.peterson | 2010-06-08 00:24:18 +0200 (Tue, 08 Jun 2010) | 1 line
  
  use the 's' format code instead of 'U'
................
  r81823 | benjamin.peterson | 2010-06-08 00:31:26 +0200 (Tue, 08 Jun 2010) | 9 lines
  
  Merged revisions 81820 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81820 | benjamin.peterson | 2010-06-07 17:23:23 -0500 (Mon, 07 Jun 2010) | 1 line
    
    correctly overflow when indexes are too large
  ........
................
  r81826 | benjamin.peterson | 2010-06-08 00:35:08 +0200 (Tue, 08 Jun 2010) | 9 lines
  
  Merged revisions 81824 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81824 | benjamin.peterson | 2010-06-07 17:32:44 -0500 (Mon, 07 Jun 2010) | 1 line
    
    remove extra byte and fix comment
  ........
................
  r81827 | benjamin.peterson | 2010-06-08 00:36:44 +0200 (Tue, 08 Jun 2010) | 8 lines
  
  Blocked revisions 81825 via svnmerge
  
  ........
    r81825 | benjamin.peterson | 2010-06-07 17:33:09 -0500 (Mon, 07 Jun 2010) | 1 line
    
    use unicode literals
  ........
................
  r81829 | stefan.krah | 2010-06-08 15:26:49 +0200 (Tue, 08 Jun 2010) | 21 lines
  
  Blocked revisions 81669,81672,81683 via svnmerge
  
  ........
    r81669 | stefan.krah | 2010-06-03 14:39:50 +0200 (Thu, 03 Jun 2010) | 9 lines
    
    Issue #7384: If the system readline library is linked against ncurses,
    the curses module must be linked against ncurses as well. Otherwise it 
    is not safe to load both the readline and curses modules in an application.
    
    Thanks Thomas Dickey for answering questions about ncurses/ncursesw
    and readline!
  ........
    r81672 | stefan.krah | 2010-06-03 16:25:16 +0200 (Thu, 03 Jun 2010) | 3 lines
    
    Use compiler rather than compiler_obj. Thanks Michael Foord for noticing.
  ........
    r81683 | stefan.krah | 2010-06-04 11:49:20 +0200 (Fri, 04 Jun 2010) | 1 line
    
    Detect missing ldd on all systems.
  ........
................
  r81830 | stefan.krah | 2010-06-08 15:41:44 +0200 (Tue, 08 Jun 2010) | 9 lines
  
  Issue #7384: If the system readline library is linked against ncurses,
  the curses module must be linked against ncurses as well. Otherwise it
  is not safe to load both the readline and curses modules in an application.
  
  Thanks Thomas Dickey for answering questions about ncurses/ncursesw
  and readline!
................
  r81831 | stefan.krah | 2010-06-08 16:00:52 +0200 (Tue, 08 Jun 2010) | 1 line
  
  Add note for r81830.
................
  r81832 | r.david.murray | 2010-06-08 16:41:45 +0200 (Tue, 08 Jun 2010) | 2 lines
  
  Now that sunau has some tests, remove it from test_sundry.
................
  r81835 | benjamin.peterson | 2010-06-08 16:57:22 +0200 (Tue, 08 Jun 2010) | 9 lines
  
  Merged revisions 81834 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81834 | benjamin.peterson | 2010-06-08 09:53:29 -0500 (Tue, 08 Jun 2010) | 1 line
    
    kill extra word
  ........
................
  r81838 | alexander.belopolsky | 2010-06-08 19:06:48 +0200 (Tue, 08 Jun 2010) | 1 line
  
  Added myself as a maintainer of time and datetime modules.
................
  r81840 | alexander.belopolsky | 2010-06-08 20:59:20 +0200 (Tue, 08 Jun 2010) | 9 lines
  
  Merged revisions 81489 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81489 | georg.brandl | 2010-05-23 17:29:29 -0400 (Sun, 23 May 2010) | 1 line
    
    #1436346: make it more obvious that timetuple[7] is yday.
  ........
................
  r81841 | victor.stinner | 2010-06-08 22:46:00 +0200 (Tue, 08 Jun 2010) | 6 lines
  
  sys_pyfile_write() does nothing if file is NULL
  
  mywrite() falls back to the C file object if sys_pyfile_write() returns an
  error. This patch fixes a segfault is Py_FatalError() is called in an early
  stage of Python initialization.
................
  r81843 | brian.curtin | 2010-06-08 22:57:52 +0200 (Tue, 08 Jun 2010) | 3 lines
  
  Fix a compile warning missed during porting (wchar_t/char) and move a 
  variable declaration outside of a loop. #2810 was when this first went in.
................
  r81844 | victor.stinner | 2010-06-08 23:00:13 +0200 (Tue, 08 Jun 2010) | 6 lines
  
  Py_FatalError(): don't sys sys.last_xxx variables
  
  Call PyErr_PrintEx(0) instead of PyErr_Print() to avoid a crash if
  Py_FatalError() is called in an early stage of Python initialization (if PySys
  is not yet initialized).
................
  r81849 | victor.stinner | 2010-06-08 23:45:51 +0200 (Tue, 08 Jun 2010) | 7 lines
  
  PyArg_Parse*("Z#") raises an error for unknown type
  
  instead of ignoring the error and leave the pointer to the string and the size
  unchanged (not initialized).
  
  Fix also the type in the error message of "Z", "Z#" and "Y" formats.
................
  r81851 | brian.curtin | 2010-06-09 00:27:07 +0200 (Wed, 09 Jun 2010) | 2 lines
  
  Fix #8946. Extra PyObject* parameter documented which doesn't exist.
................
  r81854 | victor.stinner | 2010-06-09 00:54:19 +0200 (Wed, 09 Jun 2010) | 5 lines
  
  Issue #8838, #8339: Remove codecs.charbuffer_encode() and "t#" parsing format
  
  Remove last references to the "char buffer" of the buffer protocol from
  Python3.
................
  r81856 | kristjan.jonsson | 2010-06-09 10:13:42 +0200 (Wed, 09 Jun 2010) | 2 lines
  
  http://bugs.python.org/issue8832
  Issue minidom.unlink with a context manager
................
  r81857 | stefan.krah | 2010-06-09 10:56:28 +0200 (Wed, 09 Jun 2010) | 3 lines
  
  Issue #8932: Skip required when compiled --without-threads.
................
  r81862 | antoine.pitrou | 2010-06-09 18:38:55 +0200 (Wed, 09 Jun 2010) | 9 lines
  
  Merged revisions 81860 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81860 | antoine.pitrou | 2010-06-09 18:24:00 +0200 (mer., 09 juin 2010) | 3 lines
    
    Issue #8930: fix some C code indentation
  ........
................
  r81865 | alexander.belopolsky | 2010-06-09 19:11:01 +0200 (Wed, 09 Jun 2010) | 9 lines
  
  Merged revisions 81864 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81864 | alexander.belopolsky | 2010-06-09 13:08:11 -0400 (Wed, 09 Jun 2010) | 1 line
    
    Fixed markup of tm_isdst attribute.
  ........
................
  r81869 | victor.stinner | 2010-06-10 14:00:55 +0200 (Thu, 10 Jun 2010) | 4 lines
  
  Issue #8922: Normalize the encoding name in PyUnicode_AsEncodedString() to
  enable shortcuts for upper case encoding name. Add also a shortcut for
  "iso-8859-1" in PyUnicode_AsEncodedString() and PyUnicode_Decode().
................
  r81871 | victor.stinner | 2010-06-10 15:36:23 +0200 (Thu, 10 Jun 2010) | 4 lines
  
  Fix r81869: ISO-8859-15 was seen as an alias to ISO-8859-1
  
  Don't use normalize_encoding() result if it is truncated.
................
  r81873 | mark.dickinson | 2010-06-10 18:05:10 +0200 (Thu, 10 Jun 2010) | 4 lines
  
  Issue #8950: Make PyArg_Parse* with 'L' code raise for float inputs,
  instead of warning.  This makes it consistent with the other integer
  codes.
................
  r81874 | michael.foord | 2010-06-10 18:16:08 +0200 (Thu, 10 Jun 2010) | 9 lines
  
  Merged revisions 81853 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81853 | michael.foord | 2010-06-08 23:44:52 +0100 (Tue, 08 Jun 2010) | 1 line
    
    Issue 8948. cleanup functions are not run by unittest.TestCase.debug(), plus class and module teardowns are not run by unittest.TestSuite.debug().
  ........
................
  r81875 | michael.foord | 2010-06-10 18:17:07 +0200 (Thu, 10 Jun 2010) | 9 lines
  
  Merged revisions 81859 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81859 | michael.foord | 2010-06-09 13:29:56 +0100 (Wed, 09 Jun 2010) | 1 line
    
    Typo correction.
  ........
................
  r81877 | michael.foord | 2010-06-10 18:33:34 +0200 (Thu, 10 Jun 2010) | 8 lines
  
  Blocked revisions 81876 via svnmerge
  
  ........
    r81876 | michael.foord | 2010-06-10 17:32:00 +0100 (Thu, 10 Jun 2010) | 1 line
    
    NEWS update for issue 8948.
  ........
................
  r81879 | michael.foord | 2010-06-10 22:41:54 +0200 (Thu, 10 Jun 2010) | 9 lines
  
  Merged revisions 81878 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81878 | michael.foord | 2010-06-10 21:40:21 +0100 (Thu, 10 Jun 2010) | 2 lines
    
    Fix issue with nested test suites debug method and module setups. (unittest)
  ........
................
  r81883 | victor.stinner | 2010-06-11 02:36:33 +0200 (Fri, 11 Jun 2010) | 5 lines
  
  Issue #8965: initfsencoding() doesn't change the encoding on Mac OS X
  
  File system encoding have to be hardcoded to "utf-8" on Mac OS X. r81190
  introduced a regression: the encoding was changed depending on the locale.
................
  r81885 | victor.stinner | 2010-06-11 02:41:41 +0200 (Fri, 11 Jun 2010) | 2 lines
  
  test_sys: add a test on the file system encoding for darwin
................
  r81891 | ezio.melotti | 2010-06-11 04:26:42 +0200 (Fri, 11 Jun 2010) | 9 lines
  
  Merged revisions 81889 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81889 | ezio.melotti | 2010-06-11 05:21:25 +0300 (Fri, 11 Jun 2010) | 1 line
    
    Remove extra ] from itertools.count docstring.
  ........
................
  r81893 | mark.dickinson | 2010-06-11 12:44:52 +0200 (Fri, 11 Jun 2010) | 3 lines
  
  Issue #8188: Comparisons between Decimal objects and other numeric
  objects (Fraction, float, complex, int) now all function as expected.
................
  r81894 | mark.dickinson | 2010-06-11 12:46:57 +0200 (Fri, 11 Jun 2010) | 1 line
  
  Fix issue number typo.
................
  r81895 | alexander.belopolsky | 2010-06-11 18:04:59 +0200 (Fri, 11 Jun 2010) | 2 lines
  
  Issue #3129: Trailing digits in format string are no longer ignored.
................
  r81896 | mark.dickinson | 2010-06-11 18:49:20 +0200 (Fri, 11 Jun 2010) | 1 line
  
  Fix typo in docstring.
................
  r81897 | mark.dickinson | 2010-06-11 18:56:34 +0200 (Fri, 11 Jun 2010) | 1 line
  
  Avoid possible undefined behaviour from signed overflow.
................
  r81898 | mark.dickinson | 2010-06-11 21:05:08 +0200 (Fri, 11 Jun 2010) | 1 line
  
  Fix an incorrect return type.
................
  r81901 | victor.stinner | 2010-06-11 21:24:36 +0200 (Fri, 11 Jun 2010) | 8 lines
  
  Blocked revisions 81899 via svnmerge
  
  ........
    r81899 | victor.stinner | 2010-06-11 21:22:28 +0200 (ven., 11 juin 2010) | 2 lines
    
    Issue #8362: Add Misc/maintainers.rst: list of module maintainers
  ........
................
  r81902 | mark.dickinson | 2010-06-11 21:50:30 +0200 (Fri, 11 Jun 2010) | 1 line
  
  Fix more undefined-behaviour inducing overflow checks in struct module.
................
  r81905 | mark.dickinson | 2010-06-11 22:29:09 +0200 (Fri, 11 Jun 2010) | 10 lines
  
  Blocked revisions 81904 via svnmerge
  
  ........
    r81904 | mark.dickinson | 2010-06-11 21:27:05 +0100 (Fri, 11 Jun 2010) | 4 lines
    
    Fix possible undefined behaviour from signed overflow in struct module.
    
    Backport of revisions 81897, 81898 and 81902 from py3k.
  ........
................
  r81908 | antoine.pitrou | 2010-06-11 23:46:32 +0200 (Fri, 11 Jun 2010) | 11 lines
  
  Merged revisions 81907 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81907 | antoine.pitrou | 2010-06-11 23:42:26 +0200 (ven., 11 juin 2010) | 5 lines
    
    Issue #8941: decoding big endian UTF-32 data in UCS-2 builds could crash
    the interpreter with characters outside the Basic Multilingual Plane
    (higher than 0x10000).
  ........
................
  r81911 | victor.stinner | 2010-06-11 23:50:30 +0200 (Fri, 11 Jun 2010) | 3 lines
  
  Issue #8966: If a ctypes structure field is an array of c_char, convert its
  value to bytes instead of str (as done for c_char and c_char_p).
................
  r81912 | benjamin.peterson | 2010-06-11 23:53:07 +0200 (Fri, 11 Jun 2010) | 9 lines
  
  Merged revisions 81906 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81906 | benjamin.peterson | 2010-06-11 16:40:37 -0500 (Fri, 11 Jun 2010) | 1 line
    
    different spellings are just unacceptable
  ........
................
  r81914 | victor.stinner | 2010-06-12 00:09:51 +0200 (Sat, 12 Jun 2010) | 2 lines
  
  locale.bindtextdomain(): use PyUnicode_FSConverter() to parse the filename
................
  r81916 | victor.stinner | 2010-06-12 00:17:52 +0200 (Sat, 12 Jun 2010) | 2 lines
  
  Issue #8965: Add a regression test to test_sys with LANG=C
................
  r81918 | victor.stinner | 2010-06-12 00:27:14 +0200 (Sat, 12 Jun 2010) | 2 lines
  
  readline: use PyUnicode_FSConverter() to parse filenames
................
  r81920 | victor.stinner | 2010-06-12 01:06:13 +0200 (Sat, 12 Jun 2010) | 2 lines
  
  Issue #8965: Write more tests for sys.getfilesystemencoding()
................
  r81923 | victor.stinner | 2010-06-12 01:30:12 +0200 (Sat, 12 Jun 2010) | 16 lines
  
  Fix some bugs in c-api/arg.rst documentation
  
   * replace "the default encoding" by "'utf-8' encoding"
   * fix "w" / "w*" / "w#" doc: similar to "y" / "y*" / "y#"
     and not "s" / "s*" / "s#"
   * "u#": remove "Non-Unicode objects are handled by interpreting their
     read-buffer pointer ...", it's no more true
   * "es", "es#": remove "... and objects convertible to Unicode into a character
     buffer", it's no more true
   * Py_BuildValue(), "K" and "L" formats: specify the name of the C type on
     Windows (_int64 / unsigned _int64) as done for PyArg_Parse*() long long
     types
  --CETTE ligne, et les suivantes ci-dessous, seront ignorées--
  
  M    Doc/c-api/arg.rst
................
  r81925 | victor.stinner | 2010-06-12 01:46:47 +0200 (Sat, 12 Jun 2010) | 4 lines
  
  Issue #8784: Set tarfile default encoding to 'utf-8' on Windows.
  
  Note: file system encoding cannot be None anymore (since r81190, issue #8610).
................
  r81927 | victor.stinner | 2010-06-12 01:56:51 +0200 (Sat, 12 Jun 2010) | 3 lines
  
  Issue #8969: On Windows, use mbcs codec in strict mode to encode and decode
  filenames and enable os.fsencode().
................
  r81929 | brett.cannon | 2010-06-12 02:38:29 +0200 (Sat, 12 Jun 2010) | 5 lines
  
  When dealing with __import__ for detecting a global state change made by a
  test, make sure to check if __builtins__ is a dict or not.
  
  Discovered when running importlib.test.regrtest.
................
  r81930 | brett.cannon | 2010-06-12 02:39:28 +0200 (Sat, 12 Jun 2010) | 4 lines
  
  Calling __import__ as a method technically works, but really should be wrapped
  in a staticmethod. This is important for when __import__ is set to a function
  defined in Python instead of C.
................
  r81936 | mark.dickinson | 2010-06-12 11:10:14 +0200 (Sat, 12 Jun 2010) | 2 lines
  
  Silence 'unused variable' gcc warning.  Patch by Éric Araujo.
................
  r81937 | mark.dickinson | 2010-06-12 11:24:01 +0200 (Sat, 12 Jun 2010) | 2 lines
  
  Issue #8981:  Remove _struct.__version__.
................
  r81938 | mark.dickinson | 2010-06-12 11:25:13 +0200 (Sat, 12 Jun 2010) | 1 line
  
  Remove unused variable.
................
  r81944 | nick.coghlan | 2010-06-12 15:42:46 +0200 (Sat, 12 Jun 2010) | 9 lines
  
  Merged revisions 80578 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80578 | nick.coghlan | 2010-04-29 00:29:06 +1000 (Thu, 29 Apr 2010) | 1 line
    
    Issue 7490: make IGNORE_EXCEPTION_DETAIL also ignore details of the module containing the exception under test (original patch by Lennart Regebro)
  ........
................
  r81946 | nick.coghlan | 2010-06-12 15:46:56 +0200 (Sat, 12 Jun 2010) | 8 lines
  
  Blocked revisions 81945 via svnmerge
  
  ........
    r81945 | nick.coghlan | 2010-06-12 23:45:37 +1000 (Sat, 12 Jun 2010) | 1 line
    
    Backport a fix from Py3k for a potentially misleading example
  ........
................
  r81947 | mark.dickinson | 2010-06-12 17:17:02 +0200 (Sat, 12 Jun 2010) | 3 lines
  
  Issue #8973:  Add __all__ to struct module, so that help(struct) correctly
  displays information for the struct.Struct class.
................
  r81948 | mark.dickinson | 2010-06-12 17:19:23 +0200 (Sat, 12 Jun 2010) | 1 line
  
  Remove accidental (yet-to-be-reviewed) docstring changes included in r81947.
................
  r81949 | mark.dickinson | 2010-06-12 17:43:45 +0200 (Sat, 12 Jun 2010) | 1 line
  
  Issue #8973:  Improve struct module docstrings.
................
  r81950 | mark.dickinson | 2010-06-12 18:30:53 +0200 (Sat, 12 Jun 2010) | 1 line
  
  More struct module docs and docstring tweaks.
................
  r81951 | mark.dickinson | 2010-06-12 18:37:53 +0200 (Sat, 12 Jun 2010) | 1 line
  
  Fix mild type confusion in decimal module docstring.
................
  r81952 | alexander.belopolsky | 2010-06-12 19:18:45 +0200 (Sat, 12 Jun 2010) | 1 line
  
  Added acknowlegement for Issue #3129
................
  r81954 | benjamin.peterson | 2010-06-12 19:54:44 +0200 (Sat, 12 Jun 2010) | 9 lines
  
  Merged revisions 81953 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81953 | benjamin.peterson | 2010-06-12 12:47:06 -0500 (Sat, 12 Jun 2010) | 1 line
    
    fix warning with ucs4
  ........
................
  r81955 | mark.dickinson | 2010-06-12 20:20:47 +0200 (Sat, 12 Jun 2010) | 1 line
  
  Issue #8469: add standard sizes to struct docs table.
................
  r81956 | mark.dickinson | 2010-06-12 20:37:54 +0200 (Sat, 12 Jun 2010) | 2 lines
  
  Issue #8469:  Reorder struct module sections for clarity;  other minor tweaks.
................
  r81958 | mark.dickinson | 2010-06-12 20:54:20 +0200 (Sat, 12 Jun 2010) | 11 lines
  
  Blocked revisions 81957 via svnmerge
  
  ........
    r81957 | mark.dickinson | 2010-06-12 19:50:34 +0100 (Sat, 12 Jun 2010) | 5 lines
    
    Issue #8469:  Add standard sizes to table in struct documentation; additional
    clarifications and documentation tweaks.
    
    Backport of revisions 81955-81956 from py3k.
  ........
................
  r81961 | alexander.belopolsky | 2010-06-12 21:36:28 +0200 (Sat, 12 Jun 2010) | 1 line
  
  Issue #8973: Expanded Struct.__doc__.
................
  r81965 | mark.dickinson | 2010-06-13 11:17:13 +0200 (Sun, 13 Jun 2010) | 1 line
  
  Remove unnecessary brackets from docstring optional arguments.
................
  r81968 | mark.dickinson | 2010-06-13 12:52:38 +0200 (Sun, 13 Jun 2010) | 11 lines
  
  Merged revisions 81967 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81967 | mark.dickinson | 2010-06-13 11:50:29 +0100 (Sun, 13 Jun 2010) | 4 lines
    
    Issue #8986: erfc was raising OverflowError on Linux for arguments in
    the (approximate) range (-27.3, 30.0), as a result of an escaped errno
    value.
  ........
................
  r81970 | mark.dickinson | 2010-06-13 13:07:57 +0200 (Sun, 13 Jun 2010) | 9 lines
  
  Merged revisions 81969 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81969 | mark.dickinson | 2010-06-13 12:07:00 +0100 (Sun, 13 Jun 2010) | 1 line
    
    Add Éric Araujo to Misc/ACKS for doc work and many patch and commit reviews.
  ........
................
  r81972 | mark.dickinson | 2010-06-13 14:02:07 +0200 (Sun, 13 Jun 2010) | 9 lines
  
  Merged revisions 81971 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81971 | mark.dickinson | 2010-06-13 13:01:34 +0100 (Sun, 13 Jun 2010) | 1 line
    
    Ezio Melotti was missing from Misc/ACKS.
  ........
................
  r81973 | victor.stinner | 2010-06-13 20:21:50 +0200 (Sun, 13 Jun 2010) | 4 lines
  
  Issue #8592: PyArg_Parse*() functions raise a TypeError for "y", "u" and "Z"
  formats if the string contains a null byte/character. Write unit tests for
  string formats.
................
  r81974 | victor.stinner | 2010-06-13 22:31:26 +0200 (Sun, 13 Jun 2010) | 4 lines
  
  getargs.c: remove last reference to "t#" format
  
  "t#" format was removed from convertitem() (convertsimple) but not skipitem().
................


Added:
   python/branches/py3k-cdecimal/Lib/test/test_sunau.py
      - copied unchanged from r81974, /python/branches/py3k/Lib/test/test_sunau.py
Modified:
   python/branches/py3k-cdecimal/   (props changed)
   python/branches/py3k-cdecimal/Doc/c-api/arg.rst
   python/branches/py3k-cdecimal/Doc/c-api/buffer.rst
   python/branches/py3k-cdecimal/Doc/library/datetime.rst
   python/branches/py3k-cdecimal/Doc/library/decimal.rst
   python/branches/py3k-cdecimal/Doc/library/doctest.rst
   python/branches/py3k-cdecimal/Doc/library/os.rst
   python/branches/py3k-cdecimal/Doc/library/struct.rst
   python/branches/py3k-cdecimal/Doc/library/tarfile.rst
   python/branches/py3k-cdecimal/Doc/library/xml.dom.minidom.rst
   python/branches/py3k-cdecimal/Doc/whatsnew/3.2.rst
   python/branches/py3k-cdecimal/Include/longobject.h
   python/branches/py3k-cdecimal/Lib/ctypes/test/test_bytes.py
   python/branches/py3k-cdecimal/Lib/ctypes/test/test_structures.py
   python/branches/py3k-cdecimal/Lib/decimal.py
   python/branches/py3k-cdecimal/Lib/doctest.py
   python/branches/py3k-cdecimal/Lib/logging/config.py
   python/branches/py3k-cdecimal/Lib/os.py
   python/branches/py3k-cdecimal/Lib/struct.py
   python/branches/py3k-cdecimal/Lib/sunau.py
   python/branches/py3k-cdecimal/Lib/tarfile.py
   python/branches/py3k-cdecimal/Lib/test/math_testcases.txt
   python/branches/py3k-cdecimal/Lib/test/regrtest.py
   python/branches/py3k-cdecimal/Lib/test/test_capi.py
   python/branches/py3k-cdecimal/Lib/test/test_codecs.py
   python/branches/py3k-cdecimal/Lib/test/test_curses.py
   python/branches/py3k-cdecimal/Lib/test/test_doctest.py
   python/branches/py3k-cdecimal/Lib/test/test_fractions.py
   python/branches/py3k-cdecimal/Lib/test/test_getargs2.py
   python/branches/py3k-cdecimal/Lib/test/test_math.py
   python/branches/py3k-cdecimal/Lib/test/test_minidom.py
   python/branches/py3k-cdecimal/Lib/test/test_numeric_tower.py
   python/branches/py3k-cdecimal/Lib/test/test_ssl.py
   python/branches/py3k-cdecimal/Lib/test/test_struct.py
   python/branches/py3k-cdecimal/Lib/test/test_sundry.py
   python/branches/py3k-cdecimal/Lib/test/test_sys.py
   python/branches/py3k-cdecimal/Lib/test/test_unicode.py
   python/branches/py3k-cdecimal/Lib/unittest/case.py
   python/branches/py3k-cdecimal/Lib/unittest/suite.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_runner.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_setups.py
   python/branches/py3k-cdecimal/Lib/xml/dom/minidom.py
   python/branches/py3k-cdecimal/Misc/ACKS
   python/branches/py3k-cdecimal/Misc/NEWS
   python/branches/py3k-cdecimal/Misc/maintainers.rst
   python/branches/py3k-cdecimal/Modules/_codecsmodule.c
   python/branches/py3k-cdecimal/Modules/_ctypes/_ctypes.c
   python/branches/py3k-cdecimal/Modules/_ctypes/cfield.c
   python/branches/py3k-cdecimal/Modules/_localemodule.c
   python/branches/py3k-cdecimal/Modules/_struct.c
   python/branches/py3k-cdecimal/Modules/_testcapimodule.c
   python/branches/py3k-cdecimal/Modules/datetimemodule.c
   python/branches/py3k-cdecimal/Modules/itertoolsmodule.c
   python/branches/py3k-cdecimal/Modules/mathmodule.c
   python/branches/py3k-cdecimal/Modules/readline.c
   python/branches/py3k-cdecimal/Objects/bytearrayobject.c
   python/branches/py3k-cdecimal/Objects/bytesobject.c
   python/branches/py3k-cdecimal/Objects/exceptions.c
   python/branches/py3k-cdecimal/Objects/longobject.c
   python/branches/py3k-cdecimal/Objects/stringlib/formatter.h
   python/branches/py3k-cdecimal/Objects/stringlib/string_format.h
   python/branches/py3k-cdecimal/Objects/unicodeobject.c
   python/branches/py3k-cdecimal/PC/winreg.c
   python/branches/py3k-cdecimal/Parser/asdl_c.py
   python/branches/py3k-cdecimal/Python/Python-ast.c
   python/branches/py3k-cdecimal/Python/errors.c
   python/branches/py3k-cdecimal/Python/getargs.c
   python/branches/py3k-cdecimal/Python/modsupport.c
   python/branches/py3k-cdecimal/Python/pythonrun.c
   python/branches/py3k-cdecimal/Python/symtable.c
   python/branches/py3k-cdecimal/Python/sysmodule.c
   python/branches/py3k-cdecimal/setup.py

Modified: python/branches/py3k-cdecimal/Doc/c-api/arg.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/arg.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/arg.rst	Mon Jun 14 11:30:15 2010
@@ -53,13 +53,13 @@
    drop int support.  It is best to always define :cmacro:`PY_SSIZE_T_CLEAN`.
 
 
-``s`` (Unicode object) [const char \*]
+``s`` (:class:`str`) [const char \*]
    Convert a Unicode object to a C pointer to a character string.
    A pointer to an existing string is stored in the character pointer
    variable whose address you pass.  The C string is NUL-terminated.
    The Python string must not contain embedded NUL bytes; if it does,
    a :exc:`TypeError` exception is raised. Unicode objects are converted
-   to C strings using the default encoding.  If this conversion fails, a
+   to C strings using ``'utf-8'`` encoding. If this conversion fails, a
    :exc:`UnicodeError` is raised.
 
    .. note::
@@ -68,118 +68,111 @@
       preferrable to use the ``O&`` format with :cfunc:`PyUnicode_FSConverter`
       as *converter*.
 
-``s*`` (Unicode object or any buffer compatible object) [Py_buffer]
+``s*`` (:class:`str`, :class:`bytes`, :class:`bytearray` or buffer compatible object) [Py_buffer]
    This format accepts Unicode objects as well as objects supporting the
-   buffer protocol (such as :class:`bytes` or :class:`bytearray` objects).
+   buffer protocol.
    It fills a :ctype:`Py_buffer` structure provided by the caller.
-   Unicode objects are converted to C strings using the default encoding.
    In this case the resulting C string may contain embedded NUL bytes.
+   Unicode objects are converted to C strings using ``'utf-8'`` encoding.
 
-``s#`` (string, Unicode or any read buffer compatible object) [const char \*, int or :ctype:`Py_ssize_t`]
+``s#`` (:class:`str`, :class:`bytes` or read-only buffer compatible object) [const char \*, int or :ctype:`Py_ssize_t`]
    Like ``s*``, except that it doesn't accept mutable buffer-like objects
    such as :class:`bytearray`.  The result is stored into two C variables,
    the first one a pointer to a C string, the second one its length.
-   The string may contain embedded null bytes.
+   The string may contain embedded null bytes. Unicode objects are converted
+   to C strings using ``'utf-8'`` encoding.
 
-``z`` (Unicode object or ``None``) [const char \*]
+``z`` (:class:`str` or ``None``) [const char \*]
    Like ``s``, but the Python object may also be ``None``, in which case the C
    pointer is set to *NULL*.
 
-``z*`` (Unicode object or ``None`` or any buffer compatible object) [Py_buffer]
+``z*`` (:class:`str`, :class:`bytes`, :class:`bytearray`, buffer compatible object or ``None``) [Py_buffer]
    Like ``s*``, but the Python object may also be ``None``, in which case the
    ``buf`` member of the :ctype:`Py_buffer` structure is set to *NULL*.
 
-``z#`` (Unicode object or ``None`` or any read buffer compatible object) [const char \*, int]
+``z#`` (:class:`str`, :class:`bytes`, read-only buffer compatible object or ``None``) [const char \*, int]
    Like ``s#``, but the Python object may also be ``None``, in which case the C
    pointer is set to *NULL*.
 
-``y`` (bytes object) [const char \*]
+``y`` (:class:`bytes`) [const char \*]
    This format converts a bytes-like object to a C pointer to a character
    string; it does not accept Unicode objects.  The bytes buffer must not
    contain embedded NUL bytes; if it does, a :exc:`TypeError`
    exception is raised.
 
-``y*`` (any buffer compatible object) [Py_buffer \*]
+``y*`` (:class:`bytes`, :class:`bytearray` or buffer compatible object) [Py_buffer \*]
    This variant on ``s*`` doesn't accept Unicode objects, only objects
    supporting the buffer protocol.  **This is the recommended way to accept
    binary data.**
 
-``y#`` (bytes object) [const char \*, int]
+``y#`` (:class:`bytes`) [const char \*, int]
    This variant on ``s#`` doesn't accept Unicode objects, only bytes-like
    objects.
 
-``S`` (bytes object) [PyBytesObject \*]
+``S`` (:class:`bytes`) [PyBytesObject \*]
    Requires that the Python object is a :class:`bytes` object, without
    attempting any conversion.  Raises :exc:`TypeError` if the object is not
    a bytes object.  The C variable may also be declared as :ctype:`PyObject\*`.
 
-``Y`` (bytearray object) [PyByteArrayObject \*]
+``Y`` (:class:`bytearray`) [PyByteArrayObject \*]
    Requires that the Python object is a :class:`bytearray` object, without
    attempting any conversion.  Raises :exc:`TypeError` if the object is not
-   a bytearray object.  The C variable may also be declared as :ctype:`PyObject\*`.
+   a :class:`bytearray` object. The C variable may also be declared as :ctype:`PyObject\*`.
 
-``u`` (Unicode object) [Py_UNICODE \*]
+``u`` (:class:`str`) [Py_UNICODE \*]
    Convert a Python Unicode object to a C pointer to a NUL-terminated buffer of
    Unicode characters.  You must pass the address of a :ctype:`Py_UNICODE`
    pointer variable, which will be filled with the pointer to an existing
    Unicode buffer.  Please note that the width of a :ctype:`Py_UNICODE`
    character depends on compilation options (it is either 16 or 32 bits).
+   The Python string must not contain embedded NUL characters; if it does,
+   a :exc:`TypeError` exception is raised.
 
-   ..note ::
+   .. note::
       Since ``u`` doesn't give you back the length of the string, and it
       may contain embedded NUL characters, it is recommended to use ``u#``
       or ``U`` instead.
 
-``u#`` (Unicode object) [Py_UNICODE \*, int]
+``u#`` (:class:`str`) [Py_UNICODE \*, int]
    This variant on ``u`` stores into two C variables, the first one a pointer to a
-   Unicode data buffer, the second one its length. Non-Unicode objects are handled
-   by interpreting their read-buffer pointer as pointer to a :ctype:`Py_UNICODE`
-   array.
+   Unicode data buffer, the second one its length.
 
-``Z`` (Unicode or ``None``) [Py_UNICODE \*]
+``Z`` (:class:`str` or ``None``) [Py_UNICODE \*]
    Like ``u``, but the Python object may also be ``None``, in which case the
    :ctype:`Py_UNICODE` pointer is set to *NULL*.
 
-``Z#`` (Unicode or ``None``) [Py_UNICODE \*, int]
+``Z#`` (:class:`str` or ``None``) [Py_UNICODE \*, int]
    Like ``u#``, but the Python object may also be ``None``, in which case the
    :ctype:`Py_UNICODE` pointer is set to *NULL*.
 
-``U`` (Unicode object) [PyUnicodeObject \*]
+``U`` (:class:`str`) [PyUnicodeObject \*]
    Requires that the Python object is a Unicode object, without attempting
    any conversion.  Raises :exc:`TypeError` if the object is not a Unicode
    object.  The C variable may also be declared as :ctype:`PyObject\*`.
 
-``t#`` (read-only character buffer) [char \*, int]
-   Like ``s#``, but accepts any object which implements the read-only buffer
-   interface.  The :ctype:`char\*` variable is set to point to the first byte of
-   the buffer, and the :ctype:`int` is set to the length of the buffer.  Only
-   single-segment buffer objects are accepted; :exc:`TypeError` is raised for all
-   others.
-
-``w`` (read-write character buffer) [char \*]
-   Similar to ``s``, but accepts any object which implements the read-write buffer
+``w`` (:class:`bytearray` or read-write character buffer) [char \*]
+   Similar to ``y``, but accepts any object which implements the read-write buffer
    interface.  The caller must determine the length of the buffer by other means,
    or use ``w#`` instead.  Only single-segment buffer objects are accepted;
    :exc:`TypeError` is raised for all others.
 
-``w*`` (read-write byte-oriented buffer) [Py_buffer]
-   This is to ``w`` what ``s*`` is to ``s``.
+``w*`` (:class:`bytearray` or read-write byte-oriented buffer) [Py_buffer]
+   This is to ``w`` what ``y*`` is to ``y``.
 
-``w#`` (read-write character buffer) [char \*, int]
-   Like ``s#``, but accepts any object which implements the read-write buffer
+``w#`` (:class:`bytearray` or read-write character buffer) [char \*, int]
+   Like ``y#``, but accepts any object which implements the read-write buffer
    interface.  The :ctype:`char \*` variable is set to point to the first byte
    of the buffer, and the :ctype:`int` is set to the length of the buffer.
    Only single-segment buffer objects are accepted; :exc:`TypeError` is raised
    for all others.
 
-``es`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer]
-   This variant on ``s`` is used for encoding Unicode and objects convertible to
-   Unicode into a character buffer. It only works for encoded data without embedded
-   NUL bytes.
+``es`` (:class:`str`) [const char \*encoding, char \*\*buffer]
+   This variant on ``s`` is used for encoding Unicode into a character buffer.
+   It only works for encoded data without embedded NUL bytes.
 
    This format requires two arguments.  The first is only used as input, and
    must be a :ctype:`const char\*` which points to the name of an encoding as a
-   NUL-terminated string, or *NULL*, in which case the default encoding is used.
+   NUL-terminated string, or *NULL*, in which case ``'utf-8'`` encoding is used.
    An exception is raised if the named encoding is not known to Python.  The
    second argument must be a :ctype:`char\*\*`; the value of the pointer it
    references will be set to a buffer with the contents of the argument text.
@@ -190,19 +183,19 @@
    allocated storage.  The caller is responsible for calling :cfunc:`PyMem_Free` to
    free the allocated buffer after use.
 
-``et`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer]
-   Same as ``es`` except that 8-bit string objects are passed through without
-   recoding them.  Instead, the implementation assumes that the string object uses
+``et`` (:class:`str`, :class:`bytes` or :class:`bytearray`) [const char \*encoding, char \*\*buffer]
+   Same as ``es`` except that byte string objects are passed through without
+   recoding them.  Instead, the implementation assumes that the byte string object uses
    the encoding passed in as parameter.
 
-``es#`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer, int \*buffer_length]
-   This variant on ``s#`` is used for encoding Unicode and objects convertible to
-   Unicode into a character buffer.  Unlike the ``es`` format, this variant allows
-   input data which contains NUL characters.
+``es#`` (:class:`str`) [const char \*encoding, char \*\*buffer, int \*buffer_length]
+   This variant on ``s#`` is used for encoding Unicode into a character buffer.
+   Unlike the ``es`` format, this variant allows input data which contains NUL
+   characters.
 
    It requires three arguments.  The first is only used as input, and must be a
    :ctype:`const char\*` which points to the name of an encoding as a
-   NUL-terminated string, or *NULL*, in which case the default encoding is used.
+   NUL-terminated string, or *NULL*, in which case ``'utf-8'`` encoding is used.
    An exception is raised if the named encoding is not known to Python.  The
    second argument must be a :ctype:`char\*\*`; the value of the pointer it
    references will be set to a buffer with the contents of the argument text.
@@ -226,71 +219,71 @@
    In both cases, *\*buffer_length* is set to the length of the encoded data
    without the trailing NUL byte.
 
-``et#`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer, int \*buffer_length]
-   Same as ``es#`` except that string objects are passed through without recoding
-   them. Instead, the implementation assumes that the string object uses the
+``et#`` (:class:`str`, :class:`bytes` or :class:`bytearray`) [const char \*encoding, char \*\*buffer, int \*buffer_length]
+   Same as ``es#`` except that byte string objects are passed through without recoding
+   them. Instead, the implementation assumes that the byte string object uses the
    encoding passed in as parameter.
 
 Numbers
 -------
 
-``b`` (integer) [unsigned char]
+``b`` (:class:`int`) [unsigned char]
    Convert a nonnegative Python integer to an unsigned tiny int, stored in a C
    :ctype:`unsigned char`.
 
-``B`` (integer) [unsigned char]
+``B`` (:class:`int`) [unsigned char]
    Convert a Python integer to a tiny int without overflow checking, stored in a C
    :ctype:`unsigned char`.
 
-``h`` (integer) [short int]
+``h`` (:class:`int`) [short int]
    Convert a Python integer to a C :ctype:`short int`.
 
-``H`` (integer) [unsigned short int]
+``H`` (:class:`int`) [unsigned short int]
    Convert a Python integer to a C :ctype:`unsigned short int`, without overflow
    checking.
 
-``i`` (integer) [int]
+``i`` (:class:`int`) [int]
    Convert a Python integer to a plain C :ctype:`int`.
 
-``I`` (integer) [unsigned int]
+``I`` (:class:`int`) [unsigned int]
    Convert a Python integer to a C :ctype:`unsigned int`, without overflow
    checking.
 
-``l`` (integer) [long int]
+``l`` (:class:`int`) [long int]
    Convert a Python integer to a C :ctype:`long int`.
 
-``k`` (integer) [unsigned long]
+``k`` (:class:`int`) [unsigned long]
    Convert a Python integer to a C :ctype:`unsigned long` without
    overflow checking.
 
-``L`` (integer) [PY_LONG_LONG]
+``L`` (:class:`int`) [PY_LONG_LONG]
    Convert a Python integer to a C :ctype:`long long`.  This format is only
    available on platforms that support :ctype:`long long` (or :ctype:`_int64` on
    Windows).
 
-``K`` (integer) [unsigned PY_LONG_LONG]
+``K`` (:class:`int`) [unsigned PY_LONG_LONG]
    Convert a Python integer to a C :ctype:`unsigned long long`
    without overflow checking.  This format is only available on platforms that
    support :ctype:`unsigned long long` (or :ctype:`unsigned _int64` on Windows).
 
-``n`` (integer) [Py_ssize_t]
+``n`` (:class:`int`) [Py_ssize_t]
    Convert a Python integer to a C :ctype:`Py_ssize_t`.
 
-``c`` (bytes object of length 1) [char]
+``c`` (:class:`bytes` of length 1) [char]
    Convert a Python byte, represented as a :class:`bytes` object of length 1,
    to a C :ctype:`char`.
 
-``C`` (Unicode object of length 1) [int]
-   Convert a Python character, represented as a :class:`str`: object of
+``C`` (:class:`str` of length 1) [int]
+   Convert a Python character, represented as a :class:`str` object of
    length 1, to a C :ctype:`int`.
 
-``f`` (float) [float]
+``f`` (:class:`float`) [float]
    Convert a Python floating point number to a C :ctype:`float`.
 
-``d`` (float) [double]
+``d`` (:class:`float`) [double]
    Convert a Python floating point number to a C :ctype:`double`.
 
-``D`` (complex) [Py_complex]
+``D`` (:class:`complex`) [Py_complex]
    Convert a Python complex number to a C :ctype:`Py_complex` structure.
 
 Other objects
@@ -330,7 +323,7 @@
    .. versionchanged:: 3.1
       Py_CLEANUP_SUPPORTED was added.
 
-``(items)`` (tuple) [*matching-items*]
+``(items)`` (:class:`tuple`) [*matching-items*]
    The object must be a Python sequence whose length is the number of format units
    in *items*.  The C arguments must correspond to the individual format units in
    *items*.  Format units for sequences may be nested.
@@ -498,95 +491,96 @@
    not within format units such as ``s#``).  This can be used to make long format
    strings a tad more readable.
 
-   ``s`` (string) [char \*]
-      Convert a null-terminated C string to a Python object.  If the C string pointer
-      is *NULL*, ``None`` is used.
-
-   ``s#`` (string) [char \*, int]
-      Convert a C string and its length to a Python object.  If the C string pointer
-      is *NULL*, the length is ignored and ``None`` is returned.
+   ``s`` (:class:`str` or ``None``) [char \*]
+      Convert a null-terminated C string to a Python object using ``'utf-8'``
+      encoding. If the C string pointer is *NULL*, ``None`` is used.
+
+   ``s#`` (:class:`str` or ``None``) [char \*, int]
+      Convert a C string and its length to a Python object using ``'utf-8'``
+      encoding. If the C string pointer is *NULL*, the length is ignored and
+      ``None`` is returned.
 
-   ``y`` (bytes) [char \*]
+   ``y`` (:class:`bytes`) [char \*]
       This converts a C string to a Python :func:`bytes` object.  If the C
       string pointer is *NULL*, ``None`` is returned.
 
-   ``y#`` (bytes) [char \*, int]
+   ``y#`` (:class:`bytes`) [char \*, int]
       This converts a C string and its lengths to a Python object.  If the C
       string pointer is *NULL*, ``None`` is returned.
 
-   ``z`` (string or ``None``) [char \*]
+   ``z`` (:class:`str` or ``None``) [char \*]
       Same as ``s``.
 
-   ``z#`` (string or ``None``) [char \*, int]
+   ``z#`` (:class:`str` or ``None``) [char \*, int]
       Same as ``s#``.
 
-   ``u`` (Unicode string) [Py_UNICODE \*]
+   ``u`` (:class:`str`) [Py_UNICODE \*]
       Convert a null-terminated buffer of Unicode (UCS-2 or UCS-4) data to a Python
       Unicode object.  If the Unicode buffer pointer is *NULL*, ``None`` is returned.
 
-   ``u#`` (Unicode string) [Py_UNICODE \*, int]
+   ``u#`` (:class:`str`) [Py_UNICODE \*, int]
       Convert a Unicode (UCS-2 or UCS-4) data buffer and its length to a Python
       Unicode object.   If the Unicode buffer pointer is *NULL*, the length is ignored
       and ``None`` is returned.
 
-   ``U`` (string) [char \*]
-      Convert a null-terminated C string to a Python unicode object. If the C string
-      pointer is *NULL*, ``None`` is used.
-
-   ``U#`` (string) [char \*, int]
-      Convert a C string and its length to a Python unicode object. If the C string
-      pointer is *NULL*, the length is ignored and ``None`` is returned.
+   ``U`` (:class:`str` or ``None``) [char \*]
+      Same as ``s``.
+
+   ``U#`` (:class:`str` or ``None``) [char \*, int]
+      Same as ``s#``.
 
-   ``i`` (integer) [int]
+   ``i`` (:class:`int`) [int]
       Convert a plain C :ctype:`int` to a Python integer object.
 
-   ``b`` (integer) [char]
+   ``b`` (:class:`int`) [char]
       Convert a plain C :ctype:`char` to a Python integer object.
 
-   ``h`` (integer) [short int]
+   ``h`` (:class:`int`) [short int]
       Convert a plain C :ctype:`short int` to a Python integer object.
 
-   ``l`` (integer) [long int]
+   ``l`` (:class:`int`) [long int]
       Convert a C :ctype:`long int` to a Python integer object.
 
-   ``B`` (integer) [unsigned char]
+   ``B`` (:class:`int`) [unsigned char]
       Convert a C :ctype:`unsigned char` to a Python integer object.
 
-   ``H`` (integer) [unsigned short int]
+   ``H`` (:class:`int`) [unsigned short int]
       Convert a C :ctype:`unsigned short int` to a Python integer object.
 
-   ``I`` (integer) [unsigned int]
+   ``I`` (:class:`int`) [unsigned int]
       Convert a C :ctype:`unsigned int` to a Python integer object.
 
-   ``k`` (integer) [unsigned long]
+   ``k`` (:class:`int`) [unsigned long]
       Convert a C :ctype:`unsigned long` to a Python integer object.
 
-   ``L`` (long) [PY_LONG_LONG]
+   ``L`` (:class:`int`) [PY_LONG_LONG]
       Convert a C :ctype:`long long` to a Python integer object. Only available
-      on platforms that support :ctype:`long long`.
+      on platforms that support :ctype:`long long` (or :ctype:`_int64` on
+      Windows).
 
-   ``K`` (long) [unsigned PY_LONG_LONG]
+   ``K`` (:class:`int`) [unsigned PY_LONG_LONG]
       Convert a C :ctype:`unsigned long long` to a Python integer object. Only
-      available on platforms that support :ctype:`unsigned long long`.
+      available on platforms that support :ctype:`unsigned long long` (or
+      :ctype:`unsigned _int64` on Windows).
 
-   ``n`` (int) [Py_ssize_t]
+   ``n`` (:class:`int`) [Py_ssize_t]
       Convert a C :ctype:`Py_ssize_t` to a Python integer.
 
-   ``c`` (string of length 1) [char]
-      Convert a C :ctype:`int` representing a byte to a Python byte string of
+   ``c`` (:class:`bytes` of length 1) [char]
+      Convert a C :ctype:`int` representing a byte to a Python :class:`bytes` object of
       length 1.
 
-   ``C`` (string of length 1) [int]
-      Convert a C :ctype:`int` representing a character to Python unicode
-      string of length 1.
+   ``C`` (:class:`str` of length 1) [int]
+      Convert a C :ctype:`int` representing a character to Python :class:`str`
+      object of length 1.
 
-   ``d`` (float) [double]
+   ``d`` (:class:`float`) [double]
       Convert a C :ctype:`double` to a Python floating point number.
 
-   ``f`` (float) [float]
-      Same as ``d``.
+   ``f`` (:class:`float`) [float]
+      Convert a C :ctype:`float` to a Python floating point number.
 
-   ``D`` (complex) [Py_complex \*]
+   ``D`` (:class:`complex`) [Py_complex \*]
       Convert a C :ctype:`Py_complex` structure to a Python complex number.
 
    ``O`` (object) [PyObject \*]
@@ -611,13 +605,13 @@
       \*`) as its argument and should return a "new" Python object, or *NULL* if an
       error occurred.
 
-   ``(items)`` (tuple) [*matching-items*]
+   ``(items)`` (:class:`tuple`) [*matching-items*]
       Convert a sequence of C values to a Python tuple with the same number of items.
 
-   ``[items]`` (list) [*matching-items*]
+   ``[items]`` (:class:`list`) [*matching-items*]
       Convert a sequence of C values to a Python list with the same number of items.
 
-   ``{items}`` (dictionary) [*matching-items*]
+   ``{items}`` (:class:`dict`) [*matching-items*]
       Convert a sequence of C values to a Python dictionary.  Each pair of consecutive
       C values adds one item to the dictionary, serving as key and value,
       respectively.

Modified: python/branches/py3k-cdecimal/Doc/c-api/buffer.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/buffer.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/buffer.rst	Mon Jun 14 11:30:15 2010
@@ -249,10 +249,10 @@
       +------------------------------+---------------------------------------------------+
 
 
-.. cfunction:: void PyBuffer_Release(PyObject *obj, Py_buffer *view)
+.. cfunction:: void PyBuffer_Release(Py_buffer *view)
 
-   Release the buffer *view* over *obj*.  This should be called when the buffer
-   is no longer being used as it may free memory from it.
+   Release the buffer *view*.  This should be called when the buffer is no
+   longer being used as it may free memory from it.
 
 
 .. cfunction:: Py_ssize_t PyBuffer_SizeFromFormat(const char *)

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 14 11:30:15 2010
@@ -480,7 +480,9 @@
    Return a :class:`time.struct_time` such as returned by :func:`time.localtime`.
    The hours, minutes and seconds are 0, and the DST flag is -1. ``d.timetuple()``
    is equivalent to ``time.struct_time((d.year, d.month, d.day, 0, 0, 0,
-   d.weekday(), d.toordinal() - date(d.year, 1, 1).toordinal() + 1, -1))``
+   d.weekday(), yday, -1))``, where ``yday = d.toordinal() - date(d.year, 1,
+   1).toordinal() + 1`` is the day number within the current year starting with
+   ``1`` for January 1st.
 
 
 .. method:: date.toordinal()
@@ -944,12 +946,13 @@
 
    Return a :class:`time.struct_time` such as returned by :func:`time.localtime`.
    ``d.timetuple()`` is equivalent to ``time.struct_time((d.year, d.month, d.day,
-   d.hour, d.minute, d.second, d.weekday(), d.toordinal() - date(d.year, 1,
-   1).toordinal() + 1, dst))`` The :attr:`tm_isdst` flag of the result is set
-   according to the :meth:`dst` method:  :attr:`tzinfo` is ``None`` or :meth:`dst`
-   returns ``None``, :attr:`tm_isdst` is set to  ``-1``; else if :meth:`dst`
-   returns a non-zero value, :attr:`tm_isdst` is set to ``1``; else ``tm_isdst`` is
-   set to ``0``.
+   d.hour, d.minute, d.second, d.weekday(), yday, dst))``, where ``yday =
+   d.toordinal() - date(d.year, 1, 1).toordinal() + 1`` is the day number within
+   the current year starting with ``1`` for January 1st. The :attr:`tm_isdst` flag
+   of the result is set according to the :meth:`dst` method: :attr:`tzinfo` is
+   ``None`` or :meth:`dst`` returns ``None``, :attr:`tm_isdst` is set to ``-1``;
+   else if :meth:`dst` returns a non-zero value, :attr:`tm_isdst` is set to ``1``;
+   else :attr:`tm_isdst` is set to ``0``.
 
 
 .. method:: datetime.utctimetuple()

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 14 11:30:15 2010
@@ -363,23 +363,17 @@
    compared, sorted, and coerced to another type (such as :class:`float` or
    :class:`int`).
 
-   Decimal objects cannot generally be combined with floats in
-   arithmetic operations: an attempt to add a :class:`Decimal` to a
-   :class:`float`, for example, will raise a :exc:`TypeError`.
-   There's one exception to this rule: it's possible to use Python's
-   comparison operators to compare a :class:`float` instance ``x``
-   with a :class:`Decimal` instance ``y``.  Without this exception,
-   comparisons between :class:`Decimal` and :class:`float` instances
-   would follow the general rules for comparing objects of different
-   types described in the :ref:`expressions` section of the reference
-   manual, leading to confusing results.
+   Decimal objects cannot generally be combined with floats or
+   instances of :class:`fractions.Fraction` in arithmetic operations:
+   an attempt to add a :class:`Decimal` to a :class:`float`, for
+   example, will raise a :exc:`TypeError`.  However, it is possible to
+   use Python's comparison operators to compare a :class:`Decimal`
+   instance ``x`` with another number ``y``.  This avoids confusing results
+   when doing equality comparisons between numbers of different types.
 
    .. versionchanged:: 3.2
-      A comparison between a :class:`float` instance ``x`` and a
-      :class:`Decimal` instance ``y`` now returns a result based on
-      the values of ``x`` and ``y``.  In earlier versions ``x < y``
-      returned the same (arbitrary) result for any :class:`Decimal`
-      instance ``x`` and any :class:`float` instance ``y``.
+      Mixed-type comparisons between :class:`Decimal` instances and
+      other numeric types are now fully supported.
 
    In addition to the standard numeric properties, decimal floating point
    objects also have a number of specialized methods:

Modified: python/branches/py3k-cdecimal/Doc/library/doctest.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/doctest.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/doctest.rst	Mon Jun 14 11:30:15 2010
@@ -444,8 +444,9 @@
   with an alphanumeric is taken to be the start of the exception detail.  Of
   course this does the right thing for genuine tracebacks.
 
-* When the :const:`IGNORE_EXCEPTION_DETAIL` doctest option is is specified,
-  everything following the leftmost colon is ignored.
+* When the :const:`IGNORE_EXCEPTION_DETAIL` doctest option is specified,
+  everything following the leftmost colon and any module information in the
+  exception name is ignored.
 
 * The interactive shell omits the traceback header line for some
   :exc:`SyntaxError`\ s.  But doctest uses the traceback header line to
@@ -535,20 +536,38 @@
    exception raised is ``ValueError: 3*14``, but will fail, e.g., if
    :exc:`TypeError` is raised.
 
-   Note that a similar effect can be obtained using :const:`ELLIPSIS`, and
-   :const:`IGNORE_EXCEPTION_DETAIL` may go away when Python releases prior to 2.4
-   become uninteresting.  Until then, :const:`IGNORE_EXCEPTION_DETAIL` is the only
-   clear way to write a doctest that doesn't care about the exception detail yet
-   continues to pass under Python releases prior to 2.4 (doctest directives appear
-   to be comments to them).  For example, ::
+   It will also ignore the module name used in Python 3 doctest reports. Hence
+   both these variations will work regardless of whether the test is run under
+   Python 2.7 or Python 3.2 (or later versions):
+
+      >>> raise CustomError('message') #doctest: +IGNORE_EXCEPTION_DETAIL
+      Traceback (most recent call last):
+      CustomError: message
+
+      >>> raise CustomError('message') #doctest: +IGNORE_EXCEPTION_DETAIL
+      Traceback (most recent call last):
+      my_module.CustomError: message
+
+   Note that :const:`ELLIPSIS` can also be used to ignore the
+   details of the exception message, but such a test may still fail based
+   on whether or not the module details are printed as part of the
+   exception name. Using :const:`IGNORE_EXCEPTION_DETAIL` and the details
+   from Python 2.3 is also the only clear way to write a doctest that doesn't
+   care about the exception detail yet continues to pass under Python 2.3 or
+   earlier (those releases do not support doctest directives and ignore them
+   as irrelevant comments). For example, ::
 
       >>> (1, 2)[3] = 'moo' #doctest: +IGNORE_EXCEPTION_DETAIL
       Traceback (most recent call last):
         File "<stdin>", line 1, in ?
       TypeError: object doesn't support item assignment
 
-   passes under Python 2.4 and Python 2.3.  The detail changed in 2.4, to say "does
-   not" instead of "doesn't".
+   passes under Python 2.3 and later Python versions, even though the detail
+   changed in Python 2.4 to say "does not" instead of "doesn't".
+
+   .. versionchanged:: 3.2
+      :const:`IGNORE_EXCEPTION_DETAIL` now also ignores any information
+      relating to the module containing the exception under test
 
 
 .. data:: SKIP
@@ -663,7 +682,6 @@
 functions that run doctests, establishing different defaults.  In such cases,
 disabling an option via ``-`` in a directive can be useful.
 
-
 There's also a way to register new option flag names, although this isn't useful
 unless you intend to extend :mod:`doctest` internals via subclassing:
 

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 14 11:30:15 2010
@@ -159,10 +159,10 @@
 .. function:: fsencode(value)
 
    Encode *value* to bytes for use in the file system, environment variables or
-   the command line. Uses :func:`sys.getfilesystemencoding` and
-   ``'surrogateescape'`` error handler for strings and returns bytes unchanged.
-
-   Availability: Unix.
+   the command line. Use :func:`sys.getfilesystemencoding` and
+   ``'surrogateescape'`` error handler for strings and return bytes unchanged.
+   On Windows, use ``'strict'`` error handler for strings if the file system
+   encoding is ``'mbcs'`` (which is the default encoding).
 
    .. versionadded:: 3.2
 

Modified: python/branches/py3k-cdecimal/Doc/library/struct.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/struct.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/struct.rst	Mon Jun 14 11:30:15 2010
@@ -38,38 +38,38 @@
 
 .. function:: pack(fmt, v1, v2, ...)
 
-   Return a bytes containing the values ``v1, v2, ...`` packed according to the
-   given format.  The arguments must match the values required by the format
-   exactly.
+   Return a bytes object containing the values *v1*, *v2*, ... packed according
+   to the format string *fmt*.  The arguments must match the values required by
+   the format exactly.
 
 
 .. function:: pack_into(fmt, buffer, offset, v1, v2, ...)
 
-   Pack the values ``v1, v2, ...`` according to the given format, write the
-   packed bytes into the writable *buffer* starting at *offset*. Note that the
-   offset is a required argument.
+   Pack the values *v1*, *v2*, ... according to the format string *fmt* and
+   write the packed bytes into the writable buffer *buffer* starting at
+   position *offset*. Note that *offset* is a required argument.
 
 
-.. function:: unpack(fmt, bytes)
+.. function:: unpack(fmt, buffer)
 
-   Unpack the bytes (presumably packed by ``pack(fmt, ...)``) according to the
-   given format.  The result is a tuple even if it contains exactly one item.
-   The bytes must contain exactly the amount of data required by the format
-   (``len(bytes)`` must equal ``calcsize(fmt)``).
+   Unpack from the buffer *buffer* (presumably packed by ``pack(fmt, ...)``)
+   according to the format string *fmt*.  The result is a tuple even if it
+   contains exactly one item.  The buffer must contain exactly the amount of
+   data required by the format (``len(bytes)`` must equal ``calcsize(fmt)``).
 
 
 .. function:: unpack_from(fmt, buffer, offset=0)
 
-   Unpack the *buffer* according to the given format. The result is a tuple even
-   if it contains exactly one item. The *buffer* must contain at least the
-   amount of data required by the format (``len(buffer[offset:])`` must be at
-   least ``calcsize(fmt)``).
+   Unpack from *buffer* starting at position *offset*, according to the format
+   string *fmt*.  The result is a tuple even if it contains exactly one
+   item.  *buffer* must contain at least the amount of data required by the
+   format (``len(buffer[offset:])`` must be at least ``calcsize(fmt)``).
 
 
 .. function:: calcsize(fmt)
 
-   Return the size of the struct (and hence of the bytes) corresponding to the
-   given format.
+   Return the size of the struct (and hence of the bytes object produced by
+   ``pack(fmt, ...)``) corresponding to the format string *fmt*.
 
 .. _struct-format-strings:
 
@@ -77,9 +77,84 @@
 --------------
 
 Format strings are the mechanism used to specify the expected layout when
-packing and unpacking data.  They are built up from format characters, which
-specify the type of data being packed/unpacked.  In addition, there are
-special characters for controlling the byte order, size, and alignment.
+packing and unpacking data.  They are built up from :ref:`format-characters`,
+which specify the type of data being packed/unpacked.  In addition, there are
+special characters for controlling the :ref:`struct-alignment`.
+
+
+.. _struct-alignment:
+
+Byte Order, Size, and Alignment
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+By default, C types are represented in the machine's native format and byte
+order, and properly aligned by skipping pad bytes if necessary (according to the
+rules used by the C compiler).
+
+Alternatively, the first character of the format string can be used to indicate
+the byte order, size and alignment of the packed data, according to the
+following table:
+
++-----------+------------------------+--------------------+
+| Character | Byte order             | Size and alignment |
++===========+========================+====================+
+| ``@``     | native                 | native             |
++-----------+------------------------+--------------------+
+| ``=``     | native                 | standard           |
++-----------+------------------------+--------------------+
+| ``<``     | little-endian          | standard           |
++-----------+------------------------+--------------------+
+| ``>``     | big-endian             | standard           |
++-----------+------------------------+--------------------+
+| ``!``     | network (= big-endian) | standard           |
++-----------+------------------------+--------------------+
+
+If the first character is not one of these, ``'@'`` is assumed.
+
+Native byte order is big-endian or little-endian, depending on the host
+system. For example, Intel x86 and AMD64 (x86-64) are little-endian;
+Motorola 68000 and PowerPC G5 are big-endian; ARM and Intel Itanium feature
+switchable endianness (bi-endian). Use ``sys.byteorder`` to check the
+endianness of your system.
+
+Native size and alignment are determined using the C compiler's
+``sizeof`` expression.  This is always combined with native byte order.
+
+Standard size and alignment are as follows: no alignment is required for any
+type (so you have to use pad bytes); :ctype:`short` is 2 bytes; :ctype:`int` and
+:ctype:`long` are 4 bytes; :ctype:`long long` (:ctype:`__int64` on Windows) is 8
+bytes; :ctype:`float` and :ctype:`double` are 32-bit and 64-bit IEEE floating
+point numbers, respectively. :ctype:`_Bool` is 1 byte.
+
+Note the difference between ``'@'`` and ``'='``: both use native byte order, but
+the size and alignment of the latter is standardized.
+
+The form ``'!'`` is available for those poor souls who claim they can't remember
+whether network byte order is big-endian or little-endian.
+
+There is no way to indicate non-native byte order (force byte-swapping); use the
+appropriate choice of ``'<'`` or ``'>'``.
+
+The ``'P'`` format character is only available for the native byte ordering
+(selected as the default or with the ``'@'`` byte order character). The byte
+order character ``'='`` chooses to use little- or big-endian ordering based on
+the host system. The struct module does not interpret this as native ordering,
+so the ``'P'`` format is not available.
+
+Notes:
+
+(1) Padding is only automatically added between successive structure members.
+    No padding is added at the beginning or the end of the encoded struct.
+
+(2) No padding is added when using non-native size and alignment, e.g.
+    with '<', '>', '=', and '!'.
+
+(3) To align the end of a structure to the alignment requirement of a
+    particular type, end the format with the code for that type with a repeat
+    count of zero.  See :ref:`struct-examples`.
+
+
+.. _format-characters:
 
 Format Characters
 ^^^^^^^^^^^^^^^^^
@@ -87,46 +162,46 @@
 Format characters have the following meaning; the conversion between C and
 Python values should be obvious given their types:
 
-+--------+-------------------------+--------------------+------------+
-| Format | C Type                  | Python             | Notes      |
-+========+=========================+====================+============+
-| ``x``  | pad byte                | no value           |            |
-+--------+-------------------------+--------------------+------------+
-| ``c``  | :ctype:`char`           | bytes of length 1  |            |
-+--------+-------------------------+--------------------+------------+
-| ``b``  | :ctype:`signed char`    | integer            | \(1),\(4)  |
-+--------+-------------------------+--------------------+------------+
-| ``B``  | :ctype:`unsigned char`  | integer            | \(4)       |
-+--------+-------------------------+--------------------+------------+
-| ``?``  | :ctype:`_Bool`          | bool               | \(2)       |
-+--------+-------------------------+--------------------+------------+
-| ``h``  | :ctype:`short`          | integer            | \(4)       |
-+--------+-------------------------+--------------------+------------+
-| ``H``  | :ctype:`unsigned short` | integer            | \(4)       |
-+--------+-------------------------+--------------------+------------+
-| ``i``  | :ctype:`int`            | integer            | \(4)       |
-+--------+-------------------------+--------------------+------------+
-| ``I``  | :ctype:`unsigned int`   | integer            | \(4)       |
-+--------+-------------------------+--------------------+------------+
-| ``l``  | :ctype:`long`           | integer            | \(4)       |
-+--------+-------------------------+--------------------+------------+
-| ``L``  | :ctype:`unsigned long`  | integer            | \(4)       |
-+--------+-------------------------+--------------------+------------+
-| ``q``  | :ctype:`long long`      | integer            | \(3), \(4) |
-+--------+-------------------------+--------------------+------------+
-| ``Q``  | :ctype:`unsigned long   | integer            | \(3), \(4) |
-|        | long`                   |                    |            |
-+--------+-------------------------+--------------------+------------+
-| ``f``  | :ctype:`float`          | float              |            |
-+--------+-------------------------+--------------------+------------+
-| ``d``  | :ctype:`double`         | float              |            |
-+--------+-------------------------+--------------------+------------+
-| ``s``  | :ctype:`char[]`         | bytes              | \(1)       |
-+--------+-------------------------+--------------------+------------+
-| ``p``  | :ctype:`char[]`         | bytes              | \(1)       |
-+--------+-------------------------+--------------------+------------+
-| ``P``  | :ctype:`void \*`        | integer            |            |
-+--------+-------------------------+--------------------+------------+
++--------+-------------------------+--------------------+----------------+------------+
+| Format | C Type                  | Python type        | Standard size  | Notes      |
++========+=========================+====================+================+============+
+| ``x``  | pad byte                | no value           |                |            |
++--------+-------------------------+--------------------+----------------+------------+
+| ``c``  | :ctype:`char`           | bytes of length 1  | 1              |            |
++--------+-------------------------+--------------------+----------------+------------+
+| ``b``  | :ctype:`signed char`    | integer            | 1              | \(1),\(4)  |
++--------+-------------------------+--------------------+----------------+------------+
+| ``B``  | :ctype:`unsigned char`  | integer            | 1              | \(4)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``?``  | :ctype:`_Bool`          | bool               | 1              | \(2)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``h``  | :ctype:`short`          | integer            | 2              | \(4)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``H``  | :ctype:`unsigned short` | integer            | 2              | \(4)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``i``  | :ctype:`int`            | integer            | 4              | \(4)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``I``  | :ctype:`unsigned int`   | integer            | 4              | \(4)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``l``  | :ctype:`long`           | integer            | 4              | \(4)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``L``  | :ctype:`unsigned long`  | integer            | 4              | \(4)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``q``  | :ctype:`long long`      | integer            | 8              | \(3), \(4) |
++--------+-------------------------+--------------------+----------------+------------+
+| ``Q``  | :ctype:`unsigned long   | integer            | 8              | \(3), \(4) |
+|        | long`                   |                    |                |            |
++--------+-------------------------+--------------------+----------------+------------+
+| ``f``  | :ctype:`float`          | float              | 4              |            |
++--------+-------------------------+--------------------+----------------+------------+
+| ``d``  | :ctype:`double`         | float              | 8              |            |
++--------+-------------------------+--------------------+----------------+------------+
+| ``s``  | :ctype:`char[]`         | bytes              |                | \(1)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``p``  | :ctype:`char[]`         | bytes              |                | \(1)       |
++--------+-------------------------+--------------------+----------------+------------+
+| ``P``  | :ctype:`void \*`        | integer            |                |            |
++--------+-------------------------+--------------------+----------------+------------+
 
 Notes:
 
@@ -196,77 +271,6 @@
 any non-zero value will be True when unpacking.
 
 
-.. _struct-alignment:
-
-Byte Order, Size, and Alignment
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-By default, C types are represented in the machine's native format and byte
-order, and properly aligned by skipping pad bytes if necessary (according to the
-rules used by the C compiler).
-
-Alternatively, the first character of the format string can be used to indicate
-the byte order, size and alignment of the packed data, according to the
-following table:
-
-+-----------+------------------------+--------------------+
-| Character | Byte order             | Size and alignment |
-+===========+========================+====================+
-| ``@``     | native                 | native             |
-+-----------+------------------------+--------------------+
-| ``=``     | native                 | standard           |
-+-----------+------------------------+--------------------+
-| ``<``     | little-endian          | standard           |
-+-----------+------------------------+--------------------+
-| ``>``     | big-endian             | standard           |
-+-----------+------------------------+--------------------+
-| ``!``     | network (= big-endian) | standard           |
-+-----------+------------------------+--------------------+
-
-If the first character is not one of these, ``'@'`` is assumed.
-
-Native byte order is big-endian or little-endian, depending on the host
-system. For example, Intel x86 and AMD64 (x86-64) are little-endian;
-Motorola 68000 and PowerPC G5 are big-endian; ARM and Intel Itanium feature
-switchable endianness (bi-endian). Use ``sys.byteorder`` to check the
-endianness of your system.
-
-Native size and alignment are determined using the C compiler's
-``sizeof`` expression.  This is always combined with native byte order.
-
-Standard size and alignment are as follows: no alignment is required for any
-type (so you have to use pad bytes); :ctype:`short` is 2 bytes; :ctype:`int` and
-:ctype:`long` are 4 bytes; :ctype:`long long` (:ctype:`__int64` on Windows) is 8
-bytes; :ctype:`float` and :ctype:`double` are 32-bit and 64-bit IEEE floating
-point numbers, respectively. :ctype:`_Bool` is 1 byte.
-
-Note the difference between ``'@'`` and ``'='``: both use native byte order, but
-the size and alignment of the latter is standardized.
-
-The form ``'!'`` is available for those poor souls who claim they can't remember
-whether network byte order is big-endian or little-endian.
-
-There is no way to indicate non-native byte order (force byte-swapping); use the
-appropriate choice of ``'<'`` or ``'>'``.
-
-The ``'P'`` format character is only available for the native byte ordering
-(selected as the default or with the ``'@'`` byte order character). The byte
-order character ``'='`` chooses to use little- or big-endian ordering based on
-the host system. The struct module does not interpret this as native ordering,
-so the ``'P'`` format is not available.
-
-Notes:
-
-(1) Padding is only automatically added between successive structure members.
-    No padding is added at the beginning or the end of the encoded struct.
-
-(2) No padding is added when using non-native size and alignment, e.g.
-    with '<', '>', '=', and '!'.
-
-(3) To align the end of a structure to the alignment requirement of a
-    particular type, end the format with the code for that type with a repeat
-    count of zero.  See :ref:`struct-examples`.
-
 
 .. _struct-examples:
 
@@ -331,7 +335,7 @@
 
 .. _struct-objects:
 
-Objects
+Classes
 -------
 
 The :mod:`struct` module also defines the following type:
@@ -358,10 +362,10 @@
       Identical to the :func:`pack_into` function, using the compiled format.
 
 
-   .. method:: unpack(bytes)
+   .. method:: unpack(buffer)
 
       Identical to the :func:`unpack` function, using the compiled format.
-      (``len(bytes)`` must equal :attr:`self.size`).
+      (``len(buffer)`` must equal :attr:`self.size`).
 
 
    .. method:: unpack_from(buffer, offset=0)
@@ -376,6 +380,6 @@
 
    .. attribute:: size
 
-      The calculated size of the struct (and hence of the bytes) corresponding
-      to :attr:`format`.
+      The calculated size of the struct (and hence of the bytes object produced
+      by the :meth:`pack` method) corresponding to :attr:`format`.
 

Modified: python/branches/py3k-cdecimal/Doc/library/tarfile.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/tarfile.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/tarfile.rst	Mon Jun 14 11:30:15 2010
@@ -185,8 +185,8 @@
 
 .. data:: ENCODING
 
-   The default character encoding i.e. the value from either
-   :func:`sys.getfilesystemencoding` or :func:`sys.getdefaultencoding`.
+   The default character encoding: ``'utf-8'`` on Windows,
+   :func:`sys.getfilesystemencoding` otherwise.
 
 
 .. seealso::

Modified: python/branches/py3k-cdecimal/Doc/library/xml.dom.minidom.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/xml.dom.minidom.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/xml.dom.minidom.rst	Mon Jun 14 11:30:15 2010
@@ -114,6 +114,13 @@
    to be called on the :class:`Document` object, but may be called on child nodes
    to discard children of that node.
 
+   You can avoid calling this method explicitly by using the :keyword:`with`
+   statement. The following code will automatically unlink *dom* when the
+   :keyword:`with` block is exited::
+
+      with xml.dom.minidom.parse(datasource) as dom:
+          ... # Work with dom.
+
 
 .. method:: Node.writexml(writer, indent="", addindent="", newl="", encoding="")
 

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 14 11:30:15 2010
@@ -173,4 +173,7 @@
 
 * bytearray objects cannot be used anymore as filenames: convert them to bytes
 
+* "t#" format of PyArg_Parse*() functions has been removed: use "s#" or "s*"
+  instead
+
 * Stub

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 14 11:30:15 2010
@@ -101,13 +101,13 @@
 */
 PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
 
-/* _PyLong_Divmod_Near.  Given integers a and b, compute the nearest
+/* _PyLong_DivmodNear.  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 *);
+PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(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.

Modified: python/branches/py3k-cdecimal/Lib/ctypes/test/test_bytes.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/ctypes/test/test_bytes.py	(original)
+++ python/branches/py3k-cdecimal/Lib/ctypes/test/test_bytes.py	Mon Jun 14 11:30:15 2010
@@ -30,8 +30,8 @@
 
         X("abc")
         x = X(b"abc")
-        self.assertEqual(x.a, "abc")
-        self.assertEqual(type(x.a), str)
+        self.assertEqual(x.a, b"abc")
+        self.assertEqual(type(x.a), bytes)
 
     def test_struct_W(self):
         class X(Structure):

Modified: python/branches/py3k-cdecimal/Lib/ctypes/test/test_structures.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/ctypes/test/test_structures.py	(original)
+++ python/branches/py3k-cdecimal/Lib/ctypes/test/test_structures.py	Mon Jun 14 11:30:15 2010
@@ -209,9 +209,9 @@
         self.assertRaises(TypeError, Person, "Name", "HI")
 
         # short enough
-        self.assertEqual(Person("12345", 5).name, "12345")
+        self.assertEqual(Person("12345", 5).name, b"12345")
         # exact fit
-        self.assertEqual(Person("123456", 5).name, "123456")
+        self.assertEqual(Person("123456", 5).name, b"123456")
         # too long
         self.assertRaises(ValueError, Person, "1234567", 5)
 
@@ -269,9 +269,9 @@
 
         p = Person("Someone", ("1234", "5678"), 5)
 
-        self.assertEqual(p.name, "Someone")
-        self.assertEqual(p.phone.areacode, "1234")
-        self.assertEqual(p.phone.number, "5678")
+        self.assertEqual(p.name, b"Someone")
+        self.assertEqual(p.phone.areacode, b"1234")
+        self.assertEqual(p.phone.number, b"5678")
         self.assertEqual(p.age, 5)
 
     def test_structures_with_wchar(self):

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 14 11:30:15 2010
@@ -31,7 +31,8 @@
 useful for financial applications or for contexts where users have
 expectations that are at odds with binary floating point (for instance,
 in binary floating point, 1.00 % 0.1 gives 0.09999999999999995 instead
-of the expected Decimal('0.00') returned by decimal floating point).
+of 0.0; Decimal('1.00') % Decimal('0.1') returns the expected
+Decimal('0.00')).
 
 Here are some examples of using the decimal module:
 
@@ -862,7 +863,7 @@
     # that specified by IEEE 754.
 
     def __eq__(self, other, context=None):
-        other = _convert_other(other, allow_float = True)
+        self, other = _convert_for_comparison(self, other, equality_op=True)
         if other is NotImplemented:
             return other
         if self._check_nans(other, context):
@@ -870,7 +871,7 @@
         return self._cmp(other) == 0
 
     def __ne__(self, other, context=None):
-        other = _convert_other(other, allow_float = True)
+        self, other = _convert_for_comparison(self, other, equality_op=True)
         if other is NotImplemented:
             return other
         if self._check_nans(other, context):
@@ -879,7 +880,7 @@
 
 
     def __lt__(self, other, context=None):
-        other = _convert_other(other, allow_float = True)
+        self, other = _convert_for_comparison(self, other)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -888,7 +889,7 @@
         return self._cmp(other) < 0
 
     def __le__(self, other, context=None):
-        other = _convert_other(other, allow_float = True)
+        self, other = _convert_for_comparison(self, other)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -897,7 +898,7 @@
         return self._cmp(other) <= 0
 
     def __gt__(self, other, context=None):
-        other = _convert_other(other, allow_float = True)
+        self, other = _convert_for_comparison(self, other)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -906,7 +907,7 @@
         return self._cmp(other) > 0
 
     def __ge__(self, other, context=None):
-        other = _convert_other(other, allow_float = True)
+        self, other = _convert_for_comparison(self, other)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -5860,6 +5861,37 @@
         raise TypeError("Unable to convert %s to Decimal" % other)
     return NotImplemented
 
+def _convert_for_comparison(self, other, equality_op=False):
+    """Given a Decimal instance self and a Python object other, return
+    a pair (s, o) of Decimal instances such that "s op o" is
+    equivalent to "self op other" for any of the 6 comparison
+    operators "op".
+
+    """
+    if isinstance(other, Decimal):
+        return self, other
+
+    # Comparison with a Rational instance (also includes integers):
+    # self op n/d <=> self*d op n (for n and d integers, d positive).
+    # A NaN or infinity can be left unchanged without affecting the
+    # comparison result.
+    if isinstance(other, _numbers.Rational):
+        if not self._is_special:
+            self = _dec_from_triple(self._sign,
+                                    str(int(self._int) * other.denominator),
+                                    self._exp)
+        return self, Decimal(other.numerator)
+
+    # Comparisons with float and complex types.  == and != comparisons
+    # with complex numbers should succeed, returning either True or False
+    # as appropriate.  Other comparisons return NotImplemented.
+    if equality_op and isinstance(other, _numbers.Complex) and other.imag == 0:
+        other = other.real
+    if isinstance(other, float):
+        return self, Decimal.from_float(other)
+    return NotImplemented, NotImplemented
+
+
 ##### Setup Specific Contexts ############################################
 
 # The default context prototype used by Context()

Modified: python/branches/py3k-cdecimal/Lib/doctest.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/doctest.py	(original)
+++ python/branches/py3k-cdecimal/Lib/doctest.py	Mon Jun 14 11:30:15 2010
@@ -1277,9 +1277,9 @@
 
                 # Another chance if they didn't care about the detail.
                 elif self.optionflags & IGNORE_EXCEPTION_DETAIL:
-                    m1 = re.match(r'[^:]*:', example.exc_msg)
-                    m2 = re.match(r'[^:]*:', exc_msg)
-                    if m1 and m2 and check(m1.group(0), m2.group(0),
+                    m1 = re.match(r'(?:[^:]*\.)?([^:]*:)', example.exc_msg)
+                    m2 = re.match(r'(?:[^:]*\.)?([^:]*:)', exc_msg)
+                    if m1 and m2 and check(m1.group(1), m2.group(1),
                                            self.optionflags):
                         outcome = SUCCESS
 

Modified: python/branches/py3k-cdecimal/Lib/logging/config.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/logging/config.py	(original)
+++ python/branches/py3k-cdecimal/Lib/logging/config.py	Mon Jun 14 11:30:15 2010
@@ -373,7 +373,7 @@
     }
 
     # We might want to use a different one, e.g. importlib
-    importer = __import__
+    importer = staticmethod(__import__)
 
     def __init__(self, config):
         self.config = ConvertingDict(config)

Modified: python/branches/py3k-cdecimal/Lib/os.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/os.py	(original)
+++ python/branches/py3k-cdecimal/Lib/os.py	Mon Jun 14 11:30:15 2010
@@ -533,16 +533,19 @@
         return environb.get(key, default)
     __all__.append("getenvb")
 
-if name != 'nt':
-    def fsencode(value):
-        """Encode value for use in the file system, environment variables
-        or the command line."""
-        if isinstance(value, bytes):
-            return value
-        elif isinstance(value, str):
-            return value.encode(sys.getfilesystemencoding(), 'surrogateescape')
+def fsencode(value):
+    """Encode value for use in the file system, environment variables
+    or the command line."""
+    if isinstance(value, bytes):
+        return value
+    elif isinstance(value, str):
+        encoding = sys.getfilesystemencoding()
+        if encoding == 'mbcs':
+            return value.encode(encoding)
         else:
-            raise TypeError("expect bytes or str, not %s" % type(value).__name__)
+            return value.encode(encoding, 'surrogateescape')
+    else:
+        raise TypeError("expect bytes or str, not %s" % type(value).__name__)
 
 def _exists(name):
     return name in globals()

Modified: python/branches/py3k-cdecimal/Lib/struct.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/struct.py	(original)
+++ python/branches/py3k-cdecimal/Lib/struct.py	Mon Jun 14 11:30:15 2010
@@ -1,3 +1,14 @@
+__all__ = [
+    # Functions
+    'calcsize', 'pack', 'unpack', 'unpack', 'unpack_from',
+
+    # Classes
+    'Struct',
+
+    # Exceptions
+    'error'
+    ]
+
 from _struct import *
 from _struct import _clearcache
 from _struct import __doc__

Modified: python/branches/py3k-cdecimal/Lib/sunau.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/sunau.py	(original)
+++ python/branches/py3k-cdecimal/Lib/sunau.py	Mon Jun 14 11:30:15 2010
@@ -299,7 +299,7 @@
         self._nframeswritten = 0
         self._datawritten = 0
         self._datalength = 0
-        self._info = ''
+        self._info = b''
         self._comptype = 'ULAW' # default is U-law
 
     def setnchannels(self, nchannels):

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 14 11:30:15 2010
@@ -159,9 +159,10 @@
 #---------------------------------------------------------
 # initialization
 #---------------------------------------------------------
-ENCODING = sys.getfilesystemencoding()
-if ENCODING is None:
-    ENCODING = "ascii"
+if os.name in ("nt", "ce"):
+    ENCODING = "utf-8"
+else:
+    ENCODING = sys.getfilesystemencoding()
 
 #---------------------------------------------------------
 # Some useful functions

Modified: python/branches/py3k-cdecimal/Lib/test/math_testcases.txt
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/math_testcases.txt	(original)
+++ python/branches/py3k-cdecimal/Lib/test/math_testcases.txt	Mon Jun 14 11:30:15 2010
@@ -84,6 +84,25 @@
 erf0042 erf -1e150 -> -1.0
 erf0043 erf 1.7e308 -> 1.0
 
+-- Issue 8986: inputs x with exp(-x*x) near the underflow threshold
+-- incorrectly signalled overflow on some platforms.
+erf0100 erf 26.2 -> 1.0
+erf0101 erf 26.4 -> 1.0
+erf0102 erf 26.6 -> 1.0
+erf0103 erf 26.8 -> 1.0
+erf0104 erf 27.0 -> 1.0
+erf0105 erf 27.2 -> 1.0
+erf0106 erf 27.4 -> 1.0
+erf0107 erf 27.6 -> 1.0
+
+erf0110 erf -26.2 -> -1.0
+erf0111 erf -26.4 -> -1.0
+erf0112 erf -26.6 -> -1.0
+erf0113 erf -26.8 -> -1.0
+erf0114 erf -27.0 -> -1.0
+erf0115 erf -27.2 -> -1.0
+erf0116 erf -27.4 -> -1.0
+erf0117 erf -27.6 -> -1.0
 
 ----------------------------------------
 -- erfc: complementary error function --
@@ -127,6 +146,25 @@
 erfc0052 erfc -1e150 -> 2.0
 erfc0053 erfc 1.7e308 -> 0.0
 
+-- Issue 8986: inputs x with exp(-x*x) near the underflow threshold
+-- incorrectly signalled overflow on some platforms.
+erfc0100 erfc 26.2 -> 1.6432507924389461e-300
+erfc0101 erfc 26.4 -> 4.4017768588035426e-305
+erfc0102 erfc 26.6 -> 1.0885125885442269e-309
+erfc0103 erfc 26.8 -> 2.4849621571966629e-314
+erfc0104 erfc 27.0 -> 5.2370464393526292e-319
+erfc0105 erfc 27.2 -> 9.8813129168249309e-324
+erfc0106 erfc 27.4 -> 0.0
+erfc0107 erfc 27.6 -> 0.0
+
+erfc0110 erfc -26.2 -> 2.0
+erfc0111 erfc -26.4 -> 2.0
+erfc0112 erfc -26.6 -> 2.0
+erfc0113 erfc -26.8 -> 2.0
+erfc0114 erfc -27.0 -> 2.0
+erfc0115 erfc -27.2 -> 2.0
+erfc0116 erfc -27.4 -> 2.0
+erfc0117 erfc -27.6 -> 2.0
 
 ---------------------------------------------------------
 -- lgamma: log of absolute value of the gamma function --

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 14 11:30:15 2010
@@ -859,9 +859,15 @@
         sys.path_hooks[:] = saved_hooks[2]
 
     def get___import__(self):
-        return __builtins__.__import__
+        if isinstance(__builtins__, dict):
+            return __builtins__['__import__']
+        else:
+            return __builtins__.__import__
     def restore___import__(self, import_):
-        __builtins__.__import__ = import_
+        if isinstance(__builtins__, dict):
+            __builtins__['__import__'] = import_
+        else:
+            __builtins__.__import__ = import_
 
     def get_warnings_filters(self):
         return id(warnings.filters), warnings.filters, warnings.filters[:]

Modified: python/branches/py3k-cdecimal/Lib/test/test_capi.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_capi.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_capi.py	Mon Jun 14 11:30:15 2010
@@ -36,6 +36,7 @@
         self.assertEqual(testfunction.attribute, "test")
         self.assertRaises(AttributeError, setattr, inst.testfunction, "attribute", "test")
 
+    @unittest.skipUnless(threading, 'Threading required for this test.')
     def test_no_FatalError_infinite_loop(self):
         p = subprocess.Popen([sys.executable, "-c",
                               'import _testcapi;'

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 14 11:30:15 2010
@@ -72,7 +72,6 @@
         # check that there's nothing left in the buffers
         self.assertEqual(r.read(), "")
         self.assertEqual(r.bytebuffer, b"")
-        self.assertEqual(r.charbuffer, "")
 
         # do the check again, this time using a incremental decoder
         d = codecs.getincrementaldecoder(self.encoding)()
@@ -354,6 +353,16 @@
         self.check_state_handling_decode(self.encoding,
                                          "spamspam", self.spambe)
 
+    def test_issue8941(self):
+        # Issue #8941: insufficient result allocation when decoding into
+        # surrogate pairs on UCS-2 builds.
+        encoded_le = b'\xff\xfe\x00\x00' + b'\x00\x00\x01\x00' * 1024
+        self.assertEqual('\U00010000' * 1024,
+                         codecs.utf_32_decode(encoded_le)[0])
+        encoded_be = b'\x00\x00\xfe\xff' + b'\x00\x01\x00\x00' * 1024
+        self.assertEqual('\U00010000' * 1024,
+                         codecs.utf_32_decode(encoded_be)[0])
+
 class UTF32LETest(ReadTest):
     encoding = "utf-32-le"
 
@@ -387,6 +396,13 @@
         self.assertRaises(UnicodeDecodeError, codecs.utf_32_le_decode,
                           b"\xff", "strict", True)
 
+    def test_issue8941(self):
+        # Issue #8941: insufficient result allocation when decoding into
+        # surrogate pairs on UCS-2 builds.
+        encoded = b'\x00\x00\x01\x00' * 1024
+        self.assertEqual('\U00010000' * 1024,
+                         codecs.utf_32_le_decode(encoded)[0])
+
 class UTF32BETest(ReadTest):
     encoding = "utf-32-be"
 
@@ -420,6 +436,14 @@
         self.assertRaises(UnicodeDecodeError, codecs.utf_32_be_decode,
                           b"\xff", "strict", True)
 
+    def test_issue8941(self):
+        # Issue #8941: insufficient result allocation when decoding into
+        # surrogate pairs on UCS-2 builds.
+        encoded = b'\x00\x01\x00\x00' * 1024
+        self.assertEqual('\U00010000' * 1024,
+                         codecs.utf_32_be_decode(encoded)[0])
+
+
 class UTF16Test(ReadTest):
     encoding = "utf-16"
 
@@ -628,18 +652,6 @@
         self.assertRaises(TypeError, codecs.readbuffer_encode)
         self.assertRaises(TypeError, codecs.readbuffer_encode, 42)
 
-class CharBufferTest(unittest.TestCase):
-
-    def test_string(self):
-        self.assertEqual(codecs.charbuffer_encode(b"spam"), (b"spam", 4))
-
-    def test_empty(self):
-        self.assertEqual(codecs.charbuffer_encode(b""), (b"", 0))
-
-    def test_bad_args(self):
-        self.assertRaises(TypeError, codecs.charbuffer_encode)
-        self.assertRaises(TypeError, codecs.charbuffer_encode, 42)
-
 class UTF8SigTest(ReadTest):
     encoding = "utf-8-sig"
 
@@ -1663,7 +1675,6 @@
         UTF7Test,
         UTF16ExTest,
         ReadBufferTest,
-        CharBufferTest,
         RecodingTest,
         PunycodeTest,
         UnicodeInternalTest,

Modified: python/branches/py3k-cdecimal/Lib/test/test_curses.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_curses.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_curses.py	Mon Jun 14 11:30:15 2010
@@ -23,11 +23,6 @@
 curses = import_module('curses')
 curses.panel = import_module('curses.panel')
 
-# skip all these tests on FreeBSD: test_curses currently hangs the
-# FreeBSD buildbots, preventing other tests from running.  See issue
-# #7384.
-if 'freebsd' in sys.platform:
-    raise unittest.SkipTest('The curses module is broken on FreeBSD.  See http://bugs.python.org/issue7384.')
 
 # XXX: if newterm was supported we could use it instead of initscr and not exit
 term = os.environ.get('TERM')

Modified: python/branches/py3k-cdecimal/Lib/test/test_doctest.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_doctest.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_doctest.py	Mon Jun 14 11:30:15 2010
@@ -864,6 +864,77 @@
     >>> doctest.DocTestRunner(verbose=False).run(test)
     TestResults(failed=0, attempted=1)
 
+IGNORE_EXCEPTION_DETAIL also ignores difference in exception formatting
+between Python versions. For example, in Python 2.x, the module path of
+the exception is not in the output, but this will fail under Python 3:
+
+    >>> def f(x):
+    ...     r'''
+    ...     >>> from http.client import HTTPException
+    ...     >>> raise HTTPException('message')
+    ...     Traceback (most recent call last):
+    ...     HTTPException: message
+    ...     '''
+    >>> test = doctest.DocTestFinder().find(f)[0]
+    >>> doctest.DocTestRunner(verbose=False).run(test)
+    ... # doctest: +ELLIPSIS
+    **********************************************************************
+    File ..., line 4, in f
+    Failed example:
+        raise HTTPException('message')
+    Expected:
+        Traceback (most recent call last):
+        HTTPException: message
+    Got:
+        Traceback (most recent call last):
+        ...
+        http.client.HTTPException: message
+    TestResults(failed=1, attempted=2)
+
+But in Python 3 the module path is included, and therefore a test must look
+like the following test to succeed in Python 3. But that test will fail under
+Python 2.
+
+    >>> def f(x):
+    ...     r'''
+    ...     >>> from http.client import HTTPException
+    ...     >>> raise HTTPException('message')
+    ...     Traceback (most recent call last):
+    ...     http.client.HTTPException: message
+    ...     '''
+    >>> test = doctest.DocTestFinder().find(f)[0]
+    >>> doctest.DocTestRunner(verbose=False).run(test)
+    TestResults(failed=0, attempted=2)
+
+However, with IGNORE_EXCEPTION_DETAIL, the module name of the exception
+(or its unexpected absence) will be ignored:
+
+    >>> def f(x):
+    ...     r'''
+    ...     >>> from http.client import HTTPException
+    ...     >>> raise HTTPException('message') #doctest: +IGNORE_EXCEPTION_DETAIL
+    ...     Traceback (most recent call last):
+    ...     HTTPException: message
+    ...     '''
+    >>> test = doctest.DocTestFinder().find(f)[0]
+    >>> doctest.DocTestRunner(verbose=False).run(test)
+    TestResults(failed=0, attempted=2)
+
+The module path will be completely ignored, so two different module paths will
+still pass if IGNORE_EXCEPTION_DETAIL is given. This is intentional, so it can
+be used when exceptions have changed module.
+
+    >>> def f(x):
+    ...     r'''
+    ...     >>> from http.client import HTTPException
+    ...     >>> raise HTTPException('message') #doctest: +IGNORE_EXCEPTION_DETAIL
+    ...     Traceback (most recent call last):
+    ...     foo.bar.HTTPException: message
+    ...     '''
+    >>> test = doctest.DocTestFinder().find(f)[0]
+    >>> doctest.DocTestRunner(verbose=False).run(test)
+    TestResults(failed=0, attempted=2)
+
 But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
 
     >>> def f(x):

Modified: python/branches/py3k-cdecimal/Lib/test/test_fractions.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_fractions.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_fractions.py	Mon Jun 14 11:30:15 2010
@@ -395,12 +395,11 @@
         self.assertTypedEquals(1.0 + 0j, (1.0 + 0j) ** F(1, 10))
 
     def testMixingWithDecimal(self):
-        # Decimal refuses mixed comparisons.
+        # Decimal refuses mixed arithmetic (but not mixed comparisons)
         self.assertRaisesMessage(
             TypeError,
             "unsupported operand type(s) for +: 'Fraction' and 'Decimal'",
             operator.add, F(3,11), Decimal('3.1415926'))
-        self.assertNotEquals(F(5, 2), Decimal('2.5'))
 
     def testComparisons(self):
         self.assertTrue(F(1, 2) < F(2, 3))

Modified: python/branches/py3k-cdecimal/Lib/test/test_getargs2.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_getargs2.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_getargs2.py	Mon Jun 14 11:30:15 2010
@@ -1,7 +1,6 @@
 import unittest
 from test import support
 from _testcapi import getargs_keywords
-import warnings
 
 """
 > How about the following counterproposal. This also changes some of
@@ -190,21 +189,7 @@
         from _testcapi import getargs_L
         # L returns 'long long', and does range checking (LLONG_MIN
         # ... LLONG_MAX)
-        with warnings.catch_warnings():
-            warnings.filterwarnings(
-                "ignore",
-                category=DeprecationWarning,
-                message=".*integer argument expected, got float",
-                module=__name__)
-            self.assertEqual(3, getargs_L(3.14))
-        with warnings.catch_warnings():
-            warnings.filterwarnings(
-                "error",
-                category=DeprecationWarning,
-                message=".*integer argument expected, got float",
-                module="unittest")
-            self.assertRaises(DeprecationWarning, getargs_L, 3.14)
-
+        self.assertRaises(TypeError, getargs_L, 3.14)
         self.assertRaises(TypeError, getargs_L, "Hello")
         self.assertEqual(99, getargs_L(Int()))
 
@@ -308,8 +293,136 @@
         else:
             self.fail('TypeError should have been raised')
 
+class Bytes_TestCase(unittest.TestCase):
+    def test_s(self):
+        from _testcapi import getargs_s
+        self.assertEqual(getargs_s('abc\xe9'), b'abc\xc3\xa9')
+        self.assertRaises(TypeError, getargs_s, 'nul:\0')
+        self.assertRaises(TypeError, getargs_s, b'bytes')
+        self.assertRaises(TypeError, getargs_s, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_s, memoryview(b'memoryview'))
+        self.assertRaises(TypeError, getargs_s, None)
+
+    def test_s_star(self):
+        from _testcapi import getargs_s_star
+        self.assertEqual(getargs_s_star('abc\xe9'), b'abc\xc3\xa9')
+        self.assertEqual(getargs_s_star('nul:\0'), b'nul:\0')
+        self.assertEqual(getargs_s_star(b'bytes'), b'bytes')
+        self.assertEqual(getargs_s_star(bytearray(b'bytearray')), b'bytearray')
+        self.assertEqual(getargs_s_star(memoryview(b'memoryview')), b'memoryview')
+        self.assertRaises(TypeError, getargs_s_star, None)
+
+    def test_s_hash(self):
+        from _testcapi import getargs_s_hash
+        self.assertEqual(getargs_s_hash('abc\xe9'), b'abc\xc3\xa9')
+        self.assertEqual(getargs_s_hash('nul:\0'), b'nul:\0')
+        self.assertEqual(getargs_s_hash(b'bytes'), b'bytes')
+        self.assertRaises(TypeError, getargs_s_hash, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_s_hash, memoryview(b'memoryview'))
+        self.assertRaises(TypeError, getargs_s_hash, None)
+
+    def test_z(self):
+        from _testcapi import getargs_z
+        self.assertEqual(getargs_z('abc\xe9'), b'abc\xc3\xa9')
+        self.assertRaises(TypeError, getargs_z, 'nul:\0')
+        self.assertEqual(getargs_z(b'bytes'), b'bytes')
+        self.assertRaises(TypeError, getargs_z, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_z, memoryview(b'memoryview'))
+        self.assertIsNone(getargs_z(None))
+
+    def test_z_star(self):
+        from _testcapi import getargs_z_star
+        self.assertEqual(getargs_z_star('abc\xe9'), b'abc\xc3\xa9')
+        self.assertEqual(getargs_z_star('nul:\0'), b'nul:\0')
+        self.assertEqual(getargs_z_star(b'bytes'), b'bytes')
+        self.assertEqual(getargs_z_star(bytearray(b'bytearray')), b'bytearray')
+        self.assertEqual(getargs_z_star(memoryview(b'memoryview')), b'memoryview')
+        self.assertIsNone(getargs_z_star(None))
+
+    def test_z_hash(self):
+        from _testcapi import getargs_z_hash
+        self.assertEqual(getargs_z_hash('abc\xe9'), b'abc\xc3\xa9')
+        self.assertEqual(getargs_z_hash('nul:\0'), b'nul:\0')
+        self.assertEqual(getargs_z_hash(b'bytes'), b'bytes')
+        self.assertRaises(TypeError, getargs_z_hash, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_z_hash, memoryview(b'memoryview'))
+        self.assertIsNone(getargs_z_hash(None))
+
+    def test_y(self):
+        from _testcapi import getargs_y
+        self.assertRaises(TypeError, getargs_y, 'abc\xe9')
+        self.assertEqual(getargs_y(b'bytes'), b'bytes')
+        self.assertRaises(TypeError, getargs_y, b'nul:\0')
+        self.assertRaises(TypeError, getargs_y, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_y, memoryview(b'memoryview'))
+        self.assertRaises(TypeError, getargs_y, None)
+
+    def test_y_star(self):
+        from _testcapi import getargs_y_star
+        self.assertRaises(TypeError, getargs_y_star, 'abc\xe9')
+        self.assertEqual(getargs_y_star(b'bytes'), b'bytes')
+        self.assertEqual(getargs_y_star(b'nul:\0'), b'nul:\0')
+        self.assertEqual(getargs_y_star(bytearray(b'bytearray')), b'bytearray')
+        self.assertEqual(getargs_y_star(memoryview(b'memoryview')), b'memoryview')
+        self.assertRaises(TypeError, getargs_y_star, None)
+
+    def test_y_hash(self):
+        from _testcapi import getargs_y_hash
+        self.assertRaises(TypeError, getargs_y_hash, 'abc\xe9')
+        self.assertEqual(getargs_y_hash(b'bytes'), b'bytes')
+        self.assertEqual(getargs_y_hash(b'nul:\0'), b'nul:\0')
+        self.assertRaises(TypeError, getargs_y_hash, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_y_hash, memoryview(b'memoryview'))
+        self.assertRaises(TypeError, getargs_y_hash, None)
+
+
+class Unicode_TestCase(unittest.TestCase):
+    def test_u(self):
+        from _testcapi import getargs_u
+        self.assertEqual(getargs_u('abc\xe9'), 'abc\xe9')
+        self.assertRaises(TypeError, getargs_u, 'nul:\0')
+        self.assertRaises(TypeError, getargs_u, b'bytes')
+        self.assertRaises(TypeError, getargs_u, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_u, memoryview(b'memoryview'))
+        self.assertRaises(TypeError, getargs_u, None)
+
+    def test_u_hash(self):
+        from _testcapi import getargs_u_hash
+        self.assertEqual(getargs_u_hash('abc\xe9'), 'abc\xe9')
+        self.assertEqual(getargs_u_hash('nul:\0'), 'nul:\0')
+        self.assertRaises(TypeError, getargs_u_hash, b'bytes')
+        self.assertRaises(TypeError, getargs_u_hash, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_u_hash, memoryview(b'memoryview'))
+        self.assertRaises(TypeError, getargs_u_hash, None)
+
+    def test_Z(self):
+        from _testcapi import getargs_Z
+        self.assertEqual(getargs_Z('abc\xe9'), 'abc\xe9')
+        self.assertRaises(TypeError, getargs_Z, 'nul:\0')
+        self.assertRaises(TypeError, getargs_Z, b'bytes')
+        self.assertRaises(TypeError, getargs_Z, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_Z, memoryview(b'memoryview'))
+        self.assertIsNone(getargs_Z(None))
+
+    def test_Z_hash(self):
+        from _testcapi import getargs_Z_hash
+        self.assertEqual(getargs_Z_hash('abc\xe9'), 'abc\xe9')
+        self.assertEqual(getargs_Z_hash('nul:\0'), 'nul:\0')
+        self.assertRaises(TypeError, getargs_Z_hash, b'bytes')
+        self.assertRaises(TypeError, getargs_Z_hash, bytearray(b'bytearray'))
+        self.assertRaises(TypeError, getargs_Z_hash, memoryview(b'memoryview'))
+        self.assertIsNone(getargs_Z_hash(None))
+
+
 def test_main():
-    tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase, Keywords_TestCase]
+    tests = [
+        Signed_TestCase,
+        Unsigned_TestCase,
+        Tuple_TestCase,
+        Keywords_TestCase,
+        Bytes_TestCase,
+        Unicode_TestCase,
+    ]
     try:
         from _testcapi import getargs_L, getargs_K
     except ImportError:

Modified: python/branches/py3k-cdecimal/Lib/test/test_math.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_math.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_math.py	Mon Jun 14 11:30:15 2010
@@ -1042,6 +1042,15 @@
                         accuracy_failure = acc_check(expected, got,
                                                   rel_err = 5e-15,
                                                   abs_err = 5e-15)
+                    elif fn == 'erfc':
+                        # erfc has less-than-ideal accuracy for large
+                        # arguments (x ~ 25 or so), mainly due to the
+                        # error involved in computing exp(-x*x).
+                        #
+                        # XXX Would be better to weaken this test only
+                        # for large x, instead of for all x.
+                        accuracy_failure = ulps_check(expected, got, 2000)
+
                     else:
                         accuracy_failure = ulps_check(expected, got, 20)
                     if accuracy_failure is None:

Modified: python/branches/py3k-cdecimal/Lib/test/test_minidom.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_minidom.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_minidom.py	Mon Jun 14 11:30:15 2010
@@ -228,7 +228,14 @@
 
     def testUnlink(self):
         dom = parse(tstfile)
+        self.assertTrue(dom.childNodes)
         dom.unlink()
+        self.assertFalse(dom.childNodes)
+
+    def testContext(self):
+        with parse(tstfile) as dom:
+            self.assertTrue(dom.childNodes)
+        self.assertFalse(dom.childNodes)
 
     def testElement(self):
         dom = Document()

Modified: python/branches/py3k-cdecimal/Lib/test/test_numeric_tower.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_numeric_tower.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_numeric_tower.py	Mon Jun 14 11:30:15 2010
@@ -143,9 +143,64 @@
         x = {'halibut', HalibutProxy()}
         self.assertEqual(len(x), 1)
 
+class ComparisonTest(unittest.TestCase):
+    def test_mixed_comparisons(self):
+
+        # ordered list of distinct test values of various types:
+        # int, float, Fraction, Decimal
+        test_values = [
+            float('-inf'),
+            D('-1e999999999'),
+            -1e308,
+            F(-22, 7),
+            -3.14,
+            -2,
+            0.0,
+            1e-320,
+            True,
+            F('1.2'),
+            D('1.3'),
+            float('1.4'),
+            F(275807, 195025),
+            D('1.414213562373095048801688724'),
+            F(114243, 80782),
+            F(473596569, 84615),
+            7e200,
+            D('infinity'),
+            ]
+        for i, first in enumerate(test_values):
+            for second in test_values[i+1:]:
+                self.assertLess(first, second)
+                self.assertLessEqual(first, second)
+                self.assertGreater(second, first)
+                self.assertGreaterEqual(second, first)
+
+    def test_complex(self):
+        # comparisons with complex are special:  equality and inequality
+        # comparisons should always succeed, but order comparisons should
+        # raise TypeError.
+        z = 1.0 + 0j
+        w = -3.14 + 2.7j
+
+        for v in 1, 1.0, F(1), D(1), complex(1):
+            self.assertEqual(z, v)
+            self.assertEqual(v, z)
+
+        for v in 2, 2.0, F(2), D(2), complex(2):
+            self.assertNotEqual(z, v)
+            self.assertNotEqual(v, z)
+            self.assertNotEqual(w, v)
+            self.assertNotEqual(v, w)
+
+        for v in (1, 1.0, F(1), D(1), complex(1),
+                  2, 2.0, F(2), D(2), complex(2), w):
+            for op in operator.le, operator.lt, operator.ge, operator.gt:
+                self.assertRaises(TypeError, op, z, v)
+                self.assertRaises(TypeError, op, v, z)
+
 
 def test_main():
-    run_unittest(HashTest)
+    run_unittest(HashTest, ComparisonTest)
 
 if __name__ == '__main__':
     test_main()

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 14 11:30:15 2010
@@ -33,16 +33,15 @@
 HOST = support.HOST
 
 data_file = lambda name: os.path.join(os.path.dirname(__file__), name)
-fsencode = lambda name: name.encode(sys.getfilesystemencoding(), "surrogateescape")
 
 CERTFILE = data_file("keycert.pem")
-BYTES_CERTFILE = fsencode(CERTFILE)
+BYTES_CERTFILE = os.fsencode(CERTFILE)
 ONLYCERT = data_file("ssl_cert.pem")
 ONLYKEY = data_file("ssl_key.pem")
-BYTES_ONLYCERT = fsencode(ONLYCERT)
-BYTES_ONLYKEY = fsencode(ONLYKEY)
+BYTES_ONLYCERT = os.fsencode(ONLYCERT)
+BYTES_ONLYKEY = os.fsencode(ONLYKEY)
 CAPATH = data_file("capath")
-BYTES_CAPATH = fsencode(CAPATH)
+BYTES_CAPATH = os.fsencode(CAPATH)
 
 SVN_PYTHON_ORG_ROOT_CERT = data_file("https_svn_python_org_root.pem")
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_struct.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_struct.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_struct.py	Mon Jun 14 11:30:15 2010
@@ -443,7 +443,7 @@
 
         # Test bogus offset (issue 3694)
         sb = small_buf
-        self.assertRaises(TypeError, struct.pack_into, b'1', sb, None)
+        self.assertRaises(TypeError, struct.pack_into, b'', sb, None)
 
     def test_pack_into_fn(self):
         test_string = b'Reykjavik rocks, eow!'
@@ -506,10 +506,43 @@
             for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']:
                 self.assertTrue(struct.unpack('>?', c)[0])
 
+    def test_count_overflow(self):
+        hugecount = '{}b'.format(sys.maxsize+1)
+        self.assertRaises(struct.error, struct.calcsize, hugecount)
+
+        hugecount2 = '{}b{}H'.format(sys.maxsize//2, sys.maxsize//2)
+        self.assertRaises(struct.error, struct.calcsize, hugecount2)
+
     if IS32BIT:
         def test_crasher(self):
             self.assertRaises(MemoryError, struct.pack, "357913941b", "a")
 
+    def test_trailing_counter(self):
+        store = array.array('b', b' '*100)
+
+        # format lists containing only count spec should result in an error
+        self.assertRaises(struct.error, struct.pack, '12345')
+        self.assertRaises(struct.error, struct.unpack, '12345', '')
+        self.assertRaises(struct.error, struct.pack_into, '12345', store, 0)
+        self.assertRaises(struct.error, struct.unpack_from, '12345', store, 0)
+
+        # Format lists with trailing count spec should result in an error
+        self.assertRaises(struct.error, struct.pack, 'c12345', 'x')
+        self.assertRaises(struct.error, struct.unpack, 'c12345', 'x')
+        self.assertRaises(struct.error, struct.pack_into, 'c12345', store, 0,
+                           'x')
+        self.assertRaises(struct.error, struct.unpack_from, 'c12345', store,
+                           0)
+
+        # Mixed format tests
+        self.assertRaises(struct.error, struct.pack, '14s42', 'spam and eggs')
+        self.assertRaises(struct.error, struct.unpack, '14s42',
+                          'spam and eggs')
+        self.assertRaises(struct.error, struct.pack_into, '14s42', store, 0,
+                          'spam and eggs')
+        self.assertRaises(struct.error, struct.unpack_from, '14s42', store, 0)
+
+
 
 def test_main():
     run_unittest(StructTest)

Modified: python/branches/py3k-cdecimal/Lib/test/test_sundry.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_sundry.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_sundry.py	Mon Jun 14 11:30:15 2010
@@ -60,7 +60,6 @@
             import rlcompleter
             import sched
             import sndhdr
-            import sunau
             import symbol
             import tabnanny
             import timeit

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 14 11:30:15 2010
@@ -863,6 +863,35 @@
         # sys.flags
         check(sys.flags, size(vh) + self.P * len(sys.flags))
 
+    def test_getfilesystemencoding(self):
+        import codecs
+
+        def check_fsencoding(fs_encoding):
+            self.assertIsNotNone(fs_encoding)
+            if sys.platform == 'darwin':
+                self.assertEqual(fs_encoding, 'utf-8')
+            codecs.lookup(fs_encoding)
+
+        fs_encoding = sys.getfilesystemencoding()
+        check_fsencoding(fs_encoding)
+
+        # Even in C locale
+        try:
+            sys.executable.encode('ascii')
+        except UnicodeEncodeError:
+            # Python doesn't start with ASCII locale if its path is not ASCII,
+            # see issue #8611
+            pass
+        else:
+            env = os.environ.copy()
+            env['LANG'] = 'C'
+            output = subprocess.check_output(
+                [sys.executable, "-c",
+                 "import sys; print(sys.getfilesystemencoding())"],
+                env=env)
+            fs_encoding = output.rstrip().decode('ascii')
+            check_fsencoding(fs_encoding)
+
     def test_setfilesystemencoding(self):
         old = sys.getfilesystemencoding()
         try:

Modified: python/branches/py3k-cdecimal/Lib/test/test_unicode.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_unicode.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_unicode.py	Mon Jun 14 11:30:15 2010
@@ -681,6 +681,9 @@
         self.assertRaises(IndexError, "{:}".format)
         self.assertRaises(IndexError, "{:s}".format)
         self.assertRaises(IndexError, "{}".format)
+        big = "23098475029384702983476098230754973209482573"
+        self.assertRaises(ValueError, ("{" + big + "}").format)
+        self.assertRaises(ValueError, ("{[" + big + "]}").format, [0])
 
         # issue 6089
         self.assertRaises(ValueError, "{0[0]x}".format, [None])

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 14 11:30:15 2010
@@ -172,7 +172,7 @@
 
     longMessage = False
 
-    # This attribute sets the maximum length of a diff in failure messsages
+    # This attribute sets the maximum length of a diff in failure messages
     # by assert methods using difflib. It is looked up as an instance attribute
     # so can be configured by individual tests if required.
 
@@ -389,6 +389,9 @@
         self.setUp()
         getattr(self, self._testMethodName)()
         self.tearDown()
+        while self._cleanups:
+            function, args, kwargs = self._cleanups.pop(-1)
+            function(*args, **kwargs)
 
     def skipTest(self, reason):
         """Skip this test."""

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 14 11:30:15 2010
@@ -84,9 +84,16 @@
         self._handleModuleTearDown(result)
         return result
 
+    def debug(self):
+        """Run the tests without collecting errors in a TestResult"""
+        debug = _DebugResult()
+        self._wrapped_run(debug, True)
+        self._tearDownPreviousClass(None, debug)
+        self._handleModuleTearDown(debug)
+
     ################################
     # private methods
-    def _wrapped_run(self, result):
+    def _wrapped_run(self, result, debug=False):
         for test in self:
             if result.shouldStop:
                 break
@@ -102,9 +109,11 @@
                     continue
 
             if hasattr(test, '_wrapped_run'):
-                test._wrapped_run(result)
-            else:
+                test._wrapped_run(result, debug)
+            elif not debug:
                 test(result)
+            else:
+                test.debug()
 
     def _handleClassSetUp(self, test, result):
         previousClass = getattr(result, '_previousTestClass', None)
@@ -128,6 +137,8 @@
             try:
                 setUpClass()
             except Exception as e:
+                if isinstance(result, _DebugResult):
+                    raise
                 currentClass._classSetupFailed = True
                 className = util.strclass(currentClass)
                 errorName = 'setUpClass (%s)' % className
@@ -160,6 +171,8 @@
             try:
                 setUpModule()
             except Exception as e:
+                if isinstance(result, _DebugResult):
+                    raise
                 result._moduleSetUpFailed = True
                 errorName = 'setUpModule (%s)' % currentModule
                 self._addClassOrModuleLevelException(result, e, errorName)
@@ -189,6 +202,8 @@
             try:
                 tearDownModule()
             except Exception as e:
+                if isinstance(result, _DebugResult):
+                    raise
                 errorName = 'tearDownModule (%s)' % previousModule
                 self._addClassOrModuleLevelException(result, e, errorName)
 
@@ -209,6 +224,8 @@
             try:
                 tearDownClass()
             except Exception as e:
+                if isinstance(result, _DebugResult):
+                    raise
                 className = util.strclass(previousClass)
                 errorName = 'tearDownClass (%s)' % className
                 self._addClassOrModuleLevelException(result, e, errorName)
@@ -260,3 +277,10 @@
     except TypeError:
         return True
     return False
+
+
+class _DebugResult(object):
+    "Used by the TestSuite to hold previous class when running in debug."
+    _previousTestClass = None
+    _moduleSetUpFailed = False
+    shouldStop = False

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_runner.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_runner.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_runner.py	Mon Jun 14 11:30:15 2010
@@ -110,6 +110,31 @@
         test.run(result)
         self.assertEqual(ordering, ['setUp', 'cleanup1'])
 
+    def testTestCaseDebugExecutesCleanups(self):
+        ordering = []
+
+        class TestableTest(unittest.TestCase):
+            def setUp(self):
+                ordering.append('setUp')
+                self.addCleanup(cleanup1)
+
+            def testNothing(self):
+                ordering.append('test')
+
+            def tearDown(self):
+                ordering.append('tearDown')
+
+        test = TestableTest('testNothing')
+
+        def cleanup1():
+            ordering.append('cleanup1')
+            test.addCleanup(cleanup2)
+        def cleanup2():
+            ordering.append('cleanup2')
+
+        test.debug()
+        self.assertEqual(ordering, ['setUp', 'test', 'tearDown', 'cleanup1', 'cleanup2'])
+
 
 class Test_TextTestRunner(unittest.TestCase):
     """Tests for TextTestRunner."""

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 14 11:30:15 2010
@@ -438,6 +438,70 @@
         skipped = result.skipped[0][0]
         self.assertEqual(str(skipped), 'setUpModule (Module)')
 
+    def test_suite_debug_executes_setups_and_teardowns(self):
+        ordering = []
+
+        class Module(object):
+            @staticmethod
+            def setUpModule():
+                ordering.append('setUpModule')
+            @staticmethod
+            def tearDownModule():
+                ordering.append('tearDownModule')
+
+        class Test(unittest.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                ordering.append('setUpClass')
+            @classmethod
+            def tearDownClass(cls):
+                ordering.append('tearDownClass')
+            def test_something(self):
+                ordering.append('test_something')
+
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+
+        suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test)
+        suite.debug()
+        expectedOrder = ['setUpModule', 'setUpClass', 'test_something', 'tearDownClass', 'tearDownModule']
+        self.assertEqual(ordering, expectedOrder)
+
+    def test_suite_debug_propagates_exceptions(self):
+        class Module(object):
+            @staticmethod
+            def setUpModule():
+                if phase == 0:
+                    raise Exception('setUpModule')
+            @staticmethod
+            def tearDownModule():
+                if phase == 1:
+                    raise Exception('tearDownModule')
+
+        class Test(unittest.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                if phase == 2:
+                    raise Exception('setUpClass')
+            @classmethod
+            def tearDownClass(cls):
+                if phase == 3:
+                    raise Exception('tearDownClass')
+            def test_something(self):
+                if phase == 4:
+                    raise Exception('test_something')
+
+        Test.__module__ = 'Module'
+        sys.modules['Module'] = Module
+
+        _suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test)
+        suite = unittest.TestSuite()
+        suite.addTest(_suite)
+
+        messages = ('setUpModule', 'tearDownModule', 'setUpClass', 'tearDownClass', 'test_something')
+        for phase, msg in enumerate(messages):
+            with self.assertRaisesRegexp(Exception, msg):
+                suite.debug()
 
 if __name__ == '__main__':
     unittest.main()

Modified: python/branches/py3k-cdecimal/Lib/xml/dom/minidom.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/xml/dom/minidom.py	(original)
+++ python/branches/py3k-cdecimal/Lib/xml/dom/minidom.py	Mon Jun 14 11:30:15 2010
@@ -268,6 +268,14 @@
         self.previousSibling = None
         self.nextSibling = None
 
+    # A Node is its own context manager, to ensure that an unlink() call occurs.
+    # This is similar to how a file object works.
+    def __enter__(self):
+        return self
+
+    def __exit__(self, et, ev, tb):
+        self.unlink()
+
 defproperty(Node, "firstChild", doc="First child node, or None.")
 defproperty(Node, "lastChild",  doc="Last child node, or None.")
 defproperty(Node, "localName",  doc="Namespace-local name of this node.")

Modified: python/branches/py3k-cdecimal/Misc/ACKS
==============================================================================
--- python/branches/py3k-cdecimal/Misc/ACKS	(original)
+++ python/branches/py3k-cdecimal/Misc/ACKS	Mon Jun 14 11:30:15 2010
@@ -25,6 +25,7 @@
 Erik Andersén
 Oliver Andrich
 Ross Andrus
+Éric Araujo
 Jason Asbahr
 David Ascher
 Chris AtLee
@@ -153,6 +154,7 @@
 Jeffery Collins
 Robert Collins
 Paul Colomiets
+Geremy Condra
 Juan José Conti
 Matt Conway
 David M. Cooke
@@ -188,6 +190,7 @@
 Erik Demaine
 Roger Dev
 Raghuram Devarakonda
+Caleb Deveraux
 Toby Dickenson
 Mark Dickinson
 Jack Diederich
@@ -389,6 +392,7 @@
 Fredrik Johansson
 Gregory K. Johnson
 Simon Johnston
+Thomas Jollans
 Evan Jones
 Jeremy Jones
 Richard Jones
@@ -517,6 +521,7 @@
 Lambert Meertens
 Bill van Melle
 Lucas Prado Melo
+Ezio Melotti
 Brian Merrell
 Luke Mewburn
 Mike Meyer
@@ -637,6 +642,7 @@
 John Redford
 Terry Reedy
 Steve Reeves
+Lennart Regebro
 Ofir Reichenberg
 Sean Reifschneider
 Michael P. Reilly

Modified: python/branches/py3k-cdecimal/Misc/NEWS
==============================================================================
--- python/branches/py3k-cdecimal/Misc/NEWS	(original)
+++ python/branches/py3k-cdecimal/Misc/NEWS	Mon Jun 14 11:30:15 2010
@@ -12,9 +12,43 @@
 Core and Builtins
 -----------------
 
+- Issue #8592: PyArg_Parse*() functions raise a TypeError for "y", "u" and "Z"
+  formats if the string contains a null byte/character. Write unit tests for
+  string formats.
+
+- Issue #7490: to facilitate sharing of doctests between 2.x and 3.x test
+  suites, the IGNORE_EXCEPTION_DETAIL directive now also ignores the module
+  location of the raised exception.
+
+- Issue #8969: On Windows, use mbcs codec in strict mode to encode and decode
+  filenames and enable os.fsencode().
+
+- Issue #8941: decoding big endian UTF-32 data in UCS-2 builds could crash
+  the interpreter with characters outside the Basic Multilingual Plane
+  (higher than 0x10000).
+
+- Issue #8950: (See also issue #5080).  Py_ArgParse*() functions now
+  raise TypeError instead of giving a DeprecationWarning when a float
+  is parsed using the 'L' code (for long long).  (All other integer
+  codes already raise TypeError in this case.)
+
+- Issue #8922: Normalize the encoding name in PyUnicode_AsEncodedString() to
+  enable shortcuts for upper case encoding name. Add also a shortcut for
+  "iso-8859-1" in PyUnicode_AsEncodedString() and PyUnicode_Decode().
+
+- Issue #8838: Remove codecs.charbuffer_encode() function. The buffer protocol
+  doesn't support "char buffer" anymore in Python3.
+
+- Issue #8339: Remove "t#" format of PyArg_Parse*() functions, use "s#" or "s*"
+  instead. codecs.charbuffer_encode() now accepts modifiable buffer objects
+  like bytearray.
+
 - Issue #8837: Remove "O?" format of PyArg_Parse*() functions. The format is no
   used anymore and it was never documented.
 
+- In the str.format(), raise a ValueError when indexes to arguments are too
+  large.
+
 - Issue #2844: Make int('42', n) consistently raise ValueError for
   invalid integers n (including n = -909).
 
@@ -398,6 +432,24 @@
 Library
 -------
 
+- Issue #8986: math.erfc was incorrectly raising OverflowError for
+  values between -27.3 and -30.0 on some platforms.
+
+- Issue #8784: Set tarfile default encoding to 'utf-8' on Windows.
+
+- Issue #8966: If a ctypes structure field is an array of c_char, convert its
+  value to bytes instead of str (as done for c_char and c_char_p).
+
+- Issue #8188: Comparisons between Decimal and Fraction objects are
+  now permitted, returning a result based on the exact numerical
+  values of the operands.  This builds on issue #2531, which allowed
+  Decimal-to-float comparisons;  all comparisons involving numeric
+  types (bool, int, float, complex, Decimal, Fraction) should now
+  act as expected.
+
+- Issue #8897: Fix sunau module, use bytes to write the header. Patch written
+  by Thomas Jollans.
+
 - Issue #8899: time.struct_time now has class and atribute docstrings.
 
 - Issue #6470: Drop UNC prefix in FixTk.
@@ -692,7 +744,8 @@
 - Issue #2531: Comparison operations between floats and Decimal
   instances now return a result based on the numeric values of the
   operands;  previously they returned an arbitrary result based on
-  the relative ordering of id(float) and id(Decimal).
+  the relative ordering of id(float) and id(Decimal).  See also
+  issue #8188, which adds Decimal-to-Fraction comparisons.
 
 - Added a subtract() method to collections.Counter().
 
@@ -1253,6 +1306,17 @@
 Extension Modules
 -----------------
 
+- Issue #8973: Add __all__ to struct module; this ensures that
+  help(struct) includes documentation for the struct.Struct class.
+
+- Issue #3129: Trailing digits in struct format string are no longer ignored.
+  For example, "1" or "ilib123" are now invalid formats and cause
+  ``struct.error`` to be raised.  Patch by Caleb Deveraux.
+
+- Issue #7384: If the system readline library is linked against ncurses,
+  the curses module must be linked against ncurses as well. Otherwise it
+  is not safe to load both the readline and curses modules in an application.
+
 - Issue #2810: Fix cases where the Windows registry API returns
   ERROR_MORE_DATA, requiring a re-try in order to get the complete result.
 

Modified: python/branches/py3k-cdecimal/Misc/maintainers.rst
==============================================================================
--- python/branches/py3k-cdecimal/Misc/maintainers.rst	(original)
+++ python/branches/py3k-cdecimal/Misc/maintainers.rst	Mon Jun 14 11:30:15 2010
@@ -80,7 +80,7 @@
 csv
 ctypes              theller
 curses              andrew.kuchling
-datetime
+datetime            alexander.belopolsky
 dbm
 decimal             facundobatista, rhettinger, mark.dickinson
 difflib             tim_one
@@ -207,7 +207,7 @@
 test
 textwrap
 threading
-time
+time                alexander.belopolsky
 timeit
 tkinter             gpolo
 token               georg.brandl

Modified: python/branches/py3k-cdecimal/Modules/_codecsmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_codecsmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_codecsmodule.c	Mon Jun 14 11:30:15 2010
@@ -162,62 +162,62 @@
 escape_encode(PyObject *self,
               PyObject *args)
 {
-        static const char *hexdigits = "0123456789abcdef";
-        PyObject *str;
-        Py_ssize_t size;
-        Py_ssize_t newsize;
-        const char *errors = NULL;
-        PyObject *v;
-
-        if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
-                              &PyBytes_Type, &str, &errors))
-                return NULL;
-
-        size = PyBytes_GET_SIZE(str);
-        newsize = 4*size;
-        if (newsize > PY_SSIZE_T_MAX || newsize / 4 != size) {
-                PyErr_SetString(PyExc_OverflowError,
-                        "string is too large to encode");
-                        return NULL;
-        }
-        v = PyBytes_FromStringAndSize(NULL, newsize);
+    static const char *hexdigits = "0123456789abcdef";
+    PyObject *str;
+    Py_ssize_t size;
+    Py_ssize_t newsize;
+    const char *errors = NULL;
+    PyObject *v;
+
+    if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
+                          &PyBytes_Type, &str, &errors))
+        return NULL;
+
+    size = PyBytes_GET_SIZE(str);
+    newsize = 4*size;
+    if (newsize > PY_SSIZE_T_MAX || newsize / 4 != size) {
+        PyErr_SetString(PyExc_OverflowError,
+            "string is too large to encode");
+            return NULL;
+    }
+    v = PyBytes_FromStringAndSize(NULL, newsize);
 
-        if (v == NULL) {
-                return NULL;
+    if (v == NULL) {
+        return NULL;
+    }
+    else {
+        register Py_ssize_t i;
+        register char c;
+        register char *p = PyBytes_AS_STRING(v);
+
+        for (i = 0; i < size; i++) {
+            /* There's at least enough room for a hex escape */
+            assert(newsize - (p - PyBytes_AS_STRING(v)) >= 4);
+            c = PyBytes_AS_STRING(str)[i];
+            if (c == '\'' || c == '\\')
+                *p++ = '\\', *p++ = c;
+            else if (c == '\t')
+                *p++ = '\\', *p++ = 't';
+            else if (c == '\n')
+                *p++ = '\\', *p++ = 'n';
+            else if (c == '\r')
+                *p++ = '\\', *p++ = 'r';
+            else if (c < ' ' || c >= 0x7f) {
+                *p++ = '\\';
+                *p++ = 'x';
+                *p++ = hexdigits[(c & 0xf0) >> 4];
+                *p++ = hexdigits[c & 0xf];
+            }
+            else
+                *p++ = c;
         }
-        else {
-                register Py_ssize_t i;
-                register char c;
-                register char *p = PyBytes_AS_STRING(v);
-
-                for (i = 0; i < size; i++) {
-                        /* There's at least enough room for a hex escape */
-                        assert(newsize - (p - PyBytes_AS_STRING(v)) >= 4);
-                        c = PyBytes_AS_STRING(str)[i];
-                        if (c == '\'' || c == '\\')
-                                *p++ = '\\', *p++ = c;
-                        else if (c == '\t')
-                                *p++ = '\\', *p++ = 't';
-                        else if (c == '\n')
-                                *p++ = '\\', *p++ = 'n';
-                        else if (c == '\r')
-                                *p++ = '\\', *p++ = 'r';
-                        else if (c < ' ' || c >= 0x7f) {
-                                *p++ = '\\';
-                                *p++ = 'x';
-                                *p++ = hexdigits[(c & 0xf0) >> 4];
-                                *p++ = hexdigits[c & 0xf];
-                        }
-                        else
-                                *p++ = c;
-                }
-                *p = '\0';
-                if (_PyBytes_Resize(&v, (p - PyBytes_AS_STRING(v)))) {
-                        return NULL;
-                }
+        *p = '\0';
+        if (_PyBytes_Resize(&v, (p - PyBytes_AS_STRING(v)))) {
+            return NULL;
         }
+    }
 
-        return codec_tuple(v, size);
+    return codec_tuple(v, size);
 }
 
 /* --- Decoder ------------------------------------------------------------ */
@@ -252,7 +252,7 @@
 utf_7_decode(PyObject *self,
              PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int final = 0;
     Py_ssize_t consumed;
@@ -265,7 +265,7 @@
 
     decoded = PyUnicode_DecodeUTF7Stateful(pbuf.buf, pbuf.len, errors,
                                            final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (decoded == NULL)
         return NULL;
     return codec_tuple(decoded, consumed);
@@ -275,7 +275,7 @@
 utf_8_decode(PyObject *self,
             PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int final = 0;
     Py_ssize_t consumed;
@@ -288,7 +288,7 @@
 
     decoded = PyUnicode_DecodeUTF8Stateful(pbuf.buf, pbuf.len, errors,
                                            final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (decoded == NULL)
         return NULL;
     return codec_tuple(decoded, consumed);
@@ -298,7 +298,7 @@
 utf_16_decode(PyObject *self,
             PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int byteorder = 0;
     int final = 0;
@@ -311,7 +311,7 @@
     consumed = pbuf.len; /* This is overwritten unless final is true. */
     decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors,
                                         &byteorder, final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (decoded == NULL)
         return NULL;
     return codec_tuple(decoded, consumed);
@@ -321,7 +321,7 @@
 utf_16_le_decode(PyObject *self,
                  PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int byteorder = -1;
     int final = 0;
@@ -335,7 +335,7 @@
     consumed = pbuf.len; /* This is overwritten unless final is true. */
     decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors,
         &byteorder, final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (decoded == NULL)
         return NULL;
     return codec_tuple(decoded, consumed);
@@ -345,7 +345,7 @@
 utf_16_be_decode(PyObject *self,
                  PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int byteorder = 1;
     int final = 0;
@@ -359,7 +359,7 @@
     consumed = pbuf.len; /* This is overwritten unless final is true. */
     decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors,
         &byteorder, final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (decoded == NULL)
         return NULL;
     return codec_tuple(decoded, consumed);
@@ -377,7 +377,7 @@
 utf_16_ex_decode(PyObject *self,
                  PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int byteorder = 0;
     PyObject *unicode, *tuple;
@@ -390,7 +390,7 @@
     consumed = pbuf.len; /* This is overwritten unless final is true. */
     unicode = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors,
                                         &byteorder, final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (unicode == NULL)
         return NULL;
     tuple = Py_BuildValue("Oni", unicode, consumed, byteorder);
@@ -402,7 +402,7 @@
 utf_32_decode(PyObject *self,
             PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int byteorder = 0;
     int final = 0;
@@ -415,7 +415,7 @@
     consumed = pbuf.len; /* This is overwritten unless final is true. */
     decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors,
                                         &byteorder, final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (decoded == NULL)
         return NULL;
     return codec_tuple(decoded, consumed);
@@ -425,7 +425,7 @@
 utf_32_le_decode(PyObject *self,
                  PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int byteorder = -1;
     int final = 0;
@@ -438,7 +438,7 @@
     consumed = pbuf.len; /* This is overwritten unless final is true. */
     decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors,
                                         &byteorder, final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (decoded == NULL)
         return NULL;
     return codec_tuple(decoded, consumed);
@@ -448,7 +448,7 @@
 utf_32_be_decode(PyObject *self,
                  PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int byteorder = 1;
     int final = 0;
@@ -461,7 +461,7 @@
     consumed = pbuf.len; /* This is overwritten unless final is true. */
     decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors,
                                         &byteorder, final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (decoded == NULL)
         return NULL;
     return codec_tuple(decoded, consumed);
@@ -479,7 +479,7 @@
 utf_32_ex_decode(PyObject *self,
                  PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int byteorder = 0;
     PyObject *unicode, *tuple;
@@ -492,7 +492,7 @@
     consumed = pbuf.len; /* This is overwritten unless final is true. */
     unicode = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors,
                                         &byteorder, final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (unicode == NULL)
         return NULL;
     tuple = Py_BuildValue("Oni", unicode, consumed, byteorder);
@@ -504,7 +504,7 @@
 unicode_escape_decode(PyObject *self,
                      PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
         PyObject *unicode;
 
@@ -512,68 +512,68 @@
                           &pbuf, &errors))
         return NULL;
 
-        unicode = PyUnicode_DecodeUnicodeEscape(pbuf.buf, pbuf.len, errors);
-        PyBuffer_Release(&pbuf);
-        return codec_tuple(unicode, pbuf.len);
+    unicode = PyUnicode_DecodeUnicodeEscape(pbuf.buf, pbuf.len, errors);
+    PyBuffer_Release(&pbuf);
+    return codec_tuple(unicode, pbuf.len);
 }
 
 static PyObject *
 raw_unicode_escape_decode(PyObject *self,
                         PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
-        PyObject *unicode;
+    PyObject *unicode;
 
     if (!PyArg_ParseTuple(args, "s*|z:raw_unicode_escape_decode",
                           &pbuf, &errors))
         return NULL;
 
-        unicode = PyUnicode_DecodeRawUnicodeEscape(pbuf.buf, pbuf.len, errors);
-        PyBuffer_Release(&pbuf);
-        return codec_tuple(unicode, pbuf.len);
+    unicode = PyUnicode_DecodeRawUnicodeEscape(pbuf.buf, pbuf.len, errors);
+    PyBuffer_Release(&pbuf);
+    return codec_tuple(unicode, pbuf.len);
 }
 
 static PyObject *
 latin_1_decode(PyObject *self,
                PyObject *args)
 {
-        Py_buffer pbuf;
-        PyObject *unicode;
+    Py_buffer pbuf;
+    PyObject *unicode;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "y*|z:latin_1_decode",
                           &pbuf, &errors))
         return NULL;
 
-        unicode = PyUnicode_DecodeLatin1(pbuf.buf, pbuf.len, errors);
-        PyBuffer_Release(&pbuf);
-        return codec_tuple(unicode, pbuf.len);
+    unicode = PyUnicode_DecodeLatin1(pbuf.buf, pbuf.len, errors);
+    PyBuffer_Release(&pbuf);
+    return codec_tuple(unicode, pbuf.len);
 }
 
 static PyObject *
 ascii_decode(PyObject *self,
              PyObject *args)
 {
-        Py_buffer pbuf;
-        PyObject *unicode;
+    Py_buffer pbuf;
+    PyObject *unicode;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "y*|z:ascii_decode",
                           &pbuf, &errors))
         return NULL;
 
-        unicode = PyUnicode_DecodeASCII(pbuf.buf, pbuf.len, errors);
-        PyBuffer_Release(&pbuf);
-        return codec_tuple(unicode, pbuf.len);
+    unicode = PyUnicode_DecodeASCII(pbuf.buf, pbuf.len, errors);
+    PyBuffer_Release(&pbuf);
+    return codec_tuple(unicode, pbuf.len);
 }
 
 static PyObject *
 charmap_decode(PyObject *self,
                PyObject *args)
 {
-        Py_buffer pbuf;
-        PyObject *unicode;
+    Py_buffer pbuf;
+    PyObject *unicode;
     const char *errors = NULL;
     PyObject *mapping = NULL;
 
@@ -583,9 +583,9 @@
     if (mapping == Py_None)
         mapping = NULL;
 
-        unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors);
-        PyBuffer_Release(&pbuf);
-        return codec_tuple(unicode, pbuf.len);
+    unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors);
+    PyBuffer_Release(&pbuf);
+    return codec_tuple(unicode, pbuf.len);
 }
 
 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
@@ -594,7 +594,7 @@
 mbcs_decode(PyObject *self,
             PyObject *args)
 {
-        Py_buffer pbuf;
+    Py_buffer pbuf;
     const char *errors = NULL;
     int final = 0;
     Py_ssize_t consumed;
@@ -607,7 +607,7 @@
 
     decoded = PyUnicode_DecodeMBCSStateful(pbuf.buf, pbuf.len, errors,
                                            final ? NULL : &consumed);
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (decoded == NULL)
         return NULL;
     return codec_tuple(decoded, consumed);
@@ -639,21 +639,6 @@
 }
 
 static PyObject *
-charbuffer_encode(PyObject *self,
-                  PyObject *args)
-{
-    const char *data;
-    Py_ssize_t size;
-    const char *errors = NULL;
-
-    if (!PyArg_ParseTuple(args, "t#|z:charbuffer_encode",
-                          &data, &size, &errors))
-        return NULL;
-
-    return codec_tuple(PyBytes_FromStringAndSize(data, size), size);
-}
-
-static PyObject *
 unicode_internal_encode(PyObject *self,
                         PyObject *args)
 {
@@ -1116,7 +1101,6 @@
     {"charmap_decode",          charmap_decode,                 METH_VARARGS},
     {"charmap_build",           charmap_build,                  METH_VARARGS},
     {"readbuffer_encode",       readbuffer_encode,              METH_VARARGS},
-    {"charbuffer_encode",       charbuffer_encode,              METH_VARARGS},
 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
     {"mbcs_encode",             mbcs_encode,                    METH_VARARGS},
     {"mbcs_decode",             mbcs_decode,                    METH_VARARGS},

Modified: python/branches/py3k-cdecimal/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_ctypes/_ctypes.c	Mon Jun 14 11:30:15 2010
@@ -4467,7 +4467,7 @@
 #endif
 
     result = PyObject_CallFunction((PyObject *)&PyCArrayType_Type,
-                                   "U(O){s:n,s:O}",
+                                   "s(O){s:n,s:O}",
                                    name,
                                    &PyCArray_Type,
                                    "_length_",

Modified: python/branches/py3k-cdecimal/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_ctypes/cfield.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_ctypes/cfield.c	Mon Jun 14 11:30:15 2010
@@ -1333,7 +1333,7 @@
             break;
     }
 
-    return PyUnicode_FromStringAndSize((char *)ptr, (Py_ssize_t)i);
+    return PyBytes_FromStringAndSize((char *)ptr, (Py_ssize_t)i);
 }
 
 static PyObject *

Modified: python/branches/py3k-cdecimal/Modules/_localemodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_localemodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_localemodule.c	Mon Jun 14 11:30:15 2010
@@ -572,19 +572,31 @@
 static PyObject*
 PyIntl_bindtextdomain(PyObject* self,PyObject*args)
 {
-    char *domain, *dirname;
-    if (!PyArg_ParseTuple(args, "sz", &domain, &dirname))
+    char *domain, *dirname, *current_dirname;
+    PyObject *dirname_obj, *dirname_bytes = NULL, *result;
+    if (!PyArg_ParseTuple(args, "sO", &domain, &dirname_obj))
         return 0;
     if (!strlen(domain)) {
         PyErr_SetString(Error, "domain must be a non-empty string");
         return 0;
     }
-    dirname = bindtextdomain(domain, dirname);
-    if (!dirname) {
+    if (dirname_obj != Py_None) {
+        if (!PyUnicode_FSConverter(dirname_obj, &dirname_bytes))
+            return NULL;
+        dirname = PyBytes_AsString(dirname_bytes);
+    } else {
+        dirname_bytes = NULL;
+        dirname = NULL;
+    }
+    current_dirname = bindtextdomain(domain, dirname);
+    if (current_dirname == NULL) {
+        Py_XDECREF(dirname_bytes);
         PyErr_SetFromErrno(PyExc_OSError);
         return NULL;
     }
-    return str2uni(dirname);
+    result = str2uni(current_dirname);
+    Py_XDECREF(dirname_bytes);
+    return result;
 }
 
 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET

Modified: python/branches/py3k-cdecimal/Modules/_struct.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_struct.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_struct.c	Mon Jun 14 11:30:15 2010
@@ -1143,16 +1143,19 @@
 }
 
 
-/* Align a size according to a format code */
+/* Align a size according to a format code.  Return -1 on overflow. */
 
-static int
+static Py_ssize_t
 align(Py_ssize_t size, char c, const formatdef *e)
 {
+    Py_ssize_t extra;
+
     if (e->format == c) {
-        if (e->alignment) {
-            size = ((size + e->alignment - 1)
-                / e->alignment)
-                * e->alignment;
+        if (e->alignment && size > 0) {
+            extra = (e->alignment - 1) - (size - 1) % (e->alignment);
+            if (extra > PY_SSIZE_T_MAX - size)
+                return -1;
+            size += extra;
         }
     }
     return size;
@@ -1171,7 +1174,7 @@
     const char *s;
     const char *fmt;
     char c;
-    Py_ssize_t size, len, num, itemsize, x;
+    Py_ssize_t size, len, num, itemsize;
 
     fmt = PyBytes_AS_STRING(self->s_format);
 
@@ -1186,17 +1189,19 @@
         if ('0' <= c && c <= '9') {
             num = c - '0';
             while ('0' <= (c = *s++) && c <= '9') {
-                x = num*10 + (c - '0');
-                if (x/10 != num) {
-                    PyErr_SetString(
-                        StructError,
-                        "overflow in item count");
-                    return -1;
-                }
-                num = x;
+                /* overflow-safe version of
+                   if (num*10 + (c - '0') > PY_SSIZE_T_MAX) { ... } */
+                if (num >= PY_SSIZE_T_MAX / 10 && (
+                        num > PY_SSIZE_T_MAX / 10 ||
+                        (c - '0') > PY_SSIZE_T_MAX % 10))
+                    goto overflow;
+                num = num*10 + (c - '0');
+            }
+            if (c == '\0') {
+                PyErr_SetString(StructError,
+                                "repeat count given without format specifier");
+                return -1;
             }
-            if (c == '\0')
-                break;
         }
         else
             num = 1;
@@ -1214,13 +1219,13 @@
 
         itemsize = e->size;
         size = align(size, c, e);
-        x = num * itemsize;
-        size += x;
-        if (x/itemsize != num || size < 0) {
-            PyErr_SetString(StructError,
-                            "total struct size too long");
-            return -1;
-        }
+        if (size == -1)
+            goto overflow;
+
+        /* if (size + num * itemsize > PY_SSIZE_T_MAX) { ... } */
+        if (num > (PY_SSIZE_T_MAX - size) / itemsize)
+            goto overflow;
+        size += num * itemsize;
     }
 
     /* check for overflow */
@@ -1279,6 +1284,11 @@
     codes->size = 0;
 
     return 0;
+
+  overflow:
+    PyErr_SetString(StructError,
+                    "total struct size too long");
+    return -1;
 }
 
 static PyObject *
@@ -1388,9 +1398,9 @@
 PyDoc_STRVAR(s_unpack__doc__,
 "S.unpack(buffer) -> (v1, v2, ...)\n\
 \n\
-Return tuple containing values unpacked according to this Struct's format.\n\
-Requires len(buffer) == self.size. See struct.__doc__ for more on format\n\
-strings.");
+Return a tuple containing values unpacked according to the format\n\
+string S.format.  Requires len(buffer) == S.size.  See help(struct)\n\
+for more on format strings.");
 
 static PyObject *
 s_unpack(PyObject *self, PyObject *input)
@@ -1416,12 +1426,11 @@
 }
 
 PyDoc_STRVAR(s_unpack_from__doc__,
-"S.unpack_from(buffer[, offset]) -> (v1, v2, ...)\n\
+"S.unpack_from(buffer, offset=0) -> (v1, v2, ...)\n\
 \n\
-Return tuple containing values unpacked according to this Struct's format.\n\
-Unlike unpack, unpack_from can unpack values from any object supporting\n\
-the buffer API, not just str. Requires len(buffer[offset:]) >= self.size.\n\
-See struct.__doc__ for more on format strings.");
+Return a tuple containing values unpacked according to the format\n\
+string S.format.  Requires len(buffer[offset:]) >= S.size.  See\n\
+help(struct) for more on format strings.");
 
 static PyObject *
 s_unpack_from(PyObject *self, PyObject *args, PyObject *kwds)
@@ -1556,8 +1565,9 @@
 PyDoc_STRVAR(s_pack__doc__,
 "S.pack(v1, v2, ...) -> bytes\n\
 \n\
-Return a bytes containing values v1, v2, ... packed according to this\n\
-Struct's format. See struct.__doc__ for more on format strings.");
+Return a bytes object containing values v1, v2, ... packed according\n\
+to the format string S.format.  See help(struct) for more on format\n\
+strings.");
 
 static PyObject *
 s_pack(PyObject *self, PyObject *args)
@@ -1593,10 +1603,10 @@
 PyDoc_STRVAR(s_pack_into__doc__,
 "S.pack_into(buffer, offset, v1, v2, ...)\n\
 \n\
-Pack the values v1, v2, ... according to this Struct's format, write \n\
-the packed bytes into the writable buffer buf starting at offset.  Note\n\
-that the offset is not an optional argument.  See struct.__doc__ for \n\
-more on format strings.");
+Pack the values v1, v2, ... according to the format string S.format\n\
+and write the packed bytes into the writable buffer buf starting at\n\
+offset.  Note that the offset is a required argument.  See\n\
+help(struct) for more on format strings.");
 
 static PyObject *
 s_pack_into(PyObject *self, PyObject *args)
@@ -1673,7 +1683,11 @@
     {NULL,       NULL}          /* sentinel */
 };
 
-PyDoc_STRVAR(s__doc__, "Compiled struct object");
+PyDoc_STRVAR(s__doc__, 
+"Struct(fmt) --> compiled struct object\n"
+"\n"
+"Return a new Struct object which writes and reads binary data according to\n"
+"the format string fmt.  See help(struct) for more on format strings.");
 
 #define OFF(x) offsetof(PyStructObject, x)
 
@@ -1771,7 +1785,9 @@
 }
 
 PyDoc_STRVAR(calcsize_doc,
-"Return size of C struct described by format string fmt.");
+"calcsize(fmt) -> integer\n\
+\n\
+Return size in bytes of the struct described by the format string fmt.");
 
 static PyObject *
 calcsize(PyObject *self, PyObject *fmt)
@@ -1786,7 +1802,10 @@
 }
 
 PyDoc_STRVAR(pack_doc,
-"Return bytes containing values v1, v2, ... packed according to fmt.");
+"pack(fmt, v1, v2, ...) -> bytes\n\
+\n\
+Return a bytes object containing the values v1, v2, ... packed according\n\
+to the format string fmt.  See help(struct) for more on format strings.");
 
 static PyObject *
 pack(PyObject *self, PyObject *args)
@@ -1815,8 +1834,12 @@
 }
 
 PyDoc_STRVAR(pack_into_doc,
-"Pack the values v1, v2, ... according to fmt.\n\
-Write the packed bytes into the writable buffer buf starting at offset.");
+"pack_into(fmt, buffer, offset, v1, v2, ...)\n\
+\n\
+Pack the values v1, v2, ... according to the format string fmt and write\n\
+the packed bytes into the writable buffer buf starting at offset.  Note\n\
+that the offset is a required argument.  See help(struct) for more\n\
+on format strings.");
 
 static PyObject *
 pack_into(PyObject *self, PyObject *args)
@@ -1845,8 +1868,11 @@
 }
 
 PyDoc_STRVAR(unpack_doc,
-"Unpack the bytes containing packed C structure data, according to fmt.\n\
-Requires len(bytes) == calcsize(fmt).");
+"unpack(fmt, buffer) -> (v1, v2, ...)\n\
+\n\
+Return a tuple containing values unpacked according to the format string\n\
+fmt.  Requires len(buffer) == calcsize(fmt). See help(struct) for more\n\
+on format strings.");
 
 static PyObject *
 unpack(PyObject *self, PyObject *args)
@@ -1865,8 +1891,11 @@
 }
 
 PyDoc_STRVAR(unpack_from_doc,
-"Unpack the buffer, containing packed C structure data, according to\n\
-fmt, starting at offset. Requires len(buffer[offset:]) >= calcsize(fmt).");
+"unpack_from(fmt, buffer, offset=0) -> (v1, v2, ...)\n\
+\n\
+Return a tuple containing values unpacked according to the format string\n\
+fmt.  Requires len(buffer[offset:]) >= calcsize(fmt).  See help(struct)\n\
+for more on format strings.");
 
 static PyObject *
 unpack_from(PyObject *self, PyObject *args, PyObject *kwds)
@@ -1953,11 +1982,7 @@
 PyMODINIT_FUNC
 PyInit__struct(void)
 {
-    PyObject *ver, *m;
-
-    ver = PyBytes_FromString("0.3");
-    if (ver == NULL)
-        return NULL;
+    PyObject *m;
 
     m = PyModule_Create(&_structmodule);
     if (m == NULL)
@@ -2019,7 +2044,5 @@
     Py_INCREF((PyObject*)&PyStructType);
     PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType);
 
-    PyModule_AddObject(m, "__version__", ver);
-
     return m;
 }

Modified: python/branches/py3k-cdecimal/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_testcapimodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_testcapimodule.c	Mon Jun 14 11:30:15 2010
@@ -1011,6 +1011,157 @@
     return Py_None;
 }
 
+static PyObject *
+getargs_s(PyObject *self, PyObject *args)
+{
+    char *str;
+    if (!PyArg_ParseTuple(args, "s", &str))
+        return NULL;
+    return PyBytes_FromString(str);
+}
+
+static PyObject *
+getargs_s_star(PyObject *self, PyObject *args)
+{
+    Py_buffer buffer;
+    PyObject *bytes;
+    if (!PyArg_ParseTuple(args, "s*", &buffer))
+        return NULL;
+    bytes = PyBytes_FromStringAndSize(buffer.buf, buffer.len);
+    PyBuffer_Release(&buffer);
+    return bytes;
+}
+
+static PyObject *
+getargs_s_hash(PyObject *self, PyObject *args)
+{
+    char *str;
+    Py_ssize_t size;
+    if (!PyArg_ParseTuple(args, "s#", &str, &size))
+        return NULL;
+    return PyBytes_FromStringAndSize(str, size);
+}
+
+static PyObject *
+getargs_z(PyObject *self, PyObject *args)
+{
+    char *str;
+    if (!PyArg_ParseTuple(args, "z", &str))
+        return NULL;
+    if (str != NULL)
+        return PyBytes_FromString(str);
+    else
+        Py_RETURN_NONE;
+}
+
+static PyObject *
+getargs_z_star(PyObject *self, PyObject *args)
+{
+    Py_buffer buffer;
+    PyObject *bytes;
+    if (!PyArg_ParseTuple(args, "z*", &buffer))
+        return NULL;
+    if (buffer.buf != NULL)
+        bytes = PyBytes_FromStringAndSize(buffer.buf, buffer.len);
+    else {
+        Py_INCREF(Py_None);
+        bytes = Py_None;
+    }
+    PyBuffer_Release(&buffer);
+    return bytes;
+}
+
+static PyObject *
+getargs_z_hash(PyObject *self, PyObject *args)
+{
+    char *str;
+    Py_ssize_t size;
+    if (!PyArg_ParseTuple(args, "z#", &str, &size))
+        return NULL;
+    if (str != NULL)
+        return PyBytes_FromStringAndSize(str, size);
+    else
+        Py_RETURN_NONE;
+}
+
+static PyObject *
+getargs_y(PyObject *self, PyObject *args)
+{
+    char *str;
+    if (!PyArg_ParseTuple(args, "y", &str))
+        return NULL;
+    return PyBytes_FromString(str);
+}
+
+static PyObject *
+getargs_y_star(PyObject *self, PyObject *args)
+{
+    Py_buffer buffer;
+    PyObject *bytes;
+    if (!PyArg_ParseTuple(args, "y*", &buffer))
+        return NULL;
+    bytes = PyBytes_FromStringAndSize(buffer.buf, buffer.len);
+    PyBuffer_Release(&buffer);
+    return bytes;
+}
+
+static PyObject *
+getargs_y_hash(PyObject *self, PyObject *args)
+{
+    char *str;
+    Py_ssize_t size;
+    if (!PyArg_ParseTuple(args, "y#", &str, &size))
+        return NULL;
+    return PyBytes_FromStringAndSize(str, size);
+}
+
+static PyObject *
+getargs_u(PyObject *self, PyObject *args)
+{
+    Py_UNICODE *str;
+    Py_ssize_t size;
+    if (!PyArg_ParseTuple(args, "u", &str))
+        return NULL;
+    size = Py_UNICODE_strlen(str);
+    return PyUnicode_FromUnicode(str, size);
+}
+
+static PyObject *
+getargs_u_hash(PyObject *self, PyObject *args)
+{
+    Py_UNICODE *str;
+    Py_ssize_t size;
+    if (!PyArg_ParseTuple(args, "u#", &str, &size))
+        return NULL;
+    return PyUnicode_FromUnicode(str, size);
+}
+
+static PyObject *
+getargs_Z(PyObject *self, PyObject *args)
+{
+    Py_UNICODE *str;
+    Py_ssize_t size;
+    if (!PyArg_ParseTuple(args, "Z", &str))
+        return NULL;
+    if (str != NULL) {
+        size = Py_UNICODE_strlen(str);
+        return PyUnicode_FromUnicode(str, size);
+    } else
+        Py_RETURN_NONE;
+}
+
+static PyObject *
+getargs_Z_hash(PyObject *self, PyObject *args)
+{
+    Py_UNICODE *str;
+    Py_ssize_t size;
+    if (!PyArg_ParseTuple(args, "Z#", &str, &size))
+        return NULL;
+    if (str != NULL)
+        return PyUnicode_FromUnicode(str, size);
+    else
+        Py_RETURN_NONE;
+}
 
 /* Test the s and z codes for PyArg_ParseTuple.
 */
@@ -2062,11 +2213,24 @@
     {"test_long_long_and_overflow",
         (PyCFunction)test_long_long_and_overflow, METH_NOARGS},
     {"test_L_code",             (PyCFunction)test_L_code,        METH_NOARGS},
+#endif
+    {"getargs_s",               getargs_s,                       METH_VARARGS},
+    {"getargs_s_star",          getargs_s_star,                  METH_VARARGS},
+    {"getargs_s_hash",          getargs_s_hash,                  METH_VARARGS},
+    {"getargs_z",               getargs_z,                       METH_VARARGS},
+    {"getargs_z_star",          getargs_z_star,                  METH_VARARGS},
+    {"getargs_z_hash",          getargs_z_hash,                  METH_VARARGS},
+    {"getargs_y",               getargs_y,                       METH_VARARGS},
+    {"getargs_y_star",          getargs_y_star,                  METH_VARARGS},
+    {"getargs_y_hash",          getargs_y_hash,                  METH_VARARGS},
+    {"getargs_u",               getargs_u,                       METH_VARARGS},
+    {"getargs_u_hash",          getargs_u_hash,                  METH_VARARGS},
+    {"getargs_Z",               getargs_Z,                       METH_VARARGS},
+    {"getargs_Z_hash",          getargs_Z_hash,                  METH_VARARGS},
     {"codec_incrementalencoder",
      (PyCFunction)codec_incrementalencoder,      METH_VARARGS},
     {"codec_incrementaldecoder",
      (PyCFunction)codec_incrementaldecoder,      METH_VARARGS},
-#endif
     {"test_s_code",             (PyCFunction)test_s_code,        METH_NOARGS},
     {"test_u_code",             (PyCFunction)test_u_code,        METH_NOARGS},
     {"test_Z_code",             (PyCFunction)test_Z_code,        METH_NOARGS},

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 14 11:30:15 2010
@@ -161,7 +161,7 @@
     PyObject *result;
     PyObject *temp;
 
-    temp = _PyLong_Divmod_Near(m, n);
+    temp = _PyLong_DivmodNear(m, n);
     if (temp == NULL)
         return NULL;
     result = PyTuple_GET_ITEM(temp, 0);

Modified: python/branches/py3k-cdecimal/Modules/itertoolsmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/itertoolsmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/itertoolsmodule.c	Mon Jun 14 11:30:15 2010
@@ -3066,7 +3066,7 @@
 };
 
 PyDoc_STRVAR(count_doc,
-                         "count(start=0, step=1]) --> count object\n\
+                         "count(start=0, step=1) --> count object\n\
 \n\
 Return a count object whose .__next__() method returns consecutive values.\n\
 Equivalent to:\n\n\

Modified: python/branches/py3k-cdecimal/Modules/mathmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/mathmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/mathmodule.c	Mon Jun 14 11:30:15 2010
@@ -428,8 +428,8 @@
 static double
 m_erf_series(double x)
 {
-    double x2, acc, fk;
-    int i;
+    double x2, acc, fk, result;
+    int i, saved_errno;
 
     x2 = x * x;
     acc = 0.0;
@@ -438,7 +438,12 @@
         acc = 2.0 + x2 * acc / fk;
         fk -= 1.0;
     }
-    return acc * x * exp(-x2) / sqrtpi;
+    /* Make sure the exp call doesn't affect errno;
+       see m_erfc_contfrac for more. */
+    saved_errno = errno;
+    result = acc * x * exp(-x2) / sqrtpi;
+    errno = saved_errno;
+    return result;
 }
 
 /*
@@ -453,8 +458,8 @@
 static double
 m_erfc_contfrac(double x)
 {
-    double x2, a, da, p, p_last, q, q_last, b;
-    int i;
+    double x2, a, da, p, p_last, q, q_last, b, result;
+    int i, saved_errno;
 
     if (x >= ERFC_CONTFRAC_CUTOFF)
         return 0.0;
@@ -472,7 +477,12 @@
         temp = p; p = b*p - a*p_last; p_last = temp;
         temp = q; q = b*q - a*q_last; q_last = temp;
     }
-    return p / q * x * exp(-x2) / sqrtpi;
+    /* Issue #8986: On some platforms, exp sets errno on underflow to zero;
+       save the current errno value so that we can restore it later. */
+    saved_errno = errno;
+    result = p / q * x * exp(-x2) / sqrtpi;
+    errno = saved_errno;
+    return result;
 }
 
 /* Error function erf(x), for general x */

Modified: python/branches/py3k-cdecimal/Modules/readline.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/readline.c	(original)
+++ python/branches/py3k-cdecimal/Modules/readline.c	Mon Jun 14 11:30:15 2010
@@ -98,10 +98,16 @@
 static PyObject *
 read_init_file(PyObject *self, PyObject *args)
 {
-    char *s = NULL;
-    if (!PyArg_ParseTuple(args, "|z:read_init_file", &s))
+    PyObject *filename_obj = Py_None, *filename_bytes;
+    if (!PyArg_ParseTuple(args, "|O:read_init_file", &filename_obj))
         return NULL;
-    errno = rl_read_init_file(s);
+    if (filename_obj != Py_None) {
+        if (!PyUnicode_FSConverter(filename_obj, &filename_bytes))
+            return NULL;
+        errno = rl_read_init_file(PyBytes_AsString(filename_bytes));
+        Py_DECREF(filename_bytes);
+    } else
+        errno = rl_read_init_file(NULL);
     if (errno)
         return PyErr_SetFromErrno(PyExc_IOError);
     Py_RETURN_NONE;
@@ -118,10 +124,16 @@
 static PyObject *
 read_history_file(PyObject *self, PyObject *args)
 {
-    char *s = NULL;
-    if (!PyArg_ParseTuple(args, "|z:read_history_file", &s))
+    PyObject *filename_obj = Py_None, *filename_bytes;
+    if (!PyArg_ParseTuple(args, "|O:read_history_file", &filename_obj))
         return NULL;
-    errno = read_history(s);
+    if (filename_obj != Py_None) {
+        if (!PyUnicode_FSConverter(filename_obj, &filename_bytes))
+            return NULL;
+        errno = read_history(PyBytes_AsString(filename_bytes));
+        Py_DECREF(filename_bytes);
+    } else
+        errno = read_history(NULL);
     if (errno)
         return PyErr_SetFromErrno(PyExc_IOError);
     Py_RETURN_NONE;
@@ -139,12 +151,22 @@
 static PyObject *
 write_history_file(PyObject *self, PyObject *args)
 {
-    char *s = NULL;
-    if (!PyArg_ParseTuple(args, "|z:write_history_file", &s))
+    PyObject *filename_obj = Py_None, *filename_bytes;
+    char *filename;
+    if (!PyArg_ParseTuple(args, "|O:write_history_file", &filename_obj))
         return NULL;
-    errno = write_history(s);
+    if (filename_obj != Py_None) {
+        if (!PyUnicode_FSConverter(filename_obj, &filename_bytes))
+            return NULL;
+        filename = PyBytes_AsString(filename_bytes);
+    } else {
+        filename_bytes = NULL;
+        filename = NULL;
+    }
+    errno = write_history(filename);
     if (!errno && _history_length >= 0)
-        history_truncate_file(s, _history_length);
+        history_truncate_file(filename, _history_length);
+    Py_XDECREF(filename_bytes);
     if (errno)
         return PyErr_SetFromErrno(PyExc_IOError);
     Py_RETURN_NONE;

Modified: python/branches/py3k-cdecimal/Objects/bytearrayobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/bytearrayobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/bytearrayobject.c	Mon Jun 14 11:30:15 2010
@@ -1650,43 +1650,43 @@
                                   char from_c, char to_c,
                                   Py_ssize_t maxcount)
 {
-        char *self_s, *result_s, *start, *end, *next;
-        Py_ssize_t self_len;
-        PyByteArrayObject *result;
-
-        /* The result string will be the same size */
-        self_s = PyByteArray_AS_STRING(self);
-        self_len = PyByteArray_GET_SIZE(self);
-
-        next = findchar(self_s, self_len, from_c);
-
-        if (next == NULL) {
-                /* No matches; return the original bytes */
-                return return_self(self);
-        }
+    char *self_s, *result_s, *start, *end, *next;
+    Py_ssize_t self_len;
+    PyByteArrayObject *result;
 
-        /* Need to make a new bytes */
-        result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len);
-        if (result == NULL)
-                return NULL;
-        result_s = PyByteArray_AS_STRING(result);
-        Py_MEMCPY(result_s, self_s, self_len);
+    /* The result string will be the same size */
+    self_s = PyByteArray_AS_STRING(self);
+    self_len = PyByteArray_GET_SIZE(self);
 
-        /* change everything in-place, starting with this one */
-        start =  result_s + (next-self_s);
-        *start = to_c;
-        start++;
-        end = result_s + self_len;
-
-        while (--maxcount > 0) {
-                next = findchar(start, end-start, from_c);
-                if (next == NULL)
-                        break;
-                *next = to_c;
-                start = next+1;
-        }
+    next = findchar(self_s, self_len, from_c);
+
+    if (next == NULL) {
+        /* No matches; return the original bytes */
+        return return_self(self);
+    }
+
+    /* Need to make a new bytes */
+    result = (PyByteArrayObject *) PyByteArray_FromStringAndSize(NULL, self_len);
+    if (result == NULL)
+        return NULL;
+    result_s = PyByteArray_AS_STRING(result);
+    Py_MEMCPY(result_s, self_s, self_len);
+
+    /* change everything in-place, starting with this one */
+    start =  result_s + (next-self_s);
+    *start = to_c;
+    start++;
+    end = result_s + self_len;
 
-        return result;
+    while (--maxcount > 0) {
+        next = findchar(start, end-start, from_c);
+        if (next == NULL)
+            break;
+        *next = to_c;
+        start = next+1;
+    }
+
+    return result;
 }
 
 /* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */

Modified: python/branches/py3k-cdecimal/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/bytesobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/bytesobject.c	Mon Jun 14 11:30:15 2010
@@ -14,10 +14,10 @@
 
     if (buffer == NULL || buffer->bf_getbuffer == NULL)
     {
-    PyErr_Format(PyExc_TypeError,
-                 "Type %.100s doesn't support the buffer API",
-                 Py_TYPE(obj)->tp_name);
-    return -1;
+        PyErr_Format(PyExc_TypeError,
+                     "Type %.100s doesn't support the buffer API",
+                     Py_TYPE(obj)->tp_name);
+        return -1;
     }
 
     if (buffer->bf_getbuffer(obj, view, PyBUF_SIMPLE) < 0)
@@ -776,19 +776,19 @@
 {
     Py_ssize_t ival = PyNumber_AsSsize_t(arg, PyExc_ValueError);
     if (ival == -1 && PyErr_Occurred()) {
-    Py_buffer varg;
-    int pos;
-    PyErr_Clear();
-    if (_getbuffer(arg, &varg) < 0)
-        return -1;
-    pos = stringlib_find(PyBytes_AS_STRING(self), Py_SIZE(self),
-                         varg.buf, varg.len, 0);
-    PyBuffer_Release(&varg);
-    return pos >= 0;
+        Py_buffer varg;
+        int pos;
+        PyErr_Clear();
+        if (_getbuffer(arg, &varg) < 0)
+            return -1;
+        pos = stringlib_find(PyBytes_AS_STRING(self), Py_SIZE(self),
+                             varg.buf, varg.len, 0);
+        PyBuffer_Release(&varg);
+        return pos >= 0;
     }
     if (ival < 0 || ival >= 256) {
-    PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
-    return -1;
+        PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)");
+        return -1;
     }
 
     return memchr(PyBytes_AS_STRING(self), ival, Py_SIZE(self)) != NULL;
@@ -2345,12 +2345,12 @@
     int keepends = 0;
 
     if (!PyArg_ParseTuple(args, "|i:splitlines", &keepends))
-    return NULL;
+        return NULL;
 
     return stringlib_splitlines(
-    (PyObject*) self, PyBytes_AS_STRING(self),
-    PyBytes_GET_SIZE(self), keepends
-    );
+        (PyObject*) self, PyBytes_AS_STRING(self),
+        PyBytes_GET_SIZE(self), keepends
+        );
 }
 
 

Modified: python/branches/py3k-cdecimal/Objects/exceptions.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/exceptions.c	(original)
+++ python/branches/py3k-cdecimal/Objects/exceptions.c	Mon Jun 14 11:30:15 2010
@@ -1510,7 +1510,7 @@
     const char *encoding, const Py_UNICODE *object, Py_ssize_t length,
     Py_ssize_t start, Py_ssize_t end, const char *reason)
 {
-    return PyObject_CallFunction(PyExc_UnicodeEncodeError, "Uu#nnU",
+    return PyObject_CallFunction(PyExc_UnicodeEncodeError, "su#nns",
                                  encoding, object, length, start, end, reason);
 }
 
@@ -1625,7 +1625,7 @@
     assert(length < INT_MAX);
     assert(start < INT_MAX);
     assert(end < INT_MAX);
-    return PyObject_CallFunction(PyExc_UnicodeDecodeError, "Uy#nnU",
+    return PyObject_CallFunction(PyExc_UnicodeDecodeError, "sy#nns",
                                  encoding, object, length, start, end, reason);
 }
 

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 14 11:30:15 2010
@@ -4218,7 +4218,7 @@
    round-half-to-even. */
 
 PyObject *
-_PyLong_Divmod_Near(PyObject *a, PyObject *b)
+_PyLong_DivmodNear(PyObject *a, PyObject *b)
 {
     PyLongObject *quo = NULL, *rem = NULL;
     PyObject *one = NULL, *twice_rem, *result, *temp;
@@ -4363,7 +4363,7 @@
     if (result == NULL)
         return NULL;
 
-    temp = _PyLong_Divmod_Near(self, result);
+    temp = _PyLong_DivmodNear(self, result);
     Py_DECREF(result);
     result = temp;
     if (result == NULL)

Modified: python/branches/py3k-cdecimal/Objects/stringlib/formatter.h
==============================================================================
--- python/branches/py3k-cdecimal/Objects/stringlib/formatter.h	(original)
+++ python/branches/py3k-cdecimal/Objects/stringlib/formatter.h	Mon Jun 14 11:30:15 2010
@@ -649,8 +649,8 @@
     case LT_DEFAULT_LOCALE:
         locale_info->decimal_point = ".";
         locale_info->thousands_sep = ",";
-        locale_info->grouping = "\3"; /* Group every 3 characters,
-                                         trailing 0 means repeat
+        locale_info->grouping = "\3"; /* Group every 3 characters.  The
+                                         (implicit) trailing 0 means repeat
                                          infinitely. */
         break;
     case LT_NO_LOCALE:

Modified: python/branches/py3k-cdecimal/Objects/stringlib/string_format.h
==============================================================================
--- python/branches/py3k-cdecimal/Objects/stringlib/string_format.h	(original)
+++ python/branches/py3k-cdecimal/Objects/stringlib/string_format.h	Mon Jun 14 11:30:15 2010
@@ -373,6 +373,8 @@
         if (_FieldNameIterator_item(self, name) == 0)
             return 0;
         *name_idx = get_integer(name);
+        if (*name_idx == -1 && PyErr_Occurred())
+            return 0;
         break;
     default:
         /* Invalid character follows ']' */
@@ -429,6 +431,8 @@
 
     /* see if "first" is an integer, in which case it's used as an index */
     *first_idx = get_integer(first);
+    if (*first_idx == -1 && PyErr_Occurred())
+        return 0;
 
     field_name_is_empty = first->ptr >= first->end;
 

Modified: python/branches/py3k-cdecimal/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/unicodeobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/unicodeobject.c	Mon Jun 14 11:30:15 2010
@@ -1293,25 +1293,24 @@
     return NULL;
 }
 
-PyObject *PyUnicode_Decode(const char *s,
-                           Py_ssize_t size,
-                           const char *encoding,
-                           const char *errors)
+/* Convert encoding to lower case and replace '_' with '-' in order to
+   catch e.g. UTF_8. Return 0 on error (encoding is longer than lower_len-1),
+   1 on success. */
+static int
+normalize_encoding(const char *encoding,
+                   char *lower,
+                   size_t lower_len)
 {
-    PyObject *buffer = NULL, *unicode;
-    Py_buffer info;
-    char lower[20];  /* Enough for any encoding name we recognize */
-    char *l;
     const char *e;
+    char *l;
+    char *l_end;
 
-    if (encoding == NULL)
-        encoding = PyUnicode_GetDefaultEncoding();
-
-    /* Convert encoding to lower case and replace '_' with '-' in order to
-       catch e.g. UTF_8 */
     e = encoding;
     l = lower;
-    while (*e && l < &lower[(sizeof lower) - 2]) {
+    l_end = &lower[lower_len - 1];
+    while (*e) {
+        if (l == l_end)
+            return 0;
         if (ISUPPER(*e)) {
             *l++ = TOLOWER(*e++);
         }
@@ -1324,23 +1323,39 @@
         }
     }
     *l = '\0';
+    return 1;
+}
+
+PyObject *PyUnicode_Decode(const char *s,
+                           Py_ssize_t size,
+                           const char *encoding,
+                           const char *errors)
+{
+    PyObject *buffer = NULL, *unicode;
+    Py_buffer info;
+    char lower[11];  /* Enough for any encoding shortcut */
+
+    if (encoding == NULL)
+        encoding = PyUnicode_GetDefaultEncoding();
 
     /* Shortcuts for common default encodings */
-    if (strcmp(lower, "utf-8") == 0)
-        return PyUnicode_DecodeUTF8(s, size, errors);
-    else if ((strcmp(lower, "latin-1") == 0) ||
-             (strcmp(lower, "iso-8859-1") == 0))
-        return PyUnicode_DecodeLatin1(s, size, errors);
+    if (normalize_encoding(encoding, lower, sizeof(lower))) {
+        if (strcmp(lower, "utf-8") == 0)
+            return PyUnicode_DecodeUTF8(s, size, errors);
+        else if ((strcmp(lower, "latin-1") == 0) ||
+                 (strcmp(lower, "iso-8859-1") == 0))
+            return PyUnicode_DecodeLatin1(s, size, errors);
 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
-    else if (strcmp(lower, "mbcs") == 0)
-        return PyUnicode_DecodeMBCS(s, size, errors);
+        else if (strcmp(lower, "mbcs") == 0)
+            return PyUnicode_DecodeMBCS(s, size, errors);
 #endif
-    else if (strcmp(lower, "ascii") == 0)
-        return PyUnicode_DecodeASCII(s, size, errors);
-    else if (strcmp(lower, "utf-16") == 0)
-        return PyUnicode_DecodeUTF16(s, size, errors, 0);
-    else if (strcmp(lower, "utf-32") == 0)
-        return PyUnicode_DecodeUTF32(s, size, errors, 0);
+        else if (strcmp(lower, "ascii") == 0)
+            return PyUnicode_DecodeASCII(s, size, errors);
+        else if (strcmp(lower, "utf-16") == 0)
+            return PyUnicode_DecodeUTF16(s, size, errors, 0);
+        else if (strcmp(lower, "utf-32") == 0)
+            return PyUnicode_DecodeUTF32(s, size, errors, 0);
+    }
 
     /* Decode via the codec registry */
     buffer = NULL;
@@ -1463,11 +1478,17 @@
 
 PyObject *PyUnicode_EncodeFSDefault(PyObject *unicode)
 {
-    if (Py_FileSystemDefaultEncoding)
+    if (Py_FileSystemDefaultEncoding) {
+#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+        if (strcmp(Py_FileSystemDefaultEncoding, "mbcs") == 0)
+            return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(unicode),
+                                        PyUnicode_GET_SIZE(unicode),
+                                        NULL);
+#endif
         return PyUnicode_AsEncodedString(unicode,
                                          Py_FileSystemDefaultEncoding,
                                          "surrogateescape");
-    else
+    } else
         return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
                                      PyUnicode_GET_SIZE(unicode),
                                      "surrogateescape");
@@ -1478,6 +1499,7 @@
                                     const char *errors)
 {
     PyObject *v;
+    char lower[11];  /* Enough for any encoding shortcut */
 
     if (!PyUnicode_Check(unicode)) {
         PyErr_BadArgument();
@@ -1488,24 +1510,27 @@
         encoding = PyUnicode_GetDefaultEncoding();
 
     /* Shortcuts for common default encodings */
-    if (strcmp(encoding, "utf-8") == 0)
-        return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
-                                    PyUnicode_GET_SIZE(unicode),
-                                    errors);
-    else if (strcmp(encoding, "latin-1") == 0)
-        return PyUnicode_EncodeLatin1(PyUnicode_AS_UNICODE(unicode),
-                                      PyUnicode_GET_SIZE(unicode),
-                                      errors);
+    if (normalize_encoding(encoding, lower, sizeof(lower))) {
+        if (strcmp(lower, "utf-8") == 0)
+            return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
+                                        PyUnicode_GET_SIZE(unicode),
+                                        errors);
+        else if ((strcmp(lower, "latin-1") == 0) ||
+                 (strcmp(lower, "iso-8859-1") == 0))
+            return PyUnicode_EncodeLatin1(PyUnicode_AS_UNICODE(unicode),
+                                          PyUnicode_GET_SIZE(unicode),
+                                          errors);
 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
-    else if (strcmp(encoding, "mbcs") == 0)
-        return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(unicode),
-                                    PyUnicode_GET_SIZE(unicode),
-                                    errors);
+        else if (strcmp(lower, "mbcs") == 0)
+            return PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(unicode),
+                                        PyUnicode_GET_SIZE(unicode),
+                                        errors);
 #endif
-    else if (strcmp(encoding, "ascii") == 0)
-        return PyUnicode_EncodeASCII(PyUnicode_AS_UNICODE(unicode),
-                                     PyUnicode_GET_SIZE(unicode),
-                                     errors);
+        else if (strcmp(lower, "ascii") == 0)
+            return PyUnicode_EncodeASCII(PyUnicode_AS_UNICODE(unicode),
+                                         PyUnicode_GET_SIZE(unicode),
+                                         errors);
+    }
     /* During bootstrap, we may need to find the encodings
        package, to load the file system encoding, and require the
        file system encoding in order to load the encodings
@@ -1515,7 +1540,7 @@
        the encodings module is ASCII-only.  XXX could try wcstombs
        instead, if the file system encoding is the locale's
        encoding. */
-    else if (Py_FileSystemDefaultEncoding &&
+    if (Py_FileSystemDefaultEncoding &&
              strcmp(encoding, Py_FileSystemDefaultEncoding) == 0 &&
              !PyThreadState_GET()->interp->codecs_initialized)
         return PyUnicode_EncodeASCII(PyUnicode_AS_UNICODE(unicode),
@@ -1620,7 +1645,7 @@
     if (Py_FileSystemDefaultEncoding) {
 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
         if (strcmp(Py_FileSystemDefaultEncoding, "mbcs") == 0) {
-            return PyUnicode_DecodeMBCS(s, size, "surrogateescape");
+            return PyUnicode_DecodeMBCS(s, size, NULL);
         }
 #elif defined(__APPLE__)
         if (strcmp(Py_FileSystemDefaultEncoding, "utf-8") == 0) {
@@ -2711,7 +2736,8 @@
     PyUnicodeObject *unicode;
     Py_UNICODE *p;
 #ifndef Py_UNICODE_WIDE
-    int i, pairs;
+    int pairs = 0;
+    const unsigned char *qq;
 #else
     const int pairs = 0;
 #endif
@@ -2726,23 +2752,7 @@
 #endif
     PyObject *errorHandler = NULL;
     PyObject *exc = NULL;
-    /* On narrow builds we split characters outside the BMP into two
-       codepoints => count how much extra space we need. */
-#ifndef Py_UNICODE_WIDE
-    for (i = pairs = 0; i < size/4; i++)
-        if (((Py_UCS4 *)s)[i] >= 0x10000)
-            pairs++;
-#endif
 
-    /* This might be one to much, because of a BOM */
-    unicode = _PyUnicode_New((size+3)/4+pairs);
-    if (!unicode)
-        return NULL;
-    if (size == 0)
-        return (PyObject *)unicode;
-
-    /* Unpack UTF-32 encoded data */
-    p = unicode->str;
     q = (unsigned char *)s;
     e = q + size;
 
@@ -2794,6 +2804,24 @@
         iorder[3] = 0;
     }
 
+    /* On narrow builds we split characters outside the BMP into two
+       codepoints => count how much extra space we need. */
+#ifndef Py_UNICODE_WIDE
+    for (qq = q; qq < e; qq += 4)
+        if (qq[iorder[2]] != 0 || qq[iorder[3]] != 0)
+            pairs++;
+#endif
+
+    /* This might be one to much, because of a BOM */
+    unicode = _PyUnicode_New((size+3)/4+pairs);
+    if (!unicode)
+        return NULL;
+    if (size == 0)
+        return (PyObject *)unicode;
+
+    /* Unpack UTF-32 encoded data */
+    p = unicode->str;
+
     while (q < e) {
         Py_UCS4 ch;
         /* remaining bytes at the end? (size should be divisible by 4) */

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 14 11:30:15 2010
@@ -1129,6 +1129,7 @@
     int index;
     long rc;
     wchar_t *retValueBuf;
+    wchar_t *tmpBuf;
     BYTE *retDataBuf;
     DWORD retValueSize, bufValueSize;
     DWORD retDataSize, bufDataSize;
@@ -1161,7 +1162,6 @@
     }
 
     while (1) {
-        wchar_t *tmp;
         Py_BEGIN_ALLOW_THREADS
         rc = RegEnumValueW(hKey,
                   index,
@@ -1177,13 +1177,13 @@
             break;
 
         bufDataSize *= 2;
-        tmp = (char *)PyMem_Realloc(retDataBuf, bufDataSize);
-        if (tmp == NULL) {
+        tmpBuf = (wchar_t *)PyMem_Realloc(retDataBuf, bufDataSize);
+        if (tmpBuf == NULL) {
             PyErr_NoMemory();
             retVal = NULL;
             goto fail;
         }
-        retDataBuf = tmp;
+        retDataBuf = tmpBuf;
         retDataSize = bufDataSize;
         retValueSize = bufValueSize;
     }

Modified: python/branches/py3k-cdecimal/Parser/asdl_c.py
==============================================================================
--- python/branches/py3k-cdecimal/Parser/asdl_c.py	(original)
+++ python/branches/py3k-cdecimal/Parser/asdl_c.py	Mon Jun 14 11:30:15 2010
@@ -722,7 +722,7 @@
         }
         PyTuple_SET_ITEM(fnames, i, field);
     }
-    result = PyObject_CallFunction((PyObject*)&PyType_Type, "U(O){sOss}",
+    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
                     type, base, "_fields", fnames, "__module__", "_ast");
     Py_DECREF(fnames);
     return (PyTypeObject*)result;

Modified: python/branches/py3k-cdecimal/Python/Python-ast.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/Python-ast.c	(original)
+++ python/branches/py3k-cdecimal/Python/Python-ast.c	Mon Jun 14 11:30:15 2010
@@ -527,7 +527,7 @@
         }
         PyTuple_SET_ITEM(fnames, i, field);
     }
-    result = PyObject_CallFunction((PyObject*)&PyType_Type, "U(O){sOss}",
+    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
                     type, base, "_fields", fnames, "__module__", "_ast");
     Py_DECREF(fnames);
     return (PyTypeObject*)result;

Modified: python/branches/py3k-cdecimal/Python/errors.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/errors.c	(original)
+++ python/branches/py3k-cdecimal/Python/errors.c	Mon Jun 14 11:30:15 2010
@@ -679,7 +679,7 @@
             goto failure;
     }
     /* Create a real new-style class. */
-    result = PyObject_CallFunction((PyObject *)&PyType_Type, "UOO",
+    result = PyObject_CallFunction((PyObject *)&PyType_Type, "sOO",
                                    dot+1, bases, dict);
   failure:
     Py_XDECREF(bases);

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 14 11:30:15 2010
@@ -582,19 +582,6 @@
 
 #define CONV_UNICODE "(unicode conversion error)"
 
-/* explicitly check for float arguments when integers are expected.  For now
- * signal a warning.  Returns true if an exception was raised. */
-static int
-float_argument_warning(PyObject *arg)
-{
-    if (PyFloat_Check(arg) &&
-        PyErr_Warn(PyExc_DeprecationWarning,
-                   "integer argument expected, got float" ))
-        return 1;
-    else
-        return 0;
-}
-
 /* Explicitly check for float arguments when integers are expected.
    Return 1 for error, 0 if ok. */
 static int
@@ -791,14 +778,13 @@
     case 'L': {/* PY_LONG_LONG */
         PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * );
         PY_LONG_LONG ival;
-        if (float_argument_warning(arg))
+        if (float_argument_error(arg))
             return converterr("long<L>", arg, msgbuf, bufsize);
         ival = PyLong_AsLongLong(arg);
-        if (ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) {
+        if (ival == (PY_LONG_LONG)-1 && PyErr_Occurred())
             return converterr("long<L>", arg, msgbuf, bufsize);
-        } else {
+        else
             *p = ival;
-        }
         break;
     }
 
@@ -864,7 +850,7 @@
         break;
     }
 
-    /* XXX WAAAAH!  's', 'y', 'z', 'u', 'Z', 'e', 'w', 't' codes all
+    /* XXX WAAAAH!  's', 'y', 'z', 'u', 'Z', 'e', 'w' codes all
        need to be cleaned up! */
 
     case 's': {/* text string */
@@ -949,10 +935,15 @@
         count = convertbuffer(arg, p, &buf);
         if (count < 0)
             return converterr(buf, arg, msgbuf, bufsize);
-        else if (*format == '#') {
+        if (*format == '#') {
             FETCH_SIZE;
             STORE_SIZE(count);
             format++;
+        } else {
+            if (strlen(*p) != count)
+                return converterr(
+                    "bytes without null bytes",
+                    arg, msgbuf, bufsize);
         }
         break;
     }
@@ -1051,17 +1042,22 @@
                 *p = PyUnicode_AS_UNICODE(arg);
                 STORE_SIZE(PyUnicode_GET_SIZE(arg));
             }
+            else
+                return converterr("str or None", arg, msgbuf, bufsize);
             format++;
         } else {
             Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **);
 
             if (arg == Py_None)
                 *p = 0;
-            else if (PyUnicode_Check(arg))
+            else if (PyUnicode_Check(arg)) {
                 *p = PyUnicode_AS_UNICODE(arg);
-            else
-                return converterr("string or None",
-                                  arg, msgbuf, bufsize);
+                if (Py_UNICODE_strlen(*p) != PyUnicode_GET_SIZE(arg))
+                    return converterr(
+                        "str without null character or None",
+                        arg, msgbuf, bufsize);
+            } else
+                return converterr("str or None", arg, msgbuf, bufsize);
         }
         break;
     }
@@ -1240,6 +1236,11 @@
             FETCH_SIZE;
             STORE_SIZE(PyUnicode_GET_SIZE(arg));
             format++;
+        } else {
+            if (Py_UNICODE_strlen(*p) != PyUnicode_GET_SIZE(arg))
+                return converterr(
+                    "str without null character",
+                    arg, msgbuf, bufsize);
         }
         break;
     }
@@ -1258,7 +1259,7 @@
         if (PyByteArray_Check(arg))
             *p = arg;
         else
-            return converterr("buffer", arg, msgbuf, bufsize);
+            return converterr("bytearray", arg, msgbuf, bufsize);
         break;
     }
 
@@ -1361,45 +1362,6 @@
         break;
     }
 
-      /*TEO: This can be eliminated --- here only for backward
-        compatibility */
-    case 't': { /* 8-bit character buffer, read-only access */
-        char **p = va_arg(*p_va, char **);
-        PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
-        Py_ssize_t count;
-        Py_buffer view;
-
-        if (*format++ != '#')
-            return converterr(
-                "invalid use of 't' format character",
-                arg, msgbuf, bufsize);
-        if (pb == NULL || pb->bf_getbuffer == NULL)
-            return converterr(
-                "bytes or read-only character buffer",
-                arg, msgbuf, bufsize);
-
-        if (PyObject_GetBuffer(arg, &view, PyBUF_SIMPLE) != 0)
-            return converterr("string or single-segment read-only buffer",
-                              arg, msgbuf, bufsize);
-
-        count = view.len;
-        *p = view.buf;
-        if (pb->bf_releasebuffer)
-            return converterr(
-                "string or pinned buffer",
-                arg, msgbuf, bufsize);
-
-        PyBuffer_Release(&view);
-
-        if (count < 0)
-            return converterr("(unspecified)", arg, msgbuf, bufsize);
-        {
-            FETCH_SIZE;
-            STORE_SIZE(count);
-        }
-        break;
-    }
-
     default:
         return converterr("impossible<bad format char>", arg, msgbuf, bufsize);
 
@@ -1806,7 +1768,6 @@
     case 'z': /* string or None */
     case 'y': /* bytes */
     case 'u': /* unicode string */
-    case 't': /* buffer, read-only */
     case 'w': /* buffer, read-write */
         {
             (void) va_arg(*p_va, char **);

Modified: python/branches/py3k-cdecimal/Python/modsupport.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/modsupport.c	(original)
+++ python/branches/py3k-cdecimal/Python/modsupport.c	Mon Jun 14 11:30:15 2010
@@ -302,39 +302,7 @@
 
         case 's':
         case 'z':
-        {
-            PyObject *v;
-            char *str = va_arg(*p_va, char *);
-            Py_ssize_t n;
-            if (**p_format == '#') {
-                ++*p_format;
-                if (flags & FLAG_SIZE_T)
-                    n = va_arg(*p_va, Py_ssize_t);
-                else
-                    n = va_arg(*p_va, int);
-            }
-            else
-                n = -1;
-            if (str == NULL) {
-                v = Py_None;
-                Py_INCREF(v);
-            }
-            else {
-                if (n < 0) {
-                    size_t m = strlen(str);
-                    if (m > PY_SSIZE_T_MAX) {
-                        PyErr_SetString(PyExc_OverflowError,
-                            "string too long for Python string");
-                        return NULL;
-                    }
-                    n = (Py_ssize_t)m;
-                }
-                v = PyUnicode_FromStringAndSize(str, n);
-            }
-            return v;
-        }
-
-        case 'U':
+        case 'U':   /* XXX deprecated alias */
         {
             PyObject *v;
             char *str = va_arg(*p_va, char *);

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 14 11:30:15 2010
@@ -703,24 +703,26 @@
 #if defined(HAVE_LANGINFO_H) && defined(CODESET)
     char *codeset;
 
-    /* On Unix, set the file system encoding according to the
-       user's preference, if the CODESET names a well-known
-       Python codec, and Py_FileSystemDefaultEncoding isn't
-       initialized by other means. Also set the encoding of
-       stdin and stdout if these are terminals.  */
-    codeset = get_codeset();
-    if (codeset != NULL) {
-        Py_FileSystemDefaultEncoding = codeset;
-        Py_HasFileSystemDefaultEncoding = 0;
-        return;
-    }
+    if (Py_FileSystemDefaultEncoding == NULL) {
+        /* On Unix, set the file system encoding according to the
+           user's preference, if the CODESET names a well-known
+           Python codec, and Py_FileSystemDefaultEncoding isn't
+           initialized by other means. Also set the encoding of
+           stdin and stdout if these are terminals.  */
+        codeset = get_codeset();
+        if (codeset != NULL) {
+            Py_FileSystemDefaultEncoding = codeset;
+            Py_HasFileSystemDefaultEncoding = 0;
+            return;
+        }
 
-    PyErr_Clear();
-    fprintf(stderr,
-            "Unable to get the locale encoding: "
-            "fallback to utf-8\n");
-    Py_FileSystemDefaultEncoding = "utf-8";
-    Py_HasFileSystemDefaultEncoding = 1;
+        PyErr_Clear();
+        fprintf(stderr,
+                "Unable to get the locale encoding: "
+                "fallback to utf-8\n");
+        Py_FileSystemDefaultEncoding = "utf-8";
+        Py_HasFileSystemDefaultEncoding = 1;
+    }
 #endif
 
     /* the encoding is mbcs, utf-8 or ascii */
@@ -2055,7 +2057,7 @@
     fprintf(stderr, "Fatal Python error: %s\n", msg);
     fflush(stderr); /* it helps in Windows debug build */
     if (PyErr_Occurred()) {
-        PyErr_Print();
+        PyErr_PrintEx(0);
     }
 #ifdef MS_WINDOWS
     {

Modified: python/branches/py3k-cdecimal/Python/symtable.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/symtable.c	(original)
+++ python/branches/py3k-cdecimal/Python/symtable.c	Mon Jun 14 11:30:15 2010
@@ -1533,7 +1533,7 @@
 symtable_visit_alias(struct symtable *st, alias_ty a)
 {
     /* Compute store_name, the name actually bound by the import
-       operation.  It is diferent than a->name when a->name is a
+       operation.  It is different than a->name when a->name is a
        dotted package name (e.g. spam.eggs)
     */
     PyObject *store_name;

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 14 11:30:15 2010
@@ -1510,7 +1510,7 @@
                          PyLong_FromLong(PY_VERSION_HEX));
     svnversion_init();
     SET_SYS_FROM_STRING("subversion",
-                        Py_BuildValue("(UUU)", "CPython", branch,
+                        Py_BuildValue("(sss)", "CPython", branch,
                                       svn_revision));
     SET_SYS_FROM_STRING("dont_write_bytecode",
                          PyBool_FromLong(Py_DontWriteBytecodeFlag));
@@ -1839,6 +1839,9 @@
     PyObject *unicode = NULL, *writer = NULL, *args = NULL, *result = NULL;
     int err;
 
+    if (file == NULL)
+        return -1;
+
     unicode = PyUnicode_FromString(text);
     if (unicode == NULL)
         goto error;

Modified: python/branches/py3k-cdecimal/setup.py
==============================================================================
--- python/branches/py3k-cdecimal/setup.py	(original)
+++ python/branches/py3k-cdecimal/setup.py	Mon Jun 14 11:30:15 2010
@@ -14,6 +14,7 @@
 from distutils.command.build_ext import build_ext
 from distutils.command.install import install
 from distutils.command.install_lib import install_lib
+from distutils.spawn import find_executable
 
 # Were we compiled --with-pydebug or with #define Py_DEBUG?
 COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
@@ -525,6 +526,38 @@
 
         # readline
         do_readline = self.compiler_obj.find_library_file(lib_dirs, 'readline')
+        readline_termcap_library = ""
+        curses_library = ""
+        # Determine if readline is already linked against curses or tinfo.
+        if do_readline and find_executable('ldd'):
+            # Cannot use os.popen here in py3k.
+            tmpfile = os.path.join(self.build_temp, 'readline_termcap_lib')
+            if not os.path.exists(self.build_temp):
+                os.makedirs(self.build_temp)
+            os.system("ldd %s > %s" % (do_readline, tmpfile))
+            fp = open(tmpfile)
+            for ln in fp:
+                if 'curses' in ln:
+                    readline_termcap_library = re.sub(
+                        r'.*lib(n?cursesw?)\.so.*', r'\1', ln
+                    ).rstrip()
+                    break
+                if 'tinfo' in ln: # termcap interface split out from ncurses
+                    readline_termcap_library = 'tinfo'
+                    break
+            fp.close()
+            os.unlink(tmpfile)
+        # Issue 7384: If readline is already linked against curses,
+        # use the same library for the readline and curses modules.
+        if 'curses' in readline_termcap_library:
+            curses_library = readline_termcap_library
+        elif self.compiler_obj.find_library_file(lib_dirs, 'ncursesw'):
+            curses_library = 'ncursesw'
+        elif self.compiler_obj.find_library_file(lib_dirs, 'ncurses'):
+            curses_library = 'ncurses'
+        elif self.compiler_obj.find_library_file(lib_dirs, 'curses'):
+            curses_library = 'curses'
+
         if platform == 'darwin':
             os_release = int(os.uname()[2].split('.')[0])
             dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
@@ -548,14 +581,10 @@
                 readline_extra_link_args = ()
 
             readline_libs = ['readline']
-            if self.compiler_obj.find_library_file(lib_dirs,
-                                                   'ncursesw'):
-                readline_libs.append('ncursesw')
-            elif self.compiler_obj.find_library_file(lib_dirs,
-                                                     'ncurses'):
-                readline_libs.append('ncurses')
-            elif self.compiler_obj.find_library_file(lib_dirs, 'curses'):
-                readline_libs.append('curses')
+            if readline_termcap_library:
+                pass # Issue 7384: Already linked against curses or tinfo.
+            elif curses_library:
+                readline_libs.append(curses_library)
             elif self.compiler_obj.find_library_file(lib_dirs +
                                                      ['/usr/lib/termcap'],
                                                      'termcap'):
@@ -1070,19 +1099,15 @@
         # Curses support, requiring the System V version of curses, often
         # provided by the ncurses library.
         panel_library = 'panel'
-        if (self.compiler_obj.find_library_file(lib_dirs, 'ncursesw')):
-            curses_libs = ['ncursesw']
-            # Bug 1464056: If _curses.so links with ncursesw,
-            # _curses_panel.so must link with panelw.
-            panel_library = 'panelw'
-            exts.append( Extension('_curses', ['_cursesmodule.c'],
-                                   libraries = curses_libs) )
-        elif (self.compiler_obj.find_library_file(lib_dirs, 'ncurses')):
-            curses_libs = ['ncurses']
+        if curses_library.startswith('ncurses'):
+            if curses_library == 'ncursesw':
+                # Bug 1464056: If _curses.so links with ncursesw,
+                # _curses_panel.so must link with panelw.
+                panel_library = 'panelw'
+            curses_libs = [curses_library]
             exts.append( Extension('_curses', ['_cursesmodule.c'],
                                    libraries = curses_libs) )
-        elif (self.compiler_obj.find_library_file(lib_dirs, 'curses')
-              and platform != 'darwin'):
+        elif curses_library == 'curses' and platform != 'darwin':
                 # OSX has an old Berkeley curses, not good enough for
                 # the _curses module.
             if (self.compiler_obj.find_library_file(lib_dirs, 'terminfo')):


More information about the Python-checkins mailing list