[Python-checkins] r87616 - in python/branches/py3k-cdecimal: .gitignore Demo Doc/ACKS.txt Doc/README.txt Doc/c-api/buffer.rst Doc/c-api/codec.rst Doc/c-api/exceptions.rst Doc/c-api/import.rst Doc/c-api/init.rst Doc/c-api/intro.rst Doc/c-api/list.rst Doc/c-api/slice.rst Doc/c-api/typeobj.rst Doc/c-api/unicode.rst Doc/c-api/veryhigh.rst Doc/copyright.rst Doc/distutils/apiref.rst Doc/documenting/markup.rst Doc/extending/embedding.rst Doc/extending/extending.rst Doc/extending/windows.rst Doc/faq/extending.rst Doc/glossary.rst Doc/howto/index.rst Doc/howto/logging-cookbook.rst Doc/howto/logging.rst Doc/includes/tzinfo-examples.py Doc/install/index.rst Doc/library/_thread.rst Doc/library/allos.rst Doc/library/argparse.rst Doc/library/array.rst Doc/library/bdb.rst Doc/library/builtins.rst Doc/library/codecs.rst Doc/library/collections.rst Doc/library/compileall.rst Doc/library/concurrent.futures.rst Doc/library/configparser.rst Doc/library/ctypes.rst Doc/library/curses.rst Doc/library/dbm.rst Doc/library/difflib.rst Doc/library/dis.rst Doc/library/doctest.rst Doc/library/email.header.rst Doc/library/email.message.rst Doc/library/email.util.rst Doc/library/exceptions.rst Doc/library/fileformats.rst Doc/library/functions.rst Doc/library/functools.rst Doc/library/grp.rst Doc/library/hashlib.rst Doc/library/heapq.rst Doc/library/html.parser.rst Doc/library/http.client.rst Doc/library/imp.rst Doc/library/inspect.rst Doc/library/io.rst Doc/library/itertools.rst Doc/library/logging.config.rst Doc/library/logging.handlers.rst Doc/library/logging.rst Doc/library/msilib.rst Doc/library/multiprocessing.rst Doc/library/os.path.rst Doc/library/os.rst Doc/library/parser.rst Doc/library/pdb.rst Doc/library/pickle.rst Doc/library/pkgutil.rst Doc/library/platform.rst Doc/library/pty.rst Doc/library/py_compile.rst Doc/library/pydoc.rst Doc/library/random.rst Doc/library/re.rst Doc/library/runpy.rst Doc/library/shelve.rst Doc/library/socket.rst Doc/library/someos.rst Doc/library/sqlite3.rst Doc/library/stdtypes.rst Doc/library/string.rst Doc/library/struct.rst Doc/library/subprocess.rst Doc/library/sys.rst Doc/library/test.rst Doc/library/textwrap.rst Doc/library/threading.rst Doc/library/tkinter.rst Doc/library/tkinter.tix.rst Doc/library/trace.rst Doc/library/turtle.rst Doc/library/unicodedata.rst Doc/library/unittest.rst Doc/library/urllib.parse.rst Doc/library/urllib.request.rst Doc/library/warnings.rst Doc/library/xml.dom.minidom.rst Doc/library/zipfile.rst Doc/license.rst Doc/reference/datamodel.rst Doc/reference/expressions.rst Doc/reference/lexical_analysis.rst Doc/tools/sphinxext/static/basic.css Doc/tools/sphinxext/susp-ignored.csv Doc/tutorial/interpreter.rst Doc/tutorial/stdlib.rst Doc/using/cmdline.rst Doc/whatsnew/2.7.rst Doc/whatsnew/3.2.rst Include/Python.h Include/abstract.h Include/ast.h Include/bytearrayobject.h Include/bytes_methods.h Include/bytesobject.h Include/cellobject.h Include/ceval.h Include/classobject.h Include/code.h Include/codecs.h Include/compile.h Include/complexobject.h Include/datetime.h Include/descrobject.h Include/dictobject.h Include/dtoa.h Include/eval.h Include/fileobject.h Include/floatobject.h Include/frameobject.h Include/funcobject.h Include/genobject.h Include/import.h Include/listobject.h Include/longintrepr.h Include/longobject.h Include/marshal.h Include/memoryobject.h Include/methodobject.h Include/modsupport.h Include/moduleobject.h Include/object.h Include/objimpl.h Include/parsetok.h Include/patchlevel.h Include/pyarena.h Include/pyatomic.h Include/pyctype.h Include/pydebug.h Include/pyerrors.h Include/pygetopt.h Include/pymath.h Include/pystate.h Include/pystrtod.h Include/pythonrun.h Include/pythread.h Include/pytime.h Include/setobject.h Include/sliceobject.h Include/structseq.h Include/symtable.h Include/sysmodule.h Include/timefuncs.h Include/token.h Include/traceback.h Include/tupleobject.h Include/typeslots.h Include/ucnhash.h Include/unicodeobject.h Include/warnings.h Include/weakrefobject.h LICENSE Lib/_abcoll.py Lib/_pyio.py Lib/_weakrefset.py Lib/argparse.py Lib/bdb.py Lib/codecs.py Lib/collections.py Lib/compileall.py Lib/concurrent/futures/_base.py Lib/concurrent/futures/process.py Lib/configparser.py Lib/dbm/dumb.py Lib/decimal.py Lib/difflib.py Lib/distutils/__init__.py Lib/distutils/archive_util.py Lib/distutils/command/build_ext.py Lib/distutils/command/install.py Lib/distutils/sysconfig.py Lib/doctest.py Lib/email/_parseaddr.py Lib/email/generator.py Lib/email/header.py Lib/email/message.py Lib/email/test/test_email.py Lib/email/utils.py Lib/encodings/aliases.py Lib/encodings/base64_codec.py Lib/encodings/bz2_codec.py Lib/encodings/hex_codec.py Lib/encodings/quopri_codec.py Lib/encodings/rot_13.py Lib/encodings/uu_codec.py Lib/encodings/zlib_codec.py Lib/functools.py Lib/getpass.py Lib/gettext.py Lib/html/parser.py Lib/http/client.py Lib/http/cookies.py Lib/http/server.py Lib/idlelib/Bindings.py Lib/idlelib/EditorWindow.py Lib/idlelib/FileList.py Lib/idlelib/IOBinding.py Lib/idlelib/idlever.py Lib/idlelib/macosxSupport.py Lib/inspect.py Lib/json/tests Lib/lib2to3 Lib/lib2to3/fixes/fix_urllib.py Lib/lib2to3/main.py Lib/lib2to3/refactor.py Lib/lib2to3/tests/test_refactor.py Lib/lib2to3/tests/test_util.py Lib/logging/__init__.py Lib/mimetypes.py Lib/multiprocessing/__init__.py Lib/multiprocessing/connection.py Lib/multiprocessing/dummy/__init__.py Lib/multiprocessing/dummy/connection.py Lib/multiprocessing/forking.py Lib/multiprocessing/heap.py Lib/multiprocessing/managers.py Lib/multiprocessing/pool.py Lib/multiprocessing/process.py Lib/multiprocessing/queues.py Lib/multiprocessing/reduction.py Lib/multiprocessing/sharedctypes.py Lib/multiprocessing/synchronize.py Lib/multiprocessing/util.py Lib/netrc.py Lib/numbers.py Lib/os.py Lib/pdb.py Lib/py_compile.py Lib/pydoc.py Lib/pydoc_data/_pydoc.css Lib/pydoc_data/topics.py Lib/random.py Lib/shelve.py Lib/shutil.py Lib/site.py Lib/smtpd.py Lib/subprocess.py Lib/sysconfig.py Lib/tabnanny.py Lib/telnetlib.py Lib/tempfile.py Lib/test/__main__.py Lib/test/crashers/README Lib/test/datetimetester.py Lib/test/json_tests Lib/test/pystone.py Lib/test/regrtest.py Lib/test/script_helper.py Lib/test/subprocessdata Lib/test/support.py Lib/test/symlink_support.py Lib/test/test_abc.py Lib/test/test_argparse.py Lib/test/test_array.py Lib/test/test_asyncore.py Lib/test/test_bool.py Lib/test/test_builtin.py Lib/test/test_calendar.py Lib/test/test_cfgparser.py Lib/test/test_cgi.py Lib/test/test_cmath.py Lib/test/test_cmd_line.py Lib/test/test_codecs.py Lib/test/test_collections.py Lib/test/test_compileall.py Lib/test/test_complex.py Lib/test/test_concurrent_futures.py Lib/test/test_contextlib.py Lib/test/test_csv.py Lib/test/test_dbm_gnu.py Lib/test/test_decimal.py Lib/test/test_descr.py Lib/test/test_difflib.py Lib/test/test_dis.py Lib/test/test_float.py Lib/test/test_fork1.py Lib/test/test_fractions.py Lib/test/test_functools.py Lib/test/test_grp.py Lib/test/test_htmlparser.py Lib/test/test_http_cookies.py Lib/test/test_httplib.py Lib/test/test_httpservers.py Lib/test/test_import.py Lib/test/test_inspect.py Lib/test/test_int.py Lib/test/test_io.py Lib/test/test_itertools.py Lib/test/test_json.py Lib/test/test_listcomps.py Lib/test/test_logging.py Lib/test/test_long.py Lib/test/test_math.py Lib/test/test_memoryview.py Lib/test/test_multiprocessing.py Lib/test/test_netrc.py Lib/test/test_normalization.py Lib/test/test_ntpath.py Lib/test/test_os.py Lib/test/test_pdb.py Lib/test/test_posixpath.py Lib/test/test_pydoc.py Lib/test/test_pyexpat.py Lib/test/test_random.py Lib/test/test_range.py Lib/test/test_runpy.py Lib/test/test_shelve.py Lib/test/test_shutil.py Lib/test/test_site.py Lib/test/test_smtpd.py Lib/test/test_smtplib.py Lib/test/test_socket.py Lib/test/test_ssl.py Lib/test/test_struct.py Lib/test/test_subprocess.py Lib/test/test_sys.py Lib/test/test_syslog.py Lib/test/test_telnetlib.py Lib/test/test_tempfile.py Lib/test/test_threadsignals.py Lib/test/test_time.py Lib/test/test_trace.py Lib/test/test_tuple.py Lib/test/test_types.py Lib/test/test_unicode.py Lib/test/test_unicodedata.py Lib/test/test_unittest.py Lib/test/test_urllib.py Lib/test/test_urllib2.py Lib/test/test_urllibnet.py Lib/test/test_urlparse.py Lib/test/test_weakset.py Lib/test/test_winsound.py Lib/test/test_wsgiref.py Lib/test/test_xml_etree.py Lib/test/test_xml_etree_c.py Lib/test/test_xmlrpc.py Lib/test/test_zipfile.py Lib/test/test_zipimport_support.py Lib/test/test_zlib.py Lib/test/win_console_handler.py Lib/test/zip_cp437_header.zip Lib/threading.py Lib/tkinter/__init__.py Lib/tkinter/scrolledtext.py Lib/tkinter/test/test_ttk/test_widgets.py Lib/tkinter/tix.py Lib/turtle.py Lib/turtledemo/__main__.py Lib/turtledemo/about_turtledemo.txt Lib/turtledemo/demohelp.txt Lib/unittest/case.py Lib/unittest/main.py Lib/unittest/runner.py Lib/unittest/suite.py Lib/unittest/test/_test_warnings.py Lib/unittest/test/test_assertions.py Lib/unittest/test/test_break.py Lib/unittest/test/test_case.py Lib/unittest/test/test_discovery.py Lib/unittest/test/test_functiontestcase.py Lib/unittest/test/test_loader.py Lib/unittest/test/test_program.py Lib/unittest/test/test_runner.py Lib/unittest/test/test_setups.py Lib/unittest/test/test_suite.py Lib/unittest/util.py Lib/urllib/parse.py Lib/urllib/request.py Lib/wave.py Lib/weakref.py Lib/webbrowser.py Lib/wsgiref/util.py Lib/xml/etree/ElementTree.py Lib/xmlrpc/client.py Lib/zipfile.py Mac/BuildScript/build-installer.py Mac/Makefile.in Mac/README Makefile.pre.in Misc/ACKS Misc/NEWS Misc/README Misc/RFD Misc/RPM/python-3.2.spec Misc/SpecialBuilds.txt Misc/pymemcompat.h Misc/python-wing4.wpr Misc/python.man Misc/python.pc.in Misc/setuid-prog.c Modules/_collectionsmodule.c Modules/_ctypes/_ctypes.c Modules/_ctypes/cfield.c Modules/_datetimemodule.c Modules/_elementtree.c Modules/_functoolsmodule.c Modules/_gdbmmodule.c Modules/_io/bufferedio.c Modules/_lsprof.c Modules/_posixsubprocess.c Modules/_ssl.c Modules/_struct.c Modules/_testcapimodule.c Modules/_threadmodule.c Modules/arraymodule.c Modules/getpath.c Modules/grpmodule.c Modules/itertoolsmodule.c Modules/main.c Modules/mmapmodule.c Modules/parsermodule.c Modules/posixmodule.c Modules/pwdmodule.c Modules/pyexpat.c Modules/readline.c Modules/resource.c Modules/signalmodule.c Modules/socketmodule.c Modules/socketmodule.h Modules/spwdmodule.c Modules/symtablemodule.c Modules/syslogmodule.c Modules/timemodule.c Modules/unicodedata.c Modules/xxlimited.c Objects/bytearrayobject.c Objects/bytesobject.c Objects/complexobject.c Objects/descrobject.c Objects/floatobject.c Objects/funcobject.c Objects/genobject.c Objects/listobject.c Objects/longobject.c Objects/memoryobject.c Objects/moduleobject.c Objects/object.c Objects/obmalloc.c Objects/rangeobject.c Objects/setobject.c Objects/sliceobject.c Objects/stringlib/formatter.h Objects/structseq.c Objects/tupleobject.c Objects/typeobject.c Objects/typeslots.inc Objects/typeslots.py Objects/unicodectype.c Objects/unicodeobject.c PC/VC6/readme.txt PC/getpathp.c PC/pyconfig.h PC/python3.def PC/python3.mak PC/python32gen.py PC/python32stub.def PC/python3dll.c PC/python_nt.rc PCbuild/build_tkinter.py PCbuild/make_buildinfo.c PCbuild/pcbuild.sln PCbuild/pyproject.vsprops PCbuild/python3dll.vcproj PCbuild/pythoncore.vcproj PCbuild/readme.txt PCbuild/xxlimited.vcproj Parser/pgenmain.c Parser/printgrammar.c Parser/tokenizer.c Python/_warnings.c Python/ast.c Python/bltinmodule.c Python/ceval.c Python/compile.c Python/dynload_shlib.c Python/dynload_win.c Python/errors.c Python/future.c Python/getcopyright.c Python/import.c Python/peephole.c Python/pyarena.c Python/pythonrun.c Python/sysmodule.c Python/thread_nt.h Python/thread_pthread.h Python/traceback.c README Tools/README Tools/buildbot/external-amd64.bat Tools/buildbot/external-common.bat Tools/buildbot/external.bat Tools/buildbot/test.bat Tools/demo Tools/framer Tools/msi/msi.py Tools/parser Tools/scripts/README Tools/scripts/abitype.py Tools/scripts/find-uname.py Tools/scripts/get-remote-certificate.py Tools/scripts/redemo.py Tools/scripts/untabify.py Tools/ssl Tools/test2to3 Tools/unicode/gencodec.py Tools/world configure configure.in pyconfig.h.in runtests.sh setup.py

stefan.krah python-checkins at python.org
Sun Jan 2 13:18:44 CET 2011


Author: stefan.krah
Date: Sun Jan  2 13:18:37 2011
New Revision: 87616

Log:
Merged revisions 86689-86690,86693-86694,86697,86699-86702,86705,86708,86713,86717,86720,86725,86727,86729-86734,86737,86743-86747,86750-86751,86758-86759,86791,86794-86795,86797-86801,86804,86808,86819,86823-86825,86828-86829,86837-86839,86842-86845,86854-86857,86861,86864,86867-86870,86874-86875,86878-86884,86887-86893,86895-86896,86901-86903,86905-86925,86928-86937,86940,86943-86971,86974-86977,86979-86981,86983-86986,86993,86996-87004,87007-87014,87017-87032,87036,87038-87045,87047-87048,87050-87052,87054,87056-87060,87062-87084,87086,87088,87093-87094,87101-87110,87112-87119,87124-87137,87140-87141,87145-87161,87171-87177,87179-87186,87188-87194,87197-87198,87201-87210,87212-87217,87221-87222,87225,87228-87230,87233,87236,87238,87241,87245-87248,87251,87256,87258,87260-87277,87280,87283-87284,87288-87289,87292-87304,87306,87312,87315-87317,87323-87324,87327-87329,87337-87341,87344-87346,87348,87350-87356,87359-87368,87371-87374,87377-87378,87381,87384,87389-87400,87402-87403,87408,87411,87415,87418,87421,87424-87427,87430,87433,87435-87443,87445-87448,87451,87454-87455,87458-87463,87466-87479,87482-87483,87485-87486,87489,87492-87493,87496-87498,87501,87504-87508,87512-87514,87516-87539,87542,87547-87550,87553,87556-87564,87567,87569,87571,87573,87575,87577,87579-87590,87593-87595,87598,87601,87603-87604,87606-87607,87610-87612,87615 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r86689 | kristjan.jonsson | 2010-11-22 12:37:06 +0100 (Mon, 22 Nov 2010) | 3 lines
  
  issue 10501
  make_buildinfo regression with unquoted path
  Make_buildinfo.exe should be called with a quoted path, and should quote the full paths to its temp files, to support spaces in filenames.
................
  r86690 | ezio.melotti | 2010-11-22 13:56:58 +0100 (Mon, 22 Nov 2010) | 1 line
  
  #9424: add a DeprecationWarning for assertEquals, assertNotEquals, assertAlmostEquals, assertNotAlmostEquals, and assert_
................
  r86693 | antoine.pitrou | 2010-11-22 17:19:04 +0100 (Mon, 22 Nov 2010) | 3 lines
  
  Fix tests when ctypes isn't available
................
  r86694 | antoine.pitrou | 2010-11-22 17:26:21 +0100 (Mon, 22 Nov 2010) | 3 lines
  
  Fix test_multiprocessing when ctypes isn't available
................
  r86697 | alexander.belopolsky | 2010-11-22 20:40:51 +0100 (Mon, 22 Nov 2010) | 1 line
  
  Issue #6878: Fixed return type of tkinter methods documented to return lists.
................
  r86699 | lukasz.langa | 2010-11-23 00:31:26 +0100 (Tue, 23 Nov 2010) | 3 lines
  
  Issue #9846: ZipExtFile provides no mechanism for closing the underlying file object
................
  r86700 | lukasz.langa | 2010-11-23 01:15:02 +0100 (Tue, 23 Nov 2010) | 3 lines
  
  zipfile: remove remaining ResourceWarnings
................
  r86701 | lukasz.langa | 2010-11-23 01:19:53 +0100 (Tue, 23 Nov 2010) | 3 lines
  
  information on Issue #9846
................
  r86702 | terry.reedy | 2010-11-23 07:01:31 +0100 (Tue, 23 Nov 2010) | 2 lines
  
  Issue 9222 Fix filetypes for open dialog
................
  r86705 | georg.brandl | 2010-11-23 08:54:19 +0100 (Tue, 23 Nov 2010) | 1 line
  
  #10468: document Unicode exception creation and access functions.
................
  r86708 | georg.brandl | 2010-11-23 09:37:54 +0100 (Tue, 23 Nov 2010) | 2 lines
  
  #10511: clarification of what heaps are; suggested by Johannes Hoff.
................
  r86713 | georg.brandl | 2010-11-23 19:14:57 +0100 (Tue, 23 Nov 2010) | 1 line
  
  assert.h is also included. Thanks to Savio Sena.
................
  r86717 | terry.reedy | 2010-11-23 21:17:24 +0100 (Tue, 23 Nov 2010) | 2 lines
  
  Issue 1859: Doc that textwrap does not break on \n (pending possible behavior patch). Patch by Jeremy Thurgood.
................
  r86720 | terry.reedy | 2010-11-23 21:32:47 +0100 (Tue, 23 Nov 2010) | 2 lines
  
  IssIssue 1859: Add Jeremy Thurgood to Misc/ACKS
................
  r86725 | georg.brandl | 2010-11-24 10:09:29 +0100 (Wed, 24 Nov 2010) | 1 line
  
  Remove UTF-8 BOM.
................
  r86727 | brian.curtin | 2010-11-24 14:14:05 +0100 (Wed, 24 Nov 2010) | 7 lines
  
  Fix #10027. st_nlink not set on Windows calls to os.stat/lstat.
  
  Note: This patch has no tests because as of now there is no way to create
  links. #8879 adds that and the tests will go in there. I've manually observed
  that existing links on my system function properly with this.
................
  r86729 | brian.curtin | 2010-11-24 14:23:18 +0100 (Wed, 24 Nov 2010) | 2 lines
  
  ifdef a Windows specific section.
................
  r86730 | barry.warsaw | 2010-11-24 19:18:21 +0100 (Wed, 24 Nov 2010) | 2 lines
  
  Remove unnecessary import.
................
  r86731 | barry.warsaw | 2010-11-24 20:43:47 +0100 (Wed, 24 Nov 2010) | 2 lines
  
  Final patch for issue 9807.
................
  r86732 | ezio.melotti | 2010-11-24 21:18:02 +0100 (Wed, 24 Nov 2010) | 1 line
  
  #10299: Add a table that lists all the built-in functions in functions.rst
................
  r86733 | brian.curtin | 2010-11-24 21:24:31 +0100 (Wed, 24 Nov 2010) | 8 lines
  
  Fix #8879. Add os.link support to Windows.
  
  Additionally, the st_ino attribute of stat structures was not being filled
  in. This was left out of the fix to #10027 and was noticed due to
  test_tarfile failing when applying the patch for this issue. An earlier
  version of the fix to #10027 included st_ino, but that attribute got lost
  in the shuffle of a few review/fix cycles. All tests pass.
................
  r86734 | barry.warsaw | 2010-11-24 21:30:00 +0100 (Wed, 24 Nov 2010) | 5 lines
  
  Put /usr/local paths after the relative paths in library_dirs and
  include_dirs, so installed non-matching shared libraries don't break extension
  module linking.  Fixes issue 10520.
................
  r86737 | ezio.melotti | 2010-11-24 23:02:18 +0100 (Wed, 24 Nov 2010) | 1 line
  
  Add NEWS entry for r86732 and fix double function in the table.
................
  r86743 | barry.warsaw | 2010-11-25 02:34:47 +0100 (Thu, 25 Nov 2010) | 2 lines
  
  sys.abiflags may not be defined on all platforms.
................
  r86744 | barry.warsaw | 2010-11-25 04:46:44 +0100 (Thu, 25 Nov 2010) | 2 lines
  
  sys.abiflags is not defined on all platforms.
................
  r86745 | terry.reedy | 2010-11-25 07:12:34 +0100 (Thu, 25 Nov 2010) | 2 lines
  
  Issue 2986: Add autojunk paramater to SequenceMatcher to turn off heuristic. Patch by Terry Reedy, Eli Bendersky, and Simon Cross
................
  r86746 | raymond.hettinger | 2010-11-25 09:11:57 +0100 (Thu, 25 Nov 2010) | 1 line
  
  Clean-up docstring, comments, and whitespace.
................
  r86747 | amaury.forgeotdarc | 2010-11-25 09:13:35 +0100 (Thu, 25 Nov 2010) | 3 lines
  
  Fix compilation warnings seen on Windows.
  'typecode' is always an ascii letter, there was no data lost.
................
  r86750 | senthil.kumaran | 2010-11-25 15:56:44 +0100 (Thu, 25 Nov 2010) | 3 lines
  
  Mouse support and colour to Demo/curses/life.py by Dafydd Crosby
................
  r86751 | eric.smith | 2010-11-25 17:08:06 +0100 (Thu, 25 Nov 2010) | 1 line
  
  Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
................
  r86758 | eric.araujo | 2010-11-26 01:39:59 +0100 (Fri, 26 Nov 2010) | 2 lines
  
  #10453 follow-up: Fix test_quiet on Windows, thanks to Stephan Krah.
................
  r86759 | senthil.kumaran | 2010-11-26 03:20:04 +0100 (Fri, 26 Nov 2010) | 3 lines
  
   s/colour/color/g 
................
  r86791 | stefan.krah | 2010-11-26 11:54:09 +0100 (Fri, 26 Nov 2010) | 1 line
  
  Indentation cleanup.
................
  r86794 | georg.brandl | 2010-11-26 12:50:13 +0100 (Fri, 26 Nov 2010) | 1 line
  
  #10526: fix typo.
................
  r86795 | georg.brandl | 2010-11-26 12:55:48 +0100 (Fri, 26 Nov 2010) | 1 line
  
  Use PyLong_FromLong where appropriate.
................
  r86797 | georg.brandl | 2010-11-26 13:05:27 +0100 (Fri, 26 Nov 2010) | 1 line
  
  Modernize code in effective().
................
  r86798 | georg.brandl | 2010-11-26 13:05:48 +0100 (Fri, 26 Nov 2010) | 1 line
  
  #10420: fix docs of bdb.effective().
................
  r86799 | georg.brandl | 2010-11-26 13:08:19 +0100 (Fri, 26 Nov 2010) | 1 line
  
  Remove parenthetical remark that is confusing now that the module is not named "__builtin__" anymore.
................
  r86800 | georg.brandl | 2010-11-26 13:10:06 +0100 (Fri, 26 Nov 2010) | 1 line
  
  Typo fix.
................
  r86801 | georg.brandl | 2010-11-26 13:12:14 +0100 (Fri, 26 Nov 2010) | 1 line
  
  Better example for os.system(): do not change the system time.
................
  r86804 | stefan.krah | 2010-11-26 13:58:05 +0100 (Fri, 26 Nov 2010) | 1 line
  
  Issue #10383: Fix two leaks.
................
  r86808 | stefan.krah | 2010-11-26 17:16:47 +0100 (Fri, 26 Nov 2010) | 1 line
  
  Further indentation cleanup.
................
  r86819 | alexander.belopolsky | 2010-11-26 19:51:39 +0100 (Fri, 26 Nov 2010) | 1 line
  
  Fixed deprecation warnings.
................
  r86823 | eric.araujo | 2010-11-27 00:31:07 +0100 (Sat, 27 Nov 2010) | 2 lines
  
  Use link-generating markup (see #9312)
................
  r86824 | eric.araujo | 2010-11-27 00:46:18 +0100 (Sat, 27 Nov 2010) | 2 lines
  
  Rewrap long lines + minor edits
................
  r86825 | raymond.hettinger | 2010-11-27 09:09:40 +0100 (Sat, 27 Nov 2010) | 1 line
  
  Replace _nbits() with int.bit_length().
................
  r86828 | raymond.hettinger | 2010-11-27 10:31:37 +0100 (Sat, 27 Nov 2010) | 1 line
  
  Issue 10242: unittest.assertItemsEqual makes too many assumptions.
................
  r86829 | stefan.krah | 2010-11-27 12:44:18 +0100 (Sat, 27 Nov 2010) | 1 line
  
  Fix additional leaks.
................
  r86837 | barry.warsaw | 2010-11-27 21:03:03 +0100 (Sat, 27 Nov 2010) | 2 lines
  
  Roumen Petrov's fix for when all paths are absolute.  (Issue 10520)
................
  r86838 | antoine.pitrou | 2010-11-27 21:40:43 +0100 (Sat, 27 Nov 2010) | 3 lines
  
  Make doc for PyErr_Format() up to date.
................
  r86839 | terry.reedy | 2010-11-27 21:52:14 +0100 (Sat, 27 Nov 2010) | 2 lines
  
  Add version-added note twice for new difflib SequenceMatcher autojunk parameter.
................
  r86842 | antoine.pitrou | 2010-11-27 23:00:11 +0100 (Sat, 27 Nov 2010) | 4 lines
  
  Issue #10518: Bring back the callable() builtin.
  Approved by Guido (BDFL) and Georg (RM).
................
  r86843 | stefan.krah | 2010-11-27 23:06:49 +0100 (Sat, 27 Nov 2010) | 1 line
  
  Windows: fix leak in posix_listdir.
................
  r86844 | benjamin.peterson | 2010-11-28 03:51:28 +0100 (Sun, 28 Nov 2010) | 1 line
  
  there's now a setup.py switch for this
................
  r86845 | ezio.melotti | 2010-11-28 05:18:54 +0100 (Sun, 28 Nov 2010) | 1 line
  
  Add callable() to the built-in functions table.
................
  r86854 | brian.curtin | 2010-11-29 00:59:46 +0100 (Mon, 29 Nov 2010) | 6 lines
  
  Fix for #8879.
  Amaury noticed that this was originally written in a way that would fail on
  names that can't be encoded with the mbcs codec. Restructured the function
  to work with wide names first then narrow names second, to fall in line
  with the way other functions are written in posixmodule.c.
................
  r86855 | raymond.hettinger | 2010-11-29 02:38:25 +0100 (Mon, 29 Nov 2010) | 1 line
  
  Do not add an obsolete unittest name to Py3.2.
................
  r86856 | ezio.melotti | 2010-11-29 03:02:10 +0100 (Mon, 29 Nov 2010) | 1 line
  
  Use assertCountEqual instead of assertItemsEqual
................
  r86857 | raymond.hettinger | 2010-11-29 04:56:12 +0100 (Mon, 29 Nov 2010) | 1 line
  
  Issue #10565:  Iterator ABC should require both __next__ and __iter__.
................
  r86861 | senthil.kumaran | 2010-11-29 12:54:17 +0100 (Mon, 29 Nov 2010) | 5 lines
  
  Fix #10561 - Fix pdb behavior. Delete the breakpoints by breakpoint number.
  Handle multiple breakpoints at same line. Update docs/test. 
  Patch by Xavier de Gaye.
................
  r86864 | senthil.kumaran | 2010-11-29 13:42:29 +0100 (Mon, 29 Nov 2010) | 3 lines
  
  Remove the comment used while testing.
................
  r86867 | georg.brandl | 2010-11-29 15:50:54 +0100 (Mon, 29 Nov 2010) | 1 line
  
  Fix indentation bug.
................
  r86868 | georg.brandl | 2010-11-29 15:53:15 +0100 (Mon, 29 Nov 2010) | 1 line
  
  Fix heading style inconsistencies.
................
  r86869 | georg.brandl | 2010-11-29 21:12:24 +0100 (Mon, 29 Nov 2010) | 1 line
  
  Code style cleanup in bdb.
................
  r86870 | georg.brandl | 2010-11-29 21:19:15 +0100 (Mon, 29 Nov 2010) | 1 line
  
  Use booleans where applicable.
................
  r86874 | raymond.hettinger | 2010-11-30 03:49:29 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Issue #10323: Predictable final state for slice().
................
  r86875 | alexander.belopolsky | 2010-11-30 04:03:30 +0100 (Tue, 30 Nov 2010) | 3 lines
  
  Issue #10572: Moved json tests to Lib/test/json_tests.
  Approved by Raymond Hettinger.
................
  r86878 | nick.coghlan | 2010-11-30 07:19:46 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Issue 10586: change the new functools.lru_cache implementation to expose the maximum and current cache sizes through the public statistics API. This API is now a single function that returns a named tuple.
................
  r86879 | nick.coghlan | 2010-11-30 07:36:04 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Issue 10220: switch to using string constants rather than integers for inspect.getgeneratorstate() return values and make debugging friendly str() and repr() for generator states a requirement in the test suite
................
  r86880 | raymond.hettinger | 2010-11-30 08:13:04 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Neaten-up a bit.
................
  r86881 | georg.brandl | 2010-11-30 08:43:28 +0100 (Tue, 30 Nov 2010) | 1 line
  
  #10584: fix bad links.
................
  r86882 | georg.brandl | 2010-11-30 09:20:16 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Fix input type for zlib.
................
  r86883 | georg.brandl | 2010-11-30 10:30:54 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Include structseq.h in Python.h, and remove now-redundant includes in individual sources.
................
  r86884 | georg.brandl | 2010-11-30 10:41:01 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Remove redundant includes of headers that are already included by Python.h.
................
  r86887 | georg.brandl | 2010-11-30 15:57:54 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Fix typo.
................
  r86888 | brian.curtin | 2010-11-30 16:40:04 +0100 (Tue, 30 Nov 2010) | 3 lines
  
  Try to fix failures on platforms that can't encode the test characters.
  Skip the test if encoding fails.
................
  r86889 | nick.coghlan | 2010-11-30 16:48:08 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Issue 9873: the URL parsing functions now accept ASCII encoded byte sequences in addition to character strings
................
  r86890 | brian.curtin | 2010-11-30 16:54:04 +0100 (Tue, 30 Nov 2010) | 2 lines
  
  Actually fix what I attempted to fix in r86888...
................
  r86891 | alexander.belopolsky | 2010-11-30 17:56:15 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Issue #10552: Partially fixed a sort error in Tools/unicode/gencodec.py
................
  r86892 | eric.araujo | 2010-11-30 18:20:31 +0100 (Tue, 30 Nov 2010) | 2 lines
  
  Let’s keep “throw” for the generator method and use “raise” elsewhere.
................
  r86893 | alexander.belopolsky | 2010-11-30 18:30:43 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Issue #9598: untabify.py will now respect encoding cookie in the files it processes
................
  r86895 | raymond.hettinger | 2010-11-30 18:45:41 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Add some internal links.
................
  r86896 | daniel.stutzbach | 2010-11-30 18:49:53 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Fix typo: "ofbytes" should be "of bytes"
................
  r86901 | raymond.hettinger | 2010-11-30 20:15:45 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Add example, tighten text, and minor clean-ups.
................
  r86902 | raymond.hettinger | 2010-11-30 21:02:57 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Documentation nits.
................
  r86903 | raymond.hettinger | 2010-11-30 21:32:59 +0100 (Tue, 30 Nov 2010) | 1 line
  
  Add link to specification.
................
  r86905 | antoine.pitrou | 2010-11-30 23:23:20 +0100 (Tue, 30 Nov 2010) | 4 lines
  
  Issue #8685: Speed up set difference `a - b` when source set `a` is
  much larger than operand `b`.  Patch by Andrew Bennetts.
................
  r86906 | brian.curtin | 2010-12-01 00:46:54 +0100 (Wed, 01 Dec 2010) | 3 lines
  
  Fix #10591. Fix test_os for refleak runs.
  Split a common setUp/tearDown into the appropriate parts.
................
  r86907 | raymond.hettinger | 2010-12-01 01:47:56 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Doc and docstring nits.
................
  r86908 | ezio.melotti | 2010-12-01 01:56:10 +0100 (Wed, 01 Dec 2010) | 1 line
  
  #10535: Enable silenced warnings in unittest by default
................
  r86909 | ezio.melotti | 2010-12-01 02:45:53 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Fix test failure in debug builds and add NEWS entry for r86908
................
  r86910 | ezio.melotti | 2010-12-01 03:32:32 +0100 (Wed, 01 Dec 2010) | 1 line
  
  #10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
................
  r86911 | raymond.hettinger | 2010-12-01 04:45:41 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Issue 10593:  Adopt Nick's suggestion for an lru_cache with maxsize=None.
................
  r86912 | raymond.hettinger | 2010-12-01 11:49:19 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Add recipe to itertools doc.
................
  r86913 | georg.brandl | 2010-12-01 16:32:43 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Add missing word, and add a better reference to the actual function.
................
  r86914 | georg.brandl | 2010-12-01 16:36:33 +0100 (Wed, 01 Dec 2010) | 1 line
  
  #10594: fix parameter names in PyList API docs.
................
  r86915 | georg.brandl | 2010-12-01 16:44:25 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Fix some markup and style in the unittest docs.
................
  r86916 | alexander.belopolsky | 2010-12-01 21:05:49 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Issue #4113: Added custom __repr__ method to functools.partial.
................
  r86917 | alexander.belopolsky | 2010-12-01 22:55:40 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Reverted unintended change from r86916
................
  r86918 | raymond.hettinger | 2010-12-01 23:48:00 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Add itertools.accumulate().
................
  r86919 | raymond.hettinger | 2010-12-01 23:50:36 +0100 (Wed, 01 Dec 2010) | 1 line
  
  Add itertools.accumulate().
................
  r86920 | raymond.hettinger | 2010-12-02 00:45:20 +0100 (Thu, 02 Dec 2010) | 1 line
  
  Clean-up last update (missing comma, unnecessary spacing change, spurious backtick).
................
  r86921 | alexander.belopolsky | 2010-12-02 01:05:57 +0100 (Thu, 02 Dec 2010) | 1 line
  
  With Raymond's approval added a paragraph describing Unicode 6.0.0 changes.  Not reST formatted.
................
  r86922 | alexander.belopolsky | 2010-12-02 01:10:11 +0100 (Thu, 02 Dec 2010) | 1 line
  
  Issue4335: Added a test for inspect.getsourcelines with a module without EOL at EOF.
................
  r86923 | raymond.hettinger | 2010-12-02 02:38:25 +0100 (Thu, 02 Dec 2010) | 1 line
  
  Fix markup
................
  r86924 | raymond.hettinger | 2010-12-02 03:41:33 +0100 (Thu, 02 Dec 2010) | 1 line
  
  Add an example to the random docs.
................
  r86925 | r.david.murray | 2010-12-02 03:58:07 +0100 (Thu, 02 Dec 2010) | 4 lines
  
  #10464: fix netrc handling of lines with embedded '#" characters.
  
  Patch by Xuanji Li.
................
  r86928 | nick.coghlan | 2010-12-02 05:11:46 +0100 (Thu, 02 Dec 2010) | 1 line
  
  Issue #9573: os.fork now works when triggered as a side effect of import (the wisdom of actually relying on this remains questionable!)
................
  r86929 | raymond.hettinger | 2010-12-02 06:35:35 +0100 (Thu, 02 Dec 2010) | 1 line
  
  Neaten-up random module docs.
................
  r86930 | terry.reedy | 2010-12-02 08:05:56 +0100 (Thu, 02 Dec 2010) | 2 lines
  
  Issue 9299 Add exist_ok parameter to os.makedirs to suppress 'File exists' exception. Patch by Ray Allen.
................
  r86931 | georg.brandl | 2010-12-02 10:06:12 +0100 (Thu, 02 Dec 2010) | 1 line
  
  Fix-up documentation of makedirs().
................
  r86932 | david.malcolm | 2010-12-02 17:41:00 +0100 (Thu, 02 Dec 2010) | 2 lines
  
  Fix spelling of Jamie Zawinski's surname in urllib.parse docstring (issue 10606)
................
  r86933 | georg.brandl | 2010-12-02 19:02:01 +0100 (Thu, 02 Dec 2010) | 1 line
  
  #10597: fix Py_SetPythonHome docs by pointing to where the meaning of PYTHONHOME is already documented.
................
  r86934 | georg.brandl | 2010-12-02 19:06:51 +0100 (Thu, 02 Dec 2010) | 1 line
  
  #7475: add (un)transform method to bytes/bytearray and str, add back codecs that can be used with them from Python 2.
................
  r86935 | brian.curtin | 2010-12-02 19:29:18 +0100 (Thu, 02 Dec 2010) | 17 lines
  
  Fix #9333. Expose os.symlink on Windows only when usable.
  
  In order to create symlinks on Windows, SeCreateSymbolicLinkPrivilege 
  is an account privilege that is required to be held by the user. Not only
  must the privilege be enabled for the account, the activated privileges for
  the currently running application must be adjusted to enable the requested
  privilege.
  
  Rather than exposing an additional function to be called prior to the user's
  first os.symlink call, we handle the AdjustTokenPrivileges Windows API call
  internally and only expose os.symlink when the privilege escalation was
  successful.
  
  Due to the change of only exposing os.symlink when it's available, we can
  go back to the original test skipping methods of checking via `hasattr`.
................
  r86936 | r.david.murray | 2010-12-02 22:47:19 +0100 (Thu, 02 Dec 2010) | 4 lines
  
  #8989: add 'domain' keyword to make_msgid.
  
  Patch by Adrian von Bidder.
................
  r86937 | daniel.stutzbach | 2010-12-02 22:55:33 +0100 (Thu, 02 Dec 2010) | 1 line
  
  Issue9915: speeding up sorting with a key
................
  r86940 | eric.araujo | 2010-12-02 23:16:19 +0100 (Thu, 02 Dec 2010) | 2 lines
  
  Fix wrong test code in test_csv (#10602)
................
  r86943 | georg.brandl | 2010-12-02 23:35:25 +0100 (Thu, 02 Dec 2010) | 1 line
  
  Re-add accidentally removed line.
................
  r86944 | michael.foord | 2010-12-03 01:53:09 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Issue 7911: unittest.TestCase.longMessage defaults to True for improved failure messages by default
................
  r86945 | michael.foord | 2010-12-03 02:34:01 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Initial implementation of Lib/test/__main__.py so we can run tests with 'python -m test'
................
  r86946 | benjamin.peterson | 2010-12-03 02:44:10 +0100 (Fri, 03 Dec 2010) | 1 line
  
  code style
................
  r86947 | michael.foord | 2010-12-03 03:03:30 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Set test.regrtest.TEMPDIR correctly when run with 'python -m test'
................
  r86948 | raymond.hettinger | 2010-12-03 03:09:34 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Simplify the signature for itertools.accumulate() to match numpy.  Handle one item iterable the same way as min()/max().
................
  r86949 | michael.foord | 2010-12-03 03:27:44 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Remove test/__main__.py until runpy tests can be fixed
................
  r86950 | raymond.hettinger | 2010-12-03 03:33:53 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Update the itertools.accumulate() docs.
................
  r86951 | brian.curtin | 2010-12-03 03:46:02 +0100 (Fri, 03 Dec 2010) | 6 lines
  
  Fix #10554. Added context manager support to Popen objects.
  
  Added a few common Popen uses to the tests like we've done for a few other
  instances of adding context managers. Eventually the entire test suite
  could be converted to use the context manager format.
................
  r86952 | r.david.murray | 2010-12-03 05:06:39 +0100 (Fri, 03 Dec 2010) | 12 lines
  
  #1486713: Add a tolerant mode to HTMLParser.
  
  The motivation for adding this option is that the the functionality it
  provides used to be provided by sgmllib in Python2, and was used by,
  for example, BeautifulSoup.  Without this option, the Python3 version
  of BeautifulSoup and the many programs that use it are crippled.
  
  The original patch was by 'kxroberto'.  I modified it heavily but kept his
  heuristics and test.  I also added additional heuristics to fix #975556,
  #1046092, and part of #6191.  This patch should be completely backward
  compatible:  the behavior with the default strict=True is unchanged.
................
  r86953 | r.david.murray | 2010-12-03 05:26:18 +0100 (Fri, 03 Dec 2010) | 2 lines
  
  Add missing versionchanged, correct 'throw' wording to 'raise'.
................
  r86954 | georg.brandl | 2010-12-03 08:37:16 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Move entries from "core" section to where they belong.
................
  r86955 | georg.brandl | 2010-12-03 08:38:22 +0100 (Fri, 03 Dec 2010) | 1 line
  
  #1745035: add limits for command and data size to smtpd; patch by Savio Sena.
................
  r86956 | nick.coghlan | 2010-12-03 08:44:33 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Partially revert r78719 - it removed a check that is still needed in some cases (i.e. this will allow Michael to add the test.__main__ support that broke the buildbots previously)
................
  r86957 | georg.brandl | 2010-12-03 08:47:22 +0100 (Fri, 03 Dec 2010) | 1 line
  
  #940286: pydoc.Helper.help() ignores input/output init parameters.
................
  r86958 | georg.brandl | 2010-12-03 08:49:09 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Use booleans.
................
  r86959 | georg.brandl | 2010-12-03 08:54:09 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Remove redundant check for PyBytes in unicode_encode.
................
  r86960 | georg.brandl | 2010-12-03 08:55:44 +0100 (Fri, 03 Dec 2010) | 1 line
  
  #10360: catch TypeError in WeakSet.__contains__, just like WeakKeyDictionary does.
................
  r86961 | georg.brandl | 2010-12-03 10:18:37 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Rewrap NEWS (Builbot test commit.)
................
  r86962 | nick.coghlan | 2010-12-03 10:29:11 +0100 (Fri, 03 Dec 2010) | 14 lines
  
  Improve Pydoc interactive browsing (#2001).  Patch by Ron Adam.
  
  * A -b option to start an enhanced browsing session.
  * Allow -b and -p options to be used together.
  * Specifying port 0 will pick an arbitrary unused socket port.
  * A new browse() function to start the new server and browser.
  * Show Python version information in the header.
  * A *Get* field which takes the same input as the help() function.
  * A *Search* field which replaces the Tkinter search box.
  * Links to *Module Index*, *Topics*, and *Keywords*.
  * Improved source file viewing.
  * An HTMLDoc.filelink() method.
  * The -g option and the gui() and serve() functions are deprecated.
................
  r86963 | georg.brandl | 2010-12-03 10:45:33 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Add a line with the actual changes.
................
  r86964 | georg.brandl | 2010-12-03 10:58:38 +0100 (Fri, 03 Dec 2010) | 1 line
  
  #10549: fix interface of docclass() for text documenter.
................
  r86965 | michael.foord | 2010-12-03 11:42:03 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Adding lib/test/__main__.py for running tests with 'python -m test'
................
  r86966 | michael.foord | 2010-12-03 11:59:15 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Fix lib/test/__main__.py to work even outside a Python build.
................
  r86967 | vinay.sajip | 2010-12-03 12:50:38 +0100 (Fri, 03 Dec 2010) | 1 line
  
  logging: Added getLogRecordFactory/setLogRecordFactory with docs and tests.
................
  r86968 | michael.foord | 2010-12-03 13:27:40 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Factor out common code from lib/test/__main__.py and lib/test/regrtest.py into a function.
................
  r86969 | vinay.sajip | 2010-12-03 14:01:11 +0100 (Fri, 03 Dec 2010) | 1 line
  
  logging: tidied up some docstrings.
................
  r86970 | nick.coghlan | 2010-12-03 15:26:13 +0100 (Fri, 03 Dec 2010) | 3 lines
  
  Issue 2690: Add support for slicing and negative indices to range objects (includes precalculation and storage of the range length).
  
  Refer to the tracker issue for the language moratorium implications of this change
................
  r86971 | nick.coghlan | 2010-12-03 15:30:41 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Add missing CSS file from r86962
................
  r86974 | georg.brandl | 2010-12-03 16:30:09 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Markup consistency fixes.
................
  r86975 | nick.coghlan | 2010-12-03 17:08:46 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Handle Windows paths and don't double up on HTML header sections in new pydoc URL handler
................
  r86976 | lukasz.langa | 2010-12-03 17:28:00 +0100 (Fri, 03 Dec 2010) | 2 lines
  
  Issue 10499: Modular interpolation in configparser
................
  r86977 | victor.stinner | 2010-12-03 17:51:33 +0100 (Fri, 03 Dec 2010) | 1 line
  
  #6780: fix complex() constructor TypeError message
................
  r86979 | victor.stinner | 2010-12-03 18:06:43 +0100 (Fri, 03 Dec 2010) | 4 lines
  
  import: use PyUnicode_FSConverter to support bytes path and PEP 383
  
  (instead of PyArg_Parse*() with "es" format and Py_FileSystemDefaultEncoding)
................
  r86980 | georg.brandl | 2010-12-03 18:19:27 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Fix punctuation.
................
  r86981 | antoine.pitrou | 2010-12-03 19:41:39 +0100 (Fri, 03 Dec 2010) | 5 lines
  
  Issue #10478: Reentrant calls inside buffered IO objects (for example by
  way of a signal handler) now raise a RuntimeError instead of freezing the
  current process.
................
  r86983 | terry.reedy | 2010-12-03 19:57:42 +0100 (Fri, 03 Dec 2010) | 1 line
................
  r86984 | antoine.pitrou | 2010-12-03 20:14:17 +0100 (Fri, 03 Dec 2010) | 3 lines
  
  Add an "advanced topics" section to the io doc.
................
  r86985 | eric.araujo | 2010-12-03 20:19:17 +0100 (Fri, 03 Dec 2010) | 5 lines
  
  Fix incorrect use of gettext in argparse (#10497).
  
  Steven, the maintainer of argparse, agreed to have this committed
  without tests for now, since the fix is obvious.  See the bug log.
................
  r86986 | michael.foord | 2010-12-03 20:20:44 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Fix so that test.test_unittest can be executed by unittest and not just regrtest
................
  r86993 | eric.araujo | 2010-12-03 20:41:00 +0100 (Fri, 03 Dec 2010) | 7 lines
  
  Allow translators to reorder placeholders in localizable messages from
  argparse (#10528).
  
  There is no unit test; I checked with xgettext that no more warnings
  were emitted.  Steven approved the change.
................
  r86996 | georg.brandl | 2010-12-03 20:56:42 +0100 (Fri, 03 Dec 2010) | 1 line
  
  Fix indentation.
................
  r86997 | antoine.pitrou | 2010-12-03 20:59:41 +0100 (Fri, 03 Dec 2010) | 4 lines
  
  Issue #10272: The ssl module now raises socket.timeout instead of a generic
  SSLError on socket timeouts.
................
  r86998 | martin.v.loewis | 2010-12-03 21:14:31 +0100 (Fri, 03 Dec 2010) | 2 lines
  
  Merge branches/pep-0384.
................
  r86999 | lukasz.langa | 2010-12-03 23:15:19 +0100 (Fri, 03 Dec 2010) | 3 lines
  
  %s -> %r correction after review by Éric Araujo
................
  r87000 | terry.reedy | 2010-12-03 23:29:40 +0100 (Fri, 03 Dec 2010) | 3 lines
  
  Issue 10534 deprecate isbjunk and isbpopular methods.
  Will add gone in 3.3 test later.
................
  r87001 | terry.reedy | 2010-12-03 23:50:06 +0100 (Fri, 03 Dec 2010) | 2 lines
  
  Issue #10534: add NEWS entry for r86983 and  r87000.
................
  r87002 | martin.v.loewis | 2010-12-04 00:11:07 +0100 (Sat, 04 Dec 2010) | 21 lines
  
  Merged revisions 85551,86156-86157,86464 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
  
  ........
    r85551 | benjamin.peterson | 2010-10-15 23:57:29 +0200 (Fr, 15 Okt 2010) | 1 line
    
    escape() is now in the html module
  ........
    r86156 | georg.brandl | 2010-11-04 09:34:57 +0100 (Do, 04 Nov 2010) | 1 line
    
    Consistency fixes in option parser help texts.
  ........
    r86157 | georg.brandl | 2010-11-04 09:35:30 +0100 (Do, 04 Nov 2010) | 1 line
    
    #10286: fix urllib class names.
  ........
    r86464 | benjamin.peterson | 2010-11-14 16:28:52 +0100 (So, 14 Nov 2010) | 1 line
    
    match only .py files #10416
  ........
................
  r87003 | michael.foord | 2010-12-04 02:11:21 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Issue 10620: Specifying test modules by path instead of module name to 'python -m unittest'
................
  r87004 | michael.foord | 2010-12-04 02:43:59 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Correct comment in unittest test
................
  r87007 | alexander.belopolsky | 2010-12-04 04:38:46 +0100 (Sat, 04 Dec 2010) | 5 lines
  
  Issue #10557: Fixed error messages from float() and other numeric
  types.  Added a new API function, PyUnicode_TransformDecimalToASCII(),
  which transforms non-ASCII decimal digits in a Unicode string to their
  ASCII equivalents.
................
  r87008 | georg.brandl | 2010-12-04 10:04:04 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Fix typo.
................
  r87009 | martin.v.loewis | 2010-12-04 10:08:10 +0100 (Sat, 04 Dec 2010) | 2 lines
  
  Make script 2-vs-3-agnostic.
................
  r87010 | gregory.p.smith | 2010-12-04 10:10:44 +0100 (Sat, 04 Dec 2010) | 11 lines
  
  issue7213 + issue2320: Cause a DeprecationWarning if the close_fds argument is
  not passed to subprocess.Popen as the default value will be changing in a
  future Python to the safer and more often desired value of True.
  
  DeprecationWarnings that show up in a lot of existing code are controversial
  and have caused pain in the past.  I'd like to leave this on for 3.2 beta1 and
  see how things go.  We can remove the warning if it is deemed too noisy during
  any betas.  (case study: the md5 and sha module DeprecationWarnings are loathed
  around the world as those modules were never going to be removed in 2.x and
  2to3 has a fixer for code that uses them)
................
  r87011 | martin.v.loewis | 2010-12-04 10:11:41 +0100 (Sat, 04 Dec 2010) | 2 lines
  
  Add Revision keyword.
................
  r87012 | martin.v.loewis | 2010-12-04 10:12:14 +0100 (Sat, 04 Dec 2010) | 2 lines
  
  Regenerate.
................
  r87013 | georg.brandl | 2010-12-04 10:14:36 +0100 (Sat, 04 Dec 2010) | 1 line
  
  #6045: provide at least get() and setdefault() for all dbm modules.
................
  r87014 | senthil.kumaran | 2010-12-04 10:44:30 +0100 (Sat, 04 Dec 2010) | 3 lines
  
  Add the NEWS entry for issue7904
................
  r87017 | gregory.p.smith | 2010-12-04 10:59:52 +0100 (Sat, 04 Dec 2010) | 2 lines
  
  refactor the warning test.
................
  r87018 | hirokazu.yamamoto | 2010-12-04 11:16:05 +0100 (Sat, 04 Dec 2010) | 6 lines
  
  Fixed several corner case issues on os.stat/os.lstat related to reparse
  points. (Windows)
  
  - Set S_IEXEC via final path name not link name.
  - Set S_IFLNK also via FindFirstFile (when CreateFile fails)
................
  r87019 | georg.brandl | 2010-12-04 11:26:46 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Add an "optimize" parameter to compile() to control the optimization level, and provide an interface to it in py_compile, compileall and PyZipFile.
................
  r87020 | georg.brandl | 2010-12-04 11:39:14 +0100 (Sat, 04 Dec 2010) | 1 line
  
  #1513299: cleanup some map() uses where a comprehension works better.
................
  r87021 | georg.brandl | 2010-12-04 11:47:18 +0100 (Sat, 04 Dec 2010) | 1 line
  
  #1772833: add -q command line option.
................
  r87022 | georg.brandl | 2010-12-04 12:02:04 +0100 (Sat, 04 Dec 2010) | 1 line
  
  #1569291: speed up array.repeat() by making only O(log n) memcpy() calls; the code follows unicode_repeat.
................
  r87023 | mark.dickinson | 2010-12-04 12:06:25 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Fix indentation in Objects/longobject.c
................
  r87024 | georg.brandl | 2010-12-04 12:12:43 +0100 (Sat, 04 Dec 2010) | 1 line
  
  #7905: Actually respect the keyencoding parameter to shelve.Shelf.
................
  r87025 | georg.brandl | 2010-12-04 12:20:26 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Add the "interact" pdb command from pdb++.
................
  r87026 | gregory.p.smith | 2010-12-04 12:22:11 +0100 (Sat, 04 Dec 2010) | 3 lines
  
  issue6559: Adds a pass_fds parameter to subprocess.Popen that allows the caller
  to list exactly which file descriptors should be kept open.
................
  r87027 | gregory.p.smith | 2010-12-04 12:36:58 +0100 (Sat, 04 Dec 2010) | 3 lines
  
  issue10622: fix superflous scrollbar on the right side of <pre> boxes in the
  generated html docs.  visible in chrome, possibly other webkit browsers.
................
  r87028 | lukasz.langa | 2010-12-04 12:48:11 +0100 (Sat, 04 Dec 2010) | 3 lines
  
  configparser: minute refactoring of RawConfigParser.items()
................
  r87029 | mark.dickinson | 2010-12-04 12:52:58 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Remove some unecessary '#ifdef Py_NAN's from floatobject.c
................
  r87030 | martin.v.loewis | 2010-12-04 13:00:49 +0100 (Sat, 04 Dec 2010) | 3 lines
  
  Expose CompileString, not CompileStringFlags under the
  limited API.
................
  r87031 | hirokazu.yamamoto | 2010-12-04 13:20:57 +0100 (Sat, 04 Dec 2010) | 2 lines
  
  I hope this will fix Win2008(x64) buildbot error.
................
  r87032 | mark.dickinson | 2010-12-04 13:25:30 +0100 (Sat, 04 Dec 2010) | 3 lines
  
  Issue #10596: Fix float.__mod__ to have the same behaviour as
  float.__divmod__ with respect to signed zeros.
................
  r87036 | lukasz.langa | 2010-12-04 13:46:01 +0100 (Sat, 04 Dec 2010) | 5 lines
  
  configparser: fixed inconsistency where in SafeConfigParser option values
   were ensured to be strings but section names and option keys were not.
   Behaviour unchanged for RawConfigParser and ConfigParser.
................
  r87038 | mark.dickinson | 2010-12-04 14:14:29 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Use copysign to produce appropriately signed zeros instead of trying to worm around possible compiler optimizations.
................
  r87039 | eric.smith | 2010-12-04 14:27:34 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Removed static function complex_format, moved it into complex_repr. Modified tests to check both str and repr, which are the same for complex.
................
  r87040 | eric.smith | 2010-12-04 14:32:18 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Issue #10624: Move requires_IEEE_754 into test.support. I'll fix up other uses of it shortly.
................
  r87041 | lukasz.langa | 2010-12-04 14:48:13 +0100 (Sat, 04 Dec 2010) | 4 lines
  
  support for checking test coverage added.
  70% coverage at the moment (not tragic but needs work).
................
  r87042 | martin.v.loewis | 2010-12-04 14:49:32 +0100 (Sat, 04 Dec 2010) | 2 lines
  
  Fix PEP number.
................
  r87043 | eric.smith | 2010-12-04 16:17:38 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Issue #10624: Use support.requires_IEEE_754 in all appropriate tests.
................
  r87044 | eric.smith | 2010-12-04 16:26:13 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Issue 10625: Add tests for negative zeros in complex str and repr.
................
  r87045 | georg.brandl | 2010-12-04 17:00:47 +0100 (Sat, 04 Dec 2010) | 1 line
  
  #7245: Add a SIGINT handler on continue in pdb that allows to break a program again by pressing Ctrl-C.
................
  r87047 | georg.brandl | 2010-12-04 17:21:42 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Add display/undisplay pdb commands.
................
  r87048 | georg.brandl | 2010-12-04 17:22:44 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Fix accidental checkin.
................
  r87050 | georg.brandl | 2010-12-04 18:09:30 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Fix typo.
................
  r87051 | georg.brandl | 2010-12-04 18:11:36 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Fix test suite to not activate new sigint behavior in pdb.
................
  r87052 | eric.smith | 2010-12-04 18:12:41 +0100 (Sat, 04 Dec 2010) | 1 line
  
  More issue #10624: Add requires_IEEE_754 to __all__.
................
  r87054 | victor.stinner | 2010-12-04 18:24:33 +0100 (Sat, 04 Dec 2010) | 3 lines
  
  Issue #10601: sys.displayhook uses 'backslashreplace' error handler on
  UnicodeEncodeError.
................
  r87056 | eric.araujo | 2010-12-04 18:31:49 +0100 (Sat, 04 Dec 2010) | 2 lines
  
  Use proper plural forms in argparse (#4391)
................
  r87057 | lukasz.langa | 2010-12-04 18:48:18 +0100 (Sat, 04 Dec 2010) | 2 lines
  
  configparser: mapping protocol access get() handles configparser-specific arguments as well
................
  r87058 | gregory.p.smith | 2010-12-04 19:11:44 +0100 (Sat, 04 Dec 2010) | 2 lines
  
  clarify the docs and new warning message.
................
  r87059 | antoine.pitrou | 2010-12-04 19:36:03 +0100 (Sat, 04 Dec 2010) | 3 lines
  
  Silence compile error
................
  r87060 | georg.brandl | 2010-12-04 20:01:29 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Update pydoc topics.
................
  r87062 | georg.brandl | 2010-12-04 20:06:14 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Update suspicious exceptions.
................
  r87063 | georg.brandl | 2010-12-04 20:06:18 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Fix markup errors.
................
  r87064 | georg.brandl | 2010-12-04 20:09:24 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Bump to 3.2b1.
................
  r87065 | raymond.hettinger | 2010-12-04 21:51:36 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Doc nit.
................
  r87066 | raymond.hettinger | 2010-12-04 23:56:25 +0100 (Sat, 04 Dec 2010) | 1 line
  
  Fill-in stub for concurrent.futures
................
  r87067 | raymond.hettinger | 2010-12-05 00:42:12 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Mention itertools.accumulate().
................
  r87068 | raymond.hettinger | 2010-12-05 01:39:18 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Start the argparse entry.
................
  r87069 | raymond.hettinger | 2010-12-05 02:01:52 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Optimization of Timsort.
................
  r87070 | hirokazu.yamamoto | 2010-12-05 03:04:16 +0100 (Sun, 05 Dec 2010) | 3 lines
  
  Now can reproduce the error on AMD64 Windows Server 2008
  even where os.symlink is not supported.
................
  r87071 | hirokazu.yamamoto | 2010-12-05 03:41:46 +0100 (Sun, 05 Dec 2010) | 2 lines
  
  Avoid possible zombi process.
................
  r87072 | hirokazu.yamamoto | 2010-12-05 03:48:08 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Sorry, I had introduced tab in source code.
................
  r87073 | raymond.hettinger | 2010-12-05 03:56:21 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Note the updates to range objects.
................
  r87074 | raymond.hettinger | 2010-12-05 05:04:21 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Describe the transform/untranform methods
................
  r87075 | hirokazu.yamamoto | 2010-12-05 05:16:47 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Should use posix_error here.
................
  r87076 | raymond.hettinger | 2010-12-05 06:39:54 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Optimization notes.
................
  r87077 | raymond.hettinger | 2010-12-05 07:35:16 +0100 (Sun, 05 Dec 2010) | 1 line
  
  New string format character.
................
  r87078 | nick.coghlan | 2010-12-05 07:45:03 +0100 (Sun, 05 Dec 2010) | 2 lines
  
  Issue 10626 investigation: regrtest now checks for alterations to the logging state in the current process (and yes, test_pydoc alters it)
................
  r87079 | raymond.hettinger | 2010-12-05 08:02:45 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Update the unittest section.
................
  r87080 | raymond.hettinger | 2010-12-05 08:06:47 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Spelling
................
  r87081 | nick.coghlan | 2010-12-05 08:17:25 +0100 (Sun, 05 Dec 2010) | 1 line
  
  More fine-grained monitoring of alterations to logging state
................
  r87082 | georg.brandl | 2010-12-05 08:51:39 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Temporarily disable newly failing test for the release.
................
  r87083 | georg.brandl | 2010-12-05 08:59:29 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Apply rest of #10628, and add a few todo comments.
................
  r87084 | raymond.hettinger | 2010-12-05 09:35:21 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Nits and todos
................
  r87086 | georg.brandl | 2010-12-05 12:40:48 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Take PyUnicode_TransformDecimalToASCII out of the limited API.
................
  r87088 | georg.brandl | 2010-12-05 12:42:38 +0100 (Sun, 05 Dec 2010) | 1 line
  
  Fix title.
................
  r87093 | martin.v.loewis | 2010-12-06 00:07:58 +0100 (Mon, 06 Dec 2010) | 2 lines
  
  Automate build for python3.dll.
  Package missing files.
................
  r87094 | raymond.hettinger | 2010-12-06 05:31:40 +0100 (Mon, 06 Dec 2010) | 2 lines
  
  Typo fixups.
................
  r87101 | georg.brandl | 2010-12-06 23:02:48 +0100 (Mon, 06 Dec 2010) | 1 line
  
  Remove visible XXX comments.
................
  r87102 | georg.brandl | 2010-12-06 23:25:25 +0100 (Mon, 06 Dec 2010) | 1 line
  
  Don't use deprecated aliases.
................
  r87103 | raymond.hettinger | 2010-12-07 00:31:36 +0100 (Tue, 07 Dec 2010) | 1 line
  
  Note improvements to the docs.
................
  r87104 | david.malcolm | 2010-12-07 01:32:04 +0100 (Tue, 07 Dec 2010) | 2 lines
  
  Fix typo
................
  r87105 | raymond.hettinger | 2010-12-07 02:47:52 +0100 (Tue, 07 Dec 2010) | 1 line
  
  Add entry for the new sysconfig module.
................
  r87106 | raymond.hettinger | 2010-12-07 03:04:56 +0100 (Tue, 07 Dec 2010) | 1 line
  
  Add entry for new pdb features
................
  r87107 | benjamin.peterson | 2010-12-07 04:46:27 +0100 (Tue, 07 Dec 2010) | 1 line
  
  return views from dict proxy items/values/keys #10630
................
  r87108 | benjamin.peterson | 2010-12-07 04:47:37 +0100 (Tue, 07 Dec 2010) | 1 line
  
  add news note
................
  r87109 | benjamin.peterson | 2010-12-07 05:04:02 +0100 (Tue, 07 Dec 2010) | 1 line
  
  use the more direct API
................
  r87110 | raymond.hettinger | 2010-12-07 07:45:30 +0100 (Tue, 07 Dec 2010) | 1 line
  
  Add example for the entry for argparse
................
  r87112 | raymond.hettinger | 2010-12-07 09:52:41 +0100 (Tue, 07 Dec 2010) | 1 line
  
  More cleanups and examples.
................
  r87113 | raymond.hettinger | 2010-12-07 10:24:30 +0100 (Tue, 07 Dec 2010) | 2 lines
  
  Spelling.
................
  r87114 | raymond.hettinger | 2010-12-07 10:37:11 +0100 (Tue, 07 Dec 2010) | 1 line
  
  Clean-ups and examples.
................
  r87115 | raymond.hettinger | 2010-12-07 10:44:21 +0100 (Tue, 07 Dec 2010) | 1 line
  
  Make the example a little more interesting and useful.
................
  r87116 | raymond.hettinger | 2010-12-07 10:55:02 +0100 (Tue, 07 Dec 2010) | 2 lines
  
  Martin's name with Unicode.
................
  r87117 | hirokazu.yamamoto | 2010-12-07 11:24:37 +0100 (Tue, 07 Dec 2010) | 2 lines
  
  Issue #10637: Called CloseHandle twice in os.stat/os.lstat (Windows)
................
  r87118 | ronald.oussoren | 2010-12-07 15:41:05 +0100 (Tue, 07 Dec 2010) | 14 lines
  
  Two small changes to adjust framework builds to the new stable ABI
  
  Both the Makefile and the script that is used on OSX to create the binary
  installer refer to the directory containing the Makefile using the name
  'config'. This name was changed with the new ABI (with default build flags
  it is now named config-3.2m).  This patch ensures that both files use the
  correct name.
  
  The build-installer.py script contains one other change: it now tests for the
  Tcl/Tk framework version by looking at the 'Current' symlink in the framework
  instead of runnning a script. This makes it possible to verify the version
  that is in the SDK that's used during the build instead of the version that
  is installed on the system.
................
  r87119 | ronald.oussoren | 2010-12-07 16:28:10 +0100 (Tue, 07 Dec 2010) | 2 lines
  
  Fix for issue #10107: Without this patch IDLE on OSX doesn't warn about unsaved files when quitting.
................
  r87124 | raymond.hettinger | 2010-12-08 02:13:53 +0100 (Wed, 08 Dec 2010) | 1 line
  
  Update whatsnew.  Salt the random number seed.
................
  r87125 | raymond.hettinger | 2010-12-08 07:42:41 +0100 (Wed, 08 Dec 2010) | 2 lines
  
  Add example for concurrent.futures.
................
  r87126 | raymond.hettinger | 2010-12-08 07:48:33 +0100 (Wed, 08 Dec 2010) | 1 line
  
  Clean-ups.
................
  r87127 | raymond.hettinger | 2010-12-08 07:50:02 +0100 (Wed, 08 Dec 2010) | 1 line
  
  Nits.
................
  r87128 | senthil.kumaran | 2010-12-08 09:04:49 +0100 (Wed, 08 Dec 2010) | 3 lines
  
  Fix Issue8194  - Fix incompatible API change in the parse_respones for xmlrpclib.
................
  r87129 | raymond.hettinger | 2010-12-08 11:18:21 +0100 (Wed, 08 Dec 2010) | 1 line
  
  range() example
................
  r87130 | raymond.hettinger | 2010-12-08 12:19:45 +0100 (Wed, 08 Dec 2010) | 1 line
  
  Example of argparge with subparsers.
................
  r87131 | raymond.hettinger | 2010-12-08 12:33:19 +0100 (Wed, 08 Dec 2010) | 2 lines
  
  Entry for inspect.getattr_static().
................
  r87132 | hirokazu.yamamoto | 2010-12-08 15:47:07 +0100 (Wed, 08 Dec 2010) | 3 lines
  
  Mention NASM which is needed to build openssl-1.0.0a original source.
  (PC/VC6/readme.txt)
................
  r87133 | alexander.belopolsky | 2010-12-08 22:21:56 +0100 (Wed, 08 Dec 2010) | 1 line
  
  Added a datetime new features entry
................
  r87134 | alexander.belopolsky | 2010-12-08 22:38:46 +0100 (Wed, 08 Dec 2010) | 1 line
  
  Edited the Unicode 6.0.0 entry to add unicode.org links and trim the summary.
................
  r87135 | victor.stinner | 2010-12-08 23:25:45 +0100 (Wed, 08 Dec 2010) | 4 lines
  
  Issue #10546: UTF-16-LE and UTF-16-BE *do* support non-BMP characters
  
  Fix the doc and add tests.
................
  r87136 | r.david.murray | 2010-12-08 23:53:00 +0100 (Wed, 08 Dec 2010) | 6 lines
  
  Have script_helper._assert_python strip refcount strings from stderr.
  
  This makes the output of the function and those that depend on it
  independent of whether or not they are being run under a debug
  build.
................
  r87137 | alexander.belopolsky | 2010-12-09 00:31:48 +0100 (Thu, 09 Dec 2010) | 1 line
  
  Issue #6697: Fixed instances of _PyUnicode_AsString() result not checked for NULL
................
  r87140 | hirokazu.yamamoto | 2010-12-09 11:49:00 +0100 (Thu, 09 Dec 2010) | 2 lines
  
  Should call Py_INCREF for Py_None (Modules/_ssl.c: PySSL_cipher)
................
  r87141 | hirokazu.yamamoto | 2010-12-09 12:13:30 +0100 (Thu, 09 Dec 2010) | 2 lines
  
  Fixed typo in comment.
................
  r87145 | raymond.hettinger | 2010-12-09 17:41:54 +0100 (Thu, 09 Dec 2010) | 2 lines
  
  Entries for datetime, callable, and collections.Counter.
................
  r87146 | georg.brandl | 2010-12-09 19:08:43 +0100 (Thu, 09 Dec 2010) | 1 line
  
  Fix "seperate".
................
  r87147 | georg.brandl | 2010-12-09 19:10:27 +0100 (Thu, 09 Dec 2010) | 1 line
  
  #10661: give QName a nicer repr.
................
  r87148 | georg.brandl | 2010-12-09 19:26:02 +0100 (Thu, 09 Dec 2010) | 1 line
  
  Guard against rogue tuples.
................
  r87149 | raymond.hettinger | 2010-12-10 00:43:34 +0100 (Fri, 10 Dec 2010) | 1 line
  
  Doh! Example pasted twice, but only once in the right place.
................
  r87150 | raymond.hettinger | 2010-12-10 02:09:01 +0100 (Fri, 10 Dec 2010) | 1 line
  
  Overview of email module and recategorize various entries.
................
  r87151 | raymond.hettinger | 2010-12-10 02:19:15 +0100 (Fri, 10 Dec 2010) | 1 line
  
  Reclassify some entries and remove a couple of minor ones.
................
  r87152 | ezio.melotti | 2010-12-10 03:32:05 +0100 (Fri, 10 Dec 2010) | 1 line
  
  #10273: Remove a "Matches" that I missed in r86910. Thanks to RDM for noticing it.
................
  r87153 | vinay.sajip | 2010-12-10 09:17:05 +0100 (Fri, 10 Dec 2010) | 1 line
  
  Minor documentation tweak.
................
  r87154 | vinay.sajip | 2010-12-10 09:19:38 +0100 (Fri, 10 Dec 2010) | 1 line
  
  test.support: Added TestHandler and Matcher classes for better support of assertions about logging.
................
  r87155 | vinay.sajip | 2010-12-10 10:11:23 +0100 (Fri, 10 Dec 2010) | 1 line
  
  Fied typo
................
  r87156 | georg.brandl | 2010-12-10 11:01:44 +0100 (Fri, 10 Dec 2010) | 1 line
  
  #10668: fix wrong call of __init__.
................
  r87157 | vinay.sajip | 2010-12-10 12:42:57 +0100 (Fri, 10 Dec 2010) | 1 line
  
  logging: added handler of last resort.
................
  r87158 | raymond.hettinger | 2010-12-10 18:45:13 +0100 (Fri, 10 Dec 2010) | 1 line
  
  Move nntp entry back to changed modules section and add entry for non-ascii import directories.
................
  r87159 | alexander.belopolsky | 2010-12-10 19:11:24 +0100 (Fri, 10 Dec 2010) | 1 line
  
  Updated UCD version and unicode.org links to Unicode 6.0.0
................
  r87160 | alexander.belopolsky | 2010-12-10 19:14:16 +0100 (Fri, 10 Dec 2010) | 1 line
  
  Reverted accidental commit (from r87159)
................
  r87161 | georg.brandl | 2010-12-10 20:22:11 +0100 (Fri, 10 Dec 2010) | 1 line
  
  Fix typo.
................
  r87171 | martin.v.loewis | 2010-12-11 19:17:22 +0100 (Sat, 11 Dec 2010) | 2 lines
  
  Adjust PySlice_GetIndices documentation to signature change.
................
  r87172 | georg.brandl | 2010-12-11 20:10:30 +0100 (Sat, 11 Dec 2010) | 1 line
  
  Avoid AttributeError(_closed) when a TemporaryDirectory is deallocated whose mkdtemp call failed.
................
  r87173 | martin.v.loewis | 2010-12-11 20:22:04 +0100 (Sat, 11 Dec 2010) | 2 lines
  
  Add versionchanged for parameter type changes.
................
  r87174 | barry.warsaw | 2010-12-11 22:32:01 +0100 (Sat, 11 Dec 2010) | 4 lines
  
  Create the hardlink between python-3.2m and python-3.2 in altbininstall target
  instead of bininstall target so it shows up when you do 'make altinstall'.
  Closes issue 10677.
................
  r87175 | georg.brandl | 2010-12-11 23:19:34 +0100 (Sat, 11 Dec 2010) | 1 line
  
  Fix markup.
................
  r87176 | benjamin.peterson | 2010-12-12 02:33:04 +0100 (Sun, 12 Dec 2010) | 1 line
  
  remove (un)transform methods
................
  r87177 | benjamin.peterson | 2010-12-12 02:46:43 +0100 (Sun, 12 Dec 2010) | 1 line
  
  having three copies of the same test is surely a bit excessive
................
  r87179 | vinay.sajip | 2010-12-12 14:20:55 +0100 (Sun, 12 Dec 2010) | 1 line
  
  Logging documentation update.
................
  r87180 | vinay.sajip | 2010-12-12 14:25:29 +0100 (Sun, 12 Dec 2010) | 1 line
  
  Logging documentation - further update.
................
  r87181 | vinay.sajip | 2010-12-12 14:49:39 +0100 (Sun, 12 Dec 2010) | 1 line
  
  Logging documentation - further update.
................
  r87182 | nick.coghlan | 2010-12-12 16:24:21 +0100 (Sun, 12 Dec 2010) | 2 lines
  
  Issue #10188 (partial resolution): tidy up some behaviour in the new tempfile.TemporaryDirectory context manager
................
  r87183 | vinay.sajip | 2010-12-12 18:37:27 +0100 (Sun, 12 Dec 2010) | 1 line
  
  Logging documentation - further update.
................
  r87184 | antoine.pitrou | 2010-12-12 19:09:53 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  SET_LINENO was removed in 2.3
................
  r87185 | antoine.pitrou | 2010-12-12 19:12:40 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Remove reference to stuff which is already obsolete in 2.x.
................
  r87186 | antoine.pitrou | 2010-12-12 19:14:34 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Obsolete aliases needn't be documented
................
  r87188 | antoine.pitrou | 2010-12-12 19:25:25 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Make this a warning and fix indentation
................
  r87189 | antoine.pitrou | 2010-12-12 20:59:47 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Better explain the buffer interface (hopefully)
................
  r87190 | antoine.pitrou | 2010-12-12 21:01:43 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Add link to the buffer protocol description from the memory description.
................
  r87191 | r.david.murray | 2010-12-12 21:06:19 +0100 (Sun, 12 Dec 2010) | 6 lines
  
  #243654: only create a new MIME boundary if we don't already have one.
  
  The rearranged code should do exactly what the old code did, but
  the new code avoids a potentially costly re computation in the case
  where a boundary already exists.
................
  r87192 | antoine.pitrou | 2010-12-12 21:09:18 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Remove redundant sentence, and fix markup
................
  r87193 | antoine.pitrou | 2010-12-12 21:13:31 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Fix heading level
................
  r87194 | antoine.pitrou | 2010-12-12 21:17:29 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Consistent ordering of availability statements
................
  r87197 | antoine.pitrou | 2010-12-12 21:34:49 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Homogenize the "optional OS services" menu
................
  r87198 | antoine.pitrou | 2010-12-12 21:57:12 +0100 (Sun, 12 Dec 2010) | 3 lines
  
  Improve readability of the socket docs
................
  r87201 | vinay.sajip | 2010-12-12 23:30:17 +0100 (Sun, 12 Dec 2010) | 1 line
  
  Logging documentation - further update.
................
  r87202 | vinay.sajip | 2010-12-12 23:45:35 +0100 (Sun, 12 Dec 2010) | 1 line
  
  Logging documentation - further update.
................
  r87203 | vinay.sajip | 2010-12-12 23:47:13 +0100 (Sun, 12 Dec 2010) | 1 line
  
  Logging documentation - further update.
................
  r87204 | nick.coghlan | 2010-12-13 04:02:43 +0100 (Mon, 13 Dec 2010) | 1 line
  
  Actually finish the tests for r87182
................
  r87205 | kristjan.jonsson | 2010-12-13 04:32:10 +0100 (Mon, 13 Dec 2010) | 8 lines
  
  issue 10683
  When the solution is converted to Visual Studio 2010, the command line to invoke make_buildinfo changes from:
  $(SolutionDir)make_buildinfo.exe" Debug "$(IntDir)\"
  to
  $(SolutionDir)make_buildinfo.exe" Debug "$(IntDir)"
  If the final backslash is omitted, the backslash in IntDir will escape the quote, thus passing the quote in as part of the path name.
  
  This solution is a hack-fix to that problem by skipping any trailing quote from the path name.  It works as long as we don't need any additional arguments to make_buildinfo.exe.  This will help all those sould that are going to run this project through the visual studio autoconverter and get the same error.
................
  r87206 | gregory.p.smith | 2010-12-13 07:45:02 +0100 (Mon, 13 Dec 2010) | 5 lines
  
  Get rid of the close_fds DeprecationWarning.  Changes the default on a per
  platform basis.  It remains False on Windows and changes to True on all
  other platforms (POSIX).  Based on python-dev discussion and
  http://bugs.python.org/issue7213.
................
  r87207 | gregory.p.smith | 2010-12-13 08:59:39 +0100 (Mon, 13 Dec 2010) | 4 lines
  
  issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
  the C code, using pipe2() when available.  Adds unittests for close_fds and
  cloexec behaviors.
................
  r87208 | gregory.p.smith | 2010-12-13 09:00:52 +0100 (Mon, 13 Dec 2010) | 2 lines
  
  regenerate configure based on r87207.
................
  r87209 | gregory.p.smith | 2010-12-13 09:07:14 +0100 (Mon, 13 Dec 2010) | 2 lines
  
  Mention the subprocess.Popen close_fds default change.  Fixup *s to -s.
................
  r87210 | vinay.sajip | 2010-12-13 09:54:02 +0100 (Mon, 13 Dec 2010) | 1 line
  
  Logging documentatio update.
................
  r87212 | nick.coghlan | 2010-12-13 17:32:51 +0100 (Mon, 13 Dec 2010) | 1 line
  
  Captured IO streams with embedded backslashes are always such a fun combination...
................
  r87213 | barry.warsaw | 2010-12-13 19:04:23 +0100 (Mon, 13 Dec 2010) | 6 lines
  
  Issue 10687.  When --without-pymalloc is given, $VERSION is the same as
  $LDVERSION, which screws up the sym/hard-links.  This avoids those games when
  $VERSION == $LDVERSION.
  
  Also, include a drive-by fix for an obvious syntax error.
................
  r87214 | vinay.sajip | 2010-12-13 19:43:57 +0100 (Mon, 13 Dec 2010) | 1 line
  
  Logging documentation update.
................
  r87215 | vinay.sajip | 2010-12-13 19:49:08 +0100 (Mon, 13 Dec 2010) | 1 line
  
  Logging documentation update.
................
  r87216 | r.david.murray | 2010-12-13 23:50:30 +0100 (Mon, 13 Dec 2010) | 2 lines
  
  #10698: fix typo in example.
................
  r87217 | r.david.murray | 2010-12-14 00:51:19 +0100 (Tue, 14 Dec 2010) | 5 lines
  
  #1078919: make add_header automatically do RFC2231 encoding when needed.
  
  Also document the use of three-tuples if control of the charset
  and language is desired.
................
  r87221 | r.david.murray | 2010-12-14 01:55:46 +0100 (Tue, 14 Dec 2010) | 4 lines
  
  #10699: fix docstring for tzset: it does not take a parameter
  
  Thanks to Garrett Cooper for the fix.
................
  r87222 | r.david.murray | 2010-12-14 02:22:50 +0100 (Tue, 14 Dec 2010) | 2 lines
  
  Use skipIf instead of a return when attribute doesn't exist.
................
  r87225 | r.david.murray | 2010-12-14 02:38:16 +0100 (Tue, 14 Dec 2010) | 2 lines
  
  9162: fix license in multiprocessing files
................
  r87228 | r.david.murray | 2010-12-14 03:25:43 +0100 (Tue, 14 Dec 2010) | 2 lines
  
  Turn on regrtest -W (rerun immediately) option for Windows, too.
................
  r87229 | gregory.p.smith | 2010-12-14 14:43:30 +0100 (Tue, 14 Dec 2010) | 7 lines
  
  Issue #6559: fix the subprocess.Popen pass_fds implementation. Add a unittest.
  Issue #7213: Change the close_fds default on Windows to better match the new
  default on POSIX.  True when possible (False if stdin/stdout/stderr are
  supplied).
  
  Update the documentation to reflect all of the above.
................
  r87230 | r.david.murray | 2010-12-14 15:16:20 +0100 (Tue, 14 Dec 2010) | 7 lines
  
  #10695: use %s not %d so that a string 'port' does not cause a debug traceback
  
  Passing the port as a string value works fine in regular mode, but
  if you turned debug on it would throw an error trying to print the
  port number, which is surprising and confusing.
................
  r87233 | gregory.p.smith | 2010-12-14 15:38:00 +0100 (Tue, 14 Dec 2010) | 4 lines
  
  Issue #1731717: Fixed the problem where subprocess.wait() could cause an
  OSError exception when The OS had been told to ignore SIGCLD in our process
  or otherwise not wait for exiting child processes.
................
  r87236 | gregory.p.smith | 2010-12-14 16:23:02 +0100 (Tue, 14 Dec 2010) | 2 lines
  
  Fix "BytesWarning: str() on a bytes instance"
................
  r87238 | r.david.murray | 2010-12-14 17:20:53 +0100 (Tue, 14 Dec 2010) | 7 lines
  
  #775964: skip YP/NIS entries instead of failing the test
  
  Also includes doc updates mentioning that these entries may not
  be retrievable via getgrnam and getgrgid.
  
  Patch by Bobby Impollonia.
................
  r87241 | gregory.p.smith | 2010-12-14 19:18:49 +0100 (Tue, 14 Dec 2010) | 2 lines
  
  SIGCHLD is a more portable name than SIGCLD.  (OSX has no SIGCLD)
................
  r87245 | vinay.sajip | 2010-12-14 20:40:21 +0100 (Tue, 14 Dec 2010) | 1 line
  
  Logging documentation update.
................
  r87246 | raymond.hettinger | 2010-12-14 22:12:03 +0100 (Tue, 14 Dec 2010) | 1 line
  
  Nits
................
  r87247 | antoine.pitrou | 2010-12-14 23:06:10 +0100 (Tue, 14 Dec 2010) | 3 lines
  
  Freshen README contents
................
  r87248 | r.david.murray | 2010-12-14 23:32:50 +0100 (Tue, 14 Dec 2010) | 2 lines
  
  More comprehensive compileall cli tests, and fixes.
................
  r87251 | r.david.murray | 2010-12-15 00:06:25 +0100 (Wed, 15 Dec 2010) | 4 lines
  
  #4236: avoid possible Fatal Error when import is called from __del__
  
  Patch by Simon Cross, crasher test code by Martin von Löwis.
................
  r87256 | r.david.murray | 2010-12-15 03:19:14 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  #10705: document what the values of debuglevel are and mean.
................
  r87258 | andrew.kuchling | 2010-12-15 03:37:01 +0100 (Wed, 15 Dec 2010) | 1 line
  
  Typo fix
................
  r87260 | senthil.kumaran | 2010-12-15 05:02:45 +0100 (Wed, 15 Dec 2010) | 6 lines
  
  TIMEOUT value change in URLTimeout Test. test.support.transient_internet has a
  socket timeout of 30 when it checks for resource.  Explicit overrding (like
  setting the 10) wont exhibit consistent behavior when tests are outside context
  manager. So, settting it 30.
................
  r87261 | antoine.pitrou | 2010-12-15 16:33:18 +0100 (Wed, 15 Dec 2010) | 4 lines
  
  Issue #10706: Remove outdated script runtests.sh.  Either `make test`
  or `python -m test` should be used instead.
................
  r87262 | antoine.pitrou | 2010-12-15 16:42:59 +0100 (Wed, 15 Dec 2010) | 3 lines
  
  Remove outdated compatibility file.
................
  r87263 | antoine.pitrou | 2010-12-15 16:47:34 +0100 (Wed, 15 Dec 2010) | 3 lines
  
  Encourage --with-pydebug rather than individual setting of debug options.
................
  r87264 | antoine.pitrou | 2010-12-15 16:48:20 +0100 (Wed, 15 Dec 2010) | 3 lines
  
  I don't think we need to ship the comp.lang.python RFD these days.
................
  r87265 | raymond.hettinger | 2010-12-15 17:30:37 +0100 (Wed, 15 Dec 2010) | 1 line
  
  Issue 10667: Fast path for collections.Counter
................
  r87266 | raymond.hettinger | 2010-12-15 18:54:13 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Add entries for the random module and the collections module.
................
  r87267 | raymond.hettinger | 2010-12-15 19:20:19 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Adopt Antoine's suggestion to improve readability with module subsections.
................
  r87268 | raymond.hettinger | 2010-12-15 19:31:57 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Minor regroupings.
................
  r87269 | raymond.hettinger | 2010-12-15 20:00:38 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Move email section in with other modules.  Fix markup.
................
  r87270 | antoine.pitrou | 2010-12-15 20:07:26 +0100 (Wed, 15 Dec 2010) | 3 lines
  
  Move the urllib-inherited API to a distinguished section
................
  r87271 | eric.araujo | 2010-12-15 20:09:58 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Improve trace documentation (#9264).  Patch by Eli Bendersky.
................
  r87272 | raymond.hettinger | 2010-12-15 20:20:01 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Add intro to the changed modules section.
................
  r87273 | eric.araujo | 2010-12-15 20:30:15 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Use nested method directives, rewrap long lines, fix whitespace.
................
  r87274 | raymond.hettinger | 2010-12-15 20:33:49 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Elaborate on the calculation used in the random module.
................
  r87275 | alexander.belopolsky | 2010-12-15 20:47:37 +0100 (Wed, 15 Dec 2010) | 1 line
  
  Use sentence case in section titles consistently
................
  r87276 | terry.reedy | 2010-12-15 21:18:10 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Issue 10534, difflib: tweak doc; test new SequenceMatcher instance attributes; avoid unneeded lists of SM.b2j keys and items in .__chain_b. Do not backport.
................
  r87277 | eric.araujo | 2010-12-15 21:26:30 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Fix wrong name in docstring and doc (#10693).  Original patch by Eli Bendersky.
................
  r87280 | eric.araujo | 2010-12-15 22:07:22 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Fix build_ext with VS 8.0.  Patch by Hirokazu Yamamoto (#9558).
................
  r87283 | eric.araujo | 2010-12-15 23:06:35 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Add disclaimer about MinGW compat in distutils docs (#6007).  Patch by Chris Lambacher.
................
  r87284 | raymond.hettinger | 2010-12-15 23:07:15 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Add entries for structseq, ContextDecorator, and various C-API changes.
................
  r87288 | raymond.hettinger | 2010-12-15 23:35:03 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Entry for decimal and fractions.
................
  r87289 | eric.araujo | 2010-12-15 23:37:27 +0100 (Wed, 15 Dec 2010) | 2 lines
  
  Mark up one missed None in pkgutil.rst (#8851)
................
  r87292 | antoine.pitrou | 2010-12-15 23:59:16 +0100 (Wed, 15 Dec 2010) | 4 lines
  
  Issue #8844: Regular and recursive lock acquisitions can now be interrupted
  by signals on platforms using pthreads.  Patch by Reid Kleckner.
................
  r87293 | antoine.pitrou | 2010-12-16 00:38:50 +0100 (Thu, 16 Dec 2010) | 3 lines
  
  Make test_threadsignals more lax, and add notes
................
  r87294 | eric.araujo | 2010-12-16 01:07:01 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  No need to generate a link for something that’s just above.
................
  r87295 | raymond.hettinger | 2010-12-16 01:21:08 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  Entries for ElementTree, collectionsm, functools and ZipFile.
................
  r87296 | eric.araujo | 2010-12-16 01:23:30 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  Advertise “python -m” instead of direct filename.
................
  r87297 | raymond.hettinger | 2010-12-16 01:30:53 +0100 (Thu, 16 Dec 2010) | 1 line
  
  Nits
................
  r87298 | raymond.hettinger | 2010-12-16 01:53:05 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  Thank you ispell.
................
  r87299 | lukasz.langa | 2010-12-16 02:16:22 +0100 (Thu, 16 Dec 2010) | 4 lines
  
  Broken ConfigParser removed, SafeConfigParser renamed to ConfigParser.
  Life is beatiful once again.
................
  r87300 | eric.araujo | 2010-12-16 02:40:26 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  Advertise “python -m test” over test.regrtest (r87296 followup)
................
  r87301 | lukasz.langa | 2010-12-16 02:42:36 +0100 (Thu, 16 Dec 2010) | 3 lines
  
  Acknowledged renaming of SafeConfigParser to ConfigParser.
................
  r87302 | eric.araujo | 2010-12-16 03:10:11 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  Add versionadded directive missing from r78983.
................
  r87303 | raymond.hettinger | 2010-12-16 03:24:12 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  Improve the ContextDecorator example.
................
  r87304 | eric.araujo | 2010-12-16 04:13:05 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  Fix one versionchanged
................
  r87306 | brian.curtin | 2010-12-16 04:24:49 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  EasyDialogs was removed in 3.x. fallback_getpass will always be the answer here.
................
  r87312 | eric.araujo | 2010-12-16 07:28:48 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  Add missing docs and directives related to PEP 3147 and byte-compilation
................
  r87315 | raymond.hettinger | 2010-12-16 11:06:11 +0100 (Thu, 16 Dec 2010) | 1 line
  
  Add todo for WSGI
................
  r87316 | antoine.pitrou | 2010-12-16 14:33:56 +0100 (Thu, 16 Dec 2010) | 3 lines
  
  Credit Florent for porting
................
  r87317 | antoine.pitrou | 2010-12-16 17:48:36 +0100 (Thu, 16 Dec 2010) | 4 lines
  
  Issue #10714: Limit length of incoming request in http.server to 65536 bytes
  for security reasons.  Initial patch by Ross Lagerwall.
................
  r87323 | antoine.pitrou | 2010-12-16 19:25:24 +0100 (Thu, 16 Dec 2010) | 3 lines
  
  Issue #10710: `Misc/setuid-prog.c` is removed from the source tree.
................
  r87324 | r.david.murray | 2010-12-16 20:08:51 +0100 (Thu, 16 Dec 2010) | 9 lines
  
  #10719: restore messages generated on invalid compileall args
  
  Before the introduction of filename arguments to compileall it gave semi useful
  messages about not being able to 'list' names that weren't valid directories.
  This fix restores that behavior.  In addition to the test for this case, the
  patch also adds a test for the default behavior of compileall when no arguments
  are provided, and fixes a bug in one of the previously added tests.
................
  r87327 | gregory.p.smith | 2010-12-16 20:23:05 +0100 (Thu, 16 Dec 2010) | 2 lines
  
  assert that the regex given to assertRegex is non-empty.
................
  r87328 | lukasz.langa | 2010-12-17 02:32:29 +0100 (Fri, 17 Dec 2010) | 5 lines
  
  configparser API cleanup: default values now sensible, slightly incompatible.
  Backwards compatible alternative values possible as documented.
  Done by Łukasz Langa, approved by Raymond and Fred.
................
  r87329 | senthil.kumaran | 2010-12-17 05:48:45 +0100 (Fri, 17 Dec 2010) | 3 lines
  
  Fix Issue9721 - urljoin behavior when the relative url starts with ';'
................
  r87337 | r.david.murray | 2010-12-17 17:11:40 +0100 (Fri, 17 Dec 2010) | 2 lines
  
  #10559: provide instructions for accessing sys.argv when first mentioned.
................
  r87338 | r.david.murray | 2010-12-17 17:29:07 +0100 (Fri, 17 Dec 2010) | 2 lines
  
  #10454: clarify the compileall docs and help messages.
................
  r87339 | daniel.stutzbach | 2010-12-17 17:31:32 +0100 (Fri, 17 Dec 2010) | 1 line
  
  Issue 8753: Added documentation for Py_ReprEntr and Py_ReprLeave.
................
  r87340 | antoine.pitrou | 2010-12-17 18:35:56 +0100 (Fri, 17 Dec 2010) | 4 lines
  
  Issue #10711: Remove HTTP 0.9 support from http.client.  The `strict`
  parameter to HTTPConnection and friends is deprecated.
................
  r87341 | antoine.pitrou | 2010-12-17 18:42:16 +0100 (Fri, 17 Dec 2010) | 4 lines
  
  Issue #4188: Avoid creating dummy thread objects when logging operations
  from the threading module (with the internal verbose flag activated).
................
  r87344 | raymond.hettinger | 2010-12-17 21:19:50 +0100 (Fri, 17 Dec 2010) | 1 line
  
  Expand the LBYL glossary entry.
................
  r87345 | martin.v.loewis | 2010-12-17 21:43:27 +0100 (Fri, 17 Dec 2010) | 1 line
  
  Upgrade Tcl/Tk to 8.5.9.
................
  r87346 | daniel.stutzbach | 2010-12-17 21:53:03 +0100 (Fri, 17 Dec 2010) | 1 line
  
  Issue2690: Update docs to reflect the change made by issue2690.
................
  r87348 | martin.v.loewis | 2010-12-17 22:04:09 +0100 (Fri, 17 Dec 2010) | 1 line
  
  Upgrade to sqlite3 3.7.4.
................
  r87350 | lukasz.langa | 2010-12-17 22:56:32 +0100 (Fri, 17 Dec 2010) | 3 lines
  
  100% test coverage, better mapping protocol compatibility, some minor bugfixes
................
  r87351 | lukasz.langa | 2010-12-17 22:57:32 +0100 (Fri, 17 Dec 2010) | 3 lines
  
  configparser hype coming up!
................
  r87352 | lukasz.langa | 2010-12-17 23:05:46 +0100 (Fri, 17 Dec 2010) | 3 lines
  
  fix for an embarrassing autoformatting SNAFU. Thanks for your alertness, Antoine.
................
  r87353 | victor.stinner | 2010-12-17 23:24:30 +0100 (Fri, 17 Dec 2010) | 1 line
  
  update .gitignore using .hgignore
................
  r87354 | daniel.stutzbach | 2010-12-17 23:28:07 +0100 (Fri, 17 Dec 2010) | 1 line
  
  Fix typo
................
  r87355 | raymond.hettinger | 2010-12-18 00:31:30 +0100 (Sat, 18 Dec 2010) | 1 line
  
  Add link to a sample solution to a common problem.
................
  r87356 | r.david.murray | 2010-12-18 04:48:32 +0100 (Sat, 18 Dec 2010) | 11 lines
  
  #9907: call rl_initialize early when using editline on OSX
  
  editline rl_initialize apparently discards any mappings done before it
  is called, which makes tab revert to file completion instead of inserting
  a tab.  So now on OSX we call rl_initialize first if we are using
  readline, and then re-read the users .editrc (if any) afterward so they
  can still override our defaults.
  
  Patch by Ned Deily, modified by Ronald Oussoren.
................
  r87359 | raymond.hettinger | 2010-12-18 10:41:32 +0100 (Sat, 18 Dec 2010) | 1 line
  
  Enhance argparse example to show aliases.
................
  r87360 | raymond.hettinger | 2010-12-18 11:48:26 +0100 (Sat, 18 Dec 2010) | 2 lines
  
  Minor wordsmithing and markup fix-ups.
................
  r87361 | raymond.hettinger | 2010-12-18 11:57:50 +0100 (Sat, 18 Dec 2010) | 2 lines
  
  Minor markup and wording fixups.
................
  r87362 | steven.bethard | 2010-12-18 12:19:23 +0100 (Sat, 18 Dec 2010) | 1 line
  
  Add subparser aliases for argparse. Resolves issue 9324. Approved by Georg for beta2 on the tracker.
................
  r87363 | raymond.hettinger | 2010-12-18 12:20:52 +0100 (Sat, 18 Dec 2010) | 2 lines
  
  Nits.
................
  r87364 | georg.brandl | 2010-12-18 12:53:25 +0100 (Sat, 18 Dec 2010) | 1 line
  
  Add attribution.
................
  r87365 | georg.brandl | 2010-12-18 12:58:12 +0100 (Sat, 18 Dec 2010) | 1 line
  
  Typo fix.
................
  r87366 | georg.brandl | 2010-12-18 13:01:15 +0100 (Sat, 18 Dec 2010) | 1 line
  
  Use kbd role.
................
  r87367 | antoine.pitrou | 2010-12-18 13:33:06 +0100 (Sat, 18 Dec 2010) | 3 lines
  
  Make this a note again.
................
  r87368 | ezio.melotti | 2010-12-18 15:59:43 +0100 (Sat, 18 Dec 2010) | 1 line
  
  #5587: add a repr to dict_proxy objects.  Patch by David Stanek and Daniel Urban.
................
  r87371 | georg.brandl | 2010-12-18 17:21:58 +0100 (Sat, 18 Dec 2010) | 1 line
  
  Fix typo.
................
  r87372 | r.david.murray | 2010-12-18 17:39:06 +0100 (Sat, 18 Dec 2010) | 2 lines
  
  #10728: the default for printing help is sys.stdout, not stderr.
................
  r87373 | senthil.kumaran | 2010-12-18 17:55:23 +0100 (Sat, 18 Dec 2010) | 3 lines
  
  Fix Issue6791 - Limit the HTTP header readline with _MAXLENGTH. Patch by Antoine Pitrou
................
  r87374 | r.david.murray | 2010-12-18 18:19:10 +0100 (Sat, 18 Dec 2010) | 8 lines
  
  #10404: Use ctl-button-1 for context menus on OSX Idle.
  
  This provides access to the context menus where they previously could
  not be accessed due to the way OSX Tk binds buttons.  It also
  improves platform consistency.
  
  Patch by Ned Deily.
................
  r87377 | ezio.melotti | 2010-12-18 18:31:58 +0100 (Sat, 18 Dec 2010) | 1 line
  
  Use lowercase true/false in assertTrue/assertFalse messages.
................
  r87378 | georg.brandl | 2010-12-18 18:51:28 +0100 (Sat, 18 Dec 2010) | 1 line
  
  #10723: add missing builtin exceptions.
................
  r87381 | antoine.pitrou | 2010-12-18 18:59:18 +0100 (Sat, 18 Dec 2010) | 3 lines
  
  NEWS entry for r87373	
................
  r87384 | r.david.murray | 2010-12-18 19:25:38 +0100 (Sat, 18 Dec 2010) | 12 lines
  
  #9286: Fix the rfc822 parser to preserve whitespace in address local part.
  
  Such addresses are not RFC compliant except under the 'obsolete syntax'
  rules, but before this fix the whitespace was dropped from the input,
  concatenating the pieces.  That breaks one of the principles of the
  email package, that of preserving the input as much as possible.
  It also denies the application program the opportunity to apply its
  own heuristics to interpretation of such non-compliant addresses.
  
  It is possible users of the email package were depending on the local
  part always being a single token, so this fix will not be backported.
................
  r87389 | ezio.melotti | 2010-12-18 21:00:04 +0100 (Sat, 18 Dec 2010) | 1 line
  
  #10573: use actual/expected consistently in unittest methods. The order of the args of assertCountEqual is also changed.
................
  r87390 | michael.foord | 2010-12-19 04:19:47 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Issue 10611. Issue 9857. Improve the way exception handling, including test skipping, is done inside TestCase.run
................
  r87391 | michael.foord | 2010-12-19 04:59:10 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Fix minor issue in implementation of issue 10470.
................
  r87392 | michael.foord | 2010-12-19 05:07:28 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Improvement to fix for issue 9926 to allow TestResult to be reused.
................
  r87393 | vinay.sajip | 2010-12-19 07:02:31 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Logging documentation update.
................
  r87394 | georg.brandl | 2010-12-19 11:10:32 +0100 (Sun, 19 Dec 2010) | 1 line
  
  #6075: make idle work with both Carbon AquaTk and Cocoa AquaTk. Patch by Kevin Walzer and Ned Deily.
................
  r87395 | georg.brandl | 2010-12-19 11:17:46 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Temporarily skip test failing with newer ttk.
................
  r87396 | georg.brandl | 2010-12-19 11:25:28 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Update pydoc topics.
................
  r87397 | georg.brandl | 2010-12-19 11:28:46 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Fix markup error and update suspicious file.
................
  r87398 | georg.brandl | 2010-12-19 11:30:28 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Bump to 3.2b2.
................
  r87399 | senthil.kumaran | 2010-12-19 11:49:52 +0100 (Sun, 19 Dec 2010) | 3 lines
  
  Issue3243 - Support iterable bodies in httplib. Patch contributions by Xuanji Li and Chris AtLee.
................
  r87400 | georg.brandl | 2010-12-19 13:33:52 +0100 (Sun, 19 Dec 2010) | 1 line
  
  #3243 follow-up: remove debugging print and fix docs; data is a bytes object.
................
  r87402 | vinay.sajip | 2010-12-19 13:56:57 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Logging documentation reorganised.
................
  r87403 | vinay.sajip | 2010-12-19 14:41:26 +0100 (Sun, 19 Dec 2010) | 1 line
  
  Logging documentation updates.
................
  r87408 | r.david.murray | 2010-12-20 19:08:59 +0100 (Mon, 20 Dec 2010) | 8 lines
  
  Make test_compileall more robust by using -S to keep sys.path minimized.
  
  Arfrever Taifersar Arahesis reported that test_compileall failed during Gentoo
  install because it was tyring to write .pyc files to a read-only system
  directory during test_no_args_compiles_path.  Having subprocess call python
  with -S should eliminate the system directories from the path.
................
  r87411 | r.david.murray | 2010-12-20 20:04:51 +0100 (Mon, 20 Dec 2010) | 2 lines
  
  Revert incorrect patch made at the wrong time.
................
  r87415 | r.david.murray | 2010-12-21 19:07:59 +0100 (Tue, 21 Dec 2010) | 4 lines
  
  Fix the change made for issue 1243654.
  
  Surprisingly, it turns out there was no test that exercised this code path.
................
  r87418 | r.david.murray | 2010-12-21 19:24:33 +0100 (Tue, 21 Dec 2010) | 10 lines
  
  Make test_compileall more robust by using -S to keep sys.path minimized.
  
  Try this again, hopefully the right way this time.
  
  Arfrever Taifersar Arahesis reported that test_compileall failed during Gentoo
  install because it was tyring to write .pyc files to a read-only system
  directory during test_no_args_compiles_path.  Having the tests call python
  with -S should eliminate the system directories from the path.
................
  r87421 | antoine.pitrou | 2010-12-21 19:49:01 +0100 (Tue, 21 Dec 2010) | 4 lines
  
  Suggest sys.maxsize as a reliable way to know whether the interpreter is 64-bit.
  (part of #10735)
................
  r87424 | raymond.hettinger | 2010-12-21 20:24:26 +0100 (Tue, 21 Dec 2010) | 1 line
  
  Deprecate assertDictContainsSubset()
................
  r87425 | raymond.hettinger | 2010-12-21 21:09:55 +0100 (Tue, 21 Dec 2010) | 2 lines
  
  Reference the release schedule
................
  r87426 | raymond.hettinger | 2010-12-21 21:52:12 +0100 (Tue, 21 Dec 2010) | 2 lines
  
  Document the alternate format for :ref:.
................
  r87427 | antoine.pitrou | 2010-12-21 22:20:59 +0100 (Tue, 21 Dec 2010) | 3 lines
  
  Issue #10750: The `raw` attribute of buffered IO objects is now read-only.
................
  r87430 | r.david.murray | 2010-12-21 22:53:37 +0100 (Tue, 21 Dec 2010) | 9 lines
  
  #4871: check that zipfile password is bytes, and give useful error message.
  
  Previously passing a string in as the password would fail either with
  an assertion error or a TypeError with a confusing error message.
  Note that a string can't be accepted since zipfile has no way to
  guess what encoding should be used to turn it into bytes.
  
  Patch by Victor Stinner.
................
  r87433 | alexander.belopolsky | 2010-12-22 02:37:36 +0100 (Wed, 22 Dec 2010) | 3 lines
  
  Both PEP 3131 and the current implementation use NFKC normalization
  for identifiers.  Fixed the documentation to agree.
................
  r87435 | alexander.belopolsky | 2010-12-22 03:35:20 +0100 (Wed, 22 Dec 2010) | 1 line
  
  Removed unneeded #include
................
  r87436 | gregory.p.smith | 2010-12-22 06:22:17 +0100 (Wed, 22 Dec 2010) | 2 lines
  
  fix a compiler warning about err_msg potentially being used uninitialized.
................
  r87437 | raymond.hettinger | 2010-12-22 10:11:54 +0100 (Wed, 22 Dec 2010) | 2 lines
  
  Add todo
................
  r87438 | michael.foord | 2010-12-22 11:39:04 +0100 (Wed, 22 Dec 2010) | 1 line
  
  Minor typo corrections in whatsnew
................
  r87439 | vinay.sajip | 2010-12-22 16:04:15 +0100 (Wed, 22 Dec 2010) | 1 line
  
  Logging documentation updates.
................
  r87440 | michael.foord | 2010-12-22 19:28:51 +0100 (Wed, 22 Dec 2010) | 1 line
  
  Another trivial typo correction in whatsnew
................
  r87441 | antoine.pitrou | 2010-12-22 23:19:15 +0100 (Wed, 22 Dec 2010) | 3 lines
  
  Fix ResourceWarning in test_normalization
................
  r87442 | alexander.belopolsky | 2010-12-23 03:27:37 +0100 (Thu, 23 Dec 2010) | 1 line
  
  Issue #10254: Fixed a crash and a regression introduced by the implementation of PRI 29.
................
  r87443 | alexander.belopolsky | 2010-12-23 03:58:25 +0100 (Thu, 23 Dec 2010) | 1 line
  
  Issue #10587: Document the meaning of str methods.
................
  r87445 | eric.araujo | 2010-12-23 19:41:33 +0100 (Thu, 23 Dec 2010) | 2 lines
  
  Fix small inaccuracy: there is no index function
................
  r87446 | eric.araujo | 2010-12-23 19:44:31 +0100 (Thu, 23 Dec 2010) | 2 lines
  
  Nits: use a real boolean, make one docstring more similar to the other ones
................
  r87447 | eric.araujo | 2010-12-23 20:13:05 +0100 (Thu, 23 Dec 2010) | 2 lines
  
  Fix typo in superclass method name
................
  r87448 | r.david.murray | 2010-12-23 20:44:49 +0100 (Thu, 23 Dec 2010) | 4 lines
  
  #4496: remove misleading comment and note that self.handlers is obsolete.
  
  self.handlers is still used in one urllib2 test, but not by the code iteslf.
................
  r87451 | r.david.murray | 2010-12-23 21:35:46 +0100 (Thu, 23 Dec 2010) | 4 lines
  
  #1155362: allow hh:mm:ss-uuuu like we allow hh:mm:ss+uuuu in parsedate_tz
  
  Original patch by Thomas Herve.
................
  r87454 | raymond.hettinger | 2010-12-23 22:54:02 +0100 (Thu, 23 Dec 2010) | 4 lines
  
  Fix buglet.  If the input was an iterator, the fallback would occur after
  part of the iterator had been consumed.   Also, fix argument names which
  did not match the docs and were a bit misleading.
................
  r87455 | benjamin.peterson | 2010-12-23 23:17:42 +0100 (Thu, 23 Dec 2010) | 1 line
  
  fix docstring
................
  r87458 | benjamin.peterson | 2010-12-23 23:49:38 +0100 (Thu, 23 Dec 2010) | 1 line
  
  use native tenary condition
................
  r87459 | benjamin.peterson | 2010-12-23 23:53:42 +0100 (Thu, 23 Dec 2010) | 1 line
  
  kill some function imports
................
  r87460 | terry.reedy | 2010-12-24 00:10:28 +0100 (Fri, 24 Dec 2010) | 3 lines
  
  Issue 10730: mimetypes module - add .svgz to mimetypes.suffix_map and .svg to types_map.
  Addition OKed by GB on IRC (R. David Murray). No backport.
................
  r87461 | eric.araujo | 2010-12-24 00:18:41 +0100 (Fri, 24 Dec 2010) | 2 lines
  
  Fix syntax typo
................
  r87462 | benjamin.peterson | 2010-12-24 00:45:39 +0100 (Fri, 24 Dec 2010) | 1 line
  
  update comment
................
  r87463 | alexander.belopolsky | 2010-12-24 01:24:11 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Issue #9063: Corrected the tzinfo example.
................
  r87466 | raymond.hettinger | 2010-12-24 01:48:47 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Add test for r87454.
................
  r87467 | raymond.hettinger | 2010-12-24 01:52:54 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Fix docs and comment for r87454.
................
  r87468 | raymond.hettinger | 2010-12-24 01:58:34 +0100 (Fri, 24 Dec 2010) | 2 lines
  
  Fix docstring.
................
  r87469 | senthil.kumaran | 2010-12-24 05:03:59 +0100 (Fri, 24 Dec 2010) | 4 lines
  
  Fix some mistakes- Issue3243 (r87399)  Correcting the operator precendence
  problem with Content-Length header and uncommenting the test.
................
  r87470 | alexander.belopolsky | 2010-12-24 05:22:40 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Added an XXX note to describe timedelta/timedelta feature.
................
  r87471 | raymond.hettinger | 2010-12-24 11:02:22 +0100 (Fri, 24 Dec 2010) | 20 lines
  
  Improve diff for assertCountEqual() to actually show the differing counts.
  
  New output looks like this: 
  
  Traceback (most recent call last):
    File "test.py", line 5, in test_ce
      self.assertCountEqual('abracadabra xx', 'simsalabim xx')
  AssertionError: Element counts were not equal:
  Expected 5, got 2:  'a'
  Expected 2, got 1:  'b'
  Expected 0, got 2:  'i'
  Expected 0, got 2:  'm'
  Expected 0, got 1:  'l'
  Expected 0, got 2:  's'
  Expected 1, got 0:  'c'
  Expected 1, got 0:  'd'
  Expected 2, got 0:  'r'
................
  r87472 | raymond.hettinger | 2010-12-24 11:04:00 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Add news entry for 87471.
................
  r87473 | raymond.hettinger | 2010-12-24 11:30:06 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Add direct tests for the util functions.
................
  r87474 | raymond.hettinger | 2010-12-24 12:20:30 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Put diff output in useful order (when the elements were first seen).
................
  r87475 | raymond.hettinger | 2010-12-24 12:24:00 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Keep helper functions private.
................
  r87476 | vinay.sajip | 2010-12-24 13:03:48 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Logging documentation updates.
................
  r87477 | raymond.hettinger | 2010-12-24 22:51:48 +0100 (Fri, 24 Dec 2010) | 1 line
  
  Adopt symmetric names for arguments (actual/expected --> first/second).
................
  r87478 | terry.reedy | 2010-12-24 22:59:03 +0100 (Fri, 24 Dec 2010) | 2 lines
  
  Match current tracker name, though I do not know if still active.
................
  r87479 | r.david.murray | 2010-12-24 23:36:49 +0100 (Fri, 24 Dec 2010) | 8 lines
  
  #1693546: don't add quotes around RFC 2231 encoded values.
  
  The RFC is bit hard to understand on this point, but the examples
  clearly show that parameter values that are encoded according
  to its charset/language rules don't have surrounding quotes, and
  the ABNF does not allow for quotes.  So when we produce such
  encoded values, we no longer add quotes.
................
  r87482 | brian.quinlan | 2010-12-25 00:10:41 +0100 (Sat, 25 Dec 2010) | 1 line
  
  Better reporting of test failures on Windows.
................
  r87483 | brian.quinlan | 2010-12-25 01:18:27 +0100 (Sat, 25 Dec 2010) | 1 line
  
  Assign closed handles to None to make errors more obvious if they are used.
................
  r87485 | victor.stinner | 2010-12-25 23:40:32 +0100 (Sat, 25 Dec 2010) | 5 lines
  
  Issue #10763: subprocess.communicate() closes stdout and stderr if both are
  pipes (bug specific to Windows).
  
  Improve also the unit test: write a portable unit test.
................
  r87486 | eric.araujo | 2010-12-26 03:18:49 +0100 (Sun, 26 Dec 2010) | 2 lines
  
  Fix typo spotted by Rodrigo Bernardo Pimentel (#9891)
................
  r87489 | eric.araujo | 2010-12-26 03:38:05 +0100 (Sun, 26 Dec 2010) | 2 lines
  
  Remove unexistent parameter (#3216)
................
  r87492 | terry.reedy | 2010-12-26 04:48:35 +0100 (Sun, 26 Dec 2010) | 1 line
  
  revert 87478
................
  r87493 | eric.araujo | 2010-12-26 18:53:27 +0100 (Sun, 26 Dec 2010) | 2 lines
  
  Fix typo (#10770)
................
  r87496 | vinay.sajip | 2010-12-26 19:47:51 +0100 (Sun, 26 Dec 2010) | 1 line
  
  Improved logging cookbook for logging with multiprocessing.
................
  r87497 | r.david.murray | 2010-12-26 20:54:29 +0100 (Sun, 26 Dec 2010) | 10 lines
  
  #5258/#10642: print fn, line, traceback and continue when .pth file is broken
  
  If a .pth file contained an error, it could cause a traceback in site.py,
  terminating its processing.  In 2.7 and 3.2, the interpreter will then not
  start.  Previously, a message would print saying to use -v to get the
  traceback.  In either case, the traceback generated for a failed .pth file did
  not include the .pth filename, making it difficult to debug the problem.  Now
  site.py reports not only the .pth filename but also the line number causing the
  error, and just skips the remainder of the file.
................
  r87498 | vinay.sajip | 2010-12-26 22:22:33 +0100 (Sun, 26 Dec 2010) | 1 line
  
  Added logging documentation cross-references.
................
  r87501 | r.david.murray | 2010-12-27 01:03:13 +0100 (Mon, 27 Dec 2010) | 2 lines
  
  Escape file path before searching for it in output via regex
................
  r87504 | victor.stinner | 2010-12-27 02:49:26 +0100 (Mon, 27 Dec 2010) | 1 line
  
  Issue #9738: Document encodings of error and warning functions
................
  r87505 | victor.stinner | 2010-12-27 02:49:29 +0100 (Mon, 27 Dec 2010) | 1 line
  
  Issue #9738: document encodings of unicode functions
................
  r87506 | victor.stinner | 2010-12-27 02:49:31 +0100 (Mon, 27 Dec 2010) | 1 line
  
  Issue #9738: Document encodings of AST, compiler, parser and PyRun functions
................
  r87507 | victor.stinner | 2010-12-27 03:39:20 +0100 (Mon, 27 Dec 2010) | 1 line
  
  Issue #9738: Ooops, fix typos in my previous commit (r87506)
................
  r87508 | r.david.murray | 2010-12-27 05:31:48 +0100 (Mon, 27 Dec 2010) | 5 lines
  
  Skip test that does not raise an error on Windows.
  
  I'm assuming that the putative path from the malformed
  pth file is simply not found and therefore ignored.
................
  r87512 | vinay.sajip | 2010-12-27 12:18:52 +0100 (Mon, 27 Dec 2010) | 1 line
  
  Issue #10774: test_logging now removes temp files created during tests.
................
  r87513 | vinay.sajip | 2010-12-27 15:31:52 +0100 (Mon, 27 Dec 2010) | 1 line
  
  Issue #10626: test_logging now preserves logger disabled states.
................
  r87514 | vinay.sajip | 2010-12-27 19:34:25 +0100 (Mon, 27 Dec 2010) | 1 line
  
  Issue #10626: test_logging now preserves logger disabled states.
................
  r87516 | r.david.murray | 2010-12-27 21:09:32 +0100 (Mon, 27 Dec 2010) | 5 lines
  
  #7056: runtest and runtest_inner don't use testdir, so drop it from their sigs
  
  I've only tested regular runs and -j runs.  If I've broken anything
  else I'm sure I'll hear about it sooner or later.
................
  r87517 | victor.stinner | 2010-12-27 21:10:36 +0100 (Mon, 27 Dec 2010) | 3 lines
  
  Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
  encoding instead of UTF-8.
................
  r87518 | victor.stinner | 2010-12-27 21:12:13 +0100 (Mon, 27 Dec 2010) | 3 lines
  
  Issue #10778: decoding_fgets() decodes the filename from the filesystem
  encoding instead of UTF-8.
................
  r87519 | victor.stinner | 2010-12-28 01:28:21 +0100 (Tue, 28 Dec 2010) | 3 lines
  
  Issue #10780: PyErr_SetFromWindowsErrWithFilename() and
  PyErr_SetExcFromWindowsErrWithFilename() decode the filename from the
  filesystem encoding instead of UTF-8.
................
  r87520 | victor.stinner | 2010-12-28 01:59:02 +0100 (Tue, 28 Dec 2010) | 3 lines
  
  Issue #8966: Remove the documentation of ctypes.set_conversion_mode()
  
  Function removed by r83195.
................
  r87521 | victor.stinner | 2010-12-28 01:59:03 +0100 (Tue, 28 Dec 2010) | 3 lines
  
  Issue #10780: Remove commas at the end of the argument list
  
  Forbidden in C, stupid language!
................
  r87522 | georg.brandl | 2010-12-28 10:16:12 +0100 (Tue, 28 Dec 2010) | 1 line
  
  Replace sys.maxint mention by sys.maxsize.
................
  r87523 | georg.brandl | 2010-12-28 10:18:24 +0100 (Tue, 28 Dec 2010) | 1 line
  
  Remove confusing paragraph -- this is relevant only to advanced users anyway and does not belong into the tutorial.
................
  r87524 | georg.brandl | 2010-12-28 10:29:19 +0100 (Tue, 28 Dec 2010) | 1 line
  
  Fix advice: call PyType_Ready to fill in ob_type of custom types.
................
  r87525 | georg.brandl | 2010-12-28 10:51:43 +0100 (Tue, 28 Dec 2010) | 1 line
  
  #10679: install idle, pydoc, 2to3 scripts with X.Y suffix for make altinstall; create symlinks for make install.
................
  r87526 | georg.brandl | 2010-12-28 11:38:33 +0100 (Tue, 28 Dec 2010) | 1 line
  
  #10777: fix iteration over dict keys while mutating the dict.
................
  r87527 | georg.brandl | 2010-12-28 11:56:20 +0100 (Tue, 28 Dec 2010) | 1 line
  
  #10768: fix ScrolledText widget construction, and make the example work from the interactive shell.
................
  r87528 | georg.brandl | 2010-12-28 12:02:12 +0100 (Tue, 28 Dec 2010) | 1 line
  
  Add news entry and clarify another.
................
  r87529 | victor.stinner | 2010-12-28 12:02:46 +0100 (Tue, 28 Dec 2010) | 2 lines
  
  Issue #9738: Fix typo, ASCII-encoding string => ASCII-encoded string
................
  r87530 | georg.brandl | 2010-12-28 12:06:07 +0100 (Tue, 28 Dec 2010) | 1 line
  
  #10767: update README in crashers; not all may have a bug entry and/or be fixed.
................
  r87531 | georg.brandl | 2010-12-28 12:08:17 +0100 (Tue, 28 Dec 2010) | 1 line
  
  #10742: document readonly attribute of memoryviews.
................
  r87532 | georg.brandl | 2010-12-28 12:15:49 +0100 (Tue, 28 Dec 2010) | 1 line
  
  #10781: clarify that *encoding* is not a parameter for Node objects in general.
................
  r87533 | georg.brandl | 2010-12-28 12:38:12 +0100 (Tue, 28 Dec 2010) | 1 line
  
  Remove history; adapt a bit more to reST, since this will once be part of the dev guide.
................
  r87534 | georg.brandl | 2010-12-28 12:48:53 +0100 (Tue, 28 Dec 2010) | 1 line
  
  Rewrap.
................
  r87535 | georg.brandl | 2010-12-28 12:49:41 +0100 (Tue, 28 Dec 2010) | 1 line
  
  #10739: document that on Windows, socket.makefile() does not make a file that has a true file descriptor usable where such a thing is expected.
................
  r87536 | georg.brandl | 2010-12-28 12:53:25 +0100 (Tue, 28 Dec 2010) | 1 line
  
  #10609: fix non-working dbm example.
................
  r87537 | victor.stinner | 2010-12-28 14:26:42 +0100 (Tue, 28 Dec 2010) | 6 lines
  
  Issue #10783: struct.pack() doesn't encode implicitly unicode to UTF-8
  
   * Replace "bytes" by "bytes object" in struct error messages
   * Document the API change in What's new in Python 3.2
   * Fix test_wave
   * Remove also ugly implicit conversions in test_struct
................
  r87538 | victor.stinner | 2010-12-28 14:33:43 +0100 (Tue, 28 Dec 2010) | 1 line
  
  Issue #10783: Fix test_sys, pack('c', ' ') => pack('c', b' ')
................
  r87539 | brian.curtin | 2010-12-28 15:31:47 +0100 (Tue, 28 Dec 2010) | 3 lines
  
  Fix #9333. The symlink function is always available now, raising OSError
  when the user doesn't hold the symbolic link privilege rather than hiding it.
................
  r87542 | senthil.kumaran | 2010-12-28 16:55:16 +0100 (Tue, 28 Dec 2010) | 3 lines
  
  Fix Issue10759 - html.parser.unescape() fails on HTML entities with incorrect syntax
................
  r87547 | brian.curtin | 2010-12-28 18:08:22 +0100 (Tue, 28 Dec 2010) | 3 lines
  
  Minor doc update for #9333. Took out the phrasing about os.symlink not
  existing and mentioned the OSError possibility.
................
  r87548 | brian.curtin | 2010-12-28 18:12:43 +0100 (Tue, 28 Dec 2010) | 3 lines
  
  This file was obsolted by a number of adjustments to the os.symlink tests
  on Windows, and is no longer needed by any tests or Lib/test/support.py
................
  r87549 | georg.brandl | 2010-12-28 19:30:18 +0100 (Tue, 28 Dec 2010) | 1 line
  
  Add sys.flags.quiet attribute for the new -q option, as noted missing by Eric in #1772833.
................
  r87550 | r.david.murray | 2010-12-28 19:54:13 +0100 (Tue, 28 Dec 2010) | 8 lines
  
  #9824: encode , and ; in cookie values so that browsers don't split on them
  
  There is a small chance of backward incompatibility here, but only for
  non-SimpleCookie applications reading SimpleCookie generated cookies.  Even
  then, any such ap is likely to be handling escaped values already, and it would
  take a fairly perverse implementation of unescaping to fail to unescape these
  newly escaped chars, so the risk seems minimal.
................
  r87553 | terry.reedy | 2010-12-28 20:30:19 +0100 (Tue, 28 Dec 2010) | 2 lines
  
  Issue 10738: Fix webbrowser.Opera.raise_opts value.
................
  r87556 | brian.quinlan | 2010-12-28 22:14:34 +0100 (Tue, 28 Dec 2010) | 1 line
  
  Does not install a logging handler. Fixes issue 10626.
................
  r87557 | victor.stinner | 2010-12-29 00:05:20 +0100 (Wed, 29 Dec 2010) | 1 line
  
  Compile pgenmain.c and printgrammar.c with PGEN defined
................
  r87558 | victor.stinner | 2010-12-29 00:14:17 +0100 (Wed, 29 Dec 2010) | 1 line
  
  Don't ignore pgen error (on "make Parser/pgen.stamp")
................
  r87559 | victor.stinner | 2010-12-29 00:35:10 +0100 (Wed, 29 Dec 2010) | 1 line
  
  Issue #10783: rephrase the changelog (NEWS, What's new)
................
  r87560 | victor.stinner | 2010-12-29 00:39:51 +0100 (Wed, 29 Dec 2010) | 1 line
  
  Rephrase PyUnicode_CompareWithASCIIString() documentation
................
  r87561 | brian.curtin | 2010-12-29 03:04:28 +0100 (Wed, 29 Dec 2010) | 2 lines
  
  Fix #9333 on Windows XP, where os.symlink is not a possibility.
................
  r87562 | brian.curtin | 2010-12-29 03:41:07 +0100 (Wed, 29 Dec 2010) | 2 lines
  
  Close stdout, clear ResourceWarning
................
  r87563 | victor.stinner | 2010-12-29 03:44:42 +0100 (Wed, 29 Dec 2010) | 1 line
  
  Issue #10783: rephrase the changelog (new try)
................
  r87564 | senthil.kumaran | 2010-12-29 07:25:42 +0100 (Wed, 29 Dec 2010) | 3 lines
  
  Fix Issue 10753 - Don't quote ;=, in the PATH_INFO envvar.
................
  r87567 | r.david.murray | 2010-12-29 17:57:24 +0100 (Wed, 29 Dec 2010) | 2 lines
  
  Fix a comment typo and update another comment to match Python3 reality                                                                                                                                                                                                                 
................
  r87569 | terry.reedy | 2010-12-29 20:02:07 +0100 (Wed, 29 Dec 2010) | 2 lines
  
  Minor clarification
................
  r87571 | r.david.murray | 2010-12-29 20:06:48 +0100 (Wed, 29 Dec 2010) | 2 lines
  
  Fix same typo in docs.
................
  r87573 | senthil.kumaran | 2010-12-30 08:07:58 +0100 (Thu, 30 Dec 2010) | 3 lines
  
  Fix Issue10793 - hashlib documentation issue on return type of digest
................
  r87575 | martin.v.loewis | 2010-12-30 09:36:37 +0100 (Thu, 30 Dec 2010) | 2 lines
  
  Issue #10542: Document that identifiers use XID_Start XID_Continue*.
................
  r87577 | martin.v.loewis | 2010-12-30 15:55:47 +0100 (Thu, 30 Dec 2010) | 2 lines
  
  Build and install libpython3.so.
................
  r87579 | georg.brandl | 2010-12-30 18:22:33 +0100 (Thu, 30 Dec 2010) | 1 line
  
  Remove some of the old demos.  (Put a few somewhere else.)
................
  r87580 | georg.brandl | 2010-12-30 18:32:22 +0100 (Thu, 30 Dec 2010) | 1 line
  
  Clean up tools: remove "world" and "framer", move single SSL script to scripts/.
................
  r87581 | georg.brandl | 2010-12-30 18:36:17 +0100 (Thu, 30 Dec 2010) | 1 line
  
  Fix NameErrors.
................
  r87582 | michael.foord | 2010-12-30 20:36:29 +0100 (Thu, 30 Dec 2010) | 1 line
  
  Issue 10786: unittest.TextTestRunner default stream no longer bound at import time
................
  r87583 | georg.brandl | 2010-12-30 22:33:07 +0100 (Thu, 30 Dec 2010) | 1 line
  
  More cleanup: Move some demos into a dedicated Tools/demo dir, move 2to3 demo to Tools, and remove all the other Demo content.
................
  r87584 | georg.brandl | 2010-12-30 22:33:49 +0100 (Thu, 30 Dec 2010) | 1 line
  
  Remove the actual Demo dir.
................
  r87585 | georg.brandl | 2010-12-30 23:11:50 +0100 (Thu, 30 Dec 2010) | 1 line
  
  Harmonize docstrings.  Move redemo from Tools/scripts to Tools/demo.  Add a README file to Tools/demo.
................
  r87586 | georg.brandl | 2010-12-30 23:12:40 +0100 (Thu, 30 Dec 2010) | 1 line
  
  Remove mentions of the Demo directory.
................
  r87587 | georg.brandl | 2010-12-30 23:31:10 +0100 (Thu, 30 Dec 2010) | 1 line
  
  Add the missing __main__.py in the turtledemo package.  It seems to have been lost during some mass rename action (r86095).
................
  r87588 | georg.brandl | 2010-12-30 23:32:49 +0100 (Thu, 30 Dec 2010) | 1 line
  
  Update README, remove empty directory.
................
  r87589 | vinay.sajip | 2010-12-31 00:26:50 +0100 (Fri, 31 Dec 2010) | 1 line
  
  Issue #10788: Changed test_logging setUp logic to provide more information.
................
  r87590 | r.david.murray | 2010-12-31 20:21:14 +0100 (Fri, 31 Dec 2010) | 4 lines
  
  #9361: add some tests for calendar.leapdays
  
  Patch by John Chandler.
................
  r87593 | georg.brandl | 2011-01-01 00:00:03 +0100 (Sat, 01 Jan 2011) | 1 line
  
  Happy New Year!  (CET edition)
................
  r87594 | raymond.hettinger | 2011-01-01 00:16:17 +0100 (Sat, 01 Jan 2011) | 1 line
  
  Fix OrderedDict.setdefault() to work for subclasses that define __missing__().
................
  r87595 | raymond.hettinger | 2011-01-01 00:23:06 +0100 (Sat, 01 Jan 2011) | 2 lines
  
  Typo.
................
  r87598 | terry.reedy | 2011-01-01 03:25:36 +0100 (Sat, 01 Jan 2011) | 2 lines
  
  Issue 6285: catch missing IDLE help file.
................
  r87601 | terry.reedy | 2011-01-01 03:54:11 +0100 (Sat, 01 Jan 2011) | 2 lines
  
  Issue 6285: add NEWS entry for 3.2.
................
  r87603 | georg.brandl | 2011-01-01 11:07:30 +0100 (Sat, 01 Jan 2011) | 1 line
  
  Fix issue references.
................
  r87604 | georg.brandl | 2011-01-01 11:09:32 +0100 (Sat, 01 Jan 2011) | 1 line
  
  #10801: In zipfile, support different encodings for the header and the filenames.  Patch by MvL, test by Eli Bendersky.
................
  r87606 | georg.brandl | 2011-01-01 11:42:31 +0100 (Sat, 01 Jan 2011) | 1 line
  
  #10801: do not actually extract, just open() the files in the test zipfile.
................
  r87607 | benjamin.peterson | 2011-01-01 15:28:31 +0100 (Sat, 01 Jan 2011) | 1 line
  
  update copyright to 2011
................
  r87610 | gregory.p.smith | 2011-01-01 22:18:46 +0100 (Sat, 01 Jan 2011) | 2 lines
  
  post release bump
................
  r87611 | raymond.hettinger | 2011-01-01 23:38:00 +0100 (Sat, 01 Jan 2011) | 1 line
  
  Make it easier to extend OrderedDict without breaking it.
................
  r87612 | raymond.hettinger | 2011-01-02 00:51:55 +0100 (Sun, 02 Jan 2011) | 1 line
  
  Fix OrderedDic.pop() to work for subclasses that define  __missing__().
................
  r87615 | raymond.hettinger | 2011-01-02 09:03:33 +0100 (Sun, 02 Jan 2011) | 4 lines
  
  Fix doctest to not rely on order of dictionary entries.
  Use super() instead of direct references to the dict superclass.
................


Added:
   python/branches/py3k-cdecimal/Doc/howto/logging-cookbook.rst
      - copied unchanged from r87615, /python/branches/py3k/Doc/howto/logging-cookbook.rst
   python/branches/py3k-cdecimal/Doc/howto/logging.rst
      - copied unchanged from r87615, /python/branches/py3k/Doc/howto/logging.rst
   python/branches/py3k-cdecimal/Doc/library/logging.config.rst
      - copied unchanged from r87615, /python/branches/py3k/Doc/library/logging.config.rst
   python/branches/py3k-cdecimal/Doc/library/logging.handlers.rst
      - copied unchanged from r87615, /python/branches/py3k/Doc/library/logging.handlers.rst
   python/branches/py3k-cdecimal/Include/typeslots.h
      - copied unchanged from r87615, /python/branches/py3k/Include/typeslots.h
   python/branches/py3k-cdecimal/Lib/encodings/base64_codec.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/encodings/base64_codec.py
   python/branches/py3k-cdecimal/Lib/encodings/bz2_codec.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/encodings/bz2_codec.py
   python/branches/py3k-cdecimal/Lib/encodings/hex_codec.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/encodings/hex_codec.py
   python/branches/py3k-cdecimal/Lib/encodings/quopri_codec.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/encodings/quopri_codec.py
   python/branches/py3k-cdecimal/Lib/encodings/rot_13.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/encodings/rot_13.py
   python/branches/py3k-cdecimal/Lib/encodings/uu_codec.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/encodings/uu_codec.py
   python/branches/py3k-cdecimal/Lib/encodings/zlib_codec.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/encodings/zlib_codec.py
   python/branches/py3k-cdecimal/Lib/pydoc_data/_pydoc.css
      - copied unchanged from r87615, /python/branches/py3k/Lib/pydoc_data/_pydoc.css
   python/branches/py3k-cdecimal/Lib/test/__main__.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/test/__main__.py
   python/branches/py3k-cdecimal/Lib/test/json_tests/   (props changed)
      - copied from r87615, /python/branches/py3k/Lib/test/json_tests/
   python/branches/py3k-cdecimal/Lib/test/subprocessdata/
      - copied from r87615, /python/branches/py3k/Lib/test/subprocessdata/
   python/branches/py3k-cdecimal/Lib/test/zip_cp437_header.zip
      - copied unchanged from r87615, /python/branches/py3k/Lib/test/zip_cp437_header.zip
   python/branches/py3k-cdecimal/Lib/turtledemo/__main__.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/turtledemo/__main__.py
   python/branches/py3k-cdecimal/Lib/unittest/test/_test_warnings.py
      - copied unchanged from r87615, /python/branches/py3k/Lib/unittest/test/_test_warnings.py
   python/branches/py3k-cdecimal/Modules/xxlimited.c
      - copied unchanged from r87615, /python/branches/py3k/Modules/xxlimited.c
   python/branches/py3k-cdecimal/Objects/typeslots.inc
      - copied unchanged from r87615, /python/branches/py3k/Objects/typeslots.inc
   python/branches/py3k-cdecimal/Objects/typeslots.py
      - copied unchanged from r87615, /python/branches/py3k/Objects/typeslots.py
   python/branches/py3k-cdecimal/PC/python3.def
      - copied unchanged from r87615, /python/branches/py3k/PC/python3.def
   python/branches/py3k-cdecimal/PC/python3.mak
      - copied unchanged from r87615, /python/branches/py3k/PC/python3.mak
   python/branches/py3k-cdecimal/PC/python32gen.py
      - copied unchanged from r87615, /python/branches/py3k/PC/python32gen.py
   python/branches/py3k-cdecimal/PC/python32stub.def
      - copied unchanged from r87615, /python/branches/py3k/PC/python32stub.def
   python/branches/py3k-cdecimal/PC/python3dll.c
      - copied unchanged from r87615, /python/branches/py3k/PC/python3dll.c
   python/branches/py3k-cdecimal/PCbuild/python3dll.vcproj
      - copied unchanged from r87615, /python/branches/py3k/PCbuild/python3dll.vcproj
   python/branches/py3k-cdecimal/PCbuild/xxlimited.vcproj
      - copied unchanged from r87615, /python/branches/py3k/PCbuild/xxlimited.vcproj
   python/branches/py3k-cdecimal/Tools/demo/
      - copied from r87615, /python/branches/py3k/Tools/demo/
   python/branches/py3k-cdecimal/Tools/parser/
      - copied from r87615, /python/branches/py3k/Tools/parser/
   python/branches/py3k-cdecimal/Tools/scripts/abitype.py
      - copied unchanged from r87615, /python/branches/py3k/Tools/scripts/abitype.py
   python/branches/py3k-cdecimal/Tools/scripts/find-uname.py
      - copied unchanged from r87615, /python/branches/py3k/Tools/scripts/find-uname.py
   python/branches/py3k-cdecimal/Tools/scripts/get-remote-certificate.py
      - copied unchanged from r87615, /python/branches/py3k/Tools/scripts/get-remote-certificate.py
   python/branches/py3k-cdecimal/Tools/test2to3/   (props changed)
      - copied from r87615, /python/branches/py3k/Tools/test2to3/
Removed:
   python/branches/py3k-cdecimal/Demo/
   python/branches/py3k-cdecimal/Lib/json/tests/
   python/branches/py3k-cdecimal/Lib/test/symlink_support.py
   python/branches/py3k-cdecimal/Misc/RFD
   python/branches/py3k-cdecimal/Misc/pymemcompat.h
   python/branches/py3k-cdecimal/Misc/setuid-prog.c
   python/branches/py3k-cdecimal/Tools/framer/
   python/branches/py3k-cdecimal/Tools/scripts/redemo.py
   python/branches/py3k-cdecimal/Tools/ssl/
   python/branches/py3k-cdecimal/Tools/world/
   python/branches/py3k-cdecimal/runtests.sh
Modified:
   python/branches/py3k-cdecimal/   (props changed)
   python/branches/py3k-cdecimal/.gitignore
   python/branches/py3k-cdecimal/Doc/ACKS.txt
   python/branches/py3k-cdecimal/Doc/README.txt
   python/branches/py3k-cdecimal/Doc/c-api/buffer.rst
   python/branches/py3k-cdecimal/Doc/c-api/codec.rst
   python/branches/py3k-cdecimal/Doc/c-api/exceptions.rst
   python/branches/py3k-cdecimal/Doc/c-api/import.rst
   python/branches/py3k-cdecimal/Doc/c-api/init.rst
   python/branches/py3k-cdecimal/Doc/c-api/intro.rst
   python/branches/py3k-cdecimal/Doc/c-api/list.rst
   python/branches/py3k-cdecimal/Doc/c-api/slice.rst
   python/branches/py3k-cdecimal/Doc/c-api/typeobj.rst
   python/branches/py3k-cdecimal/Doc/c-api/unicode.rst
   python/branches/py3k-cdecimal/Doc/c-api/veryhigh.rst
   python/branches/py3k-cdecimal/Doc/copyright.rst
   python/branches/py3k-cdecimal/Doc/distutils/apiref.rst
   python/branches/py3k-cdecimal/Doc/documenting/markup.rst
   python/branches/py3k-cdecimal/Doc/extending/embedding.rst
   python/branches/py3k-cdecimal/Doc/extending/extending.rst
   python/branches/py3k-cdecimal/Doc/extending/windows.rst
   python/branches/py3k-cdecimal/Doc/faq/extending.rst
   python/branches/py3k-cdecimal/Doc/glossary.rst
   python/branches/py3k-cdecimal/Doc/howto/index.rst
   python/branches/py3k-cdecimal/Doc/includes/tzinfo-examples.py
   python/branches/py3k-cdecimal/Doc/install/index.rst
   python/branches/py3k-cdecimal/Doc/library/_thread.rst
   python/branches/py3k-cdecimal/Doc/library/allos.rst
   python/branches/py3k-cdecimal/Doc/library/argparse.rst
   python/branches/py3k-cdecimal/Doc/library/array.rst
   python/branches/py3k-cdecimal/Doc/library/bdb.rst
   python/branches/py3k-cdecimal/Doc/library/builtins.rst
   python/branches/py3k-cdecimal/Doc/library/codecs.rst
   python/branches/py3k-cdecimal/Doc/library/collections.rst
   python/branches/py3k-cdecimal/Doc/library/compileall.rst
   python/branches/py3k-cdecimal/Doc/library/concurrent.futures.rst
   python/branches/py3k-cdecimal/Doc/library/configparser.rst
   python/branches/py3k-cdecimal/Doc/library/ctypes.rst
   python/branches/py3k-cdecimal/Doc/library/curses.rst
   python/branches/py3k-cdecimal/Doc/library/dbm.rst
   python/branches/py3k-cdecimal/Doc/library/difflib.rst
   python/branches/py3k-cdecimal/Doc/library/dis.rst
   python/branches/py3k-cdecimal/Doc/library/doctest.rst
   python/branches/py3k-cdecimal/Doc/library/email.header.rst
   python/branches/py3k-cdecimal/Doc/library/email.message.rst
   python/branches/py3k-cdecimal/Doc/library/email.util.rst
   python/branches/py3k-cdecimal/Doc/library/exceptions.rst
   python/branches/py3k-cdecimal/Doc/library/fileformats.rst
   python/branches/py3k-cdecimal/Doc/library/functions.rst
   python/branches/py3k-cdecimal/Doc/library/functools.rst
   python/branches/py3k-cdecimal/Doc/library/grp.rst
   python/branches/py3k-cdecimal/Doc/library/hashlib.rst
   python/branches/py3k-cdecimal/Doc/library/heapq.rst
   python/branches/py3k-cdecimal/Doc/library/html.parser.rst
   python/branches/py3k-cdecimal/Doc/library/http.client.rst
   python/branches/py3k-cdecimal/Doc/library/imp.rst
   python/branches/py3k-cdecimal/Doc/library/inspect.rst
   python/branches/py3k-cdecimal/Doc/library/io.rst
   python/branches/py3k-cdecimal/Doc/library/itertools.rst
   python/branches/py3k-cdecimal/Doc/library/logging.rst
   python/branches/py3k-cdecimal/Doc/library/msilib.rst
   python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst
   python/branches/py3k-cdecimal/Doc/library/os.path.rst
   python/branches/py3k-cdecimal/Doc/library/os.rst
   python/branches/py3k-cdecimal/Doc/library/parser.rst
   python/branches/py3k-cdecimal/Doc/library/pdb.rst
   python/branches/py3k-cdecimal/Doc/library/pickle.rst
   python/branches/py3k-cdecimal/Doc/library/pkgutil.rst
   python/branches/py3k-cdecimal/Doc/library/platform.rst
   python/branches/py3k-cdecimal/Doc/library/pty.rst
   python/branches/py3k-cdecimal/Doc/library/py_compile.rst
   python/branches/py3k-cdecimal/Doc/library/pydoc.rst
   python/branches/py3k-cdecimal/Doc/library/random.rst
   python/branches/py3k-cdecimal/Doc/library/re.rst
   python/branches/py3k-cdecimal/Doc/library/runpy.rst
   python/branches/py3k-cdecimal/Doc/library/shelve.rst
   python/branches/py3k-cdecimal/Doc/library/socket.rst
   python/branches/py3k-cdecimal/Doc/library/someos.rst
   python/branches/py3k-cdecimal/Doc/library/sqlite3.rst
   python/branches/py3k-cdecimal/Doc/library/stdtypes.rst
   python/branches/py3k-cdecimal/Doc/library/string.rst
   python/branches/py3k-cdecimal/Doc/library/struct.rst
   python/branches/py3k-cdecimal/Doc/library/subprocess.rst
   python/branches/py3k-cdecimal/Doc/library/sys.rst
   python/branches/py3k-cdecimal/Doc/library/test.rst
   python/branches/py3k-cdecimal/Doc/library/textwrap.rst
   python/branches/py3k-cdecimal/Doc/library/threading.rst
   python/branches/py3k-cdecimal/Doc/library/tkinter.rst
   python/branches/py3k-cdecimal/Doc/library/tkinter.tix.rst
   python/branches/py3k-cdecimal/Doc/library/trace.rst
   python/branches/py3k-cdecimal/Doc/library/turtle.rst
   python/branches/py3k-cdecimal/Doc/library/unicodedata.rst
   python/branches/py3k-cdecimal/Doc/library/unittest.rst
   python/branches/py3k-cdecimal/Doc/library/urllib.parse.rst
   python/branches/py3k-cdecimal/Doc/library/urllib.request.rst
   python/branches/py3k-cdecimal/Doc/library/warnings.rst
   python/branches/py3k-cdecimal/Doc/library/xml.dom.minidom.rst
   python/branches/py3k-cdecimal/Doc/library/zipfile.rst
   python/branches/py3k-cdecimal/Doc/license.rst
   python/branches/py3k-cdecimal/Doc/reference/datamodel.rst
   python/branches/py3k-cdecimal/Doc/reference/expressions.rst
   python/branches/py3k-cdecimal/Doc/reference/lexical_analysis.rst
   python/branches/py3k-cdecimal/Doc/tools/sphinxext/static/basic.css
   python/branches/py3k-cdecimal/Doc/tools/sphinxext/susp-ignored.csv
   python/branches/py3k-cdecimal/Doc/tutorial/interpreter.rst
   python/branches/py3k-cdecimal/Doc/tutorial/stdlib.rst
   python/branches/py3k-cdecimal/Doc/using/cmdline.rst
   python/branches/py3k-cdecimal/Doc/whatsnew/2.7.rst
   python/branches/py3k-cdecimal/Doc/whatsnew/3.2.rst
   python/branches/py3k-cdecimal/Include/Python.h
   python/branches/py3k-cdecimal/Include/abstract.h
   python/branches/py3k-cdecimal/Include/ast.h
   python/branches/py3k-cdecimal/Include/bytearrayobject.h
   python/branches/py3k-cdecimal/Include/bytes_methods.h
   python/branches/py3k-cdecimal/Include/bytesobject.h
   python/branches/py3k-cdecimal/Include/cellobject.h
   python/branches/py3k-cdecimal/Include/ceval.h
   python/branches/py3k-cdecimal/Include/classobject.h
   python/branches/py3k-cdecimal/Include/code.h
   python/branches/py3k-cdecimal/Include/codecs.h
   python/branches/py3k-cdecimal/Include/compile.h
   python/branches/py3k-cdecimal/Include/complexobject.h
   python/branches/py3k-cdecimal/Include/datetime.h
   python/branches/py3k-cdecimal/Include/descrobject.h
   python/branches/py3k-cdecimal/Include/dictobject.h
   python/branches/py3k-cdecimal/Include/dtoa.h
   python/branches/py3k-cdecimal/Include/eval.h
   python/branches/py3k-cdecimal/Include/fileobject.h
   python/branches/py3k-cdecimal/Include/floatobject.h
   python/branches/py3k-cdecimal/Include/frameobject.h
   python/branches/py3k-cdecimal/Include/funcobject.h
   python/branches/py3k-cdecimal/Include/genobject.h
   python/branches/py3k-cdecimal/Include/import.h
   python/branches/py3k-cdecimal/Include/listobject.h
   python/branches/py3k-cdecimal/Include/longintrepr.h
   python/branches/py3k-cdecimal/Include/longobject.h
   python/branches/py3k-cdecimal/Include/marshal.h
   python/branches/py3k-cdecimal/Include/memoryobject.h
   python/branches/py3k-cdecimal/Include/methodobject.h
   python/branches/py3k-cdecimal/Include/modsupport.h
   python/branches/py3k-cdecimal/Include/moduleobject.h
   python/branches/py3k-cdecimal/Include/object.h
   python/branches/py3k-cdecimal/Include/objimpl.h
   python/branches/py3k-cdecimal/Include/parsetok.h
   python/branches/py3k-cdecimal/Include/patchlevel.h
   python/branches/py3k-cdecimal/Include/pyarena.h
   python/branches/py3k-cdecimal/Include/pyatomic.h
   python/branches/py3k-cdecimal/Include/pyctype.h
   python/branches/py3k-cdecimal/Include/pydebug.h
   python/branches/py3k-cdecimal/Include/pyerrors.h
   python/branches/py3k-cdecimal/Include/pygetopt.h
   python/branches/py3k-cdecimal/Include/pymath.h
   python/branches/py3k-cdecimal/Include/pystate.h
   python/branches/py3k-cdecimal/Include/pystrtod.h
   python/branches/py3k-cdecimal/Include/pythonrun.h
   python/branches/py3k-cdecimal/Include/pythread.h
   python/branches/py3k-cdecimal/Include/pytime.h
   python/branches/py3k-cdecimal/Include/setobject.h
   python/branches/py3k-cdecimal/Include/sliceobject.h
   python/branches/py3k-cdecimal/Include/structseq.h
   python/branches/py3k-cdecimal/Include/symtable.h
   python/branches/py3k-cdecimal/Include/sysmodule.h
   python/branches/py3k-cdecimal/Include/timefuncs.h
   python/branches/py3k-cdecimal/Include/token.h
   python/branches/py3k-cdecimal/Include/traceback.h
   python/branches/py3k-cdecimal/Include/tupleobject.h
   python/branches/py3k-cdecimal/Include/ucnhash.h
   python/branches/py3k-cdecimal/Include/unicodeobject.h
   python/branches/py3k-cdecimal/Include/warnings.h
   python/branches/py3k-cdecimal/Include/weakrefobject.h
   python/branches/py3k-cdecimal/LICENSE
   python/branches/py3k-cdecimal/Lib/_abcoll.py
   python/branches/py3k-cdecimal/Lib/_pyio.py
   python/branches/py3k-cdecimal/Lib/_weakrefset.py
   python/branches/py3k-cdecimal/Lib/argparse.py
   python/branches/py3k-cdecimal/Lib/bdb.py
   python/branches/py3k-cdecimal/Lib/codecs.py
   python/branches/py3k-cdecimal/Lib/collections.py
   python/branches/py3k-cdecimal/Lib/compileall.py
   python/branches/py3k-cdecimal/Lib/concurrent/futures/_base.py
   python/branches/py3k-cdecimal/Lib/concurrent/futures/process.py
   python/branches/py3k-cdecimal/Lib/configparser.py
   python/branches/py3k-cdecimal/Lib/dbm/dumb.py
   python/branches/py3k-cdecimal/Lib/decimal.py
   python/branches/py3k-cdecimal/Lib/difflib.py
   python/branches/py3k-cdecimal/Lib/distutils/__init__.py
   python/branches/py3k-cdecimal/Lib/distutils/archive_util.py
   python/branches/py3k-cdecimal/Lib/distutils/command/build_ext.py
   python/branches/py3k-cdecimal/Lib/distutils/command/install.py
   python/branches/py3k-cdecimal/Lib/distutils/sysconfig.py
   python/branches/py3k-cdecimal/Lib/doctest.py
   python/branches/py3k-cdecimal/Lib/email/_parseaddr.py
   python/branches/py3k-cdecimal/Lib/email/generator.py
   python/branches/py3k-cdecimal/Lib/email/header.py
   python/branches/py3k-cdecimal/Lib/email/message.py
   python/branches/py3k-cdecimal/Lib/email/test/test_email.py
   python/branches/py3k-cdecimal/Lib/email/utils.py
   python/branches/py3k-cdecimal/Lib/encodings/aliases.py
   python/branches/py3k-cdecimal/Lib/functools.py
   python/branches/py3k-cdecimal/Lib/getpass.py
   python/branches/py3k-cdecimal/Lib/gettext.py
   python/branches/py3k-cdecimal/Lib/html/parser.py
   python/branches/py3k-cdecimal/Lib/http/client.py
   python/branches/py3k-cdecimal/Lib/http/cookies.py
   python/branches/py3k-cdecimal/Lib/http/server.py
   python/branches/py3k-cdecimal/Lib/idlelib/Bindings.py
   python/branches/py3k-cdecimal/Lib/idlelib/EditorWindow.py
   python/branches/py3k-cdecimal/Lib/idlelib/FileList.py
   python/branches/py3k-cdecimal/Lib/idlelib/IOBinding.py
   python/branches/py3k-cdecimal/Lib/idlelib/idlever.py
   python/branches/py3k-cdecimal/Lib/idlelib/macosxSupport.py
   python/branches/py3k-cdecimal/Lib/inspect.py
   python/branches/py3k-cdecimal/Lib/lib2to3/   (props changed)
   python/branches/py3k-cdecimal/Lib/lib2to3/fixes/fix_urllib.py
   python/branches/py3k-cdecimal/Lib/lib2to3/main.py
   python/branches/py3k-cdecimal/Lib/lib2to3/refactor.py
   python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_refactor.py
   python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_util.py
   python/branches/py3k-cdecimal/Lib/logging/__init__.py
   python/branches/py3k-cdecimal/Lib/mimetypes.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/__init__.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/connection.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/dummy/__init__.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/dummy/connection.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/forking.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/heap.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/managers.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/pool.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/process.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/queues.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/reduction.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/sharedctypes.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/synchronize.py
   python/branches/py3k-cdecimal/Lib/multiprocessing/util.py
   python/branches/py3k-cdecimal/Lib/netrc.py
   python/branches/py3k-cdecimal/Lib/numbers.py
   python/branches/py3k-cdecimal/Lib/os.py
   python/branches/py3k-cdecimal/Lib/pdb.py
   python/branches/py3k-cdecimal/Lib/py_compile.py
   python/branches/py3k-cdecimal/Lib/pydoc.py
   python/branches/py3k-cdecimal/Lib/pydoc_data/topics.py
   python/branches/py3k-cdecimal/Lib/random.py
   python/branches/py3k-cdecimal/Lib/shelve.py
   python/branches/py3k-cdecimal/Lib/shutil.py
   python/branches/py3k-cdecimal/Lib/site.py
   python/branches/py3k-cdecimal/Lib/smtpd.py
   python/branches/py3k-cdecimal/Lib/subprocess.py
   python/branches/py3k-cdecimal/Lib/sysconfig.py
   python/branches/py3k-cdecimal/Lib/tabnanny.py
   python/branches/py3k-cdecimal/Lib/telnetlib.py
   python/branches/py3k-cdecimal/Lib/tempfile.py
   python/branches/py3k-cdecimal/Lib/test/crashers/README
   python/branches/py3k-cdecimal/Lib/test/datetimetester.py
   python/branches/py3k-cdecimal/Lib/test/pystone.py
   python/branches/py3k-cdecimal/Lib/test/regrtest.py
   python/branches/py3k-cdecimal/Lib/test/script_helper.py
   python/branches/py3k-cdecimal/Lib/test/support.py
   python/branches/py3k-cdecimal/Lib/test/test_abc.py
   python/branches/py3k-cdecimal/Lib/test/test_argparse.py
   python/branches/py3k-cdecimal/Lib/test/test_array.py
   python/branches/py3k-cdecimal/Lib/test/test_asyncore.py
   python/branches/py3k-cdecimal/Lib/test/test_bool.py
   python/branches/py3k-cdecimal/Lib/test/test_builtin.py
   python/branches/py3k-cdecimal/Lib/test/test_calendar.py
   python/branches/py3k-cdecimal/Lib/test/test_cfgparser.py
   python/branches/py3k-cdecimal/Lib/test/test_cgi.py
   python/branches/py3k-cdecimal/Lib/test/test_cmath.py
   python/branches/py3k-cdecimal/Lib/test/test_cmd_line.py
   python/branches/py3k-cdecimal/Lib/test/test_codecs.py
   python/branches/py3k-cdecimal/Lib/test/test_collections.py
   python/branches/py3k-cdecimal/Lib/test/test_compileall.py
   python/branches/py3k-cdecimal/Lib/test/test_complex.py
   python/branches/py3k-cdecimal/Lib/test/test_concurrent_futures.py
   python/branches/py3k-cdecimal/Lib/test/test_contextlib.py
   python/branches/py3k-cdecimal/Lib/test/test_csv.py
   python/branches/py3k-cdecimal/Lib/test/test_dbm_gnu.py
   python/branches/py3k-cdecimal/Lib/test/test_decimal.py
   python/branches/py3k-cdecimal/Lib/test/test_descr.py
   python/branches/py3k-cdecimal/Lib/test/test_difflib.py
   python/branches/py3k-cdecimal/Lib/test/test_dis.py
   python/branches/py3k-cdecimal/Lib/test/test_float.py
   python/branches/py3k-cdecimal/Lib/test/test_fork1.py
   python/branches/py3k-cdecimal/Lib/test/test_fractions.py
   python/branches/py3k-cdecimal/Lib/test/test_functools.py
   python/branches/py3k-cdecimal/Lib/test/test_grp.py
   python/branches/py3k-cdecimal/Lib/test/test_htmlparser.py
   python/branches/py3k-cdecimal/Lib/test/test_http_cookies.py
   python/branches/py3k-cdecimal/Lib/test/test_httplib.py
   python/branches/py3k-cdecimal/Lib/test/test_httpservers.py
   python/branches/py3k-cdecimal/Lib/test/test_import.py
   python/branches/py3k-cdecimal/Lib/test/test_inspect.py
   python/branches/py3k-cdecimal/Lib/test/test_int.py
   python/branches/py3k-cdecimal/Lib/test/test_io.py
   python/branches/py3k-cdecimal/Lib/test/test_itertools.py
   python/branches/py3k-cdecimal/Lib/test/test_json.py
   python/branches/py3k-cdecimal/Lib/test/test_listcomps.py
   python/branches/py3k-cdecimal/Lib/test/test_logging.py
   python/branches/py3k-cdecimal/Lib/test/test_long.py
   python/branches/py3k-cdecimal/Lib/test/test_math.py
   python/branches/py3k-cdecimal/Lib/test/test_memoryview.py
   python/branches/py3k-cdecimal/Lib/test/test_multiprocessing.py
   python/branches/py3k-cdecimal/Lib/test/test_netrc.py
   python/branches/py3k-cdecimal/Lib/test/test_normalization.py
   python/branches/py3k-cdecimal/Lib/test/test_ntpath.py
   python/branches/py3k-cdecimal/Lib/test/test_os.py
   python/branches/py3k-cdecimal/Lib/test/test_pdb.py
   python/branches/py3k-cdecimal/Lib/test/test_posixpath.py
   python/branches/py3k-cdecimal/Lib/test/test_pydoc.py
   python/branches/py3k-cdecimal/Lib/test/test_pyexpat.py
   python/branches/py3k-cdecimal/Lib/test/test_random.py
   python/branches/py3k-cdecimal/Lib/test/test_range.py
   python/branches/py3k-cdecimal/Lib/test/test_runpy.py
   python/branches/py3k-cdecimal/Lib/test/test_shelve.py
   python/branches/py3k-cdecimal/Lib/test/test_shutil.py
   python/branches/py3k-cdecimal/Lib/test/test_site.py
   python/branches/py3k-cdecimal/Lib/test/test_smtpd.py
   python/branches/py3k-cdecimal/Lib/test/test_smtplib.py
   python/branches/py3k-cdecimal/Lib/test/test_socket.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_subprocess.py
   python/branches/py3k-cdecimal/Lib/test/test_sys.py
   python/branches/py3k-cdecimal/Lib/test/test_syslog.py
   python/branches/py3k-cdecimal/Lib/test/test_telnetlib.py
   python/branches/py3k-cdecimal/Lib/test/test_tempfile.py
   python/branches/py3k-cdecimal/Lib/test/test_threadsignals.py
   python/branches/py3k-cdecimal/Lib/test/test_time.py
   python/branches/py3k-cdecimal/Lib/test/test_trace.py
   python/branches/py3k-cdecimal/Lib/test/test_tuple.py
   python/branches/py3k-cdecimal/Lib/test/test_types.py
   python/branches/py3k-cdecimal/Lib/test/test_unicode.py
   python/branches/py3k-cdecimal/Lib/test/test_unicodedata.py
   python/branches/py3k-cdecimal/Lib/test/test_unittest.py
   python/branches/py3k-cdecimal/Lib/test/test_urllib.py
   python/branches/py3k-cdecimal/Lib/test/test_urllib2.py
   python/branches/py3k-cdecimal/Lib/test/test_urllibnet.py
   python/branches/py3k-cdecimal/Lib/test/test_urlparse.py
   python/branches/py3k-cdecimal/Lib/test/test_weakset.py
   python/branches/py3k-cdecimal/Lib/test/test_winsound.py
   python/branches/py3k-cdecimal/Lib/test/test_wsgiref.py
   python/branches/py3k-cdecimal/Lib/test/test_xml_etree.py
   python/branches/py3k-cdecimal/Lib/test/test_xml_etree_c.py
   python/branches/py3k-cdecimal/Lib/test/test_xmlrpc.py
   python/branches/py3k-cdecimal/Lib/test/test_zipfile.py
   python/branches/py3k-cdecimal/Lib/test/test_zipimport_support.py
   python/branches/py3k-cdecimal/Lib/test/test_zlib.py
   python/branches/py3k-cdecimal/Lib/test/win_console_handler.py
   python/branches/py3k-cdecimal/Lib/threading.py
   python/branches/py3k-cdecimal/Lib/tkinter/__init__.py
   python/branches/py3k-cdecimal/Lib/tkinter/scrolledtext.py
   python/branches/py3k-cdecimal/Lib/tkinter/test/test_ttk/test_widgets.py
   python/branches/py3k-cdecimal/Lib/tkinter/tix.py
   python/branches/py3k-cdecimal/Lib/turtle.py
   python/branches/py3k-cdecimal/Lib/turtledemo/about_turtledemo.txt
   python/branches/py3k-cdecimal/Lib/turtledemo/demohelp.txt
   python/branches/py3k-cdecimal/Lib/unittest/case.py
   python/branches/py3k-cdecimal/Lib/unittest/main.py
   python/branches/py3k-cdecimal/Lib/unittest/runner.py
   python/branches/py3k-cdecimal/Lib/unittest/suite.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_assertions.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_break.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_case.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_discovery.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_functiontestcase.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_loader.py
   python/branches/py3k-cdecimal/Lib/unittest/test/test_program.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/unittest/test/test_suite.py
   python/branches/py3k-cdecimal/Lib/unittest/util.py
   python/branches/py3k-cdecimal/Lib/urllib/parse.py
   python/branches/py3k-cdecimal/Lib/urllib/request.py
   python/branches/py3k-cdecimal/Lib/wave.py
   python/branches/py3k-cdecimal/Lib/weakref.py
   python/branches/py3k-cdecimal/Lib/webbrowser.py
   python/branches/py3k-cdecimal/Lib/wsgiref/util.py
   python/branches/py3k-cdecimal/Lib/xml/etree/ElementTree.py
   python/branches/py3k-cdecimal/Lib/xmlrpc/client.py
   python/branches/py3k-cdecimal/Lib/zipfile.py
   python/branches/py3k-cdecimal/Mac/BuildScript/build-installer.py
   python/branches/py3k-cdecimal/Mac/Makefile.in
   python/branches/py3k-cdecimal/Mac/README
   python/branches/py3k-cdecimal/Makefile.pre.in
   python/branches/py3k-cdecimal/Misc/ACKS
   python/branches/py3k-cdecimal/Misc/NEWS
   python/branches/py3k-cdecimal/Misc/README
   python/branches/py3k-cdecimal/Misc/RPM/python-3.2.spec
   python/branches/py3k-cdecimal/Misc/SpecialBuilds.txt
   python/branches/py3k-cdecimal/Misc/python-wing4.wpr
   python/branches/py3k-cdecimal/Misc/python.man
   python/branches/py3k-cdecimal/Misc/python.pc.in
   python/branches/py3k-cdecimal/Modules/_collectionsmodule.c
   python/branches/py3k-cdecimal/Modules/_ctypes/_ctypes.c
   python/branches/py3k-cdecimal/Modules/_ctypes/cfield.c
   python/branches/py3k-cdecimal/Modules/_datetimemodule.c
   python/branches/py3k-cdecimal/Modules/_elementtree.c
   python/branches/py3k-cdecimal/Modules/_functoolsmodule.c
   python/branches/py3k-cdecimal/Modules/_gdbmmodule.c
   python/branches/py3k-cdecimal/Modules/_io/bufferedio.c
   python/branches/py3k-cdecimal/Modules/_lsprof.c
   python/branches/py3k-cdecimal/Modules/_posixsubprocess.c
   python/branches/py3k-cdecimal/Modules/_ssl.c
   python/branches/py3k-cdecimal/Modules/_struct.c
   python/branches/py3k-cdecimal/Modules/_testcapimodule.c
   python/branches/py3k-cdecimal/Modules/_threadmodule.c
   python/branches/py3k-cdecimal/Modules/arraymodule.c
   python/branches/py3k-cdecimal/Modules/getpath.c
   python/branches/py3k-cdecimal/Modules/grpmodule.c
   python/branches/py3k-cdecimal/Modules/itertoolsmodule.c
   python/branches/py3k-cdecimal/Modules/main.c
   python/branches/py3k-cdecimal/Modules/mmapmodule.c
   python/branches/py3k-cdecimal/Modules/parsermodule.c
   python/branches/py3k-cdecimal/Modules/posixmodule.c
   python/branches/py3k-cdecimal/Modules/pwdmodule.c
   python/branches/py3k-cdecimal/Modules/pyexpat.c
   python/branches/py3k-cdecimal/Modules/readline.c
   python/branches/py3k-cdecimal/Modules/resource.c
   python/branches/py3k-cdecimal/Modules/signalmodule.c
   python/branches/py3k-cdecimal/Modules/socketmodule.c
   python/branches/py3k-cdecimal/Modules/socketmodule.h
   python/branches/py3k-cdecimal/Modules/spwdmodule.c
   python/branches/py3k-cdecimal/Modules/symtablemodule.c
   python/branches/py3k-cdecimal/Modules/syslogmodule.c
   python/branches/py3k-cdecimal/Modules/timemodule.c
   python/branches/py3k-cdecimal/Modules/unicodedata.c
   python/branches/py3k-cdecimal/Objects/bytearrayobject.c
   python/branches/py3k-cdecimal/Objects/bytesobject.c
   python/branches/py3k-cdecimal/Objects/complexobject.c
   python/branches/py3k-cdecimal/Objects/descrobject.c
   python/branches/py3k-cdecimal/Objects/floatobject.c
   python/branches/py3k-cdecimal/Objects/funcobject.c
   python/branches/py3k-cdecimal/Objects/genobject.c
   python/branches/py3k-cdecimal/Objects/listobject.c
   python/branches/py3k-cdecimal/Objects/longobject.c
   python/branches/py3k-cdecimal/Objects/memoryobject.c
   python/branches/py3k-cdecimal/Objects/moduleobject.c
   python/branches/py3k-cdecimal/Objects/object.c
   python/branches/py3k-cdecimal/Objects/obmalloc.c
   python/branches/py3k-cdecimal/Objects/rangeobject.c
   python/branches/py3k-cdecimal/Objects/setobject.c
   python/branches/py3k-cdecimal/Objects/sliceobject.c
   python/branches/py3k-cdecimal/Objects/stringlib/formatter.h
   python/branches/py3k-cdecimal/Objects/structseq.c
   python/branches/py3k-cdecimal/Objects/tupleobject.c
   python/branches/py3k-cdecimal/Objects/typeobject.c
   python/branches/py3k-cdecimal/Objects/unicodectype.c
   python/branches/py3k-cdecimal/Objects/unicodeobject.c
   python/branches/py3k-cdecimal/PC/VC6/readme.txt
   python/branches/py3k-cdecimal/PC/getpathp.c
   python/branches/py3k-cdecimal/PC/pyconfig.h
   python/branches/py3k-cdecimal/PC/python_nt.rc
   python/branches/py3k-cdecimal/PCbuild/build_tkinter.py
   python/branches/py3k-cdecimal/PCbuild/make_buildinfo.c
   python/branches/py3k-cdecimal/PCbuild/pcbuild.sln
   python/branches/py3k-cdecimal/PCbuild/pyproject.vsprops
   python/branches/py3k-cdecimal/PCbuild/pythoncore.vcproj
   python/branches/py3k-cdecimal/PCbuild/readme.txt
   python/branches/py3k-cdecimal/Parser/pgenmain.c
   python/branches/py3k-cdecimal/Parser/printgrammar.c
   python/branches/py3k-cdecimal/Parser/tokenizer.c
   python/branches/py3k-cdecimal/Python/_warnings.c
   python/branches/py3k-cdecimal/Python/ast.c
   python/branches/py3k-cdecimal/Python/bltinmodule.c
   python/branches/py3k-cdecimal/Python/ceval.c
   python/branches/py3k-cdecimal/Python/compile.c
   python/branches/py3k-cdecimal/Python/dynload_shlib.c
   python/branches/py3k-cdecimal/Python/dynload_win.c
   python/branches/py3k-cdecimal/Python/errors.c
   python/branches/py3k-cdecimal/Python/future.c
   python/branches/py3k-cdecimal/Python/getcopyright.c
   python/branches/py3k-cdecimal/Python/import.c
   python/branches/py3k-cdecimal/Python/peephole.c
   python/branches/py3k-cdecimal/Python/pyarena.c
   python/branches/py3k-cdecimal/Python/pythonrun.c
   python/branches/py3k-cdecimal/Python/sysmodule.c
   python/branches/py3k-cdecimal/Python/thread_nt.h
   python/branches/py3k-cdecimal/Python/thread_pthread.h
   python/branches/py3k-cdecimal/Python/traceback.c
   python/branches/py3k-cdecimal/README
   python/branches/py3k-cdecimal/Tools/README
   python/branches/py3k-cdecimal/Tools/buildbot/external-amd64.bat
   python/branches/py3k-cdecimal/Tools/buildbot/external-common.bat
   python/branches/py3k-cdecimal/Tools/buildbot/external.bat
   python/branches/py3k-cdecimal/Tools/buildbot/test.bat
   python/branches/py3k-cdecimal/Tools/msi/msi.py
   python/branches/py3k-cdecimal/Tools/scripts/README
   python/branches/py3k-cdecimal/Tools/scripts/untabify.py
   python/branches/py3k-cdecimal/Tools/unicode/gencodec.py
   python/branches/py3k-cdecimal/configure
   python/branches/py3k-cdecimal/configure.in
   python/branches/py3k-cdecimal/pyconfig.h.in
   python/branches/py3k-cdecimal/setup.py

Modified: python/branches/py3k-cdecimal/.gitignore
==============================================================================
--- python/branches/py3k-cdecimal/.gitignore	(original)
+++ python/branches/py3k-cdecimal/.gitignore	Sun Jan  2 13:18:37 2011
@@ -1,8 +1,17 @@
+*.cover
+*.o
+*.orig
+*.pyc
+*.pyd
+*.pyo
+*.rej
+*~
 Doc/build/
 Doc/tools/docutils/
 Doc/tools/jinja2/
 Doc/tools/pygments/
 Doc/tools/sphinx/
+Lib/lib2to3/*.pickle
 Makefile
 Makefile.pre
 Misc/python.pc
@@ -10,17 +19,26 @@
 Modules/Setup.config
 Modules/Setup.local
 Modules/config.c
+Modules/ld_so_aix
+PCbuild/*.bsc
+PCbuild/*.dll
+PCbuild/*.exe
+PCbuild/*.exp
+PCbuild/*.lib
+PCbuild/*.ncb
+PCbuild/*.o
+PCbuild/*.pdb
+PCbuild/Win32-temp-*
 Parser/pgen
 Parser/pgen.stamp
+__pycache__
+autom4te.cache
 build/
 config.log
 config.status
-libpython3.2.a
+libpython*.a
 pybuilddir.txt
 pyconfig.h
 python
 python-gdb.py
 tags
-Lib/lib2to3/Grammar3.2.0.alpha.2.pickle
-Lib/lib2to3/PatternGrammar3.2.0.alpha.2.pickle
-autom4te.cache

Modified: python/branches/py3k-cdecimal/Doc/ACKS.txt
==============================================================================
--- python/branches/py3k-cdecimal/Doc/ACKS.txt	(original)
+++ python/branches/py3k-cdecimal/Doc/ACKS.txt	Sun Jan  2 13:18:37 2011
@@ -111,6 +111,7 @@
    * Andrew M. Kuchling
    * Dave Kuhlman
    * Erno Kuusela
+   * Ross Lagerwall
    * Thomas Lamb
    * Detlef Lannert
    * Piers Lauder

Modified: python/branches/py3k-cdecimal/Doc/README.txt
==============================================================================
--- python/branches/py3k-cdecimal/Doc/README.txt	(original)
+++ python/branches/py3k-cdecimal/Doc/README.txt	Sun Jan  2 13:18:37 2011
@@ -132,7 +132,7 @@
 as long as you don't change or remove the copyright notice:
 
 ----------------------------------------------------------------------
-Copyright (c) 2000-2010 Python Software Foundation.
+Copyright (c) 2000-2011 Python Software Foundation.
 All rights reserved.
 
 Copyright (c) 2000 BeOpen.com.

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	Sun Jan  2 13:18:37 2011
@@ -12,16 +12,32 @@
 .. index::
    single: buffer interface
 
-Python objects implemented in C can export a "buffer interface."  These
-functions can be used by an object to expose its data in a raw, byte-oriented
-format. Clients of the object can use the buffer interface to access the
-object data directly, without needing to copy it first.
-
-Examples of objects that support the buffer interface are :class:`bytes`,
-:class:`bytearray` and :class:`array.array`. The bytes and bytearray objects
-exposes their bytes contents in the buffer interface's byte-oriented form.
-An :class:`array.array` can also expose its contents, but it should be noted
-that array elements may be multi-byte values.
+Certain objects available in Python wrap access to an underlying memory
+array or *buffer*.  Such objects include the built-in :class:`bytes` and
+:class:`bytearray`, and some extension types like :class:`array.array`.
+Third-party libraries may define their own types for special purposes, such
+as image processing or numeric analysis.
+
+While each of these types have their own semantics, they share the common
+characteristic of being backed by a possibly large memory buffer.  It is
+then desireable, in some situations, to access that buffer directly and
+without intermediate copying.
+
+Python provides such a facility at the C level in the form of the *buffer
+protocol*.  This protocol has two sides:
+
+.. index:: single: PyBufferProcs
+
+- on the producer side, a type can export a "buffer interface" which allows
+  objects of that type to expose information about their underlying buffer.
+  This interface is described in the section :ref:`buffer-structs`;
+
+- on the consumer side, several means are available to obtain a pointer to
+  the raw underlying data of an object (for example a method parameter).
+
+Simple objects such as :class:`bytes` and :class:`bytearray` expose their
+underlying buffer in byte-oriented form.  Other forms are possible; for example,
+the elements exposed by a :class:`array.array` can be multi-byte values.
 
 An example consumer of the buffer interface is the :meth:`~io.BufferedIOBase.write`
 method of file objects: any object that can export a series of bytes through
@@ -44,12 +60,6 @@
 resource leaks.
 
 
-.. index:: single: PyBufferProcs
-
-How the buffer interface is exposed by a type object is described in the
-section :ref:`buffer-structs`, under the description for :c:type:`PyBufferProcs`.
-
-
 The buffer structure
 ====================
 

Modified: python/branches/py3k-cdecimal/Doc/c-api/codec.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/codec.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/codec.rst	Sun Jan  2 13:18:37 2011
@@ -80,15 +80,13 @@
    The callback gets a single argument, an instance of
    :exc:`UnicodeEncodeError`, :exc:`UnicodeDecodeError` or
    :exc:`UnicodeTranslateError` that holds information about the problematic
-   sequence of characters or bytes and their offset in the original string.  The
+   sequence of characters or bytes and their offset in the original string (see
+   :ref:`unicodeexceptions` for functions to extract this information).  The
    callback must either raise the given exception, or return a two-item tuple
    containing the replacement for the problematic sequence, and an integer
    giving the offset in the original string at which encoding/decoding should be
    resumed.
 
-   .. XXX once they are documented, link to PyUnicode*Error access functions
-      to show how to get at the exception properties
-
    Return ``0`` on success, ``-1`` on error.
 
 .. c:function:: PyObject* PyCodec_LookupError(const char *name)

Modified: python/branches/py3k-cdecimal/Doc/c-api/exceptions.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/exceptions.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/exceptions.rst	Sun Jan  2 13:18:37 2011
@@ -145,79 +145,11 @@
 
 .. c:function:: PyObject* PyErr_Format(PyObject *exception, const char *format, ...)
 
-   This function sets the error indicator and returns *NULL*. *exception* should be
-   a Python exception (class, not an instance). *format* should be an ASCII-encoded string,
-   containing format codes, similar to :c:func:`printf`. The ``width.precision``
-   before a format code is parsed, but the width part is ignored.
-
-   .. % This should be exactly the same as the table in PyString_FromFormat.
-   .. % One should just refer to the other.
-   .. % The descriptions for %zd and %zu are wrong, but the truth is complicated
-   .. % because not all compilers support the %z width modifier -- we fake it
-   .. % when necessary via interpolating PY_FORMAT_SIZE_T.
-   .. % Similar comments apply to the %ll width modifier and
-   .. % PY_FORMAT_LONG_LONG.
-
-   +-------------------+---------------+--------------------------------+
-   | Format Characters | Type          | Comment                        |
-   +===================+===============+================================+
-   | :attr:`%%`        | *n/a*         | The literal % character.       |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%c`        | int           | A single character,            |
-   |                   |               | represented as an C int.       |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%d`        | int           | Exactly equivalent to          |
-   |                   |               | ``printf("%d")``.              |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%u`        | unsigned int  | Exactly equivalent to          |
-   |                   |               | ``printf("%u")``.              |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%ld`       | long          | Exactly equivalent to          |
-   |                   |               | ``printf("%ld")``.             |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%lu`       | unsigned long | Exactly equivalent to          |
-   |                   |               | ``printf("%lu")``.             |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%lld`      | long long     | Exactly equivalent to          |
-   |                   |               | ``printf("%lld")``.            |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%llu`      | unsigned      | Exactly equivalent to          |
-   |                   | long long     | ``printf("%llu")``.            |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%zd`       | Py_ssize_t    | Exactly equivalent to          |
-   |                   |               | ``printf("%zd")``.             |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%zu`       | size_t        | Exactly equivalent to          |
-   |                   |               | ``printf("%zu")``.             |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%i`        | int           | Exactly equivalent to          |
-   |                   |               | ``printf("%i")``.              |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%x`        | int           | Exactly equivalent to          |
-   |                   |               | ``printf("%x")``.              |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%s`        | char\*        | A null-terminated C character  |
-   |                   |               | array.                         |
-   +-------------------+---------------+--------------------------------+
-   | :attr:`%p`        | void\*        | The hex representation of a C  |
-   |                   |               | pointer. Mostly equivalent to  |
-   |                   |               | ``printf("%p")`` except that   |
-   |                   |               | it is guaranteed to start with |
-   |                   |               | the literal ``0x`` regardless  |
-   |                   |               | of what the platform's         |
-   |                   |               | ``printf`` yields.             |
-   +-------------------+---------------+--------------------------------+
-
-   An unrecognized format character causes all the rest of the format string to be
-   copied as-is to the result string, and any extra arguments discarded.
-
-   .. note::
-
-      The `"%lld"` and `"%llu"` format specifiers are only available
-      when :const:`HAVE_LONG_LONG` is defined.
-
-   .. versionchanged:: 3.2
-      Support for `"%lld"` and `"%llu"` added.
+   This function sets the error indicator and returns *NULL*.  *exception*
+   should be a Python exception class.  The *format* and subsequent
+   parameters help format the error message; they have the same meaning and
+   values as in :c:func:`PyUnicode_FromFormat`. *format* is an ASCII-encoded
+   string.
 
 
 .. c:function:: void PyErr_SetNone(PyObject *type)
@@ -287,7 +219,9 @@
 
    Similar to :c:func:`PyErr_SetFromWindowsErr`, with the additional behavior that
    if *filename* is not *NULL*, it is passed to the constructor of
-   :exc:`WindowsError` as a third parameter. Availability: Windows.
+   :exc:`WindowsError` as a third parameter.  *filename* is decoded from the
+   filesystem encoding (:func:`sys.getfilesystemencoding`).  Availability:
+   Windows.
 
 
 .. c:function:: PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename)
@@ -301,7 +235,8 @@
    Set file, line, and offset information for the current exception.  If the
    current exception is not a :exc:`SyntaxError`, then it sets additional
    attributes, which make the exception printing subsystem think the exception
-   is a :exc:`SyntaxError`.
+   is a :exc:`SyntaxError`. *filename* is decoded from the filesystem encoding
+   (:func:`sys.getfilesystemencoding`).
 
 .. versionadded:: 3.2
 
@@ -323,7 +258,7 @@
 .. c:function:: int PyErr_WarnEx(PyObject *category, char *message, int stack_level)
 
    Issue a warning message.  The *category* argument is a warning category (see
-   below) or *NULL*; the *message* argument is a message string.  *stack_level* is a
+   below) or *NULL*; the *message* argument is an UTF-8 encoded string.  *stack_level* is a
    positive number giving a number of stack frames; the warning will be issued from
    the  currently executing line of code in that stack frame.  A *stack_level* of 1
    is the function calling :c:func:`PyErr_WarnEx`, 2 is  the function above that,
@@ -363,13 +298,16 @@
    is a straightforward wrapper around the Python function
    :func:`warnings.warn_explicit`, see there for more information.  The *module*
    and *registry* arguments may be set to *NULL* to get the default effect
-   described there.
+   described there. *message* and *module* are UTF-8 encoded strings,
+   *filename* is decoded from the filesystem encoding
+   (:func:`sys.getfilesystemencoding`).
 
 
 .. c:function:: int PyErr_WarnFormat(PyObject *category, Py_ssize_t stack_level, const char *format, ...)
 
    Function similar to :c:func:`PyErr_WarnEx`, but use
-   :c:func:`PyUnicode_FromFormatV` to format the warning message.
+   :c:func:`PyUnicode_FromFormat` to format the warning message.  *format* is
+   an ASCII-encoded string.
 
    .. versionadded:: 3.2
 
@@ -496,6 +434,85 @@
    This steals a reference to *ctx*.
 
 
+.. _unicodeexceptions:
+
+Unicode Exception Objects
+=========================
+
+The following functions are used to create and modify Unicode exceptions from C.
+
+.. c:function:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
+
+   Create a :class:`UnicodeDecodeError` object with the attributes *encoding*,
+   *object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
+   UTF-8 encoded strings.
+
+.. c:function:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
+
+   Create a :class:`UnicodeEncodeError` object with the attributes *encoding*,
+   *object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
+   UTF-8 encoded strings.
+
+.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
+
+   Create a :class:`UnicodeTranslateError` object with the attributes *object*,
+   *length*, *start*, *end* and *reason*. *reason* is an UTF-8 encoded string.
+
+.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
+                PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
+
+   Return the *encoding* attribute of the given exception object.
+
+.. c:function:: PyObject* PyUnicodeDecodeError_GetObject(PyObject *exc)
+                PyObject* PyUnicodeEncodeError_GetObject(PyObject *exc)
+                PyObject* PyUnicodeTranslateError_GetObject(PyObject *exc)
+
+   Return the *object* attribute of the given exception object.
+
+.. c:function:: int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
+                int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
+                int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start)
+
+   Get the *start* attribute of the given exception object and place it into
+   *\*start*.  *start* must not be *NULL*.  Return ``0`` on success, ``-1`` on
+   failure.
+
+.. c:function:: int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start)
+                int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start)
+                int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start)
+
+   Set the *start* attribute of the given exception object to *start*.  Return
+   ``0`` on success, ``-1`` on failure.
+
+.. c:function:: int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
+                int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
+                int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *end)
+
+   Get the *end* attribute of the given exception object and place it into
+   *\*end*.  *end* must not be *NULL*.  Return ``0`` on success, ``-1`` on
+   failure.
+
+.. c:function:: int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end)
+                int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end)
+                int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end)
+
+   Set the *end* attribute of the given exception object to *end*.  Return ``0``
+   on success, ``-1`` on failure.
+
+.. c:function:: PyObject* PyUnicodeDecodeError_GetReason(PyObject *exc)
+                PyObject* PyUnicodeEncodeError_GetReason(PyObject *exc)
+                PyObject* PyUnicodeTranslateError_GetReason(PyObject *exc)
+
+   Return the *reason* attribute of the given exception object.
+
+.. c:function:: int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason)
+                int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason)
+                int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason)
+
+   Set the *reason* attribute of the given exception object to *reason*.  Return
+   ``0`` on success, ``-1`` on failure.
+
+
 Recursion Control
 =================
 
@@ -525,6 +542,35 @@
    Ends a :c:func:`Py_EnterRecursiveCall`.  Must be called once for each
    *successful* invocation of :c:func:`Py_EnterRecursiveCall`.
 
+Properly implementing :attr:`tp_repr` for container types requires
+special recursion handling.  In addition to protecting the stack,
+:attr:`tp_repr` also needs to track objects to prevent cycles.  The
+following two functions facilitate this functionality.  Effectively,
+these are the C equivalent to :func:`reprlib.recursive_repr`.
+
+.. c:function:: int Py_ReprEnter(PyObject *object)
+
+   Called at the beginning of the :attr:`tp_repr` implementation to
+   detect cycles.
+
+   If the object has already been processed, the function returns a
+   positive integer.  In that case the :attr:`tp_repr` implementation
+   should return a string object indicating a cycle.  As examples,
+   :class:`dict` objects return ``{...}`` and :class:`list` objects
+   return ``[...]``.
+
+   The function will return a negative integer if the recursion limit
+   is reached.  In that case the :attr:`tp_repr` implementation should
+   typically return ``NULL``.
+
+   Otherwise, the function returns zero and the :attr:`tp_repr`
+   implementation can continue normally.
+
+.. c:function:: void Py_ReprLeave(PyObject *object)
+
+   Ends a :c:func:`Py_ReprEnter`.  Must be called once for each
+   invocation of :c:func:`Py_ReprEnter` that returns zero.
+
 
 .. _standardexceptions:
 

Modified: python/branches/py3k-cdecimal/Doc/c-api/import.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/import.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/import.rst	Sun Jan  2 13:18:37 2011
@@ -142,6 +142,7 @@
    attribute of the module object is set to *cpathname* if it is
    non-``NULL``.  Of the three functions, this is the preferred one to use.
 
+   .. versionadded:: 3.2
 
 .. c:function:: long PyImport_GetMagicNumber()
 
@@ -155,6 +156,8 @@
    Return the magic tag string for :pep:`3147` format Python bytecode file
    names.
 
+   .. versionadded:: 3.2
+
 .. c:function:: PyObject* PyImport_GetModuleDict()
 
    Return the dictionary used for the module administration (a.k.a.

Modified: python/branches/py3k-cdecimal/Doc/c-api/init.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/init.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/init.rst	Sun Jan  2 13:18:37 2011
@@ -412,8 +412,9 @@
 .. c:function:: void Py_SetPythonHome(wchar_t *home)
 
    Set the default "home" directory, that is, the location of the standard
-   Python libraries.  The libraries are searched in
-   :file:`{home}/lib/python{version}` and :file:`{home}/lib/python{version}`.
+   Python libraries.  See :envvar:`PYTHONHOME` for the meaning of the
+   argument string.
+
    The argument should point to a zero-terminated character string in static
    storage whose contents will not change for the duration of the program's
    execution.  No code in the Python interpreter will change the contents of

Modified: python/branches/py3k-cdecimal/Doc/c-api/intro.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/intro.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/intro.rst	Sun Jan  2 13:18:37 2011
@@ -41,8 +41,8 @@
    #include "Python.h"
 
 This implies inclusion of the following standard headers: ``<stdio.h>``,
-``<string.h>``, ``<errno.h>``, ``<limits.h>``, and ``<stdlib.h>`` (if
-available).
+``<string.h>``, ``<errno.h>``, ``<limits.h>``, ``<assert.h>`` and ``<stdlib.h>``
+(if available).
 
 .. note::
 

Modified: python/branches/py3k-cdecimal/Doc/c-api/list.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/list.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/list.rst	Sun Jan  2 13:18:37 2011
@@ -37,7 +37,7 @@
 
    .. note::
 
-      If *length* is greater than zero, the returned list object's items are
+      If *len* is greater than zero, the returned list object's items are
       set to ``NULL``.  Thus you cannot use abstract API functions such as
       :c:func:`PySequence_SetItem`  or expose the object to Python code before
       setting all items to a real object with :c:func:`PyList_SetItem`.
@@ -58,9 +58,9 @@
 
 .. c:function:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index)
 
-   Return the object at position *pos* in the list pointed to by *p*.  The
+   Return the object at position *index* in the list pointed to by *list*.  The
    position must be positive, indexing from the end of the list is not
-   supported.  If *pos* is out of bounds, return *NULL* and set an
+   supported.  If *index* is out of bounds, return *NULL* and set an
    :exc:`IndexError` exception.
 
 

Modified: python/branches/py3k-cdecimal/Doc/c-api/slice.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/slice.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/slice.rst	Sun Jan  2 13:18:37 2011
@@ -26,7 +26,7 @@
    the new object could not be allocated.
 
 
-.. c:function:: int PySlice_GetIndices(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
+.. c:function:: int PySlice_GetIndices(PyObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
 
    Retrieve the start, stop and step indices from the slice object *slice*,
    assuming a sequence of length *length*. Treats indices greater than
@@ -38,8 +38,12 @@
 
    You probably do not want to use this function.
 
+   .. versionchanged:: 3.2
+      The parameter type for the *slice* parameter was ``PySliceObject*``
+      before.
 
-.. c:function:: int PySlice_GetIndicesEx(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength)
+
+.. c:function:: int PySlice_GetIndicesEx(PyObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength)
 
    Usable replacement for :c:func:`PySlice_GetIndices`.  Retrieve the start,
    stop, and step indices from the slice object *slice* assuming a sequence of
@@ -49,3 +53,6 @@
 
    Returns 0 on success and -1 on error with exception set.
 
+   .. versionchanged:: 3.2
+      The parameter type for the *slice* parameter was ``PySliceObject*``
+      before.

Modified: python/branches/py3k-cdecimal/Doc/c-api/typeobj.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/typeobj.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/typeobj.rst	Sun Jan  2 13:18:37 2011
@@ -705,7 +705,9 @@
    This field is not inherited by subtypes (computed attributes are inherited
    through a different mechanism).
 
-   Docs for PyGetSetDef (XXX belong elsewhere)::
+   .. XXX belongs elsewhere
+
+   Docs for PyGetSetDef::
 
       typedef PyObject *(*getter)(PyObject *, void *);
       typedef int (*setter)(PyObject *, PyObject *, void *);
@@ -752,7 +754,7 @@
 
       PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);
 
-   XXX explain.
+   .. XXX explain.
 
    This field is inherited by subtypes.
 
@@ -767,7 +769,7 @@
 
    This field is inherited by subtypes.
 
-   XXX explain.
+   .. XXX explain.
 
 
 .. c:member:: long PyTypeObject.tp_dictoffset
@@ -1193,7 +1195,7 @@
 .. sectionauthor:: Benjamin Peterson
 
 
-The buffer interface exports a model where an object can expose its internal
+The :ref:`buffer interface <bufferobjects>` exports a model where an object can expose its internal
 data.
 
 If an object does not export the buffer interface, then its :attr:`tp_as_buffer`

Modified: python/branches/py3k-cdecimal/Doc/c-api/unicode.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/unicode.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/unicode.rst	Sun Jan  2 13:18:37 2011
@@ -328,6 +328,13 @@
    Identical to :c:func:`PyUnicode_FromFormat` except that it takes exactly two
    arguments.
 
+.. c:function:: PyObject* PyUnicode_TransformDecimalToASCII(Py_UNICODE *s, Py_ssize_t size)
+
+   Create a Unicode object by replacing all decimal digits in
+   :c:type:`Py_UNICODE` buffer of the given size by ASCII digits 0--9
+   according to their decimal value.  Return *NULL* if an exception
+   occurs.
+
 
 .. c:function:: Py_UNICODE* PyUnicode_AsUnicode(PyObject *unicode)
 
@@ -1056,7 +1063,9 @@
 .. c:function:: int PyUnicode_CompareWithASCIIString(PyObject *uni, char *string)
 
    Compare a unicode object, *uni*, with *string* and return -1, 0, 1 for less
-   than, equal, and greater than, respectively.
+   than, equal, and greater than, respectively. It is best to pass only
+   ASCII-encoded strings, but the function interprets the input string as
+   ISO-8859-1 if it contains non-ASCII characters".
 
 
 .. c:function:: int PyUnicode_RichCompare(PyObject *left,  PyObject *right,  int op)

Modified: python/branches/py3k-cdecimal/Doc/c-api/veryhigh.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/c-api/veryhigh.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/c-api/veryhigh.rst	Sun Jan  2 13:18:37 2011
@@ -66,8 +66,9 @@
    If *fp* refers to a file associated with an interactive device (console or
    terminal input or Unix pseudo-terminal), return the value of
    :c:func:`PyRun_InteractiveLoop`, otherwise return the result of
-   :c:func:`PyRun_SimpleFile`.  If *filename* is *NULL*, this function uses
-   ``"???"`` as the filename.
+   :c:func:`PyRun_SimpleFile`.  *filename* is decoded from the filesystem
+   encoding (:func:`sys.getfilesystemencoding`).  If *filename* is *NULL*, this
+   function uses ``"???"`` as the filename.
 
 
 .. c:function:: int PyRun_SimpleString(const char *command)
@@ -110,9 +111,10 @@
 .. c:function:: int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags)
 
    Similar to :c:func:`PyRun_SimpleStringFlags`, but the Python source code is read
-   from *fp* instead of an in-memory string. *filename* should be the name of the
-   file.  If *closeit* is true, the file is closed before PyRun_SimpleFileExFlags
-   returns.
+   from *fp* instead of an in-memory string. *filename* should be the name of
+   the file, it is decoded from the filesystem encoding
+   (:func:`sys.getfilesystemencoding`).  If *closeit* is true, the file is
+   closed before PyRun_SimpleFileExFlags returns.
 
 
 .. c:function:: int PyRun_InteractiveOne(FILE *fp, const char *filename)
@@ -125,7 +127,10 @@
 
    Read and execute a single statement from a file associated with an
    interactive device according to the *flags* argument.  The user will be
-   prompted using ``sys.ps1`` and ``sys.ps2``.  Returns ``0`` when the input was
+   prompted using ``sys.ps1`` and ``sys.ps2``.  *filename* is decoded from the
+   filesystem encoding (:func:`sys.getfilesystemencoding`).
+
+   Returns ``0`` when the input was
    executed successfully, ``-1`` if there was an exception, or an error code
    from the :file:`errcode.h` include file distributed as part of Python if
    there was a parse error.  (Note that :file:`errcode.h` is not included by
@@ -142,7 +147,8 @@
 
    Read and execute statements from a file associated with an interactive device
    until EOF is reached.  The user will be prompted using ``sys.ps1`` and
-   ``sys.ps2``.  Returns ``0`` at EOF.
+   ``sys.ps2``.  *filename* is decoded from the filesystem encoding
+   (:func:`sys.getfilesystemencoding`).  Returns ``0`` at EOF.
 
 
 .. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start)
@@ -164,7 +170,8 @@
    Parse Python source code from *str* using the start token *start* according to
    the *flags* argument.  The result can be used to create a code object which can
    be evaluated efficiently. This is useful if a code fragment must be evaluated
-   many times.
+   many times. *filename* is decoded from the filesystem encoding
+   (:func:`sys.getfilesystemencoding`).
 
 
 .. c:function:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start)
@@ -217,7 +224,8 @@
 .. c:function:: PyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags)
 
    Similar to :c:func:`PyRun_StringFlags`, but the Python source code is read from
-   *fp* instead of an in-memory string. *filename* should be the name of the file.
+   *fp* instead of an in-memory string. *filename* should be the name of the file,
+   it is decoded from the filesystem encoding (:func:`sys.getfilesystemencoding`).
    If *closeit* is true, the file is closed before :c:func:`PyRun_FileExFlags`
    returns.
 
@@ -230,23 +238,38 @@
 
 .. c:function:: PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags)
 
+   This is a simplified interface to :c:func:`Py_CompileStringExFlags` below, with
+   *optimize* set to ``-1``.
+
+
+.. c:function:: PyObject* Py_CompileStringExFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags, int optimize)
+
    Parse and compile the Python source code in *str*, returning the resulting code
    object.  The start token is given by *start*; this can be used to constrain the
    code which can be compiled and should be :const:`Py_eval_input`,
    :const:`Py_file_input`, or :const:`Py_single_input`.  The filename specified by
    *filename* is used to construct the code object and may appear in tracebacks or
-   :exc:`SyntaxError` exception messages.  This returns *NULL* if the code cannot
-   be parsed or compiled.
+   :exc:`SyntaxError` exception messages, it is decoded from the filesystem
+   encoding (:func:`sys.getfilesystemencoding`).  This returns *NULL* if the
+   code cannot be parsed or compiled.
+
+   The integer *optimize* specifies the optimization level of the compiler; a
+   value of ``-1`` selects the optimization level of the interpreter as given by
+   :option:`-O` options.  Explicit levels are ``0`` (no optimization;
+   ``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false)
+   or ``2`` (docstrings are removed too).
+
+   .. versionadded:: 3.2
 
 
-.. c:function:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
+.. c:function:: PyObject* PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals)
 
    This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just
    the code object, and the dictionaries of global and local variables.
    The other arguments are set to *NULL*.
 
 
-.. c:function:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure)
+.. c:function:: PyObject* PyEval_EvalCodeEx(PyObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure)
 
    Evaluate a precompiled code object, given a particular environment for its
    evaluation.  This environment consists of dictionaries of global and local

Modified: python/branches/py3k-cdecimal/Doc/copyright.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/copyright.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/copyright.rst	Sun Jan  2 13:18:37 2011
@@ -4,7 +4,7 @@
 
 Python and this documentation is:
 
-Copyright © 2001-2010 Python Software Foundation. All rights reserved.
+Copyright © 2001-2011 Python Software Foundation. All rights reserved.
 
 Copyright © 2000 BeOpen.com. All rights reserved.
 

Modified: python/branches/py3k-cdecimal/Doc/distutils/apiref.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/distutils/apiref.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/distutils/apiref.rst	Sun Jan  2 13:18:37 2011
@@ -888,7 +888,7 @@
 .. function:: make_zipfile(base_name, base_dir[, verbose=0, dry_run=0])
 
    Create a zip file from all files in and under *base_dir*.  The output zip file
-   will be named *base_dir* + :file:`.zip`.  Uses either the  :mod:`zipfile` Python
+   will be named *base_name* + :file:`.zip`.  Uses either the  :mod:`zipfile` Python
    module (if available) or the InfoZIP :file:`zip`  utility (if installed and
    found on the default search path).  If neither  tool is available, raises
    :exc:`DistutilsExecError`.   Returns the name of the output zip file.

Modified: python/branches/py3k-cdecimal/Doc/documenting/markup.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/documenting/markup.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/documenting/markup.rst	Sun Jan  2 13:18:37 2011
@@ -610,6 +610,8 @@
 
 The ``:ref:`` invocation is replaced with the section title.
 
+Alternatively, you can reference any label (not just section titles)
+if you provide the link text ``:ref:`link text`<reference-label>```.
 
 Paragraph-level markup
 ----------------------

Modified: python/branches/py3k-cdecimal/Doc/extending/embedding.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/extending/embedding.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/extending/embedding.rst	Sun Jan  2 13:18:37 2011
@@ -35,9 +35,6 @@
 to :c:func:`PyRun_SimpleFile`.  You can also call the lower-level operations
 described in the previous chapters to construct and use Python objects.
 
-A simple demo of embedding Python can be found in the directory
-:file:`Demo/embed/` of the source distribution.
-
 
 .. seealso::
 
@@ -209,7 +206,7 @@
    {
        if(!PyArg_ParseTuple(args, ":numargs"))
            return NULL;
-       return Py_BuildValue("i", numargs);
+       return PyLong_FromLong(numargs);
    }
 
    static PyMethodDef EmbMethods[] = {

Modified: python/branches/py3k-cdecimal/Doc/extending/extending.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/extending/extending.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/extending/extending.rst	Sun Jan  2 13:18:37 2011
@@ -81,7 +81,7 @@
        if (!PyArg_ParseTuple(args, "s", &command))
            return NULL;
        sts = system(command);
-       return Py_BuildValue("i", sts);
+       return PyLong_FromLong(sts);
    }
 
 There is a straightforward translation from the argument list in Python (for
@@ -274,12 +274,9 @@
    sts = system(command);
 
 Our :func:`spam.system` function must return the value of :c:data:`sts` as a
-Python object.  This is done using the function :c:func:`Py_BuildValue`, which is
-something like the inverse of :c:func:`PyArg_ParseTuple`: it takes a format
-string and an arbitrary number of C values, and returns a new Python object.
-More info on :c:func:`Py_BuildValue` is given later. ::
+Python object.  This is done using the function :c:func:`PyLong_FromLong`. ::
 
-   return Py_BuildValue("i", sts);
+   return PyLong_FromLong(sts);
 
 In this case, it will return an integer object.  (Yes, even integers are objects
 on the heap in Python!)
@@ -1195,7 +1192,7 @@
        if (!PyArg_ParseTuple(args, "s", &command))
            return NULL;
        sts = PySpam_System(command);
-       return Py_BuildValue("i", sts);
+       return PyLong_FromLong(sts);
    }
 
 In the beginning of the module, right after the line ::

Modified: python/branches/py3k-cdecimal/Doc/extending/windows.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/extending/windows.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/extending/windows.rst	Sun Jan  2 13:18:37 2011
@@ -110,7 +110,7 @@
    Now your options are:
 
 #. Copy :file:`example.sln` and :file:`example.vcproj`, rename them to
-      :file:`spam.\*`, and edit them by hand, or
+   :file:`spam.\*`, and edit them by hand, or
 
 #. Create a brand new project; instructions are below.
 
@@ -179,8 +179,8 @@
 
 and add the following to the module initialization function::
 
-   MyObject_Type.ob_type = &PyType_Type;
-
+   if (PyType_Ready(&MyObject_Type) < 0)
+        return NULL;
 
 
 .. _dynamic-linking:

Modified: python/branches/py3k-cdecimal/Doc/faq/extending.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/faq/extending.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/faq/extending.rst	Sun Jan  2 13:18:37 2011
@@ -379,7 +379,7 @@
            if (ps1  == prompt ||                  /* ">>> " or */
                '\n' == code[i + j - 1])           /* "... " and double '\n' */
            {                                               /* so execute it */
-             dum = PyEval_EvalCode ((PyCodeObject *)src, glb, loc);
+             dum = PyEval_EvalCode (src, glb, loc);
              Py_XDECREF (dum);
              Py_XDECREF (src);
              free (code);

Modified: python/branches/py3k-cdecimal/Doc/glossary.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/glossary.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/glossary.rst	Sun Jan  2 13:18:37 2011
@@ -27,7 +27,7 @@
       :ref:`2to3-reference`.
 
    abstract base class
-      Abstract Base Classes (abbreviated ABCs) complement :term:`duck-typing` by
+      :ref:`abstract-base-classes` complement :term:`duck-typing` by
       providing a way to define interfaces when other techniques like
       :func:`hasattr` would be clumsy. Python comes with many built-in ABCs for
       data structures (in the :mod:`collections` module), numbers (in the
@@ -181,22 +181,22 @@
       not expressions.
 
    extension module
-      A module written in C or C++, using Python's C API to interact with the core and
-      with user code.
+      A module written in C or C++, using Python's C API to interact with the
+      core and with user code.
 
    file object
       An object exposing a file-oriented API (with methods such as
-      :meth:`read()` or :meth:`write()`) to an underlying resource.
-      Depending on the way it was created, a file object can mediate access
-      to a real on-disk file or to another other type of storage or
-      communication device (for example standard input/output, in-memory
-      buffers, sockets, pipes, etc.).  File objects are also called
-      :dfn:`file-like objects` or :dfn:`streams`.
-
-      There are actually three categories of file objects: raw binary
-      files, buffered binary files and text files.  Their interfaces are
-      defined in the :mod:`io` module.  The canonical way to create a
-      file object is by using the :func:`open` function.
+      :meth:`read()` or :meth:`write()`) to an underlying resource.  Depending
+      on the way it was created, a file object can mediate access to a real
+      on-disk file or to another other type of storage or communication device
+      (for example standard input/output, in-memory buffers, sockets, pipes,
+      etc.).  File objects are also called :dfn:`file-like objects` or
+      :dfn:`streams`.
+
+      There are actually three categories of file objects: raw binary files,
+      buffered binary files and text files.  Their interfaces are defined in the
+      :mod:`io` module.  The canonical way to create a file object is by using
+      the :func:`open` function.
 
    file-like object
       A synonym for :term:`file object`.
@@ -392,6 +392,12 @@
       the :term:`EAFP` approach and is characterized by the presence of many
       :keyword:`if` statements.
 
+      In a multi-threaded environment, the LBYL approach can risk introducing a
+      race condition between "the looking" and "the leaping".  For example, the
+      code, ``if key in mapping: return mapping[key]`` can fail if another
+      thread removes *key* from *mapping* after the test, but before the lookup.
+      This issue can be solved with locks or by using the EAFP approach.
+
    list
       A built-in Python :term:`sequence`.  Despite its name it is more akin
       to an array in other languages than to a linked list since access to

Modified: python/branches/py3k-cdecimal/Doc/howto/index.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/howto/index.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/howto/index.rst	Sun Jan  2 13:18:37 2011
@@ -19,6 +19,8 @@
    descriptor.rst
    doanddont.rst
    functional.rst
+   logging.rst
+   logging-cookbook.rst
    regex.rst
    sockets.rst
    sorting.rst

Modified: python/branches/py3k-cdecimal/Doc/includes/tzinfo-examples.py
==============================================================================
--- python/branches/py3k-cdecimal/Doc/includes/tzinfo-examples.py	(original)
+++ python/branches/py3k-cdecimal/Doc/includes/tzinfo-examples.py	Sun Jan  2 13:18:37 2011
@@ -71,7 +71,7 @@
     def _isdst(self, dt):
         tt = (dt.year, dt.month, dt.day,
               dt.hour, dt.minute, dt.second,
-              dt.weekday(), 0, -1)
+              dt.weekday(), 0, 0)
         stamp = _time.mktime(tt)
         tt = _time.localtime(stamp)
         return tt.tm_isdst > 0

Modified: python/branches/py3k-cdecimal/Doc/install/index.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/install/index.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/install/index.rst	Sun Jan  2 13:18:37 2011
@@ -929,15 +929,34 @@
 GNU C / Cygwin / MinGW
 ^^^^^^^^^^^^^^^^^^^^^^
 
-These instructions only apply if you're using a version of Python prior  to
-2.4.1 with a MinGW prior to 3.0.0 (with binutils-2.13.90-20030111-1).
-
 This section describes the necessary steps to use Distutils with the GNU C/C++
 compilers in their Cygwin and MinGW distributions. [#]_ For a Python interpreter
 that was built with Cygwin, everything should work without any of these
 following steps.
 
-These compilers require some special libraries. This task is more complex than
+Not all extensions can be built with MinGW or Cygwin, but many can.  Extensions
+most likely to not work are those that use C++ or depend on Microsoft Visual C
+extensions.
+
+To let Distutils compile your extension with Cygwin you have to type::
+
+   python setup.py build --compiler=cygwin
+
+and for Cygwin in no-cygwin mode [#]_ or for MinGW type::
+
+   python setup.py build --compiler=mingw32
+
+If you want to use any of these options/compilers as default, you should
+consider writing it in your personal or system-wide configuration file for
+Distutils (see section :ref:`inst-config-files`.)
+
+Older Versions of Python and MinGW
+""""""""""""""""""""""""""""""""""
+The following instructions only apply if you're using a version of Python
+inferior to 2.4.1 with a MinGW inferior to 3.0.0 (with
+binutils-2.13.90-20030111-1).
+
+These compilers require some special libraries.  This task is more complex than
 for Borland's C++, because there is no program to convert the library.  First
 you have to create a list of symbols which the Python DLL exports. (You can find
 a good program for this task at
@@ -967,18 +986,6 @@
 them too. The converted files have to reside in the same directories as the
 normal libraries do.
 
-To let Distutils compile your extension with Cygwin you now have to type ::
-
-   python setup.py build --compiler=cygwin
-
-and for Cygwin in no-cygwin mode [#]_ or for MinGW type::
-
-   python setup.py build --compiler=mingw32
-
-If you want to use any of these options/compilers as default, you should
-consider to write it in your personal or system-wide configuration file for
-Distutils (see section :ref:`inst-config-files`.)
-
 
 .. seealso::
 

Modified: python/branches/py3k-cdecimal/Doc/library/_thread.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/_thread.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/_thread.rst	Sun Jan  2 13:18:37 2011
@@ -137,6 +137,10 @@
    .. versionchanged:: 3.2
       The *timeout* parameter is new.
 
+   .. versionchanged:: 3.2
+      Lock acquires can now be interrupted by signals on POSIX.
+
+
 .. method:: lock.release()
 
    Releases the lock.  The lock must have been acquired earlier, but not

Modified: python/branches/py3k-cdecimal/Doc/library/allos.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/allos.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/allos.rst	Sun Jan  2 13:18:37 2011
@@ -19,6 +19,8 @@
    optparse.rst
    getopt.rst
    logging.rst
+   logging.config.rst
+   logging.handlers.rst
    getpass.rst
    curses.rst
    curses.ascii.rst

Modified: python/branches/py3k-cdecimal/Doc/library/argparse.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/argparse.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/argparse.rst	Sun Jan  2 13:18:37 2011
@@ -1428,6 +1428,16 @@
 
        {foo,bar}   additional help
 
+   Furthermore, ``add_parser`` supports an additional ``aliases`` argument,
+   which allows multiple strings to refer to the same subparser. This example,
+   like ``svn``, aliases ``co`` as a shorthand for ``checkout``::
+
+     >>> parser = argparse.ArgumentParser()
+     >>> subparsers = parser.add_subparsers()
+     >>> checkout = subparsers.add_parser('checkout', aliases=['co'])
+     >>> checkout.add_argument('foo')
+     >>> parser.parse_args(['co', 'bar'])
+     Namespace(foo='bar')
 
    One particularly effective way of handling sub-commands is to combine the use
    of the :meth:`add_subparsers` method with calls to :meth:`set_defaults` so
@@ -1466,7 +1476,7 @@
      >>> args.func(args)
      ((XYZYX))
 
-   This way, you can let :meth:`parse_args` does the job of calling the
+   This way, you can let :meth:`parse_args` do the job of calling the
    appropriate function after argument parsing is complete.  Associating
    functions with actions like this is typically the easiest way to handle the
    different actions for each of your subparsers.  However, if it is necessary
@@ -1648,14 +1658,14 @@
 .. method:: ArgumentParser.print_usage(file=None)
 
    Print a brief description of how the :class:`ArgumentParser` should be
-   invoked on the command line.  If *file* is ``None``, :data:`sys.stderr` is
+   invoked on the command line.  If *file* is ``None``, :data:`sys.stdout` is
    assumed.
 
 .. method:: ArgumentParser.print_help(file=None)
 
    Print a help message, including the program usage and information about the
    arguments registered with the :class:`ArgumentParser`.  If *file* is
-   ``None``, :data:`sys.stderr` is assumed.
+   ``None``, :data:`sys.stdout` is assumed.
 
 There are also variants of these methods that simply return a string instead of
 printing it:
@@ -1729,6 +1739,7 @@
    This method prints a usage message including the *message* to the
    standard output and terminates the program with a status code of 2.
 
+.. _upgrading-optparse-code:
 
 Upgrading optparse code
 -----------------------

Modified: python/branches/py3k-cdecimal/Doc/library/array.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/array.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/array.rst	Sun Jan  2 13:18:37 2011
@@ -65,10 +65,6 @@
    passed to the :meth:`extend` method.
 
 
-.. data:: ArrayType
-
-   Obsolete alias for :class:`array`.
-
 .. data:: typecodes
 
    A string with all available type codes.

Modified: python/branches/py3k-cdecimal/Doc/library/bdb.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/bdb.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/bdb.rst	Sun Jan  2 13:18:37 2011
@@ -359,12 +359,10 @@
 .. function:: effective(file, line, frame)
 
    Determine if there is an effective (active) breakpoint at this line of code.
-   Return breakpoint number or 0 if none.
-
-   Called only if we know there is a breakpoint at this location.  Returns the
-   breakpoint that was triggered and a flag that indicates if it is ok to delete
-   a temporary breakpoint.
+   Return a tuple of the breakpoint and a boolean that indicates if it is ok
+   to delete a temporary breakpoint.  Return ``(None, None)`` if there is no
+   matching breakpoint.
 
 .. function:: set_trace()
 
-   Starts debugging with a :class:`Bdb` instance from caller's frame.
+   Start debugging with a :class:`Bdb` instance from caller's frame.

Modified: python/branches/py3k-cdecimal/Doc/library/builtins.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/builtins.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/builtins.rst	Sun Jan  2 13:18:37 2011
@@ -32,9 +32,8 @@
 
        # ...
 
-As an implementation detail, most modules have the name ``__builtins__`` (note
-the ``'s'``) made available as part of their globals.  The value of
-``__builtins__`` is normally either this module or the value of this modules's
-:attr:`__dict__` attribute.  Since this is an implementation detail, it may not
-be used by alternate implementations of Python.
-
+As an implementation detail, most modules have the name ``__builtins__`` made
+available as part of their globals.  The value of ``__builtins__`` is normally
+either this module or the value of this modules's :attr:`__dict__` attribute.
+Since this is an implementation detail, it may not be used by alternate
+implementations of Python.

Modified: python/branches/py3k-cdecimal/Doc/library/codecs.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/codecs.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/codecs.rst	Sun Jan  2 13:18:37 2011
@@ -1114,9 +1114,9 @@
 +-----------------+--------------------------------+--------------------------------+
 | utf_16          | U16, utf16                     | all languages                  |
 +-----------------+--------------------------------+--------------------------------+
-| utf_16_be       | UTF-16BE                       | all languages (BMP only)       |
+| utf_16_be       | UTF-16BE                       | all languages                  |
 +-----------------+--------------------------------+--------------------------------+
-| utf_16_le       | UTF-16LE                       | all languages (BMP only)       |
+| utf_16_le       | UTF-16LE                       | all languages                  |
 +-----------------+--------------------------------+--------------------------------+
 | utf_7           | U7, unicode-1-1-utf-7          | all languages                  |
 +-----------------+--------------------------------+--------------------------------+
@@ -1165,6 +1165,44 @@
 |                    |         | operand                   |
 +--------------------+---------+---------------------------+
 
+The following codecs provide bytes-to-bytes mappings.
+
++--------------------+---------------------------+---------------------------+
+| Codec              | Aliases                   | Purpose                   |
++====================+===========================+===========================+
+| base64_codec       | base64, base-64           | Convert operand to MIME   |
+|                    |                           | base64                    |
++--------------------+---------------------------+---------------------------+
+| bz2_codec          | bz2                       | Compress the operand      |
+|                    |                           | using bz2                 |
++--------------------+---------------------------+---------------------------+
+| hex_codec          | hex                       | Convert operand to        |
+|                    |                           | hexadecimal               |
+|                    |                           | representation, with two  |
+|                    |                           | digits per byte           |
++--------------------+---------------------------+---------------------------+
+| quopri_codec       | quopri, quoted-printable, | Convert operand to MIME   |
+|                    | quotedprintable           | quoted printable          |
++--------------------+---------------------------+---------------------------+
+| uu_codec           | uu                        | Convert the operand using |
+|                    |                           | uuencode                  |
++--------------------+---------------------------+---------------------------+
+| zlib_codec         | zip, zlib                 | Compress the operand      |
+|                    |                           | using gzip                |
++--------------------+---------------------------+---------------------------+
+
+The following codecs provide string-to-string mappings.
+
++--------------------+---------------------------+---------------------------+
+| Codec              | Aliases                   | Purpose                   |
++====================+===========================+===========================+
+| rot_13             | rot13                     | Returns the Caesar-cypher |
+|                    |                           | encryption of the operand |
++--------------------+---------------------------+---------------------------+
+
+.. versionadded:: 3.2
+   bytes-to-bytes and string-to-string codecs.
+
 
 :mod:`encodings.idna` --- Internationalized Domain Names in Applications
 ------------------------------------------------------------------------

Modified: python/branches/py3k-cdecimal/Doc/library/collections.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/collections.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/collections.rst	Sun Jan  2 13:18:37 2011
@@ -28,7 +28,7 @@
 =====================   ====================================================================
 
 In addition to the concrete container classes, the collections module provides
-ABCs (abstract base classes) that can be used to test whether a class provides a
+:ref:`abstract-base-classes` that can be used to test whether a class provides a
 particular interface, for example, whether it is hashable or a mapping.
 
 .. seealso::
@@ -866,7 +866,7 @@
 original insertion position is changed and moved to the end::
 
     class LastUpdatedOrderedDict(OrderedDict):
-        'Store items is the order the keys were last added'
+        'Store items in the order the keys were last added'
         def __setitem__(self, key, value):
             if key in self:
                 del self[key]
@@ -959,6 +959,7 @@
    subclass) or an arbitrary sequence which can be converted into a string using
    the built-in :func:`str` function.
 
+.. _abstract-base-classes:
 
 ABCs - abstract base classes
 ----------------------------

Modified: python/branches/py3k-cdecimal/Doc/library/compileall.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/compileall.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/compileall.rst	Sun Jan  2 13:18:37 2011
@@ -6,9 +6,10 @@
 
 
 This module provides some utility functions to support installing Python
-libraries.  These functions compile Python source files in a directory tree,
-allowing users without permission to write to the libraries to take advantage of
-cached byte-code files.
+libraries.  These functions compile Python source files in a directory tree.
+This module can be used to create the cached byte-code files at library
+installation time, which makes them available for use even by users who don't
+have write permission to the library directories.
 
 
 Command-line use
@@ -27,7 +28,8 @@
 
 .. cmdoption:: -l
 
-   Do not recurse.
+   Do not recurse into subdirectories, only compile source code files directly
+   contained in the named or implied directories.
 
 .. cmdoption:: -f
 
@@ -35,55 +37,118 @@
 
 .. cmdoption:: -q
 
-   Do not print the list of files compiled.
+   Do not print the list of files compiled, print only error messages.
 
 .. cmdoption:: -d destdir
 
-   Purported directory name for error messages.
+   Directory prepended to the path to each file being compiled.  This will
+   appear in compilation time tracebacks, and is also compiled in to the
+   byte-code file, where it will be used in tracebacks and other messages in
+   cases where the source file does not exist at the time the byte-code file is
+   executed.
 
 .. cmdoption:: -x regex
 
-   Skip files with a full path that matches given regular expression.
+   regex is used to search the full path to each file considered for
+   compilation, and if the regex produces a match, the file is skipped.
 
 .. cmdoption:: -i list
 
-   Expand list with its content (file and directory names).
+   Read the file ``list`` and add each line that it contains to the list of
+   files and directories to compile.  If ``list`` is ``-``, read lines from
+   ``stdin``.
 
 .. cmdoption:: -b
 
-   Write legacy ``.pyc`` file path names.  Default is to write :pep:`3147`-style
-   byte-compiled path names.
+   Write the byte-code files to their legacy locations and names, which may
+   overwrite byte-code files created by another version of Python.  The default
+   is to write files to their :pep:`3147` locations and names, which allows
+   byte-code files from multiple versions of Python to coexist.
+
+.. versionchanged:: 3.2
+   Added the ``-i``, ``-b`` and ``-h`` options.
 
 
 Public functions
 ----------------
 
-.. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, quiet=False, legacy=False)
+.. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, quiet=False, legacy=False, optimize=-1)
 
    Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
-   files along the way.  The *maxlevels* parameter is used to limit the depth of
-   the recursion; it defaults to ``10``.  If *ddir* is given, it is used as the
-   base path from  which the filenames used in error messages will be generated.
+   files along the way.
+
+   The *maxlevels* parameter is used to limit the depth of the recursion; it
+   defaults to ``10``.
+
+   If *ddir* is given, it is prepended to the path to each file being compiled
+   for use in compilation time tracebacks, and is also compiled in to the
+   byte-code file, where it will be used in tracebacks and other messages in
+   cases where the source file does not exist at the time the byte-code file is
+   executed.
+
    If *force* is true, modules are re-compiled even if the timestamps are up to
    date.
 
-   If *rx* is given, it specifies a regular expression of file names to exclude
-   from the search; that expression is searched for in the full path.
+   If *rx* is given, its search method is called on the complete path to each
+   file considered for compilation, and if it returns a true value, the file
+   is skipped.
+
+   If *quiet* is true, nothing is printed to the standard output unless errors
+   occur.
+
+   If *legacy* is true, byte-code files are written to their legacy locations
+   and names, which may overwrite byte-code files created by another version of
+   Python.  The default is to write files to their :pep:`3147` locations and
+   names, which allows byte-code files from multiple versions of Python to
+   coexist.
+
+   *optimize* specifies the optimization level for the compiler.  It is passed to
+   the built-in :func:`compile` function.
+
+   .. versionchanged:: 3.2
+      Added the *legacy* and *optimize* parameter.
+
 
-   If *quiet* is true, nothing is printed to the standard output in normal
-   operation.
+.. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=False, legacy=False, optimize=-1)
 
-   If *legacy* is true, old-style ``.pyc`` file path names are written,
-   otherwise (the default), :pep:`3147`-style path names are written.
+   Compile the file with path *fullname*.
 
+   If *ddir* is given, it is prepended to the path to the file being compiled
+   for use in compilation time tracebacks, and is also compiled in to the
+   byte-code file, where it will be used in tracebacks and other messages in
+   cases where the source file does not exist at the time the byte-code file is
+   executed.
 
-.. function:: compile_path(skip_curdir=True, maxlevels=0, force=False, legacy=False)
+   If *ra* is given, its search method is passed the full path name to the
+   file being compiled, and if it returns a true value, the file is not
+   compiled and ``True`` is returned.
+
+   If *quiet* is true, nothing is printed to the standard output unless errors
+   occur.
+
+   If *legacy* is true, byte-code files are written to their legacy locations
+   and names, which may overwrite byte-code files created by another version of
+   Python.  The default is to write files to their :pep:`3147` locations and
+   names, which allows byte-code files from multiple versions of Python to
+   coexist.
+
+   *optimize* specifies the optimization level for the compiler.  It is passed to
+   the built-in :func:`compile` function.
+
+   .. versionadded:: 3.2
+
+
+.. function:: compile_path(skip_curdir=True, maxlevels=0, force=False, legacy=False, optimize=-1)
 
    Byte-compile all the :file:`.py` files found along ``sys.path``. If
-   *skip_curdir* is true (the default), the current directory is not included in
-   the search.  The *maxlevels* parameter defaults to ``0``, and the *force*
-   and *legacy* parameters default to ``False``. All are
-   passed to the :func:`compile_dir` function.
+   *skip_curdir* is true (the default), the current directory is not included
+   in the search.  All other parameters are passed to the :func:`compile_dir`
+   function.  Note that unlike the other compile functions, ``maxlevels``
+   defaults to ``0``.
+
+   .. versionchanged:: 3.2
+      Added the *legacy* and *optimize* parameter.
+
 
 To force a recompile of all the :file:`.py` files in the :file:`Lib/`
 subdirectory and all its subdirectories::

Modified: python/branches/py3k-cdecimal/Doc/library/concurrent.futures.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/concurrent.futures.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/concurrent.futures.rst	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,5 @@
-:mod:`concurrent.futures` --- Concurrent computation
-====================================================
+:mod:`concurrent.futures` --- Launching parallel tasks
+======================================================
 
 .. module:: concurrent.futures
    :synopsis: Execute computations concurrently using threads or processes.
@@ -10,7 +10,7 @@
 asynchronously executing callables.
 
 The asynchronous execution can be be performed with threads, using
-:class:`ThreadPoolExecutor`, or seperate processes, using
+:class:`ThreadPoolExecutor`, or separate processes, using
 :class:`ProcessPoolExecutor`.  Both implement the same interface, which is
 defined by the abstract :class:`Executor` class.
 

Modified: python/branches/py3k-cdecimal/Doc/library/configparser.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/configparser.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/configparser.rst	Sun Jan  2 13:18:37 2011
@@ -17,11 +17,10 @@
    single: ini file
    single: Windows ini file
 
-This module provides the classes :class:`RawConfigParser` and
-:class:`SafeConfigParser`.  They implement a basic configuration
-language which provides a structure similar to what's found in Microsoft
-Windows INI files.  You can use this to write Python programs which can be
-customized by end users easily.
+This module provides the :class:`ConfigParser` class which implements a basic
+configuration language which provides a structure similar to what's found in
+Microsoft Windows INI files.  You can use this to write Python programs which
+can be customized by end users easily.
 
 .. note::
 
@@ -34,6 +33,10 @@
       Support for a creating Unix shell-like mini-languages which can be used
       as an alternate format for application configuration files.
 
+   Module :mod:`json`
+      The json module implements a subset of JavaScript syntax which can also
+      be used for this purpose.
+
 
 Quick Start
 -----------
@@ -43,17 +46,17 @@
 .. code-block:: ini
 
    [DEFAULT]
-     ServerAliveInterval = 45
-     Compression = yes
-     CompressionLevel = 9
-     ForwardX11 = yes
+   ServerAliveInterval = 45
+   Compression = yes
+   CompressionLevel = 9
+   ForwardX11 = yes
 
    [bitbucket.org]
-     User = hg
+   User = hg
 
    [topsecret.server.com]
-     Port = 50022
-     ForwardX11 = no
+   Port = 50022
+   ForwardX11 = no
 
 The structure of INI files is described `in the following section
 <#supported-ini-file-structure>`_.  Essentially, the file
@@ -64,7 +67,7 @@
 .. doctest::
 
    >>> import configparser
-   >>> config = configparser.RawConfigParser()
+   >>> config = configparser.ConfigParser()
    >>> config['DEFAULT'] = {'ServerAliveInterval': '45',
    ...                      'Compression': 'yes',
    ...                      'CompressionLevel': '9'}
@@ -89,7 +92,7 @@
 .. doctest::
 
    >>> import configparser
-   >>> config = configparser.RawConfigParser()
+   >>> config = configparser.ConfigParser()
    >>> config.sections()
    []
    >>> config.read('example.ini')
@@ -227,63 +230,129 @@
 
 Configuration files may include comments, prefixed by specific
 characters (``#`` and ``;`` by default [1]_).  Comments may appear on
-their own on an otherwise empty line, or may be entered on lines holding
-values or section names.  In the latter case, they need to be preceded
-by a whitespace character to be recognized as a comment.  For backwards
-compatibility, by default only ``;`` starts an inline comment, while
-``#`` does not [1]_.
-
-On top of the core functionality, :class:`SafeConfigParser` supports
-interpolation.  This means values can contain format strings which refer to
-other values in the same section, or values in a special ``DEFAULT`` section
-[1]_.  Additional defaults can be provided on initialization.
+their own on an otherwise empty line, possibly indented. [1]_
 
 For example:
 
 .. code-block:: ini
 
-   [Paths]
-   home_dir: /Users
-   my_dir: %(home_dir)s/lumberjack
-   my_pictures: %(my_dir)s/Pictures
+   [Simple Values]
+   key=value
+   spaces in keys=allowed
+   spaces in values=allowed as well
+   spaces around the delimiter = obviously
+   you can also use : to delimit keys from values
+
+   [All Values Are Strings]
+   values like this: 1000000
+   or this: 3.14159265359
+   are they treated as numbers? : no
+   integers, floats and booleans are held as: strings
+   can use the API to get converted values directly: true
 
    [Multiline Values]
    chorus: I'm a lumberjack, and I'm okay
-      I sleep all night and I work all day
+       I sleep all night and I work all day
 
    [No Values]
    key_without_value
    empty string value here =
 
-   [You can use comments] ; after a useful line
-   ; in an empty line
-   after: a_value ; here's another comment
-   inside: a         ;comment
-           multiline ;comment
-           value!    ;comment
-
-      [Sections Can Be Indented]
-         can_values_be_as_well = True
-         does_that_mean_anything_special = False
-         purpose = formatting for readability
-         multiline_values = are
-            handled just fine as
-            long as they are indented
-            deeper than the first line
-            of a value
-         # Did I mention we can indent comments, too?
-
-In the example above, :class:`SafeConfigParser` would resolve ``%(home_dir)s``
-to the value of ``home_dir`` (``/Users`` in this case).  ``%(my_dir)s`` in
-effect would resolve to ``/Users/lumberjack``.  All interpolations are done on
-demand so keys used in the chain of references do not have to be specified in
-any specific order in the configuration file.
-
-:class:`RawConfigParser` would simply return ``%(my_dir)s/Pictures`` as the
-value of ``my_pictures`` and ``%(home_dir)s/lumberjack`` as the value of
-``my_dir``.  Other features presented in the example are handled in the same
-manner by both parsers.
+   [You can use comments]
+   # like this
+   ; or this
+
+   # By default only in an empty line.
+   # Inline comments can be harmful because they prevent users
+   # from using the delimiting characters as parts of values.
+   # That being said, this can be customized.
+
+       [Sections Can Be Indented]
+           can_values_be_as_well = True
+           does_that_mean_anything_special = False
+           purpose = formatting for readability
+           multiline_values = are
+               handled just fine as
+               long as they are indented
+               deeper than the first line
+               of a value
+           # Did I mention we can indent comments, too?
+
+
+Interpolation of values
+-----------------------
+
+On top of the core functionality, :class:`ConfigParser` supports
+interpolation.  This means values can be preprocessed before returning them
+from ``get()`` calls.
+
+.. class:: BasicInterpolation()
+
+   The default implementation used by :class:`ConfigParser`.  It enables
+   values to contain format strings which refer to other values in the same
+   section, or values in the special default section [1]_.  Additional default
+   values can be provided on initialization.
+
+   For example:
+
+   .. code-block:: ini
+
+      [Paths]
+      home_dir: /Users
+      my_dir: %(home_dir)s/lumberjack
+      my_pictures: %(my_dir)s/Pictures
+
+
+   In the example above, :class:`ConfigParser` with *interpolation* set to
+   ``BasicInterpolation()`` would resolve ``%(home_dir)s`` to the value of
+   ``home_dir`` (``/Users`` in this case).  ``%(my_dir)s`` in effect would
+   resolve to ``/Users/lumberjack``.  All interpolations are done on demand so
+   keys used in the chain of references do not have to be specified in any
+   specific order in the configuration file.
+
+   With ``interpolation`` set to ``None``, the parser would simply return
+   ``%(my_dir)s/Pictures`` as the value of ``my_pictures`` and
+   ``%(home_dir)s/lumberjack`` as the value of ``my_dir``.
+
+.. class:: ExtendedInterpolation()
+
+   An alternative handler for interpolation which implements a more advanced
+   syntax, used for instance in ``zc.buildout``. Extended interpolation is
+   using ``${section:option}`` to denote a value from a foreign section.
+   Interpolation can span multiple levels. For convenience, if the ``section:``
+   part is omitted, interpolation defaults to the current section (and possibly
+   the default values from the special section).
+
+   For example, the configuration specified above with basic interpolation,
+   would look like this with extended interpolation:
+
+   .. code-block:: ini
+
+      [Paths]
+      home_dir: /Users
+      my_dir: ${home_dir}/lumberjack
+      my_pictures: ${my_dir}/Pictures
+
+   Values from other sections can be fetched as well:
+
+   .. code-block:: ini
+
+      [Common]
+      home_dir: /Users
+      library_dir: /Library
+      system_dir: /System
+      macports_dir: /opt/local
 
+      [Frameworks]
+      Python: 3.2
+      path: ${Common:system_dir}/Library/Frameworks/
+
+      [Arthur]
+      nickname: Two Sheds
+      last_name: Jackson
+      my_dir: ${Common:home_dir}/twosheds
+      my_pictures: ${my_dir}/Pictures
+      python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}
 
 Mapping Protocol Access
 -----------------------
@@ -320,19 +389,22 @@
   the default value to be visible again.  Trying to delete a default value
   causes a ``KeyError``.
 
-* Trying to delete the ``DEFAULTSECT`` throws ``ValueError``.
-
-* There are two parser-level methods in the legacy API that hide the dictionary
-  interface and are incompatible:
-
-  * ``parser.get(section, option, **kwargs)`` - the second argument is **not** a
-    fallback value
+* Trying to delete the ``DEFAULTSECT`` raises ``ValueError``.
 
-  * ``parser.items(section)`` - this returns a list of *option*, *value* pairs
-    for a specified ``section``
+* ``parser.get(section, option, **kwargs)`` - the second argument is **not**
+  a fallback value. Note however that the section-level ``get()`` methods are
+  compatible both with the mapping protocol and the classic configparser API.
+
+* ``parser.items()`` is compatible with the mapping protocol (returns a list of
+  *section_name*, *section_proxy* pairs including the DEFAULTSECT).  However,
+  this method can also be invoked with arguments: ``parser.items(section, raw,
+  vars)``. The latter call returns a list of *option*, *value* pairs for
+  a specified ``section``, with all interpolations expanded (unless
+  ``raw=True`` is provided).
 
 The mapping protocol is implemented on top of the existing legacy API so that
-subclassing the original interface makes the mappings work as expected as well.
+subclasses overriding the original interface still should have mappings working
+as expected.
 
 
 Customizing Parser Behaviour
@@ -350,9 +422,9 @@
 * *defaults*, default value: ``None``
 
   This option accepts a dictionary of key-value pairs which will be initially
-  put in the ``DEFAULTSECT``.  This makes for an elegant way to support concise
-  configuration files that don't specify values which are the same as the
-  documented default.
+  put in the ``DEFAULT`` section.  This makes for an elegant way to support
+  concise configuration files that don't specify values which are the same as
+  the documented default.
 
   Hint: if you want to specify default values for a specific section, use
   :meth:`read_dict` before you read the actual file.
@@ -374,7 +446,7 @@
 
   .. doctest::
 
-     >>> parser = configparser.RawConfigParser()
+     >>> parser = configparser.ConfigParser()
      >>> parser.read_dict({'section1': {'key1': 'value1',
      ...                                'key2': 'value2',
      ...                                'key3': 'value3'},
@@ -395,7 +467,7 @@
   .. doctest::
 
      >>> from collections import OrderedDict
-     >>> parser = configparser.RawConfigParser()
+     >>> parser = configparser.ConfigParser()
      >>> parser.read_dict(
      ...   OrderedDict((
      ...     ('s1',
@@ -439,9 +511,10 @@
      ...   skip-external-locking
      ...   old_passwords = 1
      ...   skip-bdb
-     ...   skip-innodb # we don't need ACID today
+     ...   # we don't need ACID today
+     ...   skip-innodb
      ... """
-     >>> config = configparser.RawConfigParser(allow_no_value=True)
+     >>> config = configparser.ConfigParser(allow_no_value=True)
      >>> config.read_string(sample_config)
 
      >>> # Settings with values are treated as before:
@@ -464,30 +537,80 @@
   This means values (but not keys) can contain the delimiters.
 
   See also the *space_around_delimiters* argument to
-  :meth:`RawConfigParser.write`.
+  :meth:`ConfigParser.write`.
 
-* *comment_prefixes*, default value: ``_COMPATIBLE`` (``'#'`` valid on empty
-  lines, ``';'`` valid also on non-empty lines)
+* *comment_prefixes*, default value: ``('#', ';')``
 
-  Comment prefixes are strings that indicate the start of a valid comment
-  within a config file.  The peculiar default value allows for comments starting
-  with ``'#'`` or ``';'`` but only the latter can be used in a non-empty line.
-  This is obviously dictated by backwards compatibiliy.  A more predictable
-  approach would be to specify prefixes as ``('#', ';')`` which will allow for
-  both prefixes to be used in non-empty lines.
+* *inline_comment_prefixes*, default value: ``None``
+
+  Comment prefixes are strings that indicate the start of a valid comment within
+  a config file. *comment_prefixes* are used only on otherwise empty lines
+  (optionally indented) whereas *inline_comment_prefixes* can be used after
+  every valid value (e.g.  section names, options and empty lines as well). By
+  default inline comments are disabled and ``'#'`` and ``';'`` are used as
+  prefixes for whole line comments.
+
+  .. versionchanged:: 3.2
+     In previous versions of :mod:`configparser` behaviour matched
+     ``comment_prefixes=('#',';')`` and ``inline_comment_prefixes=(';',)``.
 
   Please note that config parsers don't support escaping of comment prefixes so
-  leaving characters out of *comment_prefixes* is a way of ensuring they can be
-  used as parts of keys or values.
+  using *inline_comment_prefixes* may prevent users from specifying option
+  values with characters used as comment prefixes. When in doubt, avoid setting
+  *inline_comment_prefixes*. In any circumstances, the only way of storing
+  comment prefix characters at the beginning of a line in multiline values is to
+  interpolate the prefix, for example::
+
+    >>> from configparser import ConfigParser, ExtendedInterpolation
+    >>> parser = ConfigParser(interpolation=ExtendedInterpolation())
+    >>> # the default BasicInterpolation could be used as well
+    >>> parser.read_string("""
+    ... [DEFAULT]
+    ... hash = #
+    ...
+    ... [hashes]
+    ... shebang =
+    ...   ${hash}!/usr/bin/env python
+    ...   ${hash} -*- coding: utf-8 -*-
+    ...
+    ... extensions =
+    ...   enabled_extension
+    ...   another_extension
+    ...   #disabled_by_comment
+    ...   yet_another_extension
+    ...
+    ... interpolation not necessary = if # is not at line start
+    ... even in multiline values = line #1
+    ...   line #2
+    ...   line #3
+    ... """)
+    >>> print(parser['hashes']['shebang'])
+
+    #!/usr/bin/env python
+    # -*- coding: utf-8 -*-
+    >>> print(parser['hashes']['extensions'])
+
+    enabled_extension
+    another_extension
+    yet_another_extension
+    >>> print(parser['hashes']['interpolation not necessary'])
+    if # is not at line start
+    >>> print(parser['hashes']['even in multiline values'])
+    line #1
+    line #2
+    line #3
 
-* *strict*, default value: ``False``
+* *strict*, default value: ``True``
 
-  If set to ``True``, the parser will not allow for any section or option
+  When set to ``True``, the parser will not allow for any section or option
   duplicates while reading from a single source (using :meth:`read_file`,
-  :meth:`read_string` or :meth:`read_dict`).  The default is ``False`` only
-  because of backwards compatibility reasons.  It is recommended to use strict
+  :meth:`read_string` or :meth:`read_dict`). It is recommended to use strict
   parsers in new applications.
 
+  .. versionchanged:: 3.2
+     In previous versions of :mod:`configparser` behaviour matched
+     ``strict=False``.
+
 * *empty_lines_in_values*, default value: ``True``
 
   In config parsers, values can span multiple lines as long as they are
@@ -505,13 +628,35 @@
 
       this = is still a part of the multiline value of 'key'
 
-
   This can be especially problematic for the user to see if she's using a
   proportional font to edit the file.  That is why when your application does
   not need values with empty lines, you should consider disallowing them.  This
   will make empty lines split keys every time.  In the example above, it would
   produce two keys, ``key`` and ``this``.
 
+* *default_section*, default value: ``configparser.DEFAULTSECT`` (that is:
+  ``"DEFAULT"``)
+
+  The convention of allowing a special section of default values for other
+  sections or interpolation purposes is a powerful concept of this library,
+  letting users create complex declarative configurations. This section is
+  normally called ``"DEFAULT"`` but this can be customized to point to any
+  other valid section name. Some typical values include: ``"general"`` or
+  ``"common"``. The name provided is used for recognizing default sections when
+  reading from any source and is used when writing configuration back to
+  a file. Its current value can be retrieved using the
+  ``parser_instance.default_section`` attribute and may be modified at runtime
+  (i.e. to convert files from one format to another).
+
+* *interpolation*, default value: ``configparser.BasicInterpolation``
+
+  Interpolation behaviour may be customized by providing a custom handler
+  through the *interpolation* argument. ``None`` can be used to turn off
+  interpolation completely, ``ExtendedInterpolation()`` provides a more
+  advanced variant inspired by ``zc.buildout``. More on the subject in the
+  `dedicated documentation section <#interpolation-of-values>`_.
+  :class:`RawConfigParser` has a default value of ``None``.
+
 
 More advanced customization may be achieved by overriding default values of
 these parser attributes.  The defaults are defined on the classes, so they
@@ -527,7 +672,7 @@
 
   .. doctest::
 
-     >>> custom = configparser.RawConfigParser()
+     >>> custom = configparser.ConfigParser()
      >>> custom['section1'] = {'funky': 'nope'}
      >>> custom['section1'].getboolean('funky')
      Traceback (most recent call last):
@@ -557,7 +702,7 @@
      ... [Section2]
      ... AnotherKey = Value
      ... """
-     >>> typical = configparser.RawConfigParser()
+     >>> typical = configparser.ConfigParser()
      >>> typical.read_string(config)
      >>> list(typical['Section1'].keys())
      ['key']
@@ -575,11 +720,11 @@
 Legacy API Examples
 -------------------
 
-Mainly because of backwards compatibility concerns, :mod:`configparser` provides
-also a legacy API with explicit ``get``/``set`` methods.  While there are valid
-use cases for the methods outlined below, mapping protocol access is preferred
-for new projects.  The legacy API is at times more advanced, low-level and
-downright counterintuitive.
+Mainly because of backwards compatibility concerns, :mod:`configparser`
+provides also a legacy API with explicit ``get``/``set`` methods.  While there
+are valid use cases for the methods outlined below, mapping protocol access is
+preferred for new projects.  The legacy API is at times more advanced,
+low-level and downright counterintuitive.
 
 An example of writing to a configuration file::
 
@@ -587,12 +732,11 @@
 
    config = configparser.RawConfigParser()
 
-   # Please note that using RawConfigParser's and the raw mode of
-   # ConfigParser's respective set functions, you can assign non-string values
-   # to keys internally, but will receive an error when attempting to write to
-   # a file or when you get it in non-raw mode. Setting values using the
-   # mapping protocol or SafeConfigParser's set() does not allow such
-   # assignments to take place.
+   # Please note that using RawConfigParser's set functions, you can assign
+   # non-string values to keys internally, but will receive an error when
+   # attempting to write to a file or when you get it in non-raw mode. Setting
+   # values using the mapping protocol or ConfigParser's set() does not allow
+   # such assignments to take place.
    config.add_section('Section1')
    config.set('Section1', 'int', '15')
    config.set('Section1', 'bool', 'true')
@@ -623,12 +767,11 @@
    if config.getboolean('Section1', 'bool'):
        print(config.get('Section1', 'foo'))
 
-To get interpolation, use :class:`SafeConfigParser` or, if
-you absolutely have to, a :class:`ConfigParser`::
+To get interpolation, use :class:`ConfigParser`::
 
    import configparser
 
-   cfg = configparser.SafeConfigParser()
+   cfg = configparser.ConfigParser()
    cfg.read('example.cfg')
 
    # Set the optional `raw` argument of get() to True if you wish to disable
@@ -657,13 +800,13 @@
    print(cfg.get('Section1', 'monster', fallback=None))
          # -> None
 
-Default values are available in all three types of ConfigParsers.  They are
-used in interpolation if an option used is not defined elsewhere. ::
+Default values are available in both types of ConfigParsers.  They are used in
+interpolation if an option used is not defined elsewhere. ::
 
    import configparser
 
    # New instance with 'bar' and 'baz' defaulting to 'Life' and 'hard' each
-   config = configparser.SafeConfigParser({'bar': 'Life', 'baz': 'hard'})
+   config = configparser.ConfigParser({'bar': 'Life', 'baz': 'hard'})
    config.read('example.cfg')
 
    print(config.get('Section1', 'foo')) # -> "Python is fun!"
@@ -672,42 +815,62 @@
    print(config.get('Section1', 'foo')) # -> "Life is hard!"
 
 
-.. _rawconfigparser-objects:
+.. _configparser-objects:
 
-RawConfigParser Objects
------------------------
+ConfigParser Objects
+--------------------
 
-.. class:: RawConfigParser(defaults=None, dict_type=collections.OrderedDict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=_COMPATIBLE, strict=False, empty_lines_in_values=True)
+.. class:: ConfigParser(defaults=None, dict_type=collections.OrderedDict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section=configparser.DEFAULTSECT, interpolation=BasicInterpolation())
 
-   The basic configuration parser.  When *defaults* is given, it is initialized
+   The main configuration parser.  When *defaults* is given, it is initialized
    into the dictionary of intrinsic defaults.  When *dict_type* is given, it
    will be used to create the dictionary objects for the list of sections, for
    the options within a section, and for the default values.
 
    When *delimiters* is given, it is used as the set of substrings that
    divide keys from values.  When *comment_prefixes* is given, it will be used
-   as the set of substrings that prefix comments in a line, both for the whole
+   as the set of substrings that prefix comments in otherwise empty lines.
+   Comments can be indented. When *inline_comment_prefixes* is given, it will be
+   used as the set of substrings that prefix comments in non-empty lines.
+
    line and inline comments.  For backwards compatibility, the default value for
    *comment_prefixes* is a special value that indicates that ``;`` and ``#`` can
    start whole line comments while only ``;`` can start inline comments.
 
-   When *strict* is ``True`` (default: ``False``), the parser won't allow for
+   When *strict* is ``True`` (the default), the parser won't allow for
    any section or option duplicates while reading from a single source (file,
    string or dictionary), raising :exc:`DuplicateSectionError` or
    :exc:`DuplicateOptionError`.  When *empty_lines_in_values* is ``False``
    (default: ``True``), each empty line marks the end of an option.  Otherwise,
    internal empty lines of a multiline option are kept as part of the value.
    When *allow_no_value* is ``True`` (default: ``False``), options without
-   values are accepted; the value presented for these is ``None``.
+   values are accepted; the value held for these is ``None`` and they are
+   serialized without the trailing delimiter.
 
-   This class does not support the magical interpolation behavior.
+   When *default_section* is given, it specifies the name for the special
+   section holding default values for other sections and interpolation purposes
+   (normally named ``"DEFAULT"``). This value can be retrieved and changed on
+   runtime using the ``default_section`` instance attribute.
+
+   Interpolation behaviour may be customized by providing a custom handler
+   through the *interpolation* argument. ``None`` can be used to turn off
+   interpolation completely, ``ExtendedInterpolation()`` provides a more
+   advanced variant inspired by ``zc.buildout``. More on the subject in the
+   `dedicated documentation section <#interpolation-of-values>`_.
+
+   All option names used in interpolation will be passed through the
+   :meth:`optionxform` method just like any other option name reference.  For
+   example, using the default implementation of :meth:`optionxform` (which
+   converts option names to lower case), the values ``foo %(bar)s`` and ``foo
+   %(BAR)s`` are equivalent.
 
    .. versionchanged:: 3.1
       The default *dict_type* is :class:`collections.OrderedDict`.
 
    .. versionchanged:: 3.2
-      *allow_no_value*, *delimiters*, *comment_prefixes*, *strict* and
-      *empty_lines_in_values* were added.
+      *allow_no_value*, *delimiters*, *comment_prefixes*, *strict*,
+      *empty_lines_in_values*, *default_section* and *interpolation* were
+      added.
 
 
    .. method:: defaults()
@@ -717,22 +880,25 @@
 
    .. method:: sections()
 
-      Return a list of the sections available; ``DEFAULT`` is not included in
-      the list.
+      Return a list of the sections available; the *default section* is not
+      included in the list.
 
 
    .. method:: add_section(section)
 
       Add a section named *section* to the instance.  If a section by the given
-      name already exists, :exc:`DuplicateSectionError` is raised.  If the name
-      ``DEFAULT`` (or any of it's case-insensitive variants) is passed,
-      :exc:`ValueError` is raised.
+      name already exists, :exc:`DuplicateSectionError` is raised.  If the
+      *default section* name is passed, :exc:`ValueError` is raised.  The name
+      of the section must be a string; if not, :exc:`TypeError` is raised.
+
+      .. versionchanged:: 3.2
+         Non-string section names raise :exc:`TypeError`.
 
 
    .. method:: has_section(section)
 
-      Indicates whether the named section is present in the configuration.  The
-      ``DEFAULT`` section is not acknowledged.
+      Indicates whether the named *section* is present in the configuration.
+      The *default section* is not acknowledged.
 
 
    .. method:: options(section)
@@ -742,23 +908,25 @@
 
    .. method:: has_option(section, option)
 
-      If the given section exists, and contains the given option, return
-      :const:`True`; otherwise return :const:`False`.
+      If the given *section* exists, and contains the given *option*, return
+      :const:`True`; otherwise return :const:`False`. If the specified
+      *section* is :const:`None` or an empty string, DEFAULT is assumed.
 
 
    .. method:: read(filenames, encoding=None)
 
       Attempt to read and parse a list of filenames, returning a list of
       filenames which were successfully parsed.  If *filenames* is a string, it
-      is treated as a single filename.  If a file named in *filenames* cannot be
-      opened, that file will be ignored.  This is designed so that you can
-      specify a list of potential configuration file locations (for example, the
-      current directory, the user's home directory, and some system-wide
-      directory), and all existing configuration files in the list will be read.
-      If none of the named files exist, the :class:`ConfigParser` instance will
-      contain an empty dataset.  An application which requires initial values to
-      be loaded from a file should load the required file or files using
-      :meth:`read_file` before calling :meth:`read` for any optional files::
+      is treated as a single filename.  If a file named in *filenames* cannot
+      be opened, that file will be ignored.  This is designed so that you can
+      specify a list of potential configuration file locations (for example,
+      the current directory, the user's home directory, and some system-wide
+      directory), and all existing configuration files in the list will be
+      read.  If none of the named files exist, the :class:`ConfigParser`
+      instance will contain an empty dataset.  An application which requires
+      initial values to be loaded from a file should load the required file or
+      files using :meth:`read_file` before calling :meth:`read` for any
+      optional files::
 
          import configparser, os
 
@@ -800,17 +968,21 @@
 
    .. method:: read_dict(dictionary, source='<dict>')
 
-      Load configuration from a dictionary.  Keys are section names, values are
-      dictionaries with keys and values that should be present in the section.
-      If the used dictionary type preserves order, sections and their keys will
-      be added in order.  Values are automatically converted to strings.
+      Load configuration from any object that provides a dict-like ``items()``
+      method.  Keys are section names, values are dictionaries with keys and
+      values that should be present in the section.  If the used dictionary
+      type preserves order, sections and their keys will be added in order.
+      Values are automatically converted to strings.
 
       Optional argument *source* specifies a context-specific name of the
       dictionary passed.  If not given, ``<dict>`` is used.
 
+      This method can be used to copy state between parsers.
+
       .. versionadded:: 3.2
 
-   .. method:: get(section, option, [vars, fallback])
+
+   .. method:: get(section, option, raw=False, [vars, fallback])
 
       Get an *option* value for the named *section*.  If *vars* is provided, it
       must be a dictionary.  The *option* is looked up in *vars* (if provided),
@@ -818,58 +990,57 @@
       and *fallback* is provided, it is used as a fallback value.  ``None`` can
       be provided as a *fallback* value.
 
+      All the ``'%'`` interpolations are expanded in the return values, unless
+      the *raw* argument is true.  Values for interpolation keys are looked up
+      in the same manner as the option.
+
       .. versionchanged:: 3.2
-         Arguments *vars* and *fallback* are keyword only to protect users from
-         trying to use the third argument as the *fallback* fallback (especially
-         when using the mapping protocol).
+         Arguments *raw*, *vars* and *fallback* are keyword only to protect
+         users from trying to use the third argument as the *fallback* fallback
+         (especially when using the mapping protocol).
 
 
-   .. method:: getint(section, option, [vars, fallback])
+   .. method:: getint(section, option, raw=False, [vars, fallback])
 
       A convenience method which coerces the *option* in the specified *section*
-      to an integer.  See :meth:`get` for explanation of *vars* and *fallback*.
+      to an integer.  See :meth:`get` for explanation of *raw*, *vars* and
+      *fallback*.
 
 
-   .. method:: getfloat(section, option, [vars, fallback])
+   .. method:: getfloat(section, option, raw=False, [vars, fallback])
 
       A convenience method which coerces the *option* in the specified *section*
-      to a floating point number.  See :meth:`get` for explanation of *vars* and
-      *fallback*.
+      to a floating point number.  See :meth:`get` for explanation of *raw*,
+      *vars* and *fallback*.
 
 
-   .. method:: getboolean(section, option, [vars, fallback])
+   .. method:: getboolean(section, option, raw=False, [vars, fallback])
 
       A convenience method which coerces the *option* in the specified *section*
       to a Boolean value.  Note that the accepted values for the option are
-      ``"1"``, ``"yes"``, ``"true"``, and ``"on"``, which cause this method to
-      return ``True``, and ``"0"``, ``"no"``, ``"false"``, and ``"off"``, which
+      ``'1'``, ``'yes'``, ``'true'``, and ``'on'``, which cause this method to
+      return ``True``, and ``'0'``, ``'no'``, ``'false'``, and ``'off'``, which
       cause it to return ``False``.  These string values are checked in a
       case-insensitive manner.  Any other value will cause it to raise
-      :exc:`ValueError`. See :meth:`get` for explanation of *vars* and
+      :exc:`ValueError`.  See :meth:`get` for explanation of *raw*, *vars* and
       *fallback*.
 
 
-   .. method:: items(section)
+   .. method:: items([section], raw=False, vars=None)
 
-      Return a list of *name*, *value* pairs for each option in the given
-      *section*.
+      When *section* is not given, return a list of *section_name*,
+      *section_proxy* pairs, including DEFAULTSECT.
+
+      Otherwise, return a list of *name*, *value* pairs for the options in the
+      given *section*.  Optional arguments have the same meaning as for the
+      :meth:`get` method.
 
 
    .. method:: set(section, option, value)
 
       If the given section exists, set the given option to the specified value;
-      otherwise raise :exc:`NoSectionError`.  While it is possible to use
-      :class:`RawConfigParser` (or :class:`ConfigParser` with *raw* parameters
-      set to true) for *internal* storage of non-string values, full
-      functionality (including interpolation and output to files) can only be
-      achieved using string values.
-
-      .. note::
-
-         This method lets users assign non-string values to keys internally.
-         This behaviour is unsupported and will cause errors when attempting to
-         write to a file or get it in non-raw mode.  **Use the mapping protocol
-         API** which does not allow such assignments to take place.
+      otherwise raise :exc:`NoSectionError`.  *option* and *value* must be
+      strings; if not, :exc:`TypeError` is raised.
 
 
    .. method:: write(fileobject, space_around_delimiters=True)
@@ -921,134 +1092,52 @@
          Use :meth:`read_file` instead.
 
 
-.. _configparser-objects:
-
-ConfigParser Objects
---------------------
-
-.. warning::
-   Whenever you can, consider using :class:`SafeConfigParser` which adds
-   validation and escaping for the interpolation.
-
-The :class:`ConfigParser` class extends some methods of the
-:class:`RawConfigParser` interface, adding some optional arguments.
-
-.. class:: ConfigParser(defaults=None, dict_type=collections.OrderedDict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=_COMPATIBLE, strict=False, empty_lines_in_values=True)
-
-   Derived class of :class:`RawConfigParser` that implements the magical
-   interpolation feature and adds optional arguments to the :meth:`get` and
-   :meth:`items` methods.
-
-   :class:`SafeConfigParser` is generally recommended over this class if you
-   need interpolation.
-
-   The values in *defaults* must be appropriate for the ``%()s`` string
-   interpolation.
-
-   All option names used in interpolation will be passed through the
-   :meth:`optionxform` method just like any other option name reference.  For
-   example, using the default implementation of :meth:`optionxform` (which
-   converts option names to lower case), the values ``foo %(bar)s`` and ``foo
-   %(BAR)s`` are equivalent.
-
-   .. versionchanged:: 3.1
-      The default *dict_type* is :class:`collections.OrderedDict`.
-
-   .. versionchanged:: 3.2
-      *allow_no_value*, *delimiters*, *comment_prefixes*,
-      *strict* and *empty_lines_in_values* were added.
-
-
-   .. method:: get(section, option, raw=False, [vars, fallback])
-
-      Get an *option* value for the named *section*.  If *vars* is provided, it
-      must be a dictionary.  The *option* is looked up in *vars* (if provided),
-      *section*, and in *DEFAULTSECT* in that order.  If the key is not found
-      and *fallback* is provided, it is used as a fallback value.  ``None`` can
-      be provided as a *fallback* value.
-
-      All the ``'%'`` interpolations are expanded in the return values, unless
-      the *raw* argument is true.  Values for interpolation keys are looked up
-      in the same manner as the option.
-
-      .. versionchanged:: 3.2
-         Arguments *raw*, *vars* and *fallback* are keyword only to protect
-         users from trying to use the third argument as the *fallback* fallback
-         (especially when using the mapping protocol).
-
-
-   .. method:: getint(section, option, raw=False, [vars, fallback])
-
-      A convenience method which coerces the *option* in the specified *section*
-      to an integer.  See :meth:`get` for explanation of *raw*, *vars* and
-      *fallback*.
-
-
-   .. method:: getfloat(section, option, raw=False, [vars, fallback])
-
-      A convenience method which coerces the *option* in the specified *section*
-      to a floating point number.  See :meth:`get` for explanation of *raw*,
-      *vars* and *fallback*.
-
-
-   .. method:: getboolean(section, option, raw=False, [vars, fallback])
-
-      A convenience method which coerces the *option* in the specified *section*
-      to a Boolean value.  Note that the accepted values for the option are
-      ``'1'``, ``'yes'``, ``'true'``, and ``'on'``, which cause this method to
-      return ``True``, and ``'0'``, ``'no'``, ``'false'``, and ``'off'``, which
-      cause it to return ``False``.  These string values are checked in a
-      case-insensitive manner.  Any other value will cause it to raise
-      :exc:`ValueError`.  See :meth:`get` for explanation of *raw*, *vars* and
-      *fallback*.
-
-
-   .. method:: items(section, raw=False, vars=None)
-
-      Return a list of *name*, *value* pairs for the options in the given
-      *section*.  Optional arguments have the same meaning as for the
-      :meth:`get` method.
-
-
 .. data:: MAX_INTERPOLATION_DEPTH
 
    The maximum depth for recursive interpolation for :meth:`get` when the *raw*
-   parameter is false.  This is relevant only for the :class:`ConfigParser` class.
+   parameter is false.  This is relevant only when the default *interpolation*
+   is used.
 
 
-.. _safeconfigparser-objects:
+.. _rawconfigparser-objects:
 
-SafeConfigParser Objects
-------------------------
+RawConfigParser Objects
+-----------------------
 
-.. class:: SafeConfigParser(defaults=None, dict_type=collections.OrderedDict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=_COMPATIBLE, strict=False, empty_lines_in_values=True)
+.. class:: RawConfigParser(defaults=None, dict_type=collections.OrderedDict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section=configaparser.DEFAULTSECT, interpolation=None)
 
-   Derived class of :class:`ConfigParser` that implements a variant of the
-   magical interpolation feature.  This implementation is more predictable as
-   it validates the interpolation syntax used within a configuration file.
-   This class also enables escaping the interpolation character (a key can have
-   ``%`` as part of the value by specifying ``%%`` in the file).
+   Legacy variant of the :class:`ConfigParser` with interpolation disabled
+   by default and unsafe ``add_section`` and ``set`` methods.
 
-   Applications that don't require interpolation should use
-   :class:`RawConfigParser`, otherwise :class:`SafeConfigParser` is the best
-   option.
+   .. note::
+      Consider using :class:`ConfigParser` instead which checks types of
+      the values to be stored internally. If you don't want interpolation, you
+      can use ``ConfigParser(interpolation=None)``.
 
-   .. versionchanged:: 3.1
-      The default *dict_type* is :class:`collections.OrderedDict`.
 
-   .. versionchanged:: 3.2
-      *allow_no_value*, *delimiters*, *comment_prefixes*, *strict* and
-      *empty_lines_in_values* were added.
+   .. method:: add_section(section)
 
+      Add a section named *section* to the instance.  If a section by the given
+      name already exists, :exc:`DuplicateSectionError` is raised.  If the
+      *default section* name is passed, :exc:`ValueError` is raised.
+
+      Type of *section* is not checked which lets users create non-string named
+      sections. This behaviour is unsupported and may cause internal errors.
 
-   The :class:`SafeConfigParser` class implements the same extended interface
-   as :class:`ConfigParser`, with the following addition:
 
    .. method:: set(section, option, value)
 
       If the given section exists, set the given option to the specified value;
-      otherwise raise :exc:`NoSectionError`.  *value* must be a string; if not,
-      :exc:`TypeError` is raised.
+      otherwise raise :exc:`NoSectionError`.  While it is possible to use
+      :class:`RawConfigParser` (or :class:`ConfigParser` with *raw* parameters
+      set to true) for *internal* storage of non-string values, full
+      functionality (including interpolation and output to files) can only be
+      achieved using string values.
+
+      This method lets users assign non-string values to keys internally.  This
+      behaviour is unsupported and will cause errors when attempting to write
+      to a file or get it in non-raw mode.  **Use the mapping protocol API**
+      which does not allow such assignments to take place.
 
 
 Exceptions

Modified: python/branches/py3k-cdecimal/Doc/library/ctypes.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/ctypes.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/ctypes.rst	Sun Jan  2 13:18:37 2011
@@ -1930,22 +1930,6 @@
    but it is possible to enlarge the buffer.
 
 
-.. function:: set_conversion_mode(encoding, errors)
-
-   This function sets the rules that ctypes objects use when converting between
-   bytes objects and (unicode) strings. *encoding* must be a string specifying an
-   encoding, like ``'utf-8'`` or ``'mbcs'``, *errors* must be a string specifying
-   the error handling on encoding/decoding errors. Examples of possible values are
-   ``'strict'``, ``'replace'``, or ``'ignore'``.
-
-   :func:`set_conversion_mode` returns a 2-tuple containing the previous
-   conversion rules. On windows, the initial conversion rules are ``('mbcs',
-   'ignore')``, on other systems ``('ascii', 'strict')``.
-
-   You can set the *encoding* to ``'undefined'`` to completely disable automatic
-   conversions.
-
-
 .. function:: set_errno(value)
 
    Set the current value of the ctypes-private copy of the system :data:`errno`

Modified: python/branches/py3k-cdecimal/Doc/library/curses.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/curses.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/curses.rst	Sun Jan  2 13:18:37 2011
@@ -49,7 +49,7 @@
       Tutorial material on using curses with Python, by Andrew Kuchling and Eric
       Raymond.
 
-   The :file:`Demo/curses/` directory in the Python source distribution contains
+   The :file:`Tools/demo/` directory in the Python source distribution contains
    some example programs using the curses bindings provided by this module.
 
 

Modified: python/branches/py3k-cdecimal/Doc/library/dbm.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/dbm.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/dbm.rst	Sun Jan  2 13:18:37 2011
@@ -20,7 +20,7 @@
 
 .. function:: whichdb(filename)
 
-   This functionattempts to guess which of the several simple database modules
+   This function attempts to guess which of the several simple database modules
    available --- :mod:`dbm.gnu`, :mod:`dbm.ndbm` or :mod:`dbm.dumb` --- should
    be used to open a given file.
 
@@ -61,10 +61,15 @@
    modified by the prevailing umask).
 
 
-The object returned by :func:`.open` supports most of the same functionality as
+The object returned by :func:`.open` supports the same basic functionality as
 dictionaries; keys and their corresponding values can be stored, retrieved, and
 deleted, and the :keyword:`in` operator and the :meth:`keys` method are
-available. Key and values are always stored as bytes. This means that when
+available, as well as :meth:`get` and :meth:`setdefault`.
+
+.. versionchanged:: 3.2
+   :meth:`get` and :meth:`setdefault` are now available in all database modules.
+
+Key and values are always stored as bytes. This means that when
 strings are used they are implicitly converted to the default encoding before
 being stored.
 
@@ -86,10 +91,8 @@
    # Notice how the value is now in bytes.
    assert db['www.cnn.com'] == b'Cable News Network'
 
-   # Loop through contents.  Other dictionary methods
-   # such as .keys(), .values() also work.
-   for k, v in db.iteritems():
-       print(k, '\t', v)
+   # Often-used methods of the dict interface work too.
+   print(db.get('python.org', b'not present'))
 
    # Storing a non-string key or value will raise an exception (most
    # likely a TypeError).

Modified: python/branches/py3k-cdecimal/Doc/library/difflib.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/difflib.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/difflib.rst	Sun Jan  2 13:18:37 2011
@@ -17,6 +17,7 @@
 information in various formats, including HTML and context and unified
 diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
 
+
 .. class:: SequenceMatcher
 
    This is a flexible class for comparing pairs of sequences of any type, so long
@@ -35,6 +36,17 @@
    complicated way on how many elements the sequences have in common; best case
    time is linear.
 
+   **Automatic junk heuristic:** :class:`SequenceMatcher` supports a heuristic that
+   automatically treats certain sequence items as junk. The heuristic counts how many
+   times each individual item appears in the sequence. If an item's duplicates (after
+   the first one) account for more than 1% of the sequence and the sequence is at least
+   200 items long, this item is marked as "popular" and is treated as junk for
+   the purpose of sequence matching. This heuristic can be turned off by setting
+   the ``autojunk`` argument to ``False`` when creating the :class:`SequenceMatcher`.
+
+   .. versionadded:: 3.2
+      The *autojunk* parameter.
+
 
 .. class:: Differ
 
@@ -324,7 +336,7 @@
 The :class:`SequenceMatcher` class has this constructor:
 
 
-.. class:: SequenceMatcher(isjunk=None, a='', b='')
+.. class:: SequenceMatcher(isjunk=None, a='', b='', autojunk=True)
 
    Optional argument *isjunk* must be ``None`` (the default) or a one-argument
    function that takes a sequence element and returns true if and only if the
@@ -340,8 +352,23 @@
    The optional arguments *a* and *b* are sequences to be compared; both default to
    empty strings.  The elements of both sequences must be :term:`hashable`.
 
-   :class:`SequenceMatcher` objects have the following methods:
+   The optional argument *autojunk* can be used to disable the automatic junk
+   heuristic.
 
+   .. versionadded:: 3.2
+      The *autojunk* parameter.
+
+   SequenceMatcher objects get three data attributes: *bjunk* is the
+   set of elements of *b* for which *isjunk* is True; *bpopular* is the set of
+   non-junk elements considered popular by the heuristic (if it is not
+   disabled); *b2j* is a dict mapping the remaining elements of *b* to a list
+   of positions where they occur. All three are reset whenever *b* is reset
+   with :meth:`set_seqs` or :meth:`set_seq2`.
+
+   .. versionadded:: 3.2
+      The *bjunk* and *bpopular* attributes.
+
+   :class:`SequenceMatcher` objects have the following methods:
 
    .. method:: set_seqs(a, b)
 
@@ -520,7 +547,7 @@
 SequenceMatcher Examples
 ------------------------
 
-This example compares two strings, considering blanks to be "junk:"
+This example compares two strings, considering blanks to be "junk":
 
    >>> s = SequenceMatcher(lambda x: x == " ",
    ...                     "private Thread currentThread;",

Modified: python/branches/py3k-cdecimal/Doc/library/dis.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/dis.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/dis.rst	Sun Jan  2 13:18:37 2011
@@ -733,11 +733,6 @@
    Used by the :keyword:`del` statement.
 
 
-.. opcode:: SET_LINENO (lineno)
-
-   This opcode is obsolete.
-
-
 .. opcode:: RAISE_VARARGS (argc)
 
    Raises an exception. *argc* indicates the number of parameters to the raise

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	Sun Jan  2 13:18:37 2011
@@ -922,7 +922,7 @@
 
    def load_tests(loader, tests, ignore):
        tests.addTests(doctest.DocTestSuite(my_module_with_doctests))
-       return test
+       return tests
 
 There are two main functions for creating :class:`unittest.TestSuite` instances
 from text files and modules with doctests:

Modified: python/branches/py3k-cdecimal/Doc/library/email.header.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/email.header.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/email.header.rst	Sun Jan  2 13:18:37 2011
@@ -63,7 +63,7 @@
    character set is used both as *s*'s initial charset and as the default for
    subsequent :meth:`append` calls.
 
-   The maximum line length can be specified explicit via *maxlinelen*.  For
+   The maximum line length can be specified explicitly via *maxlinelen*.  For
    splitting the first line to a shorter value (to account for the field header
    which isn't included in *s*, e.g. :mailheader:`Subject`) pass in the name of the
    field in *header_name*.  The default *maxlinelen* is 76, and the default value

Modified: python/branches/py3k-cdecimal/Doc/library/email.message.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/email.message.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/email.message.rst	Sun Jan  2 13:18:37 2011
@@ -270,7 +270,15 @@
       taken as the parameter name, with underscores converted to dashes (since
       dashes are illegal in Python identifiers).  Normally, the parameter will
       be added as ``key="value"`` unless the value is ``None``, in which case
-      only the key will be added.
+      only the key will be added.  If the value contains non-ASCII characters,
+      it can be specified as a three tuple in the format
+      ``(CHARSET, LANGUAGE, VALUE)``, where ``CHARSET`` is a string naming the
+      charset to be used to encode the value, ``LANGUAGE`` can usually be set
+      to ``None`` or the empty string (see :rfc:`2231` for other possibilities),
+      and ``VALUE`` is the string value containing non-ASCII code points.  If
+      a three tuple is not passed and the value contains non-ASCII characters,
+      it is automatically encoded in :rfc:`2231` format using a ``CHARSET``
+      of ``utf-8`` and a ``LANGUAGE`` of ``None``.
 
       Here's an example::
 
@@ -280,6 +288,15 @@
 
          Content-Disposition: attachment; filename="bud.gif"
 
+      An example with with non-ASCII characters::
+
+         msg.add_header('Content-Disposition', 'attachment',
+                        filename=('iso-8859-1', '', 'Fußballer.ppt'))
+
+      Which produces ::
+
+         Content-Disposition: attachment; filename*="iso-8859-1''Fu%DFballer.ppt"
+
 
    .. method:: replace_header(_name, _value)
 
@@ -369,7 +386,7 @@
       :rfc:`2231`, you can collapse the parameter value by calling
       :func:`email.utils.collapse_rfc2231_value`, passing in the return value
       from :meth:`get_param`.  This will return a suitably decoded Unicode
-      string whn the value is a tuple, or the original string unquoted if it
+      string when the value is a tuple, or the original string unquoted if it
       isn't.  For example::
 
          rawparam = msg.get_param('foo')

Modified: python/branches/py3k-cdecimal/Doc/library/email.util.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/email.util.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/email.util.rst	Sun Jan  2 13:18:37 2011
@@ -105,11 +105,17 @@
    ``False``.  The default is ``False``.
 
 
-.. function:: make_msgid(idstring=None)
+.. function:: make_msgid(idstring=None, domain=None)
 
    Returns a string suitable for an :rfc:`2822`\ -compliant
    :mailheader:`Message-ID` header.  Optional *idstring* if given, is a string
-   used to strengthen the uniqueness of the message id.
+   used to strengthen the uniqueness of the message id.  Optional *domain* if
+   given provides the portion of the msgid after the '@'.  The default is the
+   local hostname.  It is not normally necessary to override this default, but
+   may be useful certain cases, such as a constructing distributed system that
+   uses a consistent domain name across multiple hosts.
+
+   .. versionchanged:: 3.2 domain keyword added
 
 
 .. function:: decode_rfc2231(s)

Modified: python/branches/py3k-cdecimal/Doc/library/exceptions.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/exceptions.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/exceptions.rst	Sun Jan  2 13:18:37 2011
@@ -63,6 +63,12 @@
    :exc:`FloatingPointError`.
 
 
+.. exception:: BufferError
+
+   Raised when a :ref:`buffer <bufferobjects>` related operation cannot be
+   performed.
+
+
 .. exception:: LookupError
 
    The base class for the exceptions that are raised when a key or index used on
@@ -257,6 +263,18 @@
    of the exception instance returns only the message.
 
 
+.. exception:: IndentationError
+
+   Base class for syntax errors related to incorrect indentation.  This is a
+   subclass of :exc:`SyntaxError`.
+
+
+.. exception:: TabError
+
+   Raised when indentation contains an inconsistent use of tabs and spaces.
+   This is a subclass of :exc:`IndentationError`.
+
+
 .. exception:: SystemError
 
    Raised when the interpreter finds an internal error, but the situation does not

Modified: python/branches/py3k-cdecimal/Doc/library/fileformats.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/fileformats.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/fileformats.rst	Sun Jan  2 13:18:37 2011
@@ -5,7 +5,7 @@
 ************
 
 The modules described in this chapter parse various miscellaneous file formats
-that aren't markup languages or are related to e-mail.
+that aren't markup languages and are not related to e-mail.
 
 
 .. toctree::

Modified: python/branches/py3k-cdecimal/Doc/library/functions.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/functions.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/functions.rst	Sun Jan  2 13:18:37 2011
@@ -7,6 +7,24 @@
 The Python interpreter has a number of functions and types built into it that
 are always available.  They are listed here in alphabetical order.
 
+===================  =================  ==================  ================  ====================
+..                   ..                 Built-in Functions  ..                ..
+===================  =================  ==================  ================  ====================
+:func:`abs`          :func:`dict`       :func:`help`        :func:`min`       :func:`setattr`
+:func:`all`          :func:`dir`        :func:`hex`         :func:`next`      :func:`slice`
+:func:`any`          :func:`divmod`     :func:`id`          :func:`object`    :func:`sorted`
+:func:`ascii`        :func:`enumerate`  :func:`input`       :func:`oct`       :func:`staticmethod`
+:func:`bin`          :func:`eval`       :func:`int`         :func:`open`      :func:`str`
+:func:`bool`         :func:`exec`       :func:`isinstance`  :func:`ord`       :func:`sum`
+:func:`bytearray`    :func:`filter`     :func:`issubclass`  :func:`pow`       :func:`super`
+:func:`bytes`        :func:`float`      :func:`iter`        :func:`print`     :func:`tuple`
+:func:`callable`     :func:`format`     :func:`len`         :func:`property`  :func:`type`
+:func:`chr`          :func:`frozenset`  :func:`list`        :func:`range`     :func:`vars`
+:func:`classmethod`  :func:`getattr`    :func:`locals`      :func:`repr`      :func:`zip`
+:func:`compile`      :func:`globals`    :func:`map`         :func:`reversed`  :func:`__import__`
+:func:`complex`      :func:`hasattr`    :func:`max`         :func:`round`
+:func:`delattr`      :func:`hash`       :func:`memoryview`  :func:`set`
+===================  =================  ==================  ================  ====================
 
 .. function:: abs(x)
 
@@ -103,6 +121,19 @@
    Bytes objects can also be created with literals, see :ref:`strings`.
 
 
+.. function:: callable(object)
+
+   Return :const:`True` if the *object* argument appears callable,
+   :const:`False` if not.  If this returns true, it is still possible that a
+   call fails, but if it is false, calling *object* will never succeed.
+   Note that classes are callable (calling a class returns a new instance);
+   instances are callable if their class has a :meth:`__call__` method.
+
+   .. versionadded:: 3.2
+      This function was first removed in Python 3.0 and then brought back
+      in Python 3.2.
+
+
 .. function:: chr(i)
 
    Return the string representing a character whose Unicode codepoint is the integer
@@ -143,7 +174,7 @@
    type hierarchy in :ref:`types`.
 
 
-.. function:: compile(source, filename, mode, flags=0, dont_inherit=False)
+.. function:: compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)
 
    Compile the *source* into a code or AST object.  Code objects can be executed
    by :func:`exec` or :func:`eval`.  *source* can either be a string or an AST
@@ -175,6 +206,12 @@
    can be found as the :attr:`compiler_flag` attribute on the :class:`_Feature`
    instance in the :mod:`__future__` module.
 
+   The argument *optimize* specifies the optimization level of the compiler; the
+   default value of ``-1`` selects the optimization level of the interpreter as
+   given by :option:`-O` options.  Explicit levels are ``0`` (no optimization;
+   ``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false)
+   or ``2`` (docstrings are removed too).
+
    This function raises :exc:`SyntaxError` if the compiled source is invalid,
    and :exc:`TypeError` if the source contains null bytes.
 
@@ -187,7 +224,7 @@
 
    .. versionchanged:: 3.2
       Allowed use of Windows and Mac newlines.  Also input in ``'exec'`` mode
-      does not have to end in a newline anymore.
+      does not have to end in a newline anymore.  Added the *optimize* parameter.
 
 
 .. function:: complex([real[, imag]])
@@ -417,8 +454,8 @@
       sign: "+" | "-"
       infinity: "Infinity" | "inf"
       nan: "nan"
-      numeric-value: `floatnumber` | `infinity` | `nan`
-      numeric-string: [`sign`] `numeric-value`
+      numeric_value: `floatnumber` | `infinity` | `nan`
+      numeric_string: [`sign`] `numeric_value`
 
    Here ``floatnumber`` is the form of a Python floating-point literal,
    described in :ref:`floating`.  Case is not significant, so, for example,
@@ -992,8 +1029,33 @@
       >>> list(range(1, 0))
       []
 
+   Range objects implement the :class:`collections.Sequence` ABC, and provide
+   features such as containment tests, element index lookup, slicing and
+   support for negative indices:
+
+      >>> r = range(0, 20, 2)
+      >>> r
+      range(0, 20, 2)
+      >>> 11 in r
+      False
+      >>> 10 in r
+      True
+      >>> r.index(10)
+      5
+      >>> r[5]
+      10
+      >>> r[:5]
+      range(0, 10, 2)
+      >>> r[-1]
+      18
+
+   Ranges containing absolute values larger than :data:`sys.maxsize` are permitted
+   but some features (such as :func:`len`) will raise :exc:`OverflowError`.
+
    .. versionchanged:: 3.2
-      Testing integers for membership takes constant time instead of iterating
+      Implement the Sequence ABC.
+      Support slicing and negative indices.
+      Test integers for membership in constant time instead of iterating
       through all items.
 
 

Modified: python/branches/py3k-cdecimal/Doc/library/functools.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/functools.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/functools.rst	Sun Jan  2 13:18:37 2011
@@ -32,7 +32,7 @@
    A compare function is any callable that accept two arguments, compares them,
    and returns a negative number for less-than, zero for equality, or a positive
    number for greater-than.  A key function is a callable that accepts one
-   argument and returns another value that indicates the position in the desired
+   argument and returns another value indicating the position in the desired
    collation sequence.
 
    Example::
@@ -42,37 +42,76 @@
    .. versionadded:: 3.2
 
 
-.. decorator:: lru_cache(maxsize)
+.. decorator:: lru_cache(maxsize=100)
 
    Decorator to wrap a function with a memoizing callable that saves up to the
    *maxsize* most recent calls.  It can save time when an expensive or I/O bound
    function is periodically called with the same arguments.
 
-   The *maxsize* parameter defaults to 100.  Since a dictionary is used to cache
-   results, the positional and keyword arguments to the function must be
-   hashable.
-
-   The wrapped function is instrumented with two attributes, :attr:`cache_hits`
-   and :attr:`cache_misses` which count the number of successful or unsuccessful
-   cache lookups.  These statistics are helpful for tuning the *maxsize*
-   parameter and for measuring the cache's effectiveness.
+   Since a dictionary is used to cache results, the positional and keyword
+   arguments to the function must be hashable.
 
-   The wrapped function also has a :attr:`cache_clear` attribute which can be
-   called (with no arguments) to clear the cache.
+   If *maxsize* is set to None, the LRU feature is disabled and the cache
+   can grow without bound.
+
+   To help measure the effectiveness of the cache and tune the *maxsize*
+   parameter, the wrapped function is instrumented with a :func:`cache_info`
+   function that returns a :term:`named tuple` showing *hits*, *misses*,
+   *maxsize* and *currsize*.  In a multi-threaded environment, the hits
+   and misses are approximate.
+
+   The decorator also provides a :func:`cache_clear` function for clearing or
+   invalidating the cache.
 
    The original underlying function is accessible through the
-   :attr:`__wrapped__` attribute.  This allows introspection, bypassing
-   the cache, or rewrapping the function with a different caching tool.
+   :attr:`__wrapped__` attribute.  This is useful for introspection, for
+   bypassing the cache, or for rewrapping the function with a different cache.
 
-   A `LRU (least recently used) cache
-   <http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used>`_
-   is indicated when the pattern of calls changes over time, such as
-   when more recent calls are the best predictors of upcoming calls
-   (for example, the most popular articles on a news server tend to
-   change every day).
+   An `LRU (least recently used) cache
+   <http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used>`_ works
+   best when more recent calls are the best predictors of upcoming calls (for
+   example, the most popular articles on a news server tend to change daily).
+   The cache's size limit assures that the cache does not grow without bound on
+   long-running processes such as web servers.
+
+   Example of an LRU cache for static web content::
+
+        @lru_cache(maxsize=20)
+        def get_pep(num):
+            'Retrieve text of a Python Enhancement Proposal'
+            resource = 'http://www.python.org/dev/peps/pep-%04d/' % num
+            try:
+                with urllib.request.urlopen(resource) as s:
+                    return s.read()
+            except urllib.error.HTTPError:
+                return 'Not Found'
+
+        >>> for n in 8, 290, 308, 320, 8, 218, 320, 279, 289, 320, 9991:
+        ...     pep = get_pep(n)
+        ...     print(n, len(pep))
+
+        >>> print(get_pep.cache_info())
+        CacheInfo(hits=3, misses=8, maxsize=20, currsize=8)
+
+   Example of efficiently computing
+   `Fibonacci numbers <http://en.wikipedia.org/wiki/Fibonacci_number>`_
+   using a cache to implement a
+   `dynamic programming <http://en.wikipedia.org/wiki/Dynamic_programming>`_
+   technique::
+
+        @lru_cache(maxsize=None)
+        def fib(n):
+            if n < 2:
+                return n
+            return fib(n-1) + fib(n-2)
 
-   .. versionadded:: 3.2
+        >>> print([fib(n) for n in range(16)])
+        [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
 
+        >>> print(fib.cache_info())
+        CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)
+
+   .. versionadded:: 3.2
 
 .. decorator:: total_ordering
 

Modified: python/branches/py3k-cdecimal/Doc/library/grp.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/grp.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/grp.rst	Sun Jan  2 13:18:37 2011
@@ -30,7 +30,9 @@
 The gid is an integer, name and password are strings, and the member list is a
 list of strings. (Note that most users are not explicitly listed as members of
 the group they are in according to the password database.  Check both databases
-to get complete membership information.)
+to get complete membership information.  Also note that a ``gr_name`` that
+starts with a ``+`` or ``-`` is likely to be a YP/NIS reference and may not be
+accessible via :func:`getgrnam` or :func:`getgrgid`.)
 
 It defines the following items:
 

Modified: python/branches/py3k-cdecimal/Doc/library/hashlib.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/hashlib.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/hashlib.rst	Sun Jan  2 13:18:37 2011
@@ -135,7 +135,7 @@
 .. method:: hash.digest()
 
    Return the digest of the data passed to the :meth:`update` method so far.
-   This is a bytes array of size :attr:`digest_size` which may contain bytes in
+   This is a bytes object of size :attr:`digest_size` which may contain bytes in
    the whole range from 0 to 255.
 
 

Modified: python/branches/py3k-cdecimal/Doc/library/heapq.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/heapq.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/heapq.rst	Sun Jan  2 13:18:37 2011
@@ -16,11 +16,12 @@
    Latest version of the :source:`heapq Python source code
    <Lib/heapq.py>`
 
-Heaps are arrays for which ``heap[k] <= heap[2*k+1]`` and ``heap[k] <=
-heap[2*k+2]`` for all *k*, counting elements from zero.  For the sake of
-comparison, non-existing elements are considered to be infinite.  The
-interesting property of a heap is that ``heap[0]`` is always its smallest
-element.
+Heaps are binary trees for which every parent node has a value less than or
+equal to any of its children.  This implementation uses arrays for which
+``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k*, counting
+elements from zero.  For the sake of comparison, non-existing elements are
+considered to be infinite.  The interesting property of a heap is that its
+smallest element is always the root, ``heap[0]``.
 
 The API below differs from textbook heap algorithms in two aspects: (a) We use
 zero-based indexing.  This makes the relationship between the index for a node

Modified: python/branches/py3k-cdecimal/Doc/library/html.parser.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/html.parser.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/html.parser.rst	Sun Jan  2 13:18:37 2011
@@ -12,9 +12,13 @@
 This module defines a class :class:`HTMLParser` which serves as the basis for
 parsing text files formatted in HTML (HyperText Mark-up Language) and XHTML.
 
-.. class:: HTMLParser()
+.. class:: HTMLParser(strict=True)
 
-   The :class:`HTMLParser` class is instantiated without arguments.
+   Create a parser instance.  If *strict* is ``True`` (the default), invalid
+   html results in :exc:`~html.parser.HTMLParseError` exceptions [#]_.  If
+   *strict* is ``False``, the parser uses heuristics to make a best guess at
+   the intention of any invalid html it encounters, similar to the way most
+   browsers do.
 
    An :class:`HTMLParser` instance is fed HTML data and calls handler functions when tags
    begin and end.  The :class:`HTMLParser` class is meant to be overridden by the
@@ -23,6 +27,8 @@
    This parser does not check that end tags match start tags or call the end-tag
    handler for elements which are closed implicitly by closing an outer element.
 
+   .. versionchanged:: 3.2 *strict* keyword added
+
 An exception is defined as well:
 
 
@@ -191,3 +197,8 @@
    Encountered a html end tag
 
 
+.. rubric:: Footnotes
+
+.. [#] For backward compatibility reasons *strict* mode does not raise
+       exceptions for all non-compliant HTML.  That is, some invalid HTML
+       is tolerated even in *strict* mode.

Modified: python/branches/py3k-cdecimal/Doc/library/http.client.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/http.client.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/http.client.rst	Sun Jan  2 13:18:37 2011
@@ -23,16 +23,13 @@
 The module provides the following classes:
 
 
-.. class:: HTTPConnection(host, port=None, strict=None[, timeout[, source_address]])
+.. class:: HTTPConnection(host, port=None[, strict[, timeout[, source_address]]])
 
    An :class:`HTTPConnection` instance represents one transaction with an HTTP
    server.  It should be instantiated passing it a host and optional port
    number.  If no port number is passed, the port is extracted from the host
    string if it has the form ``host:port``, else the default HTTP port (80) is
-   used.  When True, the optional parameter *strict* (which defaults to a false
-   value) causes ``BadStatusLine`` to
-   be raised if the status line can't be parsed as a valid HTTP/1.0 or 1.1
-   status line.  If the optional *timeout* parameter is given, blocking
+   used.  If the optional *timeout* parameter is given, blocking
    operations (like connection attempts) will timeout after that many seconds
    (if it is not given, the global default timeout setting is used).
    The optional *source_address* parameter may be a typle of a (host, port)
@@ -49,8 +46,12 @@
    .. versionchanged:: 3.2
       *source_address* was added.
 
+   .. versionchanged:: 3.2
+      The *strict* parameter is deprecated.  HTTP 0.9-style "Simple Responses"
+      are not supported anymore.
+
 
-.. class:: HTTPSConnection(host, port=None, key_file=None, cert_file=None, strict=None[, timeout[, source_address]], *, context=None, check_hostname=None)
+.. class:: HTTPSConnection(host, port=None, key_file=None, cert_file=None[, strict[, timeout[, source_address]]], *, context=None, check_hostname=None)
 
    A subclass of :class:`HTTPConnection` that uses SSL for communication with
    secure servers.  Default port is ``443``.  If *context* is specified, it
@@ -80,12 +81,20 @@
       This class now supports HTTPS virtual hosts if possible (that is,
       if :data:`ssl.HAS_SNI` is true).
 
+   .. versionchanged:: 3.2
+      The *strict* parameter is deprecated.  HTTP 0.9-style "Simple Responses"
+      are not supported anymore.
+
 
-.. class:: HTTPResponse(sock, debuglevel=0, strict=0, method=None, url=None)
+.. class:: HTTPResponse(sock, debuglevel=0[, strict], method=None, url=None)
 
    Class whose instances are returned upon successful connection.  Not
    instantiated directly by user.
 
+   .. versionchanged:: 3.2
+      The *strict* parameter is deprecated.  HTTP 0.9-style "Simple Responses"
+      are not supported anymore.
+
 
 The following exceptions are raised as appropriate:
 
@@ -384,14 +393,18 @@
    string.
 
    The *body* may also be an open :term:`file object`, in which case the
-   contents of the file is sent; this file object should support
-   ``fileno()`` and ``read()`` methods. The header Content-Length is
-   automatically set to the length of the file as reported by
-   stat.
+   contents of the file is sent; this file object should support ``fileno()``
+   and ``read()`` methods. The header Content-Length is automatically set to
+   the length of the file as reported by stat. The *body* argument may also be
+   an iterable and Contet-Length header should be explicitly provided when the
+   body is an iterable.
 
    The *headers* argument should be a mapping of extra HTTP
    headers to send with the request.
 
+   .. versionadded:: 3.2
+      *body* can now be an iterable.
+
 .. method:: HTTPConnection.getresponse()
 
    Should be called after a request is sent to get the response from the server.
@@ -405,8 +418,10 @@
 
 .. method:: HTTPConnection.set_debuglevel(level)
 
-   Set the debugging level (the amount of debugging output printed). The default
-   debug level is ``0``, meaning no debugging output is printed.
+   Set the debugging level.  The default debug level is ``0``, meaning no
+   debugging output is printed.  Any value greater than ``0`` will cause all
+   currently defined debug output to be printed to stdout.  The ``debuglevel``
+   is passed to any new :class:`HTTPResponse` objects that are created.
 
    .. versionadded:: 3.1
 

Modified: python/branches/py3k-cdecimal/Doc/library/imp.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/imp.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/imp.rst	Sun Jan  2 13:18:37 2011
@@ -190,8 +190,8 @@
    continue to use the old class definition.  The same is true for derived classes.
 
 
-The following functions and data provide conveniences for handling :pep:`3147`
-byte-compiled file paths.
+The following functions are conveniences for handling :pep:`3147` byte-compiled
+file paths.
 
 .. versionadded:: 3.2
 
@@ -258,88 +258,6 @@
 
    The module was found as a frozen module (see :func:`init_frozen`).
 
-The following constant and functions are obsolete; their functionality is
-available through :func:`find_module` or :func:`load_module`. They are kept
-around for backward compatibility:
-
-
-.. data:: SEARCH_ERROR
-
-   Unused.
-
-
-.. function:: init_builtin(name)
-
-   Initialize the built-in module called *name* and return its module object along
-   with storing it in ``sys.modules``.  If the module was already initialized, it
-   will be initialized *again*.  Re-initialization involves the copying of the
-   built-in module's ``__dict__`` from the cached module over the module's entry in
-   ``sys.modules``.  If there is no built-in module called *name*, ``None`` is
-   returned.
-
-
-.. function:: init_frozen(name)
-
-   Initialize the frozen module called *name* and return its module object.  If
-   the module was already initialized, it will be initialized *again*.  If there
-   is no frozen module called *name*, ``None`` is returned.  (Frozen modules are
-   modules written in Python whose compiled byte-code object is incorporated
-   into a custom-built Python interpreter by Python's :program:`freeze`
-   utility. See :file:`Tools/freeze/` for now.)
-
-
-.. function:: is_builtin(name)
-
-   Return ``1`` if there is a built-in module called *name* which can be
-   initialized again.  Return ``-1`` if there is a built-in module called *name*
-   which cannot be initialized again (see :func:`init_builtin`).  Return ``0`` if
-   there is no built-in module called *name*.
-
-
-.. function:: is_frozen(name)
-
-   Return ``True`` if there is a frozen module (see :func:`init_frozen`) called
-   *name*, or ``False`` if there is no such module.
-
-
-.. function:: load_compiled(name, pathname, [file])
-
-   .. index:: pair: file; byte-code
-
-   Load and initialize a module implemented as a byte-compiled code file and return
-   its module object.  If the module was already initialized, it will be
-   initialized *again*.  The *name* argument is used to create or access a module
-   object.  The *pathname* argument points to the byte-compiled code file.  The
-   *file* argument is the byte-compiled code file, open for reading in binary mode,
-   from the beginning. It must currently be a real file object, not a user-defined
-   class emulating a file.
-
-
-.. function:: load_dynamic(name, pathname[, file])
-
-   Load and initialize a module implemented as a dynamically loadable shared
-   library and return its module object.  If the module was already initialized, it
-   will be initialized *again*. Re-initialization involves copying the ``__dict__``
-   attribute of the cached instance of the module over the value used in the module
-   cached in ``sys.modules``.  The *pathname* argument must point to the shared
-   library.  The *name* argument is used to construct the name of the
-   initialization function: an external C function called ``initname()`` in the
-   shared library is called.  The optional *file* argument is ignored.  (Note:
-   using shared libraries is highly system dependent, and not all systems support
-   it.)
-
-
-.. function:: load_source(name, pathname[, file])
-
-   Load and initialize a module implemented as a Python source file and return its
-   module object.  If the module was already initialized, it will be initialized
-   *again*.  The *name* argument is used to create or access a module object.  The
-   *pathname* argument points to the source file.  The *file* argument is the
-   source file, open for reading as text, from the beginning. It must currently be
-   a real file object, not a user-defined class emulating a file.  Note that if a
-   properly matching byte-compiled file (with suffix :file:`.pyc` or :file:`.pyo`)
-   exists, it will be used instead of parsing the given source file.
-
 
 .. class:: NullImporter(path_string)
 
@@ -390,10 +308,3 @@
            # Since we may exit via an exception, close fp explicitly.
            if fp:
                fp.close()
-
-.. index:: module: knee
-
-A more complete example that implements hierarchical module names and includes a
-:func:`reload` function can be found in the module :mod:`knee`.  The :mod:`knee`
-module can be found in :file:`Demo/imputil/` in the Python source distribution.
-

Modified: python/branches/py3k-cdecimal/Doc/library/inspect.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/inspect.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/inspect.rst	Sun Jan  2 13:18:37 2011
@@ -630,17 +630,17 @@
 When implementing coroutine schedulers and for other advanced uses of
 generators, it is useful to determine whether a generator is currently
 executing, is waiting to start or resume or execution, or has already
-terminated. func:`getgeneratorstate` allows the current state of a
+terminated. :func:`getgeneratorstate` allows the current state of a
 generator to be determined easily.
 
 .. function:: getgeneratorstate(generator)
 
-    Get current state of a generator-iterator.
+   Get current state of a generator-iterator.
 
-    Possible states are:
-      GEN_CREATED: Waiting to start execution.
-      GEN_RUNNING: Currently being executed by the interpreter.
-      GEN_SUSPENDED: Currently suspended at a yield expression.
-      GEN_CLOSED: Execution has completed.
+   Possible states are:
+   -  GEN_CREATED: Waiting to start execution.
+   -  GEN_RUNNING: Currently being executed by the interpreter.
+   -  GEN_SUSPENDED: Currently suspended at a yield expression.
+   -  GEN_CLOSED: Execution has completed.
 
    .. versionadded:: 3.2

Modified: python/branches/py3k-cdecimal/Doc/library/io.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/io.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/io.rst	Sun Jan  2 13:18:37 2011
@@ -54,12 +54,6 @@
 The text stream API is described in detail in the documentation for the
 :class:`TextIOBase`.
 
-.. note::
-
-   Text I/O over a binary storage (such as a file) is significantly slower than
-   binary I/O over the same storage.  This can become noticeable if you handle
-   huge amounts of text data (for example very large log files).
-
 
 Binary I/O
 ^^^^^^^^^^
@@ -361,9 +355,9 @@
 
    .. method:: readinto(b)
 
-      Read up to len(b) bytes into bytearray *b* and return the number ofbytes
-      read.  If the object is in non-blocking mode and no bytes are available,
-      ``None`` is returned.
+      Read up to len(b) bytes into bytearray *b* and return the number
+      of bytes read.  If the object is in non-blocking mode and no
+      bytes are available, ``None`` is returned.
 
    .. method:: write(b)
 
@@ -506,8 +500,8 @@
 Buffered Streams
 ^^^^^^^^^^^^^^^^
 
-In many situations, buffered I/O streams will provide higher performance
-(bandwidth and latency) than raw I/O streams.  Their API is also more usable.
+Buffered I/O streams provide a higher-level interface to an I/O device
+than raw I/O does.
 
 .. class:: BytesIO([initial_bytes])
 
@@ -784,14 +778,72 @@
       # .getvalue() will now raise an exception.
       output.close()
 
-   .. note::
-
-      :class:`StringIO` uses a native text storage and doesn't suffer from the
-      performance issues of other text streams, such as those based on
-      :class:`TextIOWrapper`.
 
 .. class:: IncrementalNewlineDecoder
 
    A helper codec that decodes newlines for universal newlines mode.  It
    inherits :class:`codecs.IncrementalDecoder`.
 
+
+Advanced topics
+---------------
+
+Here we will discuss several advanced topics pertaining to the concrete
+I/O implementations described above.
+
+Performance
+^^^^^^^^^^^
+
+Binary I/O
+""""""""""
+
+By reading and writing only large chunks of data even when the user asks
+for a single byte, buffered I/O is designed to hide any inefficiency in
+calling and executing the operating system's unbuffered I/O routines.  The
+gain will vary very much depending on the OS and the kind of I/O which is
+performed (for example, on some contemporary OSes such as Linux, unbuffered
+disk I/O can be as fast as buffered I/O).  The bottom line, however, is
+that buffered I/O will offer you predictable performance regardless of the
+platform and the backing device.  Therefore, it is most always preferable to
+use buffered I/O rather than unbuffered I/O.
+
+Text I/O
+""""""""
+
+Text I/O over a binary storage (such as a file) is significantly slower than
+binary I/O over the same storage, because it implies conversions from
+unicode to binary data using a character codec.  This can become noticeable
+if you handle huge amounts of text data (for example very large log files).
+
+:class:`StringIO`, however, is a native in-memory unicode container and will
+exhibit similar speed to :class:`BytesIO`.
+
+Multi-threading
+^^^^^^^^^^^^^^^
+
+:class:`FileIO` objects are thread-safe to the extent that the operating
+system calls (such as ``read(2)`` under Unix) they are wrapping are thread-safe
+too.
+
+Binary buffered objects (instances of :class:`BufferedReader`,
+:class:`BufferedWriter`, :class:`BufferedRandom` and :class:`BufferedRWPair`)
+protect their internal structures using a lock; it is therefore safe to call
+them from multiple threads at once.
+
+:class:`TextIOWrapper` objects are not thread-safe.
+
+Reentrancy
+^^^^^^^^^^
+
+Binary buffered objects (instances of :class:`BufferedReader`,
+:class:`BufferedWriter`, :class:`BufferedRandom` and :class:`BufferedRWPair`)
+are not reentrant.  While reentrant calls will not happen in normal situations,
+they can arise if you are doing I/O in a :mod:`signal` handler.  If it is
+attempted to enter a buffered object again while already being accessed
+*from the same thread*, then a :exc:`RuntimeError` is raised.
+
+The above implicitly extends to text files, since the :func:`open()`
+function will wrap a buffered object inside a :class:`TextIOWrapper`.  This
+includes standard streams and therefore affects the built-in function
+:func:`print()` as well.
+

Modified: python/branches/py3k-cdecimal/Doc/library/itertools.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/itertools.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/itertools.rst	Sun Jan  2 13:18:37 2011
@@ -46,6 +46,7 @@
 ====================    ============================    =================================================   =============================================================
 Iterator                Arguments                       Results                                             Example
 ====================    ============================    =================================================   =============================================================
+:func:`accumulate`      p                               p0, p0+p1, p0+p1+p2, ...                            ``accumulate([1,2,3,4,5]) --> 1 3 6 10 15``
 :func:`chain`           p, q, ...                       p0, p1, ... plast, q0, q1, ...                      ``chain('ABC', 'DEF') --> A B C D E F``
 :func:`compress`        data, selectors                 (d[0] if s[0]), (d[1] if s[1]), ...                 ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F``
 :func:`dropwhile`       pred, seq                       seq[n], seq[n+1], starting when pred fails          ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
@@ -83,6 +84,22 @@
 streams of infinite length, so they should only be accessed by functions or
 loops that truncate the stream.
 
+.. function:: accumulate(iterable)
+
+    Make an iterator that returns accumulated sums. Elements may be any addable
+    type including :class:`Decimal` or :class:`Fraction`.  Equivalent to::
+
+        def accumulate(iterable):
+            'Return running totals'
+            # accumulate([1,2,3,4,5]) --> 1 3 6 10 15
+            it = iter(iterable)
+            total = next(it)
+            yield total
+            for element in it:
+                total = total + element
+                yield total
+
+    .. versionadded:: 3.2
 
 .. function:: chain(*iterables)
 
@@ -560,8 +577,8 @@
 
 .. _itertools-recipes:
 
-Recipes
--------
+Itertools Recipes
+-----------------
 
 This section shows recipes for creating an extended toolset using the existing
 itertools as building blocks.

Modified: python/branches/py3k-cdecimal/Doc/library/logging.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/logging.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/logging.rst	Sun Jan  2 13:18:37 2011
@@ -2,7 +2,7 @@
 ==============================================
 
 .. module:: logging
-   :synopsis: Flexible error logging system for applications.
+   :synopsis: Flexible event logging system for applications.
 
 
 .. moduleauthor:: Vinay Sajip <vinay_sajip at red-dove.com>
@@ -11,748 +11,107 @@
 
 .. index:: pair: Errors; logging
 
-This module defines functions and classes which implement a flexible error
-logging system for applications.
+.. sidebar:: Important
 
-Logging is performed by calling methods on instances of the :class:`Logger`
-class (hereafter called :dfn:`loggers`). Each instance has a name, and they are
-conceptually arranged in a namespace hierarchy using dots (periods) as
-separators. For example, a logger named "scan" is the parent of loggers
-"scan.text", "scan.html" and "scan.pdf". Logger names can be anything you want,
-and indicate the area of an application in which a logged message originates.
-
-Logged messages also have levels of importance associated with them. The default
-levels provided are :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
-:const:`ERROR` and :const:`CRITICAL`. As a convenience, you indicate the
-importance of a logged message by calling an appropriate method of
-:class:`Logger`. The methods are :meth:`debug`, :meth:`info`, :meth:`warning`,
-:meth:`error` and :meth:`critical`, which mirror the default levels. You are not
-constrained to use these levels: you can specify your own and use a more general
-:class:`Logger` method, :meth:`log`, which takes an explicit level argument.
+   This page contains the API reference information. For tutorial
+   information and discussion of more advanced topics, see
 
+   * :ref:`Basic Tutorial <logging-basic-tutorial>`
+   * :ref:`Advanced Tutorial <logging-advanced-tutorial>`
+   * :ref:`Logging Cookbook <logging-cookbook>`
 
-Logging tutorial
-----------------
+
+This module defines functions and classes which implement a flexible event
+logging system for applications and libraries.
 
 The key benefit of having the logging API provided by a standard library module
 is that all Python modules can participate in logging, so your application log
-can include messages from third-party modules.
-
-It is, of course, possible to log messages with different verbosity levels or to
-different destinations.  Support for writing log messages to files, HTTP
-GET/POST locations, email via SMTP, generic sockets, or OS-specific logging
-mechanisms are all supported by the standard module.  You can also create your
-own log destination class if you have special requirements not met by any of the
-built-in classes.
-
-Simple examples
-^^^^^^^^^^^^^^^
-
-.. sectionauthor:: Doug Hellmann
-.. (see <http://blog.doughellmann.com/2007/05/pymotw-logging.html>)
-
-Most applications are probably going to want to log to a file, so let's start
-with that case. Using the :func:`basicConfig` function, we can set up the
-default handler so that debug messages are written to a file (in the example,
-we assume that you have the appropriate permissions to create a file called
-*example.log* in the current directory)::
-
-   import logging
-   LOG_FILENAME = 'example.log'
-   logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
-
-   logging.debug('This message should go to the log file')
-
-And now if we open the file and look at what we have, we should find the log
-message::
-
-   DEBUG:root:This message should go to the log file
-
-If you run the script repeatedly, the additional log messages are appended to
-the file.  To create a new file each time, you can pass a *filemode* argument to
-:func:`basicConfig` with a value of ``'w'``.  Rather than managing the file size
-yourself, though, it is simpler to use a :class:`RotatingFileHandler`::
-
-   import glob
-   import logging
-   import logging.handlers
-
-   LOG_FILENAME = 'logging_rotatingfile_example.out'
-
-   # Set up a specific logger with our desired output level
-   my_logger = logging.getLogger('MyLogger')
-   my_logger.setLevel(logging.DEBUG)
-
-   # Add the log message handler to the logger
-   handler = logging.handlers.RotatingFileHandler(
-                 LOG_FILENAME, maxBytes=20, backupCount=5)
-
-   my_logger.addHandler(handler)
-
-   # Log some messages
-   for i in range(20):
-       my_logger.debug('i = %d' % i)
-
-   # See what files are created
-   logfiles = glob.glob('%s*' % LOG_FILENAME)
-
-   for filename in logfiles:
-       print(filename)
-
-The result should be 6 separate files, each with part of the log history for the
-application::
-
-   logging_rotatingfile_example.out
-   logging_rotatingfile_example.out.1
-   logging_rotatingfile_example.out.2
-   logging_rotatingfile_example.out.3
-   logging_rotatingfile_example.out.4
-   logging_rotatingfile_example.out.5
-
-The most current file is always :file:`logging_rotatingfile_example.out`,
-and each time it reaches the size limit it is renamed with the suffix
-``.1``. Each of the existing backup files is renamed to increment the suffix
-(``.1`` becomes ``.2``, etc.)  and the ``.6`` file is erased.
-
-Obviously this example sets the log length much much too small as an extreme
-example.  You would want to set *maxBytes* to an appropriate value.
-
-Another useful feature of the logging API is the ability to produce different
-messages at different log levels.  This allows you to instrument your code with
-debug messages, for example, but turning the log level down so that those debug
-messages are not written for your production system.  The default levels are
-``NOTSET``, ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR`` and ``CRITICAL``.
-
-The logger, handler, and log message call each specify a level.  The log message
-is only emitted if the handler and logger are configured to emit messages of
-that level or lower.  For example, if a message is ``CRITICAL``, and the logger
-is set to ``ERROR``, the message is emitted.  If a message is a ``WARNING``, and
-the logger is set to produce only ``ERROR``\s, the message is not emitted::
-
-   import logging
-   import sys
-
-   LEVELS = {'debug': logging.DEBUG,
-             'info': logging.INFO,
-             'warning': logging.WARNING,
-             'error': logging.ERROR,
-             'critical': logging.CRITICAL}
-
-   if len(sys.argv) > 1:
-       level_name = sys.argv[1]
-       level = LEVELS.get(level_name, logging.NOTSET)
-       logging.basicConfig(level=level)
-
-   logging.debug('This is a debug message')
-   logging.info('This is an info message')
-   logging.warning('This is a warning message')
-   logging.error('This is an error message')
-   logging.critical('This is a critical error message')
-
-Run the script with an argument like 'debug' or 'warning' to see which messages
-show up at different levels::
-
-   $ python logging_level_example.py debug
-   DEBUG:root:This is a debug message
-   INFO:root:This is an info message
-   WARNING:root:This is a warning message
-   ERROR:root:This is an error message
-   CRITICAL:root:This is a critical error message
-
-   $ python logging_level_example.py info
-   INFO:root:This is an info message
-   WARNING:root:This is a warning message
-   ERROR:root:This is an error message
-   CRITICAL:root:This is a critical error message
-
-You will notice that these log messages all have ``root`` embedded in them.  The
-logging module supports a hierarchy of loggers with different names.  An easy
-way to tell where a specific log message comes from is to use a separate logger
-object for each of your modules.  Each new logger "inherits" the configuration
-of its parent, and log messages sent to a logger include the name of that
-logger.  Optionally, each logger can be configured differently, so that messages
-from different modules are handled in different ways.  Let's look at a simple
-example of how to log from different modules so it is easy to trace the source
-of the message::
-
-   import logging
-
-   logging.basicConfig(level=logging.WARNING)
-
-   logger1 = logging.getLogger('package1.module1')
-   logger2 = logging.getLogger('package2.module2')
-
-   logger1.warning('This message comes from one module')
-   logger2.warning('And this message comes from another module')
-
-And the output::
-
-   $ python logging_modules_example.py
-   WARNING:package1.module1:This message comes from one module
-   WARNING:package2.module2:And this message comes from another module
-
-There are many more options for configuring logging, including different log
-message formatting options, having messages delivered to multiple destinations,
-and changing the configuration of a long-running application on the fly using a
-socket interface.  All of these options are covered in depth in the library
-module documentation.
-
-Loggers
-^^^^^^^
-
-The logging library takes a modular approach and offers the several categories
-of components: loggers, handlers, filters, and formatters.  Loggers expose the
-interface that application code directly uses.  Handlers send the log records to
-the appropriate destination. Filters provide a finer grained facility for
-determining which log records to send on to a handler.  Formatters specify the
-layout of the resultant log record.
-
-:class:`Logger` objects have a threefold job.  First, they expose several
-methods to application code so that applications can log messages at runtime.
-Second, logger objects determine which log messages to act upon based upon
-severity (the default filtering facility) or filter objects.  Third, logger
-objects pass along relevant log messages to all interested log handlers.
-
-The most widely used methods on logger objects fall into two categories:
-configuration and message sending.
-
-* :meth:`Logger.setLevel` specifies the lowest-severity log message a logger
-  will handle, where debug is the lowest built-in severity level and critical is
-  the highest built-in severity.  For example, if the severity level is info,
-  the logger will handle only info, warning, error, and critical messages and
-  will ignore debug messages.
-
-* :meth:`Logger.addFilter` and :meth:`Logger.removeFilter` add and remove filter
-  objects from the logger object.  This tutorial does not address filters.
-
-With the logger object configured, the following methods create log messages:
-
-* :meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`,
-  :meth:`Logger.error`, and :meth:`Logger.critical` all create log records with
-  a message and a level that corresponds to their respective method names. The
-  message is actually a format string, which may contain the standard string
-  substitution syntax of :const:`%s`, :const:`%d`, :const:`%f`, and so on.  The
-  rest of their arguments is a list of objects that correspond with the
-  substitution fields in the message.  With regard to :const:`**kwargs`, the
-  logging methods care only about a keyword of :const:`exc_info` and use it to
-  determine whether to log exception information.
-
-* :meth:`Logger.exception` creates a log message similar to
-  :meth:`Logger.error`.  The difference is that :meth:`Logger.exception` dumps a
-  stack trace along with it.  Call this method only from an exception handler.
-
-* :meth:`Logger.log` takes a log level as an explicit argument.  This is a
-  little more verbose for logging messages than using the log level convenience
-  methods listed above, but this is how to log at custom log levels.
-
-:func:`getLogger` returns a reference to a logger instance with the specified
-name if it is provided, or ``root`` if not.  The names are period-separated
-hierarchical structures.  Multiple calls to :func:`getLogger` with the same name
-will return a reference to the same logger object.  Loggers that are further
-down in the hierarchical list are children of loggers higher up in the list.
-For example, given a logger with a name of ``foo``, loggers with names of
-``foo.bar``, ``foo.bar.baz``, and ``foo.bam`` are all descendants of ``foo``.
-Child loggers propagate messages up to the handlers associated with their
-ancestor loggers.  Because of this, it is unnecessary to define and configure
-handlers for all the loggers an application uses. It is sufficient to
-configure handlers for a top-level logger and create child loggers as needed.
-
-
-Handlers
-^^^^^^^^
-
-:class:`Handler` objects are responsible for dispatching the appropriate log
-messages (based on the log messages' severity) to the handler's specified
-destination.  Logger objects can add zero or more handler objects to themselves
-with an :func:`addHandler` method.  As an example scenario, an application may
-want to send all log messages to a log file, all log messages of error or higher
-to stdout, and all messages of critical to an email address.  This scenario
-requires three individual handlers where each handler is responsible for sending
-messages of a specific severity to a specific location.
-
-The standard library includes quite a few handler types; this tutorial uses only
-:class:`StreamHandler` and :class:`FileHandler` in its examples.
-
-There are very few methods in a handler for application developers to concern
-themselves with.  The only handler methods that seem relevant for application
-developers who are using the built-in handler objects (that is, not creating
-custom handlers) are the following configuration methods:
-
-* The :meth:`Handler.setLevel` method, just as in logger objects, specifies the
-  lowest severity that will be dispatched to the appropriate destination.  Why
-  are there two :func:`setLevel` methods?  The level set in the logger
-  determines which severity of messages it will pass to its handlers.  The level
-  set in each handler determines which messages that handler will send on.
-
-* :func:`setFormatter` selects a Formatter object for this handler to use.
-
-* :func:`addFilter` and :func:`removeFilter` respectively configure and
-  deconfigure filter objects on handlers.
-
-Application code should not directly instantiate and use instances of
-:class:`Handler`.  Instead, the :class:`Handler` class is a base class that
-defines the interface that all handlers should have and establishes some
-default behavior that child classes can use (or override).
-
-
-Formatters
-^^^^^^^^^^
-
-Formatter objects configure the final order, structure, and contents of the log
-message.  Unlike the base :class:`logging.Handler` class, application code may
-instantiate formatter classes, although you could likely subclass the formatter
-if your application needs special behavior.  The constructor takes three
-optional arguments -- a message format string, a date format string and a style
-indicator.
-
-.. method:: logging.Formatter.__init__(fmt=None, datefmt=None, style='%')
-
-If there is no message format string, the default is to use the
-raw message.  If there is no date format string, the default date format is::
-
-    %Y-%m-%d %H:%M:%S
-
-with the milliseconds tacked on at the end. The ``style`` is one of `%`, '{'
-or '$'. If one of these is not specified, then '%' will be used.
-
-If the ``style`` is '%', the message format string uses
-``%(<dictionary key>)s`` styled string substitution; the possible keys are
-documented in :ref:`formatter-objects`. If the style is '{', the message format
-string is assumed to be compatible with :meth:`str.format` (using keyword
-arguments), while if the style is '$' then the message format string should
-conform to what is expected by :meth:`string.Template.substitute`.
-
-.. versionchanged:: 3.2
-   Added the ``style`` parameter.
+can include your own messages integrated with messages from third-party
+modules.
 
-The following message format string will log the time in a human-readable
-format, the severity of the message, and the contents of the message, in that
-order::
-
-    "%(asctime)s - %(levelname)s - %(message)s"
-
-Formatters use a user-configurable function to convert the creation time of a
-record to a tuple. By default, :func:`time.localtime` is used; to change this
-for a particular formatter instance, set the ``converter`` attribute of the
-instance to a function with the same signature as :func:`time.localtime` or
-:func:`time.gmtime`. To change it for all formatters, for example if you want
-all logging times to be shown in GMT, set the ``converter`` attribute in the
-Formatter class (to ``time.gmtime`` for GMT display).
-
-
-Configuring Logging
-^^^^^^^^^^^^^^^^^^^
-
-Programmers can configure logging in three ways:
-
-1. Creating loggers, handlers, and formatters explicitly using Python
-   code that calls the configuration methods listed above.
-2. Creating a logging config file and reading it using the :func:`fileConfig`
-   function.
-3. Creating a dictionary of configuration information and passing it
-   to the :func:`dictConfig` function.
-
-The following example configures a very simple logger, a console
-handler, and a simple formatter using Python code::
-
-    import logging
-
-    # create logger
-    logger = logging.getLogger("simple_example")
-    logger.setLevel(logging.DEBUG)
-
-    # create console handler and set level to debug
-    ch = logging.StreamHandler()
-    ch.setLevel(logging.DEBUG)
-
-    # create formatter
-    formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
-
-    # add formatter to ch
-    ch.setFormatter(formatter)
-
-    # add ch to logger
-    logger.addHandler(ch)
-
-    # "application" code
-    logger.debug("debug message")
-    logger.info("info message")
-    logger.warn("warn message")
-    logger.error("error message")
-    logger.critical("critical message")
-
-Running this module from the command line produces the following output::
-
-    $ python simple_logging_module.py
-    2005-03-19 15:10:26,618 - simple_example - DEBUG - debug message
-    2005-03-19 15:10:26,620 - simple_example - INFO - info message
-    2005-03-19 15:10:26,695 - simple_example - WARNING - warn message
-    2005-03-19 15:10:26,697 - simple_example - ERROR - error message
-    2005-03-19 15:10:26,773 - simple_example - CRITICAL - critical message
-
-The following Python module creates a logger, handler, and formatter nearly
-identical to those in the example listed above, with the only difference being
-the names of the objects::
-
-    import logging
-    import logging.config
-
-    logging.config.fileConfig("logging.conf")
-
-    # create logger
-    logger = logging.getLogger("simpleExample")
-
-    # "application" code
-    logger.debug("debug message")
-    logger.info("info message")
-    logger.warn("warn message")
-    logger.error("error message")
-    logger.critical("critical message")
-
-Here is the logging.conf file::
-
-    [loggers]
-    keys=root,simpleExample
-
-    [handlers]
-    keys=consoleHandler
-
-    [formatters]
-    keys=simpleFormatter
-
-    [logger_root]
-    level=DEBUG
-    handlers=consoleHandler
-
-    [logger_simpleExample]
-    level=DEBUG
-    handlers=consoleHandler
-    qualname=simpleExample
-    propagate=0
-
-    [handler_consoleHandler]
-    class=StreamHandler
-    level=DEBUG
-    formatter=simpleFormatter
-    args=(sys.stdout,)
-
-    [formatter_simpleFormatter]
-    format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
-    datefmt=
-
-The output is nearly identical to that of the non-config-file-based example::
-
-    $ python simple_logging_config.py
-    2005-03-19 15:38:55,977 - simpleExample - DEBUG - debug message
-    2005-03-19 15:38:55,979 - simpleExample - INFO - info message
-    2005-03-19 15:38:56,054 - simpleExample - WARNING - warn message
-    2005-03-19 15:38:56,055 - simpleExample - ERROR - error message
-    2005-03-19 15:38:56,130 - simpleExample - CRITICAL - critical message
-
-You can see that the config file approach has a few advantages over the Python
-code approach, mainly separation of configuration and code and the ability of
-noncoders to easily modify the logging properties.
-
-Note that the class names referenced in config files need to be either relative
-to the logging module, or absolute values which can be resolved using normal
-import mechanisms. Thus, you could use either
-:class:`handlers.WatchedFileHandler` (relative to the logging module) or
-``mypackage.mymodule.MyHandler`` (for a class defined in package ``mypackage``
-and module ``mymodule``, where ``mypackage`` is available on the Python import
-path).
-
-In Python 3.2, a new means of configuring logging has been introduced, using
-dictionaries to hold configuration information. This provides a superset of the
-functionality of the config-file-based approach outlined above, and is the
-recommended configuration method for new applications and deployments. Because
-a Python dictionary is used to hold configuration information, and since you
-can populate that dictionary using different means, you have more options for
-configuration. For example, you can use a configuration file in JSON format,
-or, if you have access to YAML processing functionality, a file in YAML
-format, to populate the configuration dictionary. Or, of course, you can
-construct the dictionary in Python code, receive it in pickled form over a
-socket, or use whatever approach makes sense for your application.
-
-Here's an example of the same configuration as above, in YAML format for
-the new dictionary-based approach::
-
-    version: 1
-    formatters:
-      simple:
-        format: format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
-    handlers:
-      console:
-        class: logging.StreamHandler
-        level: DEBUG
-        formatter: simple
-        stream: ext://sys.stdout
-    loggers:
-      simpleExample:
-        level: DEBUG
-        handlers: [console]
-        propagate: no
-    root:
-        level: DEBUG
-        handlers: [console]
-
-For more information about logging using a dictionary, see
-:ref:`logging-config-api`.
-
-.. _library-config:
-
-Configuring Logging for a Library
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-When developing a library which uses logging, some consideration needs to be
-given to its configuration. If the using application does not use logging, and
-library code makes logging calls, then a one-off message "No handlers could be
-found for logger X.Y.Z" is printed to the console. This message is intended
-to catch mistakes in logging configuration, but will confuse an application
-developer who is not aware of logging by the library.
-
-In addition to documenting how a library uses logging, a good way to configure
-library logging so that it does not cause a spurious message is to add a
-handler which does nothing. This avoids the message being printed, since a
-handler will be found: it just doesn't produce any output. If the library user
-configures logging for application use, presumably that configuration will add
-some handlers, and if levels are suitably configured then logging calls made
-in library code will send output to those handlers, as normal.
-
-A do-nothing handler can be simply defined as follows::
-
-    import logging
-
-    class NullHandler(logging.Handler):
-        def emit(self, record):
-            pass
-
-An instance of this handler should be added to the top-level logger of the
-logging namespace used by the library. If all logging by a library *foo* is
-done using loggers with names matching "foo.x.y", then the code::
-
-    import logging
-
-    h = NullHandler()
-    logging.getLogger("foo").addHandler(h)
-
-should have the desired effect. If an organisation produces a number of
-libraries, then the logger name specified can be "orgname.foo" rather than
-just "foo".
-
-**PLEASE NOTE:** It is strongly advised that you *do not add any handlers other
-than* :class:`NullHandler` *to your library's loggers*. This is because the
-configuration of handlers is the prerogative of the application developer who
-uses your library. The application developer knows their target audience and
-what handlers are most appropriate for their application: if you add handlers
-"under the hood", you might well interfere with their ability to carry out
-unit tests and deliver logs which suit their requirements.
-
-.. versionadded:: 3.1
-
-The :class:`NullHandler` class was not present in previous versions, but is
-now included, so that it need not be defined in library code.
+The module provides a lot of functionality and flexibility.  If you are
+unfamiliar with logging, the best way to get to grips with it is to see the
+tutorials (see the links on the right).
+
+The basic classes defined by the module, together with their functions, are
+listed below.
+
+* Loggers expose the interface that application code directly uses.
+* Handlers send the log records (created by loggers) to the appropriate
+  destination.
+* Filters provide a finer grained facility for determining which log records
+  to output.
+* Formatters specify the layout of log records in the final output.
 
 
+.. _logger:
 
-Logging Levels
+Logger Objects
 --------------
 
-The numeric values of logging levels are given in the following table. These are
-primarily of interest if you want to define your own levels, and need them to
-have specific values relative to the predefined levels. If you define a level
-with the same numeric value, it overwrites the predefined value; the predefined
-name is lost.
-
-+--------------+---------------+
-| Level        | Numeric value |
-+==============+===============+
-| ``CRITICAL`` | 50            |
-+--------------+---------------+
-| ``ERROR``    | 40            |
-+--------------+---------------+
-| ``WARNING``  | 30            |
-+--------------+---------------+
-| ``INFO``     | 20            |
-+--------------+---------------+
-| ``DEBUG``    | 10            |
-+--------------+---------------+
-| ``NOTSET``   | 0             |
-+--------------+---------------+
-
-Levels can also be associated with loggers, being set either by the developer or
-through loading a saved logging configuration. When a logging method is called
-on a logger, the logger compares its own level with the level associated with
-the method call. If the logger's level is higher than the method call's, no
-logging message is actually generated. This is the basic mechanism controlling
-the verbosity of logging output.
-
-Logging messages are encoded as instances of the :class:`LogRecord` class. When
-a logger decides to actually log an event, a :class:`LogRecord` instance is
-created from the logging message.
-
-Logging messages are subjected to a dispatch mechanism through the use of
-:dfn:`handlers`, which are instances of subclasses of the :class:`Handler`
-class. Handlers are responsible for ensuring that a logged message (in the form
-of a :class:`LogRecord`) ends up in a particular location (or set of locations)
-which is useful for the target audience for that message (such as end users,
-support desk staff, system administrators, developers). Handlers are passed
-:class:`LogRecord` instances intended for particular destinations. Each logger
-can have zero, one or more handlers associated with it (via the
-:meth:`addHandler` method of :class:`Logger`). In addition to any handlers
-directly associated with a logger, *all handlers associated with all ancestors
-of the logger* are called to dispatch the message (unless the *propagate* flag
-for a logger is set to a false value, at which point the passing to ancestor
-handlers stops).
-
-Just as for loggers, handlers can have levels associated with them. A handler's
-level acts as a filter in the same way as a logger's level does. If a handler
-decides to actually dispatch an event, the :meth:`emit` method is used to send
-the message to its destination. Most user-defined subclasses of :class:`Handler`
-will need to override this :meth:`emit`.
-
-.. _custom-levels:
-
-Custom Levels
-^^^^^^^^^^^^^
-
-Defining your own levels is possible, but should not be necessary, as the
-existing levels have been chosen on the basis of practical experience.
-However, if you are convinced that you need custom levels, great care should
-be exercised when doing this, and it is possibly *a very bad idea to define
-custom levels if you are developing a library*. That's because if multiple
-library authors all define their own custom levels, there is a chance that
-the logging output from such multiple libraries used together will be
-difficult for the using developer to control and/or interpret, because a
-given numeric value might mean different things for different libraries.
-
-
-Useful Handlers
----------------
-
-In addition to the base :class:`Handler` class, many useful subclasses are
-provided:
-
-#. :class:`StreamHandler` instances send messages to streams (file-like
-   objects).
-
-#. :class:`FileHandler` instances send messages to disk files.
-
-.. module:: logging.handlers
-
-#. :class:`BaseRotatingHandler` is the base class for handlers that
-   rotate log files at a certain point. It is not meant to be  instantiated
-   directly. Instead, use :class:`RotatingFileHandler` or
-   :class:`TimedRotatingFileHandler`.
-
-#. :class:`RotatingFileHandler` instances send messages to disk
-   files, with support for maximum log file sizes and log file rotation.
-
-#. :class:`TimedRotatingFileHandler` instances send messages to
-   disk files, rotating the log file at certain timed intervals.
-
-#. :class:`SocketHandler` instances send messages to TCP/IP
-   sockets.
-
-#. :class:`DatagramHandler` instances send messages to UDP
-   sockets.
+Loggers have the following attributes and methods. Note that Loggers are never
+instantiated directly, but always through the module-level function
+``logging.getLogger(name)``.
 
-#. :class:`SMTPHandler` instances send messages to a designated
-   email address.
+.. class:: Logger
 
-#. :class:`SysLogHandler` instances send messages to a Unix
-   syslog daemon, possibly on a remote machine.
+.. attribute:: Logger.propagate
 
-#. :class:`NTEventLogHandler` instances send messages to a
-   Windows NT/2000/XP event log.
+   If this evaluates to false, logging messages are not passed by this logger or by
+   its child loggers to the handlers of higher level (ancestor) loggers. The
+   constructor sets this attribute to 1.
 
-#. :class:`MemoryHandler` instances send messages to a buffer
-   in memory, which is flushed whenever specific criteria are met.
 
-#. :class:`HTTPHandler` instances send messages to an HTTP
-   server using either ``GET`` or ``POST`` semantics.
+.. method:: Logger.setLevel(lvl)
 
-#. :class:`WatchedFileHandler` instances watch the file they are
-   logging to. If the file changes, it is closed and reopened using the file
-   name. This handler is only useful on Unix-like systems; Windows does not
-   support the underlying mechanism used.
+   Sets the threshold for this logger to *lvl*. Logging messages which are less
+   severe than *lvl* will be ignored. When a logger is created, the level is set to
+   :const:`NOTSET` (which causes all messages to be processed when the logger is
+   the root logger, or delegation to the parent when the logger is a non-root
+   logger). Note that the root logger is created with level :const:`WARNING`.
 
-#. :class:`QueueHandler` instances send messages to a queue, such as
-   those implemented in the :mod:`queue` or :mod:`multiprocessing` modules.
+   The term 'delegation to the parent' means that if a logger has a level of
+   NOTSET, its chain of ancestor loggers is traversed until either an ancestor with
+   a level other than NOTSET is found, or the root is reached.
 
-.. currentmodule:: logging
+   If an ancestor is found with a level other than NOTSET, then that ancestor's
+   level is treated as the effective level of the logger where the ancestor search
+   began, and is used to determine how a logging event is handled.
 
-#. :class:`NullHandler` instances do nothing with error messages. They are used
-   by library developers who want to use logging, but want to avoid the "No
-   handlers could be found for logger XXX" message which can be displayed if
-   the library user has not configured logging. See :ref:`library-config` for
-   more information.
-
-.. versionadded:: 3.1
-
-The :class:`NullHandler` class was not present in previous versions.
-
-.. versionadded:: 3.2
-
-The :class:`QueueHandler` class was not present in previous versions.
-
-The :class:`NullHandler`, :class:`StreamHandler` and :class:`FileHandler`
-classes are defined in the core logging package. The other handlers are
-defined in a sub- module, :mod:`logging.handlers`. (There is also another
-sub-module, :mod:`logging.config`, for configuration functionality.)
-
-Logged messages are formatted for presentation through instances of the
-:class:`Formatter` class. They are initialized with a format string suitable for
-use with the % operator and a dictionary.
-
-For formatting multiple messages in a batch, instances of
-:class:`BufferingFormatter` can be used. In addition to the format string (which
-is applied to each message in the batch), there is provision for header and
-trailer format strings.
-
-When filtering based on logger level and/or handler level is not enough,
-instances of :class:`Filter` can be added to both :class:`Logger` and
-:class:`Handler` instances (through their :meth:`addFilter` method). Before
-deciding to process a message further, both loggers and handlers consult all
-their filters for permission. If any filter returns a false value, the message
-is not processed further.
-
-The basic :class:`Filter` functionality allows filtering by specific logger
-name. If this feature is used, messages sent to the named logger and its
-children are allowed through the filter, and all others dropped.
+   If the root is reached, and it has a level of NOTSET, then all messages will be
+   processed. Otherwise, the root's level will be used as the effective level.
 
-Module-Level Functions
-----------------------
 
-In addition to the classes described above, there are a number of module- level
-functions.
+.. method:: Logger.isEnabledFor(lvl)
 
+   Indicates if a message of severity *lvl* would be processed by this logger.
+   This method checks first the module-level level set by
+   ``logging.disable(lvl)`` and then the logger's effective level as determined
+   by :meth:`getEffectiveLevel`.
 
-.. function:: getLogger(name=None)
 
-   Return a logger with the specified name or, if name is ``None``, return a
-   logger which is the root logger of the hierarchy. If specified, the name is
-   typically a dot-separated hierarchical name like *"a"*, *"a.b"* or *"a.b.c.d"*.
-   Choice of these names is entirely up to the developer who is using logging.
+.. method:: Logger.getEffectiveLevel()
 
-   All calls to this function with a given name return the same logger instance.
-   This means that logger instances never need to be passed between different parts
-   of an application.
+   Indicates the effective level for this logger. If a value other than
+   :const:`NOTSET` has been set using :meth:`setLevel`, it is returned. Otherwise,
+   the hierarchy is traversed towards the root until a value other than
+   :const:`NOTSET` is found, and that value is returned.
 
 
-.. function:: getLoggerClass()
+.. method:: Logger.getChild(suffix)
 
-   Return either the standard :class:`Logger` class, or the last class passed to
-   :func:`setLoggerClass`. This function may be called from within a new class
-   definition, to ensure that installing a customised :class:`Logger` class will
-   not undo customisations already applied by other code. For example::
+   Returns a logger which is a descendant to this logger, as determined by the suffix.
+   Thus, ``logging.getLogger('abc').getChild('def.ghi')`` would return the same
+   logger as would be returned by ``logging.getLogger('abc.def.ghi')``. This is a
+   convenience method, useful when the parent logger is named using e.g. ``__name__``
+   rather than a literal string.
 
-      class MyLogger(logging.getLoggerClass()):
-          # ... override behaviour here
+   .. versionadded:: 3.2
 
 
-.. function:: debug(msg, *args, **kwargs)
+.. method:: Logger.debug(msg, *args, **kwargs)
 
-   Logs a message with level :const:`DEBUG` on the root logger. The *msg* is the
+   Logs a message with level :const:`DEBUG` on this logger. The *msg* is the
    message format string, and the *args* are the arguments which are merged into
    *msg* using the string formatting operator. (Note that this means that you can
    use keywords in the format string, together with a single dictionary argument.)
@@ -781,18 +140,19 @@
    This mimics the `Traceback (most recent call last):` which is used when
    displaying exception frames.
 
-   The third optional keyword argument is *extra* which can be used to pass a
+   The third keyword argument is *extra* which can be used to pass a
    dictionary which is used to populate the __dict__ of the LogRecord created for
    the logging event with user-defined attributes. These custom attributes can then
    be used as you like. For example, they could be incorporated into logged
    messages. For example::
 
-      FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
+      FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s'
       logging.basicConfig(format=FORMAT)
-      d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
-      logging.warning("Protocol problem: %s", "connection reset", extra=d)
+      d = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' }
+      logger = logging.getLogger('tcpserver')
+      logger.warning('Protocol problem: %s', 'connection reset', extra=d)
 
-   would print something like::
+   would print something like  ::
 
       2006-02-08 22:20:02,165 192.168.0.1 fbloggs  Protocol problem: connection reset
 
@@ -817,1211 +177,101 @@
    .. versionadded:: 3.2
       The *stack_info* parameter was added.
 
-.. function:: info(msg, *args, **kwargs)
 
-   Logs a message with level :const:`INFO` on the root logger. The arguments are
-   interpreted as for :func:`debug`.
+.. method:: Logger.info(msg, *args, **kwargs)
 
+   Logs a message with level :const:`INFO` on this logger. The arguments are
+   interpreted as for :meth:`debug`.
 
-.. function:: warning(msg, *args, **kwargs)
 
-   Logs a message with level :const:`WARNING` on the root logger. The arguments are
-   interpreted as for :func:`debug`.
+.. method:: Logger.warning(msg, *args, **kwargs)
 
+   Logs a message with level :const:`WARNING` on this logger. The arguments are
+   interpreted as for :meth:`debug`.
 
-.. function:: error(msg, *args, **kwargs)
 
-   Logs a message with level :const:`ERROR` on the root logger. The arguments are
-   interpreted as for :func:`debug`.
+.. method:: Logger.error(msg, *args, **kwargs)
 
+   Logs a message with level :const:`ERROR` on this logger. The arguments are
+   interpreted as for :meth:`debug`.
 
-.. function:: critical(msg, *args, **kwargs)
 
-   Logs a message with level :const:`CRITICAL` on the root logger. The arguments
-   are interpreted as for :func:`debug`.
+.. method:: Logger.critical(msg, *args, **kwargs)
 
+   Logs a message with level :const:`CRITICAL` on this logger. The arguments are
+   interpreted as for :meth:`debug`.
 
-.. function:: exception(msg, *args)
 
-   Logs a message with level :const:`ERROR` on the root logger. The arguments are
-   interpreted as for :func:`debug`. Exception info is added to the logging
-   message. This function should only be called from an exception handler.
+.. method:: Logger.log(lvl, msg, *args, **kwargs)
 
-.. function:: log(level, msg, *args, **kwargs)
+   Logs a message with integer level *lvl* on this logger. The other arguments are
+   interpreted as for :meth:`debug`.
 
-   Logs a message with level *level* on the root logger. The other arguments are
-   interpreted as for :func:`debug`.
 
-   PLEASE NOTE: The above module-level functions which delegate to the root
-   logger should *not* be used in threads, in versions of Python earlier than
-   2.7.1 and 3.2, unless at least one handler has been added to the root
-   logger *before* the threads are started. These convenience functions call
-   :func:`basicConfig` to ensure that at least one handler is available; in
-   earlier versions of Python, this can (under rare circumstances) lead to
-   handlers being added multiple times to the root logger, which can in turn
-   lead to multiple messages for the same event.
+.. method:: Logger.exception(msg, *args)
 
-.. function:: disable(lvl)
+   Logs a message with level :const:`ERROR` on this logger. The arguments are
+   interpreted as for :meth:`debug`. Exception info is added to the logging
+   message. This method should only be called from an exception handler.
 
-   Provides an overriding level *lvl* for all loggers which takes precedence over
-   the logger's own level. When the need arises to temporarily throttle logging
-   output down across the whole application, this function can be useful. Its
-   effect is to disable all logging calls of severity *lvl* and below, so that
-   if you call it with a value of INFO, then all INFO and DEBUG events would be
-   discarded, whereas those of severity WARNING and above would be processed
-   according to the logger's effective level.
 
+.. method:: Logger.addFilter(filt)
 
-.. function:: addLevelName(lvl, levelName)
+   Adds the specified filter *filt* to this logger.
 
-   Associates level *lvl* with text *levelName* in an internal dictionary, which is
-   used to map numeric levels to a textual representation, for example when a
-   :class:`Formatter` formats a message. This function can also be used to define
-   your own levels. The only constraints are that all levels used must be
-   registered using this function, levels should be positive integers and they
-   should increase in increasing order of severity.
 
-   NOTE: If you are thinking of defining your own levels, please see the section
-   on :ref:`custom-levels`.
+.. method:: Logger.removeFilter(filt)
 
-.. function:: getLevelName(lvl)
+   Removes the specified filter *filt* from this logger.
 
-   Returns the textual representation of logging level *lvl*. If the level is one
-   of the predefined levels :const:`CRITICAL`, :const:`ERROR`, :const:`WARNING`,
-   :const:`INFO` or :const:`DEBUG` then you get the corresponding string. If you
-   have associated levels with names using :func:`addLevelName` then the name you
-   have associated with *lvl* is returned. If a numeric value corresponding to one
-   of the defined levels is passed in, the corresponding string representation is
-   returned. Otherwise, the string "Level %s" % lvl is returned.
 
+.. method:: Logger.filter(record)
 
-.. function:: makeLogRecord(attrdict)
+   Applies this logger's filters to the record and returns a true value if the
+   record is to be processed.
 
-   Creates and returns a new :class:`LogRecord` instance whose attributes are
-   defined by *attrdict*. This function is useful for taking a pickled
-   :class:`LogRecord` attribute dictionary, sent over a socket, and reconstituting
-   it as a :class:`LogRecord` instance at the receiving end.
 
+.. method:: Logger.addHandler(hdlr)
 
-.. function:: basicConfig(**kwargs)
+   Adds the specified handler *hdlr* to this logger.
 
-   Does basic configuration for the logging system by creating a
-   :class:`StreamHandler` with a default :class:`Formatter` and adding it to the
-   root logger. The functions :func:`debug`, :func:`info`, :func:`warning`,
-   :func:`error` and :func:`critical` will call :func:`basicConfig` automatically
-   if no handlers are defined for the root logger.
 
-   This function does nothing if the root logger already has handlers
-   configured for it.
+.. method:: Logger.removeHandler(hdlr)
 
-   PLEASE NOTE: This function should be called from the main thread
-   before other threads are started. In versions of Python prior to
-   2.7.1 and 3.2, if this function is called from multiple threads,
-   it is possible (in rare circumstances) that a handler will be added
-   to the root logger more than once, leading to unexpected results
-   such as messages being duplicated in the log.
+   Removes the specified handler *hdlr* from this logger.
 
-   The following keyword arguments are supported.
 
-   +--------------+---------------------------------------------+
-   | Format       | Description                                 |
-   +==============+=============================================+
-   | ``filename`` | Specifies that a FileHandler be created,    |
-   |              | using the specified filename, rather than a |
-   |              | StreamHandler.                              |
-   +--------------+---------------------------------------------+
-   | ``filemode`` | Specifies the mode to open the file, if     |
-   |              | filename is specified (if filemode is       |
-   |              | unspecified, it defaults to 'a').           |
-   +--------------+---------------------------------------------+
-   | ``format``   | Use the specified format string for the     |
-   |              | handler.                                    |
-   +--------------+---------------------------------------------+
-   | ``datefmt``  | Use the specified date/time format.         |
-   +--------------+---------------------------------------------+
-   | ``style``    | If ``format`` is specified, use this style  |
-   |              | for the format string. One of '%', '{' or   |
-   |              | '$' for %-formatting, :meth:`str.format` or |
-   |              | :class:`string.Template` respectively, and  |
-   |              | defaulting to '%' if not specified.         |
-   +--------------+---------------------------------------------+
-   | ``level``    | Set the root logger level to the specified  |
-   |              | level.                                      |
-   +--------------+---------------------------------------------+
-   | ``stream``   | Use the specified stream to initialize the  |
-   |              | StreamHandler. Note that this argument is   |
-   |              | incompatible with 'filename' - if both are  |
-   |              | present, 'stream' is ignored.               |
-   +--------------+---------------------------------------------+
+.. method:: Logger.findCaller(stack_info=False)
 
-   .. versionchanged:: 3.2
-      The ``style`` argument was added.
+   Finds the caller's source filename and line number. Returns the filename, line
+   number, function name and stack information as a 4-element tuple. The stack
+   information is returned as *None* unless *stack_info* is *True*.
 
 
-.. function:: shutdown()
+.. method:: Logger.handle(record)
 
-   Informs the logging system to perform an orderly shutdown by flushing and
-   closing all handlers. This should be called at application exit and no
-   further use of the logging system should be made after this call.
+   Handles a record by passing it to all handlers associated with this logger and
+   its ancestors (until a false value of *propagate* is found). This method is used
+   for unpickled records received from a socket, as well as those created locally.
+   Logger-level filtering is applied using :meth:`~Logger.filter`.
 
 
-.. function:: setLoggerClass(klass)
+.. method:: Logger.makeRecord(name, lvl, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None)
 
-   Tells the logging system to use the class *klass* when instantiating a logger.
-   The class should define :meth:`__init__` such that only a name argument is
-   required, and the :meth:`__init__` should call :meth:`Logger.__init__`. This
-   function is typically called before any loggers are instantiated by applications
-   which need to use custom logger behavior.
+   This is a factory method which can be overridden in subclasses to create
+   specialized :class:`LogRecord` instances.
 
+.. method:: Logger.hasHandlers()
 
-.. seealso::
+   Checks to see if this logger has any handlers configured. This is done by
+   looking for handlers in this logger and its parents in the logger hierarchy.
+   Returns True if a handler was found, else False. The method stops searching
+   up the hierarchy whenever a logger with the 'propagate' attribute set to
+   False is found - that will be the last logger which is checked for the
+   existence of handlers.
 
-   :pep:`282` - A Logging System
-      The proposal which described this feature for inclusion in the Python standard
-      library.
+   .. versionadded:: 3.2
 
-   `Original Python logging package <http://www.red-dove.com/python_logging.html>`_
-      This is the original source for the :mod:`logging` package.  The version of the
-      package available from this site is suitable for use with Python 1.5.2, 2.1.x
-      and 2.2.x, which do not include the :mod:`logging` package in the standard
-      library.
-
-.. _logger:
-
-Logger Objects
---------------
-
-Loggers have the following attributes and methods. Note that Loggers are never
-instantiated directly, but always through the module-level function
-``logging.getLogger(name)``.
-
-.. class:: Logger
-
-.. attribute:: Logger.propagate
-
-   If this evaluates to false, logging messages are not passed by this logger or by
-   its child loggers to the handlers of higher level (ancestor) loggers. The
-   constructor sets this attribute to 1.
-
-
-.. method:: Logger.setLevel(lvl)
-
-   Sets the threshold for this logger to *lvl*. Logging messages which are less
-   severe than *lvl* will be ignored. When a logger is created, the level is set to
-   :const:`NOTSET` (which causes all messages to be processed when the logger is
-   the root logger, or delegation to the parent when the logger is a non-root
-   logger). Note that the root logger is created with level :const:`WARNING`.
-
-   The term "delegation to the parent" means that if a logger has a level of
-   NOTSET, its chain of ancestor loggers is traversed until either an ancestor with
-   a level other than NOTSET is found, or the root is reached.
-
-   If an ancestor is found with a level other than NOTSET, then that ancestor's
-   level is treated as the effective level of the logger where the ancestor search
-   began, and is used to determine how a logging event is handled.
-
-   If the root is reached, and it has a level of NOTSET, then all messages will be
-   processed. Otherwise, the root's level will be used as the effective level.
-
-
-.. method:: Logger.isEnabledFor(lvl)
-
-   Indicates if a message of severity *lvl* would be processed by this logger.
-   This method checks first the module-level level set by
-   ``logging.disable(lvl)`` and then the logger's effective level as determined
-   by :meth:`getEffectiveLevel`.
-
-
-.. method:: Logger.getEffectiveLevel()
-
-   Indicates the effective level for this logger. If a value other than
-   :const:`NOTSET` has been set using :meth:`setLevel`, it is returned. Otherwise,
-   the hierarchy is traversed towards the root until a value other than
-   :const:`NOTSET` is found, and that value is returned.
-
-
-.. method:: Logger.getChild(suffix)
-
-   Returns a logger which is a descendant to this logger, as determined by the suffix.
-   Thus, ``logging.getLogger('abc').getChild('def.ghi')`` would return the same
-   logger as would be returned by ``logging.getLogger('abc.def.ghi')``. This is a
-   convenience method, useful when the parent logger is named using e.g. ``__name__``
-   rather than a literal string.
-
-   .. versionadded:: 3.2
-
-
-.. method:: Logger.debug(msg, *args, **kwargs)
-
-   Logs a message with level :const:`DEBUG` on this logger. The *msg* is the
-   message format string, and the *args* are the arguments which are merged into
-   *msg* using the string formatting operator. (Note that this means that you can
-   use keywords in the format string, together with a single dictionary argument.)
-
-   There are three keyword arguments in *kwargs* which are inspected: *exc_info*
-   which, if it does not evaluate as false, causes exception information to be
-   added to the logging message. If an exception tuple (in the format returned by
-   :func:`sys.exc_info`) is provided, it is used; otherwise, :func:`sys.exc_info`
-   is called to get the exception information.
-
-   The second optional keyword argument is *stack_info*, which defaults to
-   False. If specified as True, stack information is added to the logging
-   message, including the actual logging call. Note that this is not the same
-   stack information as that displayed through specifying *exc_info*: The
-   former is stack frames from the bottom of the stack up to the logging call
-   in the current thread, whereas the latter is information about stack frames
-   which have been unwound, following an exception, while searching for
-   exception handlers.
-
-   You can specify *stack_info* independently of *exc_info*, e.g. to just show
-   how you got to a certain point in your code, even when no exceptions were
-   raised. The stack frames are printed following a header line which says::
-
-       Stack (most recent call last):
-
-   This mimics the `Traceback (most recent call last):` which is used when
-   displaying exception frames.
-
-   The third keyword argument is *extra* which can be used to pass a
-   dictionary which is used to populate the __dict__ of the LogRecord created for
-   the logging event with user-defined attributes. These custom attributes can then
-   be used as you like. For example, they could be incorporated into logged
-   messages. For example::
-
-      FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
-      logging.basicConfig(format=FORMAT)
-      d = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' }
-      logger = logging.getLogger("tcpserver")
-      logger.warning("Protocol problem: %s", "connection reset", extra=d)
-
-   would print something like  ::
-
-      2006-02-08 22:20:02,165 192.168.0.1 fbloggs  Protocol problem: connection reset
-
-   The keys in the dictionary passed in *extra* should not clash with the keys used
-   by the logging system. (See the :class:`Formatter` documentation for more
-   information on which keys are used by the logging system.)
-
-   If you choose to use these attributes in logged messages, you need to exercise
-   some care. In the above example, for instance, the :class:`Formatter` has been
-   set up with a format string which expects 'clientip' and 'user' in the attribute
-   dictionary of the LogRecord. If these are missing, the message will not be
-   logged because a string formatting exception will occur. So in this case, you
-   always need to pass the *extra* dictionary with these keys.
-
-   While this might be annoying, this feature is intended for use in specialized
-   circumstances, such as multi-threaded servers where the same code executes in
-   many contexts, and interesting conditions which arise are dependent on this
-   context (such as remote client IP address and authenticated user name, in the
-   above example). In such circumstances, it is likely that specialized
-   :class:`Formatter`\ s would be used with particular :class:`Handler`\ s.
-
-   .. versionadded:: 3.2
-      The *stack_info* parameter was added.
-
-
-.. method:: Logger.info(msg, *args, **kwargs)
-
-   Logs a message with level :const:`INFO` on this logger. The arguments are
-   interpreted as for :meth:`debug`.
-
-
-.. method:: Logger.warning(msg, *args, **kwargs)
-
-   Logs a message with level :const:`WARNING` on this logger. The arguments are
-   interpreted as for :meth:`debug`.
-
-
-.. method:: Logger.error(msg, *args, **kwargs)
-
-   Logs a message with level :const:`ERROR` on this logger. The arguments are
-   interpreted as for :meth:`debug`.
-
-
-.. method:: Logger.critical(msg, *args, **kwargs)
-
-   Logs a message with level :const:`CRITICAL` on this logger. The arguments are
-   interpreted as for :meth:`debug`.
-
-
-.. method:: Logger.log(lvl, msg, *args, **kwargs)
-
-   Logs a message with integer level *lvl* on this logger. The other arguments are
-   interpreted as for :meth:`debug`.
-
-
-.. method:: Logger.exception(msg, *args)
-
-   Logs a message with level :const:`ERROR` on this logger. The arguments are
-   interpreted as for :meth:`debug`. Exception info is added to the logging
-   message. This method should only be called from an exception handler.
-
-
-.. method:: Logger.addFilter(filt)
-
-   Adds the specified filter *filt* to this logger.
-
-
-.. method:: Logger.removeFilter(filt)
-
-   Removes the specified filter *filt* from this logger.
-
-
-.. method:: Logger.filter(record)
-
-   Applies this logger's filters to the record and returns a true value if the
-   record is to be processed.
-
-
-.. method:: Logger.addHandler(hdlr)
-
-   Adds the specified handler *hdlr* to this logger.
-
-
-.. method:: Logger.removeHandler(hdlr)
-
-   Removes the specified handler *hdlr* from this logger.
-
-
-.. method:: Logger.findCaller(stack_info=False)
-
-   Finds the caller's source filename and line number. Returns the filename, line
-   number, function name and stack information as a 4-element tuple. The stack
-   information is returned as *None* unless *stack_info* is *True*.
-
-
-.. method:: Logger.handle(record)
-
-   Handles a record by passing it to all handlers associated with this logger and
-   its ancestors (until a false value of *propagate* is found). This method is used
-   for unpickled records received from a socket, as well as those created locally.
-   Logger-level filtering is applied using :meth:`~Logger.filter`.
-
-
-.. method:: Logger.makeRecord(name, lvl, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None)
-
-   This is a factory method which can be overridden in subclasses to create
-   specialized :class:`LogRecord` instances.
-
-.. method:: Logger.hasHandlers()
-
-   Checks to see if this logger has any handlers configured. This is done by
-   looking for handlers in this logger and its parents in the logger hierarchy.
-   Returns True if a handler was found, else False. The method stops searching
-   up the hierarchy whenever a logger with the "propagate" attribute set to
-   False is found - that will be the last logger which is checked for the
-   existence of handlers.
-
-.. versionadded:: 3.2
-
-The :meth:`hasHandlers` method was not present in previous versions.
-
-.. _minimal-example:
-
-Basic example
--------------
-
-The :mod:`logging` package provides a lot of flexibility, and its configuration
-can appear daunting.  This section demonstrates that simple use of the logging
-package is possible.
-
-The simplest example shows logging to the console::
-
-   import logging
-
-   logging.debug('A debug message')
-   logging.info('Some information')
-   logging.warning('A shot across the bows')
-
-If you run the above script, you'll see this::
-
-   WARNING:root:A shot across the bows
-
-Because no particular logger was specified, the system used the root logger. The
-debug and info messages didn't appear because by default, the root logger is
-configured to only handle messages with a severity of WARNING or above. The
-message format is also a configuration default, as is the output destination of
-the messages - ``sys.stderr``. The severity level, the message format and
-destination can be easily changed, as shown in the example below::
-
-   import logging
-
-   logging.basicConfig(level=logging.DEBUG,
-                       format='%(asctime)s %(levelname)s %(message)s',
-                       filename='myapp.log',
-                       filemode='w')
-   logging.debug('A debug message')
-   logging.info('Some information')
-   logging.warning('A shot across the bows')
-
-The :meth:`basicConfig` method is used to change the configuration defaults,
-which results in output (written to ``myapp.log``) which should look
-something like the following::
-
-   2004-07-02 13:00:08,743 DEBUG A debug message
-   2004-07-02 13:00:08,743 INFO Some information
-   2004-07-02 13:00:08,743 WARNING A shot across the bows
-
-This time, all messages with a severity of DEBUG or above were handled, and the
-format of the messages was also changed, and output went to the specified file
-rather than the console.
-
-.. XXX logging should probably be updated for new string formatting!
-
-Formatting uses the old Python string formatting - see section
-:ref:`old-string-formatting`. The format string takes the following common
-specifiers. For a complete list of specifiers, consult the :class:`Formatter`
-documentation.
-
-+-------------------+-----------------------------------------------+
-| Format            | Description                                   |
-+===================+===============================================+
-| ``%(name)s``      | Name of the logger (logging channel).         |
-+-------------------+-----------------------------------------------+
-| ``%(levelname)s`` | Text logging level for the message            |
-|                   | (``'DEBUG'``, ``'INFO'``, ``'WARNING'``,      |
-|                   | ``'ERROR'``, ``'CRITICAL'``).                 |
-+-------------------+-----------------------------------------------+
-| ``%(asctime)s``   | Human-readable time when the                  |
-|                   | :class:`LogRecord` was created.  By default   |
-|                   | this is of the form "2003-07-08 16:49:45,896" |
-|                   | (the numbers after the comma are millisecond  |
-|                   | portion of the time).                         |
-+-------------------+-----------------------------------------------+
-| ``%(message)s``   | The logged message.                           |
-+-------------------+-----------------------------------------------+
-
-To change the date/time format, you can pass an additional keyword parameter,
-*datefmt*, as in the following::
-
-   import logging
-
-   logging.basicConfig(level=logging.DEBUG,
-                       format='%(asctime)s %(levelname)-8s %(message)s',
-                       datefmt='%a, %d %b %Y %H:%M:%S',
-                       filename='/temp/myapp.log',
-                       filemode='w')
-   logging.debug('A debug message')
-   logging.info('Some information')
-   logging.warning('A shot across the bows')
-
-which would result in output like ::
-
-   Fri, 02 Jul 2004 13:06:18 DEBUG    A debug message
-   Fri, 02 Jul 2004 13:06:18 INFO     Some information
-   Fri, 02 Jul 2004 13:06:18 WARNING  A shot across the bows
-
-The date format string follows the requirements of :func:`strftime` - see the
-documentation for the :mod:`time` module.
-
-If, instead of sending logging output to the console or a file, you'd rather use
-a file-like object which you have created separately, you can pass it to
-:func:`basicConfig` using the *stream* keyword argument. Note that if both
-*stream* and *filename* keyword arguments are passed, the *stream* argument is
-ignored.
-
-Of course, you can put variable information in your output. To do this, simply
-have the message be a format string and pass in additional arguments containing
-the variable information, as in the following example::
-
-   import logging
-
-   logging.basicConfig(level=logging.DEBUG,
-                       format='%(asctime)s %(levelname)-8s %(message)s',
-                       datefmt='%a, %d %b %Y %H:%M:%S',
-                       filename='/temp/myapp.log',
-                       filemode='w')
-   logging.error('Pack my box with %d dozen %s', 5, 'liquor jugs')
-
-which would result in ::
-
-   Wed, 21 Jul 2004 15:35:16 ERROR    Pack my box with 5 dozen liquor jugs
-
-
-.. _multiple-destinations:
-
-Logging to multiple destinations
---------------------------------
-
-Let's say you want to log to console and file with different message formats and
-in differing circumstances. Say you want to log messages with levels of DEBUG
-and higher to file, and those messages at level INFO and higher to the console.
-Let's also assume that the file should contain timestamps, but the console
-messages should not. Here's how you can achieve this::
-
-   import logging
-
-   # set up logging to file - see previous section for more details
-   logging.basicConfig(level=logging.DEBUG,
-                       format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
-                       datefmt='%m-%d %H:%M',
-                       filename='/temp/myapp.log',
-                       filemode='w')
-   # define a Handler which writes INFO messages or higher to the sys.stderr
-   console = logging.StreamHandler()
-   console.setLevel(logging.INFO)
-   # set a format which is simpler for console use
-   formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
-   # tell the handler to use this format
-   console.setFormatter(formatter)
-   # add the handler to the root logger
-   logging.getLogger('').addHandler(console)
-
-   # Now, we can log to the root logger, or any other logger. First the root...
-   logging.info('Jackdaws love my big sphinx of quartz.')
-
-   # Now, define a couple of other loggers which might represent areas in your
-   # application:
-
-   logger1 = logging.getLogger('myapp.area1')
-   logger2 = logging.getLogger('myapp.area2')
-
-   logger1.debug('Quick zephyrs blow, vexing daft Jim.')
-   logger1.info('How quickly daft jumping zebras vex.')
-   logger2.warning('Jail zesty vixen who grabbed pay from quack.')
-   logger2.error('The five boxing wizards jump quickly.')
-
-When you run this, on the console you will see ::
-
-   root        : INFO     Jackdaws love my big sphinx of quartz.
-   myapp.area1 : INFO     How quickly daft jumping zebras vex.
-   myapp.area2 : WARNING  Jail zesty vixen who grabbed pay from quack.
-   myapp.area2 : ERROR    The five boxing wizards jump quickly.
-
-and in the file you will see something like ::
-
-   10-22 22:19 root         INFO     Jackdaws love my big sphinx of quartz.
-   10-22 22:19 myapp.area1  DEBUG    Quick zephyrs blow, vexing daft Jim.
-   10-22 22:19 myapp.area1  INFO     How quickly daft jumping zebras vex.
-   10-22 22:19 myapp.area2  WARNING  Jail zesty vixen who grabbed pay from quack.
-   10-22 22:19 myapp.area2  ERROR    The five boxing wizards jump quickly.
-
-As you can see, the DEBUG message only shows up in the file. The other messages
-are sent to both destinations.
-
-This example uses console and file handlers, but you can use any number and
-combination of handlers you choose.
-
-.. _logging-exceptions:
-
-Exceptions raised during logging
---------------------------------
-
-The logging package is designed to swallow exceptions which occur while logging
-in production. This is so that errors which occur while handling logging events
-- such as logging misconfiguration, network or other similar errors - do not
-cause the application using logging to terminate prematurely.
-
-:class:`SystemExit` and :class:`KeyboardInterrupt` exceptions are never
-swallowed. Other exceptions which occur during the :meth:`emit` method of a
-:class:`Handler` subclass are passed to its :meth:`handleError` method.
-
-The default implementation of :meth:`handleError` in :class:`Handler` checks
-to see if a module-level variable, :data:`raiseExceptions`, is set. If set, a
-traceback is printed to :data:`sys.stderr`. If not set, the exception is swallowed.
-
-**Note:** The default value of :data:`raiseExceptions` is ``True``. This is because
-during development, you typically want to be notified of any exceptions that
-occur. It's advised that you set :data:`raiseExceptions` to ``False`` for production
-usage.
-
-.. _context-info:
-
-Adding contextual information to your logging output
-----------------------------------------------------
-
-Sometimes you want logging output to contain contextual information in
-addition to the parameters passed to the logging call. For example, in a
-networked application, it may be desirable to log client-specific information
-in the log (e.g. remote client's username, or IP address). Although you could
-use the *extra* parameter to achieve this, it's not always convenient to pass
-the information in this way. While it might be tempting to create
-:class:`Logger` instances on a per-connection basis, this is not a good idea
-because these instances are not garbage collected. While this is not a problem
-in practice, when the number of :class:`Logger` instances is dependent on the
-level of granularity you want to use in logging an application, it could
-be hard to manage if the number of :class:`Logger` instances becomes
-effectively unbounded.
-
-
-Using LoggerAdapters to impart contextual information
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-An easy way in which you can pass contextual information to be output along
-with logging event information is to use the :class:`LoggerAdapter` class.
-This class is designed to look like a :class:`Logger`, so that you can call
-:meth:`debug`, :meth:`info`, :meth:`warning`, :meth:`error`,
-:meth:`exception`, :meth:`critical` and :meth:`log`. These methods have the
-same signatures as their counterparts in :class:`Logger`, so you can use the
-two types of instances interchangeably.
-
-When you create an instance of :class:`LoggerAdapter`, you pass it a
-:class:`Logger` instance and a dict-like object which contains your contextual
-information. When you call one of the logging methods on an instance of
-:class:`LoggerAdapter`, it delegates the call to the underlying instance of
-:class:`Logger` passed to its constructor, and arranges to pass the contextual
-information in the delegated call. Here's a snippet from the code of
-:class:`LoggerAdapter`::
-
-    def debug(self, msg, *args, **kwargs):
-        """
-        Delegate a debug call to the underlying logger, after adding
-        contextual information from this adapter instance.
-        """
-        msg, kwargs = self.process(msg, kwargs)
-        self.logger.debug(msg, *args, **kwargs)
-
-The :meth:`process` method of :class:`LoggerAdapter` is where the contextual
-information is added to the logging output. It's passed the message and
-keyword arguments of the logging call, and it passes back (potentially)
-modified versions of these to use in the call to the underlying logger. The
-default implementation of this method leaves the message alone, but inserts
-an "extra" key in the keyword argument whose value is the dict-like object
-passed to the constructor. Of course, if you had passed an "extra" keyword
-argument in the call to the adapter, it will be silently overwritten.
-
-The advantage of using "extra" is that the values in the dict-like object are
-merged into the :class:`LogRecord` instance's __dict__, allowing you to use
-customized strings with your :class:`Formatter` instances which know about
-the keys of the dict-like object. If you need a different method, e.g. if you
-want to prepend or append the contextual information to the message string,
-you just need to subclass :class:`LoggerAdapter` and override :meth:`process`
-to do what you need. Here's an example script which uses this class, which
-also illustrates what dict-like behaviour is needed from an arbitrary
-"dict-like" object for use in the constructor::
-
-   import logging
-
-   class ConnInfo:
-       """
-       An example class which shows how an arbitrary class can be used as
-       the 'extra' context information repository passed to a LoggerAdapter.
-       """
-
-       def __getitem__(self, name):
-           """
-           To allow this instance to look like a dict.
-           """
-           from random import choice
-           if name == "ip":
-               result = choice(["127.0.0.1", "192.168.0.1"])
-           elif name == "user":
-               result = choice(["jim", "fred", "sheila"])
-           else:
-               result = self.__dict__.get(name, "?")
-           return result
-
-       def __iter__(self):
-           """
-           To allow iteration over keys, which will be merged into
-           the LogRecord dict before formatting and output.
-           """
-           keys = ["ip", "user"]
-           keys.extend(self.__dict__.keys())
-           return keys.__iter__()
-
-   if __name__ == "__main__":
-       from random import choice
-       levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL)
-       a1 = logging.LoggerAdapter(logging.getLogger("a.b.c"),
-                                  { "ip" : "123.231.231.123", "user" : "sheila" })
-       logging.basicConfig(level=logging.DEBUG,
-                           format="%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s")
-       a1.debug("A debug message")
-       a1.info("An info message with %s", "some parameters")
-       a2 = logging.LoggerAdapter(logging.getLogger("d.e.f"), ConnInfo())
-       for x in range(10):
-           lvl = choice(levels)
-           lvlname = logging.getLevelName(lvl)
-           a2.log(lvl, "A message at %s level with %d %s", lvlname, 2, "parameters")
-
-When this script is run, the output should look something like this::
-
-   2008-01-18 14:49:54,023 a.b.c DEBUG    IP: 123.231.231.123 User: sheila   A debug message
-   2008-01-18 14:49:54,023 a.b.c INFO     IP: 123.231.231.123 User: sheila   An info message with some parameters
-   2008-01-18 14:49:54,023 d.e.f CRITICAL IP: 192.168.0.1     User: jim      A message at CRITICAL level with 2 parameters
-   2008-01-18 14:49:54,033 d.e.f INFO     IP: 192.168.0.1     User: jim      A message at INFO level with 2 parameters
-   2008-01-18 14:49:54,033 d.e.f WARNING  IP: 192.168.0.1     User: sheila   A message at WARNING level with 2 parameters
-   2008-01-18 14:49:54,033 d.e.f ERROR    IP: 127.0.0.1       User: fred     A message at ERROR level with 2 parameters
-   2008-01-18 14:49:54,033 d.e.f ERROR    IP: 127.0.0.1       User: sheila   A message at ERROR level with 2 parameters
-   2008-01-18 14:49:54,033 d.e.f WARNING  IP: 192.168.0.1     User: sheila   A message at WARNING level with 2 parameters
-   2008-01-18 14:49:54,033 d.e.f WARNING  IP: 192.168.0.1     User: jim      A message at WARNING level with 2 parameters
-   2008-01-18 14:49:54,033 d.e.f INFO     IP: 192.168.0.1     User: fred     A message at INFO level with 2 parameters
-   2008-01-18 14:49:54,033 d.e.f WARNING  IP: 192.168.0.1     User: sheila   A message at WARNING level with 2 parameters
-   2008-01-18 14:49:54,033 d.e.f WARNING  IP: 127.0.0.1       User: jim      A message at WARNING level with 2 parameters
-
-
-.. _filters-contextual:
-
-Using Filters to impart contextual information
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-You can also add contextual information to log output using a user-defined
-:class:`Filter`. ``Filter`` instances are allowed to modify the ``LogRecords``
-passed to them, including adding additional attributes which can then be output
-using a suitable format string, or if needed a custom :class:`Formatter`.
-
-For example in a web application, the request being processed (or at least,
-the interesting parts of it) can be stored in a threadlocal
-(:class:`threading.local`) variable, and then accessed from a ``Filter`` to
-add, say, information from the request - say, the remote IP address and remote
-user's username - to the ``LogRecord``, using the attribute names 'ip' and
-'user' as in the ``LoggerAdapter`` example above. In that case, the same format
-string can be used to get similar output to that shown above. Here's an example
-script::
-
-    import logging
-    from random import choice
-
-    class ContextFilter(logging.Filter):
-        """
-        This is a filter which injects contextual information into the log.
-
-        Rather than use actual contextual information, we just use random
-        data in this demo.
-        """
-
-        USERS = ['jim', 'fred', 'sheila']
-        IPS = ['123.231.231.123', '127.0.0.1', '192.168.0.1']
-
-        def filter(self, record):
-
-            record.ip = choice(ContextFilter.IPS)
-            record.user = choice(ContextFilter.USERS)
-            return True
-
-    if __name__ == "__main__":
-       levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL)
-       a1 = logging.LoggerAdapter(logging.getLogger("a.b.c"),
-                                  { "ip" : "123.231.231.123", "user" : "sheila" })
-       logging.basicConfig(level=logging.DEBUG,
-                           format="%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s")
-       a1 = logging.getLogger("a.b.c")
-       a2 = logging.getLogger("d.e.f")
-
-       f = ContextFilter()
-       a1.addFilter(f)
-       a2.addFilter(f)
-       a1.debug("A debug message")
-       a1.info("An info message with %s", "some parameters")
-       for x in range(10):
-           lvl = choice(levels)
-           lvlname = logging.getLevelName(lvl)
-           a2.log(lvl, "A message at %s level with %d %s", lvlname, 2, "parameters")
-
-which, when run, produces something like::
-
-    2010-09-06 22:38:15,292 a.b.c DEBUG    IP: 123.231.231.123 User: fred     A debug message
-    2010-09-06 22:38:15,300 a.b.c INFO     IP: 192.168.0.1     User: sheila   An info message with some parameters
-    2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 127.0.0.1       User: sheila   A message at CRITICAL level with 2 parameters
-    2010-09-06 22:38:15,300 d.e.f ERROR    IP: 127.0.0.1       User: jim      A message at ERROR level with 2 parameters
-    2010-09-06 22:38:15,300 d.e.f DEBUG    IP: 127.0.0.1       User: sheila   A message at DEBUG level with 2 parameters
-    2010-09-06 22:38:15,300 d.e.f ERROR    IP: 123.231.231.123 User: fred     A message at ERROR level with 2 parameters
-    2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 192.168.0.1     User: jim      A message at CRITICAL level with 2 parameters
-    2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 127.0.0.1       User: sheila   A message at CRITICAL level with 2 parameters
-    2010-09-06 22:38:15,300 d.e.f DEBUG    IP: 192.168.0.1     User: jim      A message at DEBUG level with 2 parameters
-    2010-09-06 22:38:15,301 d.e.f ERROR    IP: 127.0.0.1       User: sheila   A message at ERROR level with 2 parameters
-    2010-09-06 22:38:15,301 d.e.f DEBUG    IP: 123.231.231.123 User: fred     A message at DEBUG level with 2 parameters
-    2010-09-06 22:38:15,301 d.e.f INFO     IP: 123.231.231.123 User: fred     A message at INFO level with 2 parameters
-
-
-.. _multiple-processes:
-
-Logging to a single file from multiple processes
-------------------------------------------------
-
-Although logging is thread-safe, and logging to a single file from multiple
-threads in a single process *is* supported, logging to a single file from
-*multiple processes* is *not* supported, because there is no standard way to
-serialize access to a single file across multiple processes in Python. If you
-need to log to a single file from multiple processes, one way of doing this is
-to have all the processes log to a :class:`SocketHandler`, and have a separate
-process which implements a socket server which reads from the socket and logs
-to file. (If you prefer, you can dedicate one thread in one of the existing
-processes to perform this function.) The following section documents this
-approach in more detail and includes a working socket receiver which can be
-used as a starting point for you to adapt in your own applications.
-
-If you are using a recent version of Python which includes the
-:mod:`multiprocessing` module, you could write your own handler which uses the
-:class:`Lock` class from this module to serialize access to the file from
-your processes. The existing :class:`FileHandler` and subclasses do not make
-use of :mod:`multiprocessing` at present, though they may do so in the future.
-Note that at present, the :mod:`multiprocessing` module does not provide
-working lock functionality on all platforms (see
-http://bugs.python.org/issue3770).
-
-.. currentmodule:: logging.handlers
-
-Alternatively, you can use a ``Queue`` and a :class:`QueueHandler` to send
-all logging events to one of the processes in your multi-process application.
-The following example script demonstrates how you can do this; in the example
-a separate listener process listens for events sent by other processes and logs
-them according to its own logging configuration. Although the example only
-demonstrates one way of doing it (for example, you may want to use a listener
-thread rather than a separate listener process - the implementation would be
-analogous) it does allow for completely different logging configurations for
-the listener and the other processes in your application, and can be used as
-the basis for code meeting your own specific requirements::
-
-    # You'll need these imports in your own code
-    import logging
-    import logging.handlers
-    import multiprocessing
-
-    # Next two import lines for this demo only
-    from random import choice, random
-    import time
-
-    #
-    # Because you'll want to define the logging configurations for listener and workers, the
-    # listener and worker process functions take a configurer parameter which is a callable
-    # for configuring logging for that process. These functions are also passed the queue,
-    # which they use for communication.
-    #
-    # In practice, you can configure the listener however you want, but note that in this
-    # simple example, the listener does not apply level or filter logic to received records.
-    # In practice, you would probably want to do ths logic in the worker processes, to avoid
-    # sending events which would be filtered out between processes.
-    #
-    # The size of the rotated files is made small so you can see the results easily.
-    def listener_configurer():
-        root = logging.getLogger()
-        h = logging.handlers.RotatingFileHandler('/tmp/mptest.log', 'a', 300, 10)
-        f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %(levelname)-8s %(message)s')
-        h.setFormatter(f)
-        root.addHandler(h)
-
-    # This is the listener process top-level loop: wait for logging events
-    # (LogRecords)on the queue and handle them, quit when you get a None for a
-    # LogRecord.
-    def listener_process(queue, configurer):
-        configurer()
-        while True:
-            try:
-                record = queue.get()
-                if record is None: # We send this as a sentinel to tell the listener to quit.
-                    break
-                logger = logging.getLogger(record.name)
-                logger.handle(record) # No level or filter logic applied - just do it!
-            except (KeyboardInterrupt, SystemExit):
-                raise
-            except:
-                import sys, traceback
-                print >> sys.stderr, 'Whoops! Problem:'
-                traceback.print_exc(file=sys.stderr)
-
-    # Arrays used for random selections in this demo
-
-    LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING,
-              logging.ERROR, logging.CRITICAL]
-
-    LOGGERS = ['a.b.c', 'd.e.f']
-
-    MESSAGES = [
-        'Random message #1',
-        'Random message #2',
-        'Random message #3',
-    ]
-
-    # The worker configuration is done at the start of the worker process run.
-    # Note that on Windows you can't rely on fork semantics, so each process
-    # will run the logging configuration code when it starts.
-    def worker_configurer(queue):
-        h = logging.handlers.QueueHandler(queue) # Just the one handler needed
-        root = logging.getLogger()
-        root.addHandler(h)
-        root.setLevel(logging.DEBUG) # send all messages, for demo; no other level or filter logic applied.
-
-    # This is the worker process top-level loop, which just logs ten events with
-    # random intervening delays before terminating.
-    # The print messages are just so you know it's doing something!
-    def worker_process(queue, configurer):
-        configurer(queue)
-        name = multiprocessing.current_process().name
-        print('Worker started: %s' % name)
-        for i in range(10):
-            time.sleep(random())
-            logger = logging.getLogger(choice(LOGGERS))
-            level = choice(LEVELS)
-            message = choice(MESSAGES)
-            logger.log(level, message)
-        print('Worker finished: %s' % name)
-
-    # Here's where the demo gets orchestrated. Create the queue, create and start
-    # the listener, create ten workers and start them, wait for them to finish,
-    # then send a None to the queue to tell the listener to finish.
-    def main():
-        queue = multiprocessing.Queue(-1)
-        listener = multiprocessing.Process(target=listener_process,
-                                           args=(queue, listener_configurer))
-        listener.start()
-        workers = []
-        for i in range(10):
-            worker = multiprocessing.Process(target=worker_process,
-                                           args=(queue, worker_configurer))
-            workers.append(worker)
-            worker.start()
-        for w in workers:
-            w.join()
-        queue.put_nowait(None)
-        listener.join()
-
-    if __name__ == '__main__':
-        main()
-
-
-.. currentmodule:: logging
-
-
-.. _network-logging:
-
-Sending and receiving logging events across a network
------------------------------------------------------
-
-Let's say you want to send logging events across a network, and handle them at
-the receiving end. A simple way of doing this is attaching a
-:class:`SocketHandler` instance to the root logger at the sending end::
-
-   import logging, logging.handlers
-
-   rootLogger = logging.getLogger('')
-   rootLogger.setLevel(logging.DEBUG)
-   socketHandler = logging.handlers.SocketHandler('localhost',
-                       logging.handlers.DEFAULT_TCP_LOGGING_PORT)
-   # don't bother with a formatter, since a socket handler sends the event as
-   # an unformatted pickle
-   rootLogger.addHandler(socketHandler)
-
-   # Now, we can log to the root logger, or any other logger. First the root...
-   logging.info('Jackdaws love my big sphinx of quartz.')
-
-   # Now, define a couple of other loggers which might represent areas in your
-   # application:
-
-   logger1 = logging.getLogger('myapp.area1')
-   logger2 = logging.getLogger('myapp.area2')
-
-   logger1.debug('Quick zephyrs blow, vexing daft Jim.')
-   logger1.info('How quickly daft jumping zebras vex.')
-   logger2.warning('Jail zesty vixen who grabbed pay from quack.')
-   logger2.error('The five boxing wizards jump quickly.')
-
-At the receiving end, you can set up a receiver using the :mod:`socketserver`
-module. Here is a basic working example::
-
-   import pickle
-   import logging
-   import logging.handlers
-   import socketserver
-   import struct
-
-
-   class LogRecordStreamHandler(socketserver.StreamRequestHandler):
-       """Handler for a streaming logging request.
-
-       This basically logs the record using whatever logging policy is
-       configured locally.
-       """
-
-       def handle(self):
-           """
-           Handle multiple requests - each expected to be a 4-byte length,
-           followed by the LogRecord in pickle format. Logs the record
-           according to whatever policy is configured locally.
-           """
-           while True:
-               chunk = self.connection.recv(4)
-               if len(chunk) < 4:
-                   break
-               slen = struct.unpack(">L", chunk)[0]
-               chunk = self.connection.recv(slen)
-               while len(chunk) < slen:
-                   chunk = chunk + self.connection.recv(slen - len(chunk))
-               obj = self.unPickle(chunk)
-               record = logging.makeLogRecord(obj)
-               self.handleLogRecord(record)
-
-       def unPickle(self, data):
-           return pickle.loads(data)
-
-       def handleLogRecord(self, record):
-           # if a name is specified, we use the named logger rather than the one
-           # implied by the record.
-           if self.server.logname is not None:
-               name = self.server.logname
-           else:
-               name = record.name
-           logger = logging.getLogger(name)
-           # N.B. EVERY record gets logged. This is because Logger.handle
-           # is normally called AFTER logger-level filtering. If you want
-           # to do filtering, do it at the client end to save wasting
-           # cycles and network bandwidth!
-           logger.handle(record)
-
-   class LogRecordSocketReceiver(socketserver.ThreadingTCPServer):
-       """simple TCP socket-based logging receiver suitable for testing.
-       """
-
-       allow_reuse_address = 1
-
-       def __init__(self, host='localhost',
-                    port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
-                    handler=LogRecordStreamHandler):
-           socketserver.ThreadingTCPServer.__init__(self, (host, port), handler)
-           self.abort = 0
-           self.timeout = 1
-           self.logname = None
-
-       def serve_until_stopped(self):
-           import select
-           abort = 0
-           while not abort:
-               rd, wr, ex = select.select([self.socket.fileno()],
-                                          [], [],
-                                          self.timeout)
-               if rd:
-                   self.handle_request()
-               abort = self.abort
-
-   def main():
-       logging.basicConfig(
-           format="%(relativeCreated)5d %(name)-15s %(levelname)-8s %(message)s")
-       tcpserver = LogRecordSocketReceiver()
-       print("About to start TCP server...")
-       tcpserver.serve_until_stopped()
-
-   if __name__ == "__main__":
-       main()
-
-First run the server, and then the client. On the client side, nothing is
-printed on the console; on the server side, you should see something like::
-
-   About to start TCP server...
-      59 root            INFO     Jackdaws love my big sphinx of quartz.
-      59 myapp.area1     DEBUG    Quick zephyrs blow, vexing daft Jim.
-      69 myapp.area1     INFO     How quickly daft jumping zebras vex.
-      69 myapp.area2     WARNING  Jail zesty vixen who grabbed pay from quack.
-      69 myapp.area2     ERROR    The five boxing wizards jump quickly.
-
-Note that there are some security issues with pickle in some scenarios. If
-these affect you, you can use an alternative serialization scheme by overriding
-the :meth:`makePickle` method and implementing your alternative there, as
-well as adapting the above script to use your alternative serialization.
-
-.. _arbitrary-object-messages:
-
-Using arbitrary objects as messages
------------------------------------
-
-In the preceding sections and examples, it has been assumed that the message
-passed when logging the event is a string. However, this is not the only
-possibility. You can pass an arbitrary object as a message, and its
-:meth:`__str__` method will be called when the logging system needs to convert
-it to a string representation. In fact, if you want to, you can avoid
-computing a string representation altogether - for example, the
-:class:`SocketHandler` emits an event by pickling it and sending it over the
-wire.
-
-Dealing with handlers that block
---------------------------------
-
-.. currentmodule:: logging.handlers
-
-Sometimes you have to get your logging handlers to do their work without
-blocking the thread you’re logging from. This is common in Web applications,
-though of course it also occurs in other scenarios.
-
-A common culprit which demonstrates sluggish behaviour is the
-:class:`SMTPHandler`: sending emails can take a long time, for a
-number of reasons outside the developer’s control (for example, a poorly
-performing mail or network infrastructure). But almost any network-based
-handler can block: Even a :class:`SocketHandler` operation may do a
-DNS query under the hood which is too slow (and this query can be deep in the
-socket library code, below the Python layer, and outside your control).
-
-One solution is to use a two-part approach. For the first part, attach only a
-:class:`QueueHandler` to those loggers which are accessed from
-performance-critical threads. They simply write to their queue, which can be
-sized to a large enough capacity or initialized with no upper bound to their
-size. The write to the queue will typically be accepted quickly, though you
-will probably need to catch the :ref:`queue.Full` exception as a precaution
-in your code. If you are a library developer who has performance-critical
-threads in their code, be sure to document this (together with a suggestion to
-attach only ``QueueHandlers`` to your loggers) for the benefit of other
-developers who will use your code.
-
-The second part of the solution is :class:`QueueListener`, which has been
-designed as the counterpart to :class:`QueueHandler`.  A
-:class:`QueueListener` is very simple: it’s passed a queue and some handlers,
-and it fires up an internal thread which listens to its queue for LogRecords
-sent from ``QueueHandlers`` (or any other source of ``LogRecords``, for that
-matter). The ``LogRecords`` are removed from the queue and passed to the
-handlers for processing.
-
-The advantage of having a separate :class:`QueueListener` class is that you
-can use the same instance to service multiple ``QueueHandlers``. This is more
-resource-friendly than, say, having threaded versions of the existing handler
-classes, which would eat up one thread per handler for no particular benefit.
-
-An example of using these two classes follows (imports omitted)::
-
-    que = queue.Queue(-1) # no limit on size
-    queue_handler = QueueHandler(que)
-    handler = logging.StreamHandler()
-    listener = QueueListener(que, handler)
-    root = logging.getLogger()
-    root.addHandler(queue_handler)
-    formatter = logging.Formatter('%(threadName)s: %(message)s')
-    handler.setFormatter(formatter)
-    listener.start()
-    # The log output will display the thread which generated
-    # the event (the main thread) rather than the internal
-    # thread which monitors the internal queue. This is what
-    # you want to happen.
-    root.warning('Look out!')
-    listener.stop()
-
-which, when run, will produce::
-
-    MainThread: Look out!
-
-
-Optimization
-------------
-
-Formatting of message arguments is deferred until it cannot be avoided.
-However, computing the arguments passed to the logging method can also be
-expensive, and you may want to avoid doing it if the logger will just throw
-away your event. To decide what to do, you can call the :meth:`isEnabledFor`
-method which takes a level argument and returns true if the event would be
-created by the Logger for that level of call. You can write code like this::
-
-    if logger.isEnabledFor(logging.DEBUG):
-        logger.debug("Message with %s, %s", expensive_func1(),
-                                            expensive_func2())
-
-so that if the logger's threshold is set above ``DEBUG``, the calls to
-:func:`expensive_func1` and :func:`expensive_func2` are never made.
-
-There are other optimizations which can be made for specific applications which
-need more precise control over what logging information is collected. Here's a
-list of things you can do to avoid processing during logging which you don't
-need:
-
-+-----------------------------------------------+----------------------------------------+
-| What you don't want to collect                | How to avoid collecting it             |
-+===============================================+========================================+
-| Information about where calls were made from. | Set ``logging._srcfile`` to ``None``.  |
-+-----------------------------------------------+----------------------------------------+
-| Threading information.                        | Set ``logging.logThreads`` to ``0``.   |
-+-----------------------------------------------+----------------------------------------+
-| Process information.                          | Set ``logging.logProcesses`` to ``0``. |
-+-----------------------------------------------+----------------------------------------+
-
-Also note that the core logging module only includes the basic handlers. If
-you don't import :mod:`logging.handlers` and :mod:`logging.config`, they won't
-take up any memory.
 
 .. _handler:
 
@@ -2129,1171 +379,653 @@
    is intended to be implemented by subclasses and so raises a
    :exc:`NotImplementedError`.
 
+For a list of handlers included as standard, see :mod:`logging.handlers`.
 
-.. _stream-handler:
-
-StreamHandler
-^^^^^^^^^^^^^
-
-The :class:`StreamHandler` class, located in the core :mod:`logging` package,
-sends logging output to streams such as *sys.stdout*, *sys.stderr* or any
-file-like object (or, more precisely, any object which supports :meth:`write`
-and :meth:`flush` methods).
+.. _formatter-objects:
 
+Formatter Objects
+-----------------
 
 .. currentmodule:: logging
 
-.. class:: StreamHandler(stream=None)
-
-   Returns a new instance of the :class:`StreamHandler` class. If *stream* is
-   specified, the instance will use it for logging output; otherwise, *sys.stderr*
-   will be used.
-
-
-   .. method:: emit(record)
+:class:`Formatter` objects have the following attributes and methods. They are
+responsible for converting a :class:`LogRecord` to (usually) a string which can
+be interpreted by either a human or an external system. The base
+:class:`Formatter` allows a formatting string to be specified. If none is
+supplied, the default value of ``'%(message)s'`` is used.
 
-      If a formatter is specified, it is used to format the record. The record
-      is then written to the stream with a trailing newline. If exception
-      information is present, it is formatted using
-      :func:`traceback.print_exception` and appended to the stream.
+A Formatter can be initialized with a format string which makes use of knowledge
+of the :class:`LogRecord` attributes - such as the default value mentioned above
+making use of the fact that the user's message and arguments are pre-formatted
+into a :class:`LogRecord`'s *message* attribute.  This format string contains
+standard Python %-style mapping keys. See section :ref:`old-string-formatting`
+for more information on string formatting.
 
+The useful mapping keys in a :class:`LogRecord` are given in the section on
+:ref:`logrecord-attributes`.
 
-   .. method:: flush()
 
-      Flushes the stream by calling its :meth:`flush` method. Note that the
-      :meth:`close` method is inherited from :class:`Handler` and so does
-      no output, so an explicit :meth:`flush` call may be needed at times.
+.. class:: Formatter(fmt=None, datefmt=None)
 
-.. versionchanged:: 3.2
-   The ``StreamHandler`` class now has a ``terminator`` attribute, default
-   value ``"\n"``, which is used as the terminator when writing a formatted
-   record to a stream. If you don't want this newline termination, you can
-   set the handler instance's ``terminator`` attribute to the empty string.
-
-.. _file-handler:
-
-FileHandler
-^^^^^^^^^^^
-
-The :class:`FileHandler` class, located in the core :mod:`logging` package,
-sends logging output to a disk file.  It inherits the output functionality from
-:class:`StreamHandler`.
+   Returns a new instance of the :class:`Formatter` class.  The instance is
+   initialized with a format string for the message as a whole, as well as a
+   format string for the date/time portion of a message.  If no *fmt* is
+   specified, ``'%(message)s'`` is used.  If no *datefmt* is specified, the
+   ISO8601 date format is used.
 
+   .. method:: format(record)
 
-.. class:: FileHandler(filename, mode='a', encoding=None, delay=False)
+      The record's attribute dictionary is used as the operand to a string
+      formatting operation. Returns the resulting string. Before formatting the
+      dictionary, a couple of preparatory steps are carried out. The *message*
+      attribute of the record is computed using *msg* % *args*. If the
+      formatting string contains ``'(asctime)'``, :meth:`formatTime` is called
+      to format the event time. If there is exception information, it is
+      formatted using :meth:`formatException` and appended to the message. Note
+      that the formatted exception information is cached in attribute
+      *exc_text*. This is useful because the exception information can be
+      pickled and sent across the wire, but you should be careful if you have
+      more than one :class:`Formatter` subclass which customizes the formatting
+      of exception information. In this case, you will have to clear the cached
+      value after a formatter has done its formatting, so that the next
+      formatter to handle the event doesn't use the cached value but
+      recalculates it afresh.
 
-   Returns a new instance of the :class:`FileHandler` class. The specified file is
-   opened and used as the stream for logging. If *mode* is not specified,
-   :const:`'a'` is used.  If *encoding* is not *None*, it is used to open the file
-   with that encoding.  If *delay* is true, then file opening is deferred until the
-   first call to :meth:`emit`. By default, the file grows indefinitely.
+      If stack information is available, it's appended after the exception
+      information, using :meth:`formatStack` to transform it if necessary.
 
 
-   .. method:: close()
+   .. method:: formatTime(record, datefmt=None)
 
-      Closes the file.
+      This method should be called from :meth:`format` by a formatter which
+      wants to make use of a formatted time. This method can be overridden in
+      formatters to provide for any specific requirement, but the basic behavior
+      is as follows: if *datefmt* (a string) is specified, it is used with
+      :func:`time.strftime` to format the creation time of the
+      record. Otherwise, the ISO8601 format is used.  The resulting string is
+      returned.
 
 
-   .. method:: emit(record)
+   .. method:: formatException(exc_info)
 
-      Outputs the record to the file.
+      Formats the specified exception information (a standard exception tuple as
+      returned by :func:`sys.exc_info`) as a string. This default implementation
+      just uses :func:`traceback.print_exception`. The resulting string is
+      returned.
 
-.. _null-handler:
+   .. method:: formatStack(stack_info)
 
-NullHandler
-^^^^^^^^^^^
+      Formats the specified stack information (a string as returned by
+      :func:`traceback.print_stack`, but with the last newline removed) as a
+      string. This default implementation just returns the input value.
 
-.. versionadded:: 3.1
+.. _filter:
 
-The :class:`NullHandler` class, located in the core :mod:`logging` package,
-does not do any formatting or output. It is essentially a "no-op" handler
-for use by library developers.
+Filter Objects
+--------------
 
+``Filters`` can be used by ``Handlers`` and ``Loggers`` for more sophisticated
+filtering than is provided by levels. The base filter class only allows events
+which are below a certain point in the logger hierarchy. For example, a filter
+initialized with 'A.B' will allow events logged by loggers 'A.B', 'A.B.C',
+'A.B.C.D', 'A.B.D' etc. but not 'A.BB', 'B.A.B' etc. If initialized with the
+empty string, all events are passed.
 
-.. class:: NullHandler()
 
-   Returns a new instance of the :class:`NullHandler` class.
+.. class:: Filter(name='')
 
+   Returns an instance of the :class:`Filter` class. If *name* is specified, it
+   names a logger which, together with its children, will have its events allowed
+   through the filter. If *name* is the empty string, allows every event.
 
-   .. method:: emit(record)
 
-      This method does nothing.
+   .. method:: filter(record)
 
-   .. method:: handle(record)
+      Is the specified record to be logged? Returns zero for no, nonzero for
+      yes. If deemed appropriate, the record may be modified in-place by this
+      method.
 
-      This method does nothing.
+Note that filters attached to handlers are consulted whenever an event is
+emitted by the handler, whereas filters attached to loggers are consulted
+whenever an event is logged to the handler (using :meth:`debug`, :meth:`info`,
+etc.) This means that events which have been generated by descendant loggers
+will not be filtered by a logger's filter setting, unless the filter has also
+been applied to those descendant loggers.
 
-   .. method:: createLock()
+You don't actually need to subclass ``Filter``: you can pass any instance
+which has a ``filter`` method with the same semantics.
 
-      This method returns ``None`` for the lock, since there is no
-      underlying I/O to which access needs to be serialized.
+.. versionchanged:: 3.2
+   You don't need to create specialized ``Filter`` classes, or use other
+   classes with a ``filter`` method: you can use a function (or other
+   callable) as a filter. The filtering logic will check to see if the filter
+   object has a ``filter`` attribute: if it does, it's assumed to be a
+   ``Filter`` and its :meth:`~Filter.filter` method is called. Otherwise, it's
+   assumed to be a callable and called with the record as the single
+   parameter. The returned value should conform to that returned by
+   :meth:`~Filter.filter`.
 
+Although filters are used primarily to filter records based on more
+sophisticated criteria than levels, they get to see every record which is
+processed by the handler or logger they're attached to: this can be useful if
+you want to do things like counting how many records were processed by a
+particular logger or handler, or adding, changing or removing attributes in
+the LogRecord being processed. Obviously changing the LogRecord needs to be
+done with some care, but it does allow the injection of contextual information
+into logs (see :ref:`filters-contextual`).
 
-See :ref:`library-config` for more information on how to use
-:class:`NullHandler`.
+.. _log-record:
 
-.. _watched-file-handler:
+LogRecord Objects
+-----------------
 
-WatchedFileHandler
-^^^^^^^^^^^^^^^^^^
+:class:`LogRecord` instances are created automatically by the :class:`Logger`
+every time something is logged, and can be created manually via
+:func:`makeLogRecord` (for example, from a pickled event received over the
+wire).
 
-.. currentmodule:: logging.handlers
 
-The :class:`WatchedFileHandler` class, located in the :mod:`logging.handlers`
-module, is a :class:`FileHandler` which watches the file it is logging to. If
-the file changes, it is closed and reopened using the file name.
+.. class:: LogRecord(name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None)
 
-A file change can happen because of usage of programs such as *newsyslog* and
-*logrotate* which perform log file rotation. This handler, intended for use
-under Unix/Linux, watches the file to see if it has changed since the last emit.
-(A file is deemed to have changed if its device or inode have changed.) If the
-file has changed, the old file stream is closed, and the file opened to get a
-new stream.
+   Contains all the information pertinent to the event being logged.
 
-This handler is not appropriate for use under Windows, because under Windows
-open log files cannot be moved or renamed - logging opens the files with
-exclusive locks - and so there is no need for such a handler. Furthermore,
-*ST_INO* is not supported under Windows; :func:`stat` always returns zero for
-this value.
+   The primary information is passed in :attr:`msg` and :attr:`args`, which
+   are combined using ``msg % args`` to create the :attr:`message` field of the
+   record.
 
+   :param name:  The name of the logger used to log the event represented by
+                 this LogRecord.
+   :param level: The numeric level of the logging event (one of DEBUG, INFO etc.)
+   :param pathname: The full pathname of the source file where the logging call
+                    was made.
+   :param lineno: The line number in the source file where the logging call was
+                  made.
+   :param msg: The event description message, possibly a format string with
+               placeholders for variable data.
+   :param args: Variable data to merge into the *msg* argument to obtain the
+                event description.
+   :param exc_info: An exception tuple with the current exception information,
+                    or *None* if no exception information is available.
+   :param func: The name of the function or method from which the logging call
+                was invoked.
+   :param sinfo: A text string representing stack information from the base of
+                 the stack in the current thread, up to the logging call.
 
-.. class:: WatchedFileHandler(filename[,mode[, encoding[, delay]]])
+   .. method:: getMessage()
 
-   Returns a new instance of the :class:`WatchedFileHandler` class. The specified
-   file is opened and used as the stream for logging. If *mode* is not specified,
-   :const:`'a'` is used.  If *encoding* is not *None*, it is used to open the file
-   with that encoding.  If *delay* is true, then file opening is deferred until the
-   first call to :meth:`emit`.  By default, the file grows indefinitely.
+      Returns the message for this :class:`LogRecord` instance after merging any
+      user-supplied arguments with the message. If the user-supplied message
+      argument to the logging call is not a string, :func:`str` is called on it to
+      convert it to a string. This allows use of user-defined classes as
+      messages, whose ``__str__`` method can return the actual format string to
+      be used.
 
+   .. versionchanged:: 3.2
+      The creation of a ``LogRecord`` has been made more configurable by
+      providing a factory which is used to create the record. The factory can be
+      set using :func:`getLogRecordFactory` and :func:`setLogRecordFactory`
+      (see this for the factory's signature).
+
+   This functionality can be used to inject your own values into a
+   LogRecord at creation time. You can use the following pattern::
+
+      old_factory = logging.getLogRecordFactory()
+
+      def record_factory(*args, **kwargs):
+          record = old_factory(*args, **kwargs)
+          record.custom_attribute = 0xdecafbad
+          return record
+
+      logging.setLogRecordFactory(record_factory)
+
+   With this pattern, multiple factories could be chained, and as long
+   as they don't overwrite each other's attributes or unintentionally
+   overwrite the standard attributes listed above, there should be no
+   surprises.
+
+
+.. _logrecord-attributes:
+
+LogRecord attributes
+--------------------
+
+The LogRecord has a number of attributes, most of which are derived from the
+parameters to the constructor. (Note that the names do not always correspond
+exactly between the LogRecord constructor parameters and the LogRecord
+attributes.) These attributes can be used to merge data from the record into
+the format string. The following table lists (in alphabetical order) the
+attribute names, their meanings and the corresponding placeholder in a %-style
+format string.
+
+If you are using {}-formatting (:func:`str.format`), you can use
+``{attrname}`` as the placeholder in the format string. If you are using
+$-formatting (:class:`string.Template`), use the form ``${attrname}``. In
+both cases, of course, replace ``attrname`` with the actual attribute name
+you want to use.
+
+In the case of {}-formatting, you can specify formatting flags by placing them
+after the attribute name, separated from it with a colon. For example: a
+placeholder of ``{msecs:03d}`` would format a millisecond value of ``4`` as
+``004``. Refer to the :meth:`str.format` documentation for full details on
+the options available to you.
+
++----------------+-------------------------+-----------------------------------------------+
+| Attribute name | Format                  | Description                                   |
++================+=========================+===============================================+
+| args           | You shouldn't need to   | The tuple of arguments merged into ``msg`` to |
+|                | format this yourself.   | produce ``message``.                          |
++----------------+-------------------------+-----------------------------------------------+
+| asctime        | ``%(asctime)s``         | Human-readable time when the                  |
+|                |                         | :class:`LogRecord` was created.  By default   |
+|                |                         | this is of the form '2003-07-08 16:49:45,896' |
+|                |                         | (the numbers after the comma are millisecond  |
+|                |                         | portion of the time).                         |
++----------------+-------------------------+-----------------------------------------------+
+| created        | ``%(created)f``         | Time when the :class:`LogRecord` was created  |
+|                |                         | (as returned by :func:`time.time`).           |
++----------------+-------------------------+-----------------------------------------------+
+| exc_info       | You shouldn't need to   | Exception tuple (à la ``sys.exc_info``) or,   |
+|                | format this yourself.   | if no exception has occurred, *None*.         |
++----------------+-------------------------+-----------------------------------------------+
+| filename       | ``%(filename)s``        | Filename portion of ``pathname``.             |
++----------------+-------------------------+-----------------------------------------------+
+| funcName       | ``%(funcName)s``        | Name of function containing the logging call. |
++----------------+-------------------------+-----------------------------------------------+
+| levelname      | ``%(levelname)s``       | Text logging level for the message            |
+|                |                         | (``'DEBUG'``, ``'INFO'``, ``'WARNING'``,      |
+|                |                         | ``'ERROR'``, ``'CRITICAL'``).                 |
++----------------+-------------------------+-----------------------------------------------+
+| levelno        | ``%(levelno)s``         | Numeric logging level for the message         |
+|                |                         | (:const:`DEBUG`, :const:`INFO`,               |
+|                |                         | :const:`WARNING`, :const:`ERROR`,             |
+|                |                         | :const:`CRITICAL`).                           |
++----------------+-------------------------+-----------------------------------------------+
+| lineno         | ``%(lineno)d``          | Source line number where the logging call was |
+|                |                         | issued (if available).                        |
++----------------+-------------------------+-----------------------------------------------+
+| module         | ``%(module)s``          | Module (name portion of ``filename``).        |
++----------------+-------------------------+-----------------------------------------------+
+| msecs          | ``%(msecs)d``           | Millisecond portion of the time when the      |
+|                |                         | :class:`LogRecord` was created.               |
++----------------+-------------------------+-----------------------------------------------+
+| message        | ``%(message)s``         | The logged message, computed as ``msg %       |
+|                |                         | args``. This is set when                      |
+|                |                         | :meth:`Formatter.format` is invoked.          |
++----------------+-------------------------+-----------------------------------------------+
+| msg            | You shouldn't need to   | The format string passed in the original      |
+|                | format this yourself.   | logging call. Merged with ``args`` to         |
+|                |                         | produce ``message``, or an arbitrary object   |
+|                |                         | (see :ref:`arbitrary-object-messages`).       |
++----------------+-------------------------+-----------------------------------------------+
+| name           | ``%(name)s``            | Name of the logger used to log the call.      |
++----------------+-------------------------+-----------------------------------------------+
+| pathname       | ``%(pathname)s``        | Full pathname of the source file where the    |
+|                |                         | logging call was issued (if available).       |
++----------------+-------------------------+-----------------------------------------------+
+| process        | ``%(process)d``         | Process ID (if available).                    |
++----------------+-------------------------+-----------------------------------------------+
+| processName    | ``%(processName)s``     | Process name (if available).                  |
++----------------+-------------------------+-----------------------------------------------+
+| relativeCreated| ``%(relativeCreated)d`` | Time in milliseconds when the LogRecord was   |
+|                |                         | created, relative to the time the logging     |
+|                |                         | module was loaded.                            |
++----------------+-------------------------+-----------------------------------------------+
+| stack_info     | You shouldn't need to   | Stack frame information (where available)     |
+|                | format this yourself.   | from the bottom of the stack in the current   |
+|                |                         | thread, up to and including the stack frame   |
+|                |                         | of the logging call which resulted in the     |
+|                |                         | creation of this record.                      |
++----------------+-------------------------+-----------------------------------------------+
+| thread         | ``%(thread)d``          | Thread ID (if available).                     |
++----------------+-------------------------+-----------------------------------------------+
+| threadName     | ``%(threadName)s``      | Thread name (if available).                   |
++----------------+-------------------------+-----------------------------------------------+
 
-   .. method:: emit(record)
 
-      Outputs the record to the file, but first checks to see if the file has
-      changed.  If it has, the existing stream is flushed and closed and the
-      file opened again, before outputting the record to the file.
+.. _logger-adapter:
 
-.. _rotating-file-handler:
+LoggerAdapter Objects
+---------------------
 
-RotatingFileHandler
-^^^^^^^^^^^^^^^^^^^
+:class:`LoggerAdapter` instances are used to conveniently pass contextual
+information into logging calls. For a usage example , see the section on
+:ref:`adding contextual information to your logging output <context-info>`.
 
-The :class:`RotatingFileHandler` class, located in the :mod:`logging.handlers`
-module, supports rotation of disk log files.
 
+.. class:: LoggerAdapter(logger, extra)
 
-.. class:: RotatingFileHandler(filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=0)
+   Returns an instance of :class:`LoggerAdapter` initialized with an
+   underlying :class:`Logger` instance and a dict-like object.
 
-   Returns a new instance of the :class:`RotatingFileHandler` class. The specified
-   file is opened and used as the stream for logging. If *mode* is not specified,
-   ``'a'`` is used.  If *encoding* is not *None*, it is used to open the file
-   with that encoding.  If *delay* is true, then file opening is deferred until the
-   first call to :meth:`emit`.  By default, the file grows indefinitely.
+   .. method:: process(msg, kwargs)
 
-   You can use the *maxBytes* and *backupCount* values to allow the file to
-   :dfn:`rollover` at a predetermined size. When the size is about to be exceeded,
-   the file is closed and a new file is silently opened for output. Rollover occurs
-   whenever the current log file is nearly *maxBytes* in length; if *maxBytes* is
-   zero, rollover never occurs.  If *backupCount* is non-zero, the system will save
-   old log files by appending the extensions ".1", ".2" etc., to the filename. For
-   example, with a *backupCount* of 5 and a base file name of :file:`app.log`, you
-   would get :file:`app.log`, :file:`app.log.1`, :file:`app.log.2`, up to
-   :file:`app.log.5`. The file being written to is always :file:`app.log`.  When
-   this file is filled, it is closed and renamed to :file:`app.log.1`, and if files
-   :file:`app.log.1`, :file:`app.log.2`, etc.  exist, then they are renamed to
-   :file:`app.log.2`, :file:`app.log.3` etc.  respectively.
+      Modifies the message and/or keyword arguments passed to a logging call in
+      order to insert contextual information. This implementation takes the object
+      passed as *extra* to the constructor and adds it to *kwargs* using key
+      'extra'. The return value is a (*msg*, *kwargs*) tuple which has the
+      (possibly modified) versions of the arguments passed in.
 
+In addition to the above, :class:`LoggerAdapter` supports the following
+methods of :class:`Logger`, i.e. :meth:`debug`, :meth:`info`, :meth:`warning`,
+:meth:`error`, :meth:`exception`, :meth:`critical`, :meth:`log`,
+:meth:`isEnabledFor`, :meth:`getEffectiveLevel`, :meth:`setLevel`,
+:meth:`hasHandlers`. These methods have the same signatures as their
+counterparts in :class:`Logger`, so you can use the two types of instances
+interchangeably.
 
-   .. method:: doRollover()
+.. versionchanged:: 3.2
+   The :meth:`isEnabledFor`, :meth:`getEffectiveLevel`, :meth:`setLevel` and
+   :meth:`hasHandlers` methods were added to :class:`LoggerAdapter`.  These
+   methods delegate to the underlying logger.
 
-      Does a rollover, as described above.
 
+Thread Safety
+-------------
 
-   .. method:: emit(record)
+The logging module is intended to be thread-safe without any special work
+needing to be done by its clients. It achieves this though using threading
+locks; there is one lock to serialize access to the module's shared data, and
+each handler also creates a lock to serialize access to its underlying I/O.
 
-      Outputs the record to the file, catering for rollover as described
-      previously.
+If you are implementing asynchronous signal handlers using the :mod:`signal`
+module, you may not be able to use logging from within such handlers. This is
+because lock implementations in the :mod:`threading` module are not always
+re-entrant, and so cannot be invoked from such signal handlers.
 
-.. _timed-rotating-file-handler:
 
-TimedRotatingFileHandler
-^^^^^^^^^^^^^^^^^^^^^^^^
+Module-Level Functions
+----------------------
 
-The :class:`TimedRotatingFileHandler` class, located in the
-:mod:`logging.handlers` module, supports rotation of disk log files at certain
-timed intervals.
+In addition to the classes described above, there are a number of module- level
+functions.
 
 
-.. class:: TimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False)
+.. function:: getLogger(name=None)
 
-   Returns a new instance of the :class:`TimedRotatingFileHandler` class. The
-   specified file is opened and used as the stream for logging. On rotating it also
-   sets the filename suffix. Rotating happens based on the product of *when* and
-   *interval*.
+   Return a logger with the specified name or, if name is ``None``, return a
+   logger which is the root logger of the hierarchy. If specified, the name is
+   typically a dot-separated hierarchical name like *'a'*, *'a.b'* or *'a.b.c.d'*.
+   Choice of these names is entirely up to the developer who is using logging.
 
-   You can use the *when* to specify the type of *interval*. The list of possible
-   values is below.  Note that they are not case sensitive.
+   All calls to this function with a given name return the same logger instance.
+   This means that logger instances never need to be passed between different parts
+   of an application.
 
-   +----------------+-----------------------+
-   | Value          | Type of interval      |
-   +================+=======================+
-   | ``'S'``        | Seconds               |
-   +----------------+-----------------------+
-   | ``'M'``        | Minutes               |
-   +----------------+-----------------------+
-   | ``'H'``        | Hours                 |
-   +----------------+-----------------------+
-   | ``'D'``        | Days                  |
-   +----------------+-----------------------+
-   | ``'W'``        | Week day (0=Monday)   |
-   +----------------+-----------------------+
-   | ``'midnight'`` | Roll over at midnight |
-   +----------------+-----------------------+
 
-   The system will save old log files by appending extensions to the filename.
-   The extensions are date-and-time based, using the strftime format
-   ``%Y-%m-%d_%H-%M-%S`` or a leading portion thereof, depending on the
-   rollover interval.
+.. function:: getLoggerClass()
 
-   When computing the next rollover time for the first time (when the handler
-   is created), the last modification time of an existing log file, or else
-   the current time, is used to compute when the next rotation will occur.
+   Return either the standard :class:`Logger` class, or the last class passed to
+   :func:`setLoggerClass`. This function may be called from within a new class
+   definition, to ensure that installing a customised :class:`Logger` class will
+   not undo customisations already applied by other code. For example::
 
-   If the *utc* argument is true, times in UTC will be used; otherwise
-   local time is used.
+      class MyLogger(logging.getLoggerClass()):
+          # ... override behaviour here
 
-   If *backupCount* is nonzero, at most *backupCount* files
-   will be kept, and if more would be created when rollover occurs, the oldest
-   one is deleted. The deletion logic uses the interval to determine which
-   files to delete, so changing the interval may leave old files lying around.
 
-   If *delay* is true, then file opening is deferred until the first call to
-   :meth:`emit`.
+.. function:: getLogRecordFactory()
 
+   Return a callable which is used to create a :class:`LogRecord`.
 
-   .. method:: doRollover()
+   .. versionadded:: 3.2
+      This function has been provided, along with :func:`setLogRecordFactory`,
+      to allow developers more control over how the :class:`LogRecord`
+      representing a logging event is constructed.
 
-      Does a rollover, as described above.
+   See :func:`setLogRecordFactory` for more information about the how the
+   factory is called.
 
+.. function:: debug(msg, *args, **kwargs)
 
-   .. method:: emit(record)
+   Logs a message with level :const:`DEBUG` on the root logger. The *msg* is the
+   message format string, and the *args* are the arguments which are merged into
+   *msg* using the string formatting operator. (Note that this means that you can
+   use keywords in the format string, together with a single dictionary argument.)
 
-      Outputs the record to the file, catering for rollover as described above.
+   There are three keyword arguments in *kwargs* which are inspected: *exc_info*
+   which, if it does not evaluate as false, causes exception information to be
+   added to the logging message. If an exception tuple (in the format returned by
+   :func:`sys.exc_info`) is provided, it is used; otherwise, :func:`sys.exc_info`
+   is called to get the exception information.
 
+   The second optional keyword argument is *stack_info*, which defaults to
+   False. If specified as True, stack information is added to the logging
+   message, including the actual logging call. Note that this is not the same
+   stack information as that displayed through specifying *exc_info*: The
+   former is stack frames from the bottom of the stack up to the logging call
+   in the current thread, whereas the latter is information about stack frames
+   which have been unwound, following an exception, while searching for
+   exception handlers.
 
-.. _socket-handler:
+   You can specify *stack_info* independently of *exc_info*, e.g. to just show
+   how you got to a certain point in your code, even when no exceptions were
+   raised. The stack frames are printed following a header line which says::
 
-SocketHandler
-^^^^^^^^^^^^^
+       Stack (most recent call last):
 
-The :class:`SocketHandler` class, located in the :mod:`logging.handlers` module,
-sends logging output to a network socket. The base class uses a TCP socket.
+   This mimics the `Traceback (most recent call last):` which is used when
+   displaying exception frames.
 
+   The third optional keyword argument is *extra* which can be used to pass a
+   dictionary which is used to populate the __dict__ of the LogRecord created for
+   the logging event with user-defined attributes. These custom attributes can then
+   be used as you like. For example, they could be incorporated into logged
+   messages. For example::
 
-.. class:: SocketHandler(host, port)
+      FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s'
+      logging.basicConfig(format=FORMAT)
+      d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
+      logging.warning('Protocol problem: %s', 'connection reset', extra=d)
 
-   Returns a new instance of the :class:`SocketHandler` class intended to
-   communicate with a remote machine whose address is given by *host* and *port*.
+   would print something like::
 
+      2006-02-08 22:20:02,165 192.168.0.1 fbloggs  Protocol problem: connection reset
 
-   .. method:: close()
+   The keys in the dictionary passed in *extra* should not clash with the keys used
+   by the logging system. (See the :class:`Formatter` documentation for more
+   information on which keys are used by the logging system.)
 
-      Closes the socket.
+   If you choose to use these attributes in logged messages, you need to exercise
+   some care. In the above example, for instance, the :class:`Formatter` has been
+   set up with a format string which expects 'clientip' and 'user' in the attribute
+   dictionary of the LogRecord. If these are missing, the message will not be
+   logged because a string formatting exception will occur. So in this case, you
+   always need to pass the *extra* dictionary with these keys.
 
+   While this might be annoying, this feature is intended for use in specialized
+   circumstances, such as multi-threaded servers where the same code executes in
+   many contexts, and interesting conditions which arise are dependent on this
+   context (such as remote client IP address and authenticated user name, in the
+   above example). In such circumstances, it is likely that specialized
+   :class:`Formatter`\ s would be used with particular :class:`Handler`\ s.
 
-   .. method:: emit()
+   .. versionadded:: 3.2
+      The *stack_info* parameter was added.
 
-      Pickles the record's attribute dictionary and writes it to the socket in
-      binary format. If there is an error with the socket, silently drops the
-      packet. If the connection was previously lost, re-establishes the
-      connection. To unpickle the record at the receiving end into a
-      :class:`LogRecord`, use the :func:`makeLogRecord` function.
+.. function:: info(msg, *args, **kwargs)
 
+   Logs a message with level :const:`INFO` on the root logger. The arguments are
+   interpreted as for :func:`debug`.
 
-   .. method:: handleError()
 
-      Handles an error which has occurred during :meth:`emit`. The most likely
-      cause is a lost connection. Closes the socket so that we can retry on the
-      next event.
+.. function:: warning(msg, *args, **kwargs)
 
+   Logs a message with level :const:`WARNING` on the root logger. The arguments are
+   interpreted as for :func:`debug`.
 
-   .. method:: makeSocket()
 
-      This is a factory method which allows subclasses to define the precise
-      type of socket they want. The default implementation creates a TCP socket
-      (:const:`socket.SOCK_STREAM`).
+.. function:: error(msg, *args, **kwargs)
 
+   Logs a message with level :const:`ERROR` on the root logger. The arguments are
+   interpreted as for :func:`debug`.
 
-   .. method:: makePickle(record)
 
-      Pickles the record's attribute dictionary in binary format with a length
-      prefix, and returns it ready for transmission across the socket.
+.. function:: critical(msg, *args, **kwargs)
 
-      Note that pickles aren't completely secure. If you are concerned about
-      security, you may want to override this method to implement a more secure
-      mechanism. For example, you can sign pickles using HMAC and then verify
-      them on the receiving end, or alternatively you can disable unpickling of
-      global objects on the receiving end.
+   Logs a message with level :const:`CRITICAL` on the root logger. The arguments
+   are interpreted as for :func:`debug`.
 
-   .. method:: send(packet)
 
-      Send a pickled string *packet* to the socket. This function allows for
-      partial sends which can happen when the network is busy.
+.. function:: exception(msg, *args)
 
+   Logs a message with level :const:`ERROR` on the root logger. The arguments are
+   interpreted as for :func:`debug`. Exception info is added to the logging
+   message. This function should only be called from an exception handler.
 
-.. _datagram-handler:
+.. function:: log(level, msg, *args, **kwargs)
 
-DatagramHandler
-^^^^^^^^^^^^^^^
+   Logs a message with level *level* on the root logger. The other arguments are
+   interpreted as for :func:`debug`.
 
-The :class:`DatagramHandler` class, located in the :mod:`logging.handlers`
-module, inherits from :class:`SocketHandler` to support sending logging messages
-over UDP sockets.
+   PLEASE NOTE: The above module-level functions which delegate to the root
+   logger should *not* be used in threads, in versions of Python earlier than
+   2.7.1 and 3.2, unless at least one handler has been added to the root
+   logger *before* the threads are started. These convenience functions call
+   :func:`basicConfig` to ensure that at least one handler is available; in
+   earlier versions of Python, this can (under rare circumstances) lead to
+   handlers being added multiple times to the root logger, which can in turn
+   lead to multiple messages for the same event.
 
+.. function:: disable(lvl)
 
-.. class:: DatagramHandler(host, port)
+   Provides an overriding level *lvl* for all loggers which takes precedence over
+   the logger's own level. When the need arises to temporarily throttle logging
+   output down across the whole application, this function can be useful. Its
+   effect is to disable all logging calls of severity *lvl* and below, so that
+   if you call it with a value of INFO, then all INFO and DEBUG events would be
+   discarded, whereas those of severity WARNING and above would be processed
+   according to the logger's effective level.
 
-   Returns a new instance of the :class:`DatagramHandler` class intended to
-   communicate with a remote machine whose address is given by *host* and *port*.
 
+.. function:: addLevelName(lvl, levelName)
 
-   .. method:: emit()
+   Associates level *lvl* with text *levelName* in an internal dictionary, which is
+   used to map numeric levels to a textual representation, for example when a
+   :class:`Formatter` formats a message. This function can also be used to define
+   your own levels. The only constraints are that all levels used must be
+   registered using this function, levels should be positive integers and they
+   should increase in increasing order of severity.
 
-      Pickles the record's attribute dictionary and writes it to the socket in
-      binary format. If there is an error with the socket, silently drops the
-      packet. To unpickle the record at the receiving end into a
-      :class:`LogRecord`, use the :func:`makeLogRecord` function.
+   NOTE: If you are thinking of defining your own levels, please see the section
+   on :ref:`custom-levels`.
 
+.. function:: getLevelName(lvl)
 
-   .. method:: makeSocket()
+   Returns the textual representation of logging level *lvl*. If the level is one
+   of the predefined levels :const:`CRITICAL`, :const:`ERROR`, :const:`WARNING`,
+   :const:`INFO` or :const:`DEBUG` then you get the corresponding string. If you
+   have associated levels with names using :func:`addLevelName` then the name you
+   have associated with *lvl* is returned. If a numeric value corresponding to one
+   of the defined levels is passed in, the corresponding string representation is
+   returned. Otherwise, the string 'Level %s' % lvl is returned.
 
-      The factory method of :class:`SocketHandler` is here overridden to create
-      a UDP socket (:const:`socket.SOCK_DGRAM`).
 
+.. function:: makeLogRecord(attrdict)
 
-   .. method:: send(s)
+   Creates and returns a new :class:`LogRecord` instance whose attributes are
+   defined by *attrdict*. This function is useful for taking a pickled
+   :class:`LogRecord` attribute dictionary, sent over a socket, and reconstituting
+   it as a :class:`LogRecord` instance at the receiving end.
 
-      Send a pickled string to a socket.
 
+.. function:: basicConfig(**kwargs)
 
-.. _syslog-handler:
-
-SysLogHandler
-^^^^^^^^^^^^^
-
-The :class:`SysLogHandler` class, located in the :mod:`logging.handlers` module,
-supports sending logging messages to a remote or local Unix syslog.
+   Does basic configuration for the logging system by creating a
+   :class:`StreamHandler` with a default :class:`Formatter` and adding it to the
+   root logger. The functions :func:`debug`, :func:`info`, :func:`warning`,
+   :func:`error` and :func:`critical` will call :func:`basicConfig` automatically
+   if no handlers are defined for the root logger.
 
+   This function does nothing if the root logger already has handlers
+   configured for it.
 
-.. class:: SysLogHandler(address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER, socktype=socket.SOCK_DGRAM)
+   PLEASE NOTE: This function should be called from the main thread
+   before other threads are started. In versions of Python prior to
+   2.7.1 and 3.2, if this function is called from multiple threads,
+   it is possible (in rare circumstances) that a handler will be added
+   to the root logger more than once, leading to unexpected results
+   such as messages being duplicated in the log.
 
-   Returns a new instance of the :class:`SysLogHandler` class intended to
-   communicate with a remote Unix machine whose address is given by *address* in
-   the form of a ``(host, port)`` tuple.  If *address* is not specified,
-   ``('localhost', 514)`` is used.  The address is used to open a socket.  An
-   alternative to providing a ``(host, port)`` tuple is providing an address as a
-   string, for example "/dev/log". In this case, a Unix domain socket is used to
-   send the message to the syslog. If *facility* is not specified,
-   :const:`LOG_USER` is used. The type of socket opened depends on the
-   *socktype* argument, which defaults to :const:`socket.SOCK_DGRAM` and thus
-   opens a UDP socket. To open a TCP socket (for use with the newer syslog
-   daemons such as rsyslog), specify a value of :const:`socket.SOCK_STREAM`.
+   The following keyword arguments are supported.
 
-   Note that if your server is not listening on UDP port 514,
-   :class:`SysLogHandler` may appear not to work. In that case, check what
-   address you should be using for a domain socket - it's system dependent.
-   For example, on Linux it's usually "/dev/log" but on OS/X it's
-   "/var/run/syslog". You'll need to check your platform and use the
-   appropriate address (you may need to do this check at runtime if your
-   application needs to run on several platforms). On Windows, you pretty
-   much have to use the UDP option.
+   +--------------+---------------------------------------------+
+   | Format       | Description                                 |
+   +==============+=============================================+
+   | ``filename`` | Specifies that a FileHandler be created,    |
+   |              | using the specified filename, rather than a |
+   |              | StreamHandler.                              |
+   +--------------+---------------------------------------------+
+   | ``filemode`` | Specifies the mode to open the file, if     |
+   |              | filename is specified (if filemode is       |
+   |              | unspecified, it defaults to 'a').           |
+   +--------------+---------------------------------------------+
+   | ``format``   | Use the specified format string for the     |
+   |              | handler.                                    |
+   +--------------+---------------------------------------------+
+   | ``datefmt``  | Use the specified date/time format.         |
+   +--------------+---------------------------------------------+
+   | ``style``    | If ``format`` is specified, use this style  |
+   |              | for the format string. One of '%', '{' or   |
+   |              | '$' for %-formatting, :meth:`str.format` or |
+   |              | :class:`string.Template` respectively, and  |
+   |              | defaulting to '%' if not specified.         |
+   +--------------+---------------------------------------------+
+   | ``level``    | Set the root logger level to the specified  |
+   |              | level.                                      |
+   +--------------+---------------------------------------------+
+   | ``stream``   | Use the specified stream to initialize the  |
+   |              | StreamHandler. Note that this argument is   |
+   |              | incompatible with 'filename' - if both are  |
+   |              | present, 'stream' is ignored.               |
+   +--------------+---------------------------------------------+
 
    .. versionchanged:: 3.2
-      *socktype* was added.
-
-
-   .. method:: close()
-
-      Closes the socket to the remote host.
-
-
-   .. method:: emit(record)
-
-      The record is formatted, and then sent to the syslog server. If exception
-      information is present, it is *not* sent to the server.
-
-
-   .. method:: encodePriority(facility, priority)
-
-      Encodes the facility and priority into an integer. You can pass in strings
-      or integers - if strings are passed, internal mapping dictionaries are
-      used to convert them to integers.
-
-      The symbolic ``LOG_`` values are defined in :class:`SysLogHandler` and
-      mirror the values defined in the ``sys/syslog.h`` header file.
-
-      **Priorities**
-
-      +--------------------------+---------------+
-      | Name (string)            | Symbolic value|
-      +==========================+===============+
-      | ``alert``                | LOG_ALERT     |
-      +--------------------------+---------------+
-      | ``crit`` or ``critical`` | LOG_CRIT      |
-      +--------------------------+---------------+
-      | ``debug``                | LOG_DEBUG     |
-      +--------------------------+---------------+
-      | ``emerg`` or ``panic``   | LOG_EMERG     |
-      +--------------------------+---------------+
-      | ``err`` or ``error``     | LOG_ERR       |
-      +--------------------------+---------------+
-      | ``info``                 | LOG_INFO      |
-      +--------------------------+---------------+
-      | ``notice``               | LOG_NOTICE    |
-      +--------------------------+---------------+
-      | ``warn`` or ``warning``  | LOG_WARNING   |
-      +--------------------------+---------------+
-
-      **Facilities**
-
-      +---------------+---------------+
-      | Name (string) | Symbolic value|
-      +===============+===============+
-      | ``auth``      | LOG_AUTH      |
-      +---------------+---------------+
-      | ``authpriv``  | LOG_AUTHPRIV  |
-      +---------------+---------------+
-      | ``cron``      | LOG_CRON      |
-      +---------------+---------------+
-      | ``daemon``    | LOG_DAEMON    |
-      +---------------+---------------+
-      | ``ftp``       | LOG_FTP       |
-      +---------------+---------------+
-      | ``kern``      | LOG_KERN      |
-      +---------------+---------------+
-      | ``lpr``       | LOG_LPR       |
-      +---------------+---------------+
-      | ``mail``      | LOG_MAIL      |
-      +---------------+---------------+
-      | ``news``      | LOG_NEWS      |
-      +---------------+---------------+
-      | ``syslog``    | LOG_SYSLOG    |
-      +---------------+---------------+
-      | ``user``      | LOG_USER      |
-      +---------------+---------------+
-      | ``uucp``      | LOG_UUCP      |
-      +---------------+---------------+
-      | ``local0``    | LOG_LOCAL0    |
-      +---------------+---------------+
-      | ``local1``    | LOG_LOCAL1    |
-      +---------------+---------------+
-      | ``local2``    | LOG_LOCAL2    |
-      +---------------+---------------+
-      | ``local3``    | LOG_LOCAL3    |
-      +---------------+---------------+
-      | ``local4``    | LOG_LOCAL4    |
-      +---------------+---------------+
-      | ``local5``    | LOG_LOCAL5    |
-      +---------------+---------------+
-      | ``local6``    | LOG_LOCAL6    |
-      +---------------+---------------+
-      | ``local7``    | LOG_LOCAL7    |
-      +---------------+---------------+
-
-   .. method:: mapPriority(levelname)
-
-      Maps a logging level name to a syslog priority name.
-      You may need to override this if you are using custom levels, or
-      if the default algorithm is not suitable for your needs. The
-      default algorithm maps ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR`` and
-      ``CRITICAL`` to the equivalent syslog names, and all other level
-      names to "warning".
-
-.. _nt-eventlog-handler:
-
-NTEventLogHandler
-^^^^^^^^^^^^^^^^^
-
-The :class:`NTEventLogHandler` class, located in the :mod:`logging.handlers`
-module, supports sending logging messages to a local Windows NT, Windows 2000 or
-Windows XP event log. Before you can use it, you need Mark Hammond's Win32
-extensions for Python installed.
-
-
-.. class:: NTEventLogHandler(appname, dllname=None, logtype='Application')
-
-   Returns a new instance of the :class:`NTEventLogHandler` class. The *appname* is
-   used to define the application name as it appears in the event log. An
-   appropriate registry entry is created using this name. The *dllname* should give
-   the fully qualified pathname of a .dll or .exe which contains message
-   definitions to hold in the log (if not specified, ``'win32service.pyd'`` is used
-   - this is installed with the Win32 extensions and contains some basic
-   placeholder message definitions. Note that use of these placeholders will make
-   your event logs big, as the entire message source is held in the log. If you
-   want slimmer logs, you have to pass in the name of your own .dll or .exe which
-   contains the message definitions you want to use in the event log). The
-   *logtype* is one of ``'Application'``, ``'System'`` or ``'Security'``, and
-   defaults to ``'Application'``.
-
-
-   .. method:: close()
-
-      At this point, you can remove the application name from the registry as a
-      source of event log entries. However, if you do this, you will not be able
-      to see the events as you intended in the Event Log Viewer - it needs to be
-      able to access the registry to get the .dll name. The current version does
-      not do this.
-
-
-   .. method:: emit(record)
-
-      Determines the message ID, event category and event type, and then logs
-      the message in the NT event log.
-
-
-   .. method:: getEventCategory(record)
-
-      Returns the event category for the record. Override this if you want to
-      specify your own categories. This version returns 0.
-
-
-   .. method:: getEventType(record)
-
-      Returns the event type for the record. Override this if you want to
-      specify your own types. This version does a mapping using the handler's
-      typemap attribute, which is set up in :meth:`__init__` to a dictionary
-      which contains mappings for :const:`DEBUG`, :const:`INFO`,
-      :const:`WARNING`, :const:`ERROR` and :const:`CRITICAL`. If you are using
-      your own levels, you will either need to override this method or place a
-      suitable dictionary in the handler's *typemap* attribute.
-
-
-   .. method:: getMessageID(record)
-
-      Returns the message ID for the record. If you are using your own messages,
-      you could do this by having the *msg* passed to the logger being an ID
-      rather than a format string. Then, in here, you could use a dictionary
-      lookup to get the message ID. This version returns 1, which is the base
-      message ID in :file:`win32service.pyd`.
-
-.. _smtp-handler:
-
-SMTPHandler
-^^^^^^^^^^^
-
-The :class:`SMTPHandler` class, located in the :mod:`logging.handlers` module,
-supports sending logging messages to an email address via SMTP.
-
-
-.. class:: SMTPHandler(mailhost, fromaddr, toaddrs, subject, credentials=None)
-
-   Returns a new instance of the :class:`SMTPHandler` class. The instance is
-   initialized with the from and to addresses and subject line of the email. The
-   *toaddrs* should be a list of strings. To specify a non-standard SMTP port, use
-   the (host, port) tuple format for the *mailhost* argument. If you use a string,
-   the standard SMTP port is used. If your SMTP server requires authentication, you
-   can specify a (username, password) tuple for the *credentials* argument.
-
-
-   .. method:: emit(record)
-
-      Formats the record and sends it to the specified addressees.
-
-
-   .. method:: getSubject(record)
-
-      If you want to specify a subject line which is record-dependent, override
-      this method.
-
-.. _memory-handler:
-
-MemoryHandler
-^^^^^^^^^^^^^
-
-The :class:`MemoryHandler` class, located in the :mod:`logging.handlers` module,
-supports buffering of logging records in memory, periodically flushing them to a
-:dfn:`target` handler. Flushing occurs whenever the buffer is full, or when an
-event of a certain severity or greater is seen.
-
-:class:`MemoryHandler` is a subclass of the more general
-:class:`BufferingHandler`, which is an abstract class. This buffers logging
-records in memory. Whenever each record is added to the buffer, a check is made
-by calling :meth:`shouldFlush` to see if the buffer should be flushed.  If it
-should, then :meth:`flush` is expected to do the needful.
-
-
-.. class:: BufferingHandler(capacity)
-
-   Initializes the handler with a buffer of the specified capacity.
-
-
-   .. method:: emit(record)
-
-      Appends the record to the buffer. If :meth:`shouldFlush` returns true,
-      calls :meth:`flush` to process the buffer.
-
-
-   .. method:: flush()
-
-      You can override this to implement custom flushing behavior. This version
-      just zaps the buffer to empty.
-
-
-   .. method:: shouldFlush(record)
-
-      Returns true if the buffer is up to capacity. This method can be
-      overridden to implement custom flushing strategies.
-
-
-.. class:: MemoryHandler(capacity, flushLevel=ERROR, target=None)
-
-   Returns a new instance of the :class:`MemoryHandler` class. The instance is
-   initialized with a buffer size of *capacity*. If *flushLevel* is not specified,
-   :const:`ERROR` is used. If no *target* is specified, the target will need to be
-   set using :meth:`setTarget` before this handler does anything useful.
-
-
-   .. method:: close()
-
-      Calls :meth:`flush`, sets the target to :const:`None` and clears the
-      buffer.
-
-
-   .. method:: flush()
-
-      For a :class:`MemoryHandler`, flushing means just sending the buffered
-      records to the target, if there is one. The buffer is also cleared when
-      this happens. Override if you want different behavior.
-
-
-   .. method:: setTarget(target)
-
-      Sets the target handler for this handler.
-
-
-   .. method:: shouldFlush(record)
-
-      Checks for buffer full or a record at the *flushLevel* or higher.
-
-
-.. _http-handler:
-
-HTTPHandler
-^^^^^^^^^^^
-
-The :class:`HTTPHandler` class, located in the :mod:`logging.handlers` module,
-supports sending logging messages to a Web server, using either ``GET`` or
-``POST`` semantics.
-
-
-.. class:: HTTPHandler(host, url, method='GET', secure=False, credentials=None)
-
-   Returns a new instance of the :class:`HTTPHandler` class. The *host* can be
-   of the form ``host:port``, should you need to use a specific port number.
-   If no *method* is specified, ``GET`` is used. If *secure* is True, an HTTPS
-   connection will be used. If *credentials* is specified, it should be a
-   2-tuple consisting of userid and password, which will be placed in an HTTP
-   'Authorization' header using Basic authentication. If you specify
-   credentials, you should also specify secure=True so that your userid and
-   password are not passed in cleartext across the wire.
-
-
-   .. method:: emit(record)
-
-      Sends the record to the Web server as a percent-encoded dictionary.
-
-
-.. _queue-handler:
-
-
-QueueHandler
-^^^^^^^^^^^^
-
-The :class:`QueueHandler` class, located in the :mod:`logging.handlers` module,
-supports sending logging messages to a queue, such as those implemented in the
-:mod:`queue` or :mod:`multiprocessing` modules.
-
-Along with the :class:`QueueListener` class, :class:`QueueHandler` can be used
-to let handlers do their work on a separate thread from the one which does the
-logging. This is important in Web applications and also other service
-applications where threads servicing clients need to respond as quickly as
-possible, while any potentially slow operations (such as sending an email via
-:class:`SMTPHandler`) are done on a separate thread.
-
-.. class:: QueueHandler(queue)
-
-   Returns a new instance of the :class:`QueueHandler` class. The instance is
-   initialized with the queue to send messages to. The queue can be any queue-
-   like object; it's used as-is by the :meth:`enqueue` method, which needs
-   to know how to send messages to it.
-
-
-   .. method:: emit(record)
-
-      Enqueues the result of preparing the LogRecord.
-
-   .. method:: prepare(record)
-
-      Prepares a record for queuing. The object returned by this
-      method is enqueued.
-
-      The base implementation formats the record to merge the message
-      and arguments, and removes unpickleable items from the record
-      in-place.
-
-      You might want to override this method if you want to convert
-      the record to a dict or JSON string, or send a modified copy
-      of the record while leaving the original intact.
-
-   .. method:: enqueue(record)
-
-      Enqueues the record on the queue using ``put_nowait()``; you may
-      want to override this if you want to use blocking behaviour, or a
-      timeout, or a customised queue implementation.
-
-
-.. versionadded:: 3.2
-
-The :class:`QueueHandler` class was not present in previous versions.
-
-.. queue-listener:
-
-QueueListener
-^^^^^^^^^^^^^
-
-The :class:`QueueListener` class, located in the :mod:`logging.handlers`
-module, supports receiving logging messages from a queue, such as those
-implemented in the :mod:`queue` or :mod:`multiprocessing` modules. The
-messages are received from a queue in an internal thread and passed, on
-the same thread, to one or more handlers for processing.
-
-Along with the :class:`QueueHandler` class, :class:`QueueListener` can be used
-to let handlers do their work on a separate thread from the one which does the
-logging. This is important in Web applications and also other service
-applications where threads servicing clients need to respond as quickly as
-possible, while any potentially slow operations (such as sending an email via
-:class:`SMTPHandler`) are done on a separate thread.
-
-.. class:: QueueListener(queue, *handlers)
-
-   Returns a new instance of the :class:`QueueListener` class. The instance is
-   initialized with the queue to send messages to and a list of handlers which
-   will handle entries placed on the queue. The queue can be any queue-
-   like object; it's passed as-is to the :meth:`dequeue` method, which needs
-   to know how to get messages from it.
-
-   .. method:: dequeue(block)
-
-      Dequeues a record and return it, optionally blocking.
-
-      The base implementation uses ``get()``. You may want to override this
-      method if you want to use timeouts or work with custom queue
-      implementations.
-
-   .. method:: prepare(record)
-
-      Prepare a record for handling.
-
-      This implementation just returns the passed-in record. You may want to
-      override this method if you need to do any custom marshalling or
-      manipulation of the record before passing it to the handlers.
-
-   .. method:: handle(record)
-
-      Handle a record.
-
-      This just loops through the handlers offering them the record
-      to handle. The actual object passed to the handlers is that which
-      is returned from :meth:`prepare`.
-
-   .. method:: start()
-
-      Starts the listener.
-
-      This starts up a background thread to monitor the queue for
-      LogRecords to process.
-
-   .. method:: stop()
-
-      Stops the listener.
-
-      This asks the thread to terminate, and then waits for it to do so.
-      Note that if you don't call this before your application exits, there
-      may be some records still left on the queue, which won't be processed.
-
-.. versionadded:: 3.2
-
-The :class:`QueueListener` class was not present in previous versions.
-
-.. _zeromq-handlers:
-
-Subclassing QueueHandler
-^^^^^^^^^^^^^^^^^^^^^^^^
-
-You can use a :class:`QueueHandler` subclass to send messages to other kinds
-of queues, for example a ZeroMQ "publish" socket. In the example below,the
-socket is created separately and passed to the handler (as its 'queue')::
-
-    import zmq # using pyzmq, the Python binding for ZeroMQ
-    import json # for serializing records portably
-
-    ctx = zmq.Context()
-    sock = zmq.Socket(ctx, zmq.PUB) # or zmq.PUSH, or other suitable value
-    sock.bind('tcp://*:5556') # or wherever
-
-    class ZeroMQSocketHandler(QueueHandler):
-        def enqueue(self, record):
-            data = json.dumps(record.__dict__)
-            self.queue.send(data)
-
-    handler = ZeroMQSocketHandler(sock)
-
-
-Of course there are other ways of organizing this, for example passing in the
-data needed by the handler to create the socket::
-
-    class ZeroMQSocketHandler(QueueHandler):
-        def __init__(self, uri, socktype=zmq.PUB, ctx=None):
-            self.ctx = ctx or zmq.Context()
-            socket = zmq.Socket(self.ctx, socktype)
-            socket.bind(uri)
-            QueueHandler.__init__(self, socket)
-
-        def enqueue(self, record):
-            data = json.dumps(record.__dict__)
-            self.queue.send(data)
-
-        def close(self):
-            self.queue.close()
-
-Subclassing QueueListener
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-You can also subclass :class:`QueueListener` to get messages from other kinds
-of queues, for example a ZeroMQ "subscribe" socket. Here's an example::
-
-    class ZeroMQSocketListener(QueueListener):
-        def __init__(self, uri, *handlers, **kwargs):
-            self.ctx = kwargs.get('ctx') or zmq.Context()
-            socket = zmq.Socket(self.ctx, zmq.SUB)
-            socket.setsockopt(zmq.SUBSCRIBE, '') # subscribe to everything
-            socket.connect(uri)
-
-        def dequeue(self):
-            msg = self.queue.recv()
-            return logging.makeLogRecord(json.loads(msg))
-
-.. _formatter-objects:
-
-Formatter Objects
------------------
-
-.. currentmodule:: logging
-
-:class:`Formatter`\ s have the following attributes and methods. They are
-responsible for converting a :class:`LogRecord` to (usually) a string which can
-be interpreted by either a human or an external system. The base
-:class:`Formatter` allows a formatting string to be specified. If none is
-supplied, the default value of ``'%(message)s'`` is used.
-
-A Formatter can be initialized with a format string which makes use of knowledge
-of the :class:`LogRecord` attributes - such as the default value mentioned above
-making use of the fact that the user's message and arguments are pre-formatted
-into a :class:`LogRecord`'s *message* attribute.  This format string contains
-standard Python %-style mapping keys. See section :ref:`old-string-formatting`
-for more information on string formatting.
-
-Currently, the useful mapping keys in a :class:`LogRecord` are:
-
-+-------------------------+-----------------------------------------------+
-| Format                  | Description                                   |
-+=========================+===============================================+
-| ``%(name)s``            | Name of the logger (logging channel).         |
-+-------------------------+-----------------------------------------------+
-| ``%(levelno)s``         | Numeric logging level for the message         |
-|                         | (:const:`DEBUG`, :const:`INFO`,               |
-|                         | :const:`WARNING`, :const:`ERROR`,             |
-|                         | :const:`CRITICAL`).                           |
-+-------------------------+-----------------------------------------------+
-| ``%(levelname)s``       | Text logging level for the message            |
-|                         | (``'DEBUG'``, ``'INFO'``, ``'WARNING'``,      |
-|                         | ``'ERROR'``, ``'CRITICAL'``).                 |
-+-------------------------+-----------------------------------------------+
-| ``%(pathname)s``        | Full pathname of the source file where the    |
-|                         | logging call was issued (if available).       |
-+-------------------------+-----------------------------------------------+
-| ``%(filename)s``        | Filename portion of pathname.                 |
-+-------------------------+-----------------------------------------------+
-| ``%(module)s``          | Module (name portion of filename).            |
-+-------------------------+-----------------------------------------------+
-| ``%(funcName)s``        | Name of function containing the logging call. |
-+-------------------------+-----------------------------------------------+
-| ``%(lineno)d``          | Source line number where the logging call was |
-|                         | issued (if available).                        |
-+-------------------------+-----------------------------------------------+
-| ``%(created)f``         | Time when the :class:`LogRecord` was created  |
-|                         | (as returned by :func:`time.time`).           |
-+-------------------------+-----------------------------------------------+
-| ``%(relativeCreated)d`` | Time in milliseconds when the LogRecord was   |
-|                         | created, relative to the time the logging     |
-|                         | module was loaded.                            |
-+-------------------------+-----------------------------------------------+
-| ``%(asctime)s``         | Human-readable time when the                  |
-|                         | :class:`LogRecord` was created.  By default   |
-|                         | this is of the form "2003-07-08 16:49:45,896" |
-|                         | (the numbers after the comma are millisecond  |
-|                         | portion of the time).                         |
-+-------------------------+-----------------------------------------------+
-| ``%(msecs)d``           | Millisecond portion of the time when the      |
-|                         | :class:`LogRecord` was created.               |
-+-------------------------+-----------------------------------------------+
-| ``%(thread)d``          | Thread ID (if available).                     |
-+-------------------------+-----------------------------------------------+
-| ``%(threadName)s``      | Thread name (if available).                   |
-+-------------------------+-----------------------------------------------+
-| ``%(process)d``         | Process ID (if available).                    |
-+-------------------------+-----------------------------------------------+
-| ``%(processName)s``     | Process name (if available).                  |
-+-------------------------+-----------------------------------------------+
-| ``%(message)s``         | The logged message, computed as ``msg %       |
-|                         | args``.                                       |
-+-------------------------+-----------------------------------------------+
-
-
-.. class:: Formatter(fmt=None, datefmt=None)
-
-   Returns a new instance of the :class:`Formatter` class.  The instance is
-   initialized with a format string for the message as a whole, as well as a
-   format string for the date/time portion of a message.  If no *fmt* is
-   specified, ``'%(message)s'`` is used.  If no *datefmt* is specified, the
-   ISO8601 date format is used.
-
-   .. method:: format(record)
-
-      The record's attribute dictionary is used as the operand to a string
-      formatting operation. Returns the resulting string. Before formatting the
-      dictionary, a couple of preparatory steps are carried out. The *message*
-      attribute of the record is computed using *msg* % *args*. If the
-      formatting string contains ``'(asctime)'``, :meth:`formatTime` is called
-      to format the event time. If there is exception information, it is
-      formatted using :meth:`formatException` and appended to the message. Note
-      that the formatted exception information is cached in attribute
-      *exc_text*. This is useful because the exception information can be
-      pickled and sent across the wire, but you should be careful if you have
-      more than one :class:`Formatter` subclass which customizes the formatting
-      of exception information. In this case, you will have to clear the cached
-      value after a formatter has done its formatting, so that the next
-      formatter to handle the event doesn't use the cached value but
-      recalculates it afresh.
-
-      If stack information is available, it's appended after the exception
-      information, using :meth:`formatStack` to transform it if necessary.
-
-
-   .. method:: formatTime(record, datefmt=None)
-
-      This method should be called from :meth:`format` by a formatter which
-      wants to make use of a formatted time. This method can be overridden in
-      formatters to provide for any specific requirement, but the basic behavior
-      is as follows: if *datefmt* (a string) is specified, it is used with
-      :func:`time.strftime` to format the creation time of the
-      record. Otherwise, the ISO8601 format is used.  The resulting string is
-      returned.
-
-
-   .. method:: formatException(exc_info)
-
-      Formats the specified exception information (a standard exception tuple as
-      returned by :func:`sys.exc_info`) as a string. This default implementation
-      just uses :func:`traceback.print_exception`. The resulting string is
-      returned.
-
-   .. method:: formatStack(stack_info)
-
-      Formats the specified stack information (a string as returned by
-      :func:`traceback.print_stack`, but with the last newline removed) as a
-      string. This default implementation just returns the input value.
-
-.. _filter:
-
-Filter Objects
---------------
-
-``Filters`` can be used by ``Handlers`` and ``Loggers`` for more sophisticated
-filtering than is provided by levels. The base filter class only allows events
-which are below a certain point in the logger hierarchy. For example, a filter
-initialized with "A.B" will allow events logged by loggers "A.B", "A.B.C",
-"A.B.C.D", "A.B.D" etc. but not "A.BB", "B.A.B" etc. If initialized with the
-empty string, all events are passed.
-
-
-.. class:: Filter(name='')
-
-   Returns an instance of the :class:`Filter` class. If *name* is specified, it
-   names a logger which, together with its children, will have its events allowed
-   through the filter. If *name* is the empty string, allows every event.
-
-
-   .. method:: filter(record)
-
-      Is the specified record to be logged? Returns zero for no, nonzero for
-      yes. If deemed appropriate, the record may be modified in-place by this
-      method.
-
-Note that filters attached to handlers are consulted whenever an event is
-emitted by the handler, whereas filters attached to loggers are consulted
-whenever an event is logged to the handler (using :meth:`debug`, :meth:`info`,
-etc.) This means that events which have been generated by descendant loggers
-will not be filtered by a logger's filter setting, unless the filter has also
-been applied to those descendant loggers.
-
-You don't actually need to subclass ``Filter``: you can pass any instance
-which has a ``filter`` method with the same semantics.
-
-.. versionchanged:: 3.2
-   You don't need to create specialized ``Filter`` classes, or use other
-   classes with a ``filter`` method: you can use a function (or other
-   callable) as a filter. The filtering logic will check to see if the filter
-   object has a ``filter`` attribute: if it does, it's assumed to be a
-   ``Filter`` and its :meth:`~Filter.filter` method is called. Otherwise, it's
-   assumed to be a callable and called with the record as the single
-   parameter. The returned value should conform to that returned by
-   :meth:`~Filter.filter`.
-
-Other uses for filters
-^^^^^^^^^^^^^^^^^^^^^^
-
-Although filters are used primarily to filter records based on more
-sophisticated criteria than levels, they get to see every record which is
-processed by the handler or logger they're attached to: this can be useful if
-you want to do things like counting how many records were processed by a
-particular logger or handler, or adding, changing or removing attributes in
-the LogRecord being processed. Obviously changing the LogRecord needs to be
-done with some care, but it does allow the injection of contextual information
-into logs (see :ref:`filters-contextual`).
-
-.. _log-record:
-
-LogRecord Objects
------------------
-
-:class:`LogRecord` instances are created automatically by the :class:`Logger`
-every time something is logged, and can be created manually via
-:func:`makeLogRecord` (for example, from a pickled event received over the
-wire).
-
-
-.. class:: LogRecord(name, lvl, pathname, lineno, msg, args, exc_info, func=None, sinfo=None)
-
-   Contains all the information pertinent to the event being logged.
-
-   The primary information is passed in :attr:`msg` and :attr:`args`, which
-   are combined using ``msg % args`` to create the :attr:`message` field of the
-   record.
-
-   .. attribute:: args
-
-      Tuple of arguments to be used in formatting :attr:`msg`.
-
-   .. attribute:: exc_info
-
-      Exception tuple (à la :func:`sys.exc_info`) or ``None`` if no exception
-      information is available.
-
-   .. attribute:: func
-
-      Name of the function of origin (i.e. in which the logging call was made).
-
-   .. attribute:: lineno
-
-      Line number in the source file of origin.
-
-   .. attribute:: lvl
-
-      Numeric logging level.
-
-   .. attribute:: message
-
-      Bound to the result of :meth:`getMessage` when
-      :meth:`Formatter.format(record)<Formatter.format>` is invoked.
-
-   .. attribute:: msg
-
-      User-supplied :ref:`format string<string-formatting>` or arbitrary object
-      (see :ref:`arbitrary-object-messages`) used in :meth:`getMessage`.
-
-   .. attribute:: name
-
-      Name of the logger that emitted the record.
-
-   .. attribute:: pathname
-
-      Absolute pathname of the source file of origin.
-
-   .. attribute:: stack_info
-
-      Stack frame information (where available) from the bottom of the stack
-      in the current thread, up to and including the stack frame of the
-      logging call which resulted in the creation of this record.
-
-   .. method:: getMessage()
-
-      Returns the message for this :class:`LogRecord` instance after merging any
-      user-supplied arguments with the message. If the user-supplied message
-      argument to the logging call is not a string, :func:`str` is called on it to
-      convert it to a string. This allows use of user-defined classes as
-      messages, whose ``__str__`` method can return the actual format string to
-      be used.
-
-.. _logger-adapter:
-
-LoggerAdapter Objects
----------------------
+      The ``style`` argument was added.
 
-:class:`LoggerAdapter` instances are used to conveniently pass contextual
-information into logging calls. For a usage example , see the section on
-`adding contextual information to your logging output`__.
 
-__ context-info_
+.. function:: shutdown()
 
-.. class:: LoggerAdapter(logger, extra)
+   Informs the logging system to perform an orderly shutdown by flushing and
+   closing all handlers. This should be called at application exit and no
+   further use of the logging system should be made after this call.
 
-  Returns an instance of :class:`LoggerAdapter` initialized with an
-  underlying :class:`Logger` instance and a dict-like object.
 
-  .. method:: process(msg, kwargs)
+.. function:: setLoggerClass(klass)
 
-    Modifies the message and/or keyword arguments passed to a logging call in
-    order to insert contextual information. This implementation takes the object
-    passed as *extra* to the constructor and adds it to *kwargs* using key
-    'extra'. The return value is a (*msg*, *kwargs*) tuple which has the
-    (possibly modified) versions of the arguments passed in.
+   Tells the logging system to use the class *klass* when instantiating a logger.
+   The class should define :meth:`__init__` such that only a name argument is
+   required, and the :meth:`__init__` should call :meth:`Logger.__init__`. This
+   function is typically called before any loggers are instantiated by applications
+   which need to use custom logger behavior.
 
-In addition to the above, :class:`LoggerAdapter` supports the following
-methods of :class:`Logger`, i.e. :meth:`debug`, :meth:`info`, :meth:`warning`,
-:meth:`error`, :meth:`exception`, :meth:`critical`, :meth:`log`,
-:meth:`isEnabledFor`, :meth:`getEffectiveLevel`, :meth:`setLevel`,
-:meth:`hasHandlers`. These methods have the same signatures as their
-counterparts in :class:`Logger`, so you can use the two types of instances
-interchangeably.
 
-.. versionchanged:: 3.2
-   The :meth:`isEnabledFor`, :meth:`getEffectiveLevel`, :meth:`setLevel` and
-   :meth:`hasHandlers` methods were added to :class:`LoggerAdapter`.  These
-   methods delegate to the underlying logger.
+.. function:: setLogRecordFactory(factory)
 
+   Set a callable which is used to create a :class:`LogRecord`.
 
-Thread Safety
--------------
+   :param factory: The factory callable to be used to instantiate a log record.
 
-The logging module is intended to be thread-safe without any special work
-needing to be done by its clients. It achieves this though using threading
-locks; there is one lock to serialize access to the module's shared data, and
-each handler also creates a lock to serialize access to its underlying I/O.
-
-If you are implementing asynchronous signal handlers using the :mod:`signal`
-module, you may not be able to use logging from within such handlers. This is
-because lock implementations in the :mod:`threading` module are not always
-re-entrant, and so cannot be invoked from such signal handlers.
+   .. versionadded:: 3.2
+      This function has been provided, along with :func:`getLogRecordFactory`, to
+      allow developers more control over how the :class:`LogRecord` representing
+      a logging event is constructed.
+
+   The factory has the following signature:
+
+   ``factory(name, level, fn, lno, msg, args, exc_info, func=None, sinfo=None, **kwargs)``
+
+      :name: The logger name.
+      :level: The logging level (numeric).
+      :fn: The full pathname of the file where the logging call was made.
+      :lno: The line number in the file where the logging call was made.
+      :msg: The logging message.
+      :args: The arguments for the logging message.
+      :exc_info: An exception tuple, or None.
+      :func: The name of the function or method which invoked the logging
+             call.
+      :sinfo: A stack traceback such as is provided by
+              :func:`traceback.print_stack`, showing the call hierarchy.
+      :kwargs: Additional keyword arguments.
 
 
 Integration with the warnings module
@@ -3310,842 +1042,28 @@
    If *capture* is ``True``, warnings issued by the :mod:`warnings` module will
    be redirected to the logging system. Specifically, a warning will be
    formatted using :func:`warnings.formatwarning` and the resulting string
-   logged to a logger named "py.warnings" with a severity of `WARNING`.
+   logged to a logger named 'py.warnings' with a severity of `WARNING`.
 
    If *capture* is ``False``, the redirection of warnings to the logging system
    will stop, and warnings will be redirected to their original destinations
    (i.e. those in effect before `captureWarnings(True)` was called).
 
 
-Configuration
--------------
-
-
-.. _logging-config-api:
-
-Configuration functions
-^^^^^^^^^^^^^^^^^^^^^^^
+.. seealso::
 
-The following functions configure the logging module. They are located in the
-:mod:`logging.config` module.  Their use is optional --- you can configure the
-logging module using these functions or by making calls to the main API (defined
-in :mod:`logging` itself) and defining handlers which are declared either in
-:mod:`logging` or :mod:`logging.handlers`.
-
-.. function:: dictConfig(config)
-
-    Takes the logging configuration from a dictionary.  The contents of
-    this dictionary are described in :ref:`logging-config-dictschema`
-    below.
-
-    If an error is encountered during configuration, this function will
-    raise a :exc:`ValueError`, :exc:`TypeError`, :exc:`AttributeError`
-    or :exc:`ImportError` with a suitably descriptive message.  The
-    following is a (possibly incomplete) list of conditions which will
-    raise an error:
-
-    * A ``level`` which is not a string or which is a string not
-      corresponding to an actual logging level.
-    * A ``propagate`` value which is not a boolean.
-    * An id which does not have a corresponding destination.
-    * A non-existent handler id found during an incremental call.
-    * An invalid logger name.
-    * Inability to resolve to an internal or external object.
-
-    Parsing is performed by the :class:`DictConfigurator` class, whose
-    constructor is passed the dictionary used for configuration, and
-    has a :meth:`configure` method.  The :mod:`logging.config` module
-    has a callable attribute :attr:`dictConfigClass`
-    which is initially set to :class:`DictConfigurator`.
-    You can replace the value of :attr:`dictConfigClass` with a
-    suitable implementation of your own.
-
-    :func:`dictConfig` calls :attr:`dictConfigClass` passing
-    the specified dictionary, and then calls the :meth:`configure` method on
-    the returned object to put the configuration into effect::
-
-          def dictConfig(config):
-              dictConfigClass(config).configure()
-
-    For example, a subclass of :class:`DictConfigurator` could call
-    ``DictConfigurator.__init__()`` in its own :meth:`__init__()`, then
-    set up custom prefixes which would be usable in the subsequent
-    :meth:`configure` call. :attr:`dictConfigClass` would be bound to
-    this new subclass, and then :func:`dictConfig` could be called exactly as
-    in the default, uncustomized state.
-
-.. function:: fileConfig(fname[, defaults])
-
-   Reads the logging configuration from a :mod:`configparser`\-format file named
-   *fname*. This function can be called several times from an application,
-   allowing an end user to select from various pre-canned
-   configurations (if the developer provides a mechanism to present the choices
-   and load the chosen configuration). Defaults to be passed to the ConfigParser
-   can be specified in the *defaults* argument.
-
-
-.. function:: listen(port=DEFAULT_LOGGING_CONFIG_PORT)
-
-   Starts up a socket server on the specified port, and listens for new
-   configurations. If no port is specified, the module's default
-   :const:`DEFAULT_LOGGING_CONFIG_PORT` is used. Logging configurations will be
-   sent as a file suitable for processing by :func:`fileConfig`. Returns a
-   :class:`Thread` instance on which you can call :meth:`start` to start the
-   server, and which you can :meth:`join` when appropriate. To stop the server,
-   call :func:`stopListening`.
-
-   To send a configuration to the socket, read in the configuration file and
-   send it to the socket as a string of bytes preceded by a four-byte length
-   string packed in binary using ``struct.pack('>L', n)``.
-
-
-.. function:: stopListening()
-
-   Stops the listening server which was created with a call to :func:`listen`.
-   This is typically called before calling :meth:`join` on the return value from
-   :func:`listen`.
-
-
-.. _logging-config-dictschema:
-
-Configuration dictionary schema
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Describing a logging configuration requires listing the various
-objects to create and the connections between them; for example, you
-may create a handler named "console" and then say that the logger
-named "startup" will send its messages to the "console" handler.
-These objects aren't limited to those provided by the :mod:`logging`
-module because you might write your own formatter or handler class.
-The parameters to these classes may also need to include external
-objects such as ``sys.stderr``.  The syntax for describing these
-objects and connections is defined in :ref:`logging-config-dict-connections`
-below.
-
-Dictionary Schema Details
-"""""""""""""""""""""""""
-
-The dictionary passed to :func:`dictConfig` must contain the following
-keys:
-
-* *version* - to be set to an integer value representing the schema
-  version.  The only valid value at present is 1, but having this key
-  allows the schema to evolve while still preserving backwards
-  compatibility.
-
-All other keys are optional, but if present they will be interpreted
-as described below.  In all cases below where a 'configuring dict' is
-mentioned, it will be checked for the special ``'()'`` key to see if a
-custom instantiation is required.  If so, the mechanism described in
-:ref:`logging-config-dict-userdef` below is used to create an instance;
-otherwise, the context is used to determine what to instantiate.
-
-* *formatters* - the corresponding value will be a dict in which each
-  key is a formatter id and each value is a dict describing how to
-  configure the corresponding Formatter instance.
-
-  The configuring dict is searched for keys ``format`` and ``datefmt``
-  (with defaults of ``None``) and these are used to construct a
-  :class:`logging.Formatter` instance.
-
-* *filters* - the corresponding value will be a dict in which each key
-  is a filter id and each value is a dict describing how to configure
-  the corresponding Filter instance.
-
-  The configuring dict is searched for the key ``name`` (defaulting to the
-  empty string) and this is used to construct a :class:`logging.Filter`
-  instance.
-
-* *handlers* - the corresponding value will be a dict in which each
-  key is a handler id and each value is a dict describing how to
-  configure the corresponding Handler instance.
-
-  The configuring dict is searched for the following keys:
-
-  * ``class`` (mandatory).  This is the fully qualified name of the
-    handler class.
-
-  * ``level`` (optional).  The level of the handler.
-
-  * ``formatter`` (optional).  The id of the formatter for this
-    handler.
-
-  * ``filters`` (optional).  A list of ids of the filters for this
-    handler.
-
-  All *other* keys are passed through as keyword arguments to the
-  handler's constructor.  For example, given the snippet::
-
-      handlers:
-        console:
-          class : logging.StreamHandler
-          formatter: brief
-          level   : INFO
-          filters: [allow_foo]
-          stream  : ext://sys.stdout
-        file:
-          class : logging.handlers.RotatingFileHandler
-          formatter: precise
-          filename: logconfig.log
-          maxBytes: 1024
-          backupCount: 3
-
-  the handler with id ``console`` is instantiated as a
-  :class:`logging.StreamHandler`, using ``sys.stdout`` as the underlying
-  stream.  The handler with id ``file`` is instantiated as a
-  :class:`logging.handlers.RotatingFileHandler` with the keyword arguments
-  ``filename='logconfig.log', maxBytes=1024, backupCount=3``.
-
-* *loggers* - the corresponding value will be a dict in which each key
-  is a logger name and each value is a dict describing how to
-  configure the corresponding Logger instance.
-
-  The configuring dict is searched for the following keys:
-
-  * ``level`` (optional).  The level of the logger.
-
-  * ``propagate`` (optional).  The propagation setting of the logger.
-
-  * ``filters`` (optional).  A list of ids of the filters for this
-    logger.
-
-  * ``handlers`` (optional).  A list of ids of the handlers for this
-    logger.
-
-  The specified loggers will be configured according to the level,
-  propagation, filters and handlers specified.
-
-* *root* - this will be the configuration for the root logger.
-  Processing of the configuration will be as for any logger, except
-  that the ``propagate`` setting will not be applicable.
-
-* *incremental* - whether the configuration is to be interpreted as
-  incremental to the existing configuration.  This value defaults to
-  ``False``, which means that the specified configuration replaces the
-  existing configuration with the same semantics as used by the
-  existing :func:`fileConfig` API.
-
-  If the specified value is ``True``, the configuration is processed
-  as described in the section on :ref:`logging-config-dict-incremental`.
-
-* *disable_existing_loggers* - whether any existing loggers are to be
-  disabled. This setting mirrors the parameter of the same name in
-  :func:`fileConfig`. If absent, this parameter defaults to ``True``.
-  This value is ignored if *incremental* is ``True``.
-
-.. _logging-config-dict-incremental:
-
-Incremental Configuration
-"""""""""""""""""""""""""
-
-It is difficult to provide complete flexibility for incremental
-configuration.  For example, because objects such as filters
-and formatters are anonymous, once a configuration is set up, it is
-not possible to refer to such anonymous objects when augmenting a
-configuration.
-
-Furthermore, there is not a compelling case for arbitrarily altering
-the object graph of loggers, handlers, filters, formatters at
-run-time, once a configuration is set up; the verbosity of loggers and
-handlers can be controlled just by setting levels (and, in the case of
-loggers, propagation flags).  Changing the object graph arbitrarily in
-a safe way is problematic in a multi-threaded environment; while not
-impossible, the benefits are not worth the complexity it adds to the
-implementation.
-
-Thus, when the ``incremental`` key of a configuration dict is present
-and is ``True``, the system will completely ignore any ``formatters`` and
-``filters`` entries, and process only the ``level``
-settings in the ``handlers`` entries, and the ``level`` and
-``propagate`` settings in the ``loggers`` and ``root`` entries.
-
-Using a value in the configuration dict lets configurations to be sent
-over the wire as pickled dicts to a socket listener. Thus, the logging
-verbosity of a long-running application can be altered over time with
-no need to stop and restart the application.
-
-.. _logging-config-dict-connections:
-
-Object connections
-""""""""""""""""""
-
-The schema describes a set of logging objects - loggers,
-handlers, formatters, filters - which are connected to each other in
-an object graph.  Thus, the schema needs to represent connections
-between the objects.  For example, say that, once configured, a
-particular logger has attached to it a particular handler.  For the
-purposes of this discussion, we can say that the logger represents the
-source, and the handler the destination, of a connection between the
-two.  Of course in the configured objects this is represented by the
-logger holding a reference to the handler.  In the configuration dict,
-this is done by giving each destination object an id which identifies
-it unambiguously, and then using the id in the source object's
-configuration to indicate that a connection exists between the source
-and the destination object with that id.
-
-So, for example, consider the following YAML snippet::
-
-    formatters:
-      brief:
-        # configuration for formatter with id 'brief' goes here
-      precise:
-        # configuration for formatter with id 'precise' goes here
-    handlers:
-      h1: #This is an id
-       # configuration of handler with id 'h1' goes here
-       formatter: brief
-      h2: #This is another id
-       # configuration of handler with id 'h2' goes here
-       formatter: precise
-    loggers:
-      foo.bar.baz:
-        # other configuration for logger 'foo.bar.baz'
-        handlers: [h1, h2]
-
-(Note: YAML used here because it's a little more readable than the
-equivalent Python source form for the dictionary.)
-
-The ids for loggers are the logger names which would be used
-programmatically to obtain a reference to those loggers, e.g.
-``foo.bar.baz``.  The ids for Formatters and Filters can be any string
-value (such as ``brief``, ``precise`` above) and they are transient,
-in that they are only meaningful for processing the configuration
-dictionary and used to determine connections between objects, and are
-not persisted anywhere when the configuration call is complete.
-
-The above snippet indicates that logger named ``foo.bar.baz`` should
-have two handlers attached to it, which are described by the handler
-ids ``h1`` and ``h2``. The formatter for ``h1`` is that described by id
-``brief``, and the formatter for ``h2`` is that described by id
-``precise``.
-
-
-.. _logging-config-dict-userdef:
-
-User-defined objects
-""""""""""""""""""""
-
-The schema supports user-defined objects for handlers, filters and
-formatters.  (Loggers do not need to have different types for
-different instances, so there is no support in this configuration
-schema for user-defined logger classes.)
-
-Objects to be configured are described by dictionaries
-which detail their configuration.  In some places, the logging system
-will be able to infer from the context how an object is to be
-instantiated, but when a user-defined object is to be instantiated,
-the system will not know how to do this.  In order to provide complete
-flexibility for user-defined object instantiation, the user needs
-to provide a 'factory' - a callable which is called with a
-configuration dictionary and which returns the instantiated object.
-This is signalled by an absolute import path to the factory being
-made available under the special key ``'()'``.  Here's a concrete
-example::
-
-    formatters:
-      brief:
-        format: '%(message)s'
-      default:
-        format: '%(asctime)s %(levelname)-8s %(name)-15s %(message)s'
-        datefmt: '%Y-%m-%d %H:%M:%S'
-      custom:
-          (): my.package.customFormatterFactory
-          bar: baz
-          spam: 99.9
-          answer: 42
-
-The above YAML snippet defines three formatters.  The first, with id
-``brief``, is a standard :class:`logging.Formatter` instance with the
-specified format string.  The second, with id ``default``, has a
-longer format and also defines the time format explicitly, and will
-result in a :class:`logging.Formatter` initialized with those two format
-strings.  Shown in Python source form, the ``brief`` and ``default``
-formatters have configuration sub-dictionaries::
-
-    {
-      'format' : '%(message)s'
-    }
-
-and::
-
-    {
-      'format' : '%(asctime)s %(levelname)-8s %(name)-15s %(message)s',
-      'datefmt' : '%Y-%m-%d %H:%M:%S'
-    }
-
-respectively, and as these dictionaries do not contain the special key
-``'()'``, the instantiation is inferred from the context: as a result,
-standard :class:`logging.Formatter` instances are created.  The
-configuration sub-dictionary for the third formatter, with id
-``custom``, is::
-
-  {
-    '()' : 'my.package.customFormatterFactory',
-    'bar' : 'baz',
-    'spam' : 99.9,
-    'answer' : 42
-  }
-
-and this contains the special key ``'()'``, which means that
-user-defined instantiation is wanted.  In this case, the specified
-factory callable will be used. If it is an actual callable it will be
-used directly - otherwise, if you specify a string (as in the example)
-the actual callable will be located using normal import mechanisms.
-The callable will be called with the **remaining** items in the
-configuration sub-dictionary as keyword arguments.  In the above
-example, the formatter with id ``custom`` will be assumed to be
-returned by the call::
-
-    my.package.customFormatterFactory(bar='baz', spam=99.9, answer=42)
-
-The key ``'()'`` has been used as the special key because it is not a
-valid keyword parameter name, and so will not clash with the names of
-the keyword arguments used in the call.  The ``'()'`` also serves as a
-mnemonic that the corresponding value is a callable.
-
-
-.. _logging-config-dict-externalobj:
-
-Access to external objects
-""""""""""""""""""""""""""
-
-There are times where a configuration needs to refer to objects
-external to the configuration, for example ``sys.stderr``.  If the
-configuration dict is constructed using Python code, this is
-straightforward, but a problem arises when the configuration is
-provided via a text file (e.g. JSON, YAML).  In a text file, there is
-no standard way to distinguish ``sys.stderr`` from the literal string
-``'sys.stderr'``.  To facilitate this distinction, the configuration
-system looks for certain special prefixes in string values and
-treat them specially.  For example, if the literal string
-``'ext://sys.stderr'`` is provided as a value in the configuration,
-then the ``ext://`` will be stripped off and the remainder of the
-value processed using normal import mechanisms.
-
-The handling of such prefixes is done in a way analogous to protocol
-handling: there is a generic mechanism to look for prefixes which
-match the regular expression ``^(?P<prefix>[a-z]+)://(?P<suffix>.*)$``
-whereby, if the ``prefix`` is recognised, the ``suffix`` is processed
-in a prefix-dependent manner and the result of the processing replaces
-the string value.  If the prefix is not recognised, then the string
-value will be left as-is.
-
-
-.. _logging-config-dict-internalobj:
-
-Access to internal objects
-""""""""""""""""""""""""""
-
-As well as external objects, there is sometimes also a need to refer
-to objects in the configuration.  This will be done implicitly by the
-configuration system for things that it knows about.  For example, the
-string value ``'DEBUG'`` for a ``level`` in a logger or handler will
-automatically be converted to the value ``logging.DEBUG``, and the
-``handlers``, ``filters`` and ``formatter`` entries will take an
-object id and resolve to the appropriate destination object.
-
-However, a more generic mechanism is needed for user-defined
-objects which are not known to the :mod:`logging` module.  For
-example, consider :class:`logging.handlers.MemoryHandler`, which takes
-a ``target`` argument which is another handler to delegate to. Since
-the system already knows about this class, then in the configuration,
-the given ``target`` just needs to be the object id of the relevant
-target handler, and the system will resolve to the handler from the
-id.  If, however, a user defines a ``my.package.MyHandler`` which has
-an ``alternate`` handler, the configuration system would not know that
-the ``alternate`` referred to a handler.  To cater for this, a generic
-resolution system allows the user to specify::
-
-    handlers:
-      file:
-        # configuration of file handler goes here
-
-      custom:
-        (): my.package.MyHandler
-        alternate: cfg://handlers.file
-
-The literal string ``'cfg://handlers.file'`` will be resolved in an
-analogous way to strings with the ``ext://`` prefix, but looking
-in the configuration itself rather than the import namespace.  The
-mechanism allows access by dot or by index, in a similar way to
-that provided by ``str.format``.  Thus, given the following snippet::
-
-    handlers:
-      email:
-        class: logging.handlers.SMTPHandler
-        mailhost: localhost
-        fromaddr: my_app at domain.tld
-        toaddrs:
-          - support_team at domain.tld
-          - dev_team at domain.tld
-        subject: Houston, we have a problem.
-
-in the configuration, the string ``'cfg://handlers'`` would resolve to
-the dict with key ``handlers``, the string ``'cfg://handlers.email``
-would resolve to the dict with key ``email`` in the ``handlers`` dict,
-and so on.  The string ``'cfg://handlers.email.toaddrs[1]`` would
-resolve to ``'dev_team.domain.tld'`` and the string
-``'cfg://handlers.email.toaddrs[0]'`` would resolve to the value
-``'support_team at domain.tld'``. The ``subject`` value could be accessed
-using either ``'cfg://handlers.email.subject'`` or, equivalently,
-``'cfg://handlers.email[subject]'``.  The latter form only needs to be
-used if the key contains spaces or non-alphanumeric characters.  If an
-index value consists only of decimal digits, access will be attempted
-using the corresponding integer value, falling back to the string
-value if needed.
-
-Given a string ``cfg://handlers.myhandler.mykey.123``, this will
-resolve to ``config_dict['handlers']['myhandler']['mykey']['123']``.
-If the string is specified as ``cfg://handlers.myhandler.mykey[123]``,
-the system will attempt to retrieve the value from
-``config_dict['handlers']['myhandler']['mykey'][123]``, and fall back
-to ``config_dict['handlers']['myhandler']['mykey']['123']`` if that
-fails.
-
-.. _logging-config-fileformat:
-
-Configuration file format
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The configuration file format understood by :func:`fileConfig` is based on
-:mod:`configparser` functionality. The file must contain sections called
-``[loggers]``, ``[handlers]`` and ``[formatters]`` which identify by name the
-entities of each type which are defined in the file. For each such entity, there
-is a separate section which identifies how that entity is configured.  Thus, for
-a logger named ``log01`` in the ``[loggers]`` section, the relevant
-configuration details are held in a section ``[logger_log01]``. Similarly, a
-handler called ``hand01`` in the ``[handlers]`` section will have its
-configuration held in a section called ``[handler_hand01]``, while a formatter
-called ``form01`` in the ``[formatters]`` section will have its configuration
-specified in a section called ``[formatter_form01]``. The root logger
-configuration must be specified in a section called ``[logger_root]``.
-
-Examples of these sections in the file are given below. ::
-
-   [loggers]
-   keys=root,log02,log03,log04,log05,log06,log07
-
-   [handlers]
-   keys=hand01,hand02,hand03,hand04,hand05,hand06,hand07,hand08,hand09
-
-   [formatters]
-   keys=form01,form02,form03,form04,form05,form06,form07,form08,form09
-
-The root logger must specify a level and a list of handlers. An example of a
-root logger section is given below. ::
-
-   [logger_root]
-   level=NOTSET
-   handlers=hand01
-
-The ``level`` entry can be one of ``DEBUG, INFO, WARNING, ERROR, CRITICAL`` or
-``NOTSET``. For the root logger only, ``NOTSET`` means that all messages will be
-logged. Level values are :func:`eval`\ uated in the context of the ``logging``
-package's namespace.
-
-The ``handlers`` entry is a comma-separated list of handler names, which must
-appear in the ``[handlers]`` section. These names must appear in the
-``[handlers]`` section and have corresponding sections in the configuration
-file.
-
-For loggers other than the root logger, some additional information is required.
-This is illustrated by the following example. ::
-
-   [logger_parser]
-   level=DEBUG
-   handlers=hand01
-   propagate=1
-   qualname=compiler.parser
-
-The ``level`` and ``handlers`` entries are interpreted as for the root logger,
-except that if a non-root logger's level is specified as ``NOTSET``, the system
-consults loggers higher up the hierarchy to determine the effective level of the
-logger. The ``propagate`` entry is set to 1 to indicate that messages must
-propagate to handlers higher up the logger hierarchy from this logger, or 0 to
-indicate that messages are **not** propagated to handlers up the hierarchy. The
-``qualname`` entry is the hierarchical channel name of the logger, that is to
-say the name used by the application to get the logger.
-
-Sections which specify handler configuration are exemplified by the following.
-::
-
-   [handler_hand01]
-   class=StreamHandler
-   level=NOTSET
-   formatter=form01
-   args=(sys.stdout,)
-
-The ``class`` entry indicates the handler's class (as determined by :func:`eval`
-in the ``logging`` package's namespace). The ``level`` is interpreted as for
-loggers, and ``NOTSET`` is taken to mean "log everything".
-
-The ``formatter`` entry indicates the key name of the formatter for this
-handler. If blank, a default formatter (``logging._defaultFormatter``) is used.
-If a name is specified, it must appear in the ``[formatters]`` section and have
-a corresponding section in the configuration file.
-
-The ``args`` entry, when :func:`eval`\ uated in the context of the ``logging``
-package's namespace, is the list of arguments to the constructor for the handler
-class. Refer to the constructors for the relevant handlers, or to the examples
-below, to see how typical entries are constructed. ::
-
-   [handler_hand02]
-   class=FileHandler
-   level=DEBUG
-   formatter=form02
-   args=('python.log', 'w')
-
-   [handler_hand03]
-   class=handlers.SocketHandler
-   level=INFO
-   formatter=form03
-   args=('localhost', handlers.DEFAULT_TCP_LOGGING_PORT)
-
-   [handler_hand04]
-   class=handlers.DatagramHandler
-   level=WARN
-   formatter=form04
-   args=('localhost', handlers.DEFAULT_UDP_LOGGING_PORT)
-
-   [handler_hand05]
-   class=handlers.SysLogHandler
-   level=ERROR
-   formatter=form05
-   args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
-
-   [handler_hand06]
-   class=handlers.NTEventLogHandler
-   level=CRITICAL
-   formatter=form06
-   args=('Python Application', '', 'Application')
-
-   [handler_hand07]
-   class=handlers.SMTPHandler
-   level=WARN
-   formatter=form07
-   args=('localhost', 'from at abc', ['user1 at abc', 'user2 at xyz'], 'Logger Subject')
-
-   [handler_hand08]
-   class=handlers.MemoryHandler
-   level=NOTSET
-   formatter=form08
-   target=
-   args=(10, ERROR)
-
-   [handler_hand09]
-   class=handlers.HTTPHandler
-   level=NOTSET
-   formatter=form09
-   args=('localhost:9022', '/log', 'GET')
-
-Sections which specify formatter configuration are typified by the following. ::
-
-   [formatter_form01]
-   format=F1 %(asctime)s %(levelname)s %(message)s
-   datefmt=
-   class=logging.Formatter
-
-The ``format`` entry is the overall format string, and the ``datefmt`` entry is
-the :func:`strftime`\ -compatible date/time format string.  If empty, the
-package substitutes ISO8601 format date/times, which is almost equivalent to
-specifying the date format string ``"%Y-%m-%d %H:%M:%S"``.  The ISO8601 format
-also specifies milliseconds, which are appended to the result of using the above
-format string, with a comma separator.  An example time in ISO8601 format is
-``2003-01-23 00:29:50,411``.
-
-The ``class`` entry is optional.  It indicates the name of the formatter's class
-(as a dotted module and class name.)  This option is useful for instantiating a
-:class:`Formatter` subclass.  Subclasses of :class:`Formatter` can present
-exception tracebacks in an expanded or condensed format.
-
-
-Configuration server example
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Here is an example of a module using the logging configuration server::
-
-    import logging
-    import logging.config
-    import time
-    import os
-
-    # read initial config file
-    logging.config.fileConfig("logging.conf")
-
-    # create and start listener on port 9999
-    t = logging.config.listen(9999)
-    t.start()
-
-    logger = logging.getLogger("simpleExample")
-
-    try:
-        # loop through logging calls to see the difference
-        # new configurations make, until Ctrl+C is pressed
-        while True:
-            logger.debug("debug message")
-            logger.info("info message")
-            logger.warn("warn message")
-            logger.error("error message")
-            logger.critical("critical message")
-            time.sleep(5)
-    except KeyboardInterrupt:
-        # cleanup
-        logging.config.stopListening()
-        t.join()
-
-And here is a script that takes a filename and sends that file to the server,
-properly preceded with the binary-encoded length, as the new logging
-configuration::
-
-    #!/usr/bin/env python
-    import socket, sys, struct
-
-    data_to_send = open(sys.argv[1], "r").read()
-
-    HOST = 'localhost'
-    PORT = 9999
-    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-    print("connecting...")
-    s.connect((HOST, PORT))
-    print("sending config...")
-    s.send(struct.pack(">L", len(data_to_send)))
-    s.send(data_to_send)
-    s.close()
-    print("complete")
+   Module :mod:`logging.config`
+      Configuration API for the logging module.
 
+   Module :mod:`logging.handlers`
+      Useful handlers included with the logging module.
 
-More examples
--------------
-
-Multiple handlers and formatters
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   :pep:`282` - A Logging System
+      The proposal which described this feature for inclusion in the Python standard
+      library.
 
-Loggers are plain Python objects.  The :func:`addHandler` method has no minimum
-or maximum quota for the number of handlers you may add.  Sometimes it will be
-beneficial for an application to log all messages of all severities to a text
-file while simultaneously logging errors or above to the console.  To set this
-up, simply configure the appropriate handlers.  The logging calls in the
-application code will remain unchanged.  Here is a slight modification to the
-previous simple module-based configuration example::
-
-    import logging
-
-    logger = logging.getLogger("simple_example")
-    logger.setLevel(logging.DEBUG)
-    # create file handler which logs even debug messages
-    fh = logging.FileHandler("spam.log")
-    fh.setLevel(logging.DEBUG)
-    # create console handler with a higher log level
-    ch = logging.StreamHandler()
-    ch.setLevel(logging.ERROR)
-    # create formatter and add it to the handlers
-    formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
-    ch.setFormatter(formatter)
-    fh.setFormatter(formatter)
-    # add the handlers to logger
-    logger.addHandler(ch)
-    logger.addHandler(fh)
-
-    # "application" code
-    logger.debug("debug message")
-    logger.info("info message")
-    logger.warn("warn message")
-    logger.error("error message")
-    logger.critical("critical message")
-
-Notice that the "application" code does not care about multiple handlers.  All
-that changed was the addition and configuration of a new handler named *fh*.
-
-The ability to create new handlers with higher- or lower-severity filters can be
-very helpful when writing and testing an application.  Instead of using many
-``print`` statements for debugging, use ``logger.debug``: Unlike the print
-statements, which you will have to delete or comment out later, the logger.debug
-statements can remain intact in the source code and remain dormant until you
-need them again.  At that time, the only change that needs to happen is to
-modify the severity level of the logger and/or handler to debug.
-
-
-Using logging in multiple modules
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-It was mentioned above that multiple calls to
-``logging.getLogger('someLogger')`` return a reference to the same logger
-object.  This is true not only within the same module, but also across modules
-as long as it is in the same Python interpreter process.  It is true for
-references to the same object; additionally, application code can define and
-configure a parent logger in one module and create (but not configure) a child
-logger in a separate module, and all logger calls to the child will pass up to
-the parent.  Here is a main module::
-
-    import logging
-    import auxiliary_module
-
-    # create logger with "spam_application"
-    logger = logging.getLogger("spam_application")
-    logger.setLevel(logging.DEBUG)
-    # create file handler which logs even debug messages
-    fh = logging.FileHandler("spam.log")
-    fh.setLevel(logging.DEBUG)
-    # create console handler with a higher log level
-    ch = logging.StreamHandler()
-    ch.setLevel(logging.ERROR)
-    # create formatter and add it to the handlers
-    formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
-    fh.setFormatter(formatter)
-    ch.setFormatter(formatter)
-    # add the handlers to the logger
-    logger.addHandler(fh)
-    logger.addHandler(ch)
-
-    logger.info("creating an instance of auxiliary_module.Auxiliary")
-    a = auxiliary_module.Auxiliary()
-    logger.info("created an instance of auxiliary_module.Auxiliary")
-    logger.info("calling auxiliary_module.Auxiliary.do_something")
-    a.do_something()
-    logger.info("finished auxiliary_module.Auxiliary.do_something")
-    logger.info("calling auxiliary_module.some_function()")
-    auxiliary_module.some_function()
-    logger.info("done with auxiliary_module.some_function()")
-
-Here is the auxiliary module::
-
-    import logging
-
-    # create logger
-    module_logger = logging.getLogger("spam_application.auxiliary")
-
-    class Auxiliary:
-        def __init__(self):
-            self.logger = logging.getLogger("spam_application.auxiliary.Auxiliary")
-            self.logger.info("creating an instance of Auxiliary")
-        def do_something(self):
-            self.logger.info("doing something")
-            a = 1 + 1
-            self.logger.info("done doing something")
-
-    def some_function():
-        module_logger.info("received a call to \"some_function\"")
-
-The output looks like this::
-
-    2005-03-23 23:47:11,663 - spam_application - INFO -
-       creating an instance of auxiliary_module.Auxiliary
-    2005-03-23 23:47:11,665 - spam_application.auxiliary.Auxiliary - INFO -
-       creating an instance of Auxiliary
-    2005-03-23 23:47:11,665 - spam_application - INFO -
-       created an instance of auxiliary_module.Auxiliary
-    2005-03-23 23:47:11,668 - spam_application - INFO -
-       calling auxiliary_module.Auxiliary.do_something
-    2005-03-23 23:47:11,668 - spam_application.auxiliary.Auxiliary - INFO -
-       doing something
-    2005-03-23 23:47:11,669 - spam_application.auxiliary.Auxiliary - INFO -
-       done doing something
-    2005-03-23 23:47:11,670 - spam_application - INFO -
-       finished auxiliary_module.Auxiliary.do_something
-    2005-03-23 23:47:11,671 - spam_application - INFO -
-       calling auxiliary_module.some_function()
-    2005-03-23 23:47:11,672 - spam_application.auxiliary - INFO -
-       received a call to "some_function"
-    2005-03-23 23:47:11,673 - spam_application - INFO -
-       done with auxiliary_module.some_function()
+   `Original Python logging package <http://www.red-dove.com/python_logging.html>`_
+      This is the original source for the :mod:`logging` package.  The version of the
+      package available from this site is suitable for use with Python 1.5.2, 2.1.x
+      and 2.2.x, which do not include the :mod:`logging` package in the standard
+      library.
 

Modified: python/branches/py3k-cdecimal/Doc/library/msilib.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/msilib.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/msilib.rst	Sun Jan  2 13:18:37 2011
@@ -351,7 +351,7 @@
 -----------------
 
 
-.. class:: Directory(database, cab, basedir, physical,  logical, default, component, [componentflags])
+.. class:: Directory(database, cab, basedir, physical,  logical, default, [componentflags])
 
    Create a new directory in the Directory table. There is a current component at
    each point in time for the directory, which is either explicitly created through

Modified: python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/multiprocessing.rst	Sun Jan  2 13:18:37 2011
@@ -1,8 +1,8 @@
-:mod:`multiprocessing` --- Process-based "threading" interface
-==============================================================
+:mod:`multiprocessing` --- Process-based parallelism
+====================================================
 
 .. module:: multiprocessing
-   :synopsis: Process-based "threading" interface.
+   :synopsis: Process-based parallelism.
 
 
 Introduction

Modified: python/branches/py3k-cdecimal/Doc/library/os.path.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/os.path.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/os.path.rst	Sun Jan  2 13:18:37 2011
@@ -228,7 +228,7 @@
 
    *start* defaults to :attr:`os.curdir`.
 
-   Availability:  Windows, Unix.
+   Availability: Unix, Windows.
 
 
 .. function:: samefile(path1, path2)
@@ -241,7 +241,7 @@
    name using the Windows API call GetFinalPathNameByHandle. This function
    raises an exception if handles cannot be obtained to either file.
 
-   Availability: Windows, Unix.
+   Availability: Unix, Windows.
 
    .. versionchanged:: 3.2
       Added Windows support.

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	Sun Jan  2 13:18:37 2011
@@ -1058,7 +1058,10 @@
 
    Create a hard link pointing to *source* named *link_name*.
 
-   Availability: Unix.
+   Availability: Unix, Windows.
+
+   .. versionchanged:: 3.2
+      Added Windows support.
 
 
 .. function:: listdir(path='.')
@@ -1140,25 +1143,31 @@
    Availability: Unix, Windows.
 
 
-.. function:: makedirs(path[, mode])
+.. function:: makedirs(path, mode=0o777, exist_ok=False)
 
    .. index::
       single: directory; creating
       single: UNC paths; and os.makedirs()
 
    Recursive directory creation function.  Like :func:`mkdir`, but makes all
-   intermediate-level directories needed to contain the leaf directory.  Throws
-   an :exc:`error` exception if the leaf directory already exists or cannot be
-   created.  The default *mode* is ``0o777`` (octal).  On some systems, *mode*
-   is ignored. Where it is used, the current umask value is first masked out.
+   intermediate-level directories needed to contain the leaf directory.  If
+   the target directory with the same mode as specified already exists,
+   raises an :exc:`OSError` exception if *exist_ok* is False, otherwise no
+   exception is raised.  If the directory cannot be created in other cases,
+   raises an :exc:`OSError` exception.  The default *mode* is ``0o777`` (octal).
+   On some systems, *mode* is ignored.  Where it is used, the current umask
+   value is first masked out.
 
    .. note::
 
-      :func:`makedirs` will become confused if the path elements to create include
-      :data:`os.pardir`.
+      :func:`makedirs` will become confused if the path elements to create
+      include :data:`pardir`.
 
    This function handles UNC paths correctly.
 
+   .. versionadded:: 3.2
+      The *exist_ok* parameter.
+
 
 .. function:: pathconf(path, name)
 
@@ -1383,7 +1392,18 @@
 
    Symbolic link support was introduced in Windows 6.0 (Vista).  :func:`symlink`
    will raise a :exc:`NotImplementedError` on Windows versions earlier than 6.0.
-   The *SeCreateSymbolicLinkPrivilege* is required in order to create symlinks.
+
+   .. note::
+
+      The *SeCreateSymbolicLinkPrivilege* is required in order to successfully
+      create symlinks. This privilege is not typically granted to regular
+      users but is available to accounts which can escalate privileges to the
+      administrator level. Either obtaining the privilege or running your
+      application as an administrator are ways to successfully create symlinks.
+
+
+      :exc:`OSError` is raised when the function is called by an unprivileged
+      user.
 
    Availability: Unix, Windows.
 

Modified: python/branches/py3k-cdecimal/Doc/library/parser.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/parser.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/parser.rst	Sun Jan  2 13:18:37 2011
@@ -268,7 +268,7 @@
    will only need to be aware of the simple string values.
 
 Note that the functions :func:`compilest`, :func:`expr`, and :func:`suite` may
-raise exceptions which are normally thrown by the parsing and compilation
+raise exceptions which are normally raised by the parsing and compilation
 process.  These include the built in exceptions :exc:`MemoryError`,
 :exc:`OverflowError`, :exc:`SyntaxError`, and :exc:`SystemError`.  In these
 cases, these exceptions carry all the meaning normally associated with them.

Modified: python/branches/py3k-cdecimal/Doc/library/pdb.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/pdb.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/pdb.rst	Sun Jan  2 13:18:37 2011
@@ -135,7 +135,8 @@
 :class:`Pdb` class and calling the method of the same name.  If you want to
 access further features, you have to do this yourself:
 
-.. class:: Pdb(completekey='tab', stdin=None, stdout=None, skip=None)
+.. class:: Pdb(completekey='tab', stdin=None, stdout=None, skip=None, \
+               nosigint=False)
 
    :class:`Pdb` is the debugger class.
 
@@ -146,6 +147,11 @@
    patterns.  The debugger will not step into frames that originate in a module
    that matches one of these patterns. [1]_
 
+   By default, Pdb sets a handler for the SIGINT signal (which is sent when the
+   user presses Ctrl-C on the console) when you give a ``continue`` command.
+   This allows you to break into the debugger again by pressing Ctrl-C.  If you
+   want Pdb not to touch the SIGINT handler, set *nosigint* tot true.
+
    Example call to enable tracing with *skip*::
 
       import pdb; pdb.Pdb(skip=['django.*']).set_trace()
@@ -153,6 +159,10 @@
    .. versionadded:: 3.1
       The *skip* argument.
 
+   .. versionadded:: 3.2
+      The *nosigint* argument.  Previously, a SIGINT handler was never set by
+      Pdb.
+
    .. method:: run(statement, globals=None, locals=None)
                runeval(expression, globals=None, locals=None)
                runcall(function, *args, **kwds)
@@ -256,8 +266,9 @@
    Temporary breakpoint, which is removed automatically when it is first hit.
    The arguments are the same as for :pdbcmd:`break`.
 
-.. pdbcommand:: cl(ear) [bpnumber [bpnumber ...]]
+.. pdbcommand:: cl(ear) [filename:lineno | bpnumber [bpnumber ...]]
 
+   With a *filename:lineno* argument, clear all the breakpoints at this line.
    With a space separated list of breakpoint numbers, clear those breakpoints.
    Without argument, clear all breaks (but first ask confirmation).
 
@@ -406,6 +417,30 @@
 
    .. versionadded:: 3.2
 
+.. pdbcommand:: display [expression]
+
+   Display the value of the expression if it changed, each time execution stops
+   in the current frame.
+
+   Without expression, list all display expressions for the current frame.
+
+   .. versionadded:: 3.2
+
+.. pdbcommand:: undisplay [expression]
+
+   Do not display the expression any more in the current frame.  Without
+   expression, clear all display expressions for the current frame.
+
+   .. versionadded:: 3.2
+
+.. pdbcommand:: interact
+
+   Start an interative interpreter (using the :mod:`code` module) whose global
+   namespace contains all the (global and local) names found in the current
+   scope.
+
+   .. versionadded:: 3.2
+
 .. _debugger-aliases:
 
 .. pdbcommand:: alias [name [command]]

Modified: python/branches/py3k-cdecimal/Doc/library/pickle.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/pickle.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/pickle.rst	Sun Jan  2 13:18:37 2011
@@ -42,7 +42,7 @@
 objects.  :mod:`marshal` exists primarily to support Python's :file:`.pyc`
 files.
 
-The :mod:`pickle` module differs from :mod:`marshal` several significant ways:
+The :mod:`pickle` module differs from :mod:`marshal` in several significant ways:
 
 * The :mod:`pickle` module keeps track of the objects it has already serialized,
   so that later references to the same object won't be serialized again.

Modified: python/branches/py3k-cdecimal/Doc/library/pkgutil.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/pkgutil.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/pkgutil.rst	Sun Jan  2 13:18:37 2011
@@ -77,8 +77,8 @@
    newly created by a path hook.
 
    If there is no importer, a wrapper around the basic import machinery is
-   returned.  This wrapper is never inserted into the importer cache (None is
-   inserted instead).
+   returned.  This wrapper is never inserted into the importer cache (``None``
+   is inserted instead).
 
    The cache (or part of it) can be cleared manually if a rescan of
    :data:`sys.path_hooks` is necessary.

Modified: python/branches/py3k-cdecimal/Doc/library/platform.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/platform.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/platform.rst	Sun Jan  2 13:18:37 2011
@@ -36,6 +36,16 @@
    and then only if the executable points to the Python interpreter.  Reasonable
    defaults are used when the above needs are not met.
 
+   .. note::
+
+      On Mac OS X (and perhaps other platforms), executable files may be
+      universal files containing multiple architectures.
+
+      To get at the "64-bitness" of the current interpreter, it is more
+      reliable to query the :attr:`sys.maxsize` attribute::
+
+         is_64bits = sys.maxsize > 2**32
+
 
 .. function:: machine()
 
@@ -186,7 +196,7 @@
 
    .. note::
 
-      Note: this function works best with Mark Hammond's
+      This function works best with Mark Hammond's
       :mod:`win32all` package installed, but also on Python 2.3 and
       later (support for this was added in Python 2.6). It obviously
       only runs on Win32 compatible platforms.

Modified: python/branches/py3k-cdecimal/Doc/library/pty.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/pty.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/pty.rst	Sun Jan  2 13:18:37 2011
@@ -45,3 +45,50 @@
    a file descriptor. The defaults try to read 1024 bytes each time they are
    called.
 
+
+Example
+-------
+
+.. sectionauthor:: Steen Lumholt
+
+The following program acts like the Unix command :manpage:`script(1)`, using a
+pseudo-terminal to record all input and output of a terminal session in a
+"typescript". ::
+
+   import sys, os, time, getopt
+   import pty
+
+   mode = 'wb'
+   shell = 'sh'
+   filename = 'typescript'
+   if 'SHELL' in os.environ:
+       shell = os.environ['SHELL']
+
+   try:
+       opts, args = getopt.getopt(sys.argv[1:], 'ap')
+   except getopt.error as msg:
+       print('%s: %s' % (sys.argv[0], msg))
+       sys.exit(2)
+
+   for opt, arg in opts:
+       # option -a: append to typescript file
+       if opt == '-a':
+           mode = 'ab'
+       # option -p: use a Python shell as the terminal command
+       elif opt == '-p':
+           shell = sys.executable
+   if args:
+       filename = args[0]
+
+   script = open(filename, mode)
+
+   def read(fd):
+       data = os.read(fd, 1024)
+       script.write(data)
+       return data
+
+   sys.stdout.write('Script started, file is %s\n' % filename)
+   script.write(('Script started on %s\n' % time.asctime()).encode())
+   pty.spawn(shell, read)
+   script.write(('Script done on %s\n' % time.asctime()).encode())
+   sys.stdout.write('Script done, file is %s\n' % filename)

Modified: python/branches/py3k-cdecimal/Doc/library/py_compile.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/py_compile.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/py_compile.rst	Sun Jan  2 13:18:37 2011
@@ -22,20 +22,29 @@
    Exception raised when an error occurs while attempting to compile the file.
 
 
-.. function:: compile(file, cfile=None, dfile=None, doraise=False)
+.. function:: compile(file, cfile=None, dfile=None, doraise=False, optimize=-1)
 
-   Compile a source file to byte-code and write out the byte-code cache  file.  The
-   source code is loaded from the file name *file*.  The  byte-code is written to
-   *cfile*, which defaults to the :PEP:`3147` path, ending in ``.pyc``
-   (``'.pyo`` if optimization is enabled in the current interpreter).  For
-   example, if *file* is ``/foo/bar/baz.py`` *cfile* will default to
-   ``/foo/bar/__pycache__/baz.cpython-32.pyc`` for Python 3.2.  If *dfile* is specified, it is used as the
-   name of the source file in error messages instead of *file*.  If *doraise* is
-   true, a :exc:`PyCompileError` is raised when an error is encountered while
-   compiling *file*. If *doraise* is false (the default), an error string is
-   written to ``sys.stderr``, but no exception is raised.  This function
-   returns the path to byte-compiled file, i.e. whatever *cfile* value was
-   used.
+   Compile a source file to byte-code and write out the byte-code cache  file.
+   The source code is loaded from the file name *file*.  The  byte-code is
+   written to *cfile*, which defaults to the :PEP:`3147` path, ending in
+   ``.pyc`` (``.pyo`` if optimization is enabled in the current interpreter).
+   For example, if *file* is ``/foo/bar/baz.py`` *cfile* will default to
+   ``/foo/bar/__pycache__/baz.cpython-32.pyc`` for Python 3.2.  If *dfile* is
+   specified, it is used as the name of the source file in error messages when
+   instead of *file*.  If *doraise* is true, a :exc:`PyCompileError` is raised
+   when an error is encountered while compiling *file*. If *doraise* is false
+   (the default), an error string is written to ``sys.stderr``, but no exception
+   is raised.  This function returns the path to byte-compiled file, i.e.
+   whatever *cfile* value was used.
+
+   *optimize* controls the optimization level and is passed to the built-in
+   :func:`compile` function.  The default of ``-1`` selects the optimization
+   level of the current interpreter.
+
+   .. versionchanged:: 3.2
+      Changed default value of *cfile* to be :PEP:`3147`-compliant.  Previous
+      default was *file* + ``'c'`` (``'o'`` if optimization was enabled).
+      Also added the *optimize* parameter.
 
 
 .. function:: main(args=None)
@@ -44,6 +53,11 @@
    line, if *args* is ``None``) are compiled and the resulting bytecode is
    cached in the normal manner.  This function does not search a directory
    structure to locate source files; it only compiles files named explicitly.
+   If ``'-'`` is the only parameter in args, the list of files is taken from
+   standard input.
+
+   .. versionchanged:: 3.2
+      Added support for ``'-'``.
 
 When this module is run as a script, the :func:`main` is used to compile all the
 files named on the command line.  The exit status is nonzero if one of the files

Modified: python/branches/py3k-cdecimal/Doc/library/pydoc.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/pydoc.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/pydoc.rst	Sun Jan  2 13:18:37 2011
@@ -50,12 +50,21 @@
 module is the first line of its documentation string.
 
 You can also use :program:`pydoc` to start an HTTP server on the local machine
-that will serve documentation to visiting Web browsers. :program:`pydoc -p 1234`
-will start a HTTP server on port 1234, allowing you to browse
-the documentation at ``http://localhost:1234/`` in your preferred Web browser.
+that will serve documentation to visiting Web browsers.  :program:`pydoc -p 1234`
+will start a HTTP server on port 1234, allowing you to browse the
+documentation at ``http://localhost:1234/`` in your preferred Web browser.
+Specifying ``0`` as the port number will select an arbitrary unused port.
+
 :program:`pydoc -g` will start the server and additionally bring up a
 small :mod:`tkinter`\ -based graphical interface to help you search for
-documentation pages.
+documentation pages.  The ``-g`` option is deprecated, since the server can
+now be controlled directly from HTTP clients.
+
+:program:`pydoc -b` will start the server and additionally open a web
+browser to a module index page.  Each served page has a navigation bar at the
+top where you can *Get* help on an individual item, *Search* all modules with a
+keyword in their synopsis line, and go to the *Module index*, *Topics* and
+*Keywords* pages.
 
 When :program:`pydoc` generates documentation, it uses the current environment
 and path to locate modules.  Thus, invoking :program:`pydoc spam`
@@ -69,3 +78,5 @@
 to a different URL or to a local directory containing the Library
 Reference Manual pages.
 
+.. versionchanged:: 3.2
+   Added the ``-b`` option, deprecated the ``-g`` option.

Modified: python/branches/py3k-cdecimal/Doc/library/random.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/random.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/random.rst	Sun Jan  2 13:18:37 2011
@@ -233,41 +233,18 @@
    parameter.
 
 
-Alternative Generators:
+Alternative Generator:
 
 .. class:: SystemRandom([seed])
 
    Class that uses the :func:`os.urandom` function for generating random numbers
    from sources provided by the operating system. Not available on all systems.
-   Does not rely on software state and sequences are not reproducible. Accordingly,
+   Does not rely on software state, and sequences are not reproducible. Accordingly,
    the :meth:`seed` method has no effect and is ignored.
    The :meth:`getstate` and :meth:`setstate` methods raise
    :exc:`NotImplementedError` if called.
 
 
-Examples of basic usage::
-
-   >>> random.random()        # Random float x, 0.0 <= x < 1.0
-   0.37444887175646646
-   >>> random.uniform(1, 10)  # Random float x, 1.0 <= x < 10.0
-   1.1800146073117523
-   >>> random.randint(1, 10)  # Integer from 1 to 10, endpoints included
-   7
-   >>> random.randrange(0, 101, 2)  # Even integer from 0 to 100
-   26
-   >>> random.choice('abcdefghij')  # Choose a random element
-   'c'
-
-   >>> items = [1, 2, 3, 4, 5, 6, 7]
-   >>> random.shuffle(items)
-   >>> items
-   [7, 3, 2, 5, 6, 4, 1]
-
-   >>> random.sample([1, 2, 3, 4, 5],  3)  # Choose 3 elements
-   [4, 1, 5]
-
-
-
 .. seealso::
 
    M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-dimensionally
@@ -280,8 +257,9 @@
    random number generator with a long period and comparatively simple update
    operations.
 
+
 Notes on Reproducibility
-========================
+------------------------
 
 Sometimes it is useful to be able to reproduce the sequences given by a pseudo
 random number generator.  By re-using a seed value, the same sequence should be
@@ -295,3 +273,53 @@
 
 * The generator's :meth:`random` method will continue to produce the same
   sequence when the compatible seeder is given the same seed.
+
+.. _random-examples:
+
+Examples and Recipes
+--------------------
+
+Basic usage::
+
+   >>> random.random()                      # Random float x, 0.0 <= x < 1.0
+   0.37444887175646646
+
+   >>> random.uniform(1, 10)                # Random float x, 1.0 <= x < 10.0
+   1.1800146073117523
+
+   >>> random.randrange(10)                 # Integer from 0 to 9
+   7
+
+   >>> random.randrange(0, 101, 2)          # Even integer from 0 to 100
+   26
+
+   >>> random.choice('abcdefghij')          # Single random element
+   'c'
+
+   >>> items = [1, 2, 3, 4, 5, 6, 7]
+   >>> random.shuffle(items)
+   >>> items
+   [7, 3, 2, 5, 6, 4, 1]
+
+   >>> random.sample([1, 2, 3, 4, 5],  3)   # Three samples without replacement
+   [4, 1, 5]
+
+A common task is to make a :func:`random.choice` with weighted probababilites.
+
+If the weights are small integer ratios, a simple technique is to build a sample
+population with repeats::
+
+    >>> weighted_choices = [('Red', 3), ('Blue', 2), ('Yellow', 1), ('Green', 4)]
+    >>> population = [val for val, cnt in weighted_choices for i in range(cnt)]
+    >>> random.choice(population)
+    'Green'
+
+A more general approach is to arrange the weights in a cumulative distribution
+with :func:`itertools.accumulate`, and then locate the random value with
+:func:`bisect.bisect`::
+
+    >>> choices, weights = zip(*weighted_choices)
+    >>> cumdist = list(itertools.accumulate(weights))
+    >>> x = random.random() * cumdist[-1]
+    >>> choices[bisect.bisect(cumdist, x)]
+    'Blue'

Modified: python/branches/py3k-cdecimal/Doc/library/re.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/re.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/re.rst	Sun Jan  2 13:18:37 2011
@@ -991,8 +991,10 @@
    The string passed to :meth:`~regex.match` or :meth:`~regex.search`.
 
 
-Examples
---------
+.. _re-examples:
+
+Regular Expression Examples
+---------------------------
 
 
 Checking For a Pair
@@ -1298,6 +1300,7 @@
     Token = collections.namedtuple('Token', 'typ value line column')
 
     def tokenize(s):
+        keywords = {'IF', 'THEN', 'FOR', 'NEXT', 'GOSUB', 'RETURN'}
         tok_spec = [
             ('NUMBER', r'\d+(\.\d*)?'), # Integer or decimal number
             ('ASSIGN', r':='),          # Assignment operator
@@ -1318,6 +1321,8 @@
                 line_start = pos
                 line += 1
             elif typ != 'SKIP':
+                if typ == 'ID' and val in keywords:
+                    typ = val
                 yield Token(typ, mo.group(typ), line, mo.start()-line_start)
             pos = mo.end()
             mo = gettok(s, pos)

Modified: python/branches/py3k-cdecimal/Doc/library/runpy.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/runpy.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/runpy.rst	Sun Jan  2 13:18:37 2011
@@ -70,6 +70,9 @@
    .. versionchanged:: 3.1
       Added ability to execute packages by looking for a ``__main__`` submodule.
 
+   .. versionchanged:: 3.2
+      Added ``__cached__`` global variable (see :PEP:`3147`).
+
 
 .. function:: run_path(file_path, init_globals=None, run_name=None)
 

Modified: python/branches/py3k-cdecimal/Doc/library/shelve.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/shelve.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/shelve.rst	Sun Jan  2 13:18:37 2011
@@ -101,7 +101,7 @@
   implementation used.
 
 
-.. class:: Shelf(dict, protocol=None, writeback=False)
+.. class:: Shelf(dict, protocol=None, writeback=False, keyencoding='utf-8')
 
    A subclass of :class:`collections.MutableMapping` which stores pickled values
    in the *dict* object.
@@ -115,8 +115,15 @@
    This allows natural operations on mutable entries, but can consume much more
    memory and make sync and close take a long time.
 
+   The *keyencoding* parameter is the encoding used to encode keys before they
+   are used with the underlying dict.
 
-.. class:: BsdDbShelf(dict, protocol=None, writeback=False)
+   .. versionadded:: 3.2
+      The *keyencoding* parameter; previously, keys were always encoded in
+      UTF-8.
+
+
+.. class:: BsdDbShelf(dict, protocol=None, writeback=False, keyencoding='utf-8')
 
    A subclass of :class:`Shelf` which exposes :meth:`first`, :meth:`!next`,
    :meth:`previous`, :meth:`last` and :meth:`set_location` which are available
@@ -125,8 +132,8 @@
    modules.  The *dict* object passed to the constructor must support those
    methods.  This is generally accomplished by calling one of
    :func:`bsddb.hashopen`, :func:`bsddb.btopen` or :func:`bsddb.rnopen`.  The
-   optional *protocol* and *writeback* parameters have the same interpretation
-   as for the :class:`Shelf` class.
+   optional *protocol*, *writeback*, and *keyencoding* parameters have the same
+   interpretation as for the :class:`Shelf` class.
 
 
 .. class:: DbfilenameShelf(filename, flag='c', protocol=None, writeback=False)

Modified: python/branches/py3k-cdecimal/Doc/library/socket.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/socket.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/socket.rst	Sun Jan  2 13:18:37 2011
@@ -14,16 +14,6 @@
    Some behavior may be platform dependent, since calls are made to the operating
    system socket APIs.
 
-For an introduction to socket programming (in C), see the following papers: An
-Introductory 4.3BSD Interprocess Communication Tutorial, by Stuart Sechrest and
-An Advanced 4.3BSD Interprocess Communication Tutorial, by Samuel J.  Leffler et
-al, both in the UNIX Programmer's Manual, Supplementary Documents 1 (sections
-PS1:7 and PS1:8).  The platform-specific reference material for the various
-socket-related system calls are also a valuable source of information on the
-details of socket semantics.  For Unix, refer to the manual pages; for Windows,
-see the WinSock (or Winsock 2) specification. For IPv6-ready APIs, readers may
-want to refer to :rfc:`3493` titled Basic Socket Interface Extensions for IPv6.
-
 .. index:: object: socket
 
 The Python interface is a straightforward transliteration of the Unix system
@@ -34,26 +24,63 @@
 files, buffer allocation on receive operations is automatic, and buffer length
 is implicit on send operations.
 
-Socket addresses are represented as follows: A single string is used for the
-:const:`AF_UNIX` address family. A pair ``(host, port)`` is used for the
-:const:`AF_INET` address family, where *host* is a string representing either a
-hostname in Internet domain notation like ``'daring.cwi.nl'`` or an IPv4 address
-like ``'100.50.200.5'``, and *port* is an integral port number. For
-:const:`AF_INET6` address family, a four-tuple ``(host, port, flowinfo,
-scopeid)`` is used, where *flowinfo* and *scopeid* represents ``sin6_flowinfo``
-and ``sin6_scope_id`` member in :const:`struct sockaddr_in6` in C. For
-:mod:`socket` module methods, *flowinfo* and *scopeid* can be omitted just for
-backward compatibility. Note, however, omission of *scopeid* can cause problems
-in manipulating scoped IPv6 addresses. Other address families are currently not
-supported. The address format required by a particular socket object is
-automatically selected based on the address family specified when the socket
-object was created.
+
+Socket families
+---------------
+
+Depending on the system and the build options, various socket families
+are supported by this module.
+
+Socket addresses are represented as follows:
+
+- A single string is used for the :const:`AF_UNIX` address family.
+
+- A pair ``(host, port)`` is used for the :const:`AF_INET` address family,
+  where *host* is a string representing either a hostname in Internet domain
+  notation like ``'daring.cwi.nl'`` or an IPv4 address like ``'100.50.200.5'``,
+  and *port* is an integral port number.
+
+- For :const:`AF_INET6` address family, a four-tuple ``(host, port, flowinfo,
+  scopeid)`` is used, where *flowinfo* and *scopeid* represent the ``sin6_flowinfo``
+  and ``sin6_scope_id`` members in :const:`struct sockaddr_in6` in C.  For
+  :mod:`socket` module methods, *flowinfo* and *scopeid* can be omitted just for
+  backward compatibility.  Note, however, omission of *scopeid* can cause problems
+  in manipulating scoped IPv6 addresses.
+
+- :const:`AF_NETLINK` sockets are represented as pairs ``(pid, groups)``.
+
+- Linux-only support for TIPC is available using the :const:`AF_TIPC`
+  address family.  TIPC is an open, non-IP based networked protocol designed
+  for use in clustered computer environments.  Addresses are represented by a
+  tuple, and the fields depend on the address type. The general tuple form is
+  ``(addr_type, v1, v2, v3 [, scope])``, where:
+
+  - *addr_type* is one of TIPC_ADDR_NAMESEQ, TIPC_ADDR_NAME, or
+    TIPC_ADDR_ID.
+  - *scope* is one of TIPC_ZONE_SCOPE, TIPC_CLUSTER_SCOPE, and
+    TIPC_NODE_SCOPE.
+  - If *addr_type* is TIPC_ADDR_NAME, then *v1* is the server type, *v2* is
+    the port identifier, and *v3* should be 0.
+
+    If *addr_type* is TIPC_ADDR_NAMESEQ, then *v1* is the server type, *v2*
+    is the lower port number, and *v3* is the upper port number.
+
+    If *addr_type* is TIPC_ADDR_ID, then *v1* is the node, *v2* is the
+    reference, and *v3* should be set to 0.
+
+    If *addr_type* is TIPC_ADDR_ID, then *v1* is the node, *v2* is the
+    reference, and *v3* should be set to 0.
+
+- Certain other address families (:const:`AF_BLUETOOTH`, :const:`AF_PACKET`)
+  support specific representations.
+
+  .. XXX document them!
 
 For IPv4 addresses, two special forms are accepted instead of a host address:
 the empty string represents :const:`INADDR_ANY`, and the string
-``'<broadcast>'`` represents :const:`INADDR_BROADCAST`. The behavior is not
-available for IPv6 for backward compatibility, therefore, you may want to avoid
-these if you intend to support IPv6 with your Python programs.
+``'<broadcast>'`` represents :const:`INADDR_BROADCAST`.  This behavior is not
+compatible with IPv6, therefore, you may want to avoid these if you intend
+to support IPv6 with your Python programs.
 
 If you use a hostname in the *host* portion of IPv4/v6 socket address, the
 program may show a nondeterministic behavior, as Python uses the first address
@@ -62,40 +89,18 @@
 resolution and/or the host configuration.  For deterministic behavior use a
 numeric address in *host* portion.
 
-AF_NETLINK sockets are represented as  pairs ``pid, groups``.
-
-
-Linux-only support for TIPC is also available using the :const:`AF_TIPC`
-address family. TIPC is an open, non-IP based networked protocol designed
-for use in clustered computer environments.  Addresses are represented by a
-tuple, and the fields depend on the address type. The general tuple form is
-``(addr_type, v1, v2, v3 [, scope])``, where:
-
-- *addr_type* is one of TIPC_ADDR_NAMESEQ, TIPC_ADDR_NAME, or
-  TIPC_ADDR_ID.
-- *scope* is one of TIPC_ZONE_SCOPE, TIPC_CLUSTER_SCOPE, and
-  TIPC_NODE_SCOPE.
-- If *addr_type* is TIPC_ADDR_NAME, then *v1* is the server type, *v2* is
-  the port identifier, and *v3* should be 0.
-
-  If *addr_type* is TIPC_ADDR_NAMESEQ, then *v1* is the server type, *v2*
-  is the lower port number, and *v3* is the upper port number.
-
-  If *addr_type* is TIPC_ADDR_ID, then *v1* is the node, *v2* is the
-  reference, and *v3* should be set to 0.
-
-  If *addr_type* is TIPC_ADDR_ID, then *v1* is the node, *v2* is the
-  reference, and *v3* should be set to 0.
-
-
 All errors raise exceptions.  The normal exceptions for invalid argument types
 and out-of-memory conditions can be raised; errors related to socket or address
-semantics raise the error :exc:`socket.error`.
+semantics raise :exc:`socket.error` or one of its subclasses.
 
 Non-blocking mode is supported through :meth:`~socket.setblocking`.  A
 generalization of this based on timeouts is supported through
 :meth:`~socket.settimeout`.
 
+
+Module contents
+---------------
+
 The module :mod:`socket` exports the following constants and functions:
 
 
@@ -144,7 +149,8 @@
 
    These constants represent the address (and protocol) families, used for the
    first argument to :func:`socket`.  If the :const:`AF_UNIX` constant is not
-   defined then this protocol is unsupported.
+   defined then this protocol is unsupported.  More constants may be available
+   depending on the system.
 
 
 .. data:: SOCK_STREAM
@@ -154,8 +160,9 @@
           SOCK_SEQPACKET
 
    These constants represent the socket types, used for the second argument to
-   :func:`socket`. (Only :const:`SOCK_STREAM` and :const:`SOCK_DGRAM` appear to be
-   generally useful.)
+   :func:`socket`.  More constants may be available depending on the system.
+   (Only :const:`SOCK_STREAM` and :const:`SOCK_DGRAM` appear to be generally
+   useful.)
 
 .. data:: SOCK_CLOEXEC
           SOCK_NONBLOCK
@@ -627,18 +634,24 @@
    is system-dependent (usually 5).
 
 
-.. method:: socket.makefile(mode='r', buffering=None, *, encoding=None, errors=None, newline=None)
+.. method:: socket.makefile(mode='r', buffering=None, *, encoding=None, \
+                            errors=None, newline=None)
 
    .. index:: single: I/O control; buffering
 
-   Return a :term:`file object` associated with the socket.  The exact
-   returned type depends on the arguments given to :meth:`makefile`.  These
-   arguments are interpreted the same way as by the built-in :func:`open`
-   function.
-
-   Closing the file object won't close the socket unless there are no
-   remaining references to the socket.  The socket must be in blocking mode
-   (it can not have a timeout).
+   Return a :term:`file object` associated with the socket.  The exact returned
+   type depends on the arguments given to :meth:`makefile`.  These arguments are
+   interpreted the same way as by the built-in :func:`open` function.
+
+   Closing the file object won't close the socket unless there are no remaining
+   references to the socket.  The socket must be in blocking mode (it can not
+   have a timeout).
+
+   .. note::
+
+      On Windows, the file-like object created by :meth:`makefile` cannot be
+      used where a file object with a file descriptor is expected, such as the
+      stream arguments of :meth:`subprocess.Popen`.
 
 
 .. method:: socket.recv(bufsize[, flags])
@@ -950,3 +963,21 @@
 
    # disabled promiscuous mode
    s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
+
+
+.. seealso::
+
+   For an introduction to socket programming (in C), see the following papers:
+
+   - *An Introductory 4.3BSD Interprocess Communication Tutorial*, by Stuart Sechrest
+
+   - *An Advanced 4.3BSD Interprocess Communication Tutorial*, by Samuel J.  Leffler et
+     al,
+
+   both in the UNIX Programmer's Manual, Supplementary Documents 1 (sections
+   PS1:7 and PS1:8).  The platform-specific reference material for the various
+   socket-related system calls are also a valuable source of information on the
+   details of socket semantics.  For Unix, refer to the manual pages; for Windows,
+   see the WinSock (or Winsock 2) specification.  For IPv6-ready APIs, readers may
+   want to refer to :rfc:`3493` titled Basic Socket Interface Extensions for IPv6.
+

Modified: python/branches/py3k-cdecimal/Doc/library/someos.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/someos.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/someos.rst	Sun Jan  2 13:18:37 2011
@@ -14,11 +14,11 @@
 
    select.rst
    threading.rst
-   dummy_threading.rst
-   _thread.rst
-   _dummy_thread.rst
-   concurrent.futures.rst
    multiprocessing.rst
+   concurrent.futures.rst
    mmap.rst
    readline.rst
    rlcompleter.rst
+   dummy_threading.rst
+   _thread.rst
+   _dummy_thread.rst

Modified: python/branches/py3k-cdecimal/Doc/library/sqlite3.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/sqlite3.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/sqlite3.rst	Sun Jan  2 13:18:37 2011
@@ -888,4 +888,4 @@
 .. [#f1] The sqlite3 module is not built with loadable extension support by
   default, because some platforms (notably Mac OS X) have SQLite libraries which
   are compiled without this feature. To get loadable extension support, you must
-  modify setup.py and and remove the line that sets SQLITE_OMIT_LOAD_EXTENSION.
+  pass --enable-loadable-sqlite-extensions to configure.

Modified: python/branches/py3k-cdecimal/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/stdtypes.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/stdtypes.rst	Sun Jan  2 13:18:37 2011
@@ -836,8 +836,8 @@
 must have a trailing comma, such as ``(d,)``.
 
 Objects of type range are created using the :func:`range` function.  They don't
-support slicing, concatenation or repetition, and using ``in``, ``not in``,
-:func:`min` or :func:`max` on them is inefficient.
+support concatenation or repetition, and using :func:`min` or :func:`max` on
+them is inefficient.
 
 Most sequence types support the following operations.  The ``in`` and ``not in``
 operations have the same priorities as the comparison operations.  The ``+`` and
@@ -1078,20 +1078,26 @@
 .. method:: str.isalnum()
 
    Return true if all characters in the string are alphanumeric and there is at
-   least one character, false otherwise.
+   least one character, false otherwise.  A character ``c`` is alphanumeric if one
+   of the following returns ``True``: ``c.isalpha()``, ``c.isdecimal()``,
+   ``c.isdigit()``, or ``c.isnumeric()``.
 
 
 .. method:: str.isalpha()
 
    Return true if all characters in the string are alphabetic and there is at least
-   one character, false otherwise.
+   one character, false otherwise.  Alphabetic characters are those characters defined
+   in the Unicode character database as "Letter", i.e., those with general category
+   property being one of "Lm", "Lt", "Lu", "Ll", or "Lo".  Note that this is different
+   from the "Alphabetic" property defined in the Unicode Standard.
 
 
 .. method:: str.isdecimal()
 
    Return true if all characters in the string are decimal
    characters and there is at least one character, false
-   otherwise. Decimal characters include digit characters, and all characters
+   otherwise. Decimal characters are those from general category "Nd". This category
+   includes digit characters, and all characters
    that that can be used to form decimal-radix numbers, e.g. U+0660,
    ARABIC-INDIC DIGIT ZERO.
 
@@ -1099,7 +1105,9 @@
 .. method:: str.isdigit()
 
    Return true if all characters in the string are digits and there is at least one
-   character, false otherwise.
+   character, false otherwise.  Digits include decimal characters and digits that need
+   special handling, such as the compatibility superscript digits.  Formally, a digit
+   is a character that has the property value Numeric_Type=Digit or Numeric_Type=Decimal.
 
 
 .. method:: str.isidentifier()
@@ -1111,7 +1119,9 @@
 .. method:: str.islower()
 
    Return true if all cased characters in the string are lowercase and there is at
-   least one cased character, false otherwise.
+   least one cased character, false otherwise.  Cased characters are those with
+   general category property being one of "Lu", "Ll", or "Lt" and lowercase characters
+   are those with general category property "Ll".
 
 
 .. method:: str.isnumeric()
@@ -1120,7 +1130,8 @@
    characters, and there is at least one character, false
    otherwise. Numeric characters include digit characters, and all characters
    that have the Unicode numeric value property, e.g. U+2155,
-   VULGAR FRACTION ONE FIFTH.
+   VULGAR FRACTION ONE FIFTH.  Formally, numeric characters are those with the property
+   value Numeric_Type=Digit, Numeric_Type=Decimal or Numeric_Type=Numeric.
 
 
 .. method:: str.isprintable()
@@ -1137,8 +1148,9 @@
 .. method:: str.isspace()
 
    Return true if there are only whitespace characters in the string and there is
-   at least one character, false otherwise.
-
+   at least one character, false otherwise.  Whitespace characters  are those
+   characters defined in the Unicode character database as "Other" or "Separator"
+   and those with bidirectional property being one of "WS", "B", or "S".
 
 .. method:: str.istitle()
 
@@ -1150,7 +1162,9 @@
 .. method:: str.isupper()
 
    Return true if all cased characters in the string are uppercase and there is at
-   least one cased character, false otherwise.
+   least one cased character, false otherwise. Cased characters are those with
+   general category property being one of "Lu", "Ll", or "Lt" and uppercase characters
+   are those with general category property "Lu".
 
 
 .. method:: str.join(iterable)
@@ -2279,8 +2293,8 @@
 ===============
 
 :class:`memoryview` objects allow Python code to access the internal data
-of an object that supports the buffer protocol without copying.  Memory
-is generally interpreted as simple bytes.
+of an object that supports the :ref:`buffer protocol <bufferobjects>` without
+copying.  Memory is generally interpreted as simple bytes.
 
 .. class:: memoryview(obj)
 
@@ -2419,6 +2433,10 @@
       A tuple of integers the length of :attr:`ndim` giving the size in bytes to
       access each element for each dimension of the array.
 
+   .. attribute:: readonly
+
+      A bool indicating whether the memory is read only.
+
    .. memoryview.suboffsets isn't documented because it only seems useful for C
 
 
@@ -2433,12 +2451,9 @@
    single: protocol; context management
 
 Python's :keyword:`with` statement supports the concept of a runtime context
-defined by a context manager.  This is implemented using two separate methods
+defined by a context manager.  This is implemented using a pair of methods
 that allow user-defined classes to define a runtime context that is entered
-before the statement body is executed and exited when the statement ends.
-
-The :dfn:`context management protocol` consists of a pair of methods that need
-to be provided for a context manager object to define a runtime context:
+before the statement body is executed and exited when the statement ends:
 
 
 .. method:: contextmanager.__enter__()
@@ -2486,9 +2501,9 @@
 their implementation of the context management protocol. See the
 :mod:`contextlib` module for some examples.
 
-Python's :term:`generator`\s and the ``contextlib.contextmanager`` :term:`decorator`
+Python's :term:`generator`\s and the :class:`contextlib.contextmanager` decorator
 provide a convenient way to implement these protocols.  If a generator function is
-decorated with the ``contextlib.contextmanager`` decorator, it will return a
+decorated with the :class:`contextlib.contextmanager` decorator, it will return a
 context manager implementing the necessary :meth:`__enter__` and
 :meth:`__exit__` methods, rather than the iterator produced by an undecorated
 generator function.

Modified: python/branches/py3k-cdecimal/Doc/library/string.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/string.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/string.rst	Sun Jan  2 13:18:37 2011
@@ -350,9 +350,18 @@
    |         | positive numbers, and a minus sign on negative numbers.  |
    +---------+----------------------------------------------------------+
 
-The ``'#'`` option is only valid for integers, and only for binary, octal, or
-hexadecimal output.  If present, it specifies that the output will be prefixed
-by ``'0b'``, ``'0o'``, or ``'0x'``, respectively.
+
+The ``'#'`` option causes the "alternate form" to be used for the
+conversion.  The alternate form is defined differently for different
+types.  This option is only valid for integer, float, complex and
+Decimal types. For integers, when binary, octal, or hexadecimal output
+is used, this option adds the prefix respective ``'0b'``, ``'0o'``, or
+``'0x'`` to the output value. For floats, complex and Decimal the
+alternate form causes the result of the conversion to always contain a
+decimal-point character, even if no digits follow it. Normally, a
+decimal-point character appears in the result of these conversions
+only if a digit follows it. In addition, for ``'g'`` and ``'G'``
+conversions, trailing zeros are not removed from the result.
 
 The ``','`` option signals the use of a comma for a thousands separator.
 For a locale aware separator, use the ``'n'`` integer presentation type

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	Sun Jan  2 13:18:37 2011
@@ -164,58 +164,53 @@
 +--------+--------------------------+--------------------+----------------+------------+
 | ``c``  | :c:type:`char`           | bytes of length 1  | 1              |            |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``b``  | :c:type:`signed char`    | integer            | 1              | \(1),\(4)  |
+| ``b``  | :c:type:`signed char`    | integer            | 1              | \(1),\(3)  |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``B``  | :c:type:`unsigned char`  | integer            | 1              | \(4)       |
+| ``B``  | :c:type:`unsigned char`  | integer            | 1              | \(3)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``?``  | :c:type:`_Bool`          | bool               | 1              | \(2)       |
+| ``?``  | :c:type:`_Bool`          | bool               | 1              | \(1)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``h``  | :c:type:`short`          | integer            | 2              | \(4)       |
+| ``h``  | :c:type:`short`          | integer            | 2              | \(3)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``H``  | :c:type:`unsigned short` | integer            | 2              | \(4)       |
+| ``H``  | :c:type:`unsigned short` | integer            | 2              | \(3)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``i``  | :c:type:`int`            | integer            | 4              | \(4)       |
+| ``i``  | :c:type:`int`            | integer            | 4              | \(3)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``I``  | :c:type:`unsigned int`   | integer            | 4              | \(4)       |
+| ``I``  | :c:type:`unsigned int`   | integer            | 4              | \(3)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``l``  | :c:type:`long`           | integer            | 4              | \(4)       |
+| ``l``  | :c:type:`long`           | integer            | 4              | \(3)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``L``  | :c:type:`unsigned long`  | integer            | 4              | \(4)       |
+| ``L``  | :c:type:`unsigned long`  | integer            | 4              | \(3)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``q``  | :c:type:`long long`      | integer            | 8              | \(3), \(4) |
+| ``q``  | :c:type:`long long`      | integer            | 8              | \(2), \(3) |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``Q``  | :c:type:`unsigned long   | integer            | 8              | \(3), \(4) |
+| ``Q``  | :c:type:`unsigned long   | integer            | 8              | \(2), \(3) |
 |        | long`                    |                    |                |            |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``f``  | :c:type:`float`          | float              | 4              | \(5)       |
+| ``f``  | :c:type:`float`          | float              | 4              | \(4)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``d``  | :c:type:`double`         | float              | 8              | \(5)       |
+| ``d``  | :c:type:`double`         | float              | 8              | \(4)       |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``s``  | :c:type:`char[]`         | bytes              |                | \(1)       |
+| ``s``  | :c:type:`char[]`         | bytes              |                |            |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``p``  | :c:type:`char[]`         | bytes              |                | \(1)       |
+| ``p``  | :c:type:`char[]`         | bytes              |                |            |
 +--------+--------------------------+--------------------+----------------+------------+
-| ``P``  | :c:type:`void \*`        | integer            |                | \(6)       |
+| ``P``  | :c:type:`void \*`        | integer            |                | \(5)       |
 +--------+--------------------------+--------------------+----------------+------------+
 
 Notes:
 
 (1)
-   The ``c``, ``s`` and ``p`` conversion codes operate on :class:`bytes`
-   objects, but packing with such codes also supports :class:`str` objects,
-   which are encoded using UTF-8.
-
-(2)
    The ``'?'`` conversion code corresponds to the :c:type:`_Bool` type defined by
    C99. If this type is not available, it is simulated using a :c:type:`char`. In
    standard mode, it is always represented by one byte.
 
-(3)
+(2)
    The ``'q'`` and ``'Q'`` conversion codes are available in native mode only if
    the platform C compiler supports C :c:type:`long long`, or, on Windows,
    :c:type:`__int64`.  They are always available in standard modes.
 
-(4)
+(3)
    When attempting to pack a non-integer using any of the integer conversion
    codes, if the non-integer has a :meth:`__index__` method then that method is
    called to convert the argument to an integer before packing.
@@ -223,12 +218,12 @@
    .. versionchanged:: 3.2
       Use of the :meth:`__index__` method for non-integers is new in 3.2.
 
-(5)
+(4)
    For the ``'f'`` and ``'d'`` conversion codes, the packed representation uses
    the IEEE 754 binary32 (for ``'f'``) or binary64 (for ``'d'``) format,
    regardless of the floating-point format used by the platform.
 
-(6)
+(5)
    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
@@ -310,9 +305,9 @@
 The ordering of format characters may have an impact on size since the padding
 needed to satisfy alignment requirements is different::
 
-    >>> pack('ci', '*', 0x12131415)
+    >>> pack('ci', b'*', 0x12131415)
     b'*\x00\x00\x00\x12\x13\x14\x15'
-    >>> pack('ic', 0x12131415, '*')
+    >>> pack('ic', 0x12131415, b'*')
     b'\x12\x13\x14\x15*'
     >>> calcsize('ci')
     8

Modified: python/branches/py3k-cdecimal/Doc/library/subprocess.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/subprocess.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/subprocess.rst	Sun Jan  2 13:18:37 2011
@@ -28,7 +28,7 @@
 This module defines one class called :class:`Popen`:
 
 
-.. class:: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False)
+.. class:: Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=())
 
    Arguments are:
 
@@ -153,12 +153,22 @@
 
    If *close_fds* is true, all file descriptors except :const:`0`, :const:`1` and
    :const:`2` will be closed before the child process is executed. (Unix only).
-   Or, on Windows, if *close_fds* is true then no handles will be inherited by the
+   The default varies by platform:  Always true on Unix.  On Windows it is
+   true when *stdin*/*stdout*/*stderr* are :const:`None`, false otherwise.
+   On Windows, if *close_fds* is true then no handles will be inherited by the
    child process.  Note that on Windows, you cannot set *close_fds* to true and
    also redirect the standard handles by setting *stdin*, *stdout* or *stderr*.
 
-   If *shell* is :const:`True`, the specified command will be executed through the
-   shell.
+   .. versionchanged:: 3.2
+      The default for *close_fds* was changed from :const:`False` to
+      what is described above.
+
+   *pass_fds* is an optional sequence of file descriptors to keep open
+   between the parent and child.  Providing any *pass_fds* forces
+   *close_fds* to be :const:`True`.  (Unix only)
+
+   .. versionadded:: 3.2
+      The *pass_fds* parameter was added.
 
    If *cwd* is not ``None``, the child's current directory will be changed to *cwd*
    before it is executed.  Note that this directory is not considered when
@@ -208,6 +218,16 @@
    underlying CreateProcess() function.  They can specify things such as appearance
    of the main window and priority for the new process.  (Windows only)
 
+   Popen objects are supported as context managers via the :keyword:`with` statement,
+   closing any open file descriptors on exit.
+   ::
+
+      with Popen(["ifconfig"], stdout=PIPE) as proc:
+          log.write(proc.stdout.read())
+
+   .. versionchanged:: 3.2
+      Added context manager support.
+
 
 .. data:: PIPE
 
@@ -639,4 +659,5 @@
 * ``stdin=PIPE`` and ``stdout=PIPE`` must be specified.
 
 * popen2 closes all file descriptors by default, but you have to specify
-  ``close_fds=True`` with :class:`Popen`.
+  ``close_fds=True`` with :class:`Popen` to guarantee this behavior on
+  all platforms or past Python versions.

Modified: python/branches/py3k-cdecimal/Doc/library/sys.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/sys.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/sys.rst	Sun Jan  2 13:18:37 2011
@@ -99,13 +99,39 @@
 
 .. function:: displayhook(value)
 
-   If *value* is not ``None``, this function prints it to ``sys.stdout``, and saves
-   it in ``builtins._``.
+   If *value* is not ``None``, this function prints ``repr(value)`` to
+   ``sys.stdout``, and saves *value* in ``builtins._``. If ``repr(value)`` is
+   not encodable to ``sys.stdout.encoding`` with ``sys.stdout.errors`` error
+   handler (which is probably ``'strict'``), encode it to
+   ``sys.stdout.encoding`` with ``'backslashreplace'`` error handler.
 
    ``sys.displayhook`` is called on the result of evaluating an :term:`expression`
    entered in an interactive Python session.  The display of these values can be
    customized by assigning another one-argument function to ``sys.displayhook``.
 
+   Pseudo-code::
+
+       def displayhook(value):
+           if value is None:
+               return
+           # Set '_' to None to avoid recursion
+           builtins._ = None
+           text = repr(value)
+           try:
+               sys.stdout.write(text)
+           except UnicodeEncodeError:
+               bytes = text.encode(sys.stdout.encoding, 'backslashreplace')
+               if hasattr(sys.stdout, 'buffer'):
+                   sys.stdout.buffer.write(bytes)
+               else:
+                   text = bytes.decode(sys.stdout.encoding, 'strict')
+                   sys.stdout.write(text)
+           sys.stdout.write("\n")
+           builtins._ = value
+
+   .. versionchanged:: 3.2
+      Use ``'backslashreplace'`` error handler on :exc:`UnicodeEncodeError`.
+
 
 .. function:: excepthook(type, value, traceback)
 
@@ -238,6 +264,11 @@
    +------------------------------+------------------------------------------+
    | :const:`bytes_warning`       | -b                                       |
    +------------------------------+------------------------------------------+
+   | :const:`quiet`               | -q                                       |
+   +------------------------------+------------------------------------------+
+
+   .. versionchanged:: 3.2
+      Added ``quiet`` attribute for the new :option:`-q` flag.
 
 
 .. data:: float_info
@@ -389,6 +420,9 @@
    additional garbage collector overhead if the object is managed by the garbage
    collector.
 
+   See `recursive sizeof recipe <http://code.activestate.com/recipes/577504>`_
+   for an example of using :func:`getsizeof` recursively to find the size of
+   containers and all their contents.
 
 .. function:: getswitchinterval()
 

Modified: python/branches/py3k-cdecimal/Doc/library/test.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/test.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/test.rst	Sun Jan  2 13:18:37 2011
@@ -6,11 +6,11 @@
 .. sectionauthor:: Brett Cannon <brett at python.org>
 
 .. note::
-    The :mod:`test` package is meant for internal use by Python only. It is
-    documented for the benefit of the core developers of Python. Any use of
-    this package outside of Python's standard library is discouraged as code
-    mentioned here can change or be removed without notice between releases of
-    Python.
+   The :mod:`test` package is meant for internal use by Python only. It is
+   documented for the benefit of the core developers of Python. Any use of
+   this package outside of Python's standard library is discouraged as code
+   mentioned here can change or be removed without notice between releases of
+   Python.
 
 
 The :mod:`test` package contains all regression tests for Python as well as the
@@ -154,28 +154,31 @@
 
 .. _regrtest:
 
-Running tests using :mod:`test.regrtest`
-----------------------------------------
+Running tests using the command-line interface
+----------------------------------------------
 
-:mod:`test.regrtest` can be used as a script to drive Python's regression test
-suite. Running the script by itself automatically starts running all regression
+The :mod:`test` package can be run as a script to drive Python's regression
+test suite, thanks to the :option:`-m` option: :program:`python -m test`. Under
+the hood, it uses :mod:`test.regrtest`; the call :program:`python -m
+test.regrtest` used in previous Python versions still works).
+Running the script by itself automatically starts running all regression
 tests in the :mod:`test` package. It does this by finding all modules in the
 package whose name starts with ``test_``, importing them, and executing the
 function :func:`test_main` if present. The names of tests to execute may also
 be passed to the script. Specifying a single regression test (:program:`python
-regrtest.py test_spam.py`) will minimize output and only print
+-m test test_spam`) will minimize output and only print
 whether the test passed or failed and thus minimize output.
 
-Running :mod:`test.regrtest` directly allows what resources are available for
+Running :mod:`test` directly allows what resources are available for
 tests to use to be set. You do this by using the ``-u`` command-line
-option. Run :program:`python regrtest.py -uall` to turn on all
+option. Run :program:`python -m test -uall` to turn on all
 resources; specifying ``all`` as an option for ``-u`` enables all
 possible resources. If all but one resource is desired (a more common case), a
 comma-separated list of resources that are not desired may be listed after
-``all``. The command :program:`python regrtest.py -uall,-audio,-largefile`
-will run :mod:`test.regrtest` with all resources except the ``audio`` and
+``all``. The command :program:`python -m test -uall,-audio,-largefile`
+will run :mod:`test` with all resources except the ``audio`` and
 ``largefile`` resources. For a list of all resources and more command-line
-options, run :program:`python regrtest.py -h`.
+options, run :program:`python -m test -h`.
 
 Some other ways to execute the regression tests depend on what platform the
 tests are being executed on. On Unix, you can run :program:`make test` at the

Modified: python/branches/py3k-cdecimal/Doc/library/textwrap.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/textwrap.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/textwrap.rst	Sun Jan  2 13:18:37 2011
@@ -121,6 +121,13 @@
          each tab character will be replaced by a single space, which is *not*
          the same as tab expansion.
 
+      .. note::
+
+         If :attr:`replace_whitespace` is false, newlines may appear in the
+         middle of a line and cause strange output. For this reason, text should
+         be split into paragraphs (using :meth:`str.splitlines` or similar)
+         which are wrapped separately.
+
 
    .. attribute:: drop_whitespace
 

Modified: python/branches/py3k-cdecimal/Doc/library/threading.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/threading.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/threading.rst	Sun Jan  2 13:18:37 2011
@@ -1,8 +1,8 @@
-:mod:`threading` --- Higher-level threading interface
-=====================================================
+:mod:`threading` --- Thread-based parallelism
+=============================================
 
 .. module:: threading
-   :synopsis: Higher-level threading interface.
+   :synopsis: Thread-based parallelism.
 
 
 This module constructs higher-level threading interfaces on top of the lower
@@ -408,6 +408,9 @@
    .. versionchanged:: 3.2
       The *timeout* parameter is new.
 
+   .. versionchanged:: 3.2
+      Lock acquires can now be interrupted by signals on POSIX.
+
 
 .. method:: Lock.release()
 

Modified: python/branches/py3k-cdecimal/Doc/library/tkinter.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/tkinter.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/tkinter.rst	Sun Jan  2 13:18:37 2011
@@ -659,9 +659,7 @@
 
 scrollcommand
    This is almost always the :meth:`!set` method of some scrollbar widget, but can
-   be any widget method that takes a single argument.   Refer to the file
-   :file:`Demo/tkinter/matt/canvas-with-scrollbars.py` in the Python source
-   distribution for an example.
+   be any widget method that takes a single argument.
 
 wrap:
    Must be one of: ``"none"``, ``"char"``, or ``"word"``.

Modified: python/branches/py3k-cdecimal/Doc/library/tkinter.tix.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/tkinter.tix.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/tkinter.tix.rst	Sun Jan  2 13:18:37 2011
@@ -84,11 +84,7 @@
 -----------
 
 `Tix <http://tix.sourceforge.net/dist/current/man/html/TixCmd/TixIntro.htm>`_
-introduces over 40 widget classes to the :mod:`tkinter` repertoire.  There is a
-demo of all the :mod:`tkinter.tix` widgets in the :file:`Demo/tix` directory of
-the standard distribution.
-
-.. The Python sample code is still being added to Python, hence commented out
+introduces over 40 widget classes to the :mod:`tkinter` repertoire.
 
 
 Basic Widgets

Modified: python/branches/py3k-cdecimal/Doc/library/trace.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/trace.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/trace.rst	Sun Jan  2 13:18:37 2011
@@ -17,103 +17,178 @@
 
 .. _trace-cli:
 
-Command Line Usage
+Command-Line Usage
 ------------------
 
 The :mod:`trace` module can be invoked from the command line.  It can be as
 simple as ::
 
-   python -m trace --count somefile.py ...
+   python -m trace --count -C . somefile.py ...
 
-The above will generate annotated listings of all Python modules imported during
-the execution of :file:`somefile.py`.
+The above will execute :file:`somefile.py` and generate annotated listings of
+all Python modules imported during the execution into the current directory.
 
-The following command-line arguments are supported:
+.. program:: trace
+
+.. cmdoption:: --help
+
+   Display usage and exit.
+
+.. cmdoption:: --version
+
+   Display the version of the module and exit.
+
+Main options
+^^^^^^^^^^^^
+
+At least one of the following options must be specified when invoking
+:mod:`trace`.  The :option:`--listfuncs <-l>` option is mutually exclusive with
+the :option:`--trace <-t>` and :option:`--counts <-c>` options . When
+:option:`--listfuncs <-l>` is provided, neither :option:`--counts <-c>` nor
+:option:`--trace <-t>` are accepted, and vice versa.
+
+.. program:: trace
+
+.. cmdoption:: -c, --count
+
+   Produce a set of annotated listing files upon program completion that shows
+   how many times each statement was executed.  See also
+   :option:`--coverdir <-C>`, :option:`--file <-f>` and
+   :option:`--no-report <-R>` below.
+
+.. cmdoption:: -t, --trace
 
-:option:`--trace`, :option:`-t`
    Display lines as they are executed.
 
-:option:`--count`, :option:`-c`
-   Produce a set of  annotated listing files upon program completion that shows how
-   many times each statement was executed.
+.. cmdoption:: -l, --listfuncs
+
+   Display the functions executed by running the program.
+
+.. cmdoption:: -r, --report
 
-:option:`--report`, :option:`-r`
    Produce an annotated list from an earlier program run that used the
-   :option:`--count` and :option:`--file` arguments.
+   :option:`--count <-c>` and :option:`--file <-f>` option.  This does not
+   execute any code.
 
-:option:`--no-report`, :option:`-R`
-   Do not generate annotated listings.  This is useful if you intend to make
-   several runs with :option:`--count` then produce a single set of annotated
-   listings at the end.
+.. cmdoption:: -T, --trackcalls
+
+   Display the calling relationships exposed by running the program.
+
+Modifiers
+^^^^^^^^^
+
+.. program:: trace
+
+.. cmdoption:: -f, --file=<file>
 
-:option:`--listfuncs`, :option:`-l`
-   List the functions executed by running the program.
+   Name of a file to accumulate counts over several tracing runs.  Should be
+   used with the :option:`--count <-c>` option.
 
-:option:`--trackcalls`, :option:`-T`
-   Generate calling relationships exposed by running the program.
+.. cmdoption:: -C, --coverdir=<dir>
 
-:option:`--file`, :option:`-f`
-   Name a file containing (or to contain) counts.
+   Directory where the report files go.  The coverage report for
+   ``package.module`` is written to file :file:`{dir}/{package}/{module}.cover`.
 
-:option:`--coverdir`, :option:`-C`
-   Name a directory in which to save annotated listing files.
+.. cmdoption:: -m, --missing
 
-:option:`--missing`, :option:`-m`
    When generating annotated listings, mark lines which were not executed with
-   '``>>>>>>``'.
+   ``>>>>>>``.
 
-:option:`--summary`, :option:`-s`
-   When using :option:`--count` or :option:`--report`, write a brief summary to
-   stdout for each file processed.
-
-:option:`--ignore-module`
-   Accepts comma separated list of module names. Ignore each of the named
-   module and its submodules (if it is a package).  May be given
-   multiple times.
-
-:option:`--ignore-dir`
-   Ignore all modules and packages in the named directory and subdirectories
-   (multiple directories can be joined by os.pathsep).  May be given multiple
-   times.
+.. cmdoption:: -s, --summary
 
+   When using :option:`--count <-c>` or :option:`--report <-r>`, write a brief
+   summary to stdout for each file processed.
+
+.. cmdoption:: -R, --no-report
+
+   Do not generate annotated listings.  This is useful if you intend to make
+   several runs with :option:`--count <-c>`, and then produce a single set of
+   annotated listings at the end.
+
+.. cmdoption:: -g, --timing
+
+   Prefix each line with the time since the program started.  Only used while
+   tracing.
+
+Filters
+^^^^^^^
+
+These options may be repeated multiple times.
+
+.. program:: trace
+
+.. cmdoption:: --ignore-module=<mod>
+
+   Ignore each of the given module names and its submodules (if it is a
+   package).  The argument can be a list of names separated by a comma.
+
+.. cmdoption:: --ignore-dir=<dir>
+
+   Ignore all modules and packages in the named directory and subdirectories.
+   The argument can be a list of directories separated by :data:`os.pathsep`.
 
 .. _trace-api:
 
-Programming Interface
----------------------
+Programmatic Interface
+----------------------
+
+.. class:: Trace(count=1, trace=1, countfuncs=0, countcallers=0, ignoremods=(),\
+                 ignoredirs=(), infile=None, outfile=None, timing=False)
+
+   Create an object to trace execution of a single statement or expression.  All
+   parameters are optional.  *count* enables counting of line numbers.  *trace*
+   enables line execution tracing.  *countfuncs* enables listing of the
+   functions called during the run.  *countcallers* enables call relationship
+   tracking.  *ignoremods* is a list of modules or packages to ignore.
+   *ignoredirs* is a list of directories whose modules or packages should be
+   ignored.  *infile* is the name of the file from which to read stored count
+   information.  *outfile* is the name of the file in which to write updated
+   count information.  *timing* enables a timestamp relative to when tracing was
+   started to be displayed.
+
+    .. method:: run(cmd)
+
+       Execute the command and gather statistics from the execution with
+       the current tracing parameters.  *cmd* must be a string or code object,
+       suitable for passing into :func:`exec`.
 
+    .. method:: runctx(cmd, globals=None, locals=None)
 
-.. class:: Trace(count=1, trace=1, countfuncs=0, countcallers=0, ignoremods=(), ignoredirs=(), infile=None, outfile=None, timing=False)
+       Execute the command and gather statistics from the execution with the
+       current tracing parameters, in the defined global and local
+       environments.  If not defined, *globals* and *locals* default to empty
+       dictionaries.
 
-   Create an object to trace execution of a single statement or expression. All
-   parameters are optional.  *count* enables counting of line numbers. *trace*
-   enables line execution tracing.  *countfuncs* enables listing of the functions
-   called during the run.  *countcallers* enables call relationship tracking.
-   *ignoremods* is a list of modules or packages to ignore.  *ignoredirs* is a list
-   of directories whose modules or packages should be ignored.  *infile* is the
-   file from which to read stored count information.  *outfile* is a file in which
-   to write updated count information. *timing* enables a timestamp relative
-   to when tracing was started to be displayed.
+    .. method:: runfunc(func, *args, **kwds)
 
+       Call *func* with the given arguments under control of the :class:`Trace`
+       object with the current tracing parameters.
 
-.. method:: Trace.run(cmd)
+    .. method:: results()
 
-   Run *cmd* under control of the Trace object with the current tracing parameters.
+       Return a :class:`CoverageResults` object that contains the cumulative
+       results of all previous calls to ``run``, ``runctx`` and ``runfunc``
+       for the given :class:`Trace` instance.  Does not reset the accumulated
+       trace results.
 
+.. class:: CoverageResults
 
-.. method:: Trace.runctx(cmd, globals=None, locals=None)
+   A container for coverage results, created by :meth:`Trace.results`.  Should
+   not be created directly by the user.
 
-   Run *cmd* under control of the Trace object with the current tracing parameters
-   in the defined global and local environments.  If not defined, *globals* and
-   *locals* default to empty dictionaries.
+    .. method:: update(other)
 
+       Merge in data from another :class:`CoverageResults` object.
 
-.. method:: Trace.runfunc(func, *args, **kwds)
+    .. method:: write_results(show_missing=True, summary=False, coverdir=None)
 
-   Call *func* with the given arguments under control of the :class:`Trace` object
-   with the current tracing parameters.
+       Write coverage results.  Set *show_missing* to show lines that had no
+       hits.  Set *summary* to include in the output the coverage summary per
+       module.  *coverdir* specifies the directory into which the coverage
+       result files will be output.  If ``None``, the results for each source
+       file are placed in its directory.
 
-This is a simple example showing the use of this module::
+A simple example demonstrating the use of the programmatic interface::
 
    import sys
    import trace

Modified: python/branches/py3k-cdecimal/Doc/library/turtle.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/turtle.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/turtle.rst	Sun Jan  2 13:18:37 2011
@@ -2268,7 +2268,7 @@
 stored and an additional one in the current working directory.  The latter will
 override the settings of the first one.
 
-The :file:`Demo/turtle` directory contains a :file:`turtle.cfg` file.  You can
+The :file:`Lib/turtledemo` directory contains a :file:`turtle.cfg` file.  You can
 study it as an example and see its effects when running the demos (preferably
 not from within the demo-viewer).
 
@@ -2400,8 +2400,7 @@
   strings and numbers respectively.
 
 - Two example scripts :file:`tdemo_nim.py` and :file:`tdemo_round_dance.py`
-  have been added to the Demo directory (source distribution only). As usual
-  they can be viewed and executed within the demo viewer :file:`turtleDemo.py`.
+  have been added to the :file:`Lib/turtledemo` directory.
 
 
 .. doctest::

Modified: python/branches/py3k-cdecimal/Doc/library/unicodedata.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/unicodedata.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/unicodedata.rst	Sun Jan  2 13:18:37 2011
@@ -13,14 +13,15 @@
    single: character
    pair: Unicode; database
 
-This module provides access to the Unicode Character Database which defines
-character properties for all Unicode characters. The data in this database is
-based on the :file:`UnicodeData.txt` file version 5.2.0 which is publicly
-available from ftp://ftp.unicode.org/.
-
-The module uses the same names and symbols as defined by the UnicodeData File
-Format 5.2.0 (see http://www.unicode.org/reports/tr44/tr44-4.html).
-It defines the following functions:
+This module provides access to the Unicode Character Database (UCD) which
+defines character properties for all Unicode characters. The data contained in
+this database is compiled from the `UCD version 6.0.0
+<http://www.unicode.org/Public/6.0.0/ucd>`_.
+
+The module uses the same names and symbols as defined by Unicode
+Standard Annex #44, `"Unicode Character Database"
+<http://www.unicode.org/reports/tr44/tr44-6.html>`_.  It defines the
+following functions:
 
 
 .. function:: lookup(name)

Modified: python/branches/py3k-cdecimal/Doc/library/unittest.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/unittest.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/unittest.rst	Sun Jan  2 13:18:37 2011
@@ -191,7 +191,7 @@
 
 .. _unittest-command-line-interface:
 
-Command Line Interface
+Command-Line Interface
 ----------------------
 
 The unittest module can be used from the command line to run tests from
@@ -204,6 +204,16 @@
 You can pass in a list with any combination of module names, and fully
 qualified class or method names.
 
+Test modules can be specified by file path as well::
+
+   python -m unittest tests/test_something.py
+
+This allows you to use the shell filename completion to specify the test module.
+The file specified must still be importable as a module. The path is converted
+to a module name by removing the '.py' and converting path separators into '.'.
+If you want to execute a test file that isn't importable as a module you should
+execute the file directly instead.
+
 You can run tests with more detail (higher verbosity) by passing in the -v flag::
 
    python -m unittest -v test_module
@@ -221,8 +231,8 @@
    not modules or classes.
 
 
-failfast, catch and buffer command-line options
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Command-line options
+~~~~~~~~~~~~~~~~~~~~
 
 :program:`unittest` supports these command-line options:
 
@@ -247,7 +257,7 @@
    Stop the test run on the first error or failure.
 
 .. versionadded:: 3.2
-   The command-line options :option:`-c`, :option:`-b` and :option:`-f` were added.
+   The command-line options ``-b``, ``-c`` and ``-f`` were added.
 
 The command line can also be used for test discovery, for running all of the
 tests in a project or just a subset.
@@ -834,16 +844,16 @@
    +-----------------------------------------+-----------------------------+---------------+
 
    All the assert methods (except :meth:`assertRaises`,
-   :meth:`assertRaisesRegexp`, :meth:`assertWarns`, :meth:`assertWarnsRegexp`)
+   :meth:`assertRaisesRegex`, :meth:`assertWarns`, :meth:`assertWarnsRegex`)
    accept a *msg* argument that, if specified, is used as the error message on
    failure (see also :data:`longMessage`).
 
-   .. method:: assertEqual(first, second, msg=None)
+   .. method:: assertEqual(actual, expected, msg=None)
 
-      Test that *first* and *second* are equal.  If the values do not compare
-      equal, the test will fail.
+      Test that *actual* and *expected* are equal.  If the values do not
+      compare equal, the test will fail.
 
-      In addition, if *first* and *second* are the exact same type and one of
+      In addition, if *actual* and *expected* are the exact same type and one of
       list, tuple, dict, set, frozenset or str or any type that a subclass
       registers with :meth:`addTypeEqualityFunc` the type specific equality
       function will be called in order to generate a more useful default
@@ -858,10 +868,10 @@
          function for comparing strings.
 
 
-   .. method:: assertNotEqual(first, second, msg=None)
+   .. method:: assertNotEqual(actual, expected, msg=None)
 
-      Test that *first* and *second* are not equal.  If the values do compare
-      equal, the test will fail.
+      Test that *actual* and *expected* are not equal.  If the values do
+      compare equal, the test will fail.
 
    .. method:: assertTrue(expr, msg=None)
                assertFalse(expr, msg=None)
@@ -875,10 +885,11 @@
       provide a better error message in case of failure.
 
 
-   .. method:: assertIs(first, second, msg=None)
-               assertIsNot(first, second, msg=None)
+   .. method:: assertIs(actual, expected, msg=None)
+               assertIsNot(actual, expected, msg=None)
 
-      Test that *first* and *second* evaluate (or don't evaluate) to the same object.
+      Test that *actual* and *expected* evaluate (or don't evaluate) to the
+      same object.
 
       .. versionadded:: 3.1
 
@@ -918,14 +929,14 @@
    | :meth:`assertRaises(exc, fun, *args, **kwds)            | ``fun(*args, **kwds)`` raises `exc`  |            |
    | <TestCase.assertRaises>`                                |                                      |            |
    +---------------------------------------------------------+--------------------------------------+------------+
-   | :meth:`assertRaisesRegexp(exc, re, fun, *args, **kwds)  | ``fun(*args, **kwds)`` raises `exc`  | 3.1        |
-   | <TestCase.assertRaisesRegexp>`                          | and the message matches `re`         |            |
+   | :meth:`assertRaisesRegex(exc, re, fun, *args, **kwds)   | ``fun(*args, **kwds)`` raises `exc`  | 3.1        |
+   | <TestCase.assertRaisesRegex>`                           | and the message matches `re`         |            |
    +---------------------------------------------------------+--------------------------------------+------------+
    | :meth:`assertWarns(warn, fun, *args, **kwds)            | ``fun(*args, **kwds)`` raises `warn` | 3.2        |
    | <TestCase.assertWarns>`                                 |                                      |            |
    +---------------------------------------------------------+--------------------------------------+------------+
-   | :meth:`assertWarnsRegexp(warn, re, fun, *args, **kwds)  | ``fun(*args, **kwds)`` raises `warn` | 3.2        |
-   | <TestCase.assertWarnsRegexp>`                           | and the message matches `re`         |            |
+   | :meth:`assertWarnsRegex(warn, re, fun, *args, **kwds)   | ``fun(*args, **kwds)`` raises `warn` | 3.2        |
+   | <TestCase.assertWarnsRegex>`                            | and the message matches `re`         |            |
    +---------------------------------------------------------+--------------------------------------+------------+
 
    .. method:: assertRaises(exception, callable, *args, **kwds)
@@ -961,23 +972,26 @@
          Added the :attr:`exception` attribute.
 
 
-   .. method:: assertRaisesRegexp(exception, regexp, callable, *args, **kwds)
-               assertRaisesRegexp(exception, regexp)
+   .. method:: assertRaisesRegex(exception, regex, callable, *args, **kwds)
+               assertRaisesRegex(exception, regex)
 
-      Like :meth:`assertRaises` but also tests that *regexp* matches
-      on the string representation of the raised exception.  *regexp* may be
+      Like :meth:`assertRaises` but also tests that *regex* matches
+      on the string representation of the raised exception.  *regex* may be
       a regular expression object or a string containing a regular expression
       suitable for use by :func:`re.search`.  Examples::
 
-         self.assertRaisesRegexp(ValueError, 'invalid literal for.*XYZ$',
-                                 int, 'XYZ')
+         self.assertRaisesRegex(ValueError, 'invalid literal for.*XYZ$',
+                                int, 'XYZ')
 
       or::
 
-         with self.assertRaisesRegexp(ValueError, 'literal'):
+         with self.assertRaisesRegex(ValueError, 'literal'):
             int('XYZ')
 
       .. versionadded:: 3.1
+         under the name ``assertRaisesRegexp``.
+      .. versionchanged:: 3.2
+         Renamed to :meth:`assertRaisesRegex`.
 
 
    .. method:: assertWarns(warning, callable, *args, **kwds)
@@ -1014,21 +1028,21 @@
       .. versionadded:: 3.2
 
 
-   .. method:: assertWarnsRegexp(warning, regexp, callable, *args, **kwds)
-               assertWarnsRegexp(warning, regexp)
+   .. method:: assertWarnsRegex(warning, regex, callable, *args, **kwds)
+               assertWarnsRegex(warning, regex)
 
-      Like :meth:`assertWarns` but also tests that *regexp* matches on the
-      message of the triggered warning.  *regexp* may be a regular expression
+      Like :meth:`assertWarns` but also tests that *regex* matches on the
+      message of the triggered warning.  *regex* may be a regular expression
       object or a string containing a regular expression suitable for use
       by :func:`re.search`.  Example::
 
-         self.assertWarnsRegexp(DeprecationWarning,
-                                r'legacy_function\(\) is deprecated',
-                                legacy_function, 'XYZ')
+         self.assertWarnsRegex(DeprecationWarning,
+                               r'legacy_function\(\) is deprecated',
+                               legacy_function, 'XYZ')
 
       or::
 
-         with self.assertWarnsRegexp(RuntimeWarning, 'unsafe frobnicating'):
+         with self.assertWarnsRegex(RuntimeWarning, 'unsafe frobnicating'):
              frobnicate('/etc/passwd')
 
       .. versionadded:: 3.2
@@ -1058,47 +1072,44 @@
    | :meth:`assertLessEqual(a, b)          | ``a <= b``                     | 3.1          |
    | <TestCase.assertLessEqual>`           |                                |              |
    +---------------------------------------+--------------------------------+--------------+
-   | :meth:`assertRegexpMatches(s, re)     | ``regex.search(s)``            | 3.1          |
-   | <TestCase.assertRegexpMatches>`       |                                |              |
+   | :meth:`assertRegex(s, re)             | ``regex.search(s)``            | 3.1          |
+   | <TestCase.assertRegex>`               |                                |              |
    +---------------------------------------+--------------------------------+--------------+
-   | :meth:`assertNotRegexpMatches(s, re)  | ``not regex.search(s)``        | 3.2          |
-   | <TestCase.assertNotRegexpMatches>`    |                                |              |
+   | :meth:`assertNotRegex(s, re)          | ``not regex.search(s)``        | 3.2          |
+   | <TestCase.assertNotRegex>`            |                                |              |
    +---------------------------------------+--------------------------------+--------------+
-   | :meth:`assertDictContainsSubset(a, b) | all the key/value pairs        | 3.1          |
-   | <TestCase.assertDictContainsSubset>`  | in `a` exist in `b`            |              |
-   +---------------------------------------+--------------------------------+--------------+
-   | :meth:`assertItemsEqual(a, b)         | `a` and `b` have the same      | 3.2          |
-   | <TestCase.assertItemsEqual>`          | elements in the same number,   |              |
+   | :meth:`assertCountEqual(a, b)         | `a` and `b` have the same      | 3.2          |
+   | <TestCase.assertCountEqual>`          | elements in the same number,   |              |
    |                                       | regardless of their order      |              |
    +---------------------------------------+--------------------------------+--------------+
 
 
-   .. method:: assertAlmostEqual(first, second, places=7, msg=None, delta=None)
-               assertNotAlmostEqual(first, second, places=7, msg=None, delta=None)
+   .. method:: assertAlmostEqual(actual, expected, places=7, msg=None, delta=None)
+               assertNotAlmostEqual(actual, expected, places=7, msg=None, delta=None)
 
-      Test that *first* and *second* are approximately (or not approximately)
+      Test that *actual* and *expected* are approximately (or not approximately)
       equal by computing the difference, rounding to the given number of
       decimal *places* (default 7), and comparing to zero.  Note that these
       methods round the values to the given number of *decimal places* (i.e.
       like the :func:`round` function) and not *significant digits*.
 
       If *delta* is supplied instead of *places* then the difference
-      between *first* and *second* must be less (or more) than *delta*.
+      between *actual* and *expected* must be less (or more) than *delta*.
 
       Supplying both *delta* and *places* raises a ``TypeError``.
 
       .. versionchanged:: 3.2
-         assertAlmostEqual automatically considers almost equal objects that compare equal.
-         assertNotAlmostEqual automatically fails if the objects compare equal.
-         Added the ``delta`` keyword argument.
+         :meth:`assertAlmostEqual` automatically considers almost equal objects
+         that compare equal.  :meth:`assertNotAlmostEqual` automatically fails
+         if the objects compare equal.  Added the *delta* keyword argument.
 
 
-   .. method:: assertGreater(first, second, msg=None)
-               assertGreaterEqual(first, second, msg=None)
-               assertLess(first, second, msg=None)
-               assertLessEqual(first, second, msg=None)
+   .. method:: assertGreater(actual, expected, msg=None)
+               assertGreaterEqual(actual, expected, msg=None)
+               assertLess(actual, expected, msg=None)
+               assertLessEqual(actual, expected, msg=None)
 
-      Test that *first* is respectively >, >=, < or <= than *second* depending
+      Test that *actual* is respectively >, >=, < or <= than *expected* depending
       on the method name.  If not, the test will fail::
 
          >>> self.assertGreaterEqual(3, 4)
@@ -1107,54 +1118,64 @@
       .. versionadded:: 3.1
 
 
-   .. method:: assertRegexpMatches(text, regexp, msg=None)
-               assertNotRegexpMatches(text, regexp, msg=None)
+   .. method:: assertRegex(text, regex, msg=None)
+               assertNotRegex(text, regex, msg=None)
 
-      Test that a *regexp* search matches (or does not match) *text*.  In case
+      Test that a *regex* search matches (or does not match) *text*.  In case
       of failure, the error message will include the pattern and the *text* (or
-      the pattern and the part of *text* that unexpectedly matched).  *regexp*
+      the pattern and the part of *text* that unexpectedly matched).  *regex*
       may be a regular expression object or a string containing a regular
       expression suitable for use by :func:`re.search`.
 
-      .. versionadded:: 3.1 :meth:`~TestCase.assertRegexpMatches`
-      .. versionadded:: 3.2 :meth:`~TestCase.assertNotRegexpMatches`
+      .. versionadded:: 3.1
+         under the name ``assertRegexpMatches``.
+      .. versionchanged:: 3.2
+         The method ``assertRegexpMatches()`` has been renamed to
+         :meth:`.assertRegex`.
+      .. versionadded:: 3.2
+         :meth:`.assertNotRegex`.
 
 
-   .. method:: assertDictContainsSubset(expected, actual, msg=None)
+   .. method:: assertDictContainsSubset(subset, dictionary, msg=None)
 
-      Tests whether the key/value pairs in dictionary *actual* are a
-      superset of those in *expected*.  If not, an error message listing
-      the missing keys and mismatched values is generated.
+      Tests whether the key/value pairs in *dictionary* are a superset of
+      those in *subset*.  If not, an error message listing the missing keys
+      and mismatched values is generated.
+
+      Note, the arguments are in the opposite order of what the method name
+      dictates.  Instead, consider using the set-methods on :ref:`dictionary
+      views <dict-views>`, for example: ``d.keys() <= e.keys()`` or
+      ``d.items() <= d.items()``.
 
       .. versionadded:: 3.1
+      .. deprecated:: 3.2
 
 
-   .. method:: assertItemsEqual(actual, expected, msg=None)
+   .. method:: assertCountEqual(first, second, msg=None)
 
-      Test that sequence *expected* contains the same elements as *actual*,
+      Test that sequence *first* contains the same elements as *second*,
       regardless of their order. When they don't, an error message listing the
       differences between the sequences will be generated.
 
-      Duplicate elements are *not* ignored when comparing *actual* and
-      *expected*. It verifies if each element has the same count in both
-      sequences. It is the equivalent of ``assertEqual(sorted(expected),
-      sorted(actual))`` but it works with sequences of unhashable objects as
-      well.
+      Duplicate elements are *not* ignored when comparing *first* and
+      *second*. It verifies whether each element has the same count in both
+      sequences. Equivalent to:
+      ``assertEqual(Counter(list(first)), Counter(list(second)))``
+      but works with sequences of unhashable objects as well.
 
       .. versionadded:: 3.2
 
-
    .. method:: assertSameElements(actual, expected, msg=None)
 
-      Test that sequence *expected* contains the same elements as *actual*,
+      Test that sequence *actual* contains the same elements as *expected*,
       regardless of their order. When they don't, an error message listing
       the differences between the sequences will be generated.
 
       Duplicate elements are ignored when comparing *actual* and *expected*.
-      It is the equivalent of ``assertEqual(set(expected), set(actual))``
+      It is the equivalent of ``assertEqual(set(actual), set(expected))``
       but it works with sequences of unhashable objects as well. Because
       duplicates are ignored, this method has been deprecated in favour of
-      :meth:`assertItemsEqual`.
+      :meth:`assertCountEqual`.
 
       .. versionadded:: 3.1
       .. deprecated:: 3.2
@@ -1208,9 +1229,9 @@
 
 
 
-   .. method:: assertMultiLineEqual(first, second, msg=None)
+   .. method:: assertMultiLineEqual(actual, expected, msg=None)
 
-      Test that the multiline string *first* is equal to the string *second*.
+      Test that the multiline string *actual* is equal to the string *expected*.
       When not equal a diff of the two strings highlighting the differences
       will be included in the error message. This method is used by default
       when comparing strings with :meth:`assertEqual`.
@@ -1218,10 +1239,10 @@
       .. versionadded:: 3.1
 
 
-   .. method:: assertSequenceEqual(seq1, seq2, msg=None, seq_type=None)
+   .. method:: assertSequenceEqual(actual, expected, msg=None, seq_type=None)
 
       Tests that two sequences are equal.  If a *seq_type* is supplied, both
-      *seq1* and *seq2* must be instances of *seq_type* or a failure will
+      *actual* and *expected* must be instances of *seq_type* or a failure will
       be raised.  If the sequences are different an error message is
       constructed that shows the difference between the two.
 
@@ -1232,8 +1253,8 @@
       .. versionadded:: 3.1
 
 
-   .. method:: assertListEqual(list1, list2, msg=None)
-               assertTupleEqual(tuple1, tuple2, msg=None)
+   .. method:: assertListEqual(actual, expected, msg=None)
+               assertTupleEqual(actual, expected, msg=None)
 
       Tests that two lists or tuples are equal.  If not an error message is
       constructed that shows only the differences between the two.  An error
@@ -1244,19 +1265,19 @@
       .. versionadded:: 3.1
 
 
-   .. method:: assertSetEqual(set1, set2, msg=None)
+   .. method:: assertSetEqual(actual, expected, msg=None)
 
       Tests that two sets are equal.  If not, an error message is constructed
       that lists the differences between the sets.  This method is used by
       default when comparing sets or frozensets with :meth:`assertEqual`.
 
-      Fails if either of *set1* or *set2* does not have a :meth:`set.difference`
+      Fails if either of *actual* or *expected* does not have a :meth:`set.difference`
       method.
 
       .. versionadded:: 3.1
 
 
-   .. method:: assertDictEqual(expected, actual, msg=None)
+   .. method:: assertDictEqual(actual, expected, msg=None)
 
       Test that two dictionaries are equal.  If not, an error message is
       constructed that shows the differences in the dictionaries. This
@@ -1297,8 +1318,8 @@
       to ``True`` allows you to have a custom error message in addition to the
       normal one.
 
-      This attribute defaults to ``False``, meaning that a custom message passed
-      to an assert method will silence the normal message.
+      This attribute defaults to ``True``. If set to False then a custom message
+      passed to an assert method will silence the normal message.
 
       The class setting can be overridden in individual tests by assigning an
       instance attribute to ``True`` or ``False`` before calling the assert methods.
@@ -1355,11 +1376,11 @@
       returns the first line of the test method's docstring, if available,
       or ``None``.
 
-      .. versionchanged:: 3.1,3.2
+      .. versionchanged:: 3.1
          In 3.1 this was changed to add the test name to the short description
-         even in the presence of a docstring. This caused compatibility issues
+         even in the presence of a docstring.  This caused compatibility issues
          with unittest extensions and adding the test name was moved to the
-         :class:`TextTestResult`.
+         :class:`TextTestResult` in Python 3.2.
 
 
    .. method:: addCleanup(function, *args, **kwargs)
@@ -1401,6 +1422,8 @@
    :mod:`unittest`-based test framework.
 
 
+.. _deprecated-aliases:
+
 Deprecated aliases
 ##################
 
@@ -1408,21 +1431,27 @@
 aliases that are now deprecated.  The following table lists the correct names
 along with their deprecated aliases:
 
-   ==============================  ===============================
-    Method Name                     Deprecated alias(es)
-   ==============================  ===============================
-    :meth:`.assertEqual`            failUnlessEqual, assertEquals
-    :meth:`.assertNotEqual`         failIfEqual
-    :meth:`.assertTrue`             failUnless, assert\_
+   ==============================  ====================== ======================
+    Method Name                     Deprecated alias       Deprecated alias
+   ==============================  ====================== ======================
+    :meth:`.assertEqual`            failUnlessEqual        assertEquals
+    :meth:`.assertNotEqual`         failIfEqual            assertNotEquals
+    :meth:`.assertTrue`             failUnless             assert\_
     :meth:`.assertFalse`            failIf
     :meth:`.assertRaises`           failUnlessRaises
-    :meth:`.assertAlmostEqual`      failUnlessAlmostEqual
-    :meth:`.assertNotAlmostEqual`   failIfAlmostEqual
-   ==============================  ===============================
-
-   .. deprecated:: 3.1
-         the aliases listed in the second column
-
+    :meth:`.assertAlmostEqual`      failUnlessAlmostEqual  assertAlmostEquals
+    :meth:`.assertNotAlmostEqual`   failIfAlmostEqual      assertNotAlmostEquals
+    :meth:`.assertRegex`                                   assertRegexpMatches
+    :meth:`.assertRaisesRegex`                             assertRaisesRegexp
+   ==============================  ====================== ======================
+
+   .. deprecated-removed:: 3.1 3.3
+         the fail* aliases listed in the second column.
+   .. deprecated:: 3.2
+         the assert* aliases listed in the third column.
+   .. deprecated:: 3.2
+         ``assertRegexpMatches`` and ``assertRaisesRegexp`` have been renamed to
+         :meth:`.assertRegex` and :meth:`.assertRaisesRegex`
 
 
 .. _testsuite-objects:
@@ -1841,12 +1870,21 @@
    instead of repeatedly creating new instances.
 
 
-.. class:: TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=1, runnerclass=None)
+.. class:: TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=1, runnerclass=None, warnings=None)
 
    A basic test runner implementation which prints results on standard error.  It
    has a few configurable parameters, but is essentially very simple.  Graphical
    applications which run test suites should provide alternate implementations.
 
+   By default this runner shows :exc:`DeprecationWarning`,
+   :exc:`PendingDeprecationWarning`, and :exc:`ImportWarning` even if they are
+   :ref:`ignored by default <warning-ignored>`. Deprecation warnings caused by
+   :ref:`deprecated unittest methods <deprecated-aliases>` are also
+   special-cased and, when the warning filters are ``'default'`` or ``'always'``,
+   they will appear only once per-module, in order to avoid too many warning
+   messages.  This behavior can be overridden using the :option:`-Wd` or
+   :option:`-Wa` options and leaving *warnings* to ``None``.
+
    .. method:: _makeResult()
 
       This method returns the instance of ``TestResult`` used by :meth:`run`.
@@ -1860,7 +1898,12 @@
 
         stream, descriptions, verbosity
 
-.. function:: main(module='__main__', defaultTest=None, argv=None, testRunner=None, testLoader=unittest.loader.defaultTestLoader, exit=True, verbosity=1, failfast=None, catchbreak=None, buffer=None)
+   .. versionchanged:: 3.2
+      Added the ``warnings`` argument.
+
+.. function:: main(module='__main__', defaultTest=None, argv=None, testRunner=None, \
+                   testLoader=unittest.loader.defaultTestLoader, exit=True, verbosity=1, \
+                   failfast=None, catchbreak=None, buffer=None, warnings=None)
 
    A command-line program that runs a set of tests; this is primarily for making
    test modules conveniently executable.  The simplest use for this function is to
@@ -1887,23 +1930,29 @@
       >>> main(module='test_module', exit=False)
 
    The ``failfast``, ``catchbreak`` and ``buffer`` parameters have the same
-   effect as the `failfast, catch and buffer command-line options`_.
+   effect as the same-name `command-line options`_.
+
+   The *warning* argument specifies the :ref:`warning filter <warning-filter>`
+   that should be used while running the tests.  If it's not specified, it will
+   remain ``None`` if a :option:`-W` option is passed to :program:`python`,
+   otherwise it will be set to ``'default'``.
 
    Calling ``main`` actually returns an instance of the ``TestProgram`` class.
    This stores the result of the tests run as the ``result`` attribute.
 
+   .. versionchanged:: 3.1
+      The ``exit`` parameter was added.
+
    .. versionchanged:: 3.2
-      The ``exit``, ``verbosity``, ``failfast``, ``catchbreak`` and ``buffer``
-      parameters were added.
+      The ``verbosity``, ``failfast``, ``catchbreak``, ``buffer``
+      and ``warnings`` parameters were added.
 
 
 load_tests Protocol
 ###################
 
-
 .. versionadded:: 3.2
 
-
 Modules or packages can customize how tests are loaded from them during normal
 test runs or test discovery by implementing a function called ``load_tests``.
 
@@ -2050,12 +2099,14 @@
 Signal Handling
 ---------------
 
-The ``-c``/``--catch`` command-line option to unittest, along with the ``catchbreak``
-parameter to :func:`unittest.main()`, provide more friendly handling of
-control-C during a test run. With catch break behavior enabled control-C will
-allow the currently running test to complete, and the test run will then end
-and report all the results so far. A second control-c will raise a
-:exc:`KeyboardInterrupt` in the usual way.
+.. versionadded:: 3.2
+
+The :option:`-c/--catch <unittest -c>` command-line option to unittest,
+along with the ``catchbreak`` parameter to :func:`unittest.main()`, provide
+more friendly handling of control-C during a test run. With catch break
+behavior enabled control-C will allow the currently running test to complete,
+and the test run will then end and report all the results so far. A second
+control-c will raise a :exc:`KeyboardInterrupt` in the usual way.
 
 The control-c handling signal handler attempts to remain compatible with code or
 tests that install their own :const:`signal.SIGINT` handler. If the ``unittest``
@@ -2075,7 +2126,6 @@
    (usually in response to the user pressing control-c) all registered results
    have :meth:`~TestResult.stop` called.
 
-   .. versionadded:: 3.2
 
 .. function:: registerResult(result)
 
@@ -2087,7 +2137,6 @@
    handling is not enabled, so test frameworks can unconditionally register
    all results they create independently of whether or not handling is enabled.
 
-   .. versionadded:: 3.2
 
 .. function:: removeResult(result)
 
@@ -2095,7 +2144,6 @@
    :meth:`~TestResult.stop` will no longer be called on that result object in
    response to a control-c.
 
-   .. versionadded:: 3.2
 
 .. function:: removeHandler(function=None)
 
@@ -2106,6 +2154,3 @@
       @unittest.removeHandler
       def test_signal_handling(self):
           ...
-
-   .. versionadded:: 3.2
-

Modified: python/branches/py3k-cdecimal/Doc/library/urllib.parse.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/urllib.parse.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/urllib.parse.rst	Sun Jan  2 13:18:37 2011
@@ -24,7 +24,15 @@
 ``rsync``, ``rtsp``, ``rtspu``, ``sftp``, ``shttp``, ``sip``, ``sips``,
 ``snews``, ``svn``, ``svn+ssh``, ``telnet``, ``wais``.
 
-The :mod:`urllib.parse` module defines the following functions:
+The :mod:`urllib.parse` module defines functions that fall into two broad
+categories: URL parsing and URL quoting. These are covered in detail in
+the following sections.
+
+URL Parsing
+-----------
+
+The URL parsing functions focus on splitting a URL string into its components,
+or on combining URL components into a URL string.
 
 .. function:: urlparse(urlstring, scheme='', allow_fragments=True)
 
@@ -242,6 +250,161 @@
    string.  If there is no fragment identifier in *url*, return *url* unmodified
    and an empty string.
 
+   The return value is actually an instance of a subclass of :class:`tuple`.  This
+   class has the following additional read-only convenience attributes:
+
+   +------------------+-------+-------------------------+----------------------+
+   | Attribute        | Index | Value                   | Value if not present |
+   +==================+=======+=========================+======================+
+   | :attr:`url`      | 0     | URL with no fragment    | empty string         |
+   +------------------+-------+-------------------------+----------------------+
+   | :attr:`fragment` | 1     | Fragment identifier     | empty string         |
+   +------------------+-------+-------------------------+----------------------+
+
+   See section :ref:`urlparse-result-object` for more information on the result
+   object.
+
+   .. versionchanged:: 3.2
+      Result is a structured object rather than a simple 2-tuple
+
+
+Parsing ASCII Encoded Bytes
+---------------------------
+
+The URL parsing functions were originally designed to operate on character
+strings only. In practice, it is useful to be able to manipulate properly
+quoted and encoded URLs as sequences of ASCII bytes. Accordingly, the
+URL parsing functions in this module all operate on :class:`bytes` and
+:class:`bytearray` objects in addition to :class:`str` objects.
+
+If :class:`str` data is passed in, the result will also contain only
+:class:`str` data. If :class:`bytes` or :class:`bytearray` data is
+passed in, the result will contain only :class:`bytes` data.
+
+Attempting to mix :class:`str` data with :class:`bytes` or
+:class:`bytearray` in a single function call will result in a
+:exc:`TypeError` being raised, while attempting to pass in non-ASCII
+byte values will trigger :exc:`UnicodeDecodeError`.
+
+To support easier conversion of result objects between :class:`str` and
+:class:`bytes`, all return values from URL parsing functions provide
+either an :meth:`encode` method (when the result contains :class:`str`
+data) or a :meth:`decode` method (when the result contains :class:`bytes`
+data). The signatures of these methods match those of the corresponding
+:class:`str` and :class:`bytes` methods (except that the default encoding
+is ``'ascii'`` rather than ``'utf-8'``). Each produces a value of a
+corresponding type that contains either :class:`bytes` data (for
+:meth:`encode` methods) or :class:`str` data (for
+:meth:`decode` methods).
+
+Applications that need to operate on potentially improperly quoted URLs
+that may contain non-ASCII data will need to do their own decoding from
+bytes to characters before invoking the URL parsing methods.
+
+The behaviour described in this section applies only to the URL parsing
+functions. The URL quoting functions use their own rules when producing
+or consuming byte sequences as detailed in the documentation of the
+individual URL quoting functions.
+
+.. versionchanged:: 3.2
+   URL parsing functions now accept ASCII encoded byte sequences
+
+
+.. _urlparse-result-object:
+
+Structured Parse Results
+------------------------
+
+The result objects from the :func:`urlparse`, :func:`urlsplit`  and
+:func:`urldefrag` functions are subclasses of the :class:`tuple` type.
+These subclasses add the attributes listed in the documentation for
+those functions, the encoding and decoding support described in the
+previous section, as well as an additional method:
+
+.. method:: urllib.parse.SplitResult.geturl()
+
+   Return the re-combined version of the original URL as a string. This may
+   differ from the original URL in that the scheme may be normalized to lower
+   case and empty components may be dropped. Specifically, empty parameters,
+   queries, and fragment identifiers will be removed.
+
+   For :func:`urldefrag` results, only empty fragment identifiers will be removed.
+   For :func:`urlsplit` and :func:`urlparse` results, all noted changes will be
+   made to the URL returned by this method.
+
+   The result of this method remains unchanged if passed back through the original
+   parsing function:
+
+      >>> from urllib.parse import urlsplit
+      >>> url = 'HTTP://www.Python.org/doc/#'
+      >>> r1 = urlsplit(url)
+      >>> r1.geturl()
+      'http://www.Python.org/doc/'
+      >>> r2 = urlsplit(r1.geturl())
+      >>> r2.geturl()
+      'http://www.Python.org/doc/'
+
+
+The following classes provide the implementations of the structured parse
+results when operating on :class:`str` objects:
+
+.. class:: DefragResult(url, fragment)
+
+   Concrete class for :func:`urldefrag` results containing :class:`str`
+   data. The :meth:`encode` method returns a :class:`DefragResultBytes`
+   instance.
+
+   .. versionadded:: 3.2
+
+.. class:: ParseResult(scheme, netloc, path, params, query, fragment)
+
+   Concrete class for :func:`urlparse` results containing :class:`str`
+   data. The :meth:`encode` method returns a :class:`ParseResultBytes`
+   instance.
+
+.. class:: SplitResult(scheme, netloc, path, query, fragment)
+
+   Concrete class for :func:`urlsplit` results containing :class:`str`
+   data. The :meth:`encode` method returns a :class:`SplitResultBytes`
+   instance.
+
+
+The following classes provide the implementations of the parse results when
+operating on :class:`bytes` or :class:`bytearray` objects:
+
+.. class:: DefragResultBytes(url, fragment)
+
+   Concrete class for :func:`urldefrag` results containing :class:`bytes`
+   data. The :meth:`decode` method returns a :class:`DefragResult`
+   instance.
+
+   .. versionadded:: 3.2
+
+.. class:: ParseResultBytes(scheme, netloc, path, params, query, fragment)
+
+   Concrete class for :func:`urlparse` results containing :class:`bytes`
+   data. The :meth:`decode` method returns a :class:`ParseResult`
+   instance.
+
+   .. versionadded:: 3.2
+
+.. class:: SplitResultBytes(scheme, netloc, path, query, fragment)
+
+   Concrete class for :func:`urlsplit` results containing :class:`bytes`
+   data. The :meth:`decode` method returns a :class:`SplitResult`
+   instance.
+
+   .. versionadded:: 3.2
+
+
+URL Quoting
+-----------
+
+The URL quoting functions focus on taking program data and making it safe
+for use as URL components by quoting special characters and appropriately
+encoding non-ASCII text. They also support reversing these operations to
+recreate the original data from the contents of a URL component if that
+task isn't already covered by the URL parsing functions above.
 
 .. function:: quote(string, safe='/', encoding=None, errors=None)
 
@@ -322,8 +485,7 @@
    If it is a :class:`str`, unescaped non-ASCII characters in *string*
    are encoded into UTF-8 bytes.
 
-   Example: ``unquote_to_bytes('a%26%EF')`` yields
-   ``b'a&\xef'``.
+   Example: ``unquote_to_bytes('a%26%EF')`` yields ``b'a&\xef'``.
 
 
 .. function:: urlencode(query, doseq=False, safe='', encoding=None, errors=None)
@@ -340,12 +502,13 @@
    the optional parameter *doseq* is evaluates to *True*, individual
    ``key=value`` pairs separated by ``'&'`` are generated for each element of
    the value sequence for the key.  The order of parameters in the encoded
-   string will match the order of parameter tuples in the sequence. This module
-   provides the functions :func:`parse_qs` and :func:`parse_qsl` which are used
-   to parse query strings into Python data structures.
+   string will match the order of parameter tuples in the sequence.
 
    When *query* parameter is a :class:`str`, the *safe*, *encoding* and *error*
-   parameters are sent the :func:`quote_plus` for encoding.
+   parameters are passed down to :func:`quote_plus` for encoding.
+
+   To reverse this encoding process, :func:`parse_qs` and :func:`parse_qsl` are
+   provided in this module to parse query strings into Python data structures.
 
    .. versionchanged:: 3.2
       Query parameter supports bytes and string objects.
@@ -376,57 +539,3 @@
 
    :rfc:`1738` - Uniform Resource Locators (URL)
       This specifies the formal syntax and semantics of absolute URLs.
-
-
-.. _urlparse-result-object:
-
-Results of :func:`urlparse` and :func:`urlsplit`
-------------------------------------------------
-
-The result objects from the :func:`urlparse` and :func:`urlsplit` functions are
-subclasses of the :class:`tuple` type.  These subclasses add the attributes
-described in those functions, as well as provide an additional method:
-
-.. method:: ParseResult.geturl()
-
-   Return the re-combined version of the original URL as a string. This may differ
-   from the original URL in that the scheme will always be normalized to lower case
-   and empty components may be dropped. Specifically, empty parameters, queries,
-   and fragment identifiers will be removed.
-
-   The result of this method is a fixpoint if passed back through the original
-   parsing function:
-
-      >>> import urllib.parse
-      >>> url = 'HTTP://www.Python.org/doc/#'
-
-      >>> r1 = urllib.parse.urlsplit(url)
-      >>> r1.geturl()
-      'http://www.Python.org/doc/'
-
-      >>> r2 = urllib.parse.urlsplit(r1.geturl())
-      >>> r2.geturl()
-      'http://www.Python.org/doc/'
-
-
-The following classes provide the implementations of the parse results:
-
-.. class:: BaseResult
-
-   Base class for the concrete result classes.  This provides most of the
-   attribute definitions.  It does not provide a :meth:`geturl` method.  It is
-   derived from :class:`tuple`, but does not override the :meth:`__init__` or
-   :meth:`__new__` methods.
-
-
-.. class:: ParseResult(scheme, netloc, path, params, query, fragment)
-
-   Concrete class for :func:`urlparse` results.  The :meth:`__new__` method is
-   overridden to support checking that the right number of arguments are passed.
-
-
-.. class:: SplitResult(scheme, netloc, path, query, fragment)
-
-   Concrete class for :func:`urlsplit` results.  The :meth:`__new__` method is
-   overridden to support checking that the right number of arguments are passed.
-

Modified: python/branches/py3k-cdecimal/Doc/library/urllib.request.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/urllib.request.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/urllib.request.rst	Sun Jan  2 13:18:37 2011
@@ -1,4 +1,4 @@
-:mod:`urllib.request` --- extensible library for opening URLs
+:mod:`urllib.request` --- Extensible library for opening URLs
 =============================================================
 
 .. module:: urllib.request
@@ -20,14 +20,15 @@
    Open the URL *url*, which can be either a string or a
    :class:`Request` object.
 
-   *data* may be a string specifying additional data to send to the
-   server, or ``None`` if no such data is needed.  Currently HTTP
-   requests are the only ones that use *data*; the HTTP request will
-   be a POST instead of a GET when the *data* parameter is provided.
-   *data* should be a buffer in the standard
+   *data* may be a bytes object specifying additional data to send to the
+   server, or ``None`` if no such data is needed. *data* may also be an
+   iterable object and in that case Content-Length value must be specified in
+   the headers. Currently HTTP requests are the only ones that use *data*; the
+   HTTP request will be a POST instead of a GET when the *data* parameter is
+   provided.  *data* should be a buffer in the standard
    :mimetype:`application/x-www-form-urlencoded` format.  The
-   :func:`urllib.parse.urlencode` function takes a mapping or sequence
-   of 2-tuples and returns a string in this format. urllib.request module uses
+   :func:`urllib.parse.urlencode` function takes a mapping or sequence of
+   2-tuples and returns a string in this format. urllib.request module uses
    HTTP/1.1 and includes ``Connection:close`` header in its HTTP requests.
 
    The optional *timeout* parameter specifies a timeout in seconds for
@@ -76,6 +77,9 @@
       HTTPS virtual hosts are now supported if possible (that is, if
       :data:`ssl.HAS_SNI` is true).
 
+   .. versionadded:: 3.2
+      *data* can be an iterable object.
+
 .. function:: install_opener(opener)
 
    Install an :class:`OpenerDirector` instance as the default global opener.
@@ -104,52 +108,6 @@
    member variable to modify its position in the handlers list.
 
 
-.. function:: urlretrieve(url, filename=None, reporthook=None, data=None)
-
-   Copy a network object denoted by a URL to a local file, if necessary. If the URL
-   points to a local file, or a valid cached copy of the object exists, the object
-   is not copied.  Return a tuple ``(filename, headers)`` where *filename* is the
-   local file name under which the object can be found, and *headers* is whatever
-   the :meth:`info` method of the object returned by :func:`urlopen` returned (for
-   a remote object, possibly cached). Exceptions are the same as for
-   :func:`urlopen`.
-
-   The second argument, if present, specifies the file location to copy to (if
-   absent, the location will be a tempfile with a generated name). The third
-   argument, if present, is a hook function that will be called once on
-   establishment of the network connection and once after each block read
-   thereafter.  The hook will be passed three arguments; a count of blocks
-   transferred so far, a block size in bytes, and the total size of the file.  The
-   third argument may be ``-1`` on older FTP servers which do not return a file
-   size in response to a retrieval request.
-
-   If the *url* uses the :file:`http:` scheme identifier, the optional *data*
-   argument may be given to specify a ``POST`` request (normally the request type
-   is ``GET``).  The *data* argument must in standard
-   :mimetype:`application/x-www-form-urlencoded` format; see the :func:`urlencode`
-   function below.
-
-   :func:`urlretrieve` will raise :exc:`ContentTooShortError` when it detects that
-   the amount of data available  was less than the expected amount (which is the
-   size reported by a  *Content-Length* header). This can occur, for example, when
-   the  download is interrupted.
-
-   The *Content-Length* is treated as a lower bound: if there's more data  to read,
-   urlretrieve reads more data, but if less data is available,  it raises the
-   exception.
-
-   You can still retrieve the downloaded data in this case, it is stored  in the
-   :attr:`content` attribute of the exception instance.
-
-   If no *Content-Length* header was supplied, urlretrieve can not check the size
-   of the data it has downloaded, and just returns it.  In this case you just have
-   to assume that the download was successful.
-
-.. function:: urlcleanup()
-
-   Clear the cache that may have been built up by previous calls to
-   :func:`urlretrieve`.
-
 .. function:: pathname2url(path)
 
    Convert the pathname *path* from the local syntax for a path to the form used in
@@ -218,115 +176,6 @@
    fetching of the image, this should be true.
 
 
-.. class:: URLopener(proxies=None, **x509)
-
-   Base class for opening and reading URLs.  Unless you need to support opening
-   objects using schemes other than :file:`http:`, :file:`ftp:`, or :file:`file:`,
-   you probably want to use :class:`FancyURLopener`.
-
-   By default, the :class:`URLopener` class sends a :mailheader:`User-Agent` header
-   of ``urllib/VVV``, where *VVV* is the :mod:`urllib` version number.
-   Applications can define their own :mailheader:`User-Agent` header by subclassing
-   :class:`URLopener` or :class:`FancyURLopener` and setting the class attribute
-   :attr:`version` to an appropriate string value in the subclass definition.
-
-   The optional *proxies* parameter should be a dictionary mapping scheme names to
-   proxy URLs, where an empty dictionary turns proxies off completely.  Its default
-   value is ``None``, in which case environmental proxy settings will be used if
-   present, as discussed in the definition of :func:`urlopen`, above.
-
-   Additional keyword parameters, collected in *x509*, may be used for
-   authentication of the client when using the :file:`https:` scheme.  The keywords
-   *key_file* and *cert_file* are supported to provide an  SSL key and certificate;
-   both are needed to support client authentication.
-
-   :class:`URLopener` objects will raise an :exc:`IOError` exception if the server
-   returns an error code.
-
-    .. method:: open(fullurl, data=None)
-
-       Open *fullurl* using the appropriate protocol.  This method sets up cache and
-       proxy information, then calls the appropriate open method with its input
-       arguments.  If the scheme is not recognized, :meth:`open_unknown` is called.
-       The *data* argument has the same meaning as the *data* argument of
-       :func:`urlopen`.
-
-
-    .. method:: open_unknown(fullurl, data=None)
-
-       Overridable interface to open unknown URL types.
-
-
-    .. method:: retrieve(url, filename=None, reporthook=None, data=None)
-
-       Retrieves the contents of *url* and places it in *filename*.  The return value
-       is a tuple consisting of a local filename and either a
-       :class:`email.message.Message` object containing the response headers (for remote
-       URLs) or ``None`` (for local URLs).  The caller must then open and read the
-       contents of *filename*.  If *filename* is not given and the URL refers to a
-       local file, the input filename is returned.  If the URL is non-local and
-       *filename* is not given, the filename is the output of :func:`tempfile.mktemp`
-       with a suffix that matches the suffix of the last path component of the input
-       URL.  If *reporthook* is given, it must be a function accepting three numeric
-       parameters.  It will be called after each chunk of data is read from the
-       network.  *reporthook* is ignored for local URLs.
-
-       If the *url* uses the :file:`http:` scheme identifier, the optional *data*
-       argument may be given to specify a ``POST`` request (normally the request type
-       is ``GET``).  The *data* argument must in standard
-       :mimetype:`application/x-www-form-urlencoded` format; see the :func:`urlencode`
-       function below.
-
-
-    .. attribute:: version
-
-       Variable that specifies the user agent of the opener object.  To get
-       :mod:`urllib` to tell servers that it is a particular user agent, set this in a
-       subclass as a class variable or in the constructor before calling the base
-       constructor.
-
-
-.. class:: FancyURLopener(...)
-
-   :class:`FancyURLopener` subclasses :class:`URLopener` providing default handling
-   for the following HTTP response codes: 301, 302, 303, 307 and 401.  For the 30x
-   response codes listed above, the :mailheader:`Location` header is used to fetch
-   the actual URL.  For 401 response codes (authentication required), basic HTTP
-   authentication is performed.  For the 30x response codes, recursion is bounded
-   by the value of the *maxtries* attribute, which defaults to 10.
-
-   For all other response codes, the method :meth:`http_error_default` is called
-   which you can override in subclasses to handle the error appropriately.
-
-   .. note::
-
-      According to the letter of :rfc:`2616`, 301 and 302 responses to POST requests
-      must not be automatically redirected without confirmation by the user.  In
-      reality, browsers do allow automatic redirection of these responses, changing
-      the POST to a GET, and :mod:`urllib` reproduces this behaviour.
-
-   The parameters to the constructor are the same as those for :class:`URLopener`.
-
-   .. note::
-
-      When performing basic authentication, a :class:`FancyURLopener` instance calls
-      its :meth:`prompt_user_passwd` method.  The default implementation asks the
-      users for the required information on the controlling terminal.  A subclass may
-      override this method to support more appropriate behavior if needed.
-
-    The :class:`FancyURLopener` class offers one additional method that should be
-    overloaded to provide the appropriate behavior:
-
-    .. method:: prompt_user_passwd(host, realm)
-
-       Return information needed to authenticate the user at the given host in the
-       specified security realm.  The return value should be a tuple, ``(user,
-       password)``, which can be used for basic authentication.
-
-       The implementation prompts for this information on the terminal; an application
-       should override this method to use an appropriate interaction model in the local
-       environment.
-
 .. class:: OpenerDirector()
 
    The :class:`OpenerDirector` class opens URLs via :class:`BaseHandler`\ s chained
@@ -1219,6 +1068,170 @@
    >>> f.read().decode('utf-8')
 
 
+Legacy interface
+----------------
+
+The following functions and classes are ported from the Python 2 module
+``urllib`` (as opposed to ``urllib2``).  They might become deprecated at
+some point in the future.
+
+
+.. function:: urlretrieve(url, filename=None, reporthook=None, data=None)
+
+   Copy a network object denoted by a URL to a local file, if necessary. If the URL
+   points to a local file, or a valid cached copy of the object exists, the object
+   is not copied.  Return a tuple ``(filename, headers)`` where *filename* is the
+   local file name under which the object can be found, and *headers* is whatever
+   the :meth:`info` method of the object returned by :func:`urlopen` returned (for
+   a remote object, possibly cached). Exceptions are the same as for
+   :func:`urlopen`.
+
+   The second argument, if present, specifies the file location to copy to (if
+   absent, the location will be a tempfile with a generated name). The third
+   argument, if present, is a hook function that will be called once on
+   establishment of the network connection and once after each block read
+   thereafter.  The hook will be passed three arguments; a count of blocks
+   transferred so far, a block size in bytes, and the total size of the file.  The
+   third argument may be ``-1`` on older FTP servers which do not return a file
+   size in response to a retrieval request.
+
+   If the *url* uses the :file:`http:` scheme identifier, the optional *data*
+   argument may be given to specify a ``POST`` request (normally the request type
+   is ``GET``).  The *data* argument must in standard
+   :mimetype:`application/x-www-form-urlencoded` format; see the :func:`urlencode`
+   function below.
+
+   :func:`urlretrieve` will raise :exc:`ContentTooShortError` when it detects that
+   the amount of data available  was less than the expected amount (which is the
+   size reported by a  *Content-Length* header). This can occur, for example, when
+   the  download is interrupted.
+
+   The *Content-Length* is treated as a lower bound: if there's more data  to read,
+   urlretrieve reads more data, but if less data is available,  it raises the
+   exception.
+
+   You can still retrieve the downloaded data in this case, it is stored  in the
+   :attr:`content` attribute of the exception instance.
+
+   If no *Content-Length* header was supplied, urlretrieve can not check the size
+   of the data it has downloaded, and just returns it.  In this case you just have
+   to assume that the download was successful.
+
+.. function:: urlcleanup()
+
+   Clear the cache that may have been built up by previous calls to
+   :func:`urlretrieve`.
+
+.. class:: URLopener(proxies=None, **x509)
+
+   Base class for opening and reading URLs.  Unless you need to support opening
+   objects using schemes other than :file:`http:`, :file:`ftp:`, or :file:`file:`,
+   you probably want to use :class:`FancyURLopener`.
+
+   By default, the :class:`URLopener` class sends a :mailheader:`User-Agent` header
+   of ``urllib/VVV``, where *VVV* is the :mod:`urllib` version number.
+   Applications can define their own :mailheader:`User-Agent` header by subclassing
+   :class:`URLopener` or :class:`FancyURLopener` and setting the class attribute
+   :attr:`version` to an appropriate string value in the subclass definition.
+
+   The optional *proxies* parameter should be a dictionary mapping scheme names to
+   proxy URLs, where an empty dictionary turns proxies off completely.  Its default
+   value is ``None``, in which case environmental proxy settings will be used if
+   present, as discussed in the definition of :func:`urlopen`, above.
+
+   Additional keyword parameters, collected in *x509*, may be used for
+   authentication of the client when using the :file:`https:` scheme.  The keywords
+   *key_file* and *cert_file* are supported to provide an  SSL key and certificate;
+   both are needed to support client authentication.
+
+   :class:`URLopener` objects will raise an :exc:`IOError` exception if the server
+   returns an error code.
+
+    .. method:: open(fullurl, data=None)
+
+       Open *fullurl* using the appropriate protocol.  This method sets up cache and
+       proxy information, then calls the appropriate open method with its input
+       arguments.  If the scheme is not recognized, :meth:`open_unknown` is called.
+       The *data* argument has the same meaning as the *data* argument of
+       :func:`urlopen`.
+
+
+    .. method:: open_unknown(fullurl, data=None)
+
+       Overridable interface to open unknown URL types.
+
+
+    .. method:: retrieve(url, filename=None, reporthook=None, data=None)
+
+       Retrieves the contents of *url* and places it in *filename*.  The return value
+       is a tuple consisting of a local filename and either a
+       :class:`email.message.Message` object containing the response headers (for remote
+       URLs) or ``None`` (for local URLs).  The caller must then open and read the
+       contents of *filename*.  If *filename* is not given and the URL refers to a
+       local file, the input filename is returned.  If the URL is non-local and
+       *filename* is not given, the filename is the output of :func:`tempfile.mktemp`
+       with a suffix that matches the suffix of the last path component of the input
+       URL.  If *reporthook* is given, it must be a function accepting three numeric
+       parameters.  It will be called after each chunk of data is read from the
+       network.  *reporthook* is ignored for local URLs.
+
+       If the *url* uses the :file:`http:` scheme identifier, the optional *data*
+       argument may be given to specify a ``POST`` request (normally the request type
+       is ``GET``).  The *data* argument must in standard
+       :mimetype:`application/x-www-form-urlencoded` format; see the :func:`urlencode`
+       function below.
+
+
+    .. attribute:: version
+
+       Variable that specifies the user agent of the opener object.  To get
+       :mod:`urllib` to tell servers that it is a particular user agent, set this in a
+       subclass as a class variable or in the constructor before calling the base
+       constructor.
+
+
+.. class:: FancyURLopener(...)
+
+   :class:`FancyURLopener` subclasses :class:`URLopener` providing default handling
+   for the following HTTP response codes: 301, 302, 303, 307 and 401.  For the 30x
+   response codes listed above, the :mailheader:`Location` header is used to fetch
+   the actual URL.  For 401 response codes (authentication required), basic HTTP
+   authentication is performed.  For the 30x response codes, recursion is bounded
+   by the value of the *maxtries* attribute, which defaults to 10.
+
+   For all other response codes, the method :meth:`http_error_default` is called
+   which you can override in subclasses to handle the error appropriately.
+
+   .. note::
+
+      According to the letter of :rfc:`2616`, 301 and 302 responses to POST requests
+      must not be automatically redirected without confirmation by the user.  In
+      reality, browsers do allow automatic redirection of these responses, changing
+      the POST to a GET, and :mod:`urllib` reproduces this behaviour.
+
+   The parameters to the constructor are the same as those for :class:`URLopener`.
+
+   .. note::
+
+      When performing basic authentication, a :class:`FancyURLopener` instance calls
+      its :meth:`prompt_user_passwd` method.  The default implementation asks the
+      users for the required information on the controlling terminal.  A subclass may
+      override this method to support more appropriate behavior if needed.
+
+   The :class:`FancyURLopener` class offers one additional method that should be
+   overloaded to provide the appropriate behavior:
+
+   .. method:: prompt_user_passwd(host, realm)
+
+      Return information needed to authenticate the user at the given host in the
+      specified security realm.  The return value should be a tuple, ``(user,
+      password)``, which can be used for basic authentication.
+
+      The implementation prompts for this information on the terminal; an application
+      should override this method to use an appropriate interaction model in the local
+      environment.
+
+
 :mod:`urllib.request` Restrictions
 ----------------------------------
 
@@ -1272,8 +1285,8 @@
 
 
 
-:mod:`urllib.response` --- Response classes used by urllib.
-===========================================================
+:mod:`urllib.response` --- Response classes used by urllib
+==========================================================
 
 .. module:: urllib.response
    :synopsis: Response classes used by urllib.

Modified: python/branches/py3k-cdecimal/Doc/library/warnings.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/warnings.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/warnings.rst	Sun Jan  2 13:18:37 2011
@@ -249,6 +249,8 @@
 entries from the warnings list before each new operation).
 
 
+.. _warning-ignored:
+
 Updating Code For New Versions of Python
 ----------------------------------------
 
@@ -279,6 +281,9 @@
 developer want to be notified that your code is using a deprecated module, to a
 user this information is essentially noise and provides no benefit to them.
 
+The :mod:`unittest` module has been also updated to use the ``'default'``
+filter while running tests.
+
 
 .. _warning-functions:
 

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	Sun Jan  2 13:18:37 2011
@@ -122,7 +122,7 @@
           ... # Work with dom.
 
 
-.. method:: Node.writexml(writer, indent="", addindent="", newl="", encoding="")
+.. method:: Node.writexml(writer, indent="", addindent="", newl="")
 
    Write XML to the writer object.  The writer should have a :meth:`write` method
    which matches that of the file object interface.  The *indent* parameter is the
@@ -130,8 +130,8 @@
    indentation to use for subnodes of the current one.  The *newl* parameter
    specifies the string to use to terminate newlines.
 
-   For the :class:`Document` node, an additional keyword argument *encoding* can be
-   used to specify the encoding field of the XML header.
+   For the :class:`Document` node, an additional keyword argument *encoding* can
+   be used to specify the encoding field of the XML header.
 
 
 .. method:: Node.toxml(encoding=None)

Modified: python/branches/py3k-cdecimal/Doc/library/zipfile.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/library/zipfile.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/library/zipfile.rst	Sun Jan  2 13:18:37 2011
@@ -51,6 +51,7 @@
 
 
 .. class:: PyZipFile
+   :noindex:
 
    Class for creating ZIP archives containing Python libraries.
 
@@ -178,8 +179,8 @@
    .. note::
 
       The file-like object is read-only and provides the following methods:
-      :meth:`read`, :meth:`readline`, :meth:`readlines`, :meth:`__iter__`,
-      :meth:`__next__`.
+      :meth:`!read`, :meth:`!readline`, :meth:`!readlines`, :meth:`!__iter__`,
+      :meth:`!__next__`.
 
    .. note::
 
@@ -294,7 +295,7 @@
 
    .. note::
 
-      When passing a :class:`ZipInfo` instance as the *zinfo_or_acrname* parameter,
+      When passing a :class:`ZipInfo` instance as the *zinfo_or_arcname* parameter,
       the compression method used will be that specified in the *compress_type*
       member of the given :class:`ZipInfo` instance.  By default, the
       :class:`ZipInfo` constructor sets this member to :const:`ZIP_STORED`.
@@ -318,37 +319,53 @@
    string no longer than 65535 bytes.  Comments longer than this will be
    truncated in the written archive when :meth:`ZipFile.close` is called.
 
+
 .. _pyzipfile-objects:
 
 PyZipFile Objects
 -----------------
 
 The :class:`PyZipFile` constructor takes the same parameters as the
-:class:`ZipFile` constructor.  Instances have one method in addition to those of
-:class:`ZipFile` objects.
+:class:`ZipFile` constructor, and one additional parameter, *optimize*.
+
+.. class:: PyZipFile(file, mode='r', compression=ZIP_STORED, allowZip64=False, \
+                     optimize=-1)
+
+   .. versionadded:: 3.2
+      The *optimize* parameter.
+
+   Instances have one method in addition to those of :class:`ZipFile` objects:
 
+   .. method:: PyZipFile.writepy(pathname, basename='')
 
-.. method:: PyZipFile.writepy(pathname, basename='')
+      Search for files :file:`\*.py` and add the corresponding file to the
+      archive.
 
-   Search for files :file:`\*.py` and add the corresponding file to the archive.
-   The corresponding file is a :file:`\*.pyo` file if available, else a
-   :file:`\*.pyc` file, compiling if necessary.  If the pathname is a file, the
-   filename must end with :file:`.py`, and just the (corresponding
-   :file:`\*.py[co]`) file is added at the top level (no path information).  If the
-   pathname is a file that does not end with :file:`.py`, a :exc:`RuntimeError`
-   will be raised.  If it is a directory, and the directory is not a package
-   directory, then all the files :file:`\*.py[co]` are added at the top level.  If
-   the directory is a package directory, then all :file:`\*.py[co]` are added under
-   the package name as a file path, and if any subdirectories are package
-   directories, all of these are added recursively.  *basename* is intended for
-   internal use only.  The :meth:`writepy` method makes archives with file names
-   like this::
-
-      string.pyc                                # Top level name
-      test/__init__.pyc                         # Package directory
-      test/testall.pyc                          # Module test.testall
-      test/bogus/__init__.pyc                   # Subpackage directory
-      test/bogus/myfile.pyc                     # Submodule test.bogus.myfile
+      If the *optimize* parameter to :class:`PyZipFile` was not given or ``-1``,
+      the corresponding file is a :file:`\*.pyo` file if available, else a
+      :file:`\*.pyc` file, compiling if necessary.
+
+      If the *optimize* parameter to :class:`PyZipFile` was ``0``, ``1`` or
+      ``2``, only files with that optimization level (see :func:`compile`) are
+      added to the archive, compiling if necessary.
+
+      If the pathname is a file, the filename must end with :file:`.py`, and
+      just the (corresponding :file:`\*.py[co]`) file is added at the top level
+      (no path information).  If the pathname is a file that does not end with
+      :file:`.py`, a :exc:`RuntimeError` will be raised.  If it is a directory,
+      and the directory is not a package directory, then all the files
+      :file:`\*.py[co]` are added at the top level.  If the directory is a
+      package directory, then all :file:`\*.py[co]` are added under the package
+      name as a file path, and if any subdirectories are package directories,
+      all of these are added recursively.  *basename* is intended for internal
+      use only.  The :meth:`writepy` method makes archives with file names like
+      this::
+
+         string.pyc                   # Top level name
+         test/__init__.pyc            # Package directory
+         test/testall.pyc             # Module test.testall
+         test/bogus/__init__.pyc      # Subpackage directory
+         test/bogus/myfile.pyc        # Submodule test.bogus.myfile
 
 
 .. _zipinfo-objects:

Modified: python/branches/py3k-cdecimal/Doc/license.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/license.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/license.rst	Sun Jan  2 13:18:37 2011
@@ -108,7 +108,7 @@
 +----------------+--------------+------------+------------+-----------------+
 | 3.1.2          | 3.1          | 2010       | PSF        | yes             |
 +----------------+--------------+------------+------------+-----------------+
-| 3.2            | 3.1          | 2010       | PSF        | yes             |
+| 3.2            | 3.1          | 2011       | PSF        | yes             |
 +----------------+--------------+------------+------------+-----------------+
 
 .. note::
@@ -138,7 +138,7 @@
    analyze, test, perform and/or display publicly, prepare derivative works,
    distribute, and otherwise use Python |release| alone or in any derivative
    version, provided, however, that PSF's License Agreement and PSF's notice of
-   copyright, i.e., "Copyright © 2001-2010 Python Software Foundation; All Rights
+   copyright, i.e., "Copyright © 2001-2011 Python Software Foundation; All Rights
    Reserved" are retained in Python |release| alone or in any derivative version
    prepared by Licensee.
 
@@ -906,7 +906,7 @@
 sources unless the zlib version found on the system is too old to be
 used for the build::
 
-  Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
+  Copyright (C) 1995-2011 Jean-loup Gailly and Mark Adler
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages

Modified: python/branches/py3k-cdecimal/Doc/reference/datamodel.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/reference/datamodel.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/reference/datamodel.rst	Sun Jan  2 13:18:37 2011
@@ -618,7 +618,7 @@
       an object passed to the C function as an implicit extra argument.  An example of
       a built-in method is ``alist.append()``, assuming *alist* is a list object. In
       this case, the special read-only attribute :attr:`__self__` is set to the object
-      denoted by *list*.
+      denoted by *alist*.
 
    Classes
       Classes are callable.  These objects normally act as factories for new

Modified: python/branches/py3k-cdecimal/Doc/reference/expressions.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/reference/expressions.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/reference/expressions.rst	Sun Jan  2 13:18:37 2011
@@ -1161,7 +1161,7 @@
 'foo'`` yields ``False``, not ``''``.)
 
 
-Conditional Expressions
+Conditional expressions
 =======================
 
 .. index::
@@ -1322,8 +1322,8 @@
    true numerically due to roundoff.  For example, and assuming a platform on which
    a Python float is an IEEE 754 double-precision number, in order that ``-1e-100 %
    1e100`` have the same sign as ``1e100``, the computed result is ``-1e-100 +
-   1e100``, which is numerically exactly equal to ``1e100``.  Function :func:`fmod`
-   in the :mod:`math` module returns a result whose sign matches the sign of the
+   1e100``, which is numerically exactly equal to ``1e100``.  The function
+   :func:`math.fmod` returns a result whose sign matches the sign of the
    first argument instead, and so returns ``-1e-100`` in this case. Which approach
    is more appropriate depends on the application.
 
@@ -1344,7 +1344,8 @@
    the :keyword:`is` operator, like those involving comparisons between instance
    methods, or constants.  Check their documentation for more info.
 
-.. [#] The ``%`` is also used for string formatting; the same precedence applies.
+.. [#] The ``%`` operator is also used for string formatting; the same
+   precedence applies.
 
 .. [#] The power operator ``**`` binds less tightly than an arithmetic or
    bitwise unary operator on its right, that is, ``2**-1`` is ``0.5``.

Modified: python/branches/py3k-cdecimal/Doc/reference/lexical_analysis.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/reference/lexical_analysis.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/reference/lexical_analysis.rst	Sun Jan  2 13:18:37 2011
@@ -292,9 +292,11 @@
 Identifiers are unlimited in length.  Case is significant.
 
 .. productionlist::
-   identifier: `id_start` `id_continue`*
+   identifier: `xid_start` `xid_continue`*
    id_start: <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
    id_continue: <all characters in `id_start`, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
+   xid_start: <all characters in `id_start` whose NFKC normalization is in "id_start xid_continue*">
+   xid_continue: <all characters in `id_continue` whose NFKC normalization is in "id_continue*">
 
 The Unicode category codes mentioned above stand for:
 
@@ -308,9 +310,11 @@
 * *Mc* - spacing combining marks
 * *Nd* - decimal numbers
 * *Pc* - connector punctuations
+* *Other_ID_Start* - explicit list of characters in `PropList.txt <http://unicode.org/Public/UNIDATA/PropList.txt>`_ to support backwards compatibility
+* *Other_ID_Continue* - likewise
 
-All identifiers are converted into the normal form NFC while parsing; comparison
-of identifiers is based on NFC.
+All identifiers are converted into the normal form NFKC while parsing; comparison
+of identifiers is based on NFKC.
 
 A non-normative HTML file listing all valid identifier characters for Unicode
 4.1 can be found at

Modified: python/branches/py3k-cdecimal/Doc/tools/sphinxext/static/basic.css
==============================================================================
--- python/branches/py3k-cdecimal/Doc/tools/sphinxext/static/basic.css	(original)
+++ python/branches/py3k-cdecimal/Doc/tools/sphinxext/static/basic.css	Sun Jan  2 13:18:37 2011
@@ -364,6 +364,7 @@
 
 pre {
     overflow: auto;
+    overflow-y: hidden;
 }
 
 td.linenos pre {

Modified: python/branches/py3k-cdecimal/Doc/tools/sphinxext/susp-ignored.csv
==============================================================================
--- python/branches/py3k-cdecimal/Doc/tools/sphinxext/susp-ignored.csv	(original)
+++ python/branches/py3k-cdecimal/Doc/tools/sphinxext/susp-ignored.csv	Sun Jan  2 13:18:37 2011
@@ -324,3 +324,22 @@
 library/configparser,,`,# Set the optional `raw` argument of get() to True if you wish to disable
 library/configparser,,`,# The optional `vars` argument is a dict with members that will take
 library/configparser,,`,# The optional `fallback` argument can be used to provide a fallback value
+library/configparser,,:option,${section:option}
+library/configparser,,:system,path: ${Common:system_dir}/Library/Frameworks/
+library/configparser,,:home,my_dir: ${Common:home_dir}/twosheds
+library/configparser,,:path,python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}
+library/configparser,,:Python,python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}
+library/pdb,,:lineno,[filename:lineno | bpnumber [bpnumber ...]]
+library/pdb,,:lineno,filename:lineno
+library/logging,,:Watch,WARNING:root:Watch out!
+library/logging,,:So,INFO:root:So should this
+library/logging,,:Started,INFO:root:Started
+library/logging,,:Doing,INFO:root:Doing something
+library/logging,,:Finished,INFO:root:Finished
+library/logging,,:Look,WARNING:root:Look before you leap!
+library/logging,,:So,INFO:So should this
+library/logging,,:logger,severity:logger name:message
+library/logging,,:message,severity:logger name:message
+whatsnew/3.2,,:directory,...   ${buildout:directory}/downloads/dist
+whatsnew/3.2,,:location,... zope9-location = ${zope9:location}
+whatsnew/3.2,,:prefix,... zope-conf = ${custom:prefix}/etc/zope.conf

Modified: python/branches/py3k-cdecimal/Doc/tutorial/interpreter.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/tutorial/interpreter.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/tutorial/interpreter.rst	Sun Jan  2 13:18:37 2011
@@ -58,14 +58,6 @@
 ``python -m module [arg] ...``, which executes the source file for *module* as
 if you had spelled out its full name on the command line.
 
-Note that there is a difference between ``python file`` and ``python
-<file``.  In the latter case, input requests from the program, such as calling
-``sys.stdin.read()``, are satisfied from *file*.  Since this file has already
-been read until the end by the parser before the program starts executing, the
-program will encounter end-of-file immediately.  In the former case (which is
-usually what you want) they are satisfied from whatever file or device is
-connected to standard input of the Python interpreter.
-
 When a script file is used, it is sometimes useful to be able to run the script
 and enter interactive mode afterwards.  This can be done by passing :option:`-i`
 before the script.  (This does not work if the script is read from standard
@@ -78,8 +70,9 @@
 ----------------
 
 When known to the interpreter, the script name and additional arguments
-thereafter are passed to the script in the variable ``sys.argv``, which is a
-list of strings.  Its length is at least one; when no script and no arguments
+thereafter are turned into a list of strings and assigned to the ``argv``
+variable in the ``sys`` module.  You can access this list by executing ``import
+sys``.  The length of the list is at least one; when no script and no arguments
 are given, ``sys.argv[0]`` is an empty string.  When the script name is given as
 ``'-'`` (meaning  standard input), ``sys.argv[0]`` is set to ``'-'``.  When
 :option:`-c` *command* is used, ``sys.argv[0]`` is set to ``'-c'``.  When

Modified: python/branches/py3k-cdecimal/Doc/tutorial/stdlib.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/tutorial/stdlib.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/tutorial/stdlib.rst	Sun Jan  2 13:18:37 2011
@@ -14,11 +14,11 @@
 operating system::
 
    >>> import os
-   >>> os.system('time 0:02')
-   0
    >>> os.getcwd()      # Return the current working directory
    'C:\\Python31'
-   >>> os.chdir('/server/accesslogs')
+   >>> os.chdir('/server/accesslogs')   # Change current working directory
+   >>> os.system('mkdir today')   # Run the command mkdir in the system shell
+   0
 
 Be sure to use the ``import os`` style instead of ``from os import *``.  This
 will keep :func:`os.open` from shadowing the built-in :func:`open` function which
@@ -207,14 +207,14 @@
 :mod:`tarfile`. ::
 
    >>> import zlib
-   >>> s = 'witch which has which witches wrist watch'
+   >>> s = b'witch which has which witches wrist watch'
    >>> len(s)
    41
    >>> t = zlib.compress(s)
    >>> len(t)
    37
    >>> zlib.decompress(t)
-   'witch which has which witches wrist watch'
+   b'witch which has which witches wrist watch'
    >>> zlib.crc32(s)
    226805979
 

Modified: python/branches/py3k-cdecimal/Doc/using/cmdline.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/using/cmdline.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/using/cmdline.rst	Sun Jan  2 13:18:37 2011
@@ -220,6 +220,13 @@
    Discard docstrings in addition to the :option:`-O` optimizations.
 
 
+.. cmdoption:: -q
+
+   Don't display the copyright and version messages even in interactive mode.
+
+   .. versionadded:: 3.2
+
+
 .. cmdoption:: -s
 
    Don't add user site directory to sys.path

Modified: python/branches/py3k-cdecimal/Doc/whatsnew/2.7.rst
==============================================================================
--- python/branches/py3k-cdecimal/Doc/whatsnew/2.7.rst	(original)
+++ python/branches/py3k-cdecimal/Doc/whatsnew/2.7.rst	Sun Jan  2 13:18:37 2011
@@ -246,7 +246,7 @@
 modules.
 
 * The :mod:`ConfigParser` module uses them by default, meaning that
-  configuration files can now read, modified, and then written back
+  configuration files can now be read, modified, and then written back
   in their original order.
 
 * The :meth:`~collections.somenamedtuple._asdict()` method for

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	Sun Jan  2 13:18:37 2011
@@ -11,7 +11,7 @@
 
    * Anyone can add text to this document.  Do not spend very much time
    on the wording of your changes, because your text will probably
-   get rewritten to some degree.
+   get rewritten.
 
    * The maintainer will go through Misc/NEWS periodically and add
    changes; it's therefore more important to add your changes to
@@ -47,7 +47,128 @@
    This saves the maintainer the effort of going through the SVN log
    when researching a change.
 
-This article explains the new features in Python 3.2, compared to 3.1.
+This article explains the new features in Python 3.2 as compared to 3.1.  It
+focuses on a few highlights and gives a few examples.  For full details, see the
+:source:`Misc/NEWS <Misc/NEWS>` file.
+
+.. seealso::
+
+   :pep:`392` - Python 3.2 Release Schedule
+
+PEP 384: Defining a Stable ABI
+==============================
+
+In the past, extension modules built for one Python version were often
+not usable with other Python versions. Particularly on Windows, every
+feature release of Python required rebuilding all extension modules that
+one wanted to use. This requirement was the result of the free access to
+Python interpreter internals that extension modules could use.
+
+With Python 3.2, an alternative approach becomes available: extension
+modules which restrict themselves to a limited API (by defining
+Py_LIMITED_API) cannot use many of the internals, but are constrained
+to a set of API functions that are promised to be stable for several
+releases. As a consequence, extension modules built for 3.2 in that
+mode will also work with 3.3, 3.4, and so on. Extension modules that
+make use of details of memory structures can still be built, but will
+need to be recompiled for every feature release.
+
+.. seealso::
+
+   :pep:`384` - Defining a Stable ABI
+      PEP written by Martin von Löwis.
+
+PEP 389: Argparse Command Line Parsing Module
+=============================================
+
+A new module for command line parsing, :mod:`argparse`, was introduced to
+overcome the limitations of :mod:`optparse` which did not provide support for
+positional arguments (not just options), subcommands, required options and other
+common patterns of specifying and validating options.
+
+This module has already has wide-spread success in the community as a
+third-party module.  Being more fully featured than its predecessor, the
+:mod:`argparse` module is now the preferred module for command-line processing.
+The older module is still being kept available because of the substantial amount
+of legacy code that depends on it.
+
+Here's an annotated example parser showing features like limiting results to a
+set of choices, specifying a *metavar* in the help screen, validating that one
+or more positional arguments is present, and making a required option::
+
+    import argparse
+    parser = argparse.ArgumentParser(
+                description = 'Manage servers',         # main description for help
+                epilog = 'Tested on Solaris and Linux') # displayed after help
+    parser.add_argument('action',                       # argument name
+                choices = ['deploy', 'start', 'stop'],  # one of four allowed values
+                help = 'action on each target')         # help msg
+    parser.add_argument('targets',
+                metavar = 'HOSTNAME',                   # var name used in help msg
+                nargs = '+',                            # require 1 or more targets
+                help = 'url for target machines')       # help msg explanation
+    parser.add_argument('-u', '--user',                 # -u or --user option
+                required = True,                        # make this a required argument
+                help = 'login as user')
+
+Example of calling the parser on a command string::
+
+    >>> cmd  = 'deploy sneezy.example.com sleepy.example.com -u skycaptain'
+    >>> result = parser.parse_args(cmd.split())
+    >>> result.action
+    'deploy'
+    >>> result.targets
+    ['sneezy.example.com', 'sleepy.example.com']
+    >>> result.user
+    'skycaptain'
+
+Example of the parser's automatically generated help::
+
+    >>> parser.parse_args('-h'.split())
+
+    usage: manage_cloud.py [-h] -u USER
+                           {deploy,start,stop} HOSTNAME [HOSTNAME ...]
+
+    Manage servers
+
+    positional arguments:
+      {deploy,start,stop}   action on each target
+      HOSTNAME              url for target machines
+
+    optional arguments:
+      -h, --help            show this help message and exit
+      -u USER, --user USER  login as user
+
+    Tested on Solaris and Linux
+
+An especially nice :mod:`argparse` feature is the ability to define subparsers,
+each with their own argument patterns and help displays::
+
+    import argparse
+    parser = argparse.ArgumentParser(prog='HELM')
+    subparsers = parser.add_subparsers()
+
+    parser_l = subparsers.add_parser('launch', help='Launch Control')   # first subgroup
+    parser_l.add_argument('-m', '--missiles', action='store_true')
+    parser_l.add_argument('-t', '--torpedos', action='store_true')
+
+    parser_m = subparsers.add_parser('move', help='Move Vessel',        # second subgroup
+                                     aliases=('steer', 'turn'))         # equivalent names
+    parser_m.add_argument('-c', '--course', type=int, required=True)
+    parser_m.add_argument('-s', '--speed', type=int, default=0)
+
+    $ ./helm.py --help                         # top level help (launch and move)
+    $ ./helm.py launch --help                  # help for launch options
+    $ ./helm.py launch --missiles              # set missiles=True and torpedos=False
+    $ ./helm.py steer --course 180 --speed 5   # set movement parameters
+
+.. seealso::
+
+   :pep:`389` - New Command Line Parsing Module
+      PEP written by Steven Bethard.
+
+   :ref:`upgrading-optparse-code` for details on the differences from
+      :mod:`optparse`.
 
 
 PEP 391:  Dictionary Based Configuration for Logging
@@ -84,7 +205,7 @@
     "root": {"level": "DEBUG", "handlers": ["console", "console_priority"]}}
 
 
-If that dictionary is stored in a file called "conf.json", it can loaded
+If that dictionary is stored in a file called :file:`conf.json`, it can loaded
 and called with code like this::
 
    >>> import logging.config
@@ -100,7 +221,60 @@
 PEP 3148:  The ``concurrent.futures`` module
 ============================================
 
-.. (Stub section)
+Code for creating and managing concurrency is being collected in a new toplevel
+namespace, *concurrent*.  Its first member is a *futures* package which provides
+a uniform high level interface for managing threads and processes.
+
+The design for :mod:`concurrent.futures` was inspired by
+*java.util.concurrent.package*.  In that model, a running call and its result
+are represented by a :class:`~concurrent.futures.Future` object which abstracts
+features common to threads, processes, and remote procedure calls.  That object
+supports status checks (running or done), timeouts, cancellations, adding
+callbacks, and access to results or exceptions.
+
+The primary offering of the new module is a pair of executor classes for
+launching and managing calls.  The goal of the executors is to make it easier to
+use existing tools for making parallel calls. They save the effort needed to
+setup a pool of resources, launch the calls, create a results queue, add
+time-out handling, and limit the total number of threads, processes, or remote
+procedure calls.
+
+Ideally, each application should share a single executor across multiple
+components so that process and thread limits can be centrally managed.  This
+solves the design challenge that arises when each component has its own
+competing strategy for resource management.
+
+Both classes share a common interface with three methods:
+:meth:`~concurrent.futures.Executor.submit` for scheduling a callable and
+returning a :class:`~concurrent.futures.Future` object;
+:meth:`~concurrent.futures.Executor.map` for scheduling many asynchronous calls
+at a time, and :meth:`~concurrent.futures.Executor.shutdown` for freeing
+resources.  The class is a :term:`context manager` and can be used within a
+:keyword:`with` statement to assure that resources are automatically released
+when currently pending futures are done executing.
+
+A simple of example of :class:`~concurrent.futures.ThreadPoolExecutor` is a
+launch of four parallel threads for copying files::
+
+  import shutil
+  with ThreadPoolExecutor(max_workers=4) as e:
+      e.submit(shutil.copy, 'src1.txt', 'dest1.txt')
+      e.submit(shutil.copy, 'src2.txt', 'dest2.txt')
+      e.submit(shutil.copy, 'src3.txt', 'dest3.txt')
+      e.submit(shutil.copy, 'src3.txt', 'dest4.txt')
+
+.. seealso::
+
+   :pep:`3148` - Futures -- Execute Computations Asynchronously
+      PEP written by Brian Quinlan.
+
+   :ref:`Code for Threaded Parallel URL reads<threadpoolexecutor-example>`, an
+   example using threads to fetch multiple web pages in parallel.
+
+   :ref:`Code for computing prime numbers in
+   parallel<processpoolexecutor-example>`, an example demonstrating
+   :class:`~concurrent.futures.ProcessPoolExecutor`.
+
 
 
 PEP 3147:  PYC Repository Directories
@@ -158,8 +332,8 @@
       PEP written by Barry Warsaw.
 
 
-PEP 3149 ABI Version Tagged .so Files
-=====================================
+PEP 3149: ABI Version Tagged .so Files
+======================================
 
 The PYC repository directory allows multiple bytecode cache files to be
 co-located.  This PEP implements a similar mechanism for shared object files by
@@ -189,38 +363,29 @@
       PEP written by Barry Warsaw.
 
 
-Email 5.1
-=========
-
-The email package is extended to be able to parse and generate email messages
-in bytes format.
-
-* New functions :func:`~email.message_from_bytes` and
-  :func:`~email.message_from_binary_file`, and new classes
-  :class:`~email.parser.BytesFeedParser` and :class:`~email.parser.BytesParser`
-  allow binary message data to be parsed into model objects.
-
-* Given bytes input to the model, :meth:`~email.message.Message.get_payload`
-  will by default decode a message body that has a
-  :mailheader:`Content-Transfer-Encoding` of ``8bit`` using the charset
-  specified in the MIME headers and return the resulting string.
-
-* Given bytes input to the model, :class:`~email.generator.Generator` will
-  convert message bodies that have a :mailheader:`Content-Transfer-Encoding` of
-  8bit to instead have a 7bit Content-Transfer-Encoding.
+Other Language Changes
+======================
 
-* New class :class:`~email.generator.BytesGenerator` produces bytes
-  as output, preserving any unchanged non-ASCII data that was
-  present in the input used to build the model, including message bodies
-  with a :mailheader:`Content-Transfer-Encoding` of 8bit.
+Some smaller changes made to the core Python language are:
 
-  (Proposed and implemented by R. David Murray, :issue:`4661`.)
+* String formatting for :func:`format` and :meth:`str.format` gained new
+  capabilities for the format character **#**.  Previously, for integers in
+  binary, octal, or hexadecimal, it caused the output to be prefixed with '0b',
+  '0o', or '0x' respectively.  Now it can also handle floats, complex, and
+  Decimal, causing the output to always have a decimal point even when no digits
+  follow it.
+
+  >>> format(20, '#o')
+  '0o24'
+  >>> format(12.34, '#5.0f')
+  '  12.'
 
+  (Suggested by Mark Dickinson and implemented by Eric Smith in :issue:`7094`.)
 
-Other Language Changes
-======================
+* The interpreter can now be started with a quiet option, ``-q``, to suppress
+  the copyright and version information in an interactive mode.
 
-Some smaller changes made to the core Python language are:
+  (Contributed by Marcin Wojdyr in issue:`1772833`).
 
 * The :func:`hasattr` function used to catch and suppress any Exception.  Now,
   it only catches :exc:`AttributeError`.  Under the hood, :func:`hasattr` works
@@ -244,20 +409,18 @@
 
   (Proposed and implemented by Mark Dickinson; :issue:`9337`.)
 
-* :class:`memoryview` objects now have a :meth:`release()` method and support
-  the context manager protocol.  This allows timely release of any resources
-  that were acquired when requesting a buffer from the original object.
+* :class:`memoryview` objects now have a :meth:`~memoryview.release()` method
+  and they also now support the context manager protocol.  This allows timely
+  release of any resources that were acquired when requesting a buffer from the
+  original object.
+
+  >>> with memoryview(b'abcdefgh') as v:
+  ...     print(v.tolist())
+  ...
+  [97, 98, 99, 100, 101, 102, 103, 104]
 
   (Added by Antoine Pitrou; :issue:`9757`.)
 
-* Mark Dickinson crafted an elegant and efficient scheme for assuring that
-  different numeric datatypes will have the same hash value whenever their
-  actual values are equal::
-
-   >>> assert hash(Fraction(3, 2)) == hash(1.5) == \
-              hash(Decimal("1.5")) == hash(complex(1.5, 0))
-
-  (See :issue:`8188`.)
 
 * Previously it was illegal to delete a name from the local namespace if it
   occurs as a free variable in a nested block::
@@ -283,41 +446,179 @@
 
   (See :issue:`4617`.)
 
+* The internal :c:type:`structsequence` tool now creates subclasses of tuple.
+  This means that C generated structures like those returned by :func:`os.stat`,
+  :func:`time.gmtime`, and :func:`sys.version_info` now work like a
+  :term:`named tuple` and are more interoperable with functions and methods that
+  expect a tuple as an argument.  The is a big step forward in making the C
+  structures as flexible as their pure Python counterparts.
+
+  (Suggested by Arfrever Frehtes Taifersar Arahesis and implemented
+  by Benjamin Peterson in :issue:`8413`.)
+
+* Warnings are now easier to control.  A :envvar:`PYTHONWARNINGS` environment
+  variable is now available as an alternative to using ``-W`` at the command
+  line.
+
+  (Suggested by Barry Warsaw and implemented by Philip Jenvey in :issue:`7301`.)
+
 * A new warning category, :exc:`ResourceWarning`, has been added.  It is
-  emitted when certain potential issues with resource consumption or cleanup
+  emitted when potential issues with resource consumption or cleanup
   are detected.  It is silenced by default in normal release builds, but
-  can be easily enabled through the means provided by the :mod:`warnings`
+  can be enabled through the means provided by the :mod:`warnings`
   module, or on the command line.
 
-  :exc:`ResourceWarning` is issued at interpreter shutdown if the
+  A :exc:`ResourceWarning` is issued at interpreter shutdown if the
   :data:`gc.garbage` list isn't empty.  This is meant to make the programmer
   aware that their code contains object finalization issues.
 
-  (Added by Antoine Pitrou and Georg Brandl; :issue:`477863`.)
-
-  :exc:`ResourceWarning` is also issued when a :term:`file object` is destroyed
+  A :exc:`ResourceWarning` is also issued when a :term:`file object` is destroyed
   without having been explicitly closed.  While the deallocator for such
   object ensures it closes the underlying operating system resource
   (usually, a file descriptor), the delay in deallocating the object could
   produce various issues, especially under Windows.  Here is an example
   of enabling the warning from the command line::
 
-      $ ./python -Wdefault
-      Python 3.2a3+ (py3k, Nov  5 2010, 22:58:04)
-      [GCC 4.4.3] on linux2
-      Type "help", "copyright", "credits" or "license" for more information.
+      $ ./python -q -Wdefault
       >>> f = open("foo", "wb")
       >>> del f
       __main__:1: ResourceWarning: unclosed file <_io.BufferedWriter name='foo'>
-      >>>
 
-  (Added by Antoine Pitrou, :issue:`10093`.)
+  (Added by Antoine Pitrou and Georg Brandl in :issue:`10093` and :issue:`477863`.)
+
+* :class:`range` objects now support *index* and *count* methods. This is part
+  of an effort to make more objects fully implement the
+  :class:`collections.Sequence` :term:`abstract base class`.  As a result, the
+  language will have a more uniform API.  In addition, :class:`range` objects
+  now support slicing and negative indices.  This makes *range* more
+  interoperable with lists::
+
+      >>> range(0, 100, 2).count(10)
+      1
+      >>> range(0, 100, 2).index(10)
+      5
+      >>> range(0, 100, 2)[5]
+      10
+      >>> range(0, 100, 2)[0:5]
+      range(0, 10, 2)
+
+  (Contributed by Daniel Stuzback in :issue:`9213` and by Alexander Belopolsky
+  in :issue:`2690`.)
+
+* The :func:`callable` builtin function from Py2.x was resurrected.  It provides
+  a concise, readable alternative to using an :term:`abstract base class` in an
+  expression like ``isinstance(x, collections.Callable)``:
+
+  >>> callable(max)
+  True
+  >>> callable(20)
+  False
+
+  (See :issue:`10518`.)
+
+* Python's import mechanism can now load module installed in directories with
+  non-ASCII characters in the path name.
+
+  (Required extensive work by Victor Stinner in :issue:`9425`.)
 
 
 New, Improved, and Deprecated Modules
 =====================================
 
-* XXX mention :mod:`argparse`.
+Python's standard library has undergone significant maintenance efforts and
+quality improvements.
+
+The biggest news for Python 3.2 is that the :mod:`email` package and
+:mod:`nntplib` modules now work correctly with the bytes/text model in Python 3.
+For the first time, there is correct handling of inputs with mixed encodings.
+
+Throughout the standard library, there has been more careful attention to
+encodings and text versus bytes issues.  In particular, interactions with the
+operating system are now better able to pass non-ASCII data using the Windows
+mcbs encoding, locale aware encodings, or UTF-8.
+
+Another significant win is the addition of substantially better support for
+*SSL* connections and security certificates.
+
+In addition, more functions and classes now have a :term:`context manager` to
+support convenient and reliable resource clean-up using the
+:keyword:`with`-statement.
+
+email
+-----
+
+The usability of the :mod:`email` package in Python 3 has been mostly fixed by
+the extensive efforts of R. David Murray.  The problem was that emails are
+typically read and stored in the form of :class:`bytes` rather than :class:`str`
+text, and they may contain multiple encodings within a single email.  So, the
+email package had to be extended to parse and generate email messages in bytes
+format.
+
+* New functions :func:`~email.message_from_bytes` and
+  :func:`~email.message_from_binary_file`, and new classes
+  :class:`~email.parser.BytesFeedParser` and :class:`~email.parser.BytesParser`
+  allow binary message data to be parsed into model objects.
+
+* Given bytes input to the model, :meth:`~email.message.Message.get_payload`
+  will by default decode a message body that has a
+  :mailheader:`Content-Transfer-Encoding` of *8bit* using the charset
+  specified in the MIME headers and return the resulting string.
+
+* Given bytes input to the model, :class:`~email.generator.Generator` will
+  convert message bodies that have a :mailheader:`Content-Transfer-Encoding` of
+  *8bit* to instead have a *7bit* :mailheader:`Content-Transfer-Encoding`.
+
+* A new class :class:`~email.generator.BytesGenerator` produces bytes as output,
+  preserving any unchanged non-ASCII data that was present in the input used to
+  build the model, including message bodies with a
+  :mailheader:`Content-Transfer-Encoding` of *8bit*.
+
+* The :mod:`smtplib` :class:`~smtplib.SMTP` class now accepts a byte string
+  for the *msg* argument to the :meth:`~smtplib.SMTP.sendmail` method,
+  and a new method, :meth:`~smtplib.SMTP.send_message` accepts a
+  :class:`~email.message.Message` object and can optionally obtain the
+  *from_addr* and *to_addrs* addresses directly from the object.
+
+.. XXX Update before 3.2rc1 to reflect all of the latest work and add examples.
+
+(Proposed and implemented by R. David Murray, :issue:`4661` and :issue:`10321`.)
+
+elementtree
+-----------
+
+The :mod:`xml.etree.ElementTree` package and its :mod:`xml.etree.cElementTree`
+counterpart have been updated to version 1.3.
+
+Several new and useful functions and methods have been added:
+
+* :func:`xml.etree.ElementTree.fromstringlist` which builds an XML document
+  from a sequence of fragments
+* :func:`xml.etree.ElementTree.register_namespace` for registering a global
+  namespace prefix
+* :func:`xml.etree.ElementTree.tostringlist` for string representation
+  including all sublists
+* :meth:`xml.etree.ElementTree.Element.extend` for appending a sequence of zero
+  or more elements
+* :meth:`xml.etree.ElementTree.Element.iterfind` searches an element and
+  subelements
+* :meth:`xml.etree.ElementTree.Element.itertext` creates a text iterator over
+  an element and its sub-elements
+* :meth:`xml.etree.ElementTree.TreeBuilder.end` closes the current element
+* :meth:`xml.etree.ElementTree.TreeBuilder.doctype` handles a doctype
+  declaration
+
+Two methods have been deprecated:
+
+* :meth:`xml.etree.ElementTree.getchildren` use ``list(elem)`` instead.
+* :meth:`xml.etree.ElementTree.getiterator` use ``Element.iter`` instead.
+
+For details of the update, see `Introducing ElementTree
+<http://effbot.org/zone/elementtree-13-intro.htm>`_ on Fredrik Lundh's website.
+
+(Contributed by Florent Xicluna and Fredrik Lundh, :issue:`6472`.)
+
+functools
+---------
 
 * The :mod:`functools` module includes a new decorator for caching function
   calls.  :func:`functools.lru_cache` can save repeated queries to an external
@@ -332,20 +633,22 @@
          c.execute('SELECT phonenumber FROM phonelist WHERE name=?', (name,))
          return c.fetchone()[0]
 
+  >>> for name in user_requests:
+  ...     get_phone_number(name)        # cached lookup
+
   To help with choosing an effective cache size, the wrapped function is
-  instrumented with two attributes *cache_hits* and *cache_misses*:
+  instrumented for tracking cache statistics:
 
-  >>> for name in user_requests:
-  ...     get_phone_number(name)
-  >>> print(get_phone_number.cache_hits, get_phone_number.cache_misses)
-  4805 980
+  >>> get_phone_number.cache_info()
+  CacheInfo(hits=4805, misses=980, maxsize=300, currsize=300)
 
   If the phonelist table gets updated, the outdated contents of the cache can be
   cleared with:
 
   >>> get_phone_number.cache_clear()
 
-  (Contributed by Raymond Hettinger.)
+  (Contributed by Raymond Hettinger and incorporating design ideas from
+  Jim Baker, Miki Tebeka, and Nick Coghlan.)
 
 * The :func:`functools.wraps` decorator now adds a :attr:`__wrapped__` attribute
   pointing to the original callable function.  This allows wrapped functions to
@@ -356,76 +659,312 @@
   (By Nick Coghlan and Terrence Cole; :issue:`9567`, :issue:`3445`, and
   :issue:`8814`.)
 
-* The :mod:`nntplib` module gets a revamped implementation with better
-  bytes / unicode semantics as well as more practical APIs.  These improvements
-  break compatibility with the nntplib version in Python 3.1, which was
-  partly dysfunctional in itself.
+* To help write classes with rich comparison methods, a new decorator
+  :func:`functools.total_ordering` will use a existing equality and inequality
+  methods to fill-in the remaining methods.
+
+  For example, supplying *__eq__* and *__lt__* will enable
+  :func:`~functools.total_ordering` to fill-in *__le__*, *__gt__* and *__ge__*::
+
+    @total_ordering
+    class Student:
+        def __eq__(self, other):
+            return ((self.lastname.lower(), self.firstname.lower()) ==
+                    (other.lastname.lower(), other.firstname.lower()))
+        def __lt__(self, other):
+            return ((self.lastname.lower(), self.firstname.lower()) <
+                    (other.lastname.lower(), other.firstname.lower()))
 
-  (Contributed by Antoine Pitrou in :issue:`9360`)
+  (Contributed by Raymond Hettinger.)
 
-* The :mod:`abc` module now supports :func:`~abc.abstractclassmethod` and
-  :func:`~abc.abstractstaticmethod`.
+.. XXX clarify what the example does
 
-  (Patch submitted by Daniel Urban; :issue:`5867`.)
+* To aid in porting programs from Python 2, the :func:`~functools.cmp_to_key`
+  function converts an old-style comparison function to
+  modern :term:`key function`:
 
-* The previously deprecated :func:`contextlib.nested` function has been removed
-  in favor of a plain :keyword:`with` statement which can accept multiple
-  context managers.  The latter technique is faster (because it is built-in),
-  and it does a better job finalizing multiple context managers when one of them
-  raises an exception.
+  >>> # locale-aware sort order
+  >>> sorted(iterable, key=cmp_to_key(locale.strcoll))
 
-  (Contributed by Georg Brandl and Mattias Brändström;
-  `appspot issue 53094 <http://codereview.appspot.com/53094>`_.)
+  For sorting examples and a brief sorting tutorial, see the `Sorting HowTo
+  <http://wiki.python.org/moin/HowTo/Sorting/>`_ tutorial.
+
+  (Contributed by Raymond Hettinger.)
+
+itertools
+---------
+
+* The :mod:`itertools` module has a new :func:`~itertools.accumulate` function
+  modeled on APL's *scan* operator and on Numpy's *accumulate* function:
+
+  >>> list(accumulate(8, 2, 50))
+  [8, 10, 60]
+
+  >>> prob_dist = [0.1, 0.4, 0.2, 0.3]
+  >>> list(accumulate(prob_dist))      # cumulative probability distribution
+  [0.1, 0.5, 0.7, 1.0]
+
+  For an example using :func:`~itertools.accumulate`, see the :ref:`examples for
+  the random module <random-examples>`.
+
+  (Contributed by Raymond Hettinger and incorporating design suggestions
+  from Mark Dickinson.)
+
+collections
+-----------
+
+* The :class:`collections.Counter` class now has two forms of in-place
+  subtraction, the existing *-=* operator for `saturating subtraction
+  <http://en.wikipedia.org/wiki/Saturation_arithmetic>`_ and the new
+  :meth:`~collections.Counter.subtract` method for regular subtraction.  The
+  former is suitable for `multisets <http://en.wikipedia.org/wiki/Multiset>`_
+  which only have positive counts, and the latter is more suitable for use cases
+  that allow negative counts:
+
+  >>> tally = Counter(dogs=5, cat=3)
+  >>> tally -= Counter(dogs=2, cats=8)    # saturating subtraction
+  >>> tally
+  Counter({'dogs': 3})
+
+  >>> tally = Counter(dogs=5, cats=3)
+  >>> tally.subtract(dogs=2, cats=8)      # regular subtraction
+  >>> tally
+  Counter({'dogs': 3, 'cats': -5})
+
+  (Contributed by Raymond Hettinger.)
+
+* The :class:`collections.OrderedDict` class has a new method
+  :meth:`~collections.OrderedDict.move_to_end` which takes an existing key and
+  moves it to either the beginning or end of an ordered sequence.  When the
+  dictionary sequence is being used as a queue, these operations correspond to
+  "move to the front of the line" or "move to the back of the line":
+
+  >>> d = OrderedDict.fromkeys(['a', 'b', 'X', 'd', 'e'])
+  >>> list(d)
+  ['a', 'b', 'X', 'd', 'e']
+  >>> d.move_to_end('X', last=True)
+  >>> list(d)
+  ['a', 'b', 'd', 'e', 'X']
+  >>> d.move_to_end('X', last=False)
+  >>> list(d)
+  ['X', 'a', 'b', 'd', 'e']
+
+  (Contributed by Raymond Hettinger.)
+
+* The :class:`collections.deque` grew two new methods :meth:`~collections.deque.count`
+  and :meth:`collections.deque.reverse` that make them more substitutable for
+  :class:`list` when needed:
+
+  >>> d = deque('simsalabim')
+  >>> d.count('s')
+  2
+  >>> d.reverse()
+  >>> d
+  deque(['m', 'i', 'b', 'a', 'l', 'a', 's', 'm', 'i', 's'])
+
+  (Contributed by Raymond Hettinger.)
+
+datetime
+--------
+
+* The :mod:`datetime` module has a new type :class:`~datetime.timezone` that
+  implements the :class:`~datetime.tzinfo` interface by returning a fixed UTC
+  offset and timezone name. This makes it easier to create timezone aware
+  datetime objects:
+
+  >>> datetime.now(timezone.utc)
+  datetime.datetime(2010, 12, 8, 21, 4, 2, 923754, tzinfo=datetime.timezone.utc)
+
+  >>> datetime.strptime("01/01/2000 12:00 +0000", "%m/%d/%Y %H:%M %z")
+  datetime.datetime(2000, 1, 1, 12, 0, tzinfo=datetime.timezone.utc)
+
+* Also, :class:`~datetime.timedelta` objects can now be multiplied by
+  :class:`float` and divided by :class:`float` and :class:`int` objects.
+
+.. XXX Describe added support for dividing a timedelta by another timedelta.
+       See revision 80290 and issue #2706.
+
+  (Contributed by Alexander Belopolsky in :issue:`1289118`, :issue:`5094` and
+  :issue:`6641`.)
+
+abc
+---
+
+The :mod:`abc` module now supports :func:`~abc.abstractclassmethod` and
+:func:`~abc.abstractstaticmethod`.
+
+These tools make it possible to define an :term:`Abstract Base Class` that
+requires a particular :func:`classmethod` or :func:`staticmethod` to be
+implemented.
+
+(Patch submitted by Daniel Urban; :issue:`5867`.)
+
+contextlib
+----------
 
-* The :class:`ftplib.FTP` class now supports the context manager protocol to
-  unconditionally consume :exc:`socket.error` exceptions and to close the FTP
-  connection when done::
+There is a new and slightly mind-blowing tool
+:class:`~contextlib.ContextDecorator` that is helpful for creating a
+:term:`context manager` that does double-duty as a function decorator.
 
-   >>> from ftplib import FTP
-   >>> with FTP("ftp1.at.proftpd.org") as ftp:
-   ...     ftp.login()
-   ...     ftp.dir()
-   ...
-   '230 Anonymous login ok, restrictions apply.'
-   dr-xr-xr-x   9 ftp      ftp           154 May  6 10:43 .
-   dr-xr-xr-x   9 ftp      ftp           154 May  6 10:43 ..
-   dr-xr-xr-x   5 ftp      ftp          4096 May  6 10:43 CentOS
-   dr-xr-xr-x   3 ftp      ftp            18 Jul 10  2008 Fedora
+As a convenience, this new functionality is used by
+:func:`~contextlib.contextmanager` so that no extra effort is needed to support
+both roles.
 
-  Other file-like objects such as :class:`mmap.mmap` and :func:`fileinput.input`
-  also grew auto-closing context managers::
+The basic idea is that both context managers and function decorators can be used
+for pre-action and post-action wrappers.  Context managers wrap a group of
+statements using the :keyword:`with`-statement, and function decorators wrap a
+group of statements enclosed in a function.  So, occasionally there is a need to
+write a pre/post action wrapper that can be used in either role.
 
-      with fileinput.input(files=('log1.txt', 'log2.txt')) as f:
-          for line in f:
-              process(line)
+For example, it is sometimes useful to wrap functions or groups of statements
+with a logger that can track the time of entry and time of exit.  Rather than
+writing both a function decorator and a context manager for the task, the
+:func:`~contextlib.contextmanager` provides both capabilities in a single
+definition:
 
-  (Contributed by Tarek Ziadé and Giampaolo Rodolà in :issue:`4972`, and
-  by Georg Brandl in :issue:`8046` and :issue:`1286`.)
+>>> import logging
+>>> logging.basicConfig(level=logging.INFO)
+>>> @contextmanager
+... def track_entry_and_exit(name):
+...     logging.info('Entering: {}'.format(name))
+...     yield
+...     logging.info('Exiting: {}'.format(name))
 
-* :class:`gzip.GzipFile` now implements the :class:`io.BufferedIOBase` ABC
-  (except for ``truncate()``), has a :meth:`~gzip.GzipFile.peek` method,
-  and supports unseekable as well as zero-padded file objects.
+Formerly, this would have only been usable as a context manager:
 
-  (Contributed by Antoine Pitrou, Nir Aides and Brian Curtin in :issue:`9962`,
-  :issue:`1675951`, :issue:`7471` and :issue:`2846`.)
+>>> with track_entry_and_exit('widget loader'):
+...     print('Some time consuming activity goes here')
+...     load_widget()
 
-  The :mod:`gzip` module also gains the :func:`~gzip.compress` and
-  :func:`~gzip.decompress` functions for easier in-memory compression and
-  decompression.
+Now, it can be used as a decorator as well:
 
-  (Contributed by Anand B. Pillai in :issue:`3488`.)
+>>> @track_entry_and_exit('widget loader')
+... def activity():
+...     print('Some time consuming activity goes here')
+...     load_widget()
 
-* The :mod:`os` module now has the :const:`ST_RDONLY` and :const:`ST_NOSUID`
-  constants, for use with the :func:`~os.statvfs` function.
+Trying to fulfill two roles at once places some limitations on the technique.
+Context managers normally have the flexibility to return an argument usable by
+the :keyword:`with`-statement, but there is no parallel for function decorators.
 
-  (Patch by Adam Jackson; :issue:`7647`.)
+In the above example, there is not a clean way for the *track_entry_and_exit*
+context manager does not have a way to return a logging instance for use in the
+body of enclosed statements.
 
-* :func:`os.getppid` is now supported on Windows.  Note that it will continue to
-  return the same pid even after the parent process has exited.
+(Contributed by Michael Foord in :issue:`9110`.)
 
-  (Patch by Jon Anglin; :issue:`6394`.)
+decimal and fractions
+---------------------
 
-* The :func:`shutil.copytree` function has two new options:
+Mark Dickinson crafted an elegant and efficient scheme for assuring that
+different numeric datatypes will have the same hash value whenever their actual
+values are equal (:issue:`8188`)::
+
+   >>> assert hash(Fraction(3, 2)) == hash(1.5) == \
+              hash(Decimal("1.5")) == hash(complex(1.5, 0))
+
+An early decision to limit the inter-operability of various numeric types has
+been relaxed.  It is still unsupported (and ill-advised) to to have implicit
+mixing in arithmetic expressions such as ``Decimal('1.1') + float('1.1')``
+because the latter loses information in the process of constructing the binary
+float.  However, since existing floating point value can be converted losslessly
+to either a decimal or rational representation, it makes sense to add them to
+the constructor and to support mixed-type comparisons.
+
+* The :class:`decimal.Decimal` constructor now accepts :class:`float` objects
+  directly so there in no longer a need to use the :meth:`~decimal.Decimal.from_float`
+  method (:issue:`8257`).
+
+* Mixed type comparisons are now fully supported so that
+  :class:`~decimal.Decimal` objects can be directly compared with :class:`float`
+  and :class:`fractions.Fraction` (:issue:`2531` and :issue:`8188`).
+
+Similar changes were made to :class:`fractions.Fraction` so that the
+:meth:`~fractions.Fraction.from_float()` and :meth:`~fractions.Fraction.from_decimal`
+methods are no longer needed (:issue:`8294`):
+
+>>> Decimal(1.1)
+Decimal('1.100000000000000088817841970012523233890533447265625')
+>>> Fraction(1.1)
+Fraction(2476979795053773, 2251799813685248)
+
+Another useful change for the :mod:`decimal` module is that the
+:attr:`Context.clamp` attribute is now public.  This is useful in creating
+contexts that correspond to the decimal interchange formats specified in IEEE
+754 (see :issue:`8540`).
+
+(Contributed by Mark Dickinson and Raymond Hettinger.)
+
+ftp
+---
+
+The :class:`ftplib.FTP` class now supports the context manager protocol to
+unconditionally consume :exc:`socket.error` exceptions and to close the FTP
+connection when done::
+
+ >>> from ftplib import FTP
+ >>> with FTP("ftp1.at.proftpd.org") as ftp:
+ ...     ftp.login()
+ ...     ftp.dir()
+ ...
+ '230 Anonymous login ok, restrictions apply.'
+ dr-xr-xr-x   9 ftp      ftp           154 May  6 10:43 .
+ dr-xr-xr-x   9 ftp      ftp           154 May  6 10:43 ..
+ dr-xr-xr-x   5 ftp      ftp          4096 May  6 10:43 CentOS
+ dr-xr-xr-x   3 ftp      ftp            18 Jul 10  2008 Fedora
+
+Other file-like objects such as :class:`mmap.mmap` and :func:`fileinput.input`
+also grew auto-closing context managers::
+
+    with fileinput.input(files=('log1.txt', 'log2.txt')) as f:
+        for line in f:
+            process(line)
+
+(Contributed by Tarek Ziadé and Giampaolo Rodolà in :issue:`4972`, and
+by Georg Brandl in :issue:`8046` and :issue:`1286`.)
+
+.. XXX mention os.popen and subprocess.Popen auto-closing of fds
+
+gzip and zipfile
+----------------
+
+:class:`gzip.GzipFile` now implements the :class:`io.BufferedIOBase`
+:term:`abstract base class` (except for ``truncate()``).  It also has a
+:meth:`~gzip.GzipFile.peek` method and supports unseekable as well as
+zero-padded file objects.
+
+The :mod:`gzip` module also gains the :func:`~gzip.compress` and
+:func:`~gzip.decompress` functions for easier in-memory compression and
+decompression.  Keep in mind that text needs to be encoded in to :class:`bytes`
+before compressing and decompressing:
+
+>>> s = 'Three shall be the number thou shalt count, '
+>>> s += 'and the number of the counting shall be three'
+>>> b = s.encode()                        # convert to utf-8
+>>> len(b)
+89
+>>> c = gzip.compress(b)
+>>> len(c)
+77
+>>> gzip.decompress(c).decode()[:42]      # decompress and convert to text
+'Three shall be the number thou shalt count,'
+
+(Contributed by Anand B. Pillai in :issue:`3488`; and by Antoine Pitrou, Nir
+Aides and Brian Curtin in :issue:`9962`, :issue:`1675951`, :issue:`7471` and
+:issue:`2846`.)
+
+Also, the :class:`zipfile.ZipExtFile` class was reworked internally to represent
+files stored inside an archive.  The new implementation is significantly faster
+and can be wrapped in a :class:`io.BufferedReader` object for more speedups.  It
+also solves an issue where interleaved calls to *read* and *readline* gave the
+wrong results.
+
+(Patch submitted by by Nir Aides in :issue:`7610`.)
+
+shutil
+------
+
+The :func:`shutil.copytree` function has two new options:
 
   * *ignore_dangling_symlinks*: when ``symlinks=False`` so that the function
     copies the file pointed to by the symlink, not the symlink itself. This
@@ -434,25 +973,40 @@
   * *copy_function*: is a callable that will be used to copy files.
     :func:`shutil.copy2` is used by default.
 
-  (Contributed by Tarek Ziadé.)
+(Contributed by Tarek Ziadé.)
+
+sqlite3
+-------
+
+The :mod:`sqlite3` module was updated to version 2.6.0.  It has two new capabilities.
+
+* The :attr:`sqlite3.Connection.in_transit` attribute is true if there is an
+  active transaction for uncommitted changes.
+
+* The :meth:`sqlite3.Connection.enable_load_extension` and
+  :meth:`sqlite3.Connection.load_extension` methods allows you to load SQLite
+  extensions from ".so" files.  One well-known extension is the fulltext-search
+  extension distributed with SQLite.
+
+(Contributed by R. David Murray and Shashwat Anand; :issue:`8845`.)
+
+socket
+------
+
+The :mod:`socket` module has two new improvements.
 
 * Socket objects now have a :meth:`~socket.socket.detach()` method which puts
   the socket into closed state without actually closing the underlying file
   descriptor.  The latter can then be reused for other purposes.
-
   (Added by Antoine Pitrou; :issue:`8524`.)
 
-* The :mod:`sqlite3` module has two new capabilities.
-
-  The :attr:`Connection.in_transit` attribute is true if there is an active
-  transaction for uncommitted changes.
-
-  The :meth:`Connection.enable_load_extension` and
-  :meth:`Connection.load_extension` methods allows you to load SQLite extensions
-  from ".so" files.  One well-known extension is the fulltext-search extension
-  distributed with SQLite.
+* :func:`socket.create_connection` now supports the context manager protocol
+  to unconditionally consume :exc:`socket.error` exceptions and to close the
+  socket when done.
+  (Contributed by Giampaolo Rodolà; :issue:`9794`.)
 
-  (Contributed by R. David Murray and Shashwat Anand; :issue:`8845`.)
+ssl
+---
 
 * The :mod:`ssl` module has a new class, :class:`~ssl.SSLContext` which serves
   as a container for various persistent SSL data, such as protocol settings,
@@ -460,18 +1014,18 @@
   :meth:`~ssl.SSLContext.wrap_socket` method allows to create an SSL socket from
   such an SSL context.  (Added by Antoine Pitrou; :issue:`8550`.)
 
-  A new function, :func:`ssl.match_hostname`, helps implement server identity
+* A new function, :func:`ssl.match_hostname`, helps implement server identity
   verification for higher-level protocols by implementing the rules of
   HTTPS (from :rfc:`2818`), which are also suitable for other protocols.
   (Added by Antoine Pitrou, :issue:`1589`).
 
-  The :func:`ssl.wrap_socket` constructor function now takes a *ciphers*
+* The :func:`ssl.wrap_socket` constructor function now takes a *ciphers*
   argument that's a string listing the encryption algorithms to be allowed; the
   format of the string is described `in the OpenSSL documentation
   <http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT>`__.  (Added
   by Antoine Pitrou; :issue:`8322`.)
 
-  When linked against a recent enough version of OpenSSL, the :mod:`ssl`
+* When linked against a recent enough version of OpenSSL, the :mod:`ssl`
   module now supports the Server Name Indication extension to the TLS
   protocol, allowing for several "virtual hosts" using different certificates
   on a single IP/port.  This extension is only supported in client mode,
@@ -479,43 +1033,117 @@
   :meth:`SSLContext.wrap_socket`.
   (Added by Antoine Pitrou, :issue:`5639`.)
 
-  Various options have been added to the :mod:`ssl` module, such as
+* Various options have been added to the :mod:`ssl` module, such as
   :data:`~ssl.OP_NO_SSLv2` which allows to force disabling of the insecure and
   obsolete SSLv2 protocol.  (Added by Antoine Pitrou; :issue:`4870`.)
 
-  Another change makes the extension load all of OpenSSL's ciphers and digest
+* Another change makes the extension load all of OpenSSL's ciphers and digest
   algorithms so that they're all available.  Some SSL certificates couldn't be
   verified, reporting an "unknown algorithm" error.  (Reported by Beda Kosata,
   and fixed by Antoine Pitrou; :issue:`8484`.)
 
-  The version of OpenSSL being used is now available as the module attributes
+* The version of OpenSSL being used is now available as the module attributes
   :data:`ssl.OPENSSL_VERSION` (a string), :data:`ssl.OPENSSL_VERSION_INFO` (a
   5-tuple), and :data:`ssl.OPENSSL_VERSION_NUMBER` (an integer).  (Added by
   Antoine Pitrou; :issue:`8321`.)
 
-* :class:`http.client.HTTPSConnection`, :class:`urllib.request.HTTPSHandler`
-  and :func:`urllib.request.urlopen` now take optional arguments to allow for
-  server certificate checking against a set of Certificate Authorities,
-  as recommended in public uses of HTTPS.
-  (Added by Antoine Pitrou, :issue:`9003`.)
-
-* Instances of :class:`unittest.TestCase` have two new methods
-  :meth:`~unittest.TestCase.assertWarns` and :meth:`~unittest.TestCase.assertWarnsRegexp`
-  to check that a given warning type was triggered by the code under test::
-
-      with self.assertWarns(DeprecationWarning):
-          legacy_function('XYZ')
+nntp
+----
 
+The :mod:`nntplib` module has a revamped implementation with better bytes and
+unicode semantics as well as more practical APIs.  These improvements break
+compatibility with the nntplib version in Python 3.1, which was partly
+dysfunctional in itself.
+
+(Contributed by Antoine Pitrou in :issue:`9360`)
+
+certificates
+------------
+
+:class:`http.client.HTTPSConnection`, :class:`urllib.request.HTTPSHandler`
+and :func:`urllib.request.urlopen` now take optional arguments to allow for
+server certificate checking against a set of Certificate Authorities,
+as recommended in public uses of HTTPS.
+
+(Added by Antoine Pitrou, :issue:`9003`.)
+
+unittest
+--------
+
+* The command-line call, ``python -m unittest`` can now accept file paths
+  instead of module names for running specific tests (:issue:`10620`).  The new
+  test discovery can find tests within packages, locating any test importable
+  from the top level directory.  The top level directory can be specified with
+  the `-t` option, a pattern for matching files with ``-p``, and a directory to
+  start discovery with ``-s``::
+
+    $ python -m unittest discover -s my_proj_dir -p '_test.py'
+
+  (Contributed by Michael Foord.)
+
+* The :mod:`unittest` module has two new methods,
+  :meth:`~unittest.TestCase.assertWarns` and
+  :meth:`~unittest.TestCase.assertWarnsRegex` to check that a given warning type
+  is triggered by the code under test:
+
+  >>> with self.assertWarns(DeprecationWarning):
+  ...     legacy_function('XYZ')
+
+  Another new method, :meth:`~unittest.TestCase.assertCountEqual` is used to
+  compare two iterables to determine if their element counts are equal (whether
+  the same elements are present with the same number of occurrences regardless
+  of order)::
+
+     def test_anagram(self):
+         self.assertCountEqual('algorithm', 'logarithm')
+
+  A principal feature of the unittest module is an effort to produce meaningful
+  diagnostics when a test fails.  When possible the failure is recorded along
+  with a diff of the output.  This is especially helpful for analyzing log files
+  of failed test runs. However, since diffs can sometime be voluminous, there is
+  a new :attr:`~unittest.TestCase.maxDiff` attribute which sets maximum length of
+  diffs.
+
+  In addition the naming in the module has undergone a number of clean-ups.  For
+  example, :meth:`~unittest.TestCase.assertRegex` is the new name for
+  :meth:`~unittest.TestCase.assertRegexpMatches` which was misnamed because the
+  test uses :func:`re.search`, not :func:`re.match`.  Other methods using
+  regular expressions are now named using short form "Regex" in preference
+  to "Regexp" -- this matches the names used in other unittest implementations,
+  matches Python's old name for the :mod:`re` module, and it has unambiguous
+  camel-casing.
+
+  To improve consistency, some of long-standing method aliases are being
+  deprecated in favor of the preferred names:
+
+   - replace :meth:`assert_` with :meth:`.assertTrue`
+   - replace :meth:`assertEquals` with :meth:`.assertEqual`
+   - replace :meth:`assertNotEquals` with :meth:`.assertNotEqual`
+   - replace :meth:`assertAlmostEquals` with :meth:`.assertAlmostEqual`
+   - replace :meth:`assertNotAlmostEquals` with :meth:`.assertNotAlmostEqual`
+
+  Likewise, the ``TestCase.fail*`` methods deprecated in Python 3.1 are expected
+  to be removed in Python 3.3. See also the :ref:`deprecated-aliases` section in
+  the :mod:`unittest` documentation.
+
+  (Contributed by Ezio Melotti; :issue:`9424`.)
+
+random
+------
+
+The integer methods in the :mod:`random` module now do a better job of producing
+uniform distributions.  Previously, they computed selections with
+``int(n*random())`` which had a slight bias whenever *n* was not a power of two.
+Now, multiple selections are made from a range upto the next power of two and a
+selection is kept only when it falls within the range ``0 <= x < n``.  The
+functions and methods affected are :func:`~random.randrange`,
+:func:`~random.randint`, :func:`~random.choice`, :func:`~random.shuffle` and
+:func:`~random.sample`.
 
-* The previously deprecated :func:`string.maketrans` function has been removed
-  in favor of the static methods, :meth:`bytes.maketrans` and
-  :meth:`bytearray.maketrans`.  This change solves the confusion around which
-  types were supported by the :mod:`string` module.  Now, :class:`str`,
-  :class:`bytes`, and :class:`bytearray` each have their own **maketrans** and
-  **translate** methods with intermediate translation tables of the appropriate
-  type.
+(Contributed by Raymond Hettinger; :issue:`9025`.)
 
-  (Contributed by Georg Brandl; :issue:`5675`.)
+poplib
+------
 
 * :class:`~poplib.POP3_SSL` class now accepts a *context* parameter, which is a
   :class:`ssl.SSLContext` object allowing bundling SSL configuration options,
@@ -524,12 +1152,6 @@
 
   (Contributed by Giampaolo Rodolà; :issue:`8807`.)
 
-* :func:`socket.create_connection` now supports the context manager protocol
-  to unconditionally consume :exc:`socket.error` exceptions and to close the
-  socket when done.
-
-  (Contributed by Giampaolo Rodolà; :issue:`9794`.)
-
 * :class:`asyncore.dispatcher` now provides a
   :meth:`~asyncore.dispatcher.handle_accepted()` method
   returning a `(sock, addr)` pair which is called when a connection has actually
@@ -539,28 +1161,208 @@
 
   (Contributed by Giampaolo Rodolà; :issue:`6706`.)
 
-* The :mod:`tempfile` module has a new context manager,
-  :class:`~tempfile.TemporaryDirectory` which provides easy deterministic
-  cleanup of temporary directories.
-
-  (Contributed by Neil Schemenauer and Nick Coghlan; :issue:`5178`.)
-
-* The :mod:`smtplib` :class:`~smtplib.SMTP` class now accepts a byte string
-  for the *msg* argument to the :meth:`~smtplib.SMTP.sendmail` method,
-  and a new method, :meth:`~smtplib.SMTP.send_message` accepts a
-  :class:`~email.message.Message` object and can optionally obtain the
-  *from_addr* and *to_addrs* addresses directly from the object.
-
-  (Contributed by R. David Murray, :issue:`10321`.)
+tempfile
+--------
 
-
-* The :mod:`inspect` module has a new function :func:`getgenatorstate`
-  to easily identify the current state of a generator as one of
-  ``GEN_CREATED``, ``GEN_RUNNING``, ``GEN_SUSPENDED`` or ``GEN_CLOSED``.
-
-  (Contributed by Rodolpho Eckhardt and Nick Coghlan, :issue:`10220`.)
-
-.. XXX: Mention inspect.getattr_static (Michael Foord)
+The :mod:`tempfile` module has a new context manager,
+:class:`~tempfile.TemporaryDirectory` which provides easy deterministic
+cleanup of temporary directories:
+
+>>> with tempfile.TemporaryDirectory() as tmpdirname:
+...     print 'created temporary directory', tmpdirname
+
+(Contributed by Neil Schemenauer and Nick Coghlan; :issue:`5178`.)
+
+inspect
+-------
+
+* The :mod:`inspect` module has a new function
+  :func:`~inspect.getgeneratorstate` to easily identify the current state of a
+  generator as one of ``GEN_CREATED``, ``GEN_RUNNING``, ``GEN_SUSPENDED`` or
+  ``GEN_CLOSED``. (Contributed by Rodolpho Eckhardt and Nick Coghlan,
+  :issue:`10220`.)
+
+* To support lookups without the possibility of activating a dynamic attribute,
+  the :mod:`inspect` module has a new function, :func:`~inspect.getattr_static`.
+  Unlike, :func:`hasattr`, this is a true read-only search, guaranteed not to
+  change state while it is searching.  (Contributed by Michael Foord.)
+
+pydoc
+-----
+
+The :mod:`pydoc` module now provides a much improved Web server interface,
+as well as a new command-line option to automatically open a browser
+window to display that server.
+
+(Contributed by Ron Adam; :issue:`2001`.)
+
+sysconfig
+---------
+
+The new :mod:`sysconfig` module makes it straight-forward to discover
+installation paths and configuration variables which vary across platforms and
+installations.
+
+The module offers access simple access functions for platform and version
+information:
+
+* :func:`~sysconfig.get_platform` returning values like *linux-i586* or
+  *macosx-10.6-ppc*.
+* :func:`~sysconfig.get_python_version` returns a Python version string in
+  the form, "3.2".
+
+It also provides access to the paths and variables corresponding to one of
+seven named schemes used by :mod:`distutils`.  Those include *posix_prefix*,
+*posix_home*, *posix_user*, *nt*, *nt_user*, *os2*, *os2_home*:
+
+* :func:`~sysconfig.get_paths` makes a dictionary containing installation paths
+  for the current installation scheme.
+* :func:`~sysconfig.get_config_vars` returns a dictionary of platform specific
+  variables.
+
+There is also a convenient command-line interface::
+
+  C:\Python32>python -m sysconfig
+  Platform: "win32"
+  Python version: "3.2"
+  Current installation scheme: "nt"
+
+  Paths:
+          data = "C:\Python32"
+          include = "C:\Python32\Include"
+          platinclude = "C:\Python32\Include"
+          platlib = "C:\Python32\Lib\site-packages"
+          platstdlib = "C:\Python32\Lib"
+          purelib = "C:\Python32\Lib\site-packages"
+          scripts = "C:\Python32\Scripts"
+          stdlib = "C:\Python32\Lib"
+
+  Variables:
+          BINDIR = "C:\Python32"
+          BINLIBDEST = "C:\Python32\Lib"
+          EXE = ".exe"
+          INCLUDEPY = "C:\Python32\Include"
+          LIBDEST = "C:\Python32\Lib"
+          SO = ".pyd"
+          VERSION = "32"
+          abiflags = ""
+          base = "C:\Python32"
+          exec_prefix = "C:\Python32"
+          platbase = "C:\Python32"
+          prefix = "C:\Python32"
+          projectbase = "C:\Python32"
+          py_version = "3.2"
+          py_version_nodot = "32"
+          py_version_short = "3.2"
+          srcdir = "C:\Python32"
+          userbase = "C:\Documents and Settings\Raymond\Application Data\Python"
+
+pdb
+---
+
+The :mod:`pdb` debugger module gained a number of usability improvements:
+
+* :file:`pdb.py` now has a ``-c`` option that executes commands as given in a
+  :file:`.pdbrc` script file.
+* A :file:`.pdbrc` script file can contain ``continue`` and ``next`` commands
+  that continue debugging.
+* The :class:`Pdb` class constructor now accepts a *nosigint* argument.
+* new commands: ``l(list)``, ``ll(long list`` and ``source`` for
+  listing source code.
+* new commands: ``display`` and ``undisplay`` for showing or hiding
+  the value of an expression if it has changed.
+* new command: ``interact`` for starting an interactive interpreter containing
+  the global and local  names found in the current scope.
+* breakpoints can be cleared by breakpoint number
+
+(Contributed by Georg Brandl, Antonio Cuni and Ilya Sandler.)
+
+configparser
+------------
+
+The :mod:`configparser` module was modified to improve usability and
+predictability of the default parser and its supported INI syntax.  The old
+:class:`ConfigParser` class was removed in favor of :class:`SafeConfigParser`
+which has in turn been renamed to :class:`~configparser.ConfigParser`. Support
+for inline comments is now turned off by default and section or option
+duplicates are not allowed in a single configuration source.
+
+Config parsers gained a new API based on the mapping protocol::
+
+  >>> parser = ConfigParser()
+  >>> parser.read_string("""
+  ... [DEFAULT]
+  ... monty = python
+  ...
+  ... [phrases]
+  ... the = who
+  ... full = metal jacket
+  ... """)
+  >>> parser['phrases']['full']
+  'metal jacket'
+  >>> section = parser['phrases']
+  >>> section['the']
+  'who'
+  >>> section['british'] = '%(the)s %(full)s %(monty)s!'
+  >>> parser['phrases']['british']
+  'who metal jacket python!'
+  >>> 'british' in section
+  True
+
+The new API is implemented on top of the classical API so custom parser
+subclasses should be able to use it without modifications.
+
+The INI file structure accepted by config parsers can now be customized. Users
+can specify alternative option/value delimiters and comment prefixes, change the
+name of the *DEFAULT* section or switch the interpolation syntax.  Along with
+support for pluggable interpolation, an additional interpolation handler
+:class:`~configparser.ExtendedInterpolation` was introduced::
+
+  >>> parser = ConfigParser(interpolation=ExtendedInterpolation())
+  >>> parser.read_dict({'buildout': {'directory': '/home/ambv/zope9'},
+  ...                   'custom': {'prefix': '/usr/local'}})
+  >>> parser.read_string("""
+  ... [buildout]
+  ... parts =
+  ...   zope9
+  ...   instance
+  ... find-links =
+  ...   ${buildout:directory}/downloads/dist
+  ...
+  ... [zope9]
+  ... recipe = plone.recipe.zope9install
+  ... location = /opt/zope
+  ...
+  ... [instance]
+  ... recipe = plone.recipe.zope9instance
+  ... zope9-location = ${zope9:location}
+  ... zope-conf = ${custom:prefix}/etc/zope.conf
+  ... """)
+  >>> parser['buildout']['find-links']
+  '\n/home/ambv/zope9/downloads/dist'
+  >>> parser['instance']['zope-conf']
+  '/usr/local/etc/zope.conf'
+  >>> instance = parser['instance']
+  >>> instance['zope-conf']
+  '/usr/local/etc/zope.conf'
+  >>> instance['zope9-location']
+  '/opt/zope'
+
+A number of smaller features were also introduced, like support for specifying
+encoding in read operations, specifying fallback values for get-functions, or
+reading directly from dictionaries and strings.
+
+(All changes contributed by Łukasz Langa.)
+
+.. XXX: Mention urllib.parse changes
+          Issue 9873 (Nick Coghlan):
+            - ASCII byte sequence support in URL parsing
+            - named tuple for urldefrag return value
+          Issue 5468 (Dan Mahn) for urlencode:
+            - bytes input support
+            - non-UTF8 percent encoding of non-ASCII characters
+          Issue 2987 for IPv6 (RFC2732) support in urlparse
+.. XXX: Any updates to the WSGI bytes versus text problem?
 
 Multi-threading
 ===============
@@ -582,34 +1384,24 @@
 
   (Contributed by Antoine Pitrou.)
 
-* Recursive locks (created with the :func:`threading.RLock` API) now benefit
-  from a C implementation which makes them as fast as regular locks, and between
-  10x and 15x faster than their previous pure Python implementation.
-
-  (Contributed by Antoine Pitrou; :issue:`3001`.)
-
 * Regular and recursive locks now accept an optional *timeout* argument to their
   :meth:`acquire` method.  (Contributed by Antoine Pitrou; :issue:`7316`.)
 
-  Similarly, :meth:`threading.Semaphore.acquire` also gains a *timeout*
+* Similarly, :meth:`threading.Semaphore.acquire` also gained a *timeout*
   argument.  (Contributed by Torsten Landschoff; :issue:`850728`.)
 
+* Regular and recursive lock acquisitions can now be interrupted by signals on
+  platforms using pthreads.  This means that Python programs that deadlock while
+  acquiring locks can be successfully killed by repeatedly sending SIGINT to the
+  process (by pressing :kbd:`Ctrl+C` in most shells).
+  (Contributed by Reid Kleckner; :issue:`8844`.)
+
 
 Optimizations
 =============
 
 A number of small performance enhancements have been added:
 
-* JSON decoding performance is improved and memory consumption is reduced
-  whenever the same string is repeated for multiple keys.
-
-  (Contributed by Antoine Pitrou; :issue:`7451`.)
-
-* JSON encoding now uses the C speedups also when the ``sort_keys`` argument
-  is true.
-
-  (Contributed by Raymond Hettinger and Antoine Pitrou, :issue:`10314`.)
-
 * Python's peephole optimizer now recognizes patterns such ``x in {1, 2, 3}`` as
   being a test for membership in a set of constants.  The optimizer recasts the
   :class:`set` as a :class:`frozenset` and stores the pre-built constant.
@@ -624,6 +1416,36 @@
 
   (Patch and additional tests by Dave Malcolm; :issue:`6690`).
 
+* Serializing and unserializing data using the :mod:`pickle` module is now
+  several times faster.
+
+  (Contributed by Alexandre Vassalotti, Antoine Pitrou
+  and the Unladen Swallow team in :issue:`9410` and :issue:`3873`.)
+
+* The `Timsort algorithm <http://en.wikipedia.org/wiki/Timsort>`_ used in
+  :meth:`list.sort` and :func:`sorted` now runs faster and uses less memory
+  when called with a :term:`key function`.  Previously, every element of
+  a list was wrapped with a temporary object that remembered the key value
+  associated with each element.  Now, an array of keys and values are
+  sorted in parallel.  This save the memory consumed by the sort wrappers,
+  and it saves time lost during comparisons which were delegated by the
+  sort wrappers.
+
+  (Patch by Daniel Stuzback in :issue:`9915`.)
+
+* JSON decoding performance is improved and memory consumption is reduced
+  whenever the same string is repeated for multiple keys.  Also, JSON encoding
+  now uses the C speedups when the ``sort_keys`` argument is true.
+
+  (Contributed by Antoine Pitrou in :issue:`7451` and by Raymond Hettinger and
+  Antoine Pitrou in :issue:`10314`.)
+
+* Recursive locks (created with the :func:`threading.RLock` API) now benefit
+  from a C implementation which makes them as fast as regular locks, and between
+  10x and 15x faster than their previous pure Python implementation.
+
+  (Contributed by Antoine Pitrou; :issue:`3001`.)
+
 * The fast-search algorithm in stringlib is now used by the :meth:`split`,
   :meth:`rsplit`, :meth:`splitlines` and :meth:`replace` methods on
   :class:`bytes`, :class:`bytearray` and :class:`str` objects. Likewise, the
@@ -632,20 +1454,52 @@
 
   (Patch by Florent Xicluna in :issue:`7622` and :issue:`7462`.)
 
-* Serializing and unserializing data using the :mod:`pickle` module is now
-  several times faster. (Contributed by Alexandre Vassalotti, Antoine Pitrou
-  and the Unladen Swallow team in :issue:`9410` and :issue:`3873`.)
+
+* String to integer conversions now work two "digits" at a time, reducing the
+  number of division and modulo operations.
+
+  (:issue:`6713` by Gawain Bolton, Mark Dickinson, and Victor Stinner.)
+
+There were several other minor optimizations. Set differencing now runs faster
+when one operand is much larger than the other (Patch by Andress Bennetts in
+:issue:`8685`).  The :meth:`array.repeat` method has a faster implementation
+(:issue:`1569291` by Alexander Belopolsky). The :class:`BaseHTTPRequestHandler`
+has more efficient buffering (:issue:`3709` by Andrew Schaaf).  The
+multi-argument form of :func:`operator.attrgetter` now function runs slightly
+faster (:issue:`10160` by Christos Georgiou).  And :class:`ConfigParser` loads
+multi-line arguments a bit faster (:issue:`7113` by Łukasz Langa).
 
 
 Unicode
 =======
 
+Python has been updated to Unicode 6.0.0.  The new features of the
+Unicode Standard that will affect Python users include:
+
+* addition of 2,088 characters, including over 1,000 additional
+  symbols—chief among them the additional emoji symbols, which are
+  especially important for mobile phones;
+
+* changes to character properties for existing characters including
+
+  - a general category change to two Kannada characters (U+0CF1,
+    U+0CF2), which has the effect of making them newly eligible for
+    inclusion in identifiers;
+
+  - a general category change to one New Tai Lue numeric character
+    (U+19DA), which has the effect of disqualifying it from
+    inclusion in identifiers.
+
+  For more information, see `Unicode Character Database Changes
+  <http://www.unicode.org/versions/Unicode6.0.0/#Database_Changes>`_
+  at the `Unicode Consortium <http://www.unicode.org/>`_ web site.
+
 The :mod:`os` module has two new functions: :func:`~os.fsencode` and
 :func:`~os.fsdecode`. Add :data:`os.environb`: bytes version of
 :data:`os.environ`, :func:`os.getenvb` function and
 :data:`os.supports_bytes_environ` constant.
 
-``'mbcs'`` encoding doesn't ignore the error handler argument anymore. By
+``'mbcs'`` encoding doesn't ignore the error handler argument any more. By
 default (strict mode), it raises an UnicodeDecodeError on undecodable byte
 sequence and UnicodeEncodeError on unencodable character. To get the ``'mbcs'``
 encoding of Python 3.1, use ``'ignore'`` error handler to decode and
@@ -661,11 +1515,38 @@
 ``'mbcs'``), and the ``'surrogateescape'`` error handler on all operating
 systems.
 
+* Added the *cp720* Arabic DOS encoding (:issue:`1616979`).
+
+
+Documentation
+=============
+
+The documentation continues to be improved.
+
+A table of quick links has been added to the top of lengthy sections such as
+:ref:`built-in-funcs`.  In the case of :mod:`itertools`, the links are
+accompanied by tables of cheatsheet-style summaries to provide an overview and
+memory jog without having to read all of the docs.
+
+In some cases, the pure python source code can be helpful adjunct to the docs,
+so now some modules feature quick links to the latest version of the source
+code.  For example, the :mod:`functools` module documentation has a quick link
+at the top labeled :source:`functools Python source code <Lib/functools.py>`.
 
-.. IDLE
-   ====
+The docs now contain more examples and recipes.  In particular, :mod:`re` module
+has an extensive section, :ref:`re-examples`.  Likewise, the :mod:`itertools`
+module continues to be updated with new :ref:`itertools-recipes`.
 
-   * Stub
+The :mod:`datetime` module now has an auxiliary implementation in pure Python.
+No functionality was changed.  This just provides an easier-to-read
+alternate implementation.  (Contributed by Alexander Belopolsky.)
+
+
+IDLE
+====
+
+* The format menu now has an option to clean-up source files by stripping
+  trailing whitespace (:issue:`5150`).
 
 
 Build and C API Changes
@@ -693,11 +1574,51 @@
 
   (Contributed by Amaury Forgeot D'Arc; :issue:`9210`.)
 
-* Hash values are now values of a new type, Py_hash_t, which is defined to
-  be the same size as a pointer.  Previously they were of type long, which
-  on some 64-bit operating systems is still only 32 bits long.
+* Hash values are now values of a new type, :c:type:`Py_hash_t`, which is
+  defined to be the same size as a pointer.  Previously they were of type long,
+  which on some 64-bit operating systems is still only 32 bits long.  As a
+  result of this fix, :class:`set` and :class:`dict` can now hold more than
+  ``2**32`` entries on builds with 64-bit pointers (previously, they could grow
+  to that size but their performance degraded catastrophically).
+
+  (Suggested by Raymond Hettinger and implemented by Benjamin Peterson;
+  :issue:`9778`.)
+
+* A new macro :c:macro:`Py_VA_COPY` copies the state of the variable argument
+  list.  It is equivalent to C99 *va_copy* but available on all python platforms
+  (:issue:`2443`).
+
+* A new C API function :c:func:`PySys_SetArgvEx` allows an embedded
+  interpreter to set sys.argv without also modifying :attr:`sys.path`
+  (:issue:`5753`).
+
+* :c:macro:`PyEval_CallObject` is now only available in macro form.  The
+  function declaration, which was kept for backwards compatibility reasons, is
+  now removed -- the macro was introduced in 1997  (:issue:`8276`).
+
+* The is a new function :c:func:`PyLong_AsLongLongAndOverflow` which
+  is analogous to :c:func:`PyLong_AsLongAndOverflow`.  The both serve to
+  convert Python :class:`int` into a native fixed-width type while providing
+  detection of cases where the conversion won't fit (:issue:`7767`).
+
+* The :c:func:`PyUnicode_CompareWithASCIIString` now returns *not equal*
+  if the Python string in *NUL* terminated.
+
+* There is a new function :c:func:`PyErr_NewExceptionWithDoc` that is
+  like :c:func:`PyErr_NewException` but allows a docstring to be specified.
+  This lets C exceptions have the same self-documenting capabilities as
+  their pure Python counterparts (:issue:`7033`).
+
+* When compiled with the ``--with-valgrind`` option, the pymalloc
+  allocator will be automatically disabled when running under Valgrind.  This
+  gives improved memory leak detection when running under Valgrind, while taking
+  advantage of pymalloc at other times (:issue:`2422`).
+
+* Removed the "O?" format from the *PyArg_Parse* functions.  The format is no
+  longer used and it had never been documented (:issue:`8837`).
 
-  (Contributed by Benjamin Peterson; :issue:`9778`.)
+There were a number of other small changes to the C-API.  See the
+:file:`Misc/NEWS` file for a complete list.
 
 
 Porting to Python 3.2
@@ -706,11 +1627,42 @@
 This section lists previously described changes and other bugfixes that may
 require changes to your code:
 
+* The :mod:`configparser` module has a number of clean-ups.  The major change is
+  to replace the old :class:`ConfigParser` class with long-standing preferred
+  alternative :class:`SafeConfigParser`.  In addition there are a number of
+  smaller incompatibilites:
+
+  * The interpolation syntax is now validated on
+    :meth:`~configparser.ConfigParser.get` and
+    :meth:`~configparser.ConfigParser.set` operations. In the default
+    interpolation scheme, only two tokens with percent signs are valid: ``%(name)s``
+    and ``%%``, the latter being an escaped percent sign.
+
+  * The :meth:`~configparser.ConfigParser.set` and
+    :meth:`~configparser.ConfigParser.add_section` methods now verify that
+    values are actual strings.  Formerly, unsupported types could be introduced
+    unintentionally.
+
+  * Duplicate sections or options from a single source now raise either
+    :exc:`~configparser.DuplicateSectionError` or
+    :exc:`~configparser.DuplicateOptionError`.  Formerly, duplicates would
+    silently overwrite a previous entry.
+
+  * Inline comments are now disabled by default so now the **;** character
+    can be safely used in values.
+
+  * Comments now can be indented.  Consequently, for **;** or **#** to appear at
+    the start of a line in multiline values, it has to be interpolated.  This
+    keeps comment prefix characters in values from being mistaken as comments.
+
+  * ``""`` is now a valid value and is no longer automatically converted to an
+    empty string. For empty strings, use ``"option ="`` in a line.
+
 * The :mod:`nntplib` module was reworked extensively, meaning that its APIs
   are often incompatible with the 3.1 APIs.
 
-* :class:`bytearray` objects cannot be used anymore as filenames: convert them
-  to :class:`bytes`.
+* :class:`bytearray` objects can no longer be used as filenames; instead,
+  they should be converted to :class:`bytes`.
 
 * PyArg_Parse*() functions:
 
@@ -722,4 +1674,38 @@
   instead; the new type has a well-defined interface for passing typing safety
   information and a less complicated signature for calling a destructor.
 
- * Remove sys.setfilesystemencoding() function: it was broken by design.
+* The :func:`sys.setfilesystemencoding` function was removed because
+  it had a flawed design.
+
+* The :func:`random.seed` function and method now salt string seeds with an
+  sha512 hash function.  To access the previous version of *seed* in order to
+  reproduce Python 3.1 sequences, set the *version* argument to *1*,
+  ``random.seed(s, version=1)``.
+
+* The previously deprecated :func:`string.maketrans` function has been removed
+  in favor of the static methods, :meth:`bytes.maketrans` and
+  :meth:`bytearray.maketrans`.  This change solves the confusion around which
+  types were supported by the :mod:`string` module.  Now, :class:`str`,
+  :class:`bytes`, and :class:`bytearray` each have their own **maketrans** and
+  **translate** methods with intermediate translation tables of the appropriate
+  type.
+
+  (Contributed by Georg Brandl; :issue:`5675`.)
+
+* The previously deprecated :func:`contextlib.nested` function has been removed
+  in favor of a plain :keyword:`with` statement which can accept multiple
+  context managers.  The latter technique is faster (because it is built-in),
+  and it does a better job finalizing multiple context managers when one of them
+  raises an exception::
+
+    >>> with open('mylog.txt') as infile, open('a.out', 'w') as outfile:
+    ...     for line in infile:
+    ...         if '<critical>' in line:
+    ...             outfile.write(line)
+
+  (Contributed by Georg Brandl and Mattias Brändström;
+  `appspot issue 53094 <http://codereview.appspot.com/53094>`_.)
+
+* :func:`struct.pack` no longer implicitly encodes unicode to UTF-8: use
+  explicit conversion instead and replace unicode literals by bytes literals.
+

Modified: python/branches/py3k-cdecimal/Include/Python.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/Python.h	(original)
+++ python/branches/py3k-cdecimal/Include/Python.h	Sun Jan  2 13:18:37 2011
@@ -66,6 +66,7 @@
 
 #include "object.h"
 #include "objimpl.h"
+#include "typeslots.h"
 
 #include "pydebug.h"
 
@@ -98,6 +99,8 @@
 #include "descrobject.h"
 #include "warnings.h"
 #include "weakrefobject.h"
+#include "structseq.h"
+
 
 #include "codecs.h"
 #include "pyerrors.h"
@@ -129,7 +132,9 @@
 #endif
 
 /* _Py_Mangle is defined in compile.c */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/abstract.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/abstract.h	(original)
+++ python/branches/py3k-cdecimal/Include/abstract.h	Sun Jan  2 13:18:37 2011
@@ -387,7 +387,9 @@
      PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
 #define PyObject_Length PyObject_Size
 
+#ifndef Py_LIMITED_API
      PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t);
+#endif
 
        /*
      Guess the size of object o using len(o) or o.__length_hint__().
@@ -765,9 +767,11 @@
      that can accept a char* naming integral's type.
        */
 
+#ifndef Py_LIMITED_API
      PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt(
          PyObject *integral,
          const char* error_format);
+#endif
 
        /*
     Returns the object converted to Py_ssize_t by going through
@@ -1057,11 +1061,13 @@
      Use __contains__ if possible, else _PySequence_IterSearch().
        */
 
+#ifndef Py_LIMITED_API
 #define PY_ITERSEARCH_COUNT    1
 #define PY_ITERSEARCH_INDEX    2
 #define PY_ITERSEARCH_CONTAINS 3
      PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq,
                                         PyObject *obj, int operation);
+#endif
     /*
       Iterate over seq.  Result depends on the operation:
       PY_ITERSEARCH_COUNT:  return # of times obj appears in seq; -1 if
@@ -1228,6 +1234,7 @@
       /* issubclass(object, typeorclass) */
 
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
 
 PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
@@ -1235,6 +1242,7 @@
 PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self);
 
 PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]);
+#endif
 
 /* For internal use by buffer API functions */
 PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index,

Modified: python/branches/py3k-cdecimal/Include/ast.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/ast.h	(original)
+++ python/branches/py3k-cdecimal/Include/ast.h	Sun Jan  2 13:18:37 2011
@@ -4,8 +4,11 @@
 extern "C" {
 #endif
 
-PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags,
-				  const char *, PyArena *);
+PyAPI_FUNC(mod_ty) PyAST_FromNode(
+    const node *n,
+    PyCompilerFlags *flags,
+    const char *filename,       /* decoded from the filesystem encoding */
+    PyArena *arena);
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/bytearrayobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/bytearrayobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/bytearrayobject.h	Sun Jan  2 13:18:37 2011
@@ -19,6 +19,7 @@
  */
 
 /* Object layout */
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_VAR_HEAD
     /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
@@ -26,6 +27,7 @@
     Py_ssize_t ob_alloc; /* How many bytes allocated */
     char *ob_bytes;
 } PyByteArrayObject;
+#endif
 
 /* Type object */
 PyAPI_DATA(PyTypeObject) PyByteArray_Type;
@@ -44,12 +46,14 @@
 PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
 
 /* Macros, trading safety for speed */
+#ifndef Py_LIMITED_API
 #define PyByteArray_AS_STRING(self) \
     (assert(PyByteArray_Check(self)), \
      Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string)
 #define PyByteArray_GET_SIZE(self)  (assert(PyByteArray_Check(self)),Py_SIZE(self))
 
 PyAPI_DATA(char) _PyByteArray_empty_string[];
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/bytes_methods.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/bytes_methods.h	(original)
+++ python/branches/py3k-cdecimal/Include/bytes_methods.h	Sun Jan  2 13:18:37 2011
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_BYTES_CTYPE_H
 #define Py_BYTES_CTYPE_H
 
@@ -42,3 +43,4 @@
 #define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
 
 #endif /* !Py_BYTES_CTYPE_H */
+#endif /* !Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/bytesobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/bytesobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/bytesobject.h	Sun Jan  2 13:18:37 2011
@@ -27,6 +27,7 @@
 /* Caching the hash (ob_shash) saves recalculation of a string's hash value.
    This significantly speeds up dict lookups. */
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_VAR_HEAD
     Py_hash_t ob_shash;
@@ -38,6 +39,7 @@
      *     ob_shash is the hash of the string or -1 if not computed yet.
      */
 } PyBytesObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyBytes_Type;
 PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
@@ -58,21 +60,27 @@
 PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
 PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
 PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
 PyAPI_FUNC(PyObject *) _PyBytes_FormatLong(PyObject*, int, int,
 						  int, char**, int*);
+#endif
 PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
 						   const char *, Py_ssize_t,
 						   const char *);
 
 /* Macro, trading safety for speed */
+#ifndef Py_LIMITED_API
 #define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \
                                 (((PyBytesObject *)(op))->ob_sval))
 #define PyBytes_GET_SIZE(op)  (assert(PyBytes_Check(op)),Py_SIZE(op))
+#endif
 
 /* _PyBytes_Join(sep, x) is like sep.join(x).  sep must be PyBytesObject*,
    x must be an iterable object. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
+#endif
 
 /* Provides access to the internal data buffer and size of a string
    object or the default encoded version of an Unicode object. Passing
@@ -90,7 +98,7 @@
 /* Using the current locale, insert the thousands grouping
    into the string pointed to by buffer.  For the argument descriptions,
    see Objects/stringlib/localeutil.h */
-
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGroupingLocale(char *buffer,
                                                    Py_ssize_t n_buffer,
                                                    char *digits,
@@ -107,6 +115,7 @@
                                                    Py_ssize_t min_width,
                                                    const char *grouping,
                                                    const char *thousands_sep);
+#endif
 
 /* Flags used by string formatting */
 #define F_LJUST (1<<0)

Modified: python/branches/py3k-cdecimal/Include/cellobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/cellobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/cellobject.h	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,5 @@
 /* Cell object interface */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_CELLOBJECT_H
 #define Py_CELLOBJECT_H
 #ifdef __cplusplus
@@ -26,3 +26,4 @@
 }
 #endif
 #endif /* !Py_TUPLEOBJECT_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/ceval.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/ceval.h	(original)
+++ python/branches/py3k-cdecimal/Include/ceval.h	Sun Jan  2 13:18:37 2011
@@ -20,8 +20,10 @@
                                          const char *methodname,
                                          const char *format, ...);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
 PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
+#endif
 
 struct _frame; /* Avoid including frameobject.h */
 
@@ -33,7 +35,9 @@
 /* Look at the current frame's (if any) code's co_flags, and turn on
    the corresponding compiler flags in cf->cf_flags.  Return 1 if any
    flag was set, else return 0. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
+#endif
 
 PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
 PyAPI_FUNC(int) Py_MakePendingCalls(void);
@@ -167,8 +171,10 @@
 PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
 PyAPI_FUNC(void) PyEval_ReInitThreads(void);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
 PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
+#endif
 
 #define Py_BEGIN_ALLOW_THREADS { \
                         PyThreadState *_save; \
@@ -187,8 +193,10 @@
 
 #endif /* !WITH_THREAD */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
 PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void);
+#endif
 
 
 #ifdef __cplusplus

Modified: python/branches/py3k-cdecimal/Include/classobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/classobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/classobject.h	Sun Jan  2 13:18:37 2011
@@ -2,6 +2,7 @@
 
 /* Revealing some structures (not for general use) */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_CLASSOBJECT_H
 #define Py_CLASSOBJECT_H
 #ifdef __cplusplus
@@ -54,3 +55,4 @@
 }
 #endif
 #endif /* !Py_CLASSOBJECT_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/code.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/code.h	(original)
+++ python/branches/py3k-cdecimal/Include/code.h	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,6 @@
 /* Definitions for bytecode */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_CODE_H
 #define Py_CODE_H
 #ifdef __cplusplus
@@ -93,8 +94,10 @@
 /* Update *bounds to describe the first and one-past-the-last instructions in the
    same line as lasti.  Return the number of that line.
 */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
                                         int lasti, PyAddrPair *bounds);
+#endif
 
 PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
                                       PyObject *names, PyObject *lineno_obj);
@@ -103,3 +106,4 @@
 }
 #endif
 #endif /* !Py_CODE_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/codecs.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/codecs.h	(original)
+++ python/branches/py3k-cdecimal/Include/codecs.h	Sun Jan  2 13:18:37 2011
@@ -45,9 +45,11 @@
 
  */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
        const char *encoding
        );
+#endif
 
 /* Codec registry encoding check API.
 

Modified: python/branches/py3k-cdecimal/Include/compile.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/compile.h	(original)
+++ python/branches/py3k-cdecimal/Include/compile.h	Sun Jan  2 13:18:37 2011
@@ -1,4 +1,4 @@
-
+#ifndef Py_LIMITED_API
 #ifndef Py_COMPILE_H
 #define Py_COMPILE_H
 
@@ -29,8 +29,13 @@
 #define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL"
 
 struct _mod; /* Declare the existence of this type */
-PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *,
-					PyCompilerFlags *, PyArena *);
+#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar)
+PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx(
+    struct _mod *mod,
+    const char *filename,       /* decoded from the filesystem encoding */
+    PyCompilerFlags *flags,
+    int optimize,
+    PyArena *arena);
 PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);
 
 
@@ -38,3 +43,4 @@
 }
 #endif
 #endif /* !Py_COMPILE_H */
+#endif /* !Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/complexobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/complexobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/complexobject.h	Sun Jan  2 13:18:37 2011
@@ -6,6 +6,7 @@
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 typedef struct {
     double real;
     double imag;
@@ -28,7 +29,7 @@
 PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
 PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
 PyAPI_FUNC(double) c_abs(Py_complex);
-
+#endif
 
 /* Complex object interface */
 
@@ -36,29 +37,36 @@
 PyComplexObject represents a complex number with double-precision
 real and imaginary parts.
 */
-
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     Py_complex cval;
-} PyComplexObject;     
+} PyComplexObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyComplex_Type;
 
 #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
 #define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
+#endif
 PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
 
 PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
 PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
+#endif
 
 /* Format the object based on the format_spec, as defined in PEP 3101
    (Advanced String Formatting). */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj,
                                                  Py_UNICODE *format_spec,
                                                  Py_ssize_t format_spec_len);
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/datetime.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/datetime.h	(original)
+++ python/branches/py3k-cdecimal/Include/datetime.h	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,6 @@
 /*  datetime.h
  */
-
+#ifndef Py_LIMITED_API
 #ifndef DATETIME_H
 #define DATETIME_H
 #ifdef __cplusplus
@@ -234,3 +234,4 @@
 }
 #endif
 #endif
+#endif /* !Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/descrobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/descrobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/descrobject.h	Sun Jan  2 13:18:37 2011
@@ -16,6 +16,7 @@
     void *closure;
 } PyGetSetDef;
 
+#ifndef Py_LIMITED_API
 typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
                                  void *wrapped);
 
@@ -68,6 +69,7 @@
     struct wrapperbase *d_base;
     void *d_wrapped; /* This can be any function pointer */
 } PyWrapperDescrObject;
+#endif /* Py_LIMITED_API */
 
 PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
 PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
@@ -78,13 +80,16 @@
 
 PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
 PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
+struct PyMemberDef; /* forward declaration for following prototype */
 PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
                                                struct PyMemberDef *);
 PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
                                                struct PyGetSetDef *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
                                                 struct wrapperbase *, void *);
 #define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
+#endif
 
 PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
 PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);

Modified: python/branches/py3k-cdecimal/Include/dictobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/dictobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/dictobject.h	Sun Jan  2 13:18:37 2011
@@ -45,6 +45,7 @@
  * majority of dicts (consisting mostly of usually-small instance dicts and
  * usually-small dicts created to pass keyword arguments).
  */
+#ifndef Py_LIMITED_API
 #define PyDict_MINSIZE 8
 
 typedef struct {
@@ -84,6 +85,7 @@
     PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, Py_hash_t hash);
     PyDictEntry ma_smalltable[PyDict_MINSIZE];
 };
+#endif /* Py_LIMITED_API */
 
 PyAPI_DATA(PyTypeObject) PyDict_Type;
 PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
@@ -112,18 +114,22 @@
 PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
 PyAPI_FUNC(int) PyDict_Next(
     PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyDict_Next(
     PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
+#endif
 PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
 PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
 PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
 PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
 PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
 PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, Py_hash_t hash);
 PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
 PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
 PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
+#endif
 
 /* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
 PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);

Modified: python/branches/py3k-cdecimal/Include/dtoa.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/dtoa.h	(original)
+++ python/branches/py3k-cdecimal/Include/dtoa.h	Sun Jan  2 13:18:37 2011
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef PY_NO_SHORT_FLOAT_REPR
 #ifdef __cplusplus
 extern "C" {
@@ -13,3 +14,4 @@
 }
 #endif
 #endif
+#endif

Modified: python/branches/py3k-cdecimal/Include/eval.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/eval.h	(original)
+++ python/branches/py3k-cdecimal/Include/eval.h	Sun Jan  2 13:18:37 2011
@@ -7,9 +7,9 @@
 extern "C" {
 #endif
 
-PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *);
+PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *);
 
-PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co,
+PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
 					PyObject *globals,
 					PyObject *locals,
 					PyObject **args, int argc,
@@ -17,7 +17,9 @@
 					PyObject **defs, int defc,
 					PyObject *kwdefs, PyObject *closure);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/fileobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/fileobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/fileobject.h	Sun Jan  2 13:18:37 2011
@@ -14,7 +14,9 @@
 PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
 PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
 PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
+#endif
 
 /* The default encoding used by the platform file system APIs
    If non-NULL, this is different than the default encoding for strings
@@ -26,6 +28,7 @@
 
    The std printer acts as a preliminary sys.stderr until the new io
    infrastructure is in place. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int);
 PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
 
@@ -39,6 +42,7 @@
 #else
 #define _PyVerify_fd(A) (1) /* dummy */
 #endif
+#endif /* Py_LIMITED_API */
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/floatobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/floatobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/floatobject.h	Sun Jan  2 13:18:37 2011
@@ -11,10 +11,12 @@
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     double ob_fval;
 } PyFloatObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyFloat_Type;
 
@@ -45,8 +47,11 @@
 /* Extract C double from Python float.  The macro version trades safety for
    speed. */
 PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *);
+#ifndef Py_LIMITED_API
 #define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
+#endif
 
+#ifndef Py_LIMITED_API
 /* _PyFloat_{Pack,Unpack}{4,8}
  *
  * The struct and pickle (at least) modules need an efficient platform-
@@ -110,6 +115,7 @@
 PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
 					       Py_UNICODE *format_spec,
 					       Py_ssize_t format_spec_len);
+#endif /* Py_LIMITED_API */
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/frameobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/frameobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/frameobject.h	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,7 @@
 
 /* Frame object interface */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_FRAMEOBJECT_H
 #define Py_FRAMEOBJECT_H
 #ifdef __cplusplus
@@ -85,3 +86,4 @@
 }
 #endif
 #endif /* !Py_FRAMEOBJECT_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/funcobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/funcobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/funcobject.h	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,6 @@
 
 /* Function object interface */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_FUNCOBJECT_H
 #define Py_FUNCOBJECT_H
 #ifdef __cplusplus
@@ -84,3 +84,4 @@
 }
 #endif
 #endif /* !Py_FUNCOBJECT_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/genobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/genobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/genobject.h	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,7 @@
 
 /* Generator object interface */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_GENOBJECT_H
 #define Py_GENOBJECT_H
 #ifdef __cplusplus
@@ -38,3 +39,4 @@
 }
 #endif
 #endif /* !Py_GENOBJECT_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/import.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/import.h	(original)
+++ python/branches/py3k-cdecimal/Include/import.h	Sun Jan  2 13:18:37 2011
@@ -30,6 +30,7 @@
 PyAPI_FUNC(void) PyImport_Cleanup(void);
 PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *);
 
+#ifndef Py_LIMITED_API
 #ifdef WITH_THREAD
 PyAPI_FUNC(void) _PyImport_AcquireLock(void);
 PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
@@ -49,13 +50,15 @@
     char *name;
     PyObject* (*initfunc)(void);
 };
+PyAPI_DATA(struct _inittab *) PyImport_Inittab;
+PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
+#endif /* Py_LIMITED_API */
 
 PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
-PyAPI_DATA(struct _inittab *) PyImport_Inittab;
 
 PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, PyObject* (*initfunc)(void));
-PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
 
+#ifndef Py_LIMITED_API
 struct _frozen {
     char *name;
     unsigned char *code;
@@ -66,6 +69,7 @@
    collection of frozen modules: */
 
 PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/listobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/listobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/listobject.h	Sun Jan  2 13:18:37 2011
@@ -19,6 +19,7 @@
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_VAR_HEAD
     /* Vector of pointers to list elements.  list[0] is ob_item[0], etc. */
@@ -37,6 +38,7 @@
      */
     Py_ssize_t allocated;
 } PyListObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyList_Type;
 PyAPI_DATA(PyTypeObject) PyListIter_Type;
@@ -58,12 +60,16 @@
 PyAPI_FUNC(int) PyList_Sort(PyObject *);
 PyAPI_FUNC(int) PyList_Reverse(PyObject *);
 PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
+#endif
 
 /* Macro, trading safety for speed */
+#ifndef Py_LIMITED_API
 #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
 #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
 #define PyList_GET_SIZE(op)    Py_SIZE(op)
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/longintrepr.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/longintrepr.h	(original)
+++ python/branches/py3k-cdecimal/Include/longintrepr.h	Sun Jan  2 13:18:37 2011
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_LONGINTREPR_H
 #define Py_LONGINTREPR_H
 #ifdef __cplusplus
@@ -99,3 +100,4 @@
 }
 #endif
 #endif /* !Py_LONGINTREPR_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/longobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/longobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/longobject.h	Sun Jan  2 13:18:37 2011
@@ -50,7 +50,9 @@
 #endif /* SIZEOF_PID_T */
 
 /* Used by Python/mystrtoul.c. */
+#ifndef Py_LIMITED_API
 PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
+#endif
 
 /* _PyLong_Frexp returns a double x and an exponent e such that the
    true value is approximately equal to x * 2**e.  e is >= 0.  x is
@@ -58,7 +60,9 @@
    zeroes); otherwise, 0.5 <= abs(x) < 1.0.  On overflow, which is
    possible if the number of bits doesn't fit into a Py_ssize_t, sets
    OverflowError and returns -1.0 for x, 0 for e. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
+#endif
 
 PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
 PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
@@ -74,8 +78,11 @@
 #endif /* HAVE_LONG_LONG */
 
 PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
+#endif
 
+#ifndef Py_LIMITED_API
 /* _PyLong_Sign.  Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
    v must not be NULL, and must be a normalized long.
    There are no error cases.
@@ -150,6 +157,7 @@
 PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj,
 					      Py_UNICODE *format_spec,
 					      Py_ssize_t format_spec_len);
+#endif /* Py_LIMITED_API */
 
 /* These aren't really part of the long object, but they're handy. The
    functions are in Python/mystrtoul.c.

Modified: python/branches/py3k-cdecimal/Include/marshal.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/marshal.h	(original)
+++ python/branches/py3k-cdecimal/Include/marshal.h	Sun Jan  2 13:18:37 2011
@@ -13,10 +13,12 @@
 PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
 PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
 PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
 PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
 PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
+#endif
 PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
 
 #ifdef __cplusplus

Modified: python/branches/py3k-cdecimal/Include/memoryobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/memoryobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/memoryobject.h	Sun Jan  2 13:18:37 2011
@@ -10,10 +10,12 @@
 
 #define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type)
 
+#ifndef Py_LIMITED_API
 /* Get a pointer to the underlying Py_buffer of a memoryview object. */
 #define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view)
 /* Get a pointer to the PyObject from which originates a memoryview object. */
 #define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj)
+#endif
 
 
 PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, 
@@ -61,11 +63,12 @@
 /* The struct is declared here so that macros can work, but it shouldn't
    be considered public. Don't access those fields directly, use the macros
    and functions instead! */
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     Py_buffer view;
 } PyMemoryViewObject;
-
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/methodobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/methodobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/methodobject.h	Sun Jan  2 13:18:37 2011
@@ -26,12 +26,14 @@
 
 /* Macros for direct access to these values. Type checks are *not*
    done, so use with care. */
+#ifndef Py_LIMITED_API
 #define PyCFunction_GET_FUNCTION(func) \
         (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
 #define PyCFunction_GET_SELF(func) \
 	(((PyCFunctionObject *)func) -> m_self)
 #define PyCFunction_GET_FLAGS(func) \
 	(((PyCFunctionObject *)func) -> m_ml -> ml_flags)
+#endif
 PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
 
 struct PyMethodDef {
@@ -68,12 +70,14 @@
 
 #define METH_COEXIST   0x0040
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     PyMethodDef *m_ml; /* Description of the C function to call */
     PyObject    *m_self; /* Passed as 'self' arg to the C func, can be NULL */
     PyObject    *m_module; /* The __module__ attribute, can be anything */
 } PyCFunctionObject;
+#endif
 
 PyAPI_FUNC(int) PyCFunction_ClearFreeList(void);
 

Modified: python/branches/py3k-cdecimal/Include/modsupport.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/modsupport.h	(original)
+++ python/branches/py3k-cdecimal/Include/modsupport.h	Sun Jan  2 13:18:37 2011
@@ -31,7 +31,9 @@
 PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
 PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
 PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw);
+#endif
 
 PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
 PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
@@ -92,6 +94,12 @@
    9-Jan-1995	GvR	Initial version (incompatible with older API)
 */
 
+/* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of
+   Python 3, it will stay at the value of 3; changes to the limited API
+   must be performed in a strictly backwards-compatible manner. */
+#define PYTHON_ABI_VERSION 3
+#define PYTHON_ABI_STRING "3"
+
 #ifdef Py_TRACE_REFS
  /* When we are tracing reference counts, rename PyModule_Create2 so
     modules compiled with incompatible settings will generate a
@@ -102,10 +110,17 @@
 PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
                                      int apiver);
 
+#ifdef Py_LIMITED_API
+#define PyModule_Create(module) \
+	PyModule_Create2(module, PYTHON_ABI_VERSION)
+#else
 #define PyModule_Create(module) \
 	PyModule_Create2(module, PYTHON_API_VERSION)
+#endif
 
+#ifndef Py_LIMITED_API
 PyAPI_DATA(char *) _Py_PackageContext;
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/moduleobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/moduleobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/moduleobject.h	Sun Jan  2 13:18:37 2011
@@ -17,7 +17,9 @@
 PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
 PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
 PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
+#endif
 PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*);
 PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
 

Modified: python/branches/py3k-cdecimal/Include/object.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/object.h	(original)
+++ python/branches/py3k-cdecimal/Include/object.h	Sun Jan  2 13:18:37 2011
@@ -61,6 +61,10 @@
 #define Py_REF_DEBUG
 #endif
 
+#if defined(Py_LIMITED_API) && defined(Py_REF_DEBUG)
+#error Py_LIMITED_API is incompatible with Py_DEBUG, Py_TRACE_REFS, and Py_REF_DEBUG
+#endif
+
 #ifdef Py_TRACE_REFS
 /* Define pointers to support a doubly-linked list of all live heap objects. */
 #define _PyObject_HEAD_EXTRA            \
@@ -196,6 +200,7 @@
 typedef int (*visitproc)(PyObject *, void *);
 typedef int (*traverseproc)(PyObject *, visitproc, void *);
 
+#ifndef Py_LIMITED_API
 typedef struct {
     /* Number implementations must check *both*
        arguments for proper type and implement the necessary conversions
@@ -265,10 +270,17 @@
      getbufferproc bf_getbuffer;
      releasebufferproc bf_releasebuffer;
 } PyBufferProcs;
+#endif /* Py_LIMITED_API */
 
 typedef void (*freefunc)(void *);
 typedef void (*destructor)(PyObject *);
+#ifndef Py_LIMITED_API
+/* We can't provide a full compile-time check that limited-API
+   users won't implement tp_print. However, not defining printfunc
+   and making tp_print of a different function pointer type
+   should at least cause a warning in most cases. */
 typedef int (*printfunc)(PyObject *, FILE *, int);
+#endif
 typedef PyObject *(*getattrfunc)(PyObject *, char *);
 typedef PyObject *(*getattrofunc)(PyObject *, PyObject *);
 typedef int (*setattrfunc)(PyObject *, char *, PyObject *);
@@ -284,6 +296,9 @@
 typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
 typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);
 
+#ifdef Py_LIMITED_API
+typedef struct _typeobject PyTypeObject; /* opaque */
+#else
 typedef struct _typeobject {
     PyObject_VAR_HEAD
     const char *tp_name; /* For printing, in format "<module>.<name>" */
@@ -371,8 +386,25 @@
     struct _typeobject *tp_next;
 #endif
 } PyTypeObject;
+#endif
+
+typedef struct{
+    int slot;    /* slot id, see below */
+    void *pfunc; /* function pointer */
+} PyType_Slot;
+
+typedef struct{
+    const char* name;
+    const char* doc;
+    int basicsize;
+    int itemsize;
+    int flags;
+    PyType_Slot *slots; /* terminated by slot==0. */
+} PyType_Spec;
 
+PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*);
 
+#ifndef Py_LIMITED_API
 /* The *real* layout of a type object when allocated on the heap */
 typedef struct _heaptypeobject {
     /* Note: there's a dependency on the order of these members
@@ -393,7 +425,7 @@
 /* access macro to the members which are floating "behind" the object */
 #define PyHeapType_GET_MEMBERS(etype) \
     ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize))
-
+#endif
 
 /* Generic type check */
 PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
@@ -412,15 +444,19 @@
 PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
 PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
                                                PyObject *, PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
 PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, char *, PyObject **);
+#endif
 PyAPI_FUNC(unsigned int) PyType_ClearCache(void);
 PyAPI_FUNC(void) PyType_Modified(PyTypeObject *);
 
 /* Generic operations on objects */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
 PyAPI_FUNC(void) _Py_BreakPoint(void);
 PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
+#endif
 PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
 PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
 PyAPI_FUNC(PyObject *) PyObject_ASCII(PyObject *);
@@ -433,9 +469,13 @@
 PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
 PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
 PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
+#endif
 PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *);
+#endif
 PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
 PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *,
                                               PyObject *, PyObject *);
@@ -469,8 +509,10 @@
 PyAPI_FUNC(void) Py_ReprLeave(PyObject *);
 
 /* Helpers for hash functions */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_hash_t) _Py_HashDouble(double);
 PyAPI_FUNC(Py_hash_t) _Py_HashPointer(void*);
+#endif
 
 /* Helper for passing objects to printf and the like */
 #define PyObject_REPR(obj) _PyUnicode_AsString(PyObject_Repr(obj))
@@ -649,9 +691,13 @@
 
 #define _Py_ForgetReference(op) _Py_INC_TPFREES(op)
 
+#ifdef Py_LIMITED_API
+PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
+#else
 #define _Py_Dealloc(op) (                               \
     _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA          \
     (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op)))
+#endif
 #endif /* !Py_TRACE_REFS */
 
 #define Py_INCREF(op) (                         \

Modified: python/branches/py3k-cdecimal/Include/objimpl.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/objimpl.h	(original)
+++ python/branches/py3k-cdecimal/Include/objimpl.h	Sun Jan  2 13:18:37 2011
@@ -246,6 +246,7 @@
 #define _PyObject_GC_Del PyObject_GC_Del
 
 /* GC information is stored BEFORE the object structure. */
+#ifndef Py_LIMITED_API
 typedef union _gc_head {
     struct {
         union _gc_head *gc_next;
@@ -298,7 +299,7 @@
 #define _PyObject_GC_MAY_BE_TRACKED(obj) \
     (PyObject_IS_GC(obj) && \
         (!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj)))
-
+#endif /* Py_LIMITED_API */
 
 PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t);
 PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);

Modified: python/branches/py3k-cdecimal/Include/parsetok.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/parsetok.h	(original)
+++ python/branches/py3k-cdecimal/Include/parsetok.h	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,6 @@
 
 /* Parser-tokenizer link interface */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_PARSETOK_H
 #define Py_PARSETOK_H
 #ifdef __cplusplus
@@ -9,10 +9,10 @@
 
 typedef struct {
     int error;
-    const char *filename;
+    const char *filename;       /* decoded from the filesystem encoding */
     int lineno;
     int offset;
-    char *text;
+    char *text;                 /* UTF-8-encoded string */
     int token;
     int expected;
 } perrdetail;
@@ -39,23 +39,32 @@
 
 PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
                                               perrdetail *, int);
-PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, 
+PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *,
 					   const char*, grammar *,
 						 int, char *, char *,
 						 perrdetail *, int);
-PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *,
-					   const char*, grammar *,
-						 int, char *, char *,
-						 perrdetail *, int *);
+PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(
+    FILE *fp,
+    const char *filename,       /* decoded from the filesystem encoding */
+    const char *enc,
+    grammar *g,
+    int start,
+    char *ps1,
+    char *ps2,
+    perrdetail *err_ret,
+    int *flags);
 
 PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *,
 					      const char *,
 					      grammar *, int,
                                               perrdetail *, int);
-PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(const char *,
-					      const char *,
-					      grammar *, int,
-                                              perrdetail *, int *);
+PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(
+    const char *s,
+    const char *filename,       /* decoded from the filesystem encoding */
+    grammar *g,
+    int start,
+    perrdetail *err_ret,
+    int *flags);
 
 /* Note that he following function is defined in pythonrun.c not parsetok.c. */
 PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
@@ -64,3 +73,4 @@
 }
 #endif
 #endif /* !Py_PARSETOK_H */
+#endif /* !Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/patchlevel.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/patchlevel.h	(original)
+++ python/branches/py3k-cdecimal/Include/patchlevel.h	Sun Jan  2 13:18:37 2011
@@ -19,11 +19,11 @@
 #define PY_MAJOR_VERSION	3
 #define PY_MINOR_VERSION	2
 #define PY_MICRO_VERSION	0
-#define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_ALPHA
-#define PY_RELEASE_SERIAL	4
+#define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_BETA
+#define PY_RELEASE_SERIAL	2
 
 /* Version as a string */
-#define PY_VERSION      	"3.2a4+"
+#define PY_VERSION      	"3.2b2+"
 /*--end constants--*/
 
 /* Subversion Revision number of this file (not of the repository) */

Modified: python/branches/py3k-cdecimal/Include/pyarena.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pyarena.h	(original)
+++ python/branches/py3k-cdecimal/Include/pyarena.h	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,7 @@
 /* An arena-like memory interface for the compiler.
  */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_PYARENA_H
 #define Py_PYARENA_H
 
@@ -60,3 +61,4 @@
 #endif
 
 #endif /* !Py_PYARENA_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/pyatomic.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pyatomic.h	(original)
+++ python/branches/py3k-cdecimal/Include/pyatomic.h	Sun Jan  2 13:18:37 2011
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_ATOMIC_H
 #define Py_ATOMIC_H
 /* XXX: When compilers start offering a stdatomic.h with lock-free
@@ -177,3 +178,4 @@
 #endif
 
 #endif  /* Py_ATOMIC_H */
+#endif  /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/pyctype.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pyctype.h	(original)
+++ python/branches/py3k-cdecimal/Include/pyctype.h	Sun Jan  2 13:18:37 2011
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef PYCTYPE_H
 #define PYCTYPE_H
 
@@ -29,3 +30,4 @@
 #define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
 
 #endif /* !PYCTYPE_H */
+#endif /* !Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/pydebug.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pydebug.h	(original)
+++ python/branches/py3k-cdecimal/Include/pydebug.h	Sun Jan  2 13:18:37 2011
@@ -1,4 +1,4 @@
-
+#ifndef Py_LIMITED_API
 #ifndef Py_PYDEBUG_H
 #define Py_PYDEBUG_H
 #ifdef __cplusplus
@@ -7,6 +7,7 @@
 
 PyAPI_DATA(int) Py_DebugFlag;
 PyAPI_DATA(int) Py_VerboseFlag;
+PyAPI_DATA(int) Py_QuietFlag;
 PyAPI_DATA(int) Py_InteractiveFlag;
 PyAPI_DATA(int) Py_InspectFlag;
 PyAPI_DATA(int) Py_OptimizeFlag;
@@ -31,3 +32,4 @@
 }
 #endif
 #endif /* !Py_PYDEBUG_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/pyerrors.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pyerrors.h	(original)
+++ python/branches/py3k-cdecimal/Include/pyerrors.h	Sun Jan  2 13:18:37 2011
@@ -6,6 +6,7 @@
 
 /* Error objects */
 
+#ifndef Py_LIMITED_API
 /* PyException_HEAD defines the initial segment of every exception class. */
 #define PyException_HEAD PyObject_HEAD PyObject *dict;\
              PyObject *args; PyObject *traceback;\
@@ -55,6 +56,7 @@
     PyObject *winerror;
 } PyWindowsErrorObject;
 #endif
+#endif
 
 /* Error handling definitions */
 
@@ -68,8 +70,9 @@
 PyAPI_FUNC(void) PyErr_Clear(void);
 PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
 PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
+PyAPI_FUNC(void) Py_FatalError(const char *message);
 
-#ifdef Py_DEBUG
+#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
 #define _PyErr_OCCURRED() PyErr_Occurred()
 #else
 #define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type)
@@ -183,7 +186,7 @@
     PyObject *exc,
     const char *filename   /* decoded from the filesystem encoding */
     );
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) && !defined(Py_LIMITED_API)
 PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
     PyObject *, const Py_UNICODE *);
 #endif /* MS_WINDOWS */
@@ -198,16 +201,26 @@
 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject(
     int, const char *);
 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
-    int, const char *);
+    int ierr,
+    const char *filename        /* decoded from the filesystem encoding */
+    );
+#ifndef Py_LIMITED_API
+/* XXX redeclare to use WSTRING */
 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
     int, const Py_UNICODE *);
+#endif
 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
     PyObject *,int, PyObject *);
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
-    PyObject *,int, const char *);
+    PyObject *exc,
+    int ierr,
+    const char *filename        /* decoded from the filesystem encoding */
+    );
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
     PyObject *,int, const Py_UNICODE *);
+#endif
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
 #endif /* MS_WINDOWS */
 
@@ -230,27 +243,57 @@
 PyAPI_FUNC(void) PyErr_SetInterrupt(void);
 
 /* In signalmodule.c */
+#ifndef Py_LIMITED_API
 int PySignal_SetWakeupFd(int fd);
+#endif
 
 /* Support for adding program text to SyntaxErrors */
-PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
-PyAPI_FUNC(void) PyErr_SyntaxLocationEx(const char *, int, int);
-PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int);
+PyAPI_FUNC(void) PyErr_SyntaxLocation(
+    const char *filename,       /* decoded from the filesystem encoding */
+    int lineno);
+PyAPI_FUNC(void) PyErr_SyntaxLocationEx(
+    const char *filename,       /* decoded from the filesystem encoding */
+    int lineno,
+    int col_offset);
+PyAPI_FUNC(PyObject *) PyErr_ProgramText(
+    const char *filename,       /* decoded from the filesystem encoding */
+    int lineno);
 
 /* The following functions are used to create and modify unicode
    exceptions from C */
 
 /* create a UnicodeDecodeError object */
 PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
-    const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
+    const char *encoding,       /* UTF-8 encoded string */
+    const char *object,
+    Py_ssize_t length,
+    Py_ssize_t start,
+    Py_ssize_t end,
+    const char *reason          /* UTF-8 encoded string */
+    );
 
 /* create a UnicodeEncodeError object */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
-    const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
+    const char *encoding,       /* UTF-8 encoded string */
+    const Py_UNICODE *object,
+    Py_ssize_t length,
+    Py_ssize_t start,
+    Py_ssize_t end,
+    const char *reason          /* UTF-8 encoded string */
+    );
+#endif
 
 /* create a UnicodeTranslateError object */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
-    const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
+    const Py_UNICODE *object,
+    Py_ssize_t length,
+    Py_ssize_t start,
+    Py_ssize_t end,
+    const char *reason          /* UTF-8 encoded string */
+    );
+#endif
 
 /* get the encoding attribute */
 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
@@ -293,11 +336,17 @@
 /* assign a new value to the reason attribute
    return 0 on success, -1 on failure */
 PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason(
-    PyObject *, const char *);
+    PyObject *exc,
+    const char *reason          /* UTF-8 encoded string */
+    );
 PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
-    PyObject *, const char *);
+    PyObject *exc,
+    const char *reason          /* UTF-8 encoded string */
+    );
 PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
-    PyObject *, const char *);
+    PyObject *exc,
+    const char *reason          /* UTF-8 encoded string */
+    );
 
 
 /* These APIs aren't really part of the error implementation, but

Modified: python/branches/py3k-cdecimal/Include/pygetopt.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pygetopt.h	(original)
+++ python/branches/py3k-cdecimal/Include/pygetopt.h	Sun Jan  2 13:18:37 2011
@@ -5,9 +5,11 @@
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 PyAPI_DATA(int) _PyOS_opterr;
 PyAPI_DATA(int) _PyOS_optind;
 PyAPI_DATA(wchar_t *) _PyOS_optarg;
+#endif
 
 PyAPI_FUNC(int) _PyOS_GetOpt(int argc, wchar_t **argv, wchar_t *optstring);
 

Modified: python/branches/py3k-cdecimal/Include/pymath.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pymath.h	(original)
+++ python/branches/py3k-cdecimal/Include/pymath.h	Sun Jan  2 13:18:37 2011
@@ -67,6 +67,7 @@
    nothing. */
 
 /* we take double rounding as evidence of x87 usage */
+#ifndef Py_LIMITED_API
 #ifndef Py_FORCE_DOUBLE
 #  ifdef X87_DOUBLE_ROUNDING
 PyAPI_FUNC(double) _Py_force_double(double);
@@ -75,11 +76,14 @@
 #    define Py_FORCE_DOUBLE(X) (X)
 #  endif
 #endif
+#endif
 
+#ifndef Py_LIMITED_API
 #ifdef HAVE_GCC_ASM_FOR_X87
 PyAPI_FUNC(unsigned short) _Py_get_387controlword(void);
 PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);
 #endif
+#endif
 
 /* Py_IS_NAN(X)
  * Return 1 if float or double arg is a NaN, else 0.

Modified: python/branches/py3k-cdecimal/Include/pystate.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pystate.h	(original)
+++ python/branches/py3k-cdecimal/Include/pystate.h	Sun Jan  2 13:18:37 2011
@@ -13,6 +13,9 @@
 struct _ts; /* Forward */
 struct _is; /* Forward */
 
+#ifdef Py_LIMITED_API
+typedef struct _is PyInterpreterState;
+#else
 typedef struct _is {
 
     struct _is *next;
@@ -37,12 +40,14 @@
 #endif
 
 } PyInterpreterState;
+#endif
 
 
 /* State unique per thread */
 
 struct _frame; /* Avoid including frameobject.h */
 
+#ifndef Py_LIMITED_API
 /* Py_tracefunc return -1 when raising an exception, or 0 for success. */
 typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
 
@@ -54,7 +59,11 @@
 #define PyTrace_C_CALL 4
 #define PyTrace_C_EXCEPTION 5
 #define PyTrace_C_RETURN 6
+#endif
 
+#ifdef Py_LIMITED_API
+typedef struct _ts PyThreadState;
+#else
 typedef struct _ts {
     /* See Python/ceval.c for comments explaining most fields */
 
@@ -106,6 +115,7 @@
     /* XXX signal handlers should also be here */
 
 } PyThreadState;
+#endif
 
 
 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
@@ -133,9 +143,11 @@
 
 /* Assuming the current thread holds the GIL, this is the
    PyThreadState for the current thread. */
+#ifndef Py_LIMITED_API
 PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
+#endif
 
-#ifdef Py_DEBUG
+#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
 #define PyThreadState_GET() PyThreadState_Get()
 #else
 #define PyThreadState_GET() \
@@ -190,19 +202,25 @@
 /* The implementation of sys._current_frames()  Returns a dict mapping
    thread id to that thread's current frame.
 */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
+#endif
 
 /* Routines for advanced debuggers, requested by David Beazley.
    Don't use unless you know what you are doing! */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
 PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
 PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
 
 typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
+#endif
 
 /* hook for PyEval_GetFrame(), requested for Psyco */
+#ifndef Py_LIMITED_API
 PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/pystrtod.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pystrtod.h	(original)
+++ python/branches/py3k-cdecimal/Include/pystrtod.h	Sun Jan  2 13:18:37 2011
@@ -18,7 +18,9 @@
                                          int flags,
                                          int *type);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr);
+#endif
 
 
 /* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */

Modified: python/branches/py3k-cdecimal/Include/pythonrun.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pythonrun.h	(original)
+++ python/branches/py3k-cdecimal/Include/pythonrun.h	Sun Jan  2 13:18:37 2011
@@ -16,9 +16,11 @@
 #define PyCF_ONLY_AST 0x0400
 #define PyCF_IGNORE_COOKIE 0x0800
 
+#ifndef Py_LIMITED_API
 typedef struct {
     int cf_flags;  /* bitmask of CO_xxx flags relevant to future */
 } PyCompilerFlags;
+#endif
 
 PyAPI_FUNC(void) Py_SetProgramName(wchar_t *);
 PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
@@ -33,41 +35,87 @@
 PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
 PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
 
-PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
-
-PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *,
-                                                 int, PyCompilerFlags *flags,
-                                                 PyArena *);
-PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *,
-                                               const char*, int,
-                                               char *, char *,
-                                               PyCompilerFlags *, int *,
-                                               PyArena *);
+PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
+PyAPI_FUNC(int) PyRun_AnyFileExFlags(
+    FILE *fp,
+    const char *filename,       /* decoded from the filesystem encoding */
+    int closeit,
+    PyCompilerFlags *flags);
+PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
+    FILE *fp,
+    const char *filename,       /* decoded from the filesystem encoding */
+    int closeit,
+    PyCompilerFlags *flags);
+PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
+    FILE *fp,
+    const char *filename,       /* decoded from the filesystem encoding */
+    PyCompilerFlags *flags);
+PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
+    FILE *fp,
+    const char *filename,       /* decoded from the filesystem encoding */
+    PyCompilerFlags *flags);
+
+PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(
+    const char *s,
+    const char *filename,       /* decoded from the filesystem encoding */
+    int start,
+    PyCompilerFlags *flags,
+    PyArena *arena);
+PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(
+    FILE *fp,
+    const char *filename,       /* decoded from the filesystem encoding */
+    const char* enc,
+    int start,
+    char *ps1,
+    char *ps2,
+    PyCompilerFlags *flags,
+    int *errcode,
+    PyArena *arena);
+#endif
+
+#ifndef PyParser_SimpleParseString
 #define PyParser_SimpleParseString(S, B) \
     PyParser_SimpleParseStringFlags(S, B, 0)
 #define PyParser_SimpleParseFile(FP, S, B) \
     PyParser_SimpleParseFileFlags(FP, S, B, 0)
+#endif
 PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
                                                           int);
 PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
                                                         int, int);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
                                          PyObject *, PyCompilerFlags *);
 
-PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int,
-                                         PyObject *, PyObject *, int,
-                                         PyCompilerFlags *);
-
-#define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL)
-PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
-                                             PyCompilerFlags *);
-PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
+PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
+    FILE *fp,
+    const char *filename,       /* decoded from the filesystem encoding */
+    int start,
+    PyObject *globals,
+    PyObject *locals,
+    int closeit,
+    PyCompilerFlags *flags);
+#endif
+
+#ifdef Py_LIMITED_API
+PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
+#else
+#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
+#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
+PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
+    const char *str,
+    const char *filename,       /* decoded from the filesystem encoding */
+    int start,
+    PyCompilerFlags *flags,
+    int optimize);
+#endif
+PyAPI_FUNC(struct symtable *) Py_SymtableString(
+    const char *str,
+    const char *filename,       /* decoded from the filesystem encoding */
+    int start);
 
 PyAPI_FUNC(void) PyErr_Print(void);
 PyAPI_FUNC(void) PyErr_PrintEx(int);
@@ -76,19 +124,24 @@
 /* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
  * exit functions.
  */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(void));
+#endif
 PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
 
 PyAPI_FUNC(void) Py_Exit(int);
 
 /* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _Py_RestoreSignals(void);
 
 PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
+#endif
 
 /* Bootstrap */
 PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
 
+#ifndef Py_LIMITED_API
 /* Use macros for a bunch of old variants */
 #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
 #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
@@ -107,6 +160,7 @@
     PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
 #define PyRun_FileFlags(fp, p, s, g, l, flags) \
     PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
+#endif
 
 /* In getpath.c */
 PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
@@ -114,6 +168,9 @@
 PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
 PyAPI_FUNC(wchar_t *) Py_GetPath(void);
 PyAPI_FUNC(void)      Py_SetPath(const wchar_t *);
+#ifdef MS_WINDOWS
+int _Py_CheckPython3();
+#endif
 
 /* In their own files */
 PyAPI_FUNC(const char *) Py_GetVersion(void);
@@ -121,11 +178,14 @@
 PyAPI_FUNC(const char *) Py_GetCopyright(void);
 PyAPI_FUNC(const char *) Py_GetCompiler(void);
 PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(const char *) _Py_svnversion(void);
 PyAPI_FUNC(const char *) Py_SubversionRevision(void);
 PyAPI_FUNC(const char *) Py_SubversionShortBranch(void);
+#endif
 
 /* Internal -- various one-time initializations */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
 PyAPI_FUNC(PyObject *) _PySys_Init(void);
 PyAPI_FUNC(void) _PyImport_Init(void);
@@ -134,8 +194,10 @@
 PyAPI_FUNC(int) _PyFrame_Init(void);
 PyAPI_FUNC(void) _PyFloat_Init(void);
 PyAPI_FUNC(int) PyByteArray_Init(void);
+#endif
 
 /* Various internal finalizers */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _PyExc_Fini(void);
 PyAPI_FUNC(void) _PyImport_Fini(void);
 PyAPI_FUNC(void) PyMethod_Fini(void);
@@ -150,12 +212,17 @@
 PyAPI_FUNC(void) PyFloat_Fini(void);
 PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
 PyAPI_FUNC(void) _PyGC_Fini(void);
+#endif
 
 /* Stuff with no proper home (yet) */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
+#endif
 PyAPI_DATA(int) (*PyOS_InputHook)(void);
 PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
+#ifndef Py_LIMITED_API
 PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
+#endif
 
 /* Stack size, in "pointers" (so we get extra safety margins
    on 64-bit platforms).  On a 32-bit platform, this translates

Modified: python/branches/py3k-cdecimal/Include/pythread.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pythread.h	(original)
+++ python/branches/py3k-cdecimal/Include/pythread.h	Sun Jan  2 13:18:37 2011
@@ -9,6 +9,14 @@
 extern "C" {
 #endif
 
+/* Return status codes for Python lock acquisition.  Chosen for maximum
+ * backwards compatibility, ie failure -> 0, success -> 1.  */
+typedef enum PyLockStatus {
+    PY_LOCK_FAILURE = 0,
+    PY_LOCK_ACQUIRED = 1,
+    PY_LOCK_INTR
+} PyLockStatus;
+
 PyAPI_FUNC(void) PyThread_init_thread(void);
 PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *);
 PyAPI_FUNC(void) PyThread_exit_thread(void);
@@ -49,11 +57,18 @@
    even when the lock can't be acquired.
    If microseconds > 0, the call waits up to the specified duration.
    If microseconds < 0, the call waits until success (or abnormal failure)
-   
+
    microseconds must be less than PY_TIMEOUT_MAX. Behaviour otherwise is
-   undefined. */
-PyAPI_FUNC(int) PyThread_acquire_lock_timed(PyThread_type_lock,
-					    PY_TIMEOUT_T microseconds);
+   undefined.
+
+   If intr_flag is true and the acquire is interrupted by a signal, then the
+   call will return PY_LOCK_INTR.  The caller may reattempt to acquire the
+   lock.
+*/
+PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed(PyThread_type_lock,
+                                                     PY_TIMEOUT_T microseconds,
+                                                     int intr_flag);
+
 PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
 
 PyAPI_FUNC(size_t) PyThread_get_stacksize(void);

Modified: python/branches/py3k-cdecimal/Include/pytime.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/pytime.h	(original)
+++ python/branches/py3k-cdecimal/Include/pytime.h	Sun Jan  2 13:18:37 2011
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_PYTIME_H
 #define Py_PYTIME_H
 
@@ -44,3 +45,4 @@
 #endif
 
 #endif /* Py_PYTIME_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/setobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/setobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/setobject.h	Sun Jan  2 13:18:37 2011
@@ -18,7 +18,7 @@
 hold a search finger.  The hash field of Unused or Dummy slots has
 no meaning otherwise.
 */
-
+#ifndef Py_LIMITED_API
 #define PySet_MINSIZE 8
 
 typedef struct {
@@ -56,6 +56,7 @@
     Py_hash_t hash;                  /* only used by frozenset objects */
     PyObject *weakreflist;      /* List of weak references */
 };
+#endif /* Py_LIMITED_API */
 
 PyAPI_DATA(PyTypeObject) PySet_Type;
 PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
@@ -85,14 +86,20 @@
 PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
 PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
 PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset);
+#ifndef Py_LIMITED_API
 #define PySet_GET_SIZE(so) (((PySetObject *)(so))->used)
+#endif
 PyAPI_FUNC(int) PySet_Clear(PyObject *set);
 PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key);
 PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key);
 PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash);
+#endif
 PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/sliceobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/sliceobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/sliceobject.h	Sun Jan  2 13:18:37 2011
@@ -18,11 +18,12 @@
 names are from range).  After much talk with Guido, it was decided to
 let these be any arbitrary python type.  Py_None stands for omitted values.
 */
-
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     PyObject *start, *stop, *step;	/* not NULL */
 } PySliceObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PySlice_Type;
 PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
@@ -31,10 +32,12 @@
 
 PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
                                   PyObject* step);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
-PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
+#endif
+PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
                                   Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
-PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
+PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
 				    Py_ssize_t *start, Py_ssize_t *stop, 
 				    Py_ssize_t *step, Py_ssize_t *slicelength);
 

Modified: python/branches/py3k-cdecimal/Include/structseq.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/structseq.h	(original)
+++ python/branches/py3k-cdecimal/Include/structseq.h	Sun Jan  2 13:18:37 2011
@@ -21,18 +21,25 @@
 
 extern char* PyStructSequence_UnnamedField;
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
                                            PyStructSequence_Desc *desc);
+#endif
+PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);
 
 PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
 
+#ifndef Py_LIMITED_API
 typedef PyTupleObject PyStructSequence;
 
 /* Macro, *only* to be used to fill in brand new objects */
 #define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM(op, i, v)
 
 #define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i)
+#endif
 
+PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
+PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/symtable.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/symtable.h	(original)
+++ python/branches/py3k-cdecimal/Include/symtable.h	Sun Jan  2 13:18:37 2011
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_SYMTABLE_H
 #define Py_SYMTABLE_H
 
@@ -15,7 +16,8 @@
 struct _symtable_entry;
 
 struct symtable {
-    const char *st_filename;        /* name of file being compiled */
+    const char *st_filename;        /* name of file being compiled,
+                                       decoded from the filesystem encoding */
     struct _symtable_entry *st_cur; /* current symbol table entry */
     struct _symtable_entry *st_top; /* symbol table entry for module */
     PyObject *st_blocks;            /* dict: map AST node addresses
@@ -59,8 +61,10 @@
 
 PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
 
-PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *,
-                                              PyFutureFeatures *);
+PyAPI_FUNC(struct symtable *) PySymtable_Build(
+    mod_ty mod,
+    const char *filename,       /* decoded from the filesystem encoding */
+    PyFutureFeatures *future);
 PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);
 
 PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
@@ -102,3 +106,4 @@
 }
 #endif
 #endif /* !Py_SYMTABLE_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/sysmodule.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/sysmodule.h	(original)
+++ python/branches/py3k-cdecimal/Include/sysmodule.h	Sun Jan  2 13:18:37 2011
@@ -20,7 +20,9 @@
 PyAPI_FUNC(void) PySys_FormatStdout(const char *format, ...);
 PyAPI_FUNC(void) PySys_FormatStderr(const char *format, ...);
 
+#ifndef Py_LIMITED_API
 PyAPI_DATA(PyObject *) _PySys_TraceFunc, *_PySys_ProfileFunc;
+#endif
 
 PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
 PyAPI_FUNC(void) PySys_AddWarnOption(const wchar_t *);

Modified: python/branches/py3k-cdecimal/Include/timefuncs.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/timefuncs.h	(original)
+++ python/branches/py3k-cdecimal/Include/timefuncs.h	Sun Jan  2 13:18:37 2011
@@ -14,7 +14,9 @@
  * to fit in a time_t.  ValueError is set on return iff the return
  * value is (time_t)-1 and PyErr_Occurred().
  */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x);
+#endif
 
 
 #ifdef __cplusplus

Modified: python/branches/py3k-cdecimal/Include/token.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/token.h	(original)
+++ python/branches/py3k-cdecimal/Include/token.h	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,6 @@
 
 /* Token types */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_TOKEN_H
 #define Py_TOKEN_H
 #ifdef __cplusplus
@@ -85,3 +85,4 @@
 }
 #endif
 #endif /* !Py_TOKEN_H */
+#endif /* Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/traceback.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/traceback.h	(original)
+++ python/branches/py3k-cdecimal/Include/traceback.h	Sun Jan  2 13:18:37 2011
@@ -8,7 +8,7 @@
 struct _frame;
 
 /* Traceback interface */
-
+#ifndef Py_LIMITED_API
 typedef struct _traceback {
     PyObject_HEAD
     struct _traceback *tb_next;
@@ -16,10 +16,13 @@
     int tb_lasti;
     int tb_lineno;
 } PyTracebackObject;
+#endif
 
 PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
 PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
+#endif
 
 /* Reveal traceback type so we can typecheck traceback objects */
 PyAPI_DATA(PyTypeObject) PyTraceBack_Type;

Modified: python/branches/py3k-cdecimal/Include/tupleobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/tupleobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/tupleobject.h	Sun Jan  2 13:18:37 2011
@@ -21,6 +21,7 @@
 returned item's reference count.
 */
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_VAR_HEAD
     PyObject *ob_item[1];
@@ -30,6 +31,7 @@
      * the tuple is not yet visible outside the function that builds it.
      */
 } PyTupleObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyTuple_Type;
 PyAPI_DATA(PyTypeObject) PyTupleIter_Type;
@@ -43,16 +45,22 @@
 PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t);
 PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
 PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t);
+#endif
 PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
+#endif
 
 /* Macro, trading safety for speed */
+#ifndef Py_LIMITED_API
 #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
 #define PyTuple_GET_SIZE(op)    Py_SIZE(op)
 
 /* Macro, *only* to be used to fill in brand new tuples */
 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
+#endif
 
 PyAPI_FUNC(int) PyTuple_ClearFreeList(void);
 

Modified: python/branches/py3k-cdecimal/Include/ucnhash.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/ucnhash.h	(original)
+++ python/branches/py3k-cdecimal/Include/ucnhash.h	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,5 @@
 /* Unicode name database interface */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_UCNHASH_H
 #define Py_UCNHASH_H
 #ifdef __cplusplus
@@ -31,3 +31,4 @@
 }
 #endif
 #endif /* !Py_UCNHASH_H */
+#endif /* !Py_LIMITED_API */

Modified: python/branches/py3k-cdecimal/Include/unicodeobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/unicodeobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/unicodeobject.h	Sun Jan  2 13:18:37 2011
@@ -131,7 +131,9 @@
    Python and represents a single Unicode element in the Unicode
    type. */
 
+#ifndef Py_LIMITED_API
 typedef PY_UNICODE_TYPE Py_UNICODE;
+#endif
 
 /* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */
 
@@ -318,6 +320,7 @@
    _Py_ascii_whitespace (see below) with an inlined check.
 
  */
+#ifndef Py_LIMITED_API
 #define Py_UNICODE_ISSPACE(ch) \
     ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch))
 
@@ -362,6 +365,7 @@
     ((*((string)->str + (offset)) == *((substring)->str)) && \
     ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \
      !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE)))
+#endif /* Py_LIMITED_API */
 
 #ifdef __cplusplus
 extern "C" {
@@ -369,6 +373,7 @@
 
 /* --- Unicode Type ------------------------------------------------------- */
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     Py_ssize_t length;          /* Length of raw Unicode data in buffer */
@@ -381,6 +386,7 @@
                                    string, or NULL; this is used for
                                    implementing the buffer protocol */
 } PyUnicodeObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyUnicode_Type;
 PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
@@ -394,6 +400,7 @@
 #define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type)
 
 /* Fast access macros */
+#ifndef Py_LIMITED_API
 #define PyUnicode_GET_SIZE(op) \
     (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->length))
 #define PyUnicode_GET_DATA_SIZE(op) \
@@ -402,6 +409,7 @@
     (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->str))
 #define PyUnicode_AS_DATA(op) \
     (assert(PyUnicode_Check(op)),((const char *)((PyUnicodeObject *)(op))->str))
+#endif
 
 /* --- Constants ---------------------------------------------------------- */
 
@@ -426,29 +434,33 @@
 
    The buffer is copied into the new object. */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
     const Py_UNICODE *u,        /* Unicode buffer */
     Py_ssize_t size             /* size of buffer */
     );
+#endif
 
 /* Similar to PyUnicode_FromUnicode(), but u points to UTF-8 encoded bytes */
 PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize(
-    const char *u,        /* char buffer */
-    Py_ssize_t size       /* size of buffer */
+    const char *u,             /* UTF-8 encoded string */
+    Py_ssize_t size            /* size of buffer */
     );
 
 /* Similar to PyUnicode_FromUnicode(), but u points to null-terminated
    UTF-8 encoded bytes */
 PyAPI_FUNC(PyObject*) PyUnicode_FromString(
-    const char *u        /* string */
+    const char *u              /* UTF-8 encoded string */
     );
 
 /* Return a read-only pointer to the Unicode object's internal
    Py_UNICODE buffer. */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
     PyObject *unicode           /* Unicode object */
     );
+#endif
 
 /* Get the length of the Unicode object. */
 
@@ -456,8 +468,10 @@
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 /* Get the maximum ordinal for a Unicode character. */
 PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void);
+#endif
 
 /* Resize an already allocated Unicode object to the new size length.
 
@@ -527,16 +541,22 @@
     ...
     );
 
+#ifndef Py_LIMITED_API
 /* Format the object based on the format_spec, as defined in PEP 3101
    (Advanced String Formatting). */
 PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj,
                                                  Py_UNICODE *format_spec,
                                                  Py_ssize_t format_spec_len);
+#endif
 
 PyAPI_FUNC(void) PyUnicode_InternInPlace(PyObject **);
 PyAPI_FUNC(void) PyUnicode_InternImmortal(PyObject **);
-PyAPI_FUNC(PyObject *) PyUnicode_InternFromString(const char *);
+PyAPI_FUNC(PyObject *) PyUnicode_InternFromString(
+    const char *u              /* UTF-8 encoded string */
+    );
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _Py_ReleaseInternedUnicodeStrings(void);
+#endif
 
 /* Use only if you know it's a string */
 #define PyUnicode_CHECK_INTERNED(op) (((PyUnicodeObject *)(op))->state)
@@ -568,7 +588,7 @@
    error. */
 
 PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
-    PyUnicodeObject *unicode,   /* Unicode object */
+    PyObject *unicode,          /* Unicode object */
     register wchar_t *w,        /* wchar_t buffer */
     Py_ssize_t size             /* size of buffer */
     );
@@ -646,9 +666,11 @@
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString(
     PyObject *unicode,
     const char *errors);
+#endif
 
 /* Returns a pointer to the default encoding (UTF-8) of the
    Unicode object unicode and the size of the encoded representation
@@ -664,9 +686,11 @@
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(char *) _PyUnicode_AsStringAndSize(
     PyObject *unicode,
     Py_ssize_t *size);
+#endif
 
 /* Returns a pointer to the default encoding (UTF-8) of the
    Unicode object unicode.
@@ -682,7 +706,9 @@
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(char *) _PyUnicode_AsString(PyObject *unicode);
+#endif
 
 /* Returns "utf-8".  */
 
@@ -721,12 +747,14 @@
 /* Encodes a Py_UNICODE buffer of the given size and returns a
    Python string object. */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_Encode(
     const Py_UNICODE *s,        /* Unicode char buffer */
     Py_ssize_t size,            /* number of Py_UNICODE chars to encode */
     const char *encoding,       /* encoding */
     const char *errors          /* error handling */
     );
+#endif
 
 /* Encodes a Unicode object and returns the result as Python
    object. */
@@ -776,6 +804,7 @@
     Py_ssize_t *consumed        /* bytes consumed */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* number of Py_UNICODE chars to encode */
@@ -783,6 +812,7 @@
     int base64WhiteSpace,       /* Encode whitespace (sp, ht, nl, cr) in base64 */
     const char *errors          /* error handling */
     );
+#endif
 
 /* --- UTF-8 Codecs ------------------------------------------------------- */
 
@@ -803,11 +833,13 @@
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* number of Py_UNICODE chars to encode */
     const char *errors          /* error handling */
     );
+#endif
 
 /* --- UTF-32 Codecs ------------------------------------------------------ */
 
@@ -876,12 +908,14 @@
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* number of Py_UNICODE chars to encode */
     const char *errors,         /* error handling */
     int byteorder               /* byteorder to use 0=BOM+native;-1=LE,1=BE */
     );
+#endif
 
 /* --- UTF-16 Codecs ------------------------------------------------------ */
 
@@ -954,12 +988,14 @@
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* number of Py_UNICODE chars to encode */
     const char *errors,         /* error handling */
     int byteorder               /* byteorder to use 0=BOM+native;-1=LE,1=BE */
     );
+#endif
 
 /* --- Unicode-Escape Codecs ---------------------------------------------- */
 
@@ -973,10 +1009,12 @@
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length           /* Number of Py_UNICODE chars to encode */
     );
+#endif
 
 /* --- Raw-Unicode-Escape Codecs ------------------------------------------ */
 
@@ -990,20 +1028,24 @@
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length           /* Number of Py_UNICODE chars to encode */
     );
+#endif
 
 /* --- Unicode Internal Codec ---------------------------------------------
 
     Only for internal use in _codecsmodule.c */
 
+#ifndef Py_LIMITED_API
 PyObject *_PyUnicode_DecodeUnicodeInternal(
     const char *string,
     Py_ssize_t length,
     const char *errors
     );
+#endif
 
 /* --- Latin-1 Codecs -----------------------------------------------------
 
@@ -1021,11 +1063,13 @@
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     const char *errors          /* error handling */
     );
+#endif
 
 /* --- ASCII Codecs -------------------------------------------------------
 
@@ -1043,11 +1087,13 @@
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     const char *errors          /* error handling */
     );
+#endif
 
 /* --- Character Map Codecs -----------------------------------------------
 
@@ -1085,6 +1131,7 @@
                                    (unicode ordinal -> char ordinal) */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
@@ -1092,6 +1139,7 @@
                                    (unicode ordinal -> char ordinal) */
     const char *errors          /* error handling */
     );
+#endif
 
 /* Translate a Py_UNICODE buffer of the given length by applying a
    character mapping table to it and return the resulting Unicode
@@ -1106,12 +1154,14 @@
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     PyObject *table,            /* Translate table */
     const char *errors          /* error handling */
     );
+#endif
 
 #ifdef MS_WIN32
 
@@ -1134,11 +1184,13 @@
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     const char *errors          /* error handling */
     );
+#endif
 
 #endif /* MS_WIN32 */
 
@@ -1166,12 +1218,27 @@
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
     Py_UNICODE *s,              /* Unicode buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     char *output,               /* Output buffer; must have size >= length */
     const char *errors          /* error handling */
     );
+#endif
+
+/* Transforms code points that have decimal digit property to the
+   corresponding ASCII digit code points.
+
+   Returns a new Unicode string on success, NULL on failure.
+*/
+
+#ifndef Py_LIMITED_API
+PyAPI_FUNC(PyObject*) PyUnicode_TransformDecimalToASCII(
+    Py_UNICODE *s,              /* Unicode buffer */
+    Py_ssize_t length           /* Number of Py_UNICODE chars to transform */
+    );
+#endif
 
 /* --- File system encoding ---------------------------------------------- */
 
@@ -1390,7 +1457,7 @@
 
 PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString(
     PyObject *left,
-    const char *right
+    const char *right           /* ASCII-encoded string */
     );
 
 /* Rich compare two strings and return one of the following:
@@ -1438,26 +1505,31 @@
 
 PyAPI_FUNC(int) PyUnicode_IsIdentifier(PyObject *s);
 
+#ifndef Py_LIMITED_API
 /* Externally visible for str.strip(unicode) */
 PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
     PyUnicodeObject *self,
     int striptype,
     PyObject *sepobj
     );
+#endif
 
 /* Using the current locale, insert the thousands grouping
    into the string pointed to by buffer.  For the argument descriptions,
    see Objects/stringlib/localeutil.h */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGroupingLocale(Py_UNICODE *buffer,
                                                    Py_ssize_t n_buffer,
                                                    Py_UNICODE *digits,
                                                    Py_ssize_t n_digits,
                                                    Py_ssize_t min_width);
+#endif
 
 /* Using explicit passed-in values, insert the thousands grouping
    into the string pointed to by buffer.  For the argument descriptions,
    see Objects/stringlib/localeutil.h */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(Py_UNICODE *buffer,
                                                    Py_ssize_t n_buffer,
                                                    Py_UNICODE *digits,
@@ -1465,10 +1537,12 @@
                                                    Py_ssize_t min_width,
                                                    const char *grouping,
                                                    const char *thousands_sep);
+#endif
 /* === Characters Type APIs =============================================== */
 
 /* Helper array used by Py_UNICODE_ISSPACE(). */
 
+#ifndef Py_LIMITED_API
 PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
 
 /* These should not be used directly. Use the Py_UNICODE_IS* and
@@ -1594,6 +1668,7 @@
 PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
     PyObject *unicode
     );
+#endif /* Py_LIMITED_API */
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/warnings.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/warnings.h	(original)
+++ python/branches/py3k-cdecimal/Include/warnings.h	Sun Jan  2 13:18:37 2011
@@ -4,15 +4,31 @@
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) _PyWarnings_Init(void);
+#endif
 
-PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t);
-PyAPI_FUNC(int) PyErr_WarnFormat(PyObject *, Py_ssize_t, const char *, ...);
-PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int,
-                                    const char *, PyObject *);
+PyAPI_FUNC(int) PyErr_WarnEx(
+    PyObject *category,
+    const char *message,        /* UTF-8 encoded string */
+    Py_ssize_t stack_level);
+PyAPI_FUNC(int) PyErr_WarnFormat(
+    PyObject *category,
+    Py_ssize_t stack_level,
+    const char *format,         /* ASCII-encoded string  */
+    ...);
+PyAPI_FUNC(int) PyErr_WarnExplicit(
+    PyObject *category,
+    const char *message,        /* UTF-8 encoded string */
+    const char *filename,       /* decoded from the filesystem encoding */
+    int lineno,
+    const char *module,         /* UTF-8 encoded string */
+    PyObject *registry);
 
 /* DEPRECATED: Use PyErr_WarnEx() instead. */
+#ifndef Py_LIMITED_API
 #define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
+#endif
 
 #ifdef __cplusplus
 }

Modified: python/branches/py3k-cdecimal/Include/weakrefobject.h
==============================================================================
--- python/branches/py3k-cdecimal/Include/weakrefobject.h	(original)
+++ python/branches/py3k-cdecimal/Include/weakrefobject.h	Sun Jan  2 13:18:37 2011
@@ -12,6 +12,7 @@
 /* PyWeakReference is the base struct for the Python ReferenceType, ProxyType,
  * and CallableProxyType.
  */
+#ifndef Py_LIMITED_API
 struct _PyWeakReference {
     PyObject_HEAD
 
@@ -37,6 +38,7 @@
     PyWeakReference *wr_prev;
     PyWeakReference *wr_next;
 };
+#endif
 
 PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
 PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
@@ -62,9 +64,11 @@
                                                 PyObject *callback);
 PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
 
 PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
+#endif
 
 #define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object)
 

Modified: python/branches/py3k-cdecimal/LICENSE
==============================================================================
--- python/branches/py3k-cdecimal/LICENSE	(original)
+++ python/branches/py3k-cdecimal/LICENSE	Sun Jan  2 13:18:37 2011
@@ -68,7 +68,7 @@
     3.1             3.0.1       2009        PSF         yes
     3.1.1           3.1         2009        PSF         yes
     3.1.2           3.1         2010        PSF         yes
-    3.2             3.1         2010        PSF         yes
+    3.2             3.1         2011        PSF         yes
 
 Footnotes:
 
@@ -103,9 +103,9 @@
 analyze, test, perform and/or display publicly, prepare derivative works,
 distribute, and otherwise use Python alone or in any derivative version,
 provided, however, that PSF's License Agreement and PSF's notice of copyright,
-i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-Python Software Foundation; All Rights Reserved" are retained in Python alone or
-in any derivative version prepared by Licensee.
+i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+2011 Python Software Foundation; All Rights Reserved" are retained in Python
+alone or in any derivative version prepared by Licensee.
 
 3. In the event Licensee prepares a derivative work that is based on
 or incorporates Python or any part thereof, and wants to make

Modified: python/branches/py3k-cdecimal/Lib/_abcoll.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/_abcoll.py	(original)
+++ python/branches/py3k-cdecimal/Lib/_abcoll.py	Sun Jan  2 13:18:37 2011
@@ -90,7 +90,8 @@
     @classmethod
     def __subclasshook__(cls, C):
         if cls is Iterator:
-            if any("__next__" in B.__dict__ for B in C.__mro__):
+            if (any("__next__" in B.__dict__ for B in C.__mro__) and
+                any("__iter__" in B.__dict__ for B in C.__mro__)):
                 return True
         return NotImplemented
 

Modified: python/branches/py3k-cdecimal/Lib/_pyio.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/_pyio.py	(original)
+++ python/branches/py3k-cdecimal/Lib/_pyio.py	Sun Jan  2 13:18:37 2011
@@ -676,7 +676,7 @@
     """
 
     def __init__(self, raw):
-        self.raw = raw
+        self._raw = raw
 
     ### Positioning ###
 
@@ -720,8 +720,8 @@
         if self.raw is None:
             raise ValueError("raw stream already detached")
         self.flush()
-        raw = self.raw
-        self.raw = None
+        raw = self._raw
+        self._raw = None
         return raw
 
     ### Inquiries ###
@@ -736,6 +736,10 @@
         return self.raw.writable()
 
     @property
+    def raw(self):
+        return self._raw
+
+    @property
     def closed(self):
         return self.raw.closed
 
@@ -1465,7 +1469,7 @@
             if not isinstance(errors, str):
                 raise ValueError("invalid errors: %r" % errors)
 
-        self.buffer = buffer
+        self._buffer = buffer
         self._line_buffering = line_buffering
         self._encoding = encoding
         self._errors = errors
@@ -1520,6 +1524,10 @@
     def line_buffering(self):
         return self._line_buffering
 
+    @property
+    def buffer(self):
+        return self._buffer
+
     def seekable(self):
         return self._seekable
 
@@ -1734,8 +1742,8 @@
         if self.buffer is None:
             raise ValueError("buffer is already detached")
         self.flush()
-        buffer = self.buffer
-        self.buffer = None
+        buffer = self._buffer
+        self._buffer = None
         return buffer
 
     def seek(self, cookie, whence=0):

Modified: python/branches/py3k-cdecimal/Lib/_weakrefset.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/_weakrefset.py	(original)
+++ python/branches/py3k-cdecimal/Lib/_weakrefset.py	Sun Jan  2 13:18:37 2011
@@ -66,7 +66,11 @@
         return sum(x() is not None for x in self.data)
 
     def __contains__(self, item):
-        return ref(item) in self.data
+        try:
+            wr = ref(item)
+        except TypeError:
+            return False
+        return wr in self.data
 
     def __reduce__(self):
         return (self.__class__, (list(self),),

Modified: python/branches/py3k-cdecimal/Lib/argparse.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/argparse.py	(original)
+++ python/branches/py3k-cdecimal/Lib/argparse.py	Sun Jan  2 13:18:37 2011
@@ -88,7 +88,7 @@
 import sys as _sys
 import textwrap as _textwrap
 
-from gettext import gettext as _
+from gettext import gettext as _, ngettext
 
 
 def _callable(obj):
@@ -1023,9 +1023,13 @@
 
     class _ChoicesPseudoAction(Action):
 
-        def __init__(self, name, help):
+        def __init__(self, name, aliases, help):
+            metavar = dest = name
+            if aliases:
+                metavar += ' (%s)' % ', '.join(aliases)
             sup = super(_SubParsersAction._ChoicesPseudoAction, self)
-            sup.__init__(option_strings=[], dest=name, help=help)
+            sup.__init__(option_strings=[], dest=dest, help=help,
+                         metavar=metavar)
 
     def __init__(self,
                  option_strings,
@@ -1053,15 +1057,22 @@
         if kwargs.get('prog') is None:
             kwargs['prog'] = '%s %s' % (self._prog_prefix, name)
 
+        aliases = kwargs.pop('aliases', ())
+
         # create a pseudo-action to hold the choice help
         if 'help' in kwargs:
             help = kwargs.pop('help')
-            choice_action = self._ChoicesPseudoAction(name, help)
+            choice_action = self._ChoicesPseudoAction(name, aliases, help)
             self._choices_actions.append(choice_action)
 
         # create the parser and add it to the map
         parser = self._parser_class(**kwargs)
         self._name_parser_map[name] = parser
+
+        # make parser available under aliases also
+        for alias in aliases:
+            self._name_parser_map[alias] = parser
+
         return parser
 
     def _get_subactions(self):
@@ -1079,8 +1090,9 @@
         try:
             parser = self._name_parser_map[parser_name]
         except KeyError:
-            tup = parser_name, ', '.join(self._name_parser_map)
-            msg = _('unknown parser %r (choices: %s)' % tup)
+            args = {'parser_name': parser_name,
+                    'choices': ', '.join(self._name_parser_map)}
+            msg = _('unknown parser %(parser_name)r (choices: %(choices)s)') % args
             raise ArgumentError(self, msg)
 
         # parse all the remaining options into the namespace
@@ -1121,7 +1133,7 @@
             elif 'w' in self._mode:
                 return _sys.stdout
             else:
-                msg = _('argument "-" with mode %r' % self._mode)
+                msg = _('argument "-" with mode %r') % self._mode
                 raise ValueError(msg)
 
         # all other arguments are used as file names
@@ -1380,10 +1392,11 @@
         for option_string in args:
             # error on strings that don't start with an appropriate prefix
             if not option_string[0] in self.prefix_chars:
-                msg = _('invalid option string %r: '
-                        'must start with a character %r')
-                tup = option_string, self.prefix_chars
-                raise ValueError(msg % tup)
+                args = {'option': option_string,
+                        'prefix_chars': self.prefix_chars}
+                msg = _('invalid option string %(option)r: '
+                        'must start with a character %(prefix_chars)r')
+                raise ValueError(msg % args)
 
             # strings starting with two prefix characters are long options
             option_strings.append(option_string)
@@ -1436,7 +1449,9 @@
             conflict_handler(action, confl_optionals)
 
     def _handle_conflict_error(self, action, conflicting_actions):
-        message = _('conflicting option string(s): %s')
+        message = ngettext('conflicting option string: %s',
+                           'conflicting option strings: %s',
+                           len(conflicting_actions))
         conflict_string = ', '.join([option_string
                                      for option_string, action
                                      in conflicting_actions])
@@ -1993,7 +2008,9 @@
                 OPTIONAL: _('expected at most one argument'),
                 ONE_OR_MORE: _('expected at least one argument'),
             }
-            default = _('expected %s argument(s)') % action.nargs
+            default = ngettext('expected %s argument',
+                               'expected %s arguments',
+                               action.nargs) % action.nargs
             msg = nargs_errors.get(action.nargs, default)
             raise ArgumentError(action, msg)
 
@@ -2049,8 +2066,9 @@
         if len(option_tuples) > 1:
             options = ', '.join([option_string
                 for action, option_string, explicit_arg in option_tuples])
-            tup = arg_string, options
-            self.error(_('ambiguous option: %s could match %s') % tup)
+            args = {'option': arg_string, 'matches': options}
+            msg = _('ambiguous option: %(option)s could match %(matches)s')
+            self.error(msg % args)
 
         # if exactly one action matched, this segmentation is good,
         # so return the parsed action
@@ -2229,8 +2247,9 @@
         # TypeErrors or ValueErrors also indicate errors
         except (TypeError, ValueError):
             name = getattr(action.type, '__name__', repr(action.type))
-            msg = _('invalid %s value: %r')
-            raise ArgumentError(action, msg % (name, arg_string))
+            args = {'type': name, 'value': arg_string}
+            msg = _('invalid %(type)s value: %(value)r')
+            raise ArgumentError(action, msg % args)
 
         # return the converted value
         return result
@@ -2238,9 +2257,10 @@
     def _check_value(self, action, value):
         # converted value must be one of the choices (if specified)
         if action.choices is not None and value not in action.choices:
-            tup = value, ', '.join(map(repr, action.choices))
-            msg = _('invalid choice: %r (choose from %s)') % tup
-            raise ArgumentError(action, msg)
+            args = {'value': value,
+                    'choices': ', '.join(map(repr, action.choices))}
+            msg = _('invalid choice: %(value)r (choose from %(choices)s)')
+            raise ArgumentError(action, msg % args)
 
     # =======================
     # Help-formatting methods
@@ -2332,4 +2352,5 @@
         should either exit or raise an exception.
         """
         self.print_usage(_sys.stderr)
-        self.exit(2, _('%s: error: %s\n') % (self.prog, message))
+        args = {'prog': self.prog, 'message': message}
+        self.exit(2, _('%(prog)s: error: %(message)s\n') % args)

Modified: python/branches/py3k-cdecimal/Lib/bdb.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/bdb.py	(original)
+++ python/branches/py3k-cdecimal/Lib/bdb.py	Sun Jan  2 13:18:37 2011
@@ -3,16 +3,14 @@
 import fnmatch
 import sys
 import os
-import types
 
-__all__ = ["BdbQuit","Bdb","Breakpoint"]
+__all__ = ["BdbQuit", "Bdb", "Breakpoint"]
 
 class BdbQuit(Exception):
-    """Exception to give up completely"""
+    """Exception to give up completely."""
 
 
 class Bdb:
-
     """Generic Python debugger base class.
 
     This class takes care of details of the trace facility;
@@ -120,14 +118,14 @@
 
     def break_here(self, frame):
         filename = self.canonic(frame.f_code.co_filename)
-        if not filename in self.breaks:
+        if filename not in self.breaks:
             return False
         lineno = frame.f_lineno
-        if not lineno in self.breaks[filename]:
+        if lineno not in self.breaks[filename]:
             # The line itself has no breakpoint, but maybe the line is the
             # first line of a function with breakpoint set by function name.
             lineno = frame.f_code.co_firstlineno
-            if not lineno in self.breaks[filename]:
+            if lineno not in self.breaks[filename]:
                 return False
 
         # flag says ok to delete temp. bp
@@ -170,7 +168,7 @@
     def _set_stopinfo(self, stopframe, returnframe, stoplineno=0):
         self.stopframe = stopframe
         self.returnframe = returnframe
-        self.quitting = 0
+        self.quitting = False
         # stoplineno >= 0 means: stop at line >= the stoplineno
         # stoplineno -1 means: don't stop at all
         self.stoplineno = stoplineno
@@ -227,7 +225,7 @@
     def set_quit(self):
         self.stopframe = self.botframe
         self.returnframe = None
-        self.quitting = 1
+        self.quitting = True
         sys.settrace(None)
 
     # Derived classes and clients can call the following methods
@@ -237,47 +235,47 @@
     # Call self.get_*break*() to see the breakpoints or better
     # for bp in Breakpoint.bpbynumber: if bp: bp.bpprint().
 
-    def set_break(self, filename, lineno, temporary=0, cond = None,
+    def set_break(self, filename, lineno, temporary=False, cond=None,
                   funcname=None):
         filename = self.canonic(filename)
         import linecache # Import as late as possible
         line = linecache.getline(filename, lineno)
         if not line:
-            return 'Line %s:%d does not exist' % (filename,
-                                   lineno)
-        if not filename in self.breaks:
-            self.breaks[filename] = []
-        list = self.breaks[filename]
-        if not lineno in list:
+            return 'Line %s:%d does not exist' % (filename, lineno)
+        list = self.breaks.setdefault(filename, [])
+        if lineno not in list:
             list.append(lineno)
         bp = Breakpoint(filename, lineno, temporary, cond, funcname)
 
+    def _prune_breaks(self, filename, lineno):
+        if (filename, lineno) not in Breakpoint.bplist:
+            self.breaks[filename].remove(lineno)
+        if not self.breaks[filename]:
+            del self.breaks[filename]
+
     def clear_break(self, filename, lineno):
         filename = self.canonic(filename)
-        if not filename in self.breaks:
+        if filename not in self.breaks:
             return 'There are no breakpoints in %s' % filename
         if lineno not in self.breaks[filename]:
-            return 'There is no breakpoint at %s:%d' % (filename,
-                                    lineno)
+            return 'There is no breakpoint at %s:%d' % (filename, lineno)
         # If there's only one bp in the list for that file,line
         # pair, then remove the breaks entry
         for bp in Breakpoint.bplist[filename, lineno][:]:
             bp.deleteMe()
-        if (filename, lineno) not in Breakpoint.bplist:
-            self.breaks[filename].remove(lineno)
-        if not self.breaks[filename]:
-            del self.breaks[filename]
+        self._prune_breaks(filename, lineno)
 
     def clear_bpbynumber(self, arg):
         try:
             bp = self.get_bpbynumber(arg)
         except ValueError as err:
             return str(err)
-        self.clear_break(bp.file, bp.line)
+        bp.deleteMe()
+        self._prune_breaks(bp.file, bp.line)
 
     def clear_all_file_breaks(self, filename):
         filename = self.canonic(filename)
-        if not filename in self.breaks:
+        if filename not in self.breaks:
             return 'There are no breakpoints in %s' % filename
         for line in self.breaks[filename]:
             blist = Breakpoint.bplist[filename, line]
@@ -350,31 +348,30 @@
             i = max(0, len(stack) - 1)
         return stack, i
 
-    #
-
     def format_stack_entry(self, frame_lineno, lprefix=': '):
         import linecache, reprlib
         frame, lineno = frame_lineno
         filename = self.canonic(frame.f_code.co_filename)
         s = '%s(%r)' % (filename, lineno)
         if frame.f_code.co_name:
-            s = s + frame.f_code.co_name
+            s += frame.f_code.co_name
         else:
-            s = s + "<lambda>"
+            s += "<lambda>"
         if '__args__' in frame.f_locals:
             args = frame.f_locals['__args__']
         else:
             args = None
         if args:
-            s = s + reprlib.repr(args)
+            s += reprlib.repr(args)
         else:
-            s = s + '()'
+            s += '()'
         if '__return__' in frame.f_locals:
             rv = frame.f_locals['__return__']
-            s = s + '->'
-            s = s + reprlib.repr(rv)
+            s += '->'
+            s += reprlib.repr(rv)
         line = linecache.getline(filename, lineno, frame.f_globals)
-        if line: s = s + lprefix + line.strip()
+        if line:
+            s += lprefix + line.strip()
         return s
 
     # The following methods can be called by clients to use
@@ -394,7 +391,7 @@
         except BdbQuit:
             pass
         finally:
-            self.quitting = 1
+            self.quitting = True
             sys.settrace(None)
 
     def runeval(self, expr, globals=None, locals=None):
@@ -410,7 +407,7 @@
         except BdbQuit:
             pass
         finally:
-            self.quitting = 1
+            self.quitting = True
             sys.settrace(None)
 
     def runctx(self, cmd, globals, locals):
@@ -428,7 +425,7 @@
         except BdbQuit:
             pass
         finally:
-            self.quitting = 1
+            self.quitting = True
             sys.settrace(None)
         return res
 
@@ -438,8 +435,7 @@
 
 
 class Breakpoint:
-
-    """Breakpoint class
+    """Breakpoint class.
 
     Implements temporary breakpoints, ignore counts, disabling and
     (re)-enabling, and conditionals.
@@ -461,7 +457,7 @@
                 # index 0 is unused, except for marking an
                 # effective break .... see effective()
 
-    def __init__(self, file, line, temporary=0, cond=None, funcname=None):
+    def __init__(self, file, line, temporary=False, cond=None, funcname=None):
         self.funcname = funcname
         # Needed if funcname is not None.
         self.func_first_executable_line = None
@@ -469,11 +465,11 @@
         self.line = line
         self.temporary = temporary
         self.cond = cond
-        self.enabled = 1
+        self.enabled = True
         self.ignore = 0
         self.hits = 0
         self.number = Breakpoint.next
-        Breakpoint.next = Breakpoint.next + 1
+        Breakpoint.next += 1
         # Build the two lists
         self.bpbynumber.append(self)
         if (file, line) in self.bplist:
@@ -481,7 +477,6 @@
         else:
             self.bplist[file, line] = [self]
 
-
     def deleteMe(self):
         index = (self.file, self.line)
         self.bpbynumber[self.number] = None   # No longer in list
@@ -491,10 +486,10 @@
             del self.bplist[index]
 
     def enable(self):
-        self.enabled = 1
+        self.enabled = True
 
     def disable(self):
-        self.enabled = 0
+        self.enabled = False
 
     def bpprint(self, out=None):
         if out is None:
@@ -565,49 +560,44 @@
     that indicates if it is ok to delete a temporary bp.
 
     """
-    possibles = Breakpoint.bplist[file,line]
-    for i in range(0, len(possibles)):
-        b = possibles[i]
-        if b.enabled == 0:
+    possibles = Breakpoint.bplist[file, line]
+    for b in possibles:
+        if not b.enabled:
             continue
         if not checkfuncname(b, frame):
             continue
         # Count every hit when bp is enabled
-        b.hits = b.hits + 1
+        b.hits += 1
         if not b.cond:
-            # If unconditional, and ignoring,
-            # go on to next, else break
+            # If unconditional, and ignoring go on to next, else break
             if b.ignore > 0:
-                b.ignore = b.ignore -1
+                b.ignore -= 1
                 continue
             else:
-                # breakpoint and marker that's ok
-                # to delete if temporary
-                return (b,1)
+                # breakpoint and marker that it's ok to delete if temporary
+                return (b, True)
         else:
             # Conditional bp.
             # Ignore count applies only to those bpt hits where the
             # condition evaluates to true.
             try:
-                val = eval(b.cond, frame.f_globals,
-                       frame.f_locals)
+                val = eval(b.cond, frame.f_globals, frame.f_locals)
                 if val:
                     if b.ignore > 0:
-                        b.ignore = b.ignore -1
+                        b.ignore -= 1
                         # continue
                     else:
-                        return (b,1)
+                        return (b, True)
                 # else:
                 #   continue
             except:
-                # if eval fails, most conservative
-                # thing is to stop on breakpoint
-                # regardless of ignore count.
-                # Don't delete temporary,
-                # as another hint to user.
-                return (b,0)
+                # if eval fails, most conservative thing is to stop on
+                # breakpoint regardless of ignore count.  Don't delete
+                # temporary, as another hint to user.
+                return (b, False)
     return (None, None)
 
+
 # -------------------- testing --------------------
 
 class Tdb(Bdb):
@@ -640,5 +630,3 @@
 def test():
     t = Tdb()
     t.run('import bdb; bdb.foo(10)')
-
-# end

Modified: python/branches/py3k-cdecimal/Lib/codecs.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/codecs.py	(original)
+++ python/branches/py3k-cdecimal/Lib/codecs.py	Sun Jan  2 13:18:37 2011
@@ -396,6 +396,8 @@
 
 class StreamReader(Codec):
 
+    charbuffertype = str
+
     def __init__(self, stream, errors='strict'):
 
         """ Creates a StreamReader instance.
@@ -417,9 +419,8 @@
         self.stream = stream
         self.errors = errors
         self.bytebuffer = b""
-        # For str->str decoding this will stay a str
-        # For str->unicode decoding the first read will promote it to unicode
-        self.charbuffer = ""
+        self._empty_charbuffer = self.charbuffertype()
+        self.charbuffer = self._empty_charbuffer
         self.linebuffer = None
 
     def decode(self, input, errors='strict'):
@@ -455,7 +456,7 @@
         """
         # If we have lines cached, first merge them back into characters
         if self.linebuffer:
-            self.charbuffer = "".join(self.linebuffer)
+            self.charbuffer = self._empty_charbuffer.join(self.linebuffer)
             self.linebuffer = None
 
         # read until we get the required number of characters (if available)
@@ -498,7 +499,7 @@
         if chars < 0:
             # Return everything we've got
             result = self.charbuffer
-            self.charbuffer = ""
+            self.charbuffer = self._empty_charbuffer
         else:
             # Return the first chars characters
             result = self.charbuffer[:chars]
@@ -529,7 +530,7 @@
             return line
 
         readsize = size or 72
-        line = ""
+        line = self._empty_charbuffer
         # If size is given, we call read() only once
         while True:
             data = self.read(readsize, firstline=True)
@@ -537,7 +538,8 @@
                 # If we're at a "\r" read one extra character (which might
                 # be a "\n") to get a proper line ending. If the stream is
                 # temporarily exhausted we return the wrong line ending.
-                if data.endswith("\r"):
+                if (isinstance(data, str) and data.endswith("\r")) or \
+                   (isinstance(data, bytes) and data.endswith(b"\r")):
                     data += self.read(size=1, chars=1)
 
             line += data
@@ -563,7 +565,8 @@
                 line0withoutend = lines[0].splitlines(False)[0]
                 if line0withend != line0withoutend: # We really have a line end
                     # Put the rest back together and keep it until the next call
-                    self.charbuffer = "".join(lines[1:]) + self.charbuffer
+                    self.charbuffer = self._empty_charbuffer.join(lines[1:]) + \
+                                      self.charbuffer
                     if keepends:
                         line = line0withend
                     else:
@@ -574,7 +577,7 @@
                 if line and not keepends:
                     line = line.splitlines(False)[0]
                 break
-            if readsize<8000:
+            if readsize < 8000:
                 readsize *= 2
         return line
 
@@ -603,7 +606,7 @@
 
         """
         self.bytebuffer = b""
-        self.charbuffer = ""
+        self.charbuffer = self._empty_charbuffer
         self.linebuffer = None
 
     def seek(self, offset, whence=0):

Modified: python/branches/py3k-cdecimal/Lib/collections.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/collections.py	(original)
+++ python/branches/py3k-cdecimal/Lib/collections.py	Sun Jan  2 13:18:37 2011
@@ -22,7 +22,7 @@
 class _Link(object):
     __slots__ = 'prev', 'next', 'key', '__weakref__'
 
-class OrderedDict(dict, MutableMapping):
+class OrderedDict(dict):
     'Dictionary that remembers insertion order'
     # An inherited dict maps keys to values.
     # The inherited dict provides __getitem__, __len__, __contains__, and get.
@@ -52,7 +52,7 @@
             self.__root = root = _proxy(self.__hardroot)
             root.prev = root.next = root
             self.__map = {}
-        self.update(*args, **kwds)
+        self.__update(*args, **kwds)
 
     def __setitem__(self, key, value,
                     dict_setitem=dict.__setitem__, proxy=_proxy, Link=_Link):
@@ -171,14 +171,30 @@
         size += sizeof(self.__root) * n         # proxy objects
         return size
 
-    setdefault = MutableMapping.setdefault
-    update = MutableMapping.update
-    pop = MutableMapping.pop
+    update = __update = MutableMapping.update
     keys = MutableMapping.keys
     values = MutableMapping.values
     items = MutableMapping.items
     __ne__ = MutableMapping.__ne__
 
+    __marker = object()
+
+    def pop(self, key, default=__marker):
+        if key in self:
+            result = self[key]
+            del self[key]
+            return result
+        if default is self.__marker:
+            raise KeyError(key)
+        return default
+
+    def setdefault(self, key, default=None):
+        'OD.setdefault(k[,d]) -> OD.get(k,d), also set OD[k]=d if k not in OD'
+        if key in self:
+            return self[key]
+        self[key] = default
+        return default
+
     @_recursive_repr()
     def __repr__(self):
         'od.__repr__() <==> repr(od)'
@@ -334,21 +350,32 @@
 ###  Counter
 ########################################################################
 
+def _count_elements(mapping, iterable):
+    'Tally elements from the iterable.'
+    mapping_get = mapping.get
+    for elem in iterable:
+        mapping[elem] = mapping_get(elem, 0) + 1
+
+try:                                    # Load C helper function if available
+    from _collections import _count_elements
+except ImportError:
+    pass
+
 class Counter(dict):
     '''Dict subclass for counting hashable items.  Sometimes called a bag
     or multiset.  Elements are stored as dictionary keys and their counts
     are stored as dictionary values.
 
-    >>> c = Counter('abracadabra')      # count elements from a string
+    >>> c = Counter('abcdeabcdabcaba')  # count elements from a string
 
     >>> c.most_common(3)                # three most common elements
-    [('a', 5), ('r', 2), ('b', 2)]
+    [('a', 5), ('b', 4), ('c', 3)]
     >>> sorted(c)                       # list all unique elements
-    ['a', 'b', 'c', 'd', 'r']
+    ['a', 'b', 'c', 'd', 'e']
     >>> ''.join(sorted(c.elements()))   # list elements with repetitions
-    'aaaaabbcdrr'
+    'aaaaabbbbcccdde'
     >>> sum(c.values())                 # total of all counts
-    11
+    15
 
     >>> c['a']                          # count of letter 'a'
     5
@@ -356,8 +383,8 @@
     ...     c[elem] += 1                # by adding 1 to each element's count
     >>> c['a']                          # now there are seven 'a'
     7
-    >>> del c['r']                      # remove all 'r'
-    >>> c['r']                          # now there are zero 'r'
+    >>> del c['b']                      # remove all 'b'
+    >>> c['b']                          # now there are zero 'b'
     0
 
     >>> d = Counter('simsalabim')       # make another counter
@@ -396,6 +423,7 @@
         >>> c = Counter(a=4, b=2)                   # a new counter from keyword args
 
         '''
+        super().__init__()
         self.update(iterable, **kwds)
 
     def __missing__(self, key):
@@ -407,8 +435,8 @@
         '''List the n most common elements and their counts from the most
         common to the least.  If n is None, then list all element counts.
 
-        >>> Counter('abracadabra').most_common(3)
-        [('a', 5), ('r', 2), ('b', 2)]
+        >>> Counter('abcdeabcdabcaba').most_common(3)
+        [('a', 5), ('b', 4), ('c', 3)]
 
         '''
         # Emulate Bag.sortedByCount from Smalltalk
@@ -474,11 +502,9 @@
                     for elem, count in iterable.items():
                         self[elem] = count + self_get(elem, 0)
                 else:
-                    dict.update(self, iterable) # fast path when counter is empty
+                    super().update(iterable) # fast path when counter is empty
             else:
-                self_get = self.get
-                for elem in iterable:
-                    self[elem] = 1 + self_get(elem, 0)
+                _count_elements(self, iterable)
         if kwds:
             self.update(kwds)
 
@@ -516,7 +542,7 @@
     def __delitem__(self, elem):
         'Like dict.__delitem__() but does not raise KeyError for missing values.'
         if elem in self:
-            dict.__delitem__(self, elem)
+            super().__delitem__(elem)
 
     def __repr__(self):
         if not self:

Modified: python/branches/py3k-cdecimal/Lib/compileall.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/compileall.py	(original)
+++ python/branches/py3k-cdecimal/Lib/compileall.py	Sun Jan  2 13:18:37 2011
@@ -19,19 +19,20 @@
 
 __all__ = ["compile_dir","compile_file","compile_path"]
 
-def compile_dir(dir, maxlevels=10, ddir=None,
-                force=False, rx=None, quiet=False, legacy=False):
+def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
+                quiet=False, legacy=False, optimize=-1):
     """Byte-compile all modules in the given directory tree.
 
     Arguments (only dir is required):
 
     dir:       the directory to byte-compile
     maxlevels: maximum recursion level (default 10)
-    ddir:      if given, purported directory name (this is the
-               directory name that will show up in error messages)
+    ddir:      the directory that will be prepended to the path to the
+               file as it is compiled into each byte-code file.
     force:     if True, force compilation, even if timestamps are up-to-date
     quiet:     if True, be quiet during compilation
     legacy:    if True, produce legacy pyc paths instead of PEP 3147 paths
+    optimize:  optimization level or -1 for level of the interpreter
     """
     if not quiet:
         print('Listing', dir, '...')
@@ -51,7 +52,8 @@
         else:
             dfile = None
         if not os.path.isdir(fullname):
-            if not compile_file(fullname, ddir, force, rx, quiet, legacy):
+            if not compile_file(fullname, ddir, force, rx, quiet,
+                                legacy, optimize):
                 success = 0
         elif (maxlevels > 0 and name != os.curdir and name != os.pardir and
               os.path.isdir(fullname) and not os.path.islink(fullname)):
@@ -60,15 +62,19 @@
                 success = 0
     return success
 
-def compile_file(fullname, ddir=None, force=0, rx=None, quiet=False,
-                 legacy=False):
-    """Byte-compile file.
+def compile_file(fullname, ddir=None, force=False, rx=None, quiet=False,
+                 legacy=False, optimize=-1):
+    """Byte-compile one file.
+
+    Arguments (only fullname is required):
+
     fullname:  the file to byte-compile
-    ddir:      if given, purported directory name (this is the
-               directory name that will show up in error messages)
+    ddir:      if given, the directory name compiled in to the
+               byte-code file.
     force:     if True, force compilation, even if timestamps are up-to-date
     quiet:     if True, be quiet during compilation
     legacy:    if True, produce legacy pyc paths instead of PEP 3147 paths
+    optimize:  optimization level or -1 for level of the interpreter
     """
     success = 1
     name = os.path.basename(fullname)
@@ -84,7 +90,11 @@
         if legacy:
             cfile = fullname + ('c' if __debug__ else 'o')
         else:
-            cfile = imp.cache_from_source(fullname)
+            if optimize >= 0:
+                cfile = imp.cache_from_source(fullname,
+                                              debug_override=not optimize)
+            else:
+                cfile = imp.cache_from_source(fullname)
             cache_dir = os.path.dirname(cfile)
         head, tail = name[:-3], name[-3:]
         if tail == '.py':
@@ -101,7 +111,8 @@
             if not quiet:
                 print('Compiling', fullname, '...')
             try:
-                ok = py_compile.compile(fullname, cfile, dfile, True)
+                ok = py_compile.compile(fullname, cfile, dfile, True,
+                                        optimize=optimize)
             except py_compile.PyCompileError as err:
                 if quiet:
                     print('*** Error compiling', fullname, '...')
@@ -126,7 +137,7 @@
     return success
 
 def compile_path(skip_curdir=1, maxlevels=0, force=False, quiet=False,
-                 legacy=False):
+                 legacy=False, optimize=-1):
     """Byte-compile all module on sys.path.
 
     Arguments (all optional):
@@ -136,6 +147,7 @@
     force: as for compile_dir() (default False)
     quiet: as for compile_dir() (default False)
     legacy: as for compile_dir() (default False)
+    optimize: as for compile_dir() (default -1)
     """
     success = 1
     for dir in sys.path:
@@ -144,7 +156,7 @@
         else:
             success = success and compile_dir(dir, maxlevels, None,
                                               force, quiet=quiet,
-                                              legacy=legacy)
+                                              legacy=legacy, optimize=optimize)
     return success
 
 
@@ -154,60 +166,73 @@
 
     parser = argparse.ArgumentParser(
         description='Utilities to support installing Python libraries.')
-    parser.add_argument('-l', action='store_const', default=10, const=0,
-                        dest='maxlevels', help="don't recurse down")
+    parser.add_argument('-l', action='store_const', const=0,
+                        default=10, dest='maxlevels',
+                        help="don't recurse into subdirectories")
     parser.add_argument('-f', action='store_true', dest='force',
                         help='force rebuild even if timestamps are up to date')
     parser.add_argument('-q', action='store_true', dest='quiet',
-                        help='reduce output')
+                        help='output only error messages')
     parser.add_argument('-b', action='store_true', dest='legacy',
-                        help='produce legacy byte-compiled file paths')
+                        help='use legacy (pre-PEP3147) compiled file locations')
     parser.add_argument('-d', metavar='DESTDIR',  dest='ddir', default=None,
-                        help=('purported directory name for error messages; '
-                              'if no directory arguments, -l sys.path '
-                              'is assumed.'))
+                        help=('directory to prepend to file paths for use in '
+                              'compile time tracebacks and in runtime '
+                              'tracebacks in cases where the source file is '
+                              'unavailable'))
     parser.add_argument('-x', metavar='REGEXP', dest='rx', default=None,
-                        help=('skip files matching the regular expression.\n\t'
+                        help=('skip files matching the regular expression. '
                               'The regexp is searched for in the full path '
-                              'of the file'))
+                              'to each file considered for compilation.'))
     parser.add_argument('-i', metavar='FILE', dest='flist',
-                        help='expand the list with the content of FILE.')
-    parser.add_argument('compile_dest', metavar='FILE|DIR', nargs='?')
+                        help=('add all the files and directories listed in '
+                              'FILE to the list considered for compilation. '
+                              'If "-", names are read from stdin.'))
+    parser.add_argument('compile_dest', metavar='FILE|DIR', nargs='*',
+                        help=('zero or more file and directory names '
+                              'to compile; if no arguments given, defaults '
+                              'to the equivalent of -l sys.path'))
     args = parser.parse_args()
 
-    if (args.ddir and args.compile_dest != 1 and
-        not os.path.isdir(args.compile_dest)):
-        raise argparse.ArgumentError(
-            "-d destdir requires exactly one directory argument")
+    compile_dests = args.compile_dest
+
+    if (args.ddir and (len(compile_dests) != 1
+            or not os.path.isdir(compile_dests[0]))):
+        parser.exit('-d destdir requires exactly one directory argument')
     if args.rx:
         import re
         args.rx = re.compile(args.rx)
 
     # if flist is provided then load it
-    compile_dests = [args.compile_dest]
     if args.flist:
-        with open(args.flist) as f:
-            files = f.read().split()
-            compile_dests.extend(files)
+        try:
+            with (sys.stdin if args.flist=='-' else open(args.flist)) as f:
+                for line in f:
+                    compile_dests.append(line.strip())
+        except EnvironmentError:
+            print("Error reading file list {}".format(args.flist))
+            return False
 
+    success = True
     try:
         if compile_dests:
             for dest in compile_dests:
-                if os.path.isdir(dest):
+                if os.path.isfile(dest):
+                    if not compile_file(dest, args.ddir, args.force, args.rx,
+                                        args.quiet, args.legacy):
+                        success = False
+                else:
                     if not compile_dir(dest, args.maxlevels, args.ddir,
                                        args.force, args.rx, args.quiet,
                                        args.legacy):
-                        return 0
-                else:
-                    if not compile_file(dest, args.ddir, args.force, args.rx,
-                                        args.quiet, args.legacy):
-                        return 0
+                        success = False
+            return success
         else:
             return compile_path(legacy=args.legacy)
     except KeyboardInterrupt:
         print("\n[interrupted]")
-        return 0
-    return 1
+        return False
+    return True
 
 
 if __name__ == '__main__':

Modified: python/branches/py3k-cdecimal/Lib/concurrent/futures/_base.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/concurrent/futures/_base.py	(original)
+++ python/branches/py3k-cdecimal/Lib/concurrent/futures/_base.py	Sun Jan  2 13:18:37 2011
@@ -41,8 +41,6 @@
 
 # Logger for internal use by the futures package.
 LOGGER = logging.getLogger("concurrent.futures")
-STDERR_HANDLER = logging.StreamHandler()
-LOGGER.addHandler(STDERR_HANDLER)
 
 class Error(Exception):
     """Base class for all future-related exceptions."""

Modified: python/branches/py3k-cdecimal/Lib/concurrent/futures/process.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/concurrent/futures/process.py	(original)
+++ python/branches/py3k-cdecimal/Lib/concurrent/futures/process.py	Sun Jan  2 13:18:37 2011
@@ -118,7 +118,7 @@
 def _process_worker(call_queue, result_queue, shutdown):
     """Evaluates calls from call_queue and places the results in result_queue.
 
-    This worker is run in a seperate process.
+    This worker is run in a separate process.
 
     Args:
         call_queue: A multiprocessing.Queue of _CallItems that will be read and

Modified: python/branches/py3k-cdecimal/Lib/configparser.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/configparser.py	(original)
+++ python/branches/py3k-cdecimal/Lib/configparser.py	Sun Jan  2 13:18:37 2011
@@ -4,29 +4,20 @@
 and followed by "name: value" entries, with continuations and such in
 the style of RFC 822.
 
-The option values can contain format strings which refer to other values in
-the same section, or values in a special [DEFAULT] section.
-
-For example:
-
-    something: %(dir)s/whatever
-
-would resolve the "%(dir)s" to the value of dir.  All reference
-expansions are done late, on demand.
-
 Intrinsic defaults can be specified by passing them into the
 ConfigParser constructor as a dictionary.
 
 class:
 
 ConfigParser -- responsible for parsing a list of
-                configuration files, and managing the parsed database.
+                    configuration files, and managing the parsed database.
 
     methods:
 
     __init__(defaults=None, dict_type=_default_dict, allow_no_value=False,
-             delimiters=('=', ':'), comment_prefixes=_COMPATIBLE,
-             strict=False, empty_lines_in_values=True):
+             delimiters=('=', ':'), comment_prefixes=('#', ';'),
+             inline_comment_prefixes=None, strict=True,
+             empty_lines_in_values=True):
         Create the parser. When `defaults' is given, it is initialized into the
         dictionary or intrinsic defaults. The keys must be strings, the values
         must be appropriate for %()s string interpolation.
@@ -39,11 +30,15 @@
         that divide keys from values.
 
         When `comment_prefixes' is given, it will be used as the set of
-        substrings that prefix comments in a line.
+        substrings that prefix comments in empty lines. Comments can be
+        indented.
+
+        When `inline_comment_prefixes' is given, it will be used as the set of
+        substrings that prefix comments in non-empty lines.
 
         When `strict` is True, the parser won't allow for any section or option
         duplicates while reading from a single source (file, string or
-        dictionary). Default is False.
+        dictionary). Default is True.
 
         When `empty_lines_in_values' is False (default: True), each empty line
         marks the end of an option. Otherwise, internal empty lines of
@@ -103,8 +98,10 @@
         insensitively defined as 0, false, no, off for False, and 1, true,
         yes, on for True).  Returns False or True.
 
-    items(section, raw=False, vars=None)
-        Return a list of tuples with (name, value) for each option
+    items(section=_UNSET, raw=False, vars=None)
+        If section is given, return a list of tuples with (section_name,
+        section_proxy) for each section, including DEFAULTSECT. Otherwise,
+        return a list of tuples with (name, value) for each option
         in the section.
 
     remove_section(section)
@@ -275,9 +272,8 @@
 class InterpolationSyntaxError(InterpolationError):
     """Raised when the source text contains invalid syntax.
 
-    Current implementation raises this exception only for SafeConfigParser
-    instances when the source text into which substitutions are made
-    does not conform to the required syntax.
+    Current implementation raises this exception when the source text into
+    which substitutions are made does not conform to the required syntax.
     """
 
 
@@ -316,7 +312,7 @@
     def filename(self):
         """Deprecated, use `source'."""
         warnings.warn(
-            "This 'filename' attribute will be removed in future versions.  "
+            "The 'filename' attribute will be removed in future versions.  "
             "Use 'source' instead.",
             DeprecationWarning, stacklevel=2
         )
@@ -351,17 +347,210 @@
         self.args = (filename, lineno, line)
 
 
-# Used in parsers to denote selecting a backwards-compatible inline comment
-# character behavior (; and # are comments at the start of a line, but ; only
-# inline)
-_COMPATIBLE = object()
-
 # Used in parser getters to indicate the default behaviour when a specific
 # option is not found it to raise an exception. Created to enable `None' as
 # a valid fallback value.
 _UNSET = object()
 
 
+class Interpolation:
+    """Dummy interpolation that passes the value through with no changes."""
+
+    def before_get(self, parser, section, option, value, defaults):
+        return value
+
+    def before_set(self, parser, section, option, value):
+        return value
+
+    def before_read(self, parser, section, option, value):
+        return value
+
+    def before_write(self, parser, section, option, value):
+        return value
+
+
+class BasicInterpolation(Interpolation):
+    """Interpolation as implemented in the classic ConfigParser.
+
+    The option values can contain format strings which refer to other values in
+    the same section, or values in the special default section.
+
+    For example:
+
+        something: %(dir)s/whatever
+
+    would resolve the "%(dir)s" to the value of dir.  All reference
+    expansions are done late, on demand. If a user needs to use a bare % in
+    a configuration file, she can escape it by writing %%. Other other % usage
+    is considered a user error and raises `InterpolationSyntaxError'."""
+
+    _KEYCRE = re.compile(r"%\(([^)]+)\)s")
+
+    def before_get(self, parser, section, option, value, defaults):
+        L = []
+        self._interpolate_some(parser, option, L, value, section, defaults, 1)
+        return ''.join(L)
+
+    def before_set(self, parser, section, option, value):
+        tmp_value = value.replace('%%', '') # escaped percent signs
+        tmp_value = self._KEYCRE.sub('', tmp_value) # valid syntax
+        if '%' in tmp_value:
+            raise ValueError("invalid interpolation syntax in %r at "
+                             "position %d" % (value, tmp_value.find('%')))
+        return value
+
+    def _interpolate_some(self, parser, option, accum, rest, section, map,
+                          depth):
+        if depth > MAX_INTERPOLATION_DEPTH:
+            raise InterpolationDepthError(option, section, rest)
+        while rest:
+            p = rest.find("%")
+            if p < 0:
+                accum.append(rest)
+                return
+            if p > 0:
+                accum.append(rest[:p])
+                rest = rest[p:]
+            # p is no longer used
+            c = rest[1:2]
+            if c == "%":
+                accum.append("%")
+                rest = rest[2:]
+            elif c == "(":
+                m = self._KEYCRE.match(rest)
+                if m is None:
+                    raise InterpolationSyntaxError(option, section,
+                        "bad interpolation variable reference %r" % rest)
+                var = parser.optionxform(m.group(1))
+                rest = rest[m.end():]
+                try:
+                    v = map[var]
+                except KeyError:
+                    raise InterpolationMissingOptionError(
+                        option, section, rest, var)
+                if "%" in v:
+                    self._interpolate_some(parser, option, accum, v,
+                                           section, map, depth + 1)
+                else:
+                    accum.append(v)
+            else:
+                raise InterpolationSyntaxError(
+                    option, section,
+                    "'%%' must be followed by '%%' or '(', "
+                    "found: %r" % (rest,))
+
+
+class ExtendedInterpolation(Interpolation):
+    """Advanced variant of interpolation, supports the syntax used by
+    `zc.buildout'. Enables interpolation between sections."""
+
+    _KEYCRE = re.compile(r"\$\{([^}]+)\}")
+
+    def before_get(self, parser, section, option, value, defaults):
+        L = []
+        self._interpolate_some(parser, option, L, value, section, defaults, 1)
+        return ''.join(L)
+
+    def before_set(self, parser, section, option, value):
+        tmp_value = value.replace('$$', '') # escaped dollar signs
+        tmp_value = self._KEYCRE.sub('', tmp_value) # valid syntax
+        if '$' in tmp_value:
+            raise ValueError("invalid interpolation syntax in %r at "
+                             "position %d" % (value, tmp_value.find('%')))
+        return value
+
+    def _interpolate_some(self, parser, option, accum, rest, section, map,
+                          depth):
+        if depth > MAX_INTERPOLATION_DEPTH:
+            raise InterpolationDepthError(option, section, rest)
+        while rest:
+            p = rest.find("$")
+            if p < 0:
+                accum.append(rest)
+                return
+            if p > 0:
+                accum.append(rest[:p])
+                rest = rest[p:]
+            # p is no longer used
+            c = rest[1:2]
+            if c == "$":
+                accum.append("$")
+                rest = rest[2:]
+            elif c == "{":
+                m = self._KEYCRE.match(rest)
+                if m is None:
+                    raise InterpolationSyntaxError(option, section,
+                        "bad interpolation variable reference %r" % rest)
+                path = parser.optionxform(m.group(1)).split(':')
+                rest = rest[m.end():]
+                sect = section
+                opt = option
+                try:
+                    if len(path) == 1:
+                        opt = path[0]
+                        v = map[opt]
+                    elif len(path) == 2:
+                        sect = path[0]
+                        opt = path[1]
+                        v = parser.get(sect, opt, raw=True)
+                    else:
+                        raise InterpolationSyntaxError(
+                            option, section,
+                            "More than one ':' found: %r" % (rest,))
+                except (KeyError, NoSectionError, NoOptionError):
+                    raise InterpolationMissingOptionError(
+                        option, section, rest, ":".join(path))
+                if "$" in v:
+                    self._interpolate_some(parser, opt, accum, v, sect,
+                                           dict(parser.items(sect, raw=True)),
+                                           depth + 1)
+                else:
+                    accum.append(v)
+            else:
+                raise InterpolationSyntaxError(
+                    option, section,
+                    "'$' must be followed by '$' or '{', "
+                    "found: %r" % (rest,))
+
+
+class LegacyInterpolation(Interpolation):
+    """Deprecated interpolation used in old versions of ConfigParser.
+    Use BasicInterpolation or ExtendedInterpolation instead."""
+
+    _KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
+
+    def before_get(self, parser, section, option, value, vars):
+        rawval = value
+        depth = MAX_INTERPOLATION_DEPTH
+        while depth:                    # Loop through this until it's done
+            depth -= 1
+            if value and "%(" in value:
+                replace = functools.partial(self._interpolation_replace,
+                                            parser=parser)
+                value = self._KEYCRE.sub(replace, value)
+                try:
+                    value = value % vars
+                except KeyError as e:
+                    raise InterpolationMissingOptionError(
+                        option, section, rawval, e.args[0])
+            else:
+                break
+        if value and "%(" in value:
+            raise InterpolationDepthError(option, section, rawval)
+        return value
+
+    def before_set(self, parser, section, option, value):
+        return value
+
+    @staticmethod
+    def _interpolation_replace(match, parser):
+        s = match.group(1)
+        if s is None:
+            return match.group()
+        else:
+            return "%%(%s)s" % parser.optionxform(s)
+
+
 class RawConfigParser(MutableMapping):
     """ConfigParser that does not do interpolation."""
 
@@ -388,7 +577,8 @@
                                            # space/tab
         (?P<value>.*))?$                   # everything up to eol
         """
-
+    # Interpolation algorithm to be used if the user does not specify another
+    _DEFAULT_INTERPOLATION = Interpolation()
     # Compiled regular expression for matching sections
     SECTCRE = re.compile(_SECT_TMPL, re.VERBOSE)
     # Compiled regular expression for matching options with typical separators
@@ -404,9 +594,11 @@
 
     def __init__(self, defaults=None, dict_type=_default_dict,
                  allow_no_value=False, *, delimiters=('=', ':'),
-                 comment_prefixes=_COMPATIBLE, strict=False,
-                 empty_lines_in_values=True,
-                 default_section=DEFAULTSECT):
+                 comment_prefixes=('#', ';'), inline_comment_prefixes=None,
+                 strict=True, empty_lines_in_values=True,
+                 default_section=DEFAULTSECT,
+                 interpolation=_UNSET):
+
         self._dict = dict_type
         self._sections = self._dict()
         self._defaults = self._dict()
@@ -426,16 +618,16 @@
             else:
                 self._optcre = re.compile(self._OPT_TMPL.format(delim=d),
                                           re.VERBOSE)
-        if comment_prefixes is _COMPATIBLE:
-            self._startonly_comment_prefixes = ('#',)
-            self._comment_prefixes = (';',)
-        else:
-            self._startonly_comment_prefixes = ()
-            self._comment_prefixes = tuple(comment_prefixes or ())
+        self._comment_prefixes = tuple(comment_prefixes or ())
+        self._inline_comment_prefixes = tuple(inline_comment_prefixes or ())
         self._strict = strict
         self._allow_no_value = allow_no_value
         self._empty_lines_in_values = empty_lines_in_values
-        self._default_section=default_section
+        if interpolation is _UNSET:
+            self._interpolation = self._DEFAULT_INTERPOLATION
+        else:
+            self._interpolation = interpolation
+        self.default_section=default_section
 
     def defaults(self):
         return self._defaults
@@ -451,8 +643,8 @@
         Raise DuplicateSectionError if a section by the specified name
         already exists. Raise ValueError if name is DEFAULT.
         """
-        if section == self._default_section:
-            raise ValueError('Invalid section name: %s' % section)
+        if section == self.default_section:
+            raise ValueError('Invalid section name: %r' % section)
 
         if section in self._sections:
             raise DuplicateSectionError(section)
@@ -526,19 +718,23 @@
         that should be present in the section. If the used dictionary type
         preserves order, sections and their keys will be added in order.
 
+        All types held in the dictionary are converted to strings during
+        reading, including section names, option names and keys.
+
         Optional second argument is the `source' specifying the name of the
         dictionary being read.
         """
         elements_added = set()
         for section, keys in dictionary.items():
+            section = str(section)
             try:
                 self.add_section(section)
             except (DuplicateSectionError, ValueError):
                 if self._strict and section in elements_added:
                     raise
-                elements_added.add(section)
+            elements_added.add(section)
             for key, value in keys.items():
-                key = self.optionxform(key)
+                key = self.optionxform(str(key))
                 if value is not None:
                     value = str(value)
                 if self._strict and (section, key) in elements_added:
@@ -555,7 +751,7 @@
         )
         self.read_file(fp, source=filename)
 
-    def get(self, section, option, *, vars=None, fallback=_UNSET):
+    def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
         """Get an option value for a given section.
 
         If `vars' is provided, it must be a dictionary. The option is looked up
@@ -563,7 +759,12 @@
         If the key is not found and `fallback' is provided, it is used as
         a fallback value. `None' can be provided as a `fallback' value.
 
-        Arguments `vars' and `fallback' are keyword only.
+        If interpolation is enabled and the optional argument `raw' is False,
+        all interpolations are expanded in the return values.
+
+        Arguments `raw', `vars', and `fallback' are keyword only.
+
+        The section DEFAULT is special.
         """
         try:
             d = self._unify_values(section, vars)
@@ -574,61 +775,90 @@
                 return fallback
         option = self.optionxform(option)
         try:
-            return d[option]
+            value = d[option]
         except KeyError:
             if fallback is _UNSET:
                 raise NoOptionError(option, section)
             else:
                 return fallback
 
-    def items(self, section):
-        try:
-            d2 = self._sections[section]
-        except KeyError:
-            if section != self._default_section:
-                raise NoSectionError(section)
-            d2 = self._dict()
-        d = self._defaults.copy()
-        d.update(d2)
-        return d.items()
+        if raw or value is None:
+            return value
+        else:
+            return self._interpolation.before_get(self, section, option, value,
+                                                  d)
 
     def _get(self, section, conv, option, **kwargs):
         return conv(self.get(section, option, **kwargs))
 
-    def getint(self, section, option, *, vars=None, fallback=_UNSET):
+    def getint(self, section, option, *, raw=False, vars=None,
+               fallback=_UNSET):
         try:
-            return self._get(section, int, option, vars=vars)
+            return self._get(section, int, option, raw=raw, vars=vars)
         except (NoSectionError, NoOptionError):
             if fallback is _UNSET:
                 raise
             else:
                 return fallback
 
-    def getfloat(self, section, option, *, vars=None, fallback=_UNSET):
+    def getfloat(self, section, option, *, raw=False, vars=None,
+                 fallback=_UNSET):
         try:
-            return self._get(section, float, option, vars=vars)
+            return self._get(section, float, option, raw=raw, vars=vars)
         except (NoSectionError, NoOptionError):
             if fallback is _UNSET:
                 raise
             else:
                 return fallback
 
-    def getboolean(self, section, option, *, vars=None, fallback=_UNSET):
+    def getboolean(self, section, option, *, raw=False, vars=None,
+                   fallback=_UNSET):
         try:
             return self._get(section, self._convert_to_boolean, option,
-                             vars=vars)
+                             raw=raw, vars=vars)
         except (NoSectionError, NoOptionError):
             if fallback is _UNSET:
                 raise
             else:
                 return fallback
 
+    def items(self, section=_UNSET, raw=False, vars=None):
+        """Return a list of (name, value) tuples for each option in a section.
+
+        All % interpolations are expanded in the return values, based on the
+        defaults passed into the constructor, unless the optional argument
+        `raw' is true.  Additional substitutions may be provided using the
+        `vars' argument, which must be a dictionary whose contents overrides
+        any pre-existing defaults.
+
+        The section DEFAULT is special.
+        """
+        if section is _UNSET:
+            return super().items()
+        d = self._defaults.copy()
+        try:
+            d.update(self._sections[section])
+        except KeyError:
+            if section != self.default_section:
+                raise NoSectionError(section)
+        # Update with the entry specific variables
+        if vars:
+            for key, value in vars.items():
+                d[self.optionxform(key)] = value
+        value_getter = lambda option: self._interpolation.before_get(self,
+            section, option, d[option], d)
+        if raw:
+            value_getter = lambda option: d[option]
+        return [(option, value_getter(option)) for option in d.keys()]
+
     def optionxform(self, optionstr):
         return optionstr.lower()
 
     def has_option(self, section, option):
-        """Check for the existence of a given option in a given section."""
-        if not section or section == self._default_section:
+        """Check for the existence of a given option in a given section.
+        If the specified `section' is None or an empty string, DEFAULT is
+        assumed. If the specified `section' does not exist, returns False."""
+        if not section or section == self.default_section:
             option = self.optionxform(option)
             return option in self._defaults
         elif section not in self._sections:
@@ -640,7 +870,10 @@
 
     def set(self, section, option, value=None):
         """Set an option."""
-        if not section or section == self._default_section:
+        if value:
+            value = self._interpolation.before_set(self, section, option,
+                                                   value)
+        if not section or section == self.default_section:
             sectdict = self._defaults
         else:
             try:
@@ -660,7 +893,7 @@
         else:
             d = self._delimiters[0]
         if self._defaults:
-            self._write_section(fp, self._default_section,
+            self._write_section(fp, self.default_section,
                                     self._defaults.items(), d)
         for section in self._sections:
             self._write_section(fp, section,
@@ -670,6 +903,8 @@
         """Write a single section to the specified `fp'."""
         fp.write("[{}]\n".format(section_name))
         for key, value in section_items:
+            value = self._interpolation.before_write(self, section_name, key,
+                                                     value)
             if value is not None or not self._allow_no_value:
                 value = delimiter + str(value).replace('\n', '\n\t')
             else:
@@ -679,7 +914,7 @@
 
     def remove_option(self, section, option):
         """Remove an option."""
-        if not section or section == self._default_section:
+        if not section or section == self.default_section:
             sectdict = self._defaults
         else:
             try:
@@ -701,7 +936,7 @@
         return existed
 
     def __getitem__(self, key):
-        if key != self._default_section and not self.has_section(key):
+        if key != self.default_section and not self.has_section(key):
             raise KeyError(key)
         return self._proxies[key]
 
@@ -715,21 +950,21 @@
         self.read_dict({key: value})
 
     def __delitem__(self, key):
-        if key == self._default_section:
+        if key == self.default_section:
             raise ValueError("Cannot remove the default section.")
         if not self.has_section(key):
             raise KeyError(key)
         self.remove_section(key)
 
     def __contains__(self, key):
-        return key == self._default_section or self.has_section(key)
+        return key == self.default_section or self.has_section(key)
 
     def __len__(self):
         return len(self._sections) + 1 # the default section
 
     def __iter__(self):
         # XXX does it break when underlying container state changed?
-        return itertools.chain((self._default_section,), self._sections.keys())
+        return itertools.chain((self.default_section,), self._sections.keys())
 
     def _read(self, fp, fpname):
         """Parse a sectioned configuration file.
@@ -756,18 +991,18 @@
         indent_level = 0
         e = None                              # None, or an exception
         for lineno, line in enumerate(fp, start=1):
-            # strip full line comments
             comment_start = None
-            for prefix in self._startonly_comment_prefixes:
-                if line.strip().startswith(prefix):
-                    comment_start = 0
-                    break
             # strip inline comments
-            for prefix in self._comment_prefixes:
+            for prefix in self._inline_comment_prefixes:
                 index = line.find(prefix)
                 if index == 0 or (index > 0 and line[index-1].isspace()):
                     comment_start = index
                     break
+            # strip full line comments
+            for prefix in self._comment_prefixes:
+                if line.strip().startswith(prefix):
+                    comment_start = 0
+                    break
             value = line[:comment_start].strip()
             if not value:
                 if self._empty_lines_in_values:
@@ -801,7 +1036,7 @@
                                                         lineno)
                         cursect = self._sections[sectname]
                         elements_added.add(sectname)
-                    elif sectname == self._default_section:
+                    elif sectname == self.default_section:
                         cursect = self._defaults
                     else:
                         cursect = self._dict()
@@ -830,13 +1065,10 @@
                         # match if it would set optval to None
                         if optval is not None:
                             optval = optval.strip()
-                            # allow empty values
-                            if optval == '""':
-                                optval = ''
                             cursect[optname] = [optval]
                         else:
                             # valueless option handling
-                            cursect[optname] = optval
+                            cursect[optname] = None
                     else:
                         # a non-fatal parsing error occurred. set up the
                         # exception but keep going. the exception will be
@@ -849,12 +1081,16 @@
         self._join_multiline_values()
 
     def _join_multiline_values(self):
-        all_sections = itertools.chain((self._defaults,),
-                                       self._sections.values())
-        for options in all_sections:
+        defaults = self.default_section, self._defaults
+        all_sections = itertools.chain((defaults,),
+                                       self._sections.items())
+        for section, options in all_sections:
             for name, val in options.items():
                 if isinstance(val, list):
-                    options[name] = '\n'.join(val).rstrip()
+                    val = '\n'.join(val).rstrip()
+                options[name] = self._interpolation.before_read(self,
+                                                                section,
+                                                                name, val)
 
     def _handle_error(self, exc, fpname, lineno, line):
         if not exc:
@@ -871,7 +1107,7 @@
         try:
             d.update(self._sections[section])
         except KeyError:
-            if section != self._default_section:
+            if section != self.default_section:
                 raise NoSectionError(section)
         # Update with the entry specific variables
         if vars:
@@ -888,7 +1124,7 @@
             raise ValueError('Not a boolean: %s' % value)
         return self.BOOLEAN_STATES[value.lower()]
 
-    def _validate_value_type(self, value):
+    def _validate_value_types(self, *, section="", option="", value=""):
         """Raises a TypeError for non-string values.
 
         The only legal non-string value if we allow valueless
@@ -898,205 +1134,48 @@
         - we allow valueless options but the value is not None
 
         For compatibility reasons this method is not used in classic set()
-        for RawConfigParsers and ConfigParsers. It is invoked in every
-        case for mapping protocol access and in SafeConfigParser.set().
+        for RawConfigParsers. It is invoked in every case for mapping protocol
+        access and in ConfigParser.set().
         """
+        if not isinstance(section, str):
+            raise TypeError("section names must be strings")
+        if not isinstance(option, str):
+            raise TypeError("option keys must be strings")
         if not self._allow_no_value or value:
             if not isinstance(value, str):
                 raise TypeError("option values must be strings")
 
 
-
 class ConfigParser(RawConfigParser):
     """ConfigParser implementing interpolation."""
 
-    def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
-        """Get an option value for a given section.
-
-        If `vars' is provided, it must be a dictionary. The option is looked up
-        in `vars' (if provided), `section', and in `DEFAULTSECT' in that order.
-        If the key is not found and `fallback' is provided, it is used as
-        a fallback value. `None' can be provided as a `fallback' value.
-
-        All % interpolations are expanded in the return values, unless the
-        optional argument `raw' is true.  Values for interpolation keys are
-        looked up in the same manner as the option.
-
-        Arguments `raw', `vars', and `fallback' are keyword only.
-
-        The section DEFAULT is special.
-        """
-        try:
-            d = self._unify_values(section, vars)
-        except NoSectionError:
-            if fallback is _UNSET:
-                raise
-            else:
-                return fallback
-        option = self.optionxform(option)
-        try:
-            value = d[option]
-        except KeyError:
-            if fallback is _UNSET:
-                raise NoOptionError(option, section)
-            else:
-                return fallback
-
-        if raw or value is None:
-            return value
-        else:
-            return self._interpolate(section, option, value, d)
-
-    def getint(self, section, option, *, raw=False, vars=None,
-               fallback=_UNSET):
-        try:
-            return self._get(section, int, option, raw=raw, vars=vars)
-        except (NoSectionError, NoOptionError):
-            if fallback is _UNSET:
-                raise
-            else:
-                return fallback
-
-    def getfloat(self, section, option, *, raw=False, vars=None,
-                 fallback=_UNSET):
-        try:
-            return self._get(section, float, option, raw=raw, vars=vars)
-        except (NoSectionError, NoOptionError):
-            if fallback is _UNSET:
-                raise
-            else:
-                return fallback
-
-    def getboolean(self, section, option, *, raw=False, vars=None,
-                   fallback=_UNSET):
-        try:
-            return self._get(section, self._convert_to_boolean, option,
-                             raw=raw, vars=vars)
-        except (NoSectionError, NoOptionError):
-            if fallback is _UNSET:
-                raise
-            else:
-                return fallback
-
-    def items(self, section, raw=False, vars=None):
-        """Return a list of (name, value) tuples for each option in a section.
-
-        All % interpolations are expanded in the return values, based on the
-        defaults passed into the constructor, unless the optional argument
-        `raw' is true.  Additional substitutions may be provided using the
-        `vars' argument, which must be a dictionary whose contents overrides
-        any pre-existing defaults.
+    _DEFAULT_INTERPOLATION = BasicInterpolation()
 
-        The section DEFAULT is special.
-        """
-        d = self._defaults.copy()
-        try:
-            d.update(self._sections[section])
-        except KeyError:
-            if section != self._default_section:
-                raise NoSectionError(section)
-        # Update with the entry specific variables
-        if vars:
-            for key, value in vars.items():
-                d[self.optionxform(key)] = value
-        options = list(d.keys())
-        if raw:
-            return [(option, d[option])
-                    for option in options]
-        else:
-            return [(option, self._interpolate(section, option, d[option], d))
-                    for option in options]
-
-    def _interpolate(self, section, option, rawval, vars):
-        # do the string interpolation
-        value = rawval
-        depth = MAX_INTERPOLATION_DEPTH
-        while depth:                    # Loop through this until it's done
-            depth -= 1
-            if value and "%(" in value:
-                value = self._KEYCRE.sub(self._interpolation_replace, value)
-                try:
-                    value = value % vars
-                except KeyError as e:
-                    raise InterpolationMissingOptionError(
-                        option, section, rawval, e.args[0])
-            else:
-                break
-        if value and "%(" in value:
-            raise InterpolationDepthError(option, section, rawval)
-        return value
-
-    _KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
+    def set(self, section, option, value=None):
+        """Set an option.  Extends RawConfigParser.set by validating type and
+        interpolation syntax on the value."""
+        self._validate_value_types(option=option, value=value)
+        super().set(section, option, value)
 
-    def _interpolation_replace(self, match):
-        s = match.group(1)
-        if s is None:
-            return match.group()
-        else:
-            return "%%(%s)s" % self.optionxform(s)
+    def add_section(self, section):
+        """Create a new section in the configuration.  Extends
+        RawConfigParser.add_section by validating if the section name is
+        a string."""
+        self._validate_value_types(section=section)
+        super().add_section(section)
 
 
 class SafeConfigParser(ConfigParser):
-    """ConfigParser implementing sane interpolation."""
-
-    def _interpolate(self, section, option, rawval, vars):
-        # do the string interpolation
-        L = []
-        self._interpolate_some(option, L, rawval, section, vars, 1)
-        return ''.join(L)
-
-    _interpvar_re = re.compile(r"%\(([^)]+)\)s")
-
-    def _interpolate_some(self, option, accum, rest, section, map, depth):
-        if depth > MAX_INTERPOLATION_DEPTH:
-            raise InterpolationDepthError(option, section, rest)
-        while rest:
-            p = rest.find("%")
-            if p < 0:
-                accum.append(rest)
-                return
-            if p > 0:
-                accum.append(rest[:p])
-                rest = rest[p:]
-            # p is no longer used
-            c = rest[1:2]
-            if c == "%":
-                accum.append("%")
-                rest = rest[2:]
-            elif c == "(":
-                m = self._interpvar_re.match(rest)
-                if m is None:
-                    raise InterpolationSyntaxError(option, section,
-                        "bad interpolation variable reference %r" % rest)
-                var = self.optionxform(m.group(1))
-                rest = rest[m.end():]
-                try:
-                    v = map[var]
-                except KeyError:
-                    raise InterpolationMissingOptionError(
-                        option, section, rest, var)
-                if "%" in v:
-                    self._interpolate_some(option, accum, v,
-                                           section, map, depth + 1)
-                else:
-                    accum.append(v)
-            else:
-                raise InterpolationSyntaxError(
-                    option, section,
-                    "'%%' must be followed by '%%' or '(', "
-                    "found: %r" % (rest,))
+    """ConfigParser alias for backwards compatibility purposes."""
 
-    def set(self, section, option, value=None):
-        """Set an option.  Extend ConfigParser.set: check for string values."""
-        self._validate_value_type(value)
-        # check for bad percent signs
-        if value:
-            tmp_value = value.replace('%%', '') # escaped percent signs
-            tmp_value = self._interpvar_re.sub('', tmp_value) # valid syntax
-            if '%' in tmp_value:
-                raise ValueError("invalid interpolation syntax in %r at "
-                                "position %d" % (value, tmp_value.find('%')))
-        ConfigParser.set(self, section, option, value)
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        warnings.warn(
+            "The SafeConfigParser class has been renamed to ConfigParser "
+            "in Python 3.2. This alias will be removed in future versions."
+            " Use ConfigParser directly instead.",
+            DeprecationWarning, stacklevel=2
+        )
 
 
 class SectionProxy(MutableMapping):
@@ -1106,12 +1185,6 @@
         """Creates a view on a section of the specified `name` in `parser`."""
         self._parser = parser
         self._name = name
-        self.getint = functools.partial(self._parser.getint,
-                                        self._name)
-        self.getfloat = functools.partial(self._parser.getfloat,
-                                          self._name)
-        self.getboolean = functools.partial(self._parser.getboolean,
-                                            self._name)
 
     def __repr__(self):
         return '<Section: {}>'.format(self._name)
@@ -1122,25 +1195,44 @@
         return self._parser.get(self._name, key)
 
     def __setitem__(self, key, value):
-        self._parser._validate_value_type(value)
+        self._parser._validate_value_types(option=key, value=value)
         return self._parser.set(self._name, key, value)
 
     def __delitem__(self, key):
-        if not self._parser.has_option(self._name, key):
+        if not (self._parser.has_option(self._name, key) and
+                self._parser.remove_option(self._name, key)):
             raise KeyError(key)
-        return self._parser.remove_option(self._name, key)
 
     def __contains__(self, key):
         return self._parser.has_option(self._name, key)
 
     def __len__(self):
-        # XXX weak performance
-        return len(self._parser.options(self._name))
+        return len(self._options())
 
     def __iter__(self):
-        # XXX weak performance
-        # XXX does not break when underlying container state changed
-        return self._parser.options(self._name).__iter__()
+        return self._options().__iter__()
+
+    def _options(self):
+        if self._name != self._parser.default_section:
+            return self._parser.options(self._name)
+        else:
+            return self._parser.defaults()
+
+    def get(self, option, fallback=None, *, raw=False, vars=None):
+        return self._parser.get(self._name, option, raw=raw, vars=vars,
+                                fallback=fallback)
+
+    def getint(self, option, fallback=None, *, raw=False, vars=None):
+        return self._parser.getint(self._name, option, raw=raw, vars=vars,
+                                   fallback=fallback)
+
+    def getfloat(self, option, fallback=None, *, raw=False, vars=None):
+        return self._parser.getfloat(self._name, option, raw=raw, vars=vars,
+                                     fallback=fallback)
+
+    def getboolean(self, option, fallback=None, *, raw=False, vars=None):
+        return self._parser.getboolean(self._name, option, raw=raw, vars=vars,
+                                       fallback=fallback)
 
     @property
     def parser(self):

Modified: python/branches/py3k-cdecimal/Lib/dbm/dumb.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/dbm/dumb.py	(original)
+++ python/branches/py3k-cdecimal/Lib/dbm/dumb.py	Sun Jan  2 13:18:37 2011
@@ -203,7 +203,7 @@
         # The blocks used by the associated value are lost.
         del self._index[key]
         # XXX It's unclear why we do a _commit() here (the code always
-        # XXX has, so I'm not changing it).  _setitem__ doesn't try to
+        # XXX has, so I'm not changing it).  __setitem__ doesn't try to
         # XXX keep the directory file in synch.  Why should we?  Or
         # XXX why shouldn't __setitem__?
         self._commit()
@@ -232,7 +232,7 @@
 
     __del__ = close
 
-    def _chmod (self, file):
+    def _chmod(self, file):
         if hasattr(self._os, 'chmod'):
             self._os.chmod(file, self._mode)
 

Modified: python/branches/py3k-cdecimal/Lib/decimal.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/decimal.py	(original)
+++ python/branches/py3k-cdecimal/Lib/decimal.py	Sun Jan  2 13:18:37 2011
@@ -132,6 +132,7 @@
 ]
 
 __version__ = '1.70'    # Highest version of the spec this complies with
+                        # See http://speleotrove.com/decimal/
 
 import copy as _copy
 import math as _math
@@ -5526,23 +5527,7 @@
 
 ##### Integer arithmetic functions used by ln, log10, exp and __pow__ #####
 
-# This function from Tim Peters was taken from here:
-# http://mail.python.org/pipermail/python-list/1999-July/007758.html
-# The correction being in the function definition is for speed, and
-# the whole function is not resolved with math.log because of avoiding
-# the use of floats.
-def _nbits(n, correction = {
-        '0': 4, '1': 3, '2': 2, '3': 2,
-        '4': 1, '5': 1, '6': 1, '7': 1,
-        '8': 0, '9': 0, 'a': 0, 'b': 0,
-        'c': 0, 'd': 0, 'e': 0, 'f': 0}):
-    """Number of bits in binary representation of the positive integer n,
-    or 0 if n == 0.
-    """
-    if n < 0:
-        raise ValueError("The argument to _nbits should be nonnegative.")
-    hex_n = "%x" % n
-    return 4*len(hex_n) - correction[hex_n[0]]
+_nbits = int.bit_length
 
 def _sqrt_nearest(n, a):
     """Closest integer to the square root of the positive integer n.  a is
@@ -5991,7 +5976,7 @@
 #
 # A format specifier for Decimal looks like:
 #
-#   [[fill]align][sign][0][minimumwidth][,][.precision][type]
+#   [[fill]align][sign][#][0][minimumwidth][,][.precision][type]
 
 _parse_format_specifier_regex = re.compile(r"""\A
 (?:
@@ -5999,6 +5984,7 @@
    (?P<align>[<>=^])
 )?
 (?P<sign>[-+ ])?
+(?P<alt>\#)?
 (?P<zeropad>0)?
 (?P<minimumwidth>(?!0)\d+)?
 (?P<thousands_sep>,)?
@@ -6214,7 +6200,7 @@
 
     sign = _format_sign(is_negative, spec)
 
-    if fracpart:
+    if fracpart or spec['alt']:
         fracpart = spec['decimal_point'] + fracpart
 
     if exp != 0 or spec['type'] in 'eE':

Modified: python/branches/py3k-cdecimal/Lib/difflib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/difflib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/difflib.py	Sun Jan  2 13:18:37 2011
@@ -32,6 +32,7 @@
            'Differ','IS_CHARACTER_JUNK', 'IS_LINE_JUNK', 'context_diff',
            'unified_diff', 'HtmlDiff', 'Match']
 
+import warnings
 import heapq
 from collections import namedtuple as _namedtuple
 
@@ -150,7 +151,7 @@
         Return an upper bound on ratio() very quickly.
     """
 
-    def __init__(self, isjunk=None, a='', b=''):
+    def __init__(self, isjunk=None, a='', b='', autojunk=True):
         """Construct a SequenceMatcher.
 
         Optional arg isjunk is None (the default), or a one-argument
@@ -168,6 +169,10 @@
         Optional arg b is the second of two sequences to be compared.  By
         default, an empty string.  The elements of b must be hashable. See
         also .set_seqs() and .set_seq2().
+
+        Optional arg autojunk should be set to False to disable the
+        "automatic junk heuristic" that treats popular elements as junk
+        (see module documentation for more information).
         """
 
         # Members:
@@ -178,7 +183,7 @@
         #      we need to do to 'a' to change it into 'b'?"
         # b2j
         #      for x in b, b2j[x] is a list of the indices (into b)
-        #      at which x appears; junk elements do not appear
+        #      at which x appears; junk and popular elements do not appear
         # fullbcount
         #      for x in b, fullbcount[x] == the number of times x
         #      appears in b; only materialized if really needed (used
@@ -200,17 +205,14 @@
         #      subtle but helpful effects on the algorithm, which I'll
         #      get around to writing up someday <0.9 wink>.
         #      DON'T USE!  Only __chain_b uses this.  Use isbjunk.
-        # isbjunk
-        #      for x in b, isbjunk(x) == isjunk(x) but much faster;
-        #      it's really the __contains__ method of a hidden dict.
-        #      DOES NOT WORK for x in a!
-        # isbpopular
-        #      for x in b, isbpopular(x) is true iff b is reasonably long
-        #      (at least 200 elements) and x accounts for more than 1% of
-        #      its elements.  DOES NOT WORK for x in a!
+        # bjunk
+        #      the items in b for which isjunk is True.
+        # bpopular
+        #      nonjunk items in b treated as junk by the heuristic (if used).
 
         self.isjunk = isjunk
         self.a = self.b = None
+        self.autojunk = autojunk
         self.set_seqs(a, b)
 
     def set_seqs(self, a, b):
@@ -287,7 +289,7 @@
     # from starting any matching block at a junk element ...
     # also creates the fast isbjunk function ...
     # b2j also does not contain entries for "popular" elements, meaning
-    # elements that account for more than 1% of the total elements, and
+    # elements that account for more than 1 + 1% of the total elements, and
     # when the sequence is reasonably large (>= 200 elements); this can
     # be viewed as an adaptive notion of semi-junk, and yields an enormous
     # speedup when, e.g., comparing program files with hundreds of
@@ -308,44 +310,46 @@
         # out the junk later is much cheaper than building b2j "right"
         # from the start.
         b = self.b
-        n = len(b)
         self.b2j = b2j = {}
-        populardict = {}
+
         for i, elt in enumerate(b):
-            if elt in b2j:
-                indices = b2j[elt]
-                if n >= 200 and len(indices) * 100 > n:
-                    populardict[elt] = 1
-                    del indices[:]
-                else:
-                    indices.append(i)
-            else:
-                b2j[elt] = [i]
+            indices = b2j.setdefault(elt, [])
+            indices.append(i)
 
-        # Purge leftover indices for popular elements.
-        for elt in populardict:
-            del b2j[elt]
-
-        # Now b2j.keys() contains elements uniquely, and especially when
-        # the sequence is a string, that's usually a good deal smaller
-        # than len(string).  The difference is the number of isjunk calls
-        # saved.
+        # Purge junk elements
+        self.bjunk = junk = set()
         isjunk = self.isjunk
-        junkdict = {}
         if isjunk:
-            for d in populardict, b2j:
-                for elt in list(d.keys()):
-                    if isjunk(elt):
-                        junkdict[elt] = 1
-                        del d[elt]
-
-        # Now for x in b, isjunk(x) == x in junkdict, but the
-        # latter is much faster.  Note too that while there may be a
-        # lot of junk in the sequence, the number of *unique* junk
-        # elements is probably small.  So the memory burden of keeping
-        # this dict alive is likely trivial compared to the size of b2j.
-        self.isbjunk = junkdict.__contains__
-        self.isbpopular = populardict.__contains__
+            for elt in b2j.keys():
+                if isjunk(elt):
+                    junk.add(elt)
+            for elt in junk: # separate loop avoids separate list of keys
+                del b2j[elt]
+
+        # Purge popular elements that are not junk
+        self.bpopular = popular = set()
+        n = len(b)
+        if self.autojunk and n >= 200:
+            ntest = n // 100 + 1
+            for elt, idxs in b2j.items():
+                if len(idxs) > ntest:
+                    popular.add(elt)
+            for elt in popular: # ditto; as fast for 1% deletion
+                del b2j[elt]
+
+    def isbjunk(self, item):
+        "Deprecated; use 'item in SequenceMatcher().bjunk'."
+        warnings.warn("'SequenceMatcher().isbjunk(item)' is deprecated;\n"
+                      "use 'item in SMinstance.bjunk' instead.",
+                      DeprecationWarning, 2)
+        return item in self.bjunk
+
+    def isbpopular(self, item):
+        "Deprecated; use 'item in SequenceMatcher().bpopular'."
+        warnings.warn("'SequenceMatcher().isbpopular(item)' is deprecated;\n"
+                      "use 'item in SMinstance.bpopular' instead.",
+                      DeprecationWarning, 2)
+        return item in self.bpopular
 
     def find_longest_match(self, alo, ahi, blo, bhi):
         """Find longest matching block in a[alo:ahi] and b[blo:bhi].
@@ -403,7 +407,7 @@
         # Windiff ends up at the same place as diff, but by pairing up
         # the unique 'b's and then matching the first two 'a's.
 
-        a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.isbjunk
+        a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.bjunk.__contains__
         besti, bestj, bestsize = alo, blo, 0
         # find longest junk-free match
         # during an iteration of the loop, j2len[j] = length of longest

Modified: python/branches/py3k-cdecimal/Lib/distutils/__init__.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/distutils/__init__.py	(original)
+++ python/branches/py3k-cdecimal/Lib/distutils/__init__.py	Sun Jan  2 13:18:37 2011
@@ -15,5 +15,5 @@
 # Updated automatically by the Python release process.
 #
 #--start constants--
-__version__ = "3.2a4"
+__version__ = "3.2b2"
 #--end constants--

Modified: python/branches/py3k-cdecimal/Lib/distutils/archive_util.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/distutils/archive_util.py	(original)
+++ python/branches/py3k-cdecimal/Lib/distutils/archive_util.py	Sun Jan  2 13:18:37 2011
@@ -68,7 +68,7 @@
 def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
     """Create a zip file from all the files under 'base_dir'.
 
-    The output zip file will be named 'base_dir' + ".zip".  Uses either the
+    The output zip file will be named 'base_name' + ".zip".  Uses either the
     "zipfile" Python module (if available) or the InfoZIP "zip" utility
     (if installed and found on the default search path).  If neither tool is
     available, raises DistutilsExecError.  Returns the name of the output zip

Modified: python/branches/py3k-cdecimal/Lib/distutils/command/build_ext.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/distutils/command/build_ext.py	(original)
+++ python/branches/py3k-cdecimal/Lib/distutils/command/build_ext.py	Sun Jan  2 13:18:37 2011
@@ -214,7 +214,7 @@
 
             elif MSVC_VERSION == 8:
                 self.library_dirs.append(os.path.join(sys.exec_prefix,
-                                         'PC', 'VS8.0', 'win32release'))
+                                         'PC', 'VS8.0'))
             elif MSVC_VERSION == 7:
                 self.library_dirs.append(os.path.join(sys.exec_prefix,
                                          'PC', 'VS7.1'))

Modified: python/branches/py3k-cdecimal/Lib/distutils/command/install.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/distutils/command/install.py	(original)
+++ python/branches/py3k-cdecimal/Lib/distutils/command/install.py	Sun Jan  2 13:18:37 2011
@@ -48,7 +48,7 @@
     'unix_prefix': {
         'purelib': '$base/lib/python$py_version_short/site-packages',
         'platlib': '$platbase/lib/python$py_version_short/site-packages',
-        'headers': '$base/include/python$py_version_short/$dist_name',
+        'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
         'scripts': '$base/bin',
         'data'   : '$base',
         },
@@ -82,7 +82,8 @@
     INSTALL_SCHEMES['unix_user'] = {
         'purelib': '$usersite',
         'platlib': '$usersite',
-        'headers': '$userbase/include/python$py_version_short/$dist_name',
+        'headers':
+            '$userbase/include/python$py_version_short$abiflags/$dist_name',
         'scripts': '$userbase/bin',
         'data'   : '$userbase',
         }
@@ -312,6 +313,11 @@
 
         py_version = sys.version.split()[0]
         (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
+        try:
+            abiflags = sys.abiflags
+        except AttributeError:
+            # sys.abiflags may not be defined on all platforms.
+            abiflags = ''
         self.config_vars = {'dist_name': self.distribution.get_name(),
                             'dist_version': self.distribution.get_version(),
                             'dist_fullname': self.distribution.get_fullname(),
@@ -322,6 +328,7 @@
                             'prefix': prefix,
                             'sys_exec_prefix': exec_prefix,
                             'exec_prefix': exec_prefix,
+                            'abiflags': abiflags,
                            }
 
         if HAS_USER_SITE:

Modified: python/branches/py3k-cdecimal/Lib/distutils/sysconfig.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/distutils/sysconfig.py	(original)
+++ python/branches/py3k-cdecimal/Lib/distutils/sysconfig.py	Sun Jan  2 13:18:37 2011
@@ -11,7 +11,6 @@
 
 __revision__ = "$Id$"
 
-import io
 import os
 import re
 import sys
@@ -49,6 +48,18 @@
     return False
 python_build = _python_build()
 
+# Calculate the build qualifier flags if they are defined.  Adding the flags
+# to the include and lib directories only makes sense for an installation, not
+# an in-source build.
+build_flags = ''
+try:
+    if not python_build:
+        build_flags = sys.abiflags
+except AttributeError:
+    # It's not a configure-based build, so the sys module doesn't have
+    # this attribute, which is fine.
+    pass
+
 def get_python_version():
     """Return a string containing the major and minor Python version,
     leaving off the patchlevel.  Sample return values could be '1.5'
@@ -83,7 +94,8 @@
             else:
                 incdir = os.path.join(get_config_var('srcdir'), 'Include')
                 return os.path.normpath(incdir)
-        return os.path.join(prefix, "include", "python" + get_python_version())
+        python_dir = 'python' + get_python_version() + build_flags
+        return os.path.join(prefix, "include", python_dir)
     elif os.name == "nt":
         return os.path.join(prefix, "include")
     elif os.name == "os2":
@@ -209,7 +221,8 @@
     if python_build:
         return os.path.join(os.path.dirname(sys.executable), "Makefile")
     lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
-    return os.path.join(lib_dir, "config", "Makefile")
+    config_file = 'config-{}{}'.format(get_python_version(), build_flags)
+    return os.path.join(lib_dir, config_file, 'Makefile')
 
 
 def parse_config_h(fp, g=None):

Modified: python/branches/py3k-cdecimal/Lib/doctest.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/doctest.py	(original)
+++ python/branches/py3k-cdecimal/Lib/doctest.py	Sun Jan  2 13:18:37 2011
@@ -318,7 +318,8 @@
     def __init__(self, out):
         self.__out = out
         self.__debugger_used = False
-        pdb.Pdb.__init__(self, stdout=out)
+        # do not play signal games in the pdb
+        pdb.Pdb.__init__(self, stdout=out, nosigint=True)
         # still use input() to get user input
         self.use_rawinput = 1
 
@@ -2528,14 +2529,16 @@
                     exec(f.read(), globs, globs)
             except:
                 print(sys.exc_info()[1])
-                pdb.post_mortem(sys.exc_info()[2])
+                p = pdb.Pdb(nosigint=True)
+                p.reset()
+                p.interaction(None, sys.exc_info()[2])
         else:
             fp = open(srcfilename)
             try:
                 script = fp.read()
             finally:
                 fp.close()
-            pdb.run("exec(%r)" % script, globs, globs)
+            pdb.Pdb(nosigint=True).run("exec(%r)" % script, globs, globs)
 
     finally:
         os.remove(srcfilename)

Modified: python/branches/py3k-cdecimal/Lib/email/_parseaddr.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/email/_parseaddr.py	(original)
+++ python/branches/py3k-cdecimal/Lib/email/_parseaddr.py	Sun Jan  2 13:18:37 2011
@@ -64,8 +64,10 @@
     if len(data) == 4:
         s = data[3]
         i = s.find('+')
+        if i == -1:
+            i = s.find('-')
         if i > 0:
-            data[3:] = [s[:i], s[i+1:]]
+            data[3:] = [s[:i], s[i:]]
         else:
             data.append('') # Dummy tz
     if len(data) < 5:
@@ -199,14 +201,18 @@
         self.commentlist = []
 
     def gotonext(self):
-        """Parse up to the start of the next address."""
+        """Skip white space and extract comments."""
+        wslist = []
         while self.pos < len(self.field):
             if self.field[self.pos] in self.LWS + '\n\r':
+                if self.field[self.pos] not in '\n\r':
+                    wslist.append(self.field[self.pos])
                 self.pos += 1
             elif self.field[self.pos] == '(':
                 self.commentlist.append(self.getcomment())
             else:
                 break
+        return EMPTYSTRING.join(wslist)
 
     def getaddrlist(self):
         """Parse all addresses.
@@ -319,16 +325,24 @@
 
         self.gotonext()
         while self.pos < len(self.field):
+            preserve_ws = True
             if self.field[self.pos] == '.':
+                if aslist and not aslist[-1].strip():
+                    aslist.pop()
                 aslist.append('.')
                 self.pos += 1
+                preserve_ws = False
             elif self.field[self.pos] == '"':
                 aslist.append('"%s"' % quote(self.getquote()))
             elif self.field[self.pos] in self.atomends:
+                if aslist and not aslist[-1].strip():
+                    aslist.pop()
                 break
             else:
                 aslist.append(self.getatom())
-            self.gotonext()
+            ws = self.gotonext()
+            if preserve_ws and ws:
+                aslist.append(ws)
 
         if self.pos >= len(self.field) or self.field[self.pos] != '@':
             return EMPTYSTRING.join(aslist)

Modified: python/branches/py3k-cdecimal/Lib/email/generator.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/email/generator.py	(original)
+++ python/branches/py3k-cdecimal/Lib/email/generator.py	Sun Jan  2 13:18:37 2011
@@ -220,18 +220,13 @@
             g = self.clone(s)
             g.flatten(part, unixfrom=False, linesep=self._NL)
             msgtexts.append(s.getvalue())
-        # Now make sure the boundary we've selected doesn't appear in any of
-        # the message texts.
-        alltext = self._encoded_NL.join(msgtexts)
         # BAW: What about boundaries that are wrapped in double-quotes?
-        boundary = msg.get_boundary(failobj=self._make_boundary(alltext))
-        # If we had to calculate a new boundary because the body text
-        # contained that string, set the new boundary.  We don't do it
-        # unconditionally because, while set_boundary() preserves order, it
-        # doesn't preserve newlines/continuations in headers.  This is no big
-        # deal in practice, but turns out to be inconvenient for the unittest
-        # suite.
-        if msg.get_boundary() != boundary:
+        boundary = msg.get_boundary()
+        if not boundary:
+            # Create a boundary that doesn't appear in any of the
+            # message texts.
+            alltext = self._encoded_NL.join(msgtexts)
+            boundary = self._make_boundary(alltext)
             msg.set_boundary(boundary)
         # If there's a preamble, write it out, with a trailing CRLF
         if msg.preamble is not None:

Modified: python/branches/py3k-cdecimal/Lib/email/header.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/email/header.py	(original)
+++ python/branches/py3k-cdecimal/Lib/email/header.py	Sun Jan  2 13:18:37 2011
@@ -169,7 +169,7 @@
         charset is used both as s's initial charset and as the default for
         subsequent .append() calls.
 
-        The maximum line length can be specified explicit via maxlinelen.  For
+        The maximum line length can be specified explicitly via maxlinelen. For
         splitting the first line to a shorter value (to account for the field
         header which isn't included in s, e.g. `Subject') pass in the name of
         the field in header_name.  The default maxlinelen is 78 as recommended
@@ -241,7 +241,7 @@
         constructor is used.
 
         s may be a byte string or a Unicode string.  If it is a byte string
-        (i.e. isinstance(s, str) is true), then charset is the encoding of
+        (i.e. isinstance(s, str) is false), then charset is the encoding of
         that byte string, and a UnicodeError will be raised if the string
         cannot be decoded with that charset.  If s is a Unicode string, then
         charset is a hint specifying the character set of the characters in

Modified: python/branches/py3k-cdecimal/Lib/email/message.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/email/message.py	(original)
+++ python/branches/py3k-cdecimal/Lib/email/message.py	Sun Jan  2 13:18:37 2011
@@ -57,16 +57,28 @@
 def _formatparam(param, value=None, quote=True):
     """Convenience function to format and return a key=value pair.
 
-    This will quote the value if needed or if quote is true.
+    This will quote the value if needed or if quote is true.  If value is a
+    three tuple (charset, language, value), it will be encoded according
+    to RFC2231 rules.  If it contains non-ascii characters it will likewise
+    be encoded according to RFC2231 rules, using the utf-8 charset and
+    a null language.
     """
     if value is not None and len(value) > 0:
         # A tuple is used for RFC 2231 encoded parameter values where items
         # are (charset, language, value).  charset is a string, not a Charset
-        # instance.
+        # instance.  RFC 2231 encoded values are never quoted, per RFC.
         if isinstance(value, tuple):
             # Encode as per RFC 2231
             param += '*'
             value = utils.encode_rfc2231(value[2], value[0], value[1])
+            return '%s=%s' % (param, value)
+        else:
+            try:
+                value.encode('ascii')
+            except UnicodeEncodeError:
+                param += '*'
+                value = utils.encode_rfc2231(value, 'utf-8', '')
+                return '%s=%s' % (param, value)
         # BAW: Please check this.  I think that if quote is set it should
         # force quoting even if not necessary.
         if quote or tspecials.search(value):
@@ -438,11 +450,19 @@
         name is the header field to add.  keyword arguments can be used to set
         additional parameters for the header field, with underscores converted
         to dashes.  Normally the parameter will be added as key="value" unless
-        value is None, in which case only the key will be added.
+        value is None, in which case only the key will be added.  If a
+        parameter value contains non-ASCII characters it can be specified as a
+        three-tuple of (charset, language, value), in which case it will be
+        encoded according to RFC2231 rules.  Otherwise it will be encoded using
+        the utf-8 charset and a language of ''.
 
-        Example:
+        Examples:
 
         msg.add_header('content-disposition', 'attachment', filename='bud.gif')
+        msg.add_header('content-disposition', 'attachment',
+                       filename=('utf-8', '', Fußballer.ppt'))
+        msg.add_header('content-disposition', 'attachment',
+                       filename='Fußballer.ppt'))
         """
         parts = []
         for k, v in _params.items():

Modified: python/branches/py3k-cdecimal/Lib/email/test/test_email.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/email/test/test_email.py	(original)
+++ python/branches/py3k-cdecimal/Lib/email/test/test_email.py	Sun Jan  2 13:18:37 2011
@@ -180,6 +180,17 @@
         self.assertRaises(errors.HeaderParseError,
                           msg.set_boundary, 'BOUNDARY')
 
+    def test_make_boundary(self):
+        msg = MIMEMultipart('form-data')
+        # Note that when the boundary gets created is an implementation
+        # detail and might change.
+        self.assertEqual(msg.items()[0][1], 'multipart/form-data')
+        # Trigger creation of boundary
+        msg.as_string()
+        self.assertEqual(msg.items()[0][1][:33],
+                        'multipart/form-data; boundary="==')
+        # XXX: there ought to be tests of the uniqueness of the boundary, too.
+
     def test_message_rfc822_only(self):
         # Issue 7970: message/rfc822 not in multipart parsed by
         # HeaderParser caused an exception when flattened.
@@ -510,6 +521,45 @@
         self.assertEqual(msg.get_payload(decode=True),
                          bytes(x, 'raw-unicode-escape'))
 
+    # Issue 1078919
+    def test_ascii_add_header(self):
+        msg = Message()
+        msg.add_header('Content-Disposition', 'attachment',
+                       filename='bud.gif')
+        self.assertEqual('attachment; filename="bud.gif"',
+            msg['Content-Disposition'])
+
+    def test_noascii_add_header(self):
+        msg = Message()
+        msg.add_header('Content-Disposition', 'attachment',
+            filename="Fußballer.ppt")
+        self.assertEqual(
+            'attachment; filename*=utf-8\'\'Fu%C3%9Fballer.ppt',
+            msg['Content-Disposition'])
+
+    def test_nonascii_add_header_via_triple(self):
+        msg = Message()
+        msg.add_header('Content-Disposition', 'attachment',
+            filename=('iso-8859-1', '', 'Fußballer.ppt'))
+        self.assertEqual(
+            'attachment; filename*=iso-8859-1\'\'Fu%DFballer.ppt',
+            msg['Content-Disposition'])
+
+    def test_ascii_add_header_with_tspecial(self):
+        msg = Message()
+        msg.add_header('Content-Disposition', 'attachment',
+            filename="windows [filename].ppt")
+        self.assertEqual(
+            'attachment; filename="windows [filename].ppt"',
+            msg['Content-Disposition'])
+
+    def test_nonascii_add_header_with_tspecial(self):
+        msg = Message()
+        msg.add_header('Content-Disposition', 'attachment',
+            filename="Fußballer [filename].ppt")
+        self.assertEqual(
+            "attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.ppt",
+            msg['Content-Disposition'])
 
 
 # Test the email.encoders module
@@ -2243,6 +2293,16 @@
         eq(utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
            (2003, 2, 5, 13, 47, 26, 0, 1, -1, -28800))
 
+    def test_parsedate_no_space_before_positive_offset(self):
+        self.assertEqual(utils.parsedate_tz('Wed, 3 Apr 2002 14:58:26+0800'),
+           (2002, 4, 3, 14, 58, 26, 0, 1, -1, 28800))
+
+    def test_parsedate_no_space_before_negative_offset(self):
+        # Issue 1155362: we already handled '+' for this case.
+        self.assertEqual(utils.parsedate_tz('Wed, 3 Apr 2002 14:58:26-0800'),
+           (2002, 4, 3, 14, 58, 26, 0, 1, -1, -28800))
+
+
     def test_parsedate_acceptable_to_time_functions(self):
         eq = self.assertEqual
         timetup = utils.parsedate('5 Feb 2003 13:47:26 -0800')
@@ -2319,6 +2379,24 @@
         eq(utils.parseaddr('"\\\\"example\\\\" example"@example.com'),
           ('', '"\\\\"example\\\\" example"@example.com'))
 
+    def test_parseaddr_preserves_spaces_in_local_part(self):
+        # issue 9286.  A normal RFC5322 local part should not contain any
+        # folding white space, but legacy local parts can (they are a sequence
+        # of atoms, not dotatoms).  On the other hand we strip whitespace from
+        # before the @ and around dots, on the assumption that the whitespace
+        # around the punctuation is a mistake in what would otherwise be
+        # an RFC5322 local part.  Leading whitespace is, usual, stripped as well.
+        self.assertEqual(('', "merwok wok at xample.com"),
+            utils.parseaddr("merwok wok at xample.com"))
+        self.assertEqual(('', "merwok  wok at xample.com"),
+            utils.parseaddr("merwok  wok at xample.com"))
+        self.assertEqual(('', "merwok  wok at xample.com"),
+            utils.parseaddr(" merwok  wok  @xample.com"))
+        self.assertEqual(('', 'merwok"wok"  wok at xample.com'),
+            utils.parseaddr('merwok"wok"  wok at xample.com'))
+        self.assertEqual(('', 'merwok.wok.wok at xample.com'),
+            utils.parseaddr('merwok. wok .  wok at xample.com'))
+
     def test_multiline_from_comment(self):
         x = """\
 Foo
@@ -2457,6 +2535,10 @@
     text/rfc822-headers
 """)
 
+    def test_make_msgid_domain(self):
+        self.assertEqual(
+            email.utils.make_msgid(domain='testdomain-string')[-19:],
+            '@testdomain-string>')
 
 
 # Test the iterator/generators
@@ -3577,7 +3659,7 @@
 Subject: This is a test message
 Date: Fri, 4 May 2001 14:05:44 -0400
 Content-Type: text/plain; charset=us-ascii;
- title*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21"
+ title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21
 
 
 Hi,
@@ -3607,7 +3689,7 @@
 Subject: This is a test message
 Date: Fri, 4 May 2001 14:05:44 -0400
 Content-Type: text/plain; charset="us-ascii";
- title*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21"
+ title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21
 
 
 Hi,
@@ -3622,6 +3704,32 @@
         msg = self._msgobj('msg_32.txt')
         eq(msg.get_content_charset(), 'us-ascii')
 
+    def test_rfc2231_parse_rfc_quoting(self):
+        m = textwrap.dedent('''\
+            Content-Disposition: inline;
+            \tfilename*0*=''This%20is%20even%20more%20;
+            \tfilename*1*=%2A%2A%2Afun%2A%2A%2A%20;
+            \tfilename*2="is it not.pdf"
+
+            ''')
+        msg = email.message_from_string(m)
+        self.assertEqual(msg.get_filename(),
+                         'This is even more ***fun*** is it not.pdf')
+        self.assertEqual(m, msg.as_string())
+
+    def test_rfc2231_parse_extra_quoting(self):
+        m = textwrap.dedent('''\
+            Content-Disposition: inline;
+            \tfilename*0*="''This%20is%20even%20more%20";
+            \tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+            \tfilename*2="is it not.pdf"
+
+            ''')
+        msg = email.message_from_string(m)
+        self.assertEqual(msg.get_filename(),
+                         'This is even more ***fun*** is it not.pdf')
+        self.assertEqual(m, msg.as_string())
+
     def test_rfc2231_no_language_or_charset(self):
         m = '''\
 Content-Transfer-Encoding: 8bit

Modified: python/branches/py3k-cdecimal/Lib/email/utils.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/email/utils.py	(original)
+++ python/branches/py3k-cdecimal/Lib/email/utils.py	Sun Jan  2 13:18:37 2011
@@ -148,13 +148,15 @@
 
 
 
-def make_msgid(idstring=None):
+def make_msgid(idstring=None, domain=None):
     """Returns a string suitable for RFC 2822 compliant Message-ID, e.g:
 
     <20020201195627.33539.96671 at nightshade.la.mastaler.com>
 
     Optional idstring if given is a string used to strengthen the
-    uniqueness of the message id.
+    uniqueness of the message id.  Optional domain if given provides the
+    portion of the message id after the '@'.  It defaults to the locally
+    defined hostname.
     """
     timeval = time.time()
     utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval))
@@ -164,8 +166,9 @@
         idstring = ''
     else:
         idstring = '.' + idstring
-    idhost = socket.getfqdn()
-    msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, idhost)
+    if domain is None:
+        domain = socket.getfqdn()
+    msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, domain)
     return msgid
 
 

Modified: python/branches/py3k-cdecimal/Lib/encodings/aliases.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/encodings/aliases.py	(original)
+++ python/branches/py3k-cdecimal/Lib/encodings/aliases.py	Sun Jan  2 13:18:37 2011
@@ -33,9 +33,9 @@
     'us'                 : 'ascii',
     'us_ascii'           : 'ascii',
 
-    ## base64_codec codec
-    #'base64'             : 'base64_codec',
-    #'base_64'            : 'base64_codec',
+    # base64_codec codec
+    'base64'             : 'base64_codec',
+    'base_64'            : 'base64_codec',
 
     # big5 codec
     'big5_tw'            : 'big5',
@@ -45,8 +45,8 @@
     'big5_hkscs'         : 'big5hkscs',
     'hkscs'              : 'big5hkscs',
 
-    ## bz2_codec codec
-    #'bz2'                : 'bz2_codec',
+    # bz2_codec codec
+    'bz2'                : 'bz2_codec',
 
     # cp037 codec
     '037'                : 'cp037',
@@ -248,8 +248,8 @@
     'cp936'              : 'gbk',
     'ms936'              : 'gbk',
 
-    ## hex_codec codec
-    #'hex'                : 'hex_codec',
+    # hex_codec codec
+    'hex'                : 'hex_codec',
 
     # hp_roman8 codec
     'roman8'             : 'hp_roman8',
@@ -450,13 +450,13 @@
     'cp154'              : 'ptcp154',
     'cyrillic_asian'     : 'ptcp154',
 
-    ## quopri_codec codec
-    #'quopri'             : 'quopri_codec',
-    #'quoted_printable'   : 'quopri_codec',
-    #'quotedprintable'    : 'quopri_codec',
+    # quopri_codec codec
+    'quopri'             : 'quopri_codec',
+    'quoted_printable'   : 'quopri_codec',
+    'quotedprintable'    : 'quopri_codec',
 
-    ## rot_13 codec
-    #'rot13'              : 'rot_13',
+    # rot_13 codec
+    'rot13'              : 'rot_13',
 
     # shift_jis codec
     'csshiftjis'         : 'shift_jis',
@@ -518,12 +518,12 @@
     'utf8_ucs2'          : 'utf_8',
     'utf8_ucs4'          : 'utf_8',
 
-    ## uu_codec codec
-    #'uu'                 : 'uu_codec',
+    # uu_codec codec
+    'uu'                 : 'uu_codec',
 
-    ## zlib_codec codec
-    #'zip'                : 'zlib_codec',
-    #'zlib'               : 'zlib_codec',
+    # zlib_codec codec
+    'zip'                : 'zlib_codec',
+    'zlib'               : 'zlib_codec',
 
     # temporary mac CJK aliases, will be replaced by proper codecs in 3.1
     'x_mac_japanese'      : 'shift_jis',

Modified: python/branches/py3k-cdecimal/Lib/functools.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/functools.py	(original)
+++ python/branches/py3k-cdecimal/Lib/functools.py	Sun Jan  2 13:18:37 2011
@@ -12,7 +12,7 @@
            'total_ordering', 'cmp_to_key', 'lru_cache', 'reduce', 'partial']
 
 from _functools import partial, reduce
-from collections import OrderedDict
+from collections import OrderedDict, namedtuple
 try:
     from _thread import allocate_lock as Lock
 except:
@@ -114,49 +114,91 @@
             raise TypeError('hash not implemented')
     return K
 
+_CacheInfo = namedtuple("CacheInfo", "hits misses maxsize currsize")
+
 def lru_cache(maxsize=100):
     """Least-recently-used cache decorator.
 
+    If *maxsize* is set to None, the LRU features are disabled and the cache
+    can grow without bound.
+
     Arguments to the cached function must be hashable.
-    Cache performance statistics stored in f.hits and f.misses.
-    Clear the cache using f.clear().
-    http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
+
+    View the cache statistics named tuple (hits, misses, maxsize, currsize) with
+    f.cache_info().  Clear the cache and statistics with f.cache_clear().
+    Access the underlying function with f.__wrapped__.
+
+    See:  http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
 
     """
-    def decorating_function(user_function, tuple=tuple, sorted=sorted,
-                            len=len, KeyError=KeyError):
-        cache = OrderedDict()           # ordered least recent to most recent
-        cache_popitem = cache.popitem
-        cache_renew = cache.move_to_end
-        kwd_mark = object()             # separate positional and keyword args
+    # Users should only access the lru_cache through its public API:
+    #       cache_info, cache_clear, and f.__wrapped__
+    # The internals of the lru_cache are encapsulated for thread safety and
+    # to allow the implementation to change (including a possible C version).
+
+    def decorating_function(user_function,
+                tuple=tuple, sorted=sorted, len=len, KeyError=KeyError):
+
+        hits = misses = 0
+        kwd_mark = object()             # separates positional and keyword args
         lock = Lock()
 
-        @wraps(user_function)
-        def wrapper(*args, **kwds):
-            key = args
-            if kwds:
-                key += (kwd_mark,) + tuple(sorted(kwds.items()))
-            try:
-                with lock:
+        if maxsize is None:
+            cache = dict()              # simple cache without ordering or size limit
+
+            @wraps(user_function)
+            def wrapper(*args, **kwds):
+                nonlocal hits, misses
+                key = args
+                if kwds:
+                    key += (kwd_mark,) + tuple(sorted(kwds.items()))
+                try:
                     result = cache[key]
-                    cache_renew(key)            # record recent use of this key
-                    wrapper.cache_hits += 1
-            except KeyError:
-                result = user_function(*args, **kwds)
-                with lock:
-                    cache[key] = result         # record recent use of this key
-                    wrapper.cache_misses += 1
-                    if len(cache) > maxsize:
-                        cache_popitem(0)        # purge least recently used cache entry
-            return result
+                    hits += 1
+                except KeyError:
+                    result = user_function(*args, **kwds)
+                    cache[key] = result
+                    misses += 1
+                return result
+        else:
+            cache = OrderedDict()       # ordered least recent to most recent
+            cache_popitem = cache.popitem
+            cache_renew = cache.move_to_end
+
+            @wraps(user_function)
+            def wrapper(*args, **kwds):
+                nonlocal hits, misses
+                key = args
+                if kwds:
+                    key += (kwd_mark,) + tuple(sorted(kwds.items()))
+                try:
+                    with lock:
+                        result = cache[key]
+                        cache_renew(key)        # record recent use of this key
+                        hits += 1
+                except KeyError:
+                    result = user_function(*args, **kwds)
+                    with lock:
+                        cache[key] = result     # record recent use of this key
+                        misses += 1
+                        if len(cache) > maxsize:
+                            cache_popitem(0)    # purge least recently used cache entry
+                return result
+
+        def cache_info():
+            """Report cache statistics"""
+            with lock:
+                return _CacheInfo(hits, misses, maxsize, len(cache))
 
         def cache_clear():
             """Clear the cache and cache statistics"""
+            nonlocal hits, misses
             with lock:
                 cache.clear()
-                wrapper.cache_hits = wrapper.cache_misses = 0
+                hits = misses = 0
 
-        wrapper.cache_hits = wrapper.cache_misses = 0
+        wrapper.cache_info = cache_info
         wrapper.cache_clear = cache_clear
         return wrapper
+
     return decorating_function

Modified: python/branches/py3k-cdecimal/Lib/getpass.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/getpass.py	(original)
+++ python/branches/py3k-cdecimal/Lib/getpass.py	Sun Jan  2 13:18:37 2011
@@ -166,12 +166,7 @@
     try:
         import msvcrt
     except ImportError:
-        try:
-            from EasyDialogs import AskPassword
-        except ImportError:
-            getpass = fallback_getpass
-        else:
-            getpass = AskPassword
+        getpass = fallback_getpass
     else:
         getpass = win_getpass
 else:

Modified: python/branches/py3k-cdecimal/Lib/gettext.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/gettext.py	(original)
+++ python/branches/py3k-cdecimal/Lib/gettext.py	Sun Jan  2 13:18:37 2011
@@ -46,7 +46,7 @@
 #   find this format documented anywhere.
 
 
-import locale, copy, os, re, struct, sys
+import locale, copy, io, os, re, struct, sys
 from errno import ENOENT
 
 
@@ -58,28 +58,13 @@
 _default_localedir = os.path.join(sys.prefix, 'share', 'locale')
 
 
-def test(condition, true, false):
-    """
-    Implements the C expression:
-
-      condition ? true : false
-
-    Required to correctly interpret plural forms.
-    """
-    if condition:
-        return true
-    else:
-        return false
-
-
 def c2py(plural):
     """Gets a C expression as used in PO files for plural forms and returns a
     Python lambda function that implements an equivalent expression.
     """
     # Security check, allow only the "n" identifier
-    from io import StringIO
     import token, tokenize
-    tokens = tokenize.generate_tokens(StringIO(plural).readline)
+    tokens = tokenize.generate_tokens(io.StringIO(plural).readline)
     try:
         danger = [x for x in tokens if x[0] == token.NAME and x[1] != 'n']
     except tokenize.TokenError:
@@ -96,11 +81,11 @@
     plural = expr.sub(' not \\1', plural)
 
     # Regular expression and replacement function used to transform
-    # "a?b:c" to "test(a,b,c)".
+    # "a?b:c" to "b if a else c".
     expr = re.compile(r'(.*?)\?(.*?):(.*)')
     def repl(x):
-        return "test(%s, %s, %s)" % (x.group(1), x.group(2),
-                                     expr.sub(repl, x.group(3)))
+        return "(%s if %s else %s)" % (x.group(2), x.group(1),
+                                       expr.sub(repl, x.group(3)))
 
     # Code to transform the plural expression, taking care of parentheses
     stack = ['']
@@ -123,36 +108,35 @@
 
 
 
-def _expand_lang(locale):
-    from locale import normalize
-    locale = normalize(locale)
+def _expand_lang(loc):
+    loc = locale.normalize(loc)
     COMPONENT_CODESET   = 1 << 0
     COMPONENT_TERRITORY = 1 << 1
     COMPONENT_MODIFIER  = 1 << 2
     # split up the locale into its base components
     mask = 0
-    pos = locale.find('@')
+    pos = loc.find('@')
     if pos >= 0:
-        modifier = locale[pos:]
-        locale = locale[:pos]
+        modifier = loc[pos:]
+        loc = loc[:pos]
         mask |= COMPONENT_MODIFIER
     else:
         modifier = ''
-    pos = locale.find('.')
+    pos = loc.find('.')
     if pos >= 0:
-        codeset = locale[pos:]
-        locale = locale[:pos]
+        codeset = loc[pos:]
+        loc = loc[:pos]
         mask |= COMPONENT_CODESET
     else:
         codeset = ''
-    pos = locale.find('_')
+    pos = loc.find('_')
     if pos >= 0:
-        territory = locale[pos:]
-        locale = locale[:pos]
+        territory = loc[pos:]
+        loc = loc[:pos]
         mask |= COMPONENT_TERRITORY
     else:
         territory = ''
-    language = locale
+    language = loc
     ret = []
     for i in range(mask+1):
         if not (i & ~mask):  # if all components for this combo exist ...

Modified: python/branches/py3k-cdecimal/Lib/html/parser.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/html/parser.py	(original)
+++ python/branches/py3k-cdecimal/Lib/html/parser.py	Sun Jan  2 13:18:37 2011
@@ -24,10 +24,14 @@
 piclose = re.compile('>')
 commentclose = re.compile(r'--\s*>')
 tagfind = re.compile('[a-zA-Z][-.a-zA-Z0-9:_]*')
+# Note, the strict one of this pair isn't really strict, but we can't
+# make it correctly strict without breaking backward compatibility.
 attrfind = re.compile(
     r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*'
     r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~@]*))?')
-
+attrfind_tolerant = re.compile(
+    r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*'
+    r'(\'[^\']*\'|"[^"]*"|[^>\s]*))?')
 locatestarttagend = re.compile(r"""
   <[a-zA-Z][-.a-zA-Z0-9:_]*          # tag name
   (?:\s+                             # whitespace before attribute name
@@ -42,6 +46,21 @@
    )*
   \s*                                # trailing whitespace
 """, re.VERBOSE)
+locatestarttagend_tolerant = re.compile(r"""
+  <[a-zA-Z][-.a-zA-Z0-9:_]*          # tag name
+  (?:\s*                             # optional whitespace before attribute name
+    (?:[a-zA-Z_][-.:a-zA-Z0-9_]*     # attribute name
+      (?:\s*=\s*                     # value indicator
+        (?:'[^']*'                   # LITA-enclosed value
+          |\"[^\"]*\"                # LIT-enclosed value
+          |[^'\">\s]+                # bare value
+         )
+         (?:\s*,)*                   # possibly followed by a comma
+       )?
+     )
+   )*
+  \s*                                # trailing whitespace
+""", re.VERBOSE)
 endendtag = re.compile('>')
 endtagfind = re.compile('</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>')
 
@@ -86,9 +105,15 @@
 
     CDATA_CONTENT_ELEMENTS = ("script", "style")
 
+    def __init__(self, strict=True):
+        """Initialize and reset this instance.
 
-    def __init__(self):
-        """Initialize and reset this instance."""
+        If strict is set to True (the default), errors are raised when invalid
+        HTML is encountered.  If set to False, an attempt is instead made to
+        continue parsing, making "best guesses" about the intended meaning, in
+        a fashion similar to what browsers typically do.
+        """
+        self.strict = strict
         self.reset()
 
     def reset(self):
@@ -160,9 +185,18 @@
                 else:
                     break
                 if k < 0:
-                    if end:
+                    if not end:
+                        break
+                    if self.strict:
                         self.error("EOF in middle of construct")
-                    break
+                    k = rawdata.find('>', i + 1)
+                    if k < 0:
+                        k = rawdata.find('<', i + 1)
+                        if k < 0:
+                            k = i + 1
+                    else:
+                        k += 1
+                    self.handle_data(rawdata[i:k])
                 i = self.updatepos(i, k)
             elif startswith("&#", i):
                 match = charref.match(rawdata, i)
@@ -193,7 +227,12 @@
                 if match:
                     # match.group() will contain at least 2 chars
                     if end and match.group() == rawdata[i:]:
-                        self.error("EOF in middle of entity or char ref")
+                        if self.strict:
+                            self.error("EOF in middle of entity or char ref")
+                        else:
+                            if k <= i:
+                                k = n
+                            i = self.updatepos(i, i + 1)
                     # incomplete
                     break
                 elif (i + 1) < n:
@@ -240,7 +279,10 @@
         self.lasttag = tag = rawdata[i+1:k].lower()
 
         while k < endpos:
-            m = attrfind.match(rawdata, k)
+            if self.strict:
+                m = attrfind.match(rawdata, k)
+            else:
+                m = attrfind_tolerant.search(rawdata, k)
             if not m:
                 break
             attrname, rest, attrvalue = m.group(1, 2, 3)
@@ -262,8 +304,11 @@
                          - self.__starttag_text.rfind("\n")
             else:
                 offset = offset + len(self.__starttag_text)
-            self.error("junk characters in start tag: %r"
-                       % (rawdata[k:endpos][:20],))
+            if self.strict:
+                self.error("junk characters in start tag: %r"
+                           % (rawdata[k:endpos][:20],))
+            self.handle_data(rawdata[i:endpos])
+            return endpos
         if end.endswith('/>'):
             # XHTML-style empty tag: <span attr="value" />
             self.handle_startendtag(tag, attrs)
@@ -277,7 +322,10 @@
     # or -1 if incomplete.
     def check_for_whole_start_tag(self, i):
         rawdata = self.rawdata
-        m = locatestarttagend.match(rawdata, i)
+        if self.strict:
+            m = locatestarttagend.match(rawdata, i)
+        else:
+            m = locatestarttagend_tolerant.match(rawdata, i)
         if m:
             j = m.end()
             next = rawdata[j:j+1]
@@ -290,8 +338,13 @@
                     # buffer boundary
                     return -1
                 # else bogus input
-                self.updatepos(i, j + 1)
-                self.error("malformed empty start tag")
+                if self.strict:
+                    self.updatepos(i, j + 1)
+                    self.error("malformed empty start tag")
+                if j > i:
+                    return j
+                else:
+                    return i + 1
             if next == "":
                 # end of input
                 return -1
@@ -300,8 +353,13 @@
                 # end of input in or before attribute value, or we have the
                 # '/' from a '/>' ending
                 return -1
-            self.updatepos(i, j)
-            self.error("malformed start tag")
+            if self.strict:
+                self.updatepos(i, j)
+                self.error("malformed start tag")
+            if j > i:
+                return j
+            else:
+                return i + 1
         raise AssertionError("we should not get here!")
 
     # Internal -- parse endtag, return end or -1 if incomplete
@@ -314,7 +372,15 @@
         j = match.end()
         match = endtagfind.match(rawdata, i) # </ + tag + >
         if not match:
-            self.error("bad end tag: %r" % (rawdata[i:j],))
+            if self.strict:
+                self.error("bad end tag: %r" % (rawdata[i:j],))
+            k = rawdata.find('<', i + 1, j)
+            if k > i:
+                j = k
+            if j <= i:
+                j = i + 1
+            self.handle_data(rawdata[i:j])
+            return j
         tag = match.group(1)
         self.handle_endtag(tag.lower())
         self.clear_cdata_mode()
@@ -358,7 +424,8 @@
         pass
 
     def unknown_decl(self, data):
-        self.error("unknown declaration: %r" % (data,))
+        if self.strict:
+            self.error("unknown declaration: %r" % (data,))
 
     # Internal -- helper to remove special character quoting
     entitydefs = None
@@ -367,13 +434,16 @@
             return s
         def replaceEntities(s):
             s = s.groups()[0]
-            if s[0] == "#":
-                s = s[1:]
-                if s[0] in ['x','X']:
-                    c = int(s[1:], 16)
-                else:
-                    c = int(s)
-                return chr(c)
+            try:
+                if s[0] == "#":
+                    s = s[1:]
+                    if s[0] in ['x','X']:
+                        c = int(s[1:], 16)
+                    else:
+                        c = int(s)
+                    return chr(c)
+            except ValueError:
+                return '&#'+ s +';'
             else:
                 # Cannot use name2codepoint directly, because HTMLParser
                 # supports apos, which is not part of HTML 4

Modified: python/branches/py3k-cdecimal/Lib/http/client.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/http/client.py	(original)
+++ python/branches/py3k-cdecimal/Lib/http/client.py	Sun Jan  2 13:18:37 2011
@@ -71,6 +71,7 @@
 import io
 import os
 import socket
+import collections
 from urllib.parse import urlsplit
 import warnings
 
@@ -203,6 +204,9 @@
 # maximal amount of data to read at one time in _safe_read
 MAXAMOUNT = 1048576
 
+# maximal line length when calling readline().
+_MAXLINE = 65536
+
 class HTTPMessage(email.message.Message):
     # XXX The only usage of this method is in
     # http.server.CGIHTTPRequestHandler.  Maybe move the code there so
@@ -245,20 +249,19 @@
     """
     headers = []
     while True:
-        line = fp.readline()
+        line = fp.readline(_MAXLINE + 1)
+        if len(line) > _MAXLINE:
+            raise LineTooLong("header line")
         headers.append(line)
         if line in (b'\r\n', b'\n', b''):
             break
     hstring = b''.join(headers).decode('iso-8859-1')
     return email.parser.Parser(_class=_class).parsestr(hstring)
 
-class HTTPResponse(io.RawIOBase):
 
-    # strict: If true, raise BadStatusLine if the status line can't be
-    # parsed as a valid HTTP/1.0 or 1.1 status line.  By default it is
-    # false because it prevents clients from talking to HTTP/0.9
-    # servers.  Note that a response with a sufficiently corrupted
-    # status line will look like an HTTP/0.9 response.
+_strict_sentinel = object()
+
+class HTTPResponse(io.RawIOBase):
 
     # See RFC 2616 sec 19.6 and RFC 1945 sec 6 for details.
 
@@ -267,7 +270,7 @@
     # text following RFC 2047.  The basic status line parsing only
     # accepts iso-8859-1.
 
-    def __init__(self, sock, debuglevel=0, strict=0, method=None, url=None):
+    def __init__(self, sock, debuglevel=0, strict=_strict_sentinel, method=None, url=None):
         # If the response includes a content-length header, we need to
         # make sure that the client doesn't read more than the
         # specified number of bytes.  If it does, it will block until
@@ -277,7 +280,10 @@
         # clients unless they know what they are doing.
         self.fp = sock.makefile("rb")
         self.debuglevel = debuglevel
-        self.strict = strict
+        if strict is not _strict_sentinel:
+            warnings.warn("the 'strict' argument isn't supported anymore; "
+                "http.client now always assumes HTTP/1.x compliant servers.",
+                DeprecationWarning, 2)
         self._method = method
 
         # The HTTPResponse object is returned via urllib.  The clients
@@ -299,8 +305,9 @@
         self.will_close = _UNKNOWN      # conn will close at end of response
 
     def _read_status(self):
-        # Initialize with Simple-Response defaults.
-        line = str(self.fp.readline(), "iso-8859-1")
+        line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
+        if len(line) > _MAXLINE:
+            raise LineTooLong("status line")
         if self.debuglevel > 0:
             print("reply:", repr(line))
         if not line:
@@ -308,25 +315,17 @@
             # sending a valid response.
             raise BadStatusLine(line)
         try:
-            [version, status, reason] = line.split(None, 2)
+            version, status, reason = line.split(None, 2)
         except ValueError:
             try:
-                [version, status] = line.split(None, 1)
+                version, status = line.split(None, 1)
                 reason = ""
             except ValueError:
-                # empty version will cause next test to fail and status
-                # will be treated as 0.9 response.
+                # empty version will cause next test to fail.
                 version = ""
         if not version.startswith("HTTP/"):
-            if self.strict:
-                self.close()
-                raise BadStatusLine(line)
-            else:
-                # Assume it's a Simple-Response from an 0.9 server.
-                # We have to convert the first line back to raw bytes
-                # because self.fp.readline() needs to return bytes.
-                self.fp = LineAndFileWrapper(bytes(line, "ascii"), self.fp)
-                return "HTTP/0.9", 200, ""
+            self.close()
+            raise BadStatusLine(line)
 
         # The status code is a three-digit number
         try:
@@ -349,7 +348,10 @@
                 break
             # skip the header from the 100 response
             while True:
-                skip = self.fp.readline().strip()
+                skip = self.fp.readline(_MAXLINE + 1)
+                if len(skip) > _MAXLINE:
+                    raise LineTooLong("header line")
+                skip = skip.strip()
                 if not skip:
                     break
                 if self.debuglevel > 0:
@@ -357,22 +359,14 @@
 
         self.code = self.status = status
         self.reason = reason.strip()
-        if version == "HTTP/1.0":
+        if version in ("HTTP/1.0", "HTTP/0.9"):
+            # Some servers might still return "0.9", treat it as 1.0 anyway
             self.version = 10
         elif version.startswith("HTTP/1."):
             self.version = 11   # use HTTP/1.1 code for HTTP/1.x where x>=1
-        elif version == "HTTP/0.9":
-            self.version = 9
         else:
             raise UnknownProtocol(version)
 
-        if self.version == 9:
-            self.length = None
-            self.chunked = False
-            self.will_close = True
-            self.headers = self.msg = email.message_from_string('')
-            return
-
         self.headers = self.msg = parse_headers(self.fp)
 
         if self.debuglevel > 0:
@@ -525,7 +519,9 @@
         value = []
         while True:
             if chunk_left is None:
-                line = self.fp.readline()
+                line = self.fp.readline(_MAXLINE + 1)
+                if len(line) > _MAXLINE:
+                    raise LineTooLong("chunk size")
                 i = line.find(b";")
                 if i >= 0:
                     line = line[:i] # strip chunk-extensions
@@ -560,7 +556,9 @@
         # read and discard trailer up to the CRLF terminator
         ### note: we shouldn't have any trailers!
         while True:
-            line = self.fp.readline()
+            line = self.fp.readline(_MAXLINE + 1)
+            if len(line) > _MAXLINE:
+                raise LineTooLong("trailer line")
             if not line:
                 # a vanishingly small number of sites EOF without
                 # sending the trailer
@@ -639,10 +637,13 @@
     default_port = HTTP_PORT
     auto_open = 1
     debuglevel = 0
-    strict = 0
 
-    def __init__(self, host, port=None, strict=None,
+    def __init__(self, host, port=None, strict=_strict_sentinel,
                  timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None):
+        if strict is not _strict_sentinel:
+            warnings.warn("the 'strict' argument isn't supported anymore; "
+                "http.client now always assumes HTTP/1.x compliant servers.",
+                DeprecationWarning, 2)
         self.timeout = timeout
         self.source_address = source_address
         self.sock = None
@@ -654,8 +655,6 @@
         self._tunnel_port = None
 
         self._set_hostport(host, port)
-        if strict is not None:
-            self.strict = strict
 
     def set_tunnel(self, host, port=None, headers=None):
         """ Sets up the host and the port for the HTTP CONNECT Tunnelling.
@@ -700,8 +699,7 @@
             header_bytes = header_str.encode("ascii")
             self.send(header_bytes)
 
-        response = self.response_class(self.sock, strict = self.strict,
-                                       method = self._method)
+        response = self.response_class(self.sock, method = self._method)
         (version, code, message) = response._read_status()
 
         if code != 200:
@@ -709,7 +707,9 @@
             raise socket.error("Tunnel connection failed: %d %s" % (code,
                                                                     message.strip()))
         while True:
-            line = response.fp.readline()
+            line = response.fp.readline(_MAXLINE + 1)
+            if len(line) > _MAXLINE:
+                raise LineTooLong("header line")
             if line == b'\r\n':
                 break
 
@@ -731,7 +731,11 @@
         self.__state = _CS_IDLE
 
     def send(self, data):
-        """Send `data' to the server."""
+        """Send `data' to the server.
+        ``data`` can be a string object, a bytes object, an array object, a
+        file-like object that supports a .read() method, or an iterable object.
+        """
+
         if self.sock is None:
             if self.auto_open:
                 self.connect()
@@ -763,8 +767,16 @@
                 if encode:
                     datablock = datablock.encode("iso-8859-1")
                 self.sock.sendall(datablock)
-        else:
+
+        try:
             self.sock.sendall(data)
+        except TypeError:
+            if isinstance(data, collections.Iterable):
+                for d in data:
+                    self.sock.sendall(d)
+            else:
+                raise TypeError("data should be a bytes-like object\
+                        or an iterable, got %r " % type(it))
 
     def _output(self, s):
         """Add a line of output to the current request buffer.
@@ -1025,11 +1037,9 @@
 
         if self.debuglevel > 0:
             response = self.response_class(self.sock, self.debuglevel,
-                                           strict=self.strict,
                                            method=self._method)
         else:
-            response = self.response_class(self.sock, strict=self.strict,
-                                           method=self._method)
+            response = self.response_class(self.sock, method=self._method)
 
         response.begin()
         assert response.will_close != _UNKNOWN
@@ -1057,7 +1067,7 @@
         # XXX Should key_file and cert_file be deprecated in favour of context?
 
         def __init__(self, host, port=None, key_file=None, cert_file=None,
-                     strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
+                     strict=_strict_sentinel, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                      source_address=None, *, context=None, check_hostname=None):
             super(HTTPSConnection, self).__init__(host, port, strict, timeout,
                                                   source_address)
@@ -1156,73 +1166,10 @@
         self.args = line,
         self.line = line
 
+class LineTooLong(HTTPException):
+    def __init__(self, line_type):
+        HTTPException.__init__(self, "got more than %d bytes when reading %s"
+                                     % (_MAXLINE, line_type))
+
 # for backwards compatibility
 error = HTTPException
-
-class LineAndFileWrapper:
-    """A limited file-like object for HTTP/0.9 responses."""
-
-    # The status-line parsing code calls readline(), which normally
-    # get the HTTP status line.  For a 0.9 response, however, this is
-    # actually the first line of the body!  Clients need to get a
-    # readable file object that contains that line.
-
-    def __init__(self, line, file):
-        self._line = line
-        self._file = file
-        self._line_consumed = 0
-        self._line_offset = 0
-        self._line_left = len(line)
-
-    def __getattr__(self, attr):
-        return getattr(self._file, attr)
-
-    def _done(self):
-        # called when the last byte is read from the line.  After the
-        # call, all read methods are delegated to the underlying file
-        # object.
-        self._line_consumed = 1
-        self.read = self._file.read
-        self.readline = self._file.readline
-        self.readlines = self._file.readlines
-
-    def read(self, amt=None):
-        if self._line_consumed:
-            return self._file.read(amt)
-        assert self._line_left
-        if amt is None or amt > self._line_left:
-            s = self._line[self._line_offset:]
-            self._done()
-            if amt is None:
-                return s + self._file.read()
-            else:
-                return s + self._file.read(amt - len(s))
-        else:
-            assert amt <= self._line_left
-            i = self._line_offset
-            j = i + amt
-            s = self._line[i:j]
-            self._line_offset = j
-            self._line_left -= amt
-            if self._line_left == 0:
-                self._done()
-            return s
-
-    def readline(self):
-        if self._line_consumed:
-            return self._file.readline()
-        assert self._line_left
-        s = self._line[self._line_offset:]
-        self._done()
-        return s
-
-    def readlines(self, size=None):
-        if self._line_consumed:
-            return self._file.readlines(size)
-        assert self._line_left
-        L = [self._line[self._line_offset:]]
-        self._done()
-        if size is None:
-            return L + self._file.readlines()
-        else:
-            return L + self._file.readlines(size)

Modified: python/branches/py3k-cdecimal/Lib/http/cookies.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/http/cookies.py	(original)
+++ python/branches/py3k-cdecimal/Lib/http/cookies.py	Sun Jan  2 13:18:37 2011
@@ -173,6 +173,11 @@
     '\033' : '\\033',  '\034' : '\\034',  '\035' : '\\035',
     '\036' : '\\036',  '\037' : '\\037',
 
+    # Because of the way browsers really handle cookies (as opposed
+    # to what the RFC says) we also encode , and ;
+
+    ',' : '\\054', ';' : '\\073',
+
     '"' : '\\"',       '\\' : '\\\\',
 
     '\177' : '\\177',  '\200' : '\\200',  '\201' : '\\201',
@@ -230,7 +235,7 @@
     if all(c in LegalChars for c in str):
         return str
     else:
-        return '"' + _nulljoin(map(_Translator.get, str, str)) + '"'
+        return '"' + _nulljoin(_Translator.get(s, s) for s in str) + '"'
 
 
 _OctalPatt = re.compile(r"\\[0-3][0-7][0-7]")

Modified: python/branches/py3k-cdecimal/Lib/http/server.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/http/server.py	(original)
+++ python/branches/py3k-cdecimal/Lib/http/server.py	Sun Jan  2 13:18:37 2011
@@ -314,8 +314,12 @@
         self.command, self.path, self.request_version = command, path, version
 
         # Examine the headers and look for a Connection directive.
-        self.headers = http.client.parse_headers(self.rfile,
-                                                 _class=self.MessageClass)
+        try:
+            self.headers = http.client.parse_headers(self.rfile,
+                                                     _class=self.MessageClass)
+        except http.client.LineTooLong:
+            self.send_error(400, "Line too long")
+            return False
 
         conntype = self.headers.get('Connection', "")
         if conntype.lower() == 'close':
@@ -358,7 +362,13 @@
 
         """
         try:
-            self.raw_requestline = self.rfile.readline()
+            self.raw_requestline = self.rfile.readline(65537)
+            if len(self.raw_requestline) > 65536:
+                self.requestline = ''
+                self.request_version = ''
+                self.command = ''
+                self.send_error(414)
+                return
             if not self.raw_requestline:
                 self.close_connection = 1
                 return
@@ -868,7 +878,7 @@
     try:
         nobody = pwd.getpwnam('nobody')[2]
     except KeyError:
-        nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
+        nobody = 1 + max(x[2] for x in pwd.getpwall())
     return nobody
 
 

Modified: python/branches/py3k-cdecimal/Lib/idlelib/Bindings.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/idlelib/Bindings.py	(original)
+++ python/branches/py3k-cdecimal/Lib/idlelib/Bindings.py	Sun Jan  2 13:18:37 2011
@@ -98,14 +98,6 @@
     # menu
     del menudefs[-1][1][0:2]
 
-    menudefs.insert(0,
-            ('application', [
-                ('About IDLE', '<<about-idle>>'),
-                None,
-                ('_Preferences....', '<<open-config-dialog>>'),
-            ]))
-
-
 default_keydefs = idleConf.GetCurrentKeySet()
 
 del sys

Modified: python/branches/py3k-cdecimal/Lib/idlelib/EditorWindow.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/idlelib/EditorWindow.py	(original)
+++ python/branches/py3k-cdecimal/Lib/idlelib/EditorWindow.py	Sun Jan  2 13:18:37 2011
@@ -138,6 +138,14 @@
         if macosxSupport.runningAsOSXApp():
             # Command-W on editorwindows doesn't work without this.
             text.bind('<<close-window>>', self.close_event)
+            # Some OS X systems have only one mouse button,
+            # so use control-click for pulldown menus there.
+            #  (Note, AquaTk defines <2> as the right button if
+            #   present and the Tk Text widget already binds <2>.)
+            text.bind("<Control-Button-1>",self.right_menu_event)
+        else:
+            # Elsewhere, use right-click for pulldown menus.
+            text.bind("<3>",self.right_menu_event)
         text.bind("<<cut>>", self.cut)
         text.bind("<<copy>>", self.copy)
         text.bind("<<paste>>", self.paste)
@@ -156,7 +164,6 @@
         text.bind("<<find-selection>>", self.find_selection_event)
         text.bind("<<replace>>", self.replace_event)
         text.bind("<<goto-line>>", self.goto_line_event)
-        text.bind("<3>", self.right_menu_event)
         text.bind("<<smart-backspace>>",self.smart_backspace_event)
         text.bind("<<newline-and-indent>>",self.newline_and_indent_event)
         text.bind("<<smart-indent>>",self.smart_indent_event)
@@ -380,7 +387,7 @@
             underline, label = prepstr(label)
             menudict[name] = menu = Menu(mbar, name=name)
             mbar.add_cascade(label=label, menu=menu, underline=underline)
-        if macosxSupport.runningAsOSXApp():
+        if macosxSupport.isCarbonAquaTk(self.root):
             # Insert the application menu
             menudict['application'] = menu = Menu(mbar, name='apple')
             mbar.add_cascade(label='IDLE', menu=menu)
@@ -443,7 +450,11 @@
 
     def python_docs(self, event=None):
         if sys.platform[:3] == 'win':
-            os.startfile(self.help_url)
+            try:
+                os.startfile(self.help_url)
+            except WindowsError as why:
+                tkMessageBox.showerror(title='Document Start Failure',
+                    message=str(why), parent=self.text)
         else:
             webbrowser.open(self.help_url)
         return "break"
@@ -746,9 +757,13 @@
         "Create a callback with the helpfile value frozen at definition time"
         def display_extra_help(helpfile=helpfile):
             if not helpfile.startswith(('www', 'http')):
-                url = os.path.normpath(helpfile)
+                helpfile = os.path.normpath(helpfile)
             if sys.platform[:3] == 'win':
-                os.startfile(helpfile)
+                try:
+                    os.startfile(helpfile)
+                except WindowsError as why:
+                    tkMessageBox.showerror(title='Document Start Failure',
+                        message=str(why), parent=self.text)
             else:
                 webbrowser.open(helpfile)
         return display_extra_help

Modified: python/branches/py3k-cdecimal/Lib/idlelib/FileList.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/idlelib/FileList.py	(original)
+++ python/branches/py3k-cdecimal/Lib/idlelib/FileList.py	Sun Jan  2 13:18:37 2011
@@ -48,7 +48,7 @@
     def new(self, filename=None):
         return self.EditorWindow(self, filename)
 
-    def close_all_callback(self, event):
+    def close_all_callback(self, *args, **kwds):
         for edit in list(self.inversedict):
             reply = edit.close()
             if reply == "cancel":

Modified: python/branches/py3k-cdecimal/Lib/idlelib/IOBinding.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/idlelib/IOBinding.py	(original)
+++ python/branches/py3k-cdecimal/Lib/idlelib/IOBinding.py	Sun Jan  2 13:18:37 2011
@@ -476,8 +476,8 @@
     savedialog = None
 
     filetypes = [
-        ("Python and text files", "*.py *.pyw *.txt", "TEXT"),
-        ("All text files", "*", "TEXT"),
+        ("Python files", "*.py *.pyw", "TEXT"),
+        ("Text files", "*.txt", "TEXT"),
         ("All files", "*"),
         ]
 

Modified: python/branches/py3k-cdecimal/Lib/idlelib/idlever.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/idlelib/idlever.py	(original)
+++ python/branches/py3k-cdecimal/Lib/idlelib/idlever.py	Sun Jan  2 13:18:37 2011
@@ -1 +1 @@
-IDLE_VERSION = "3.2a4"
+IDLE_VERSION = "3.2b2"

Modified: python/branches/py3k-cdecimal/Lib/idlelib/macosxSupport.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/idlelib/macosxSupport.py	(original)
+++ python/branches/py3k-cdecimal/Lib/idlelib/macosxSupport.py	Sun Jan  2 13:18:37 2011
@@ -4,6 +4,7 @@
 """
 import sys
 import tkinter
+from os import path
 
 
 _appbundle = None
@@ -19,6 +20,20 @@
         _appbundle = (sys.platform == 'darwin' and '.app' in sys.executable)
     return _appbundle
 
+_carbonaquatk = None
+
+def isCarbonAquaTk(root):
+    """
+    Returns True if IDLE is using a Carbon Aqua Tk (instead of the
+    newer Cocoa Aqua Tk).
+    """
+    global _carbonaquatk
+    if _carbonaquatk is None:
+        _carbonaquatk = (runningAsOSXApp() and
+                         'aqua' in root.tk.call('tk', 'windowingsystem') and
+                         'AppKit' not in root.tk.call('winfo', 'server', '.'))
+    return _carbonaquatk
+
 def addOpenEventSupport(root, flist):
     """
     This ensures that the application will respont to open AppleEvents, which
@@ -79,9 +94,6 @@
         WindowList.add_windows_to_menu(menu)
     WindowList.register_callback(postwindowsmenu)
 
-    menudict['application'] = menu = Menu(menubar, name='apple')
-    menubar.add_cascade(label='IDLE', menu=menu)
-
     def about_dialog(event=None):
         from idlelib import aboutDialog
         aboutDialog.AboutDialog(root, 'About IDLE')
@@ -97,41 +109,45 @@
         root.instance_dict = flist.inversedict
         configDialog.ConfigDialog(root, 'Settings')
 
+    def help_dialog(event=None):
+        from idlelib import textView
+        fn = path.join(path.abspath(path.dirname(__file__)), 'help.txt')
+        textView.view_file(root, 'Help', fn)
 
     root.bind('<<about-idle>>', about_dialog)
     root.bind('<<open-config-dialog>>', config_dialog)
+    root.createcommand('::tk::mac::ShowPreferences', config_dialog)
     if flist:
         root.bind('<<close-all-windows>>', flist.close_all_callback)
 
-
-    ###check if Tk version >= 8.4.14; if so, use hard-coded showprefs binding
-    tkversion = root.tk.eval('info patchlevel')
-    # Note: we cannot check if the string tkversion >= '8.4.14', because
-    # the string '8.4.7' is greater than the string '8.4.14'.
-    if tuple(map(int, tkversion.split('.'))) >= (8, 4, 14):
-        Bindings.menudefs[0] =  ('application', [
+        # The binding above doesn't reliably work on all versions of Tk
+        # on MacOSX. Adding command definition below does seem to do the
+        # right thing for now.
+        root.createcommand('exit', flist.close_all_callback)
+
+    if isCarbonAquaTk(root):
+        # for Carbon AquaTk, replace the default Tk apple menu
+        menudict['application'] = menu = Menu(menubar, name='apple')
+        menubar.add_cascade(label='IDLE', menu=menu)
+        Bindings.menudefs.insert(0,
+            ('application', [
                 ('About IDLE', '<<about-idle>>'),
-                None,
-            ])
-        root.createcommand('::tk::mac::ShowPreferences', config_dialog)
+                    None,
+                ]))
+        tkversion = root.tk.eval('info patchlevel')
+        if tuple(map(int, tkversion.split('.'))) < (8, 4, 14):
+            # for earlier AquaTk versions, supply a Preferences menu item
+            Bindings.menudefs[0][1].append(
+                    ('_Preferences....', '<<open-config-dialog>>'),
+                )
     else:
-        for mname, entrylist in Bindings.menudefs:
-            menu = menudict.get(mname)
-            if not menu:
-                continue
-            else:
-                for entry in entrylist:
-                    if not entry:
-                        menu.add_separator()
-                    else:
-                        label, eventname = entry
-                        underline, label = prepstr(label)
-                        accelerator = get_accelerator(Bindings.default_keydefs,
-                        eventname)
-                        def command(text=root, eventname=eventname):
-                            text.event_generate(eventname)
-                        menu.add_command(label=label, underline=underline,
-                        command=command, accelerator=accelerator)
+        # assume Cocoa AquaTk
+        # replace default About dialog with About IDLE one
+        root.createcommand('tkAboutDialog', about_dialog)
+        # replace default "Help" item in Help menu
+        root.createcommand('::tk::mac::ShowHelp', help_dialog)
+        # remove redundant "IDLE Help" from menu
+        del Bindings.menudefs[-1][1][0]
 
 def setupApp(root, flist):
     """

Modified: python/branches/py3k-cdecimal/Lib/inspect.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/inspect.py	(original)
+++ python/branches/py3k-cdecimal/Lib/inspect.py	Sun Jan  2 13:18:37 2011
@@ -1130,7 +1130,10 @@
     raise AttributeError(attr)
 
 
-GEN_CREATED, GEN_RUNNING, GEN_SUSPENDED, GEN_CLOSED = range(4)
+GEN_CREATED = 'GEN_CREATED'
+GEN_RUNNING = 'GEN_RUNNING'
+GEN_SUSPENDED = 'GEN_SUSPENDED'
+GEN_CLOSED = 'GEN_CLOSED'
 
 def getgeneratorstate(generator):
     """Get current state of a generator-iterator.

Modified: python/branches/py3k-cdecimal/Lib/lib2to3/fixes/fix_urllib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/lib2to3/fixes/fix_urllib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/lib2to3/fixes/fix_urllib.py	Sun Jan  2 13:18:37 2011
@@ -12,7 +12,7 @@
 
 MAPPING = {"urllib":  [
                 ("urllib.request",
-                    ["URLOpener", "FancyURLOpener", "urlretrieve",
+                    ["URLopener", "FancyURLopener", "urlretrieve",
                      "_urlopener", "urlopen", "urlcleanup",
                      "pathname2url", "url2pathname"]),
                 ("urllib.parse",

Modified: python/branches/py3k-cdecimal/Lib/lib2to3/main.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/lib2to3/main.py	(original)
+++ python/branches/py3k-cdecimal/Lib/lib2to3/main.py	Sun Jan  2 13:18:37 2011
@@ -100,7 +100,7 @@
     parser.add_option("-j", "--processes", action="store", default=1,
                       type="int", help="Run 2to3 concurrently")
     parser.add_option("-x", "--nofix", action="append", default=[],
-                      help="Prevent a fixer from being run.")
+                      help="Prevent a transformation from being run")
     parser.add_option("-l", "--list-fixes", action="store_true",
                       help="List available transformations")
     parser.add_option("-p", "--print-function", action="store_true",
@@ -112,7 +112,7 @@
     parser.add_option("-w", "--write", action="store_true",
                       help="Write back modified files")
     parser.add_option("-n", "--nobackups", action="store_true", default=False,
-                      help="Don't write backups for modified files.")
+                      help="Don't write backups for modified files")
 
     # Parse command line arguments
     refactor_stdin = False

Modified: python/branches/py3k-cdecimal/Lib/lib2to3/refactor.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/lib2to3/refactor.py	(original)
+++ python/branches/py3k-cdecimal/Lib/lib2to3/refactor.py	Sun Jan  2 13:18:37 2011
@@ -302,13 +302,14 @@
 
         Files and subdirectories starting with '.' are skipped.
         """
+        py_ext = os.extsep + "py"
         for dirpath, dirnames, filenames in os.walk(dir_name):
             self.log_debug("Descending into %s", dirpath)
             dirnames.sort()
             filenames.sort()
             for name in filenames:
-                if not name.startswith(".") and \
-                        os.path.splitext(name)[1].endswith("py"):
+                if (not name.startswith(".") and
+                    os.path.splitext(name)[1] == py_ext):
                     fullname = os.path.join(dirpath, name)
                     self.refactor_file(fullname, write, doctests_only)
             # Modify dirnames in-place to remove subdirs with leading dots

Modified: python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_refactor.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_refactor.py	(original)
+++ python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_refactor.py	Sun Jan  2 13:18:37 2011
@@ -223,6 +223,7 @@
                 "hi.py",
                 ".dumb",
                 ".after.py",
+                "notpy.npy",
                 "sappy"]
         expected = ["hi.py"]
         check(tree, expected)

Modified: python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_util.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_util.py	(original)
+++ python/branches/py3k-cdecimal/Lib/lib2to3/tests/test_util.py	Sun Jan  2 13:18:37 2011
@@ -568,8 +568,8 @@
 
     def test_from_import(self):
         node = parse('bar()')
-        fixer_util.touch_import("cgi", "escape", node)
-        self.assertEqual(str(node), 'from cgi import escape\nbar()\n\n')
+        fixer_util.touch_import("html", "escape", node)
+        self.assertEqual(str(node), 'from html import escape\nbar()\n\n')
 
     def test_name_import(self):
         node = parse('bar()')

Modified: python/branches/py3k-cdecimal/Lib/logging/__init__.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/logging/__init__.py	(original)
+++ python/branches/py3k-cdecimal/Lib/logging/__init__.py	Sun Jan  2 13:18:37 2011
@@ -33,7 +33,7 @@
            'captureWarnings', 'critical', 'debug', 'disable', 'error',
            'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
            'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning',
-           'getLogRecordClass', 'setLogRecordClass']
+           'getLogRecordFactory', 'setLogRecordFactory', 'lastResort']
 
 try:
     import codecs
@@ -238,7 +238,7 @@
     information to be logged.
     """
     def __init__(self, name, level, pathname, lineno,
-                 msg, args, exc_info, func=None, sinfo=None):
+                 msg, args, exc_info, func=None, sinfo=None, **kwargs):
         """
         Initialize a logging record with interesting information.
         """
@@ -322,21 +322,24 @@
 #
 #   Determine which class to use when instantiating log records.
 #
-_logRecordClass = LogRecord
+_logRecordFactory = LogRecord
 
-def setLogRecordClass(cls):
+def setLogRecordFactory(factory):
     """
-    Set the class to be used when instantiating a log record.
+    Set the factory to be used when instantiating a log record.
+
+    :param factory: A callable which will be called to instantiate
+    a log record.
     """
-    global _logRecordClass
-    _logRecordClass = cls
+    global _logRecordFactory
+    _logRecordFactory = factory
 
-def getLogRecordClass():
+def getLogRecordFactory():
     """
-    Return the class to be used when instantiating a log record.
+    Return the factory to be used when instantiating a log record.
     """
 
-    return _logRecordClass
+    return _logRecordFactory
 
 def makeLogRecord(dict):
     """
@@ -345,7 +348,7 @@
     a socket connection (which is sent as a dictionary) into a LogRecord
     instance.
     """
-    rv = _logRecordClass(None, None, "", 0, "", (), None, None)
+    rv = _logRecordFactory(None, None, "", 0, "", (), None, None)
     rv.__dict__.update(dict)
     return rv
 
@@ -994,6 +997,26 @@
             self.stream = self._open()
         StreamHandler.emit(self, record)
 
+class _StderrHandler(StreamHandler):
+    """
+    This class is like a StreamHandler using sys.stderr, but always uses
+    whatever sys.stderr is currently set to rather than the value of
+    sys.stderr at handler construction time.
+    """
+    def __init__(self, level=NOTSET):
+        """
+        Initialize the handler.
+        """
+        Handler.__init__(self, level)
+
+    @property
+    def stream(self):
+        return sys.stderr
+
+
+_defaultLastResort = _StderrHandler(WARNING)
+lastResort = _defaultLastResort
+
 #---------------------------------------------------------------------------
 #   Manager classes and functions
 #---------------------------------------------------------------------------
@@ -1053,10 +1076,10 @@
         """
         self.root = rootnode
         self.disable = 0
-        self.emittedNoHandlerWarning = 0
+        self.emittedNoHandlerWarning = False
         self.loggerDict = {}
         self.loggerClass = None
-        self.logRecordClass = None
+        self.logRecordFactory = None
 
     def getLogger(self, name):
         """
@@ -1100,12 +1123,12 @@
                                 + klass.__name__)
         self.loggerClass = klass
 
-    def setLogRecordClass(self, cls):
+    def setLogRecordFactory(self, factory):
         """
-        Set the class to be used when instantiating a log record with this
+        Set the factory to be used when instantiating a log record with this
         Manager.
         """
-        self.logRecordClass = cls
+        self.logRecordFactory = factory
 
     def _fixupParents(self, alogger):
         """
@@ -1305,7 +1328,7 @@
         A factory method which can be overridden in subclasses to create
         specialized LogRecords.
         """
-        rv = _logRecordClass(name, level, fn, lno, msg, args, exc_info, func,
+        rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
                              sinfo)
         if extra is not None:
             for key in extra:
@@ -1412,10 +1435,13 @@
                 c = None    #break out
             else:
                 c = c.parent
-        if (found == 0) and raiseExceptions and not self.manager.emittedNoHandlerWarning:
-            sys.stderr.write("No handlers could be found for logger"
-                             " \"%s\"\n" % self.name)
-            self.manager.emittedNoHandlerWarning = 1
+        if (found == 0):
+            if lastResort:
+                lastResort.handle(record)
+            elif raiseExceptions and not self.manager.emittedNoHandlerWarning:
+                sys.stderr.write("No handlers could be found for logger"
+                                 " \"%s\"\n" % self.name)
+                self.manager.emittedNoHandlerWarning = True
 
     def getEffectiveLevel(self):
         """
@@ -1673,7 +1699,9 @@
 
 def critical(msg, *args, **kwargs):
     """
-    Log a message with severity 'CRITICAL' on the root logger.
+    Log a message with severity 'CRITICAL' on the root logger. If the logger
+    has no handlers, call basicConfig() to add a console handler with a
+    pre-defined format.
     """
     if len(root.handlers) == 0:
         basicConfig()
@@ -1683,7 +1711,9 @@
 
 def error(msg, *args, **kwargs):
     """
-    Log a message with severity 'ERROR' on the root logger.
+    Log a message with severity 'ERROR' on the root logger. If the logger has
+    no handlers, call basicConfig() to add a console handler with a pre-defined
+    format.
     """
     if len(root.handlers) == 0:
         basicConfig()
@@ -1691,15 +1721,18 @@
 
 def exception(msg, *args, **kwargs):
     """
-    Log a message with severity 'ERROR' on the root logger,
-    with exception information.
+    Log a message with severity 'ERROR' on the root logger, with exception
+    information. If the logger has no handlers, basicConfig() is called to add
+    a console handler with a pre-defined format.
     """
     kwargs['exc_info'] = True
     error(msg, *args, **kwargs)
 
 def warning(msg, *args, **kwargs):
     """
-    Log a message with severity 'WARNING' on the root logger.
+    Log a message with severity 'WARNING' on the root logger. If the logger has
+    no handlers, call basicConfig() to add a console handler with a pre-defined
+    format.
     """
     if len(root.handlers) == 0:
         basicConfig()
@@ -1709,7 +1742,9 @@
 
 def info(msg, *args, **kwargs):
     """
-    Log a message with severity 'INFO' on the root logger.
+    Log a message with severity 'INFO' on the root logger. If the logger has
+    no handlers, call basicConfig() to add a console handler with a pre-defined
+    format.
     """
     if len(root.handlers) == 0:
         basicConfig()
@@ -1717,7 +1752,9 @@
 
 def debug(msg, *args, **kwargs):
     """
-    Log a message with severity 'DEBUG' on the root logger.
+    Log a message with severity 'DEBUG' on the root logger. If the logger has
+    no handlers, call basicConfig() to add a console handler with a pre-defined
+    format.
     """
     if len(root.handlers) == 0:
         basicConfig()
@@ -1725,7 +1762,9 @@
 
 def log(level, msg, *args, **kwargs):
     """
-    Log 'msg % args' with the integer severity 'level' on the root logger.
+    Log 'msg % args' with the integer severity 'level' on the root logger. If
+    the logger has no handlers, call basicConfig() to add a console handler
+    with a pre-defined format.
     """
     if len(root.handlers) == 0:
         basicConfig()

Modified: python/branches/py3k-cdecimal/Lib/mimetypes.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/mimetypes.py	(original)
+++ python/branches/py3k-cdecimal/Lib/mimetypes.py	Sun Jan  2 13:18:37 2011
@@ -374,6 +374,7 @@
     global common_types
 
     suffix_map = {
+        '.svgz': '.svg.gz',
         '.tgz': '.tar.gz',
         '.taz': '.tar.gz',
         '.tz': '.tar.gz',
@@ -387,7 +388,7 @@
         }
 
     # Before adding new types, make sure they are either registered with IANA,
-    # at http://www.isi.edu/in-notes/iana/assignments/media-types
+    # at http://www.iana.org/assignments/media-types
     # or extensions, i.e. using the x- prefix
 
     # If you add to these, please keep them sorted!
@@ -488,6 +489,7 @@
         '.src'    : 'application/x-wais-source',
         '.sv4cpio': 'application/x-sv4cpio',
         '.sv4crc' : 'application/x-sv4crc',
+        '.svg'    : 'image/svg+xml',
         '.swf'    : 'application/x-shockwave-flash',
         '.t'      : 'application/x-troff',
         '.tar'    : 'application/x-tar',

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/__init__.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/__init__.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/__init__.py	Sun Jan  2 13:18:37 2011
@@ -38,6 +38,7 @@
 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __version__ = '0.70a1'

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/connection.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/connection.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/connection.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/connection.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __all__ = [ 'Client', 'Listener', 'Pipe' ]

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/dummy/__init__.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/dummy/__init__.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/dummy/__init__.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/dummy/__init__.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __all__ = [

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/dummy/connection.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/dummy/connection.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/dummy/connection.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/dummy/connection.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __all__ = [ 'Client', 'Listener', 'Pipe' ]

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/forking.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/forking.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/forking.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/forking.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 import os

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/heap.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/heap.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/heap.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/heap.py
 #
-# Copyright (c) 2007-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 import bisect

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/managers.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/managers.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/managers.py	Sun Jan  2 13:18:37 2011
@@ -4,7 +4,33 @@
 #
 # multiprocessing/managers.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __all__ = [ 'BaseManager', 'SyncManager', 'BaseProxy', 'Token' ]

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/pool.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/pool.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/pool.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/pool.py
 #
-# Copyright (c) 2007-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __all__ = ['Pool']

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/process.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/process.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/process.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/process.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __all__ = ['Process', 'current_process', 'active_children']

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/queues.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/queues.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/queues.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/queues.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __all__ = ['Queue', 'SimpleQueue', 'JoinableQueue']

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/reduction.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/reduction.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/reduction.py	Sun Jan  2 13:18:37 2011
@@ -4,7 +4,33 @@
 #
 # multiprocessing/reduction.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __all__ = []

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/sharedctypes.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/sharedctypes.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/sharedctypes.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/sharedctypes.py
 #
-# Copyright (c) 2007-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 import sys

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/synchronize.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/synchronize.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/synchronize.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/synchronize.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 __all__ = [

Modified: python/branches/py3k-cdecimal/Lib/multiprocessing/util.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/multiprocessing/util.py	(original)
+++ python/branches/py3k-cdecimal/Lib/multiprocessing/util.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,33 @@
 #
 # multiprocessing/util.py
 #
-# Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of author nor the names of any contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
 #
 
 import itertools

Modified: python/branches/py3k-cdecimal/Lib/netrc.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/netrc.py	(original)
+++ python/branches/py3k-cdecimal/Lib/netrc.py	Sun Jan  2 13:18:37 2011
@@ -34,11 +34,15 @@
     def _parse(self, file, fp):
         lexer = shlex.shlex(fp)
         lexer.wordchars += r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
+        lexer.commenters = lexer.commenters.replace('#', '')
         while 1:
             # Look for a machine, default, or macdef top-level keyword
             toplevel = tt = lexer.get_token()
             if not tt:
                 break
+            elif tt[0] == '#':
+                fp.readline();
+                continue;
             elif tt == 'machine':
                 entryname = lexer.get_token()
             elif tt == 'default':

Modified: python/branches/py3k-cdecimal/Lib/numbers.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/numbers.py	(original)
+++ python/branches/py3k-cdecimal/Lib/numbers.py	Sun Jan  2 13:18:37 2011
@@ -60,7 +60,7 @@
 
     @abstractproperty
     def imag(self):
-        """Retrieve the real component of this number.
+        """Retrieve the imaginary component of this number.
 
         This should subclass Real.
         """
@@ -303,7 +303,7 @@
         raise NotImplementedError
 
     def __index__(self):
-        """index(self)"""
+        """someobject[self]"""
         return int(self)
 
     @abstractmethod

Modified: python/branches/py3k-cdecimal/Lib/os.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/os.py	(original)
+++ python/branches/py3k-cdecimal/Lib/os.py	Sun Jan  2 13:18:37 2011
@@ -114,18 +114,26 @@
 SEEK_CUR = 1
 SEEK_END = 2
 
+
+def _get_masked_mode(mode):
+    mask = umask(0)
+    umask(mask)
+    return mode & ~mask
+
 #'
 
 # Super directory utilities.
 # (Inspired by Eric Raymond; the doc strings are mostly his)
 
-def makedirs(name, mode=0o777):
-    """makedirs(path [, mode=0o777])
+def makedirs(name, mode=0o777, exist_ok=False):
+    """makedirs(path [, mode=0o777][, exist_ok=False])
 
     Super-mkdir; create a leaf directory and all intermediate ones.
     Works like mkdir, except that any intermediate path segment (not
-    just the rightmost) will be created if it does not exist.  This is
-    recursive.
+    just the rightmost) will be created if it does not exist. If the
+    target directory with the same mode as we specified already exists,
+    raises an OSError if exist_ok is False, otherwise no exception is
+    raised.  This is recursive.
 
     """
     head, tail = path.split(name)
@@ -133,14 +141,20 @@
         head, tail = path.split(head)
     if head and tail and not path.exists(head):
         try:
-            makedirs(head, mode)
+            makedirs(head, mode, exist_ok)
         except OSError as e:
             # be happy if someone already created the path
             if e.errno != errno.EEXIST:
                 raise
         if tail == curdir:           # xxx/newdir/. exists if xxx/newdir exists
             return
-    mkdir(name, mode)
+    try:
+        mkdir(name, mode)
+    except OSError as e:
+        import stat as st
+        if not (e.errno == errno.EEXIST and exist_ok and path.isdir(name) and
+                st.S_IMODE(lstat(name).st_mode) == _get_masked_mode(mode)):
+            raise
 
 def removedirs(name):
     """removedirs(path)

Modified: python/branches/py3k-cdecimal/Lib/pdb.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/pdb.py	(original)
+++ python/branches/py3k-cdecimal/Lib/pdb.py	Sun Jan  2 13:18:37 2011
@@ -66,16 +66,18 @@
 # NOTE: the actual command documentation is collected from docstrings of the
 # commands and is appended to __doc__ after the class has been defined.
 
+import os
+import re
 import sys
-import linecache
 import cmd
 import bdb
 import dis
-import os
-import re
+import code
 import pprint
-import traceback
+import signal
 import inspect
+import traceback
+import linecache
 
 
 class Restart(Exception):
@@ -94,14 +96,14 @@
     # consumer of this info expects the first line to be 1
     lineno = 1
     answer = None
-    while 1:
+    while True:
         line = fp.readline()
         if line == '':
             break
         if cre.match(line):
             answer = funcname, filename, lineno
             break
-        lineno = lineno + 1
+        lineno += 1
     fp.close()
     return answer
 
@@ -123,6 +125,12 @@
     return 0
 
 
+class _rstr(str):
+    """String that doesn't quote its repr."""
+    def __repr__(self):
+        return self
+
+
 # Interaction prompt line will separate file and call info from code
 # text using value of line_prefix string.  A newline and arrow may
 # be to your liking.  You can set it once pdb is imported using the
@@ -132,21 +140,25 @@
 
 class Pdb(bdb.Bdb, cmd.Cmd):
 
-    def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None):
+    def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
+                 nosigint=False):
         bdb.Bdb.__init__(self, skip=skip)
         cmd.Cmd.__init__(self, completekey, stdin, stdout)
         if stdout:
             self.use_rawinput = 0
         self.prompt = '(Pdb) '
         self.aliases = {}
+        self.displaying = {}
         self.mainpyfile = ''
-        self._wait_for_mainpyfile = 0
+        self._wait_for_mainpyfile = False
         self.tb_lineno = {}
         # Try to load readline if it exists
         try:
             import readline
         except ImportError:
             pass
+        self.allow_kbdint = False
+        self.nosigint = nosigint
 
         # Read $HOME/.pdbrc and ./.pdbrc
         self.rcLines = []
@@ -173,6 +185,15 @@
         self.commands_bnum = None # The breakpoint number for which we are
                                   # defining a list
 
+    def sigint_handler(self, signum, frame):
+        if self.allow_kbdint:
+            raise KeyboardInterrupt
+        self.message("\nProgram interrupted. (Use 'cont' to resume).")
+        self.set_step()
+        self.set_trace(frame)
+        # restore previous signal handler
+        signal.signal(signal.SIGINT, self._previous_sigint_handler)
+
     def reset(self):
         bdb.Bdb.reset(self)
         self.forget()
@@ -235,9 +256,9 @@
         """This function is called when we stop or break at this line."""
         if self._wait_for_mainpyfile:
             if (self.mainpyfile != self.canonic(frame.f_code.co_filename)
-                or frame.f_lineno<= 0):
+                or frame.f_lineno <= 0):
                 return
-            self._wait_for_mainpyfile = 0
+            self._wait_for_mainpyfile = False
         if self.bp_commands(frame):
             self.interaction(frame, None)
 
@@ -260,7 +281,7 @@
             if not self.commands_silent[currentbp]:
                 self.print_stack_entry(self.stack[self.curindex])
             if self.commands_doprompt[currentbp]:
-                self.cmdloop()
+                self._cmdloop()
             self.forget()
             return
         return 1
@@ -285,6 +306,31 @@
         self.interaction(frame, exc_traceback)
 
     # General interaction function
+    def _cmdloop(self):
+        while True:
+            try:
+                # keyboard interrupts allow for an easy way to cancel
+                # the current command, so allow them during interactive input
+                self.allow_kbdint = True
+                self.cmdloop()
+                self.allow_kbdint = False
+                break
+            except KeyboardInterrupt:
+                self.message('--KeyboardInterrupt--')
+
+    # Called before loop, handles display expressions
+    def preloop(self):
+        displaying = self.displaying.get(self.curframe)
+        if displaying:
+            for expr, oldvalue in displaying.items():
+                newvalue = self._getval_except(expr)
+                # check for identity first; this prevents custom __eq__ to
+                # be called at every loop, and also prevents instances whose
+                # fields are changed to be displayed
+                if newvalue is not oldvalue and newvalue != oldvalue:
+                    displaying[expr] = newvalue
+                    self.message('display %s: %r  [old: %r]' %
+                                 (expr, newvalue, oldvalue))
 
     def interaction(self, frame, traceback):
         if self.setup(frame, traceback):
@@ -293,7 +339,7 @@
             self.forget()
             return
         self.print_stack_entry(self.stack[self.curindex])
-        self.cmdloop()
+        self._cmdloop()
         self.forget()
 
     def displayhook(self, obj):
@@ -337,7 +383,7 @@
             for tmpArg in args[1:]:
                 line = line.replace("%" + str(ii),
                                       tmpArg)
-                ii = ii + 1
+                ii += 1
             line = line.replace("%*", ' '.join(args[1:]))
             args = line.split()
         # split into ';;' separated commands
@@ -774,7 +820,7 @@
             except ValueError as err:
                 self.error(err)
             else:
-                self.clear_break(bp.file, bp.line)
+                self.clear_bpbynumber(i)
                 self.message('Deleted %s' % bp)
     do_cl = do_clear # 'c' is already an abbreviation for 'continue'
 
@@ -908,6 +954,9 @@
         """c(ont(inue))
         Continue execution, only stop when a breakpoint is encountered.
         """
+        if not self.nosigint:
+            self._previous_sigint_handler = \
+                signal.signal(signal.SIGINT, self.sigint_handler)
         self.set_continue()
         return 1
     do_c = do_cont = do_continue
@@ -962,7 +1011,7 @@
         """q(uit)\nexit
         Quit from the debugger. The program being executed is aborted.
         """
-        self._user_requested_quit = 1
+        self._user_requested_quit = True
         self.set_quit()
         return 1
 
@@ -974,7 +1023,7 @@
         Handles the receipt of EOF as a command.
         """
         self.message('')
-        self._user_requested_quit = 1
+        self._user_requested_quit = True
         self.set_quit()
         return 1
 
@@ -1013,6 +1062,17 @@
             self.error(traceback.format_exception_only(*exc_info)[-1].strip())
             raise
 
+    def _getval_except(self, arg, frame=None):
+        try:
+            if frame is None:
+                return eval(arg, self.curframe.f_globals, self.curframe_locals)
+            else:
+                return eval(arg, frame.f_globals, frame.f_locals)
+        except:
+            exc_info = sys.exc_info()[:2]
+            err = traceback.format_exception_only(*exc_info)[-1].strip()
+            return _rstr('** raised %s **' % err)
+
     def do_p(self, arg):
         """p(rint) expression
         Print the value of the expression.
@@ -1167,6 +1227,48 @@
         # None of the above...
         self.message(type(value))
 
+    def do_display(self, arg):
+        """display [expression]
+
+        Display the value of the expression if it changed, each time execution
+        stops in the current frame.
+
+        Without expression, list all display expressions for the current frame.
+        """
+        if not arg:
+            self.message('Currently displaying:')
+            for item in self.displaying.get(self.curframe, {}).items():
+                self.message('%s: %r' % item)
+        else:
+            val = self._getval_except(arg)
+            self.displaying.setdefault(self.curframe, {})[arg] = val
+            self.message('display %s: %r' % (arg, val))
+
+    def do_undisplay(self, arg):
+        """undisplay [expression]
+
+        Do not display the expression any more in the current frame.
+
+        Without expression, clear all display expressions for the current frame.
+        """
+        if arg:
+            try:
+                del self.displaying.get(self.curframe, {})[arg]
+            except KeyError:
+                self.error('not displaying %s' % arg)
+        else:
+            self.displaying.pop(self.curframe, None)
+
+    def do_interact(self, arg):
+        """interact
+
+        Start an interative interpreter whose global namespace
+        contains all the (global and local) names found in the current scope.
+        """
+        ns = self.curframe.f_globals.copy()
+        ns.update(self.curframe_locals)
+        code.interact("*interactive*", local=ns)
+
     def do_alias(self, arg):
         """alias [name [command [parameter parameter ...] ]]
         Create an alias called 'name' that executes 'command'.  The
@@ -1326,9 +1428,9 @@
         # events depends on python version). So we take special measures to
         # avoid stopping before we reach the main script (see user_line and
         # user_call for details).
-        self._wait_for_mainpyfile = 1
+        self._wait_for_mainpyfile = True
         self.mainpyfile = self.canonic(filename)
-        self._user_requested_quit = 0
+        self._user_requested_quit = False
         with open(filename, "rb") as fp:
             statement = "exec(compile(%r, %r, 'exec'))" % \
                         (fp.read(), self.mainpyfile)
@@ -1342,8 +1444,8 @@
         'help', 'where', 'down', 'up', 'break', 'tbreak', 'clear', 'disable',
         'enable', 'ignore', 'condition', 'commands', 'step', 'next', 'until',
         'jump', 'return', 'retval', 'run', 'continue', 'list', 'longlist',
-        'args', 'print', 'pp', 'whatis', 'source', 'alias', 'unalias',
-        'debug', 'quit',
+        'args', 'print', 'pp', 'whatis', 'source', 'display', 'undisplay',
+        'interact', 'alias', 'unalias', 'debug', 'quit',
     ]
 
     for _command in _help_order:

Modified: python/branches/py3k-cdecimal/Lib/py_compile.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/py_compile.py	(original)
+++ python/branches/py3k-cdecimal/Lib/py_compile.py	Sun Jan  2 13:18:37 2011
@@ -72,7 +72,7 @@
                    (x >> 16) & 0xff,
                    (x >> 24) & 0xff]))
 
-def compile(file, cfile=None, dfile=None, doraise=False):
+def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1):
     """Byte-compile one Python source file to Python bytecode.
 
     :param file: The source file name.
@@ -86,6 +86,10 @@
         will be printed, and the function will return to the caller. If an
         exception occurs and this flag is set to True, a PyCompileError
         exception will be raised.
+    :param optimize: The optimization level for the compiler.  Valid values
+        are -1, 0, 1 and 2.  A value of -1 means to use the optimization
+        level of the current interpreter, as given by -O command line options.
+
     :return: Path to the resulting byte compiled file.
 
     Note that it isn't necessary to byte-compile Python modules for
@@ -111,7 +115,8 @@
             timestamp = int(os.stat(file).st_mtime)
         codestring = f.read()
     try:
-        codeobject = builtins.compile(codestring, dfile or file,'exec')
+        codeobject = builtins.compile(codestring, dfile or file, 'exec',
+                                      optimize=optimize)
     except Exception as err:
         py_exc = PyCompileError(err.__class__, err, dfile or file)
         if doraise:
@@ -120,7 +125,10 @@
             sys.stderr.write(py_exc.msg + '\n')
             return
     if cfile is None:
-        cfile = imp.cache_from_source(file)
+        if optimize >= 0:
+            cfile = imp.cache_from_source(file, debug_override=not optimize)
+        else:
+            cfile = imp.cache_from_source(file)
     try:
         os.makedirs(os.path.dirname(cfile))
     except OSError as error:

Modified: python/branches/py3k-cdecimal/Lib/pydoc.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/pydoc.py	(original)
+++ python/branches/py3k-cdecimal/Lib/pydoc.py	Sun Jan  2 13:18:37 2011
@@ -15,11 +15,17 @@
 Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines
 of all available modules.
 
-Run "pydoc -p <port>" to start an HTTP server on a given port on the
-local machine to generate documentation web pages.
+Run "pydoc -p <port>" to start an HTTP server on the given port on the
+local machine.  Port number 0 can be used to get an arbitrary unused port.
+
+Run "pydoc -b" to start an HTTP server on an arbitrary unused port and
+open a Web browser to interactively browse documentation.  The -p option
+can be used with the -b option to explicitly specify the server port.
 
 For platforms without a command line, "pydoc -g" starts the HTTP server
-and also pops up a little window for controlling it.
+and also pops up a little window for controlling it.  This option is
+deprecated, since the server can now be controlled directly from HTTP
+clients.
 
 Run "pydoc -w <name>" to write out the HTML documentation for a module
 to a file named "<name>.html".
@@ -51,10 +57,22 @@
 #     the current directory is changed with os.chdir(), an incorrect
 #     path will be displayed.
 
-import sys, imp, os, re, inspect, builtins, pkgutil
-from reprlib import Repr
-from traceback import extract_tb as _extract_tb
+import os
+import sys
+import builtins
+import imp
+import io
+import inspect
+import pkgutil
+import platform
+import re
+import time
+import warnings
 from collections import deque
+from reprlib import Repr
+from traceback import extract_tb
+
+
 # --------------------------------------------------------- common routines
 
 def pathdirs():
@@ -285,7 +303,7 @@
         elif exc is SyntaxError:
             # A SyntaxError occurred before we could execute the module.
             raise ErrorDuringImport(value.filename, info)
-        elif exc is ImportError and _extract_tb(tb)[-1][2]=='safeimport':
+        elif exc is ImportError and extract_tb(tb)[-1][2]=='safeimport':
             # The import error occurred directly in this function,
             # which means there is no such module in the path.
             return None
@@ -513,6 +531,10 @@
             text = name
         return '<a href="%s">%s</a>' % (url, text)
 
+    def filelink(self, url, path):
+        """Make a link to source file."""
+        return '<a href="file:%s">%s</a>' % (url, path)
+
     def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
         """Mark up some plain text, given a context of symbols to look for.
         Each context dictionary maps object names to anchor names."""
@@ -591,7 +613,7 @@
             if sys.platform == 'win32':
                 import nturl2path
                 url = nturl2path.pathname2url(path)
-            filelink = '<a href="file:%s">%s</a>' % (url, path)
+            filelink = self.filelink(url, path)
         except TypeError:
             filelink = '(built-in)'
         info = []
@@ -978,7 +1000,7 @@
 
     def bold(self, text):
         """Format a string in bold by overstriking."""
-        return ''.join(map(lambda ch: ch + '\b' + ch, text))
+        return ''.join(ch + '\b' + ch for ch in text)
 
     def indent(self, text, prefix='    '):
         """Indent text by prepending a given prefix to each line."""
@@ -1002,7 +1024,7 @@
                 c, bases = entry
                 result = result + prefix + classname(c, modname)
                 if bases and bases != (parent,):
-                    parents = map(lambda c, m=modname: classname(c, m), bases)
+                    parents = (classname(c, modname) for c in bases)
                     result = result + '(%s)' % ', '.join(parents)
                 result = result + '\n'
             elif type(entry) is type([]):
@@ -1110,7 +1132,7 @@
         result = result + self.section('FILE', file)
         return result
 
-    def docclass(self, object, name=None, mod=None):
+    def docclass(self, object, name=None, mod=None, *ignored):
         """Produce text documentation for a given class object."""
         realname = object.__name__
         name = name or realname
@@ -1310,6 +1332,11 @@
             line += '\n' + self.indent(str(doc))
         return line
 
+class _PlainTextDoc(TextDoc):
+    """Subclass of TextDoc which overrides string styling"""
+    def bold(self, text):
+        return text
+
 # --------------------------------------------------------- user interfaces
 
 def pager(text):
@@ -1464,6 +1491,7 @@
 # --------------------------------------- interactive interpreter interface
 
 text = TextDoc()
+plaintext = _PlainTextDoc()
 html = HTMLDoc()
 
 def resolve(thing, forceload=0):
@@ -1476,8 +1504,11 @@
     else:
         return thing, getattr(thing, '__name__', None)
 
-def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
+def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
+        renderer=None):
     """Render text documentation, given an object or a path to an object."""
+    if renderer is None:
+        renderer = text
     object, name = resolve(thing, forceload)
     desc = describe(object)
     module = inspect.getmodule(object)
@@ -1496,12 +1527,16 @@
         # document its available methods instead of its value.
         object = type(object)
         desc += ' object'
-    return title % desc + '\n\n' + text.document(object, name)
+    return title % desc + '\n\n' + renderer.document(object, name)
 
-def doc(thing, title='Python Library Documentation: %s', forceload=0):
+def doc(thing, title='Python Library Documentation: %s', forceload=0,
+        output=None):
     """Display text documentation, given an object or a path to an object."""
     try:
-        pager(render_doc(thing, title, forceload))
+        if output is None:
+            pager(render_doc(thing, title, forceload))
+        else:
+            output.write(render_doc(thing, title, forceload, plaintext))
     except (ImportError, ErrorDuringImport) as value:
         print(value)
 
@@ -1755,9 +1790,9 @@
             elif request in self.symbols: self.showsymbol(request)
             elif request in self.keywords: self.showtopic(request)
             elif request in self.topics: self.showtopic(request)
-            elif request: doc(request, 'Help on %s:')
+            elif request: doc(request, 'Help on %s:', output=self._output)
         elif isinstance(request, Helper): self()
-        else: doc(request, 'Help on %s:')
+        else: doc(request, 'Help on %s:', output=self._output)
         self.output.write('\n')
 
     def intro(self):
@@ -1838,12 +1873,40 @@
         if more_xrefs:
             xrefs = (xrefs or '') + ' ' + more_xrefs
         if xrefs:
-            import io, formatter
+            import formatter
             buffer = io.StringIO()
             formatter.DumbWriter(buffer).send_flowing_data(
                 'Related help topics: ' + ', '.join(xrefs.split()) + '\n')
             self.output.write('\n%s\n' % buffer.getvalue())
 
+    def _gettopic(self, topic, more_xrefs=''):
+        """Return unbuffered tuple of (topic, xrefs).
+
+        If an error occurs, topic is the error message, and xrefs is ''.
+        This function duplicates the showtopic method but returns its
+        result directly so it can be formatted for display in an html page.
+        """
+        try:
+            import pydoc_data.topics
+        except ImportError:
+            return('''
+Sorry, topic and keyword documentation is not available because the
+module "pydoc_data.topics" could not be found.
+''' , '')
+        target = self.topics.get(topic, self.keywords.get(topic))
+        if not target:
+            return 'no documentation found for %r' % topic, ''
+        if isinstance(target, str):
+            return self._gettopic(target, more_xrefs)
+        label, xrefs = target
+        try:
+            doc = pydoc_data.topics.topics[label]
+        except KeyError:
+            return 'no documentation found for %r' % topic, ''
+        if more_xrefs:
+            xrefs = (xrefs or '') + ' ' + more_xrefs
+        return doc, xrefs
+
     def showsymbol(self, symbol):
         target = self.symbols[symbol]
         topic, _, xrefs = target.partition(' ')
@@ -1925,6 +1988,15 @@
         for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
             if self.quit:
                 break
+
+            # XXX Skipping this file is a workaround for a bug
+            # that causes python to crash with a segfault.
+            # http://bugs.python.org/issue9319
+            #
+            # TODO Remove this once the bug is fixed.
+            if modname in {'test.badsyntax_pep3120', 'badsyntax_pep3120'}:
+                continue
+
             if key is None:
                 callback(None, modname, '')
             else:
@@ -1940,7 +2012,6 @@
                         if onerror:
                             onerror(modname)
                         continue
-                    import io
                     desc = source_synopsis(io.StringIO(source)) or ''
                     if hasattr(loader, 'get_filename'):
                         path = loader.get_filename(modname)
@@ -1970,16 +2041,18 @@
         print(modname, desc and '- ' + desc)
     def onerror(modname):
         pass
-    try: import warnings
-    except ImportError: pass
-    else: warnings.filterwarnings('ignore') # ignore problems during import
-    ModuleScanner().run(callback, key, onerror=onerror)
+    with warnings.catch_warnings():
+        warnings.filterwarnings('ignore') # ignore problems during import
+        ModuleScanner().run(callback, key, onerror=onerror)
 
-# --------------------------------------------------- web browser interface
+# --------------------------------------------------- Web browser interface
 
 def serve(port, callback=None, completer=None):
     import http.server, email.message, select
 
+    msg = 'the pydoc.serve() function is deprecated'
+    warnings.warn(msg, DeprecationWarning, stacklevel=2)
+
     class DocHandler(http.server.BaseHTTPRequestHandler):
         def send_document(self, title, contents):
             try:
@@ -2058,7 +2131,12 @@
 # ----------------------------------------------------- graphical interface
 
 def gui():
-    """Graphical interface (starts web server and pops up a control window)."""
+    """Graphical interface (starts Web server and pops up a control window)."""
+
+    msg = ('the pydoc.gui() function and "pydoc -g" option are deprecated\n',
+           'use "pydoc.browse() function and "pydoc -b" option instead.')
+    warnings.warn(msg, DeprecationWarning, stacklevel=2)
+
     class GUI:
         def __init__(self, window, port=7464):
             self.window = window
@@ -2138,15 +2216,8 @@
 
         def open(self, event=None, url=None):
             url = url or self.server.url
-            try:
-                import webbrowser
-                webbrowser.open(url)
-            except ImportError: # pre-webbrowser.py compatibility
-                if sys.platform == 'win32':
-                    os.system('start "%s"' % url)
-                else:
-                    rc = os.system('netscape -remote "openURL(%s)" &' % url)
-                    if rc: os.system('netscape "%s" &' % url)
+            import webbrowser
+            webbrowser.open(url)
 
         def quit(self, event=None):
             if self.server:
@@ -2238,6 +2309,433 @@
     except KeyboardInterrupt:
         pass
 
+
+# --------------------------------------- enhanced Web browser interface
+
+def _start_server(urlhandler, port):
+    """Start an HTTP server thread on a specific port.
+
+    Start an HTML/text server thread, so HTML or text documents can be
+    browsed dynamically and interactively with a Web browser.  Example use:
+
+        >>> import time
+        >>> import pydoc
+
+        Define a URL handler.  To determine what the client is asking
+        for, check the URL and content_type.
+
+        Then get or generate some text or HTML code and return it.
+
+        >>> def my_url_handler(url, content_type):
+        ...     text = 'the URL sent was: (%s, %s)' % (url, content_type)
+        ...     return text
+
+        Start server thread on port 0.
+        If you use port 0, the server will pick a random port number.
+        You can then use serverthread.port to get the port number.
+
+        >>> port = 0
+        >>> serverthread = pydoc._start_server(my_url_handler, port)
+
+        Check that the server is really started.  If it is, open browser
+        and get first page.  Use serverthread.url as the starting page.
+
+        >>> if serverthread.serving:
+        ...    import webbrowser
+
+        The next two lines are commented out so a browser doesn't open if
+        doctest is run on this module.
+
+        #...    webbrowser.open(serverthread.url)
+        #True
+
+        Let the server do its thing. We just need to monitor its status.
+        Use time.sleep so the loop doesn't hog the CPU.
+
+        >>> starttime = time.time()
+        >>> timeout = 1                    #seconds
+
+        This is a short timeout for testing purposes.
+
+        >>> while serverthread.serving:
+        ...     time.sleep(.01)
+        ...     if serverthread.serving and time.time() - starttime > timeout:
+        ...          serverthread.stop()
+        ...          break
+
+        Print any errors that may have occurred.
+
+        >>> print(serverthread.error)
+        None
+   """
+    import http.server
+    import email.message
+    import select
+    import threading
+
+    class DocHandler(http.server.BaseHTTPRequestHandler):
+
+        def do_GET(self):
+            """Process a request from an HTML browser.
+
+            The URL received is in self.path.
+            Get an HTML page from self.urlhandler and send it.
+            """
+            if self.path.endswith('.css'):
+                content_type = 'text/css'
+            else:
+                content_type = 'text/html'
+            self.send_response(200)
+            self.send_header('Content-Type', '%s;charset=UTF-8' % content_type)
+            self.end_headers()
+            self.wfile.write(self.urlhandler(
+                self.path, content_type).encode('utf-8'))
+
+        def log_message(self, *args):
+            # Don't log messages.
+            pass
+
+    class DocServer(http.server.HTTPServer):
+
+        def __init__(self, port, callback):
+            self.host = (sys.platform == 'mac') and '127.0.0.1' or 'localhost'
+            self.address = ('', port)
+            self.callback = callback
+            self.base.__init__(self, self.address, self.handler)
+            self.quit = False
+
+        def serve_until_quit(self):
+            while not self.quit:
+                rd, wr, ex = select.select([self.socket.fileno()], [], [], 1)
+                if rd:
+                    self.handle_request()
+
+        def server_activate(self):
+            self.base.server_activate(self)
+            if self.callback:
+                self.callback(self)
+
+    class ServerThread(threading.Thread):
+
+        def __init__(self, urlhandler, port):
+            self.urlhandler = urlhandler
+            self.port = int(port)
+            threading.Thread.__init__(self)
+            self.serving = False
+            self.error = None
+
+        def run(self):
+            """Start the server."""
+            try:
+                DocServer.base = http.server.HTTPServer
+                DocServer.handler = DocHandler
+                DocHandler.MessageClass = email.message.Message
+                DocHandler.urlhandler = staticmethod(self.urlhandler)
+                docsvr = DocServer(self.port, self.ready)
+                self.docserver = docsvr
+                docsvr.serve_until_quit()
+            except Exception as e:
+                self.error = e
+
+        def ready(self, server):
+            self.serving = True
+            self.host = server.host
+            self.port = server.server_port
+            self.url = 'http://%s:%d/' % (self.host, self.port)
+
+        def stop(self):
+            """Stop the server and this thread nicely"""
+            self.docserver.quit = True
+            self.serving = False
+            self.url = None
+
+    thread = ServerThread(urlhandler, port)
+    thread.start()
+    # Wait until thread.serving is True to make sure we are
+    # really up before returning.
+    while not thread.error and not thread.serving:
+        time.sleep(.01)
+    return thread
+
+
+def _url_handler(url, content_type="text/html"):
+    """The pydoc url handler for use with the pydoc server.
+
+    If the content_type is 'text/css', the _pydoc.css style
+    sheet is read and returned if it exits.
+
+    If the content_type is 'text/html', then the result of
+    get_html_page(url) is returned.
+    """
+    class _HTMLDoc(HTMLDoc):
+
+        def page(self, title, contents):
+            """Format an HTML page."""
+            css_path = "pydoc_data/_pydoc.css"
+            css_link = (
+                '<link rel="stylesheet" type="text/css" href="%s">' %
+                css_path)
+            return '''\
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><title>Python: %s</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+%s</head><body bgcolor="#f0f0f8">%s
+</body></html>''' % (title, css_link, contents)
+
+        def filelink(self, url, path):
+            return '<a href="getfile?key=%s">%s</a>' % (url, path)
+
+
+    html = _HTMLDoc()
+
+    def html_navbar():
+        version = "%s [%s, %s]" % (platform.python_version(),
+                                   platform.python_build()[0],
+                                   platform.python_compiler())
+        return """
+            <div style='float:left'>
+                Python %s<br>%s<br><br>
+            </div>
+            <div style='float:right'>
+                <div style='text-align:center'>
+                  <a href="index.html">Module Index</a>
+                  : <a href="topics.html">Topics</a>
+                  : <a href="keywords.html">Keywords</a>
+                </div>
+                <div>
+                    <form action="get" style='float:left'>
+                      <input type=text name=key size=15>
+                      <input type=submit value="Get">
+                      &nbsp;&nbsp;&nbsp;
+                    </form>
+                    <form action="search" style='float:right'>
+                      <input type=text name=key size=15>
+                      <input type=submit value="Search">
+                    </form>
+                </div>
+            </div>
+            <div clear='all'>&nbsp;</div>
+            """ % (version, platform.platform(terse=True))
+
+    def html_index():
+        """Module Index page."""
+
+        def bltinlink(name):
+            return '<a href="%s.html">%s</a>' % (name, name)
+
+        heading = html.heading(
+            '<big><big><strong>Index of Modules</strong></big></big>',
+            '#ffffff', '#7799ee')
+        names = [name for name in sys.builtin_module_names
+                 if name != '__main__']
+        contents = html.multicolumn(names, bltinlink)
+        contents = [heading, '<p>' + html.bigsection(
+            'Built-in Modules', '#ffffff', '#ee77aa', contents)]
+
+        seen = {}
+        for dir in sys.path:
+            contents.append(html.index(dir, seen))
+
+        contents.append(
+            '<p align=right><font color="#909090" face="helvetica,'
+            'arial"><strong>pydoc</strong> by Ka-Ping Yee'
+            '&lt;ping at lfw.org&gt;</font>')
+        return 'Index of Modules', ''.join(contents)
+
+    def html_search(key):
+        """Search results page."""
+        # scan for modules
+        search_result = []
+
+        def callback(path, modname, desc):
+            if modname[-9:] == '.__init__':
+                modname = modname[:-9] + ' (package)'
+            search_result.append((modname, desc and '- ' + desc))
+
+        with warnings.catch_warnings():
+            warnings.filterwarnings('ignore') # ignore problems during import
+            ModuleScanner().run(callback, key)
+
+        # format page
+        def bltinlink(name):
+            return '<a href="%s.html">%s</a>' % (name, name)
+
+        results = []
+        heading = html.heading(
+            '<big><big><strong>Search Results</strong></big></big>',
+            '#ffffff', '#7799ee')
+        for name, desc in search_result:
+            results.append(bltinlink(name) + desc)
+        contents = heading + html.bigsection(
+            'key = %s' % key, '#ffffff', '#ee77aa', '<br>'.join(results))
+        return 'Search Results', contents
+
+    def html_getfile(path):
+        """Get and display a source file listing safely."""
+        path = path.replace('%20', ' ')
+        with open(path, 'r') as fp:
+            lines = html.escape(fp.read())
+        body = '<pre>%s</pre>' % lines
+        heading = html.heading(
+            '<big><big><strong>File Listing</strong></big></big>',
+            '#ffffff', '#7799ee')
+        contents = heading + html.bigsection(
+            'File: %s' % path, '#ffffff', '#ee77aa', body)
+        return 'getfile %s' % path, contents
+
+    def html_topics():
+        """Index of topic texts available."""
+
+        def bltinlink(name):
+            return '<a href="%s.html">%s</a>' % (name, name)
+
+        heading = html.heading(
+            '<big><big><strong>INDEX</strong></big></big>',
+            '#ffffff', '#7799ee')
+        names = sorted(Helper.topics.keys())
+
+        contents = html.multicolumn(names, bltinlink)
+        contents = heading + html.bigsection(
+            'Topics', '#ffffff', '#ee77aa', contents)
+        return 'Topics', contents
+
+    def html_keywords():
+        """Index of keywords."""
+        heading = html.heading(
+            '<big><big><strong>INDEX</strong></big></big>',
+            '#ffffff', '#7799ee')
+        names = sorted(Helper.keywords.keys())
+
+        def bltinlink(name):
+            return '<a href="%s.html">%s</a>' % (name, name)
+
+        contents = html.multicolumn(names, bltinlink)
+        contents = heading + html.bigsection(
+            'Keywords', '#ffffff', '#ee77aa', contents)
+        return 'Keywords', contents
+
+    def html_topicpage(topic):
+        """Topic or keyword help page."""
+        buf = io.StringIO()
+        htmlhelp = Helper(buf, buf)
+        contents, xrefs = htmlhelp._gettopic(topic)
+        if topic in htmlhelp.keywords:
+            title = 'KEYWORD'
+        else:
+            title = 'TOPIC'
+        heading = html.heading(
+            '<big><big><strong>%s</strong></big></big>' % title,
+            '#ffffff', '#7799ee')
+        contents = '<pre>%s</pre>' % contents
+        contents = html.bigsection(topic , '#ffffff','#ee77aa', contents)
+        xrefs = sorted(xrefs.split())
+
+        def bltinlink(name):
+            return '<a href="%s.html">%s</a>' % (name, name)
+
+        xrefs = html.multicolumn(xrefs, bltinlink)
+        xrefs = html.section('Related help topics: ',
+                             '#ffffff', '#ee77aa', xrefs)
+        return ('%s %s' % (title, topic),
+                ''.join((heading, contents, xrefs)))
+
+    def html_error(url):
+        heading = html.heading(
+            '<big><big><strong>Error</strong></big></big>',
+            '#ffffff', '#ee0000')
+        return heading + url
+
+    def get_html_page(url):
+        """Generate an HTML page for url."""
+        if url.endswith('.html'):
+            url = url[:-5]
+        if url.startswith('/'):
+            url = url[1:]
+        if url.startswith("get?key="):
+            url = url[8:]
+        title = url
+        contents = ''
+        if url in ("", ".", "index"):
+            title, contents = html_index()
+        elif url == "topics":
+            title, contents = html_topics()
+        elif url == "keywords":
+            title, contents = html_keywords()
+        elif url.startswith("search?key="):
+            title, contents = html_search(url[11:])
+        elif url.startswith("getfile?key="):
+            url = url[12:]
+            try:
+                title, contents = html_getfile(url)
+            except IOError:
+                contents = html_error('could not read file %r' % url)
+                title = 'Read Error'
+        else:
+            obj = None
+            try:
+                obj = locate(url, forceload=1)
+            except ErrorDuringImport as value:
+                contents = html.escape(str(value))
+            if obj:
+                title = describe(obj)
+                contents = html.document(obj, url)
+            elif url in Helper.keywords or url in Helper.topics:
+                title, contents = html_topicpage(url)
+            else:
+                contents = html_error(
+                    'no Python documentation found for %r' % url)
+                title = 'Error'
+        return html.page(title, html_navbar() + contents)
+
+    if url.startswith('/'):
+        url = url[1:]
+    if content_type == 'text/css':
+        path_here = os.path.dirname(os.path.realpath(__file__))
+        try:
+            with open(os.path.join(path_here, url)) as fp:
+                return ''.join(fp.readlines())
+        except IOError:
+            return 'Error: can not open css file %r' % url
+    elif content_type == 'text/html':
+        return get_html_page(url)
+    return 'Error: unknown content type %r' % content_type
+
+
+def browse(port=0, *, open_browser=True):
+    """Start the enhanced pydoc Web server and open a Web browser.
+
+    Use port '0' to start the server on an arbitrary port.
+    Set open_browser to False to suppress opening a browser.
+    """
+    import webbrowser
+    serverthread = _start_server(_url_handler, port)
+    if serverthread.error:
+        print(serverthread.error)
+        return
+    if serverthread.serving:
+        server_help_msg = 'Server commands: [b]rowser, [q]uit'
+        if open_browser:
+            webbrowser.open(serverthread.url)
+        try:
+            print('Server ready at', serverthread.url)
+            print(server_help_msg)
+            while serverthread.serving:
+                cmd = input('server> ')
+                cmd = cmd.lower()
+                if cmd == 'q':
+                    break
+                elif cmd == 'b':
+                    webbrowser.open(serverthread.url)
+                else:
+                    print(server_help_msg)
+        except (KeyboardInterrupt, EOFError):
+            print()
+        finally:
+            if serverthread.serving:
+                serverthread.stop()
+                print('Server stopped')
+
+
 # -------------------------------------------------- command-line interface
 
 def ispath(x):
@@ -2257,29 +2755,32 @@
         sys.path.insert(0, '.')
 
     try:
-        opts, args = getopt.getopt(sys.argv[1:], 'gk:p:w')
-        writing = 0
-
+        opts, args = getopt.getopt(sys.argv[1:], 'bgk:p:w')
+        writing = False
+        start_server = False
+        open_browser = False
+        port = None
         for opt, val in opts:
             if opt == '-g':
                 gui()
                 return
+            if opt == '-b':
+                start_server = True
+                open_browser = True
             if opt == '-k':
                 apropos(val)
                 return
             if opt == '-p':
-                try:
-                    port = int(val)
-                except ValueError:
-                    raise BadUsage
-                def ready(server):
-                    print('pydoc server ready at %s' % server.url)
-                def stopped():
-                    print('pydoc server stopped')
-                serve(port, ready, stopped)
-                return
+                start_server = True
+                port = val
             if opt == '-w':
-                writing = 1
+                writing = True
+
+        if start_server == True:
+            if port == None:
+                port = 0
+            browse(port, open_browser=open_browser)
+            return
 
         if not args: raise BadUsage
         for arg in args:
@@ -2300,30 +2801,37 @@
                 print(value)
 
     except (getopt.error, BadUsage):
-        cmd = os.path.basename(sys.argv[0])
+        cmd = os.path.splitext(os.path.basename(sys.argv[0]))[0]
         print("""pydoc - the Python documentation tool
 
-%s <name> ...
+{cmd} <name> ...
     Show text documentation on something.  <name> may be the name of a
     Python keyword, topic, function, module, or package, or a dotted
     reference to a class or function within a module or module in a
-    package.  If <name> contains a '%s', it is used as the path to a
+    package.  If <name> contains a '{sep}', it is used as the path to a
     Python source file to document. If name is 'keywords', 'topics',
     or 'modules', a listing of these things is displayed.
 
-%s -k <keyword>
+{cmd} -k <keyword>
     Search for a keyword in the synopsis lines of all available modules.
 
-%s -p <port>
-    Start an HTTP server on the given port on the local machine.
+{cmd} -p <port>
+    Start an HTTP server on the given port on the local machine.  Port
+    number 0 can be used to get an arbitrary unused port.
+
+{cmd} -b
+    Start an HTTP server on an arbitrary unused port and open a Web browser
+    to interactively browse documentation.  The -p option can be used with
+    the -b option to explicitly specify the server port.
 
-%s -g
-    Pop up a graphical interface for finding and serving documentation.
+{cmd} -g
+    Deprecated.
 
-%s -w <name> ...
+{cmd} -w <name> ...
     Write out the HTML documentation for a module to a file in the current
-    directory.  If <name> contains a '%s', it is treated as a filename; if
+    directory.  If <name> contains a '{sep}', it is treated as a filename; if
     it names a directory, documentation is written for all the contents.
-""" % (cmd, os.sep, cmd, cmd, cmd, cmd, os.sep))
+""".format(cmd=cmd, sep=os.sep))
 
-if __name__ == '__main__': cli()
+if __name__ == '__main__':
+    cli()

Modified: python/branches/py3k-cdecimal/Lib/pydoc_data/topics.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/pydoc_data/topics.py	(original)
+++ python/branches/py3k-cdecimal/Lib/pydoc_data/topics.py	Sun Jan  2 13:18:37 2011
@@ -1,4 +1,4 @@
-# Autogenerated by Sphinx on Sat Nov 13 06:34:47 2010
+# Autogenerated by Sphinx on Sun Dec 19 11:18:44 2010
 topics = {'assert': '\nThe ``assert`` statement\n************************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n   assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, ``assert expression``, is equivalent to\n\n   if __debug__:\n      if not expression: raise AssertionError\n\nThe extended form, ``assert expression1, expression2``, is equivalent\nto\n\n   if __debug__:\n      if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that ``__debug__`` and ``AssertionError``\nrefer to the built-in variables with those names.  In the current\nimplementation, the built-in variable ``__debug__`` is ``True`` under\nnormal circumstances, ``False`` when optimization is requested\n(command line option -O).  The current code generator emits no code\nfor an assert statement when optimization is requested at compile\ntime.  Note that it is unnecessary to include the source code for the\nexpression that failed in the error message; it will be displayed as\npart of the stack trace.\n\nAssignments to ``__debug__`` are illegal.  The value for the built-in\nvariable is determined when the interpreter starts.\n',
  'assignment': '\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n   assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n   target_list     ::= target ("," target)* [","]\n   target          ::= identifier\n              | "(" target_list ")"\n              | "[" target_list "]"\n              | attributeref\n              | subscription\n              | slicing\n              | "*" target\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable.  The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n  that target.\n\n* If the target list is a comma-separated list of targets: The object\n  must be an iterable with the same number of items as there are\n  targets in the target list, and the items are assigned, from left to\n  right, to the corresponding targets. (This rule is relaxed as of\n  Python 1.5; in earlier versions, the object had to be a tuple.\n  Since strings are sequences, an assignment like ``a, b = "xy"`` is\n  now legal as long as the string has the right length.)\n\n  * If the target list contains one target prefixed with an asterisk,\n    called a "starred" target: The object must be a sequence with at\n    least as many items as there are targets in the target list, minus\n    one.  The first items of the sequence are assigned, from left to\n    right, to the targets before the starred target.  The final items\n    of the sequence are assigned to the targets after the starred\n    target.  A list of the remaining items in the sequence is then\n    assigned to the starred target (the list can be empty).\n\n  * Else: The object must be a sequence with the same number of items\n    as there are targets in the target list, and the items are\n    assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n  * If the name does not occur in a ``global`` or ``nonlocal``\n    statement in the current code block: the name is bound to the\n    object in the current local namespace.\n\n  * Otherwise: the name is bound to the object in the global namespace\n    or the outer namespace determined by ``nonlocal``, respectively.\n\n  The name is rebound if it was already bound.  This may cause the\n  reference count for the object previously bound to the name to reach\n  zero, causing the object to be deallocated and its destructor (if it\n  has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in square\n  brackets: The object must be an iterable with the same number of\n  items as there are targets in the target list, and its items are\n  assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n  the reference is evaluated.  It should yield an object with\n  assignable attributes; if this is not the case, ``TypeError`` is\n  raised.  That object is then asked to assign the assigned object to\n  the given attribute; if it cannot perform the assignment, it raises\n  an exception (usually but not necessarily ``AttributeError``).\n\n  Note: If the object is a class instance and the attribute reference\n  occurs on both sides of the assignment operator, the RHS expression,\n  ``a.x`` can access either an instance attribute or (if no instance\n  attribute exists) a class attribute.  The LHS target ``a.x`` is\n  always set as an instance attribute, creating it if necessary.\n  Thus, the two occurrences of ``a.x`` do not necessarily refer to the\n  same attribute: if the RHS expression refers to a class attribute,\n  the LHS creates a new instance attribute as the target of the\n  assignment:\n\n     class Cls:\n         x = 3             # class variable\n     inst = Cls()\n     inst.x = inst.x + 1   # writes inst.x as 4 leaving Cls.x as 3\n\n  This description does not necessarily apply to descriptor\n  attributes, such as properties created with ``property()``.\n\n* If the target is a subscription: The primary expression in the\n  reference is evaluated.  It should yield either a mutable sequence\n  object (such as a list) or a mapping object (such as a dictionary).\n  Next, the subscript expression is evaluated.\n\n  If the primary is a mutable sequence object (such as a list), the\n  subscript must yield an integer.  If it is negative, the sequence\'s\n  length is added to it.  The resulting value must be a nonnegative\n  integer less than the sequence\'s length, and the sequence is asked\n  to assign the assigned object to its item with that index.  If the\n  index is out of range, ``IndexError`` is raised (assignment to a\n  subscripted sequence cannot add new items to a list).\n\n  If the primary is a mapping object (such as a dictionary), the\n  subscript must have a type compatible with the mapping\'s key type,\n  and the mapping is then asked to create a key/datum pair which maps\n  the subscript to the assigned object.  This can either replace an\n  existing key/value pair with the same key value, or insert a new\n  key/value pair (if no key with the same value existed).\n\n  For user-defined objects, the ``__setitem__()`` method is called\n  with appropriate arguments.\n\n* If the target is a slicing: The primary expression in the reference\n  is evaluated.  It should yield a mutable sequence object (such as a\n  list).  The assigned object should be a sequence object of the same\n  type.  Next, the lower and upper bound expressions are evaluated,\n  insofar they are present; defaults are zero and the sequence\'s\n  length.  The bounds should evaluate to integers. If either bound is\n  negative, the sequence\'s length is added to it.  The resulting\n  bounds are clipped to lie between zero and the sequence\'s length,\n  inclusive.  Finally, the sequence object is asked to replace the\n  slice with the items of the assigned sequence.  The length of the\n  slice may be different from the length of the assigned sequence,\n  thus changing the length of the target sequence, if the object\n  allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nWARNING: Although the definition of assignment implies that overlaps\nbetween the left-hand side and the right-hand side are \'safe\' (for\nexample ``a, b = b, a`` swaps two variables), overlaps *within* the\ncollection of assigned-to variables are not safe!  For instance, the\nfollowing program prints ``[0, 2]``:\n\n   x = [0, 1]\n   i = 0\n   i, x[i] = 1, 2\n   print(x)\n\nSee also:\n\n   **PEP 3132** - Extended Iterable Unpacking\n      The specification for the ``*target`` feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n   augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n   augtarget                 ::= identifier | attributeref | subscription | slicing\n   augop                     ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n             | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n',
  'atom-identifiers': '\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name.  See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a ``NameError`` exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them.  The transformation inserts the\nclass name in front of the name, with leading underscores removed, and\na single underscore inserted in front of the class name.  For example,\nthe identifier ``__spam`` occurring in a class named ``Ham`` will be\ntransformed to ``_Ham__spam``.  This transformation is independent of\nthe syntactical context in which the identifier is used.  If the\ntransformed name is extremely long (longer than 255 characters),\nimplementation defined truncation may happen.  If the class name\nconsists only of underscores, no transformation is done.\n',
@@ -16,14 +16,14 @@
  'break': '\nThe ``break`` statement\n***********************\n\n   break_stmt ::= "break"\n\n``break`` may only occur syntactically nested in a ``for`` or\n``while`` loop, but not nested in a function or class definition\nwithin that loop.\n\nIt terminates the nearest enclosing loop, skipping the optional\n``else`` clause if the loop has one.\n\nIf a ``for`` loop is terminated by ``break``, the loop control target\nkeeps its current value.\n\nWhen ``break`` passes control out of a ``try`` statement with a\n``finally`` clause, that ``finally`` clause is executed before really\nleaving the loop.\n',
  'callable-types': '\nEmulating callable objects\n**************************\n\nobject.__call__(self[, args...])\n\n   Called when the instance is "called" as a function; if this method\n   is defined, ``x(arg1, arg2, ...)`` is a shorthand for\n   ``x.__call__(arg1, arg2, ...)``.\n',
  'calls': '\nCalls\n*****\n\nA call calls a callable object (e.g., a function) with a possibly\nempty series of arguments:\n\n   call                 ::= primary "(" [argument_list [","] | comprehension] ")"\n   argument_list        ::= positional_arguments ["," keyword_arguments]\n                       ["," "*" expression] ["," keyword_arguments]\n                       ["," "**" expression]\n                     | keyword_arguments ["," "*" expression]\n                       ["," keyword_arguments] ["," "**" expression]\n                     | "*" expression ["," keyword_arguments] ["," "**" expression]\n                     | "**" expression\n   positional_arguments ::= expression ("," expression)*\n   keyword_arguments    ::= keyword_item ("," keyword_item)*\n   keyword_item         ::= identifier "=" expression\n\nA trailing comma may be present after the positional and keyword\narguments but does not affect the semantics.\n\nThe primary must evaluate to a callable object (user-defined\nfunctions, built-in functions, methods of built-in objects, class\nobjects, methods of class instances, and all objects having a\n``__call__()`` method are callable).  All argument expressions are\nevaluated before the call is attempted.  Please refer to section\n*Function definitions* for the syntax of formal parameter lists.\n\nIf keyword arguments are present, they are first converted to\npositional arguments, as follows.  First, a list of unfilled slots is\ncreated for the formal parameters.  If there are N positional\narguments, they are placed in the first N slots.  Next, for each\nkeyword argument, the identifier is used to determine the\ncorresponding slot (if the identifier is the same as the first formal\nparameter name, the first slot is used, and so on).  If the slot is\nalready filled, a ``TypeError`` exception is raised. Otherwise, the\nvalue of the argument is placed in the slot, filling it (even if the\nexpression is ``None``, it fills the slot).  When all arguments have\nbeen processed, the slots that are still unfilled are filled with the\ncorresponding default value from the function definition.  (Default\nvalues are calculated, once, when the function is defined; thus, a\nmutable object such as a list or dictionary used as default value will\nbe shared by all calls that don\'t specify an argument value for the\ncorresponding slot; this should usually be avoided.)  If there are any\nunfilled slots for which no default value is specified, a\n``TypeError`` exception is raised.  Otherwise, the list of filled\nslots is used as the argument list for the call.\n\n**CPython implementation detail:** An implementation may provide\nbuilt-in functions whose positional parameters do not have names, even\nif they are \'named\' for the purpose of documentation, and which\ntherefore cannot be supplied by keyword.  In CPython, this is the case\nfor functions implemented in C that use ``PyArg_ParseTuple()`` to\nparse their arguments.\n\nIf there are more positional arguments than there are formal parameter\nslots, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``*identifier`` is present; in this case, that formal\nparameter receives a tuple containing the excess positional arguments\n(or an empty tuple if there were no excess positional arguments).\n\nIf any keyword argument does not correspond to a formal parameter\nname, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``**identifier`` is present; in this case, that\nformal parameter receives a dictionary containing the excess keyword\narguments (using the keywords as keys and the argument values as\ncorresponding values), or a (new) empty dictionary if there were no\nexcess keyword arguments.\n\nIf the syntax ``*expression`` appears in the function call,\n``expression`` must evaluate to a sequence.  Elements from this\nsequence are treated as if they were additional positional arguments;\nif there are positional arguments *x1*,..., *xN*, and ``expression``\nevaluates to a sequence *y1*, ..., *yM*, this is equivalent to a call\nwith M+N positional arguments *x1*, ..., *xN*, *y1*, ..., *yM*.\n\nA consequence of this is that although the ``*expression`` syntax may\nappear *after* some keyword arguments, it is processed *before* the\nkeyword arguments (and the ``**expression`` argument, if any -- see\nbelow).  So:\n\n   >>> def f(a, b):\n   ...  print(a, b)\n   ...\n   >>> f(b=1, *(2,))\n   2 1\n   >>> f(a=1, *(2,))\n   Traceback (most recent call last):\n     File "<stdin>", line 1, in ?\n   TypeError: f() got multiple values for keyword argument \'a\'\n   >>> f(1, *(2,))\n   1 2\n\nIt is unusual for both keyword arguments and the ``*expression``\nsyntax to be used in the same call, so in practice this confusion does\nnot arise.\n\nIf the syntax ``**expression`` appears in the function call,\n``expression`` must evaluate to a mapping, the contents of which are\ntreated as additional keyword arguments.  In the case of a keyword\nappearing in both ``expression`` and as an explicit keyword argument,\na ``TypeError`` exception is raised.\n\nFormal parameters using the syntax ``*identifier`` or ``**identifier``\ncannot be used as positional argument slots or as keyword argument\nnames.\n\nA call always returns some value, possibly ``None``, unless it raises\nan exception.  How this value is computed depends on the type of the\ncallable object.\n\nIf it is---\n\na user-defined function:\n   The code block for the function is executed, passing it the\n   argument list.  The first thing the code block will do is bind the\n   formal parameters to the arguments; this is described in section\n   *Function definitions*.  When the code block executes a ``return``\n   statement, this specifies the return value of the function call.\n\na built-in function or method:\n   The result is up to the interpreter; see *Built-in Functions* for\n   the descriptions of built-in functions and methods.\n\na class object:\n   A new instance of that class is returned.\n\na class instance method:\n   The corresponding user-defined function is called, with an argument\n   list that is one longer than the argument list of the call: the\n   instance becomes the first argument.\n\na class instance:\n   The class must define a ``__call__()`` method; the effect is then\n   the same as if that method was called.\n',
- 'class': '\nClass definitions\n*****************\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n   classdef    ::= [decorators] "class" classname [inheritance] ":" suite\n   inheritance ::= "(" [argument_list [","] | comprehension] ")"\n   classname   ::= identifier\n\nA class definition is an executable statement.  The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing.\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.)  When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n   @f1(arg)\n   @f2\n   class Foo: pass\n\nis equivalent to\n\n   class Foo: pass\n   Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators.  The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances.  Instance attributes\ncan be set in a method with ``self.name = value``.  Both class and\ninstance attributes are accessible through the notation\n"``self.name``", and an instance attribute hides a class attribute\nwith the same name when accessed in this way.  Class attributes can be\nused as defaults for instance attributes, but using mutable values\nthere can lead to unexpected results.  *Descriptors* can be used to\ncreate instance variables with different implementation details.\n\nSee also:\n\n   **PEP 3116** - Metaclasses in Python 3 **PEP 3129** - Class\n   Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack only if there\n    is no ``finally`` clause that negates the exception.\n\n[2] Currently, control "flows off the end" except in the case of an\n    exception or the execution of a ``return``, ``continue``, or\n    ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n    body is transformed into the function\'s ``__doc__`` attribute and\n    therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n    body is transformed into the namespace\'s ``__doc__`` item and\n    therefore the class\'s *docstring*.\n',
+ 'class': '\nClass definitions\n*****************\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n   classdef    ::= [decorators] "class" classname [inheritance] ":" suite\n   inheritance ::= "(" [argument_list [","] | comprehension] ")"\n   classname   ::= identifier\n\nA class definition is an executable statement.  The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing.  Classes without an inheritance\nlist inherit, by default, from the base class ``object``; hence,\n\n   class Foo:\n       pass\n\nis equivalent to\n\n   class Foo(object):\n       pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.)  When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n   @f1(arg)\n   @f2\n   class Foo: pass\n\nis equivalent to\n\n   class Foo: pass\n   Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators.  The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances.  Instance attributes\ncan be set in a method with ``self.name = value``.  Both class and\ninstance attributes are accessible through the notation\n"``self.name``", and an instance attribute hides a class attribute\nwith the same name when accessed in this way.  Class attributes can be\nused as defaults for instance attributes, but using mutable values\nthere can lead to unexpected results.  *Descriptors* can be used to\ncreate instance variables with different implementation details.\n\nSee also:\n\n   **PEP 3116** - Metaclasses in Python 3 **PEP 3129** - Class\n   Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack only if there\n    is no ``finally`` clause that negates the exception.\n\n[2] Currently, control "flows off the end" except in the case of an\n    exception or the execution of a ``return``, ``continue``, or\n    ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n    body is transformed into the function\'s ``__doc__`` attribute and\n    therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n    body is transformed into the namespace\'s ``__doc__`` item and\n    therefore the class\'s *docstring*.\n',
  'comparisons': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation.  Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n   comparison    ::= or_expr ( comp_operator or_expr )*\n   comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n                     | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects.  The objects need not have the same type.\nIf both are numbers, they are converted to a common type.  Otherwise,\nthe ``==`` and ``!=`` operators *always* consider objects of different\ntypes to be unequal, while the ``<``, ``>``, ``>=`` and ``<=``\noperators raise a ``TypeError`` when comparing objects of different\ntypes that do not implement these operators for the given pair of\ntypes.  You can control comparison behavior of objects of non-built-in\ntypes by defining rich comparison methods like ``__gt__()``, described\nin section *Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values ``float(\'NaN\')`` and ``Decimal(\'NaN\')`` are special. The\n  are identical to themselves, ``x is x`` but are not equal to\n  themselves, ``x != x``.  Additionally, comparing any value to a\n  not-a-number value will return ``False``.  For example, both ``3 <\n  float(\'NaN\')`` and ``float(\'NaN\') < 3`` will return ``False``.\n\n* Bytes objects are compared lexicographically using the numeric\n  values of their elements.\n\n* Strings are compared lexicographically using the numeric equivalents\n  (the result of the built-in function ``ord()``) of their characters.\n  [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison of\n  corresponding elements.  This means that to compare equal, each\n  element must compare equal and the two sequences must be of the same\n  type and have the same length.\n\n  If not equal, the sequences are ordered the same as their first\n  differing elements.  For example, ``[1,2,x] <= [1,2,y]`` has the\n  same value as ``x <= y``.  If the corresponding element does not\n  exist, the shorter sequence is ordered first (for example, ``[1,2] <\n  [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if they have the\n  same ``(key, value)`` pairs. Order comparisons ``(\'<\', \'<=\', \'>=\',\n  \'>\')`` raise ``TypeError``.\n\n* Sets and frozensets define comparison operators to mean subset and\n  superset tests.  Those relations do not define total orderings (the\n  two sets ``{1,2}`` and {2,3} are not equal, nor subsets of one\n  another, nor supersets of one another).  Accordingly, sets are not\n  appropriate arguments for functions which depend on total ordering.\n  For example, ``min()``, ``max()``, and ``sorted()`` produce\n  undefined results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they are\n  the same object; the choice whether one object is considered smaller\n  or larger than another one is made arbitrarily but consistently\n  within one execution of a program.\n\nComparison of objects of the differing types depends on whether either\nof the types provide explicit support for the comparison.  Most\nnumeric types can be compared with one another, but comparisons of\n``float`` and ``Decimal`` are not supported to avoid the inevitable\nconfusion arising from representation issues such as ``float(\'1.1\')``\nbeing inexactly represented and therefore not exactly equal to\n``Decimal(\'1.1\')`` which is.  When cross-type comparison is not\nsupported, the comparison method returns ``NotImplemented``.  This can\ncreate the illusion of non-transitivity between supported cross-type\ncomparisons and unsupported comparisons.  For example, ``Decimal(2) ==\n2`` and ``2 == float(2)`` but ``Decimal(2) != float(2)``.\n\nThe operators ``in`` and ``not in`` test for membership.  ``x in s``\nevaluates to true if *x* is a member of *s*, and false otherwise.  ``x\nnot in s`` returns the negation of ``x in s``.  All built-in sequences\nand set types support this as well as dictionary, for which ``in``\ntests whether a the dictionary has a given key. For container types\nsuch as list, tuple, set, frozenset, dict, or collections.deque, the\nexpression ``x in y`` is equivalent to ``any(x is e or x == e for e in\ny)``.\n\nFor the string and bytes types, ``x in y`` is true if and only if *x*\nis a substring of *y*.  An equivalent test is ``y.find(x) != -1``.\nEmpty strings are always considered to be a substring of any other\nstring, so ``"" in "abc"`` will return ``True``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` but do\ndefine ``__iter__()``, ``x in y`` is true if some value ``z`` with ``x\n== z`` is produced while iterating over ``y``.  If an exception is\nraised during the iteration, it is as if ``in`` raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n``__getitem__()``, ``x in y`` is true if and only if there is a non-\nnegative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception.  (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object.  ``x is\nnot y`` yields the inverse truth value. [4]\n',
- 'compound': '\nCompound statements\n*******************\n\nCompound statements contain (groups of) other statements; they affect\nor control the execution of those other statements in some way.  In\ngeneral, compound statements span multiple lines, although in simple\nincarnations a whole compound statement may be contained in one line.\n\nThe ``if``, ``while`` and ``for`` statements implement traditional\ncontrol flow constructs.  ``try`` specifies exception handlers and/or\ncleanup code for a group of statements, while the ``with`` statement\nallows the execution of initialization and finalization code around a\nblock of code.  Function and class definitions are also syntactically\ncompound statements.\n\nCompound statements consist of one or more \'clauses.\'  A clause\nconsists of a header and a \'suite.\'  The clause headers of a\nparticular compound statement are all at the same indentation level.\nEach clause header begins with a uniquely identifying keyword and ends\nwith a colon.  A suite is a group of statements controlled by a\nclause.  A suite can be one or more semicolon-separated simple\nstatements on the same line as the header, following the header\'s\ncolon, or it can be one or more indented statements on subsequent\nlines.  Only the latter form of suite can contain nested compound\nstatements; the following is illegal, mostly because it wouldn\'t be\nclear to which ``if`` clause a following ``else`` clause would belong:\n\n   if test1: if test2: print(x)\n\nAlso note that the semicolon binds tighter than the colon in this\ncontext, so that in the following example, either all or none of the\n``print()`` calls are executed:\n\n   if x < y < z: print(x); print(y); print(z)\n\nSummarizing:\n\n   compound_stmt ::= if_stmt\n                     | while_stmt\n                     | for_stmt\n                     | try_stmt\n                     | with_stmt\n                     | funcdef\n                     | classdef\n   suite         ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT\n   statement     ::= stmt_list NEWLINE | compound_stmt\n   stmt_list     ::= simple_stmt (";" simple_stmt)* [";"]\n\nNote that statements always end in a ``NEWLINE`` possibly followed by\na ``DEDENT``.  Also note that optional continuation clauses always\nbegin with a keyword that cannot start a statement, thus there are no\nambiguities (the \'dangling ``else``\' problem is solved in Python by\nrequiring nested ``if`` statements to be indented).\n\nThe formatting of the grammar rules in the following sections places\neach clause on a separate line for clarity.\n\n\nThe ``if`` statement\n====================\n\nThe ``if`` statement is used for conditional execution:\n\n   if_stmt ::= "if" expression ":" suite\n               ( "elif" expression ":" suite )*\n               ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n\n\nThe ``while`` statement\n=======================\n\nThe ``while`` statement is used for repeated execution as long as an\nexpression is true:\n\n   while_stmt ::= "while" expression ":" suite\n                  ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the ``else`` clause, if present, is\nexecuted and the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite.  A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ngoes back to testing the expression.\n\n\nThe ``for`` statement\n=====================\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n   for_stmt ::= "for" target_list "in" expression_list ":" suite\n                ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject.  An iterator is created for the result of the\n``expression_list``.  The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices.  Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted.  When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a ``StopIteration``\nexception), the suite in the ``else`` clause, if present, is executed,\nand the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite.  A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, it will not have been assigned to at all\nby the loop.  Hint: the built-in function ``range()`` returns an\niterator of integers suitable to emulate the effect of Pascal\'s ``for\ni := a to b do``; e.g., ``list(range(3))`` returns the list ``[0, 1,\n2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n  (this can only occur for mutable sequences, i.e. lists).  An\n  internal counter is used to keep track of which item is used next,\n  and this is incremented on each iteration.  When this counter has\n  reached the length of the sequence the loop terminates.  This means\n  that if the suite deletes the current (or a previous) item from the\n  sequence, the next item will be skipped (since it gets the index of\n  the current item which has already been treated).  Likewise, if the\n  suite inserts an item in the sequence before the current item, the\n  current item will be treated again the next time through the loop.\n  This can lead to nasty bugs that can be avoided by making a\n  temporary copy using a slice of the whole sequence, e.g.,\n\n     for x in a[:]:\n         if x < 0: a.remove(x)\n\n\nThe ``try`` statement\n=====================\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n   try_stmt  ::= try1_stmt | try2_stmt\n   try1_stmt ::= "try" ":" suite\n                 ("except" [expression ["as" target]] ":" suite)+\n                 ["else" ":" suite]\n                 ["finally" ":" suite]\n   try2_stmt ::= "try" ":" suite\n                 "finally" ":" suite\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started.  This search inspects the except\nclauses in turn until one is found that matches the exception.  An\nexpression-less except clause, if present, must be last; it matches\nany exception.  For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception.  An object is\ncompatible with an exception if it is the class or a base class of the\nexception object or a tuple containing an item compatible with the\nexception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the ``as`` keyword in that except clause,\nif present, and the except clause\'s suite is executed.  All except\nclauses must have an executable block.  When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using ``as target``, it is cleared\nat the end of the except clause.  This is as if\n\n   except E as N:\n       foo\n\nwas translated to\n\n   except E as N:\n       try:\n           foo\n       finally:\n           del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause.  Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the ``sys`` module and can be access via\n``sys.exc_info()``. ``sys.exc_info()`` returns a 3-tuple consisting\nof: ``exc_type``, the exception class; ``exc_value``, the exception\ninstance; ``exc_traceback``, a traceback object (see section *The\nstandard type hierarchy*) identifying the point in the program where\nthe exception occurred. ``sys.exc_info()`` values are restored to\ntheir previous values (before the call) when returning from a function\nthat handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler.  The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses.  If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted.  If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is lost.  The exception information is not available to the\nprogram during execution of the ``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n\n\nThe ``with`` statement\n======================\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n   with_stmt ::= "with" with_item ("," with_item)* ":" suite\n   with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the ``with_item``)\n   is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__exit__()`` is loaded for later use.\n\n3. The context manager\'s ``__enter__()`` method is invoked.\n\n4. If a target was included in the ``with`` statement, the return\n   value from ``__enter__()`` is assigned to it.\n\n   Note: The ``with`` statement guarantees that if the ``__enter__()``\n     method returns without an error, then ``__exit__()`` will always\n     be called. Thus, if an error occurs during the assignment to the\n     target list, it will be treated the same as an error occurring\n     within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s ``__exit__()`` method is invoked.  If an\n   exception caused the suite to be exited, its type, value, and\n   traceback are passed as arguments to ``__exit__()``. Otherwise,\n   three ``None`` arguments are supplied.\n\n   If the suite was exited due to an exception, and the return value\n   from the ``__exit__()`` method was false, the exception is\n   reraised.  If the return value was true, the exception is\n   suppressed, and execution continues with the statement following\n   the ``with`` statement.\n\n   If the suite was exited for any reason other than an exception, the\n   return value from ``__exit__()`` is ignored, and execution proceeds\n   at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n   with A() as a, B() as b:\n       suite\n\nis equivalent to\n\n   with A() as a:\n       with B() as b:\n           suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also:\n\n   **PEP 0343** - The "with" statement\n      The specification, background, and examples for the Python\n      ``with`` statement.\n\n\nFunction definitions\n====================\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n   funcdef        ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n   decorators     ::= decorator+\n   decorator      ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n   dotted_name    ::= identifier ("." identifier)*\n   parameter_list ::= (defparameter ",")*\n                      (  "*" [parameter] ("," defparameter)*\n                      [, "**" parameter]\n                      | "**" parameter\n                      | defparameter [","] )\n   parameter      ::= identifier [":" expression]\n   defparameter   ::= parameter ["=" expression]\n   funcname       ::= identifier\n\nA function definition is an executable statement.  Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function).  This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition.  The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object.  Multiple decorators are applied in\nnested fashion. For example, the following code\n\n   @f1(arg)\n   @f2\n   def func(): pass\n\nis equivalent to\n\n   def func(): pass\n   func = f1(arg)(f2(func))\n\nWhen one or more parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted.  If a parameter has a default value, all following\nparameters up until the "``*``" must also have a default value ---\nthis is a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that that same "pre-computed" value is\nused for each call.  This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended.  A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n   def whats_on_the_telly(penguin=None):\n       if penguin is None:\n           penguin = []\n       penguin.append("property of the zoo")\n       return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values.  If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple.  If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after "``*``" or "``*identifier``" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "``: expression``"\nfollowing the parameter name.  Any parameter may have an annotation\neven those of the form ``*identifier`` or ``**identifier``.  Functions\nmay have "return" annotation of the form "``-> expression``" after the\nparameter list.  These annotations can be any valid Python expression\nand are evaluated when the function definition is executed.\nAnnotations may be evaluated in a different order than they appear in\nthe source code.  The presence of annotations does not change the\nsemantics of a function.  The annotation values are available as\nvalues of a dictionary keyed by the parameters\' names in the\n``__annotations__`` attribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions.  This uses lambda forms,\ndescribed in section *Lambdas*.  Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form.  The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects.  A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around.  Free variables used in the\nnested function can access the local variables of the function\ncontaining the def.  See section *Naming and binding* for details.\n\n\nClass definitions\n=================\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n   classdef    ::= [decorators] "class" classname [inheritance] ":" suite\n   inheritance ::= "(" [argument_list [","] | comprehension] ")"\n   classname   ::= identifier\n\nA class definition is an executable statement.  The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing.\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.)  When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n   @f1(arg)\n   @f2\n   class Foo: pass\n\nis equivalent to\n\n   class Foo: pass\n   Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators.  The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances.  Instance attributes\ncan be set in a method with ``self.name = value``.  Both class and\ninstance attributes are accessible through the notation\n"``self.name``", and an instance attribute hides a class attribute\nwith the same name when accessed in this way.  Class attributes can be\nused as defaults for instance attributes, but using mutable values\nthere can lead to unexpected results.  *Descriptors* can be used to\ncreate instance variables with different implementation details.\n\nSee also:\n\n   **PEP 3116** - Metaclasses in Python 3 **PEP 3129** - Class\n   Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack only if there\n    is no ``finally`` clause that negates the exception.\n\n[2] Currently, control "flows off the end" except in the case of an\n    exception or the execution of a ``return``, ``continue``, or\n    ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n    body is transformed into the function\'s ``__doc__`` attribute and\n    therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n    body is transformed into the namespace\'s ``__doc__`` item and\n    therefore the class\'s *docstring*.\n',
+ 'compound': '\nCompound statements\n*******************\n\nCompound statements contain (groups of) other statements; they affect\nor control the execution of those other statements in some way.  In\ngeneral, compound statements span multiple lines, although in simple\nincarnations a whole compound statement may be contained in one line.\n\nThe ``if``, ``while`` and ``for`` statements implement traditional\ncontrol flow constructs.  ``try`` specifies exception handlers and/or\ncleanup code for a group of statements, while the ``with`` statement\nallows the execution of initialization and finalization code around a\nblock of code.  Function and class definitions are also syntactically\ncompound statements.\n\nCompound statements consist of one or more \'clauses.\'  A clause\nconsists of a header and a \'suite.\'  The clause headers of a\nparticular compound statement are all at the same indentation level.\nEach clause header begins with a uniquely identifying keyword and ends\nwith a colon.  A suite is a group of statements controlled by a\nclause.  A suite can be one or more semicolon-separated simple\nstatements on the same line as the header, following the header\'s\ncolon, or it can be one or more indented statements on subsequent\nlines.  Only the latter form of suite can contain nested compound\nstatements; the following is illegal, mostly because it wouldn\'t be\nclear to which ``if`` clause a following ``else`` clause would belong:\n\n   if test1: if test2: print(x)\n\nAlso note that the semicolon binds tighter than the colon in this\ncontext, so that in the following example, either all or none of the\n``print()`` calls are executed:\n\n   if x < y < z: print(x); print(y); print(z)\n\nSummarizing:\n\n   compound_stmt ::= if_stmt\n                     | while_stmt\n                     | for_stmt\n                     | try_stmt\n                     | with_stmt\n                     | funcdef\n                     | classdef\n   suite         ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT\n   statement     ::= stmt_list NEWLINE | compound_stmt\n   stmt_list     ::= simple_stmt (";" simple_stmt)* [";"]\n\nNote that statements always end in a ``NEWLINE`` possibly followed by\na ``DEDENT``.  Also note that optional continuation clauses always\nbegin with a keyword that cannot start a statement, thus there are no\nambiguities (the \'dangling ``else``\' problem is solved in Python by\nrequiring nested ``if`` statements to be indented).\n\nThe formatting of the grammar rules in the following sections places\neach clause on a separate line for clarity.\n\n\nThe ``if`` statement\n====================\n\nThe ``if`` statement is used for conditional execution:\n\n   if_stmt ::= "if" expression ":" suite\n               ( "elif" expression ":" suite )*\n               ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n\n\nThe ``while`` statement\n=======================\n\nThe ``while`` statement is used for repeated execution as long as an\nexpression is true:\n\n   while_stmt ::= "while" expression ":" suite\n                  ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the ``else`` clause, if present, is\nexecuted and the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite.  A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ngoes back to testing the expression.\n\n\nThe ``for`` statement\n=====================\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n   for_stmt ::= "for" target_list "in" expression_list ":" suite\n                ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject.  An iterator is created for the result of the\n``expression_list``.  The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices.  Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted.  When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a ``StopIteration``\nexception), the suite in the ``else`` clause, if present, is executed,\nand the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite.  A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, it will not have been assigned to at all\nby the loop.  Hint: the built-in function ``range()`` returns an\niterator of integers suitable to emulate the effect of Pascal\'s ``for\ni := a to b do``; e.g., ``list(range(3))`` returns the list ``[0, 1,\n2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n  (this can only occur for mutable sequences, i.e. lists).  An\n  internal counter is used to keep track of which item is used next,\n  and this is incremented on each iteration.  When this counter has\n  reached the length of the sequence the loop terminates.  This means\n  that if the suite deletes the current (or a previous) item from the\n  sequence, the next item will be skipped (since it gets the index of\n  the current item which has already been treated).  Likewise, if the\n  suite inserts an item in the sequence before the current item, the\n  current item will be treated again the next time through the loop.\n  This can lead to nasty bugs that can be avoided by making a\n  temporary copy using a slice of the whole sequence, e.g.,\n\n     for x in a[:]:\n         if x < 0: a.remove(x)\n\n\nThe ``try`` statement\n=====================\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n   try_stmt  ::= try1_stmt | try2_stmt\n   try1_stmt ::= "try" ":" suite\n                 ("except" [expression ["as" target]] ":" suite)+\n                 ["else" ":" suite]\n                 ["finally" ":" suite]\n   try2_stmt ::= "try" ":" suite\n                 "finally" ":" suite\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started.  This search inspects the except\nclauses in turn until one is found that matches the exception.  An\nexpression-less except clause, if present, must be last; it matches\nany exception.  For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception.  An object is\ncompatible with an exception if it is the class or a base class of the\nexception object or a tuple containing an item compatible with the\nexception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the ``as`` keyword in that except clause,\nif present, and the except clause\'s suite is executed.  All except\nclauses must have an executable block.  When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using ``as target``, it is cleared\nat the end of the except clause.  This is as if\n\n   except E as N:\n       foo\n\nwas translated to\n\n   except E as N:\n       try:\n           foo\n       finally:\n           del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause.  Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the ``sys`` module and can be access via\n``sys.exc_info()``. ``sys.exc_info()`` returns a 3-tuple consisting\nof: ``exc_type``, the exception class; ``exc_value``, the exception\ninstance; ``exc_traceback``, a traceback object (see section *The\nstandard type hierarchy*) identifying the point in the program where\nthe exception occurred. ``sys.exc_info()`` values are restored to\ntheir previous values (before the call) when returning from a function\nthat handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler.  The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses.  If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted.  If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is lost.  The exception information is not available to the\nprogram during execution of the ``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n\n\nThe ``with`` statement\n======================\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n   with_stmt ::= "with" with_item ("," with_item)* ":" suite\n   with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the ``with_item``)\n   is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__exit__()`` is loaded for later use.\n\n3. The context manager\'s ``__enter__()`` method is invoked.\n\n4. If a target was included in the ``with`` statement, the return\n   value from ``__enter__()`` is assigned to it.\n\n   Note: The ``with`` statement guarantees that if the ``__enter__()``\n     method returns without an error, then ``__exit__()`` will always\n     be called. Thus, if an error occurs during the assignment to the\n     target list, it will be treated the same as an error occurring\n     within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s ``__exit__()`` method is invoked.  If an\n   exception caused the suite to be exited, its type, value, and\n   traceback are passed as arguments to ``__exit__()``. Otherwise,\n   three ``None`` arguments are supplied.\n\n   If the suite was exited due to an exception, and the return value\n   from the ``__exit__()`` method was false, the exception is\n   reraised.  If the return value was true, the exception is\n   suppressed, and execution continues with the statement following\n   the ``with`` statement.\n\n   If the suite was exited for any reason other than an exception, the\n   return value from ``__exit__()`` is ignored, and execution proceeds\n   at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n   with A() as a, B() as b:\n       suite\n\nis equivalent to\n\n   with A() as a:\n       with B() as b:\n           suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also:\n\n   **PEP 0343** - The "with" statement\n      The specification, background, and examples for the Python\n      ``with`` statement.\n\n\nFunction definitions\n====================\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n   funcdef        ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n   decorators     ::= decorator+\n   decorator      ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n   dotted_name    ::= identifier ("." identifier)*\n   parameter_list ::= (defparameter ",")*\n                      (  "*" [parameter] ("," defparameter)*\n                      [, "**" parameter]\n                      | "**" parameter\n                      | defparameter [","] )\n   parameter      ::= identifier [":" expression]\n   defparameter   ::= parameter ["=" expression]\n   funcname       ::= identifier\n\nA function definition is an executable statement.  Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function).  This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition.  The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object.  Multiple decorators are applied in\nnested fashion. For example, the following code\n\n   @f1(arg)\n   @f2\n   def func(): pass\n\nis equivalent to\n\n   def func(): pass\n   func = f1(arg)(f2(func))\n\nWhen one or more parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted.  If a parameter has a default value, all following\nparameters up until the "``*``" must also have a default value ---\nthis is a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that that same "pre-computed" value is\nused for each call.  This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended.  A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n   def whats_on_the_telly(penguin=None):\n       if penguin is None:\n           penguin = []\n       penguin.append("property of the zoo")\n       return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values.  If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple.  If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after "``*``" or "``*identifier``" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "``: expression``"\nfollowing the parameter name.  Any parameter may have an annotation\neven those of the form ``*identifier`` or ``**identifier``.  Functions\nmay have "return" annotation of the form "``-> expression``" after the\nparameter list.  These annotations can be any valid Python expression\nand are evaluated when the function definition is executed.\nAnnotations may be evaluated in a different order than they appear in\nthe source code.  The presence of annotations does not change the\nsemantics of a function.  The annotation values are available as\nvalues of a dictionary keyed by the parameters\' names in the\n``__annotations__`` attribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions.  This uses lambda forms,\ndescribed in section *Lambdas*.  Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form.  The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects.  A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around.  Free variables used in the\nnested function can access the local variables of the function\ncontaining the def.  See section *Naming and binding* for details.\n\n\nClass definitions\n=================\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n   classdef    ::= [decorators] "class" classname [inheritance] ":" suite\n   inheritance ::= "(" [argument_list [","] | comprehension] ")"\n   classname   ::= identifier\n\nA class definition is an executable statement.  The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing.  Classes without an inheritance\nlist inherit, by default, from the base class ``object``; hence,\n\n   class Foo:\n       pass\n\nis equivalent to\n\n   class Foo(object):\n       pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.)  When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n   @f1(arg)\n   @f2\n   class Foo: pass\n\nis equivalent to\n\n   class Foo: pass\n   Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators.  The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances.  Instance attributes\ncan be set in a method with ``self.name = value``.  Both class and\ninstance attributes are accessible through the notation\n"``self.name``", and an instance attribute hides a class attribute\nwith the same name when accessed in this way.  Class attributes can be\nused as defaults for instance attributes, but using mutable values\nthere can lead to unexpected results.  *Descriptors* can be used to\ncreate instance variables with different implementation details.\n\nSee also:\n\n   **PEP 3116** - Metaclasses in Python 3 **PEP 3129** - Class\n   Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack only if there\n    is no ``finally`` clause that negates the exception.\n\n[2] Currently, control "flows off the end" except in the case of an\n    exception or the execution of a ``return``, ``continue``, or\n    ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n    body is transformed into the function\'s ``__doc__`` attribute and\n    therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n    body is transformed into the namespace\'s ``__doc__`` item and\n    therefore the class\'s *docstring*.\n',
  'context-managers': '\nWith Statement Context Managers\n*******************************\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code.  Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n   Enter the runtime context related to this object. The ``with``\n   statement will bind this method\'s return value to the target(s)\n   specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n   Exit the runtime context related to this object. The parameters\n   describe the exception that caused the context to be exited. If the\n   context was exited without an exception, all three arguments will\n   be ``None``.\n\n   If an exception is supplied, and the method wishes to suppress the\n   exception (i.e., prevent it from being propagated), it should\n   return a true value. Otherwise, the exception will be processed\n   normally upon exit from this method.\n\n   Note that ``__exit__()`` methods should not reraise the passed-in\n   exception; this is the caller\'s responsibility.\n\nSee also:\n\n   **PEP 0343** - The "with" statement\n      The specification, background, and examples for the Python\n      ``with`` statement.\n',
  'continue': '\nThe ``continue`` statement\n**************************\n\n   continue_stmt ::= "continue"\n\n``continue`` may only occur syntactically nested in a ``for`` or\n``while`` loop, but not nested in a function or class definition or\n``finally`` clause within that loop.  It continues with the next cycle\nof the nearest enclosing loop.\n\nWhen ``continue`` passes control out of a ``try`` statement with a\n``finally`` clause, that ``finally`` clause is executed before really\nstarting the next loop cycle.\n',
  'conversions': '\nArithmetic conversions\n**********************\n\nWhen a description of an arithmetic operator below uses the phrase\n"the numeric arguments are converted to a common type," this means\nthat the operator implementation for built-in types works that way:\n\n* If either argument is a complex number, the other is converted to\n  complex;\n\n* otherwise, if either argument is a floating point number, the other\n  is converted to floating point;\n\n* otherwise, both must be integers and no conversion is necessary.\n\nSome additional rules apply for certain operators (e.g., a string left\nargument to the \'%\' operator).  Extensions must define their own\nconversion behavior.\n',
  'customization': '\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n   Called to create a new instance of class *cls*.  ``__new__()`` is a\n   static method (special-cased so you need not declare it as such)\n   that takes the class of which an instance was requested as its\n   first argument.  The remaining arguments are those passed to the\n   object constructor expression (the call to the class).  The return\n   value of ``__new__()`` should be the new object instance (usually\n   an instance of *cls*).\n\n   Typical implementations create a new instance of the class by\n   invoking the superclass\'s ``__new__()`` method using\n   ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n   arguments and then modifying the newly-created instance as\n   necessary before returning it.\n\n   If ``__new__()`` returns an instance of *cls*, then the new\n   instance\'s ``__init__()`` method will be invoked like\n   ``__init__(self[, ...])``, where *self* is the new instance and the\n   remaining arguments are the same as were passed to ``__new__()``.\n\n   If ``__new__()`` does not return an instance of *cls*, then the new\n   instance\'s ``__init__()`` method will not be invoked.\n\n   ``__new__()`` is intended mainly to allow subclasses of immutable\n   types (like int, str, or tuple) to customize instance creation.  It\n   is also commonly overridden in custom metaclasses in order to\n   customize class creation.\n\nobject.__init__(self[, ...])\n\n   Called when the instance is created.  The arguments are those\n   passed to the class constructor expression.  If a base class has an\n   ``__init__()`` method, the derived class\'s ``__init__()`` method,\n   if any, must explicitly call it to ensure proper initialization of\n   the base class part of the instance; for example:\n   ``BaseClass.__init__(self, [args...])``.  As a special constraint\n   on constructors, no value may be returned; doing so will cause a\n   ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n   Called when the instance is about to be destroyed.  This is also\n   called a destructor.  If a base class has a ``__del__()`` method,\n   the derived class\'s ``__del__()`` method, if any, must explicitly\n   call it to ensure proper deletion of the base class part of the\n   instance.  Note that it is possible (though not recommended!) for\n   the ``__del__()`` method to postpone destruction of the instance by\n   creating a new reference to it.  It may then be called at a later\n   time when this new reference is deleted.  It is not guaranteed that\n   ``__del__()`` methods are called for objects that still exist when\n   the interpreter exits.\n\n   Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n     decrements the reference count for ``x`` by one, and the latter\n     is only called when ``x``\'s reference count reaches zero.  Some\n     common situations that may prevent the reference count of an\n     object from going to zero include: circular references between\n     objects (e.g., a doubly-linked list or a tree data structure with\n     parent and child pointers); a reference to the object on the\n     stack frame of a function that caught an exception (the traceback\n     stored in ``sys.exc_info()[2]`` keeps the stack frame alive); or\n     a reference to the object on the stack frame that raised an\n     unhandled exception in interactive mode (the traceback stored in\n     ``sys.last_traceback`` keeps the stack frame alive).  The first\n     situation can only be remedied by explicitly breaking the cycles;\n     the latter two situations can be resolved by storing ``None`` in\n     ``sys.last_traceback``. Circular references which are garbage are\n     detected when the option cycle detector is enabled (it\'s on by\n     default), but can only be cleaned up if there are no Python-\n     level ``__del__()`` methods involved. Refer to the documentation\n     for the ``gc`` module for more information about how\n     ``__del__()`` methods are handled by the cycle detector,\n     particularly the description of the ``garbage`` value.\n\n   Warning: Due to the precarious circumstances under which ``__del__()``\n     methods are invoked, exceptions that occur during their execution\n     are ignored, and a warning is printed to ``sys.stderr`` instead.\n     Also, when ``__del__()`` is invoked in response to a module being\n     deleted (e.g., when execution of the program is done), other\n     globals referenced by the ``__del__()`` method may already have\n     been deleted or in the process of being torn down (e.g. the\n     import machinery shutting down).  For this reason, ``__del__()``\n     methods should do the absolute minimum needed to maintain\n     external invariants.  Starting with version 1.5, Python\n     guarantees that globals whose name begins with a single\n     underscore are deleted from their module before other globals are\n     deleted; if no other references to such globals exist, this may\n     help in assuring that imported modules are still available at the\n     time when the ``__del__()`` method is called.\n\nobject.__repr__(self)\n\n   Called by the ``repr()`` built-in function to compute the\n   "official" string representation of an object.  If at all possible,\n   this should look like a valid Python expression that could be used\n   to recreate an object with the same value (given an appropriate\n   environment).  If this is not possible, a string of the form\n   ``<...some useful description...>`` should be returned. The return\n   value must be a string object. If a class defines ``__repr__()``\n   but not ``__str__()``, then ``__repr__()`` is also used when an\n   "informal" string representation of instances of that class is\n   required.\n\n   This is typically used for debugging, so it is important that the\n   representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n   Called by the ``str()`` built-in function and by the ``print()``\n   function to compute the "informal" string representation of an\n   object.  This differs from ``__repr__()`` in that it does not have\n   to be a valid Python expression: a more convenient or concise\n   representation may be used instead. The return value must be a\n   string object.\n\nobject.__format__(self, format_spec)\n\n   Called by the ``format()`` built-in function (and by extension, the\n   ``format()`` method of class ``str``) to produce a "formatted"\n   string representation of an object. The ``format_spec`` argument is\n   a string that contains a description of the formatting options\n   desired. The interpretation of the ``format_spec`` argument is up\n   to the type implementing ``__format__()``, however most classes\n   will either delegate formatting to one of the built-in types, or\n   use a similar formatting option syntax.\n\n   See *Format Specification Mini-Language* for a description of the\n   standard formatting syntax.\n\n   The return value must be a string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n   These are the so-called "rich comparison" methods. The\n   correspondence between operator symbols and method names is as\n   follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n   ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` calls\n   ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls\n   ``x.__ge__(y)``.\n\n   A rich comparison method may return the singleton\n   ``NotImplemented`` if it does not implement the operation for a\n   given pair of arguments. By convention, ``False`` and ``True`` are\n   returned for a successful comparison. However, these methods can\n   return any value, so if the comparison operator is used in a\n   Boolean context (e.g., in the condition of an ``if`` statement),\n   Python will call ``bool()`` on the value to determine if the result\n   is true or false.\n\n   There are no implied relationships among the comparison operators.\n   The truth of ``x==y`` does not imply that ``x!=y`` is false.\n   Accordingly, when defining ``__eq__()``, one should also define\n   ``__ne__()`` so that the operators will behave as expected.  See\n   the paragraph on ``__hash__()`` for some important notes on\n   creating *hashable* objects which support custom comparison\n   operations and are usable as dictionary keys.\n\n   There are no swapped-argument versions of these methods (to be used\n   when the left argument does not support the operation but the right\n   argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n   other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n   reflection, and ``__eq__()`` and ``__ne__()`` are their own\n   reflection.\n\n   Arguments to rich comparison methods are never coerced.\n\n   To automatically generate ordering operations from a single root\n   operation, see ``functools.total_ordering()``.\n\nobject.__hash__(self)\n\n   Called by built-in function ``hash()`` and for operations on\n   members of hashed collections including ``set``, ``frozenset``, and\n   ``dict``.  ``__hash__()`` should return an integer.  The only\n   required property is that objects which compare equal have the same\n   hash value; it is advised to somehow mix together (e.g. using\n   exclusive or) the hash values for the components of the object that\n   also play a part in comparison of objects.\n\n   If a class does not define an ``__eq__()`` method it should not\n   define a ``__hash__()`` operation either; if it defines\n   ``__eq__()`` but not ``__hash__()``, its instances will not be\n   usable as items in hashable collections.  If a class defines\n   mutable objects and implements an ``__eq__()`` method, it should\n   not implement ``__hash__()``, since the implementation of hashable\n   collections requires that a key\'s hash value is immutable (if the\n   object\'s hash value changes, it will be in the wrong hash bucket).\n\n   User-defined classes have ``__eq__()`` and ``__hash__()`` methods\n   by default; with them, all objects compare unequal (except with\n   themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n   Classes which inherit a ``__hash__()`` method from a parent class\n   but change the meaning of ``__eq__()`` such that the hash value\n   returned is no longer appropriate (e.g. by switching to a value-\n   based concept of equality instead of the default identity based\n   equality) can explicitly flag themselves as being unhashable by\n   setting ``__hash__ = None`` in the class definition. Doing so means\n   that not only will instances of the class raise an appropriate\n   ``TypeError`` when a program attempts to retrieve their hash value,\n   but they will also be correctly identified as unhashable when\n   checking ``isinstance(obj, collections.Hashable)`` (unlike classes\n   which define their own ``__hash__()`` to explicitly raise\n   ``TypeError``).\n\n   If a class that overrides ``__eq__()`` needs to retain the\n   implementation of ``__hash__()`` from a parent class, the\n   interpreter must be told this explicitly by setting ``__hash__ =\n   <ParentClass>.__hash__``. Otherwise the inheritance of\n   ``__hash__()`` will be blocked, just as if ``__hash__`` had been\n   explicitly set to ``None``.\n\nobject.__bool__(self)\n\n   Called to implement truth value testing and the built-in operation\n   ``bool()``; should return ``False`` or ``True``.  When this method\n   is not defined, ``__len__()`` is called, if it is defined, and the\n   object is considered true if its result is nonzero.  If a class\n   defines neither ``__len__()`` nor ``__bool__()``, all its instances\n   are considered true.\n',
- 'debugger': '\n``pdb`` --- The Python Debugger\n*******************************\n\nThe module ``pdb`` defines an interactive source code debugger for\nPython programs.  It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame.  It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible -- it is actually defined as the class\n``Pdb``. This is currently undocumented but easily understood by\nreading the source.  The extension interface uses the modules ``bdb``\nand ``cmd``.\n\nThe debugger\'s prompt is ``(Pdb)``. Typical usage to run a program\nunder control of the debugger is:\n\n   >>> import pdb\n   >>> import mymodule\n   >>> pdb.run(\'mymodule.test()\')\n   > <string>(0)?()\n   (Pdb) continue\n   > <string>(1)?()\n   (Pdb) continue\n   NameError: \'spam\'\n   > <string>(1)?()\n   (Pdb)\n\n``pdb.py`` can also be invoked as a script to debug other scripts.\nFor example:\n\n   python3 -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally.  After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program.  Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 3.2: ``pdb.py`` now accepts a ``-c`` option that\nexecutes commands as if given in a ``.pdbrc`` file, see *Debugger\nCommands*.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n   import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger.  You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the ``continue`` command.\n\nThe typical usage to inspect a crashed program is:\n\n   >>> import pdb\n   >>> import mymodule\n   >>> mymodule.test()\n   Traceback (most recent call last):\n     File "<stdin>", line 1, in ?\n     File "./mymodule.py", line 4, in test\n       test2()\n     File "./mymodule.py", line 3, in test2\n       print(spam)\n   NameError: spam\n   >>> pdb.pm()\n   > ./mymodule.py(3)test2()\n   -> print(spam)\n   (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement, globals=None, locals=None)\n\n   Execute the *statement* (given as a string or a code object) under\n   debugger control.  The debugger prompt appears before any code is\n   executed; you can set breakpoints and type ``continue``, or you can\n   step through the statement using ``step`` or ``next`` (all these\n   commands are explained below).  The optional *globals* and *locals*\n   arguments specify the environment in which the code is executed; by\n   default the dictionary of the module ``__main__`` is used.  (See\n   the explanation of the built-in ``exec()`` or ``eval()``\n   functions.)\n\npdb.runeval(expression, globals=None, locals=None)\n\n   Evaluate the *expression* (given as a string or a code object)\n   under debugger control.  When ``runeval()`` returns, it returns the\n   value of the expression.  Otherwise this function is similar to\n   ``run()``.\n\npdb.runcall(function, *args, **kwds)\n\n   Call the *function* (a function or method object, not a string)\n   with the given arguments.  When ``runcall()`` returns, it returns\n   whatever the function call returned.  The debugger prompt appears\n   as soon as the function is entered.\n\npdb.set_trace()\n\n   Enter the debugger at the calling stack frame.  This is useful to\n   hard-code a breakpoint at a given point in a program, even if the\n   code is not otherwise being debugged (e.g. when an assertion\n   fails).\n\npdb.post_mortem(traceback=None)\n\n   Enter post-mortem debugging of the given *traceback* object.  If no\n   *traceback* is given, it uses the one of the exception that is\n   currently being handled (an exception must be being handled if the\n   default is to be used).\n\npdb.pm()\n\n   Enter post-mortem debugging of the traceback found in\n   ``sys.last_traceback``.\n\nThe ``run_*`` functions and ``set_trace()`` are aliases for\ninstantiating the ``Pdb`` class and calling the method of the same\nname.  If you want to access further features, you have to do this\nyourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None)\n\n   ``Pdb`` is the debugger class.\n\n   The *completekey*, *stdin* and *stdout* arguments are passed to the\n   underlying ``cmd.Cmd`` class; see the description there.\n\n   The *skip* argument, if given, must be an iterable of glob-style\n   module name patterns.  The debugger will not step into frames that\n   originate in a module that matches one of these patterns. [1]\n\n   Example call to enable tracing with *skip*:\n\n      import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n   New in version 3.1: The *skip* argument.\n\n   run(statement, globals=None, locals=None)\n   runeval(expression, globals=None, locals=None)\n   runcall(function, *args, **kwds)\n   set_trace()\n\n      See the documentation for the functions explained above.\n\n\nDebugger Commands\n=================\n\nThe commands recognized by the debugger are listed below.  Most\ncommands can be abbreviated to one or two letters as indicated; e.g.\n``h(elp)`` means that either ``h`` or ``help`` can be used to enter\nthe help command (but not ``he`` or ``hel``, nor ``H`` or ``Help`` or\n``HELP``).  Arguments to commands must be separated by whitespace\n(spaces or tabs).  Optional arguments are enclosed in square brackets\n(``[]``) in the command syntax; the square brackets must not be typed.\nAlternatives in the command syntax are separated by a vertical bar\n(``|``).\n\nEntering a blank line repeats the last command entered.  Exception: if\nthe last command was a ``list`` command, the next 11 lines are listed.\n\nCommands that the debugger doesn\'t recognize are assumed to be Python\nstatements and are executed in the context of the program being\ndebugged.  Python statements can also be prefixed with an exclamation\npoint (``!``).  This is a powerful way to inspect the program being\ndebugged; it is even possible to change a variable or call a function.\nWhen an exception occurs in such a statement, the exception name is\nprinted but the debugger\'s state is not changed.\n\nThe debugger supports *aliases*.  Aliases can have parameters which\nallows one a certain level of adaptability to the context under\nexamination.\n\nMultiple commands may be entered on a single line, separated by\n``;;``.  (A single ``;`` is not used as it is the separator for\nmultiple commands in a line that is passed to the Python parser.)  No\nintelligence is applied to separating the commands; the input is split\nat the first ``;;`` pair, even if it is in the middle of a quoted\nstring.\n\nIf a file ``.pdbrc`` exists in the user\'s home directory or in the\ncurrent directory, it is read in and executed as if it had been typed\nat the debugger prompt.  This is particularly useful for aliases.  If\nboth files exist, the one in the home directory is read first and\naliases defined there can be overridden by the local file.\n\nChanged in version 3.2: ``.pdbrc`` can now contain commands that\ncontinue debugging, such as ``continue`` or ``next``.  Previously,\nthese commands had no effect.\n\nh(elp) [command]\n\n   Without argument, print the list of available commands.  With a\n   *command* as argument, print help about that command.  ``help pdb``\n   displays the full documentation (the docstring of the ``pdb``\n   module).  Since the *command* argument must be an identifier,\n   ``help exec`` must be entered to get help on the ``!`` command.\n\nw(here)\n\n   Print a stack trace, with the most recent frame at the bottom.  An\n   arrow indicates the current frame, which determines the context of\n   most commands.\n\nd(own) [count]\n\n   Move the current frame *count* (default one) levels down in the\n   stack trace (to a newer frame).\n\nu(p) [count]\n\n   Move the current frame *count* (default one) levels up in the stack\n   trace (to an older frame).\n\nb(reak) [([filename:]lineno | function) [, condition]]\n\n   With a *lineno* argument, set a break there in the current file.\n   With a *function* argument, set a break at the first executable\n   statement within that function.  The line number may be prefixed\n   with a filename and a colon, to specify a breakpoint in another\n   file (probably one that hasn\'t been loaded yet).  The file is\n   searched on ``sys.path``.  Note that each breakpoint is assigned a\n   number to which all the other breakpoint commands refer.\n\n   If a second argument is present, it is an expression which must\n   evaluate to true before the breakpoint is honored.\n\n   Without argument, list all breaks, including for each breakpoint,\n   the number of times that breakpoint has been hit, the current\n   ignore count, and the associated condition if any.\n\ntbreak [([filename:]lineno | function) [, condition]]\n\n   Temporary breakpoint, which is removed automatically when it is\n   first hit. The arguments are the same as for ``break``.\n\ncl(ear) [bpnumber [bpnumber ...]]\n\n   With a space separated list of breakpoint numbers, clear those\n   breakpoints. Without argument, clear all breaks (but first ask\n   confirmation).\n\ndisable [bpnumber [bpnumber ...]]\n\n   Disable the breakpoints given as a space separated list of\n   breakpoint numbers.  Disabling a breakpoint means it cannot cause\n   the program to stop execution, but unlike clearing a breakpoint, it\n   remains in the list of breakpoints and can be (re-)enabled.\n\nenable [bpnumber [bpnumber ...]]\n\n   Enable the breakpoints specified.\n\nignore bpnumber [count]\n\n   Set the ignore count for the given breakpoint number.  If count is\n   omitted, the ignore count is set to 0.  A breakpoint becomes active\n   when the ignore count is zero.  When non-zero, the count is\n   decremented each time the breakpoint is reached and the breakpoint\n   is not disabled and any associated condition evaluates to true.\n\ncondition bpnumber [condition]\n\n   Set a new *condition* for the breakpoint, an expression which must\n   evaluate to true before the breakpoint is honored.  If *condition*\n   is absent, any existing condition is removed; i.e., the breakpoint\n   is made unconditional.\n\ncommands [bpnumber]\n\n   Specify a list of commands for breakpoint number *bpnumber*.  The\n   commands themselves appear on the following lines.  Type a line\n   containing just ``end`` to terminate the commands. An example:\n\n      (Pdb) commands 1\n      (com) print some_variable\n      (com) end\n      (Pdb)\n\n   To remove all commands from a breakpoint, type commands and follow\n   it immediately with ``end``; that is, give no commands.\n\n   With no *bpnumber* argument, commands refers to the last breakpoint\n   set.\n\n   You can use breakpoint commands to start your program up again.\n   Simply use the continue command, or step, or any other command that\n   resumes execution.\n\n   Specifying any command resuming execution (currently continue,\n   step, next, return, jump, quit and their abbreviations) terminates\n   the command list (as if that command was immediately followed by\n   end). This is because any time you resume execution (even with a\n   simple next or step), you may encounter another breakpoint--which\n   could have its own command list, leading to ambiguities about which\n   list to execute.\n\n   If you use the \'silent\' command in the command list, the usual\n   message about stopping at a breakpoint is not printed.  This may be\n   desirable for breakpoints that are to print a specific message and\n   then continue.  If none of the other commands print anything, you\n   see no sign that the breakpoint was reached.\n\ns(tep)\n\n   Execute the current line, stop at the first possible occasion\n   (either in a function that is called or on the next line in the\n   current function).\n\nn(ext)\n\n   Continue execution until the next line in the current function is\n   reached or it returns.  (The difference between ``next`` and\n   ``step`` is that ``step`` stops inside a called function, while\n   ``next`` executes called functions at (nearly) full speed, only\n   stopping at the next line in the current function.)\n\nunt(il) [lineno]\n\n   Without argument, continue execution until the line with a number\n   greater than the current one is reached.\n\n   With a line number, continue execution until a line with a number\n   greater or equal to that is reached.  In both cases, also stop when\n   the current frame returns.\n\n   Changed in version 3.2: Allow giving an explicit line number.\n\nr(eturn)\n\n   Continue execution until the current function returns.\n\nc(ont(inue))\n\n   Continue execution, only stop when a breakpoint is encountered.\n\nj(ump) lineno\n\n   Set the next line that will be executed.  Only available in the\n   bottom-most frame.  This lets you jump back and execute code again,\n   or jump forward to skip code that you don\'t want to run.\n\n   It should be noted that not all jumps are allowed -- for instance\n   it is not possible to jump into the middle of a ``for`` loop or out\n   of a ``finally`` clause.\n\nl(ist) [first[, last]]\n\n   List source code for the current file.  Without arguments, list 11\n   lines around the current line or continue the previous listing.\n   With ``.`` as argument, list 11 lines around the current line.\n   With one argument, list 11 lines around at that line.  With two\n   arguments, list the given range; if the second argument is less\n   than the first, it is interpreted as a count.\n\n   The current line in the current frame is indicated by ``->``.  If\n   an exception is being debugged, the line where the exception was\n   originally raised or propagated is indicated by ``>>``, if it\n   differs from the current line.\n\n   New in version 3.2: The ``>>`` marker.\n\nll | longlist\n\n   List all source code for the current function or frame.\n   Interesting lines are marked as for ``list``.\n\n   New in version 3.2.\n\na(rgs)\n\n   Print the argument list of the current function.\n\np(rint) expression\n\n   Evaluate the *expression* in the current context and print its\n   value.\n\npp expression\n\n   Like the ``print`` command, except the value of the expression is\n   pretty-printed using the ``pprint`` module.\n\nwhatis expression\n\n   Print the type of the *expression*.\n\nsource expression\n\n   Try to get source code for the given object and display it.\n\n   New in version 3.2.\n\nalias [name [command]]\n\n   Create an alias called *name* that executes *command*.  The command\n   must *not* be enclosed in quotes.  Replaceable parameters can be\n   indicated by ``%1``, ``%2``, and so on, while ``%*`` is replaced by\n   all the parameters. If no command is given, the current alias for\n   *name* is shown. If no arguments are given, all aliases are listed.\n\n   Aliases may be nested and can contain anything that can be legally\n   typed at the pdb prompt.  Note that internal pdb commands *can* be\n   overridden by aliases.  Such a command is then hidden until the\n   alias is removed.  Aliasing is recursively applied to the first\n   word of the command line; all other words in the line are left\n   alone.\n\n   As an example, here are two useful aliases (especially when placed\n   in the ``.pdbrc`` file):\n\n      # Print instance variables (usage "pi classInst")\n      alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])\n      # Print instance variables in self\n      alias ps pi self\n\nunalias name\n\n   Delete the specified alias.\n\n! statement\n\n   Execute the (one-line) *statement* in the context of the current\n   stack frame. The exclamation point can be omitted unless the first\n   word of the statement resembles a debugger command.  To set a\n   global variable, you can prefix the assignment command with a\n   ``global`` statement on the same line, e.g.:\n\n      (Pdb) global list_options; list_options = [\'-l\']\n      (Pdb)\n\nrun [args ...]\nrestart [args ...]\n\n   Restart the debugged Python program.  If an argument is supplied,\n   it is split with ``shlex`` and the result is used as the new\n   ``sys.argv``. History, breakpoints, actions and debugger options\n   are preserved. ``restart`` is an alias for ``run``.\n\nq(uit)\n\n   Quit from the debugger.  The program being executed is aborted.\n\n-[ Footnotes ]-\n\n[1] Whether a frame is considered to originate in a certain module is\n    determined by the ``__name__`` in the frame globals.\n',
+ 'debugger': '\n``pdb`` --- The Python Debugger\n*******************************\n\nThe module ``pdb`` defines an interactive source code debugger for\nPython programs.  It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame.  It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible -- it is actually defined as the class\n``Pdb``. This is currently undocumented but easily understood by\nreading the source.  The extension interface uses the modules ``bdb``\nand ``cmd``.\n\nThe debugger\'s prompt is ``(Pdb)``. Typical usage to run a program\nunder control of the debugger is:\n\n   >>> import pdb\n   >>> import mymodule\n   >>> pdb.run(\'mymodule.test()\')\n   > <string>(0)?()\n   (Pdb) continue\n   > <string>(1)?()\n   (Pdb) continue\n   NameError: \'spam\'\n   > <string>(1)?()\n   (Pdb)\n\n``pdb.py`` can also be invoked as a script to debug other scripts.\nFor example:\n\n   python3 -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally.  After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program.  Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 3.2: ``pdb.py`` now accepts a ``-c`` option that\nexecutes commands as if given in a ``.pdbrc`` file, see *Debugger\nCommands*.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n   import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger.  You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the ``continue`` command.\n\nThe typical usage to inspect a crashed program is:\n\n   >>> import pdb\n   >>> import mymodule\n   >>> mymodule.test()\n   Traceback (most recent call last):\n     File "<stdin>", line 1, in ?\n     File "./mymodule.py", line 4, in test\n       test2()\n     File "./mymodule.py", line 3, in test2\n       print(spam)\n   NameError: spam\n   >>> pdb.pm()\n   > ./mymodule.py(3)test2()\n   -> print(spam)\n   (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement, globals=None, locals=None)\n\n   Execute the *statement* (given as a string or a code object) under\n   debugger control.  The debugger prompt appears before any code is\n   executed; you can set breakpoints and type ``continue``, or you can\n   step through the statement using ``step`` or ``next`` (all these\n   commands are explained below).  The optional *globals* and *locals*\n   arguments specify the environment in which the code is executed; by\n   default the dictionary of the module ``__main__`` is used.  (See\n   the explanation of the built-in ``exec()`` or ``eval()``\n   functions.)\n\npdb.runeval(expression, globals=None, locals=None)\n\n   Evaluate the *expression* (given as a string or a code object)\n   under debugger control.  When ``runeval()`` returns, it returns the\n   value of the expression.  Otherwise this function is similar to\n   ``run()``.\n\npdb.runcall(function, *args, **kwds)\n\n   Call the *function* (a function or method object, not a string)\n   with the given arguments.  When ``runcall()`` returns, it returns\n   whatever the function call returned.  The debugger prompt appears\n   as soon as the function is entered.\n\npdb.set_trace()\n\n   Enter the debugger at the calling stack frame.  This is useful to\n   hard-code a breakpoint at a given point in a program, even if the\n   code is not otherwise being debugged (e.g. when an assertion\n   fails).\n\npdb.post_mortem(traceback=None)\n\n   Enter post-mortem debugging of the given *traceback* object.  If no\n   *traceback* is given, it uses the one of the exception that is\n   currently being handled (an exception must be being handled if the\n   default is to be used).\n\npdb.pm()\n\n   Enter post-mortem debugging of the traceback found in\n   ``sys.last_traceback``.\n\nThe ``run_*`` functions and ``set_trace()`` are aliases for\ninstantiating the ``Pdb`` class and calling the method of the same\nname.  If you want to access further features, you have to do this\nyourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None, nosigint=False)\n\n   ``Pdb`` is the debugger class.\n\n   The *completekey*, *stdin* and *stdout* arguments are passed to the\n   underlying ``cmd.Cmd`` class; see the description there.\n\n   The *skip* argument, if given, must be an iterable of glob-style\n   module name patterns.  The debugger will not step into frames that\n   originate in a module that matches one of these patterns. [1]\n\n   By default, Pdb sets a handler for the SIGINT signal (which is sent\n   when the user presses Ctrl-C on the console) when you give a\n   ``continue`` command. This allows you to break into the debugger\n   again by pressing Ctrl-C.  If you want Pdb not to touch the SIGINT\n   handler, set *nosigint* tot true.\n\n   Example call to enable tracing with *skip*:\n\n      import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n   New in version 3.1: The *skip* argument.\n\n   New in version 3.2: The *nosigint* argument.  Previously, a SIGINT\n   handler was never set by Pdb.\n\n   run(statement, globals=None, locals=None)\n   runeval(expression, globals=None, locals=None)\n   runcall(function, *args, **kwds)\n   set_trace()\n\n      See the documentation for the functions explained above.\n\n\nDebugger Commands\n=================\n\nThe commands recognized by the debugger are listed below.  Most\ncommands can be abbreviated to one or two letters as indicated; e.g.\n``h(elp)`` means that either ``h`` or ``help`` can be used to enter\nthe help command (but not ``he`` or ``hel``, nor ``H`` or ``Help`` or\n``HELP``).  Arguments to commands must be separated by whitespace\n(spaces or tabs).  Optional arguments are enclosed in square brackets\n(``[]``) in the command syntax; the square brackets must not be typed.\nAlternatives in the command syntax are separated by a vertical bar\n(``|``).\n\nEntering a blank line repeats the last command entered.  Exception: if\nthe last command was a ``list`` command, the next 11 lines are listed.\n\nCommands that the debugger doesn\'t recognize are assumed to be Python\nstatements and are executed in the context of the program being\ndebugged.  Python statements can also be prefixed with an exclamation\npoint (``!``).  This is a powerful way to inspect the program being\ndebugged; it is even possible to change a variable or call a function.\nWhen an exception occurs in such a statement, the exception name is\nprinted but the debugger\'s state is not changed.\n\nThe debugger supports *aliases*.  Aliases can have parameters which\nallows one a certain level of adaptability to the context under\nexamination.\n\nMultiple commands may be entered on a single line, separated by\n``;;``.  (A single ``;`` is not used as it is the separator for\nmultiple commands in a line that is passed to the Python parser.)  No\nintelligence is applied to separating the commands; the input is split\nat the first ``;;`` pair, even if it is in the middle of a quoted\nstring.\n\nIf a file ``.pdbrc`` exists in the user\'s home directory or in the\ncurrent directory, it is read in and executed as if it had been typed\nat the debugger prompt.  This is particularly useful for aliases.  If\nboth files exist, the one in the home directory is read first and\naliases defined there can be overridden by the local file.\n\nChanged in version 3.2: ``.pdbrc`` can now contain commands that\ncontinue debugging, such as ``continue`` or ``next``.  Previously,\nthese commands had no effect.\n\nh(elp) [command]\n\n   Without argument, print the list of available commands.  With a\n   *command* as argument, print help about that command.  ``help pdb``\n   displays the full documentation (the docstring of the ``pdb``\n   module).  Since the *command* argument must be an identifier,\n   ``help exec`` must be entered to get help on the ``!`` command.\n\nw(here)\n\n   Print a stack trace, with the most recent frame at the bottom.  An\n   arrow indicates the current frame, which determines the context of\n   most commands.\n\nd(own) [count]\n\n   Move the current frame *count* (default one) levels down in the\n   stack trace (to a newer frame).\n\nu(p) [count]\n\n   Move the current frame *count* (default one) levels up in the stack\n   trace (to an older frame).\n\nb(reak) [([filename:]lineno | function) [, condition]]\n\n   With a *lineno* argument, set a break there in the current file.\n   With a *function* argument, set a break at the first executable\n   statement within that function.  The line number may be prefixed\n   with a filename and a colon, to specify a breakpoint in another\n   file (probably one that hasn\'t been loaded yet).  The file is\n   searched on ``sys.path``.  Note that each breakpoint is assigned a\n   number to which all the other breakpoint commands refer.\n\n   If a second argument is present, it is an expression which must\n   evaluate to true before the breakpoint is honored.\n\n   Without argument, list all breaks, including for each breakpoint,\n   the number of times that breakpoint has been hit, the current\n   ignore count, and the associated condition if any.\n\ntbreak [([filename:]lineno | function) [, condition]]\n\n   Temporary breakpoint, which is removed automatically when it is\n   first hit. The arguments are the same as for ``break``.\n\ncl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n\n   With a *filename:lineno* argument, clear all the breakpoints at\n   this line. With a space separated list of breakpoint numbers, clear\n   those breakpoints. Without argument, clear all breaks (but first\n   ask confirmation).\n\ndisable [bpnumber [bpnumber ...]]\n\n   Disable the breakpoints given as a space separated list of\n   breakpoint numbers.  Disabling a breakpoint means it cannot cause\n   the program to stop execution, but unlike clearing a breakpoint, it\n   remains in the list of breakpoints and can be (re-)enabled.\n\nenable [bpnumber [bpnumber ...]]\n\n   Enable the breakpoints specified.\n\nignore bpnumber [count]\n\n   Set the ignore count for the given breakpoint number.  If count is\n   omitted, the ignore count is set to 0.  A breakpoint becomes active\n   when the ignore count is zero.  When non-zero, the count is\n   decremented each time the breakpoint is reached and the breakpoint\n   is not disabled and any associated condition evaluates to true.\n\ncondition bpnumber [condition]\n\n   Set a new *condition* for the breakpoint, an expression which must\n   evaluate to true before the breakpoint is honored.  If *condition*\n   is absent, any existing condition is removed; i.e., the breakpoint\n   is made unconditional.\n\ncommands [bpnumber]\n\n   Specify a list of commands for breakpoint number *bpnumber*.  The\n   commands themselves appear on the following lines.  Type a line\n   containing just ``end`` to terminate the commands. An example:\n\n      (Pdb) commands 1\n      (com) print some_variable\n      (com) end\n      (Pdb)\n\n   To remove all commands from a breakpoint, type commands and follow\n   it immediately with ``end``; that is, give no commands.\n\n   With no *bpnumber* argument, commands refers to the last breakpoint\n   set.\n\n   You can use breakpoint commands to start your program up again.\n   Simply use the continue command, or step, or any other command that\n   resumes execution.\n\n   Specifying any command resuming execution (currently continue,\n   step, next, return, jump, quit and their abbreviations) terminates\n   the command list (as if that command was immediately followed by\n   end). This is because any time you resume execution (even with a\n   simple next or step), you may encounter another breakpoint--which\n   could have its own command list, leading to ambiguities about which\n   list to execute.\n\n   If you use the \'silent\' command in the command list, the usual\n   message about stopping at a breakpoint is not printed.  This may be\n   desirable for breakpoints that are to print a specific message and\n   then continue.  If none of the other commands print anything, you\n   see no sign that the breakpoint was reached.\n\ns(tep)\n\n   Execute the current line, stop at the first possible occasion\n   (either in a function that is called or on the next line in the\n   current function).\n\nn(ext)\n\n   Continue execution until the next line in the current function is\n   reached or it returns.  (The difference between ``next`` and\n   ``step`` is that ``step`` stops inside a called function, while\n   ``next`` executes called functions at (nearly) full speed, only\n   stopping at the next line in the current function.)\n\nunt(il) [lineno]\n\n   Without argument, continue execution until the line with a number\n   greater than the current one is reached.\n\n   With a line number, continue execution until a line with a number\n   greater or equal to that is reached.  In both cases, also stop when\n   the current frame returns.\n\n   Changed in version 3.2: Allow giving an explicit line number.\n\nr(eturn)\n\n   Continue execution until the current function returns.\n\nc(ont(inue))\n\n   Continue execution, only stop when a breakpoint is encountered.\n\nj(ump) lineno\n\n   Set the next line that will be executed.  Only available in the\n   bottom-most frame.  This lets you jump back and execute code again,\n   or jump forward to skip code that you don\'t want to run.\n\n   It should be noted that not all jumps are allowed -- for instance\n   it is not possible to jump into the middle of a ``for`` loop or out\n   of a ``finally`` clause.\n\nl(ist) [first[, last]]\n\n   List source code for the current file.  Without arguments, list 11\n   lines around the current line or continue the previous listing.\n   With ``.`` as argument, list 11 lines around the current line.\n   With one argument, list 11 lines around at that line.  With two\n   arguments, list the given range; if the second argument is less\n   than the first, it is interpreted as a count.\n\n   The current line in the current frame is indicated by ``->``.  If\n   an exception is being debugged, the line where the exception was\n   originally raised or propagated is indicated by ``>>``, if it\n   differs from the current line.\n\n   New in version 3.2: The ``>>`` marker.\n\nll | longlist\n\n   List all source code for the current function or frame.\n   Interesting lines are marked as for ``list``.\n\n   New in version 3.2.\n\na(rgs)\n\n   Print the argument list of the current function.\n\np(rint) expression\n\n   Evaluate the *expression* in the current context and print its\n   value.\n\npp expression\n\n   Like the ``print`` command, except the value of the expression is\n   pretty-printed using the ``pprint`` module.\n\nwhatis expression\n\n   Print the type of the *expression*.\n\nsource expression\n\n   Try to get source code for the given object and display it.\n\n   New in version 3.2.\n\ndisplay [expression]\n\n   Display the value of the expression if it changed, each time\n   execution stops in the current frame.\n\n   Without expression, list all display expressions for the current\n   frame.\n\n   New in version 3.2.\n\nundisplay [expression]\n\n   Do not display the expression any more in the current frame.\n   Without expression, clear all display expressions for the current\n   frame.\n\n   New in version 3.2.\n\ninteract\n\n   Start an interative interpreter (using the ``code`` module) whose\n   global namespace contains all the (global and local) names found in\n   the current scope.\n\n   New in version 3.2.\n\nalias [name [command]]\n\n   Create an alias called *name* that executes *command*.  The command\n   must *not* be enclosed in quotes.  Replaceable parameters can be\n   indicated by ``%1``, ``%2``, and so on, while ``%*`` is replaced by\n   all the parameters. If no command is given, the current alias for\n   *name* is shown. If no arguments are given, all aliases are listed.\n\n   Aliases may be nested and can contain anything that can be legally\n   typed at the pdb prompt.  Note that internal pdb commands *can* be\n   overridden by aliases.  Such a command is then hidden until the\n   alias is removed.  Aliasing is recursively applied to the first\n   word of the command line; all other words in the line are left\n   alone.\n\n   As an example, here are two useful aliases (especially when placed\n   in the ``.pdbrc`` file):\n\n      # Print instance variables (usage "pi classInst")\n      alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])\n      # Print instance variables in self\n      alias ps pi self\n\nunalias name\n\n   Delete the specified alias.\n\n! statement\n\n   Execute the (one-line) *statement* in the context of the current\n   stack frame. The exclamation point can be omitted unless the first\n   word of the statement resembles a debugger command.  To set a\n   global variable, you can prefix the assignment command with a\n   ``global`` statement on the same line, e.g.:\n\n      (Pdb) global list_options; list_options = [\'-l\']\n      (Pdb)\n\nrun [args ...]\nrestart [args ...]\n\n   Restart the debugged Python program.  If an argument is supplied,\n   it is split with ``shlex`` and the result is used as the new\n   ``sys.argv``. History, breakpoints, actions and debugger options\n   are preserved. ``restart`` is an alias for ``run``.\n\nq(uit)\n\n   Quit from the debugger.  The program being executed is aborted.\n\n-[ Footnotes ]-\n\n[1] Whether a frame is considered to originate in a certain module is\n    determined by the ``__name__`` in the frame globals.\n',
  'del': '\nThe ``del`` statement\n*********************\n\n   del_stmt ::= "del" target_list\n\nDeletion is recursively defined very similar to the way assignment is\ndefined. Rather that spelling it out in full details, here are some\nhints.\n\nDeletion of a target list recursively deletes each target, from left\nto right.\n\nDeletion of a name removes the binding of that name from the local or\nglobal namespace, depending on whether the name occurs in a ``global``\nstatement in the same code block.  If the name is unbound, a\n``NameError`` exception will be raised.\n\nDeletion of attribute references, subscriptions and slicings is passed\nto the primary object involved; deletion of a slicing is in general\nequivalent to assignment of an empty slice of the right type (but even\nthis is determined by the sliced object).\n\nChanged in version 3.2.\n',
  'dict': '\nDictionary displays\n*******************\n\nA dictionary display is a possibly empty series of key/datum pairs\nenclosed in curly braces:\n\n   dict_display       ::= "{" [key_datum_list | dict_comprehension] "}"\n   key_datum_list     ::= key_datum ("," key_datum)* [","]\n   key_datum          ::= expression ":" expression\n   dict_comprehension ::= expression ":" expression comp_for\n\nA dictionary display yields a new dictionary object.\n\nIf a comma-separated sequence of key/datum pairs is given, they are\nevaluated from left to right to define the entries of the dictionary:\neach key object is used as a key into the dictionary to store the\ncorresponding datum.  This means that you can specify the same key\nmultiple times in the key/datum list, and the final dictionary\'s value\nfor that key will be the last one given.\n\nA dict comprehension, in contrast to list and set comprehensions,\nneeds two expressions separated with a colon followed by the usual\n"for" and "if" clauses. When the comprehension is run, the resulting\nkey and value elements are inserted in the new dictionary in the order\nthey are produced.\n\nRestrictions on the types of the key values are listed earlier in\nsection *The standard type hierarchy*.  (To summarize, the key type\nshould be *hashable*, which excludes all mutable objects.)  Clashes\nbetween duplicate keys are not detected; the last datum (textually\nrightmost in the display) stored for a given key value prevails.\n',
  'dynamic-features': '\nInteraction with dynamic features\n*********************************\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name.  An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nThe ``eval()`` and ``exec()`` functions do not have access to the full\nenvironment for resolving names.  Names may be resolved in the local\nand global namespaces of the caller.  Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace.  [1]\nThe ``exec()`` and ``eval()`` functions have optional arguments to\noverride the global and local namespace.  If only one namespace is\nspecified, it is used for both.\n',
@@ -33,14 +33,14 @@
  'exprlists': '\nExpression lists\n****************\n\n   expression_list ::= expression ( "," expression )* [","]\n\nAn expression list containing at least one comma yields a tuple.  The\nlength of the tuple is the number of expressions in the list.  The\nexpressions are evaluated from left to right.\n\nThe trailing comma is required only to create a single tuple (a.k.a. a\n*singleton*); it is optional in all other cases.  A single expression\nwithout a trailing comma doesn\'t create a tuple, but rather yields the\nvalue of that expression. (To create an empty tuple, use an empty pair\nof parentheses: ``()``.)\n',
  'floating': '\nFloating point literals\n***********************\n\nFloating point literals are described by the following lexical\ndefinitions:\n\n   floatnumber   ::= pointfloat | exponentfloat\n   pointfloat    ::= [intpart] fraction | intpart "."\n   exponentfloat ::= (intpart | pointfloat) exponent\n   intpart       ::= digit+\n   fraction      ::= "." digit+\n   exponent      ::= ("e" | "E") ["+" | "-"] digit+\n\nNote that the integer and exponent parts are always interpreted using\nradix 10. For example, ``077e010`` is legal, and denotes the same\nnumber as ``77e10``. The allowed range of floating point literals is\nimplementation-dependent. Some examples of floating point literals:\n\n   3.14    10.    .001    1e100    3.14e-10    0e0\n\nNote that numeric literals do not include a sign; a phrase like ``-1``\nis actually an expression composed of the unary operator ``-`` and the\nliteral ``1``.\n',
  'for': '\nThe ``for`` statement\n*********************\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n   for_stmt ::= "for" target_list "in" expression_list ":" suite\n                ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject.  An iterator is created for the result of the\n``expression_list``.  The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices.  Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted.  When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a ``StopIteration``\nexception), the suite in the ``else`` clause, if present, is executed,\nand the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite.  A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, it will not have been assigned to at all\nby the loop.  Hint: the built-in function ``range()`` returns an\niterator of integers suitable to emulate the effect of Pascal\'s ``for\ni := a to b do``; e.g., ``list(range(3))`` returns the list ``[0, 1,\n2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n  (this can only occur for mutable sequences, i.e. lists).  An\n  internal counter is used to keep track of which item is used next,\n  and this is incremented on each iteration.  When this counter has\n  reached the length of the sequence the loop terminates.  This means\n  that if the suite deletes the current (or a previous) item from the\n  sequence, the next item will be skipped (since it gets the index of\n  the current item which has already been treated).  Likewise, if the\n  suite inserts an item in the sequence before the current item, the\n  current item will be treated again the next time through the loop.\n  This can lead to nasty bugs that can be avoided by making a\n  temporary copy using a slice of the whole sequence, e.g.,\n\n     for x in a[:]:\n         if x < 0: a.remove(x)\n',
- 'formatstrings': '\nFormat String Syntax\n********************\n\nThe ``str.format()`` method and the ``Formatter`` class share the same\nsyntax for format strings (although in the case of ``Formatter``,\nsubclasses can define their own format string syntax).\n\nFormat strings contain "replacement fields" surrounded by curly braces\n``{}``. Anything that is not contained in braces is considered literal\ntext, which is copied unchanged to the output.  If you need to include\na brace character in the literal text, it can be escaped by doubling:\n``{{`` and ``}}``.\n\nThe grammar for a replacement field is as follows:\n\n      replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"\n      field_name        ::= arg_name ("." attribute_name | "[" element_index "]")*\n      arg_name          ::= [identifier | integer]\n      attribute_name    ::= identifier\n      element_index     ::= integer | index_string\n      index_string      ::= <any source character except "]"> +\n      conversion        ::= "r" | "s" | "a"\n      format_spec       ::= <described in the next section>\n\nIn less formal terms, the replacement field can start with a\n*field_name* that specifies the object whose value is to be formatted\nand inserted into the output instead of the replacement field. The\n*field_name* is optionally followed by a  *conversion* field, which is\npreceded by an exclamation point ``\'!\'``, and a *format_spec*, which\nis preceded by a colon ``\':\'``.  These specify a non-default format\nfor the replacement value.\n\nSee also the *Format Specification Mini-Language* section.\n\nThe *field_name* itself begins with an *arg_name* that is either\neither a number or a keyword.  If it\'s a number, it refers to a\npositional argument, and if it\'s a keyword, it refers to a named\nkeyword argument.  If the numerical arg_names in a format string are\n0, 1, 2, ... in sequence, they can all be omitted (not just some) and\nthe numbers 0, 1, 2, ... will be automatically inserted in that order.\nThe *arg_name* can be followed by any number of index or attribute\nexpressions. An expression of the form ``\'.name\'`` selects the named\nattribute using ``getattr()``, while an expression of the form\n``\'[index]\'`` does an index lookup using ``__getitem__()``.\n\nChanged in version 3.1: The positional argument specifiers can be\nomitted, so ``\'{} {}\'`` is equivalent to ``\'{0} {1}\'``.\n\nSome simple format string examples:\n\n   "First, thou shalt count to {0}" # References first positional argument\n   "Bring me a {}"                  # Implicitly references the first positional argument\n   "From {} to {}"                  # Same as "From {0} to {1}"\n   "My quest is {name}"             # References keyword argument \'name\'\n   "Weight in tons {0.weight}"      # \'weight\' attribute of first positional arg\n   "Units destroyed: {players[0]}"  # First element of keyword argument \'players\'.\n\nThe *conversion* field causes a type coercion before formatting.\nNormally, the job of formatting a value is done by the\n``__format__()`` method of the value itself.  However, in some cases\nit is desirable to force a type to be formatted as a string,\noverriding its own definition of formatting.  By converting the value\nto a string before calling ``__format__()``, the normal formatting\nlogic is bypassed.\n\nThree conversion flags are currently supported: ``\'!s\'`` which calls\n``str()`` on the value, ``\'!r\'`` which calls ``repr()`` and ``\'!a\'``\nwhich calls ``ascii()``.\n\nSome examples:\n\n   "Harold\'s a clever {0!s}"        # Calls str() on the argument first\n   "Bring out the holy {name!r}"    # Calls repr() on the argument first\n   "More {!a}"                      # Calls ascii() on the argument first\n\nThe *format_spec* field contains a specification of how the value\nshould be presented, including such details as field width, alignment,\npadding, decimal precision and so on.  Each value type can define its\nown "formatting mini-language" or interpretation of the *format_spec*.\n\nMost built-in types support a common formatting mini-language, which\nis described in the next section.\n\nA *format_spec* field can also include nested replacement fields\nwithin it. These nested replacement fields can contain only a field\nname; conversion flags and format specifications are not allowed.  The\nreplacement fields within the format_spec are substituted before the\n*format_spec* string is interpreted. This allows the formatting of a\nvalue to be dynamically specified.\n\nSee the *Format examples* section for some examples.\n\n\nFormat Specification Mini-Language\n==================================\n\n"Format specifications" are used within replacement fields contained\nwithin a format string to define how individual values are presented\n(see *Format String Syntax*).  They can also be passed directly to the\nbuilt-in ``format()`` function.  Each formattable type may define how\nthe format specification is to be interpreted.\n\nMost built-in types implement the following options for format\nspecifications, although some of the formatting options are only\nsupported by the numeric types.\n\nA general convention is that an empty format string (``""``) produces\nthe same result as if you had called ``str()`` on the value. A non-\nempty format string typically modifies the result.\n\nThe general form of a *standard format specifier* is:\n\n   format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]\n   fill        ::= <a character other than \'}\'>\n   align       ::= "<" | ">" | "=" | "^"\n   sign        ::= "+" | "-" | " "\n   width       ::= integer\n   precision   ::= integer\n   type        ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n\nThe *fill* character can be any character other than \'{\' or \'}\'.  The\npresence of a fill character is signaled by the character following\nit, which must be one of the alignment options.  If the second\ncharacter of *format_spec* is not a valid alignment option, then it is\nassumed that both the fill character and the alignment option are\nabsent.\n\nThe meaning of the various alignment options is as follows:\n\n   +-----------+------------------------------------------------------------+\n   | Option    | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'<\'``   | Forces the field to be left-aligned within the available   |\n   |           | space (this is the default).                               |\n   +-----------+------------------------------------------------------------+\n   | ``\'>\'``   | Forces the field to be right-aligned within the available  |\n   |           | space.                                                     |\n   +-----------+------------------------------------------------------------+\n   | ``\'=\'``   | Forces the padding to be placed after the sign (if any)    |\n   |           | but before the digits.  This is used for printing fields   |\n   |           | in the form \'+000000120\'. This alignment option is only    |\n   |           | valid for numeric types.                                   |\n   +-----------+------------------------------------------------------------+\n   | ``\'^\'``   | Forces the field to be centered within the available       |\n   |           | space.                                                     |\n   +-----------+------------------------------------------------------------+\n\nNote that unless a minimum field width is defined, the field width\nwill always be the same size as the data to fill it, so that the\nalignment option has no meaning in this case.\n\nThe *sign* option is only valid for number types, and can be one of\nthe following:\n\n   +-----------+------------------------------------------------------------+\n   | Option    | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'+\'``   | indicates that a sign should be used for both positive as  |\n   |           | well as negative numbers.                                  |\n   +-----------+------------------------------------------------------------+\n   | ``\'-\'``   | indicates that a sign should be used only for negative     |\n   |           | numbers (this is the default behavior).                    |\n   +-----------+------------------------------------------------------------+\n   | space     | indicates that a leading space should be used on positive  |\n   |           | numbers, and a minus sign on negative numbers.             |\n   +-----------+------------------------------------------------------------+\n\nThe ``\'#\'`` option is only valid for integers, and only for binary,\noctal, or hexadecimal output.  If present, it specifies that the\noutput will be prefixed by ``\'0b\'``, ``\'0o\'``, or ``\'0x\'``,\nrespectively.\n\nThe ``\',\'`` option signals the use of a comma for a thousands\nseparator. For a locale aware separator, use the ``\'n\'`` integer\npresentation type instead.\n\nChanged in version 3.1: Added the ``\',\'`` option (see also **PEP\n378**).\n\n*width* is a decimal integer defining the minimum field width.  If not\nspecified, then the field width will be determined by the content.\n\nIf the *width* field is preceded by a zero (``\'0\'``) character, this\nenables zero-padding.  This is equivalent to an *alignment* type of\n``\'=\'`` and a *fill* character of ``\'0\'``.\n\nThe *precision* is a decimal number indicating how many digits should\nbe displayed after the decimal point for a floating point value\nformatted with ``\'f\'`` and ``\'F\'``, or before and after the decimal\npoint for a floating point value formatted with ``\'g\'`` or ``\'G\'``.\nFor non-number types the field indicates the maximum field size - in\nother words, how many characters will be used from the field content.\nThe *precision* is not allowed for integer values.\n\nFinally, the *type* determines how the data should be presented.\n\nThe available string presentation types are:\n\n   +-----------+------------------------------------------------------------+\n   | Type      | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'s\'``   | String format. This is the default type for strings and    |\n   |           | may be omitted.                                            |\n   +-----------+------------------------------------------------------------+\n   | None      | The same as ``\'s\'``.                                       |\n   +-----------+------------------------------------------------------------+\n\nThe available integer presentation types are:\n\n   +-----------+------------------------------------------------------------+\n   | Type      | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'b\'``   | Binary format. Outputs the number in base 2.               |\n   +-----------+------------------------------------------------------------+\n   | ``\'c\'``   | Character. Converts the integer to the corresponding       |\n   |           | unicode character before printing.                         |\n   +-----------+------------------------------------------------------------+\n   | ``\'d\'``   | Decimal Integer. Outputs the number in base 10.            |\n   +-----------+------------------------------------------------------------+\n   | ``\'o\'``   | Octal format. Outputs the number in base 8.                |\n   +-----------+------------------------------------------------------------+\n   | ``\'x\'``   | Hex format. Outputs the number in base 16, using lower-    |\n   |           | case letters for the digits above 9.                       |\n   +-----------+------------------------------------------------------------+\n   | ``\'X\'``   | Hex format. Outputs the number in base 16, using upper-    |\n   |           | case letters for the digits above 9.                       |\n   +-----------+------------------------------------------------------------+\n   | ``\'n\'``   | Number. This is the same as ``\'d\'``, except that it uses   |\n   |           | the current locale setting to insert the appropriate       |\n   |           | number separator characters.                               |\n   +-----------+------------------------------------------------------------+\n   | None      | The same as ``\'d\'``.                                       |\n   +-----------+------------------------------------------------------------+\n\nIn addition to the above presentation types, integers can be formatted\nwith the floating point presentation types listed below (except\n``\'n\'`` and None). When doing so, ``float()`` is used to convert the\ninteger to a floating point number before formatting.\n\nThe available presentation types for floating point and decimal values\nare:\n\n   +-----------+------------------------------------------------------------+\n   | Type      | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'e\'``   | Exponent notation. Prints the number in scientific         |\n   |           | notation using the letter \'e\' to indicate the exponent.    |\n   +-----------+------------------------------------------------------------+\n   | ``\'E\'``   | Exponent notation. Same as ``\'e\'`` except it uses an upper |\n   |           | case \'E\' as the separator character.                       |\n   +-----------+------------------------------------------------------------+\n   | ``\'f\'``   | Fixed point. Displays the number as a fixed-point number.  |\n   +-----------+------------------------------------------------------------+\n   | ``\'F\'``   | Fixed point. Same as ``\'f\'``, but converts ``nan`` to      |\n   |           | ``NAN`` and ``inf`` to ``INF``.                            |\n   +-----------+------------------------------------------------------------+\n   | ``\'g\'``   | General format.  For a given precision ``p >= 1``, this    |\n   |           | rounds the number to ``p`` significant digits and then     |\n   |           | formats the result in either fixed-point format or in      |\n   |           | scientific notation, depending on its magnitude.  The      |\n   |           | precise rules are as follows: suppose that the result      |\n   |           | formatted with presentation type ``\'e\'`` and precision     |\n   |           | ``p-1`` would have exponent ``exp``.  Then if ``-4 <= exp  |\n   |           | < p``, the number is formatted with presentation type      |\n   |           | ``\'f\'`` and precision ``p-1-exp``. Otherwise, the number   |\n   |           | is formatted with presentation type ``\'e\'`` and precision  |\n   |           | ``p-1``. In both cases insignificant trailing zeros are    |\n   |           | removed from the significand, and the decimal point is     |\n   |           | also removed if there are no remaining digits following    |\n   |           | it.  Positive and negative infinity, positive and negative |\n   |           | zero, and nans, are formatted as ``inf``, ``-inf``, ``0``, |\n   |           | ``-0`` and ``nan`` respectively, regardless of the         |\n   |           | precision.  A precision of ``0`` is treated as equivalent  |\n   |           | to a precision of ``1``.                                   |\n   +-----------+------------------------------------------------------------+\n   | ``\'G\'``   | General format. Same as ``\'g\'`` except switches to ``\'E\'`` |\n   |           | if the number gets too large. The representations of       |\n   |           | infinity and NaN are uppercased, too.                      |\n   +-----------+------------------------------------------------------------+\n   | ``\'n\'``   | Number. This is the same as ``\'g\'``, except that it uses   |\n   |           | the current locale setting to insert the appropriate       |\n   |           | number separator characters.                               |\n   +-----------+------------------------------------------------------------+\n   | ``\'%\'``   | Percentage. Multiplies the number by 100 and displays in   |\n   |           | fixed (``\'f\'``) format, followed by a percent sign.        |\n   +-----------+------------------------------------------------------------+\n   | None      | Similar to ``\'g\'``, except with at least one digit past    |\n   |           | the decimal point and a default precision of 12. This is   |\n   |           | intended to match ``str()``, except you can add the other  |\n   |           | format modifiers.                                          |\n   +-----------+------------------------------------------------------------+\n\n\nFormat examples\n===============\n\nThis section contains examples of the new format syntax and comparison\nwith the old ``%``-formatting.\n\nIn most of the cases the syntax is similar to the old\n``%``-formatting, with the addition of the ``{}`` and with ``:`` used\ninstead of ``%``. For example, ``\'%03.2f\'`` can be translated to\n``\'{:03.2f}\'``.\n\nThe new format syntax also supports new and different options, shown\nin the follow examples.\n\nAccessing arguments by position:\n\n   >>> \'{0}, {1}, {2}\'.format(\'a\', \'b\', \'c\')\n   \'a, b, c\'\n   >>> \'{}, {}, {}\'.format(\'a\', \'b\', \'c\')  # 3.1+ only\n   \'a, b, c\'\n   >>> \'{2}, {1}, {0}\'.format(\'a\', \'b\', \'c\')\n   \'c, b, a\'\n   >>> \'{2}, {1}, {0}\'.format(*\'abc\')      # unpacking argument sequence\n   \'c, b, a\'\n   >>> \'{0}{1}{0}\'.format(\'abra\', \'cad\')   # arguments\' indices can be repeated\n   \'abracadabra\'\n\nAccessing arguments by name:\n\n   >>> \'Coordinates: {latitude}, {longitude}\'.format(latitude=\'37.24N\', longitude=\'-115.81W\')\n   \'Coordinates: 37.24N, -115.81W\'\n   >>> coord = {\'latitude\': \'37.24N\', \'longitude\': \'-115.81W\'}\n   >>> \'Coordinates: {latitude}, {longitude}\'.format(**coord)\n   \'Coordinates: 37.24N, -115.81W\'\n\nAccessing arguments\' attributes:\n\n   >>> c = 3-5j\n   >>> (\'The complex number {0} is formed from the real part {0.real} \'\n   ...  \'and the imaginary part {0.imag}.\').format(c)\n   \'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.\'\n   >>> class Point:\n   ...     def __init__(self, x, y):\n   ...         self.x, self.y = x, y\n   ...     def __str__(self):\n   ...         return \'Point({self.x}, {self.y})\'.format(self=self)\n   ...\n   >>> str(Point(4, 2))\n   \'Point(4, 2)\'\n\nAccessing arguments\' items:\n\n   >>> coord = (3, 5)\n   >>> \'X: {0[0]};  Y: {0[1]}\'.format(coord)\n   \'X: 3;  Y: 5\'\n\nReplacing ``%s`` and ``%r``:\n\n   >>> "repr() shows quotes: {!r}; str() doesn\'t: {!s}".format(\'test1\', \'test2\')\n   "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n\nAligning the text and specifying a width:\n\n   >>> \'{:<30}\'.format(\'left aligned\')\n   \'left aligned                  \'\n   >>> \'{:>30}\'.format(\'right aligned\')\n   \'                 right aligned\'\n   >>> \'{:^30}\'.format(\'centered\')\n   \'           centered           \'\n   >>> \'{:*^30}\'.format(\'centered\')  # use \'*\' as a fill char\n   \'***********centered***********\'\n\nReplacing ``%+f``, ``%-f``, and ``% f`` and specifying a sign:\n\n   >>> \'{:+f}; {:+f}\'.format(3.14, -3.14)  # show it always\n   \'+3.140000; -3.140000\'\n   >>> \'{: f}; {: f}\'.format(3.14, -3.14)  # show a space for positive numbers\n   \' 3.140000; -3.140000\'\n   >>> \'{:-f}; {:-f}\'.format(3.14, -3.14)  # show only the minus -- same as \'{:f}; {:f}\'\n   \'3.140000; -3.140000\'\n\nReplacing ``%x`` and ``%o`` and converting the value to different\nbases:\n\n   >>> # format also supports binary numbers\n   >>> "int: {0:d};  hex: {0:x};  oct: {0:o};  bin: {0:b}".format(42)\n   \'int: 42;  hex: 2a;  oct: 52;  bin: 101010\'\n   >>> # with 0x, 0o, or 0b as prefix:\n   >>> "int: {0:d};  hex: {0:#x};  oct: {0:#o};  bin: {0:#b}".format(42)\n   \'int: 42;  hex: 0x2a;  oct: 0o52;  bin: 0b101010\'\n\nUsing the comma as a thousands separator:\n\n   >>> \'{:,}\'.format(1234567890)\n   \'1,234,567,890\'\n\nExpressing a percentage:\n\n   >>> points = 19\n   >>> total = 22\n   >>> \'Correct answers: {:.2%}.\'.format(points/total)\n   \'Correct answers: 86.36%\'\n\nUsing type-specific formatting:\n\n   >>> import datetime\n   >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n   >>> \'{:%Y-%m-%d %H:%M:%S}\'.format(d)\n   \'2010-07-04 12:15:58\'\n\nNesting arguments and more complex examples:\n\n   >>> for align, text in zip(\'<^>\', [\'left\', \'center\', \'right\']):\n   ...     \'{0:{align}{fill}16}\'.format(text, fill=align, align=align)\n   ...\n   \'left<<<<<<<<<<<<\'\n   \'^^^^^center^^^^^\'\n   \'>>>>>>>>>>>right\'\n   >>>\n   >>> octets = [192, 168, 0, 1]\n   >>> \'{:02X}{:02X}{:02X}{:02X}\'.format(*octets)\n   \'C0A80001\'\n   >>> int(_, 16)\n   3232235521\n   >>>\n   >>> width = 5\n   >>> for num in range(5,12):\n   ...     for base in \'dXob\':\n   ...         print(\'{0:{width}{base}}\'.format(num, base=base, width=width), end=\' \')\n   ...     print()\n   ...\n       5     5     5   101\n       6     6     6   110\n       7     7     7   111\n       8     8    10  1000\n       9     9    11  1001\n      10     A    12  1010\n      11     B    13  1011\n',
+ 'formatstrings': '\nFormat String Syntax\n********************\n\nThe ``str.format()`` method and the ``Formatter`` class share the same\nsyntax for format strings (although in the case of ``Formatter``,\nsubclasses can define their own format string syntax).\n\nFormat strings contain "replacement fields" surrounded by curly braces\n``{}``. Anything that is not contained in braces is considered literal\ntext, which is copied unchanged to the output.  If you need to include\na brace character in the literal text, it can be escaped by doubling:\n``{{`` and ``}}``.\n\nThe grammar for a replacement field is as follows:\n\n      replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"\n      field_name        ::= arg_name ("." attribute_name | "[" element_index "]")*\n      arg_name          ::= [identifier | integer]\n      attribute_name    ::= identifier\n      element_index     ::= integer | index_string\n      index_string      ::= <any source character except "]"> +\n      conversion        ::= "r" | "s" | "a"\n      format_spec       ::= <described in the next section>\n\nIn less formal terms, the replacement field can start with a\n*field_name* that specifies the object whose value is to be formatted\nand inserted into the output instead of the replacement field. The\n*field_name* is optionally followed by a  *conversion* field, which is\npreceded by an exclamation point ``\'!\'``, and a *format_spec*, which\nis preceded by a colon ``\':\'``.  These specify a non-default format\nfor the replacement value.\n\nSee also the *Format Specification Mini-Language* section.\n\nThe *field_name* itself begins with an *arg_name* that is either\neither a number or a keyword.  If it\'s a number, it refers to a\npositional argument, and if it\'s a keyword, it refers to a named\nkeyword argument.  If the numerical arg_names in a format string are\n0, 1, 2, ... in sequence, they can all be omitted (not just some) and\nthe numbers 0, 1, 2, ... will be automatically inserted in that order.\nThe *arg_name* can be followed by any number of index or attribute\nexpressions. An expression of the form ``\'.name\'`` selects the named\nattribute using ``getattr()``, while an expression of the form\n``\'[index]\'`` does an index lookup using ``__getitem__()``.\n\nChanged in version 3.1: The positional argument specifiers can be\nomitted, so ``\'{} {}\'`` is equivalent to ``\'{0} {1}\'``.\n\nSome simple format string examples:\n\n   "First, thou shalt count to {0}" # References first positional argument\n   "Bring me a {}"                  # Implicitly references the first positional argument\n   "From {} to {}"                  # Same as "From {0} to {1}"\n   "My quest is {name}"             # References keyword argument \'name\'\n   "Weight in tons {0.weight}"      # \'weight\' attribute of first positional arg\n   "Units destroyed: {players[0]}"  # First element of keyword argument \'players\'.\n\nThe *conversion* field causes a type coercion before formatting.\nNormally, the job of formatting a value is done by the\n``__format__()`` method of the value itself.  However, in some cases\nit is desirable to force a type to be formatted as a string,\noverriding its own definition of formatting.  By converting the value\nto a string before calling ``__format__()``, the normal formatting\nlogic is bypassed.\n\nThree conversion flags are currently supported: ``\'!s\'`` which calls\n``str()`` on the value, ``\'!r\'`` which calls ``repr()`` and ``\'!a\'``\nwhich calls ``ascii()``.\n\nSome examples:\n\n   "Harold\'s a clever {0!s}"        # Calls str() on the argument first\n   "Bring out the holy {name!r}"    # Calls repr() on the argument first\n   "More {!a}"                      # Calls ascii() on the argument first\n\nThe *format_spec* field contains a specification of how the value\nshould be presented, including such details as field width, alignment,\npadding, decimal precision and so on.  Each value type can define its\nown "formatting mini-language" or interpretation of the *format_spec*.\n\nMost built-in types support a common formatting mini-language, which\nis described in the next section.\n\nA *format_spec* field can also include nested replacement fields\nwithin it. These nested replacement fields can contain only a field\nname; conversion flags and format specifications are not allowed.  The\nreplacement fields within the format_spec are substituted before the\n*format_spec* string is interpreted. This allows the formatting of a\nvalue to be dynamically specified.\n\nSee the *Format examples* section for some examples.\n\n\nFormat Specification Mini-Language\n==================================\n\n"Format specifications" are used within replacement fields contained\nwithin a format string to define how individual values are presented\n(see *Format String Syntax*).  They can also be passed directly to the\nbuilt-in ``format()`` function.  Each formattable type may define how\nthe format specification is to be interpreted.\n\nMost built-in types implement the following options for format\nspecifications, although some of the formatting options are only\nsupported by the numeric types.\n\nA general convention is that an empty format string (``""``) produces\nthe same result as if you had called ``str()`` on the value. A non-\nempty format string typically modifies the result.\n\nThe general form of a *standard format specifier* is:\n\n   format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]\n   fill        ::= <a character other than \'}\'>\n   align       ::= "<" | ">" | "=" | "^"\n   sign        ::= "+" | "-" | " "\n   width       ::= integer\n   precision   ::= integer\n   type        ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n\nThe *fill* character can be any character other than \'{\' or \'}\'.  The\npresence of a fill character is signaled by the character following\nit, which must be one of the alignment options.  If the second\ncharacter of *format_spec* is not a valid alignment option, then it is\nassumed that both the fill character and the alignment option are\nabsent.\n\nThe meaning of the various alignment options is as follows:\n\n   +-----------+------------------------------------------------------------+\n   | Option    | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'<\'``   | Forces the field to be left-aligned within the available   |\n   |           | space (this is the default).                               |\n   +-----------+------------------------------------------------------------+\n   | ``\'>\'``   | Forces the field to be right-aligned within the available  |\n   |           | space.                                                     |\n   +-----------+------------------------------------------------------------+\n   | ``\'=\'``   | Forces the padding to be placed after the sign (if any)    |\n   |           | but before the digits.  This is used for printing fields   |\n   |           | in the form \'+000000120\'. This alignment option is only    |\n   |           | valid for numeric types.                                   |\n   +-----------+------------------------------------------------------------+\n   | ``\'^\'``   | Forces the field to be centered within the available       |\n   |           | space.                                                     |\n   +-----------+------------------------------------------------------------+\n\nNote that unless a minimum field width is defined, the field width\nwill always be the same size as the data to fill it, so that the\nalignment option has no meaning in this case.\n\nThe *sign* option is only valid for number types, and can be one of\nthe following:\n\n   +-----------+------------------------------------------------------------+\n   | Option    | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'+\'``   | indicates that a sign should be used for both positive as  |\n   |           | well as negative numbers.                                  |\n   +-----------+------------------------------------------------------------+\n   | ``\'-\'``   | indicates that a sign should be used only for negative     |\n   |           | numbers (this is the default behavior).                    |\n   +-----------+------------------------------------------------------------+\n   | space     | indicates that a leading space should be used on positive  |\n   |           | numbers, and a minus sign on negative numbers.             |\n   +-----------+------------------------------------------------------------+\n\nThe ``\'#\'`` option causes the "alternate form" to be used for the\nconversion.  The alternate form is defined differently for different\ntypes.  This option is only valid for integer, float, complex and\nDecimal types. For integers, when binary, octal, or hexadecimal output\nis used, this option adds the prefix respective ``\'0b\'``, ``\'0o\'``, or\n``\'0x\'`` to the output value. For floats, complex and Decimal the\nalternate form causes the result of the conversion to always contain a\ndecimal-point character, even if no digits follow it. Normally, a\ndecimal-point character appears in the result of these conversions\nonly if a digit follows it. In addition, for ``\'g\'`` and ``\'G\'``\nconversions, trailing zeros are not removed from the result.\n\nThe ``\',\'`` option signals the use of a comma for a thousands\nseparator. For a locale aware separator, use the ``\'n\'`` integer\npresentation type instead.\n\nChanged in version 3.1: Added the ``\',\'`` option (see also **PEP\n378**).\n\n*width* is a decimal integer defining the minimum field width.  If not\nspecified, then the field width will be determined by the content.\n\nIf the *width* field is preceded by a zero (``\'0\'``) character, this\nenables zero-padding.  This is equivalent to an *alignment* type of\n``\'=\'`` and a *fill* character of ``\'0\'``.\n\nThe *precision* is a decimal number indicating how many digits should\nbe displayed after the decimal point for a floating point value\nformatted with ``\'f\'`` and ``\'F\'``, or before and after the decimal\npoint for a floating point value formatted with ``\'g\'`` or ``\'G\'``.\nFor non-number types the field indicates the maximum field size - in\nother words, how many characters will be used from the field content.\nThe *precision* is not allowed for integer values.\n\nFinally, the *type* determines how the data should be presented.\n\nThe available string presentation types are:\n\n   +-----------+------------------------------------------------------------+\n   | Type      | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'s\'``   | String format. This is the default type for strings and    |\n   |           | may be omitted.                                            |\n   +-----------+------------------------------------------------------------+\n   | None      | The same as ``\'s\'``.                                       |\n   +-----------+------------------------------------------------------------+\n\nThe available integer presentation types are:\n\n   +-----------+------------------------------------------------------------+\n   | Type      | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'b\'``   | Binary format. Outputs the number in base 2.               |\n   +-----------+------------------------------------------------------------+\n   | ``\'c\'``   | Character. Converts the integer to the corresponding       |\n   |           | unicode character before printing.                         |\n   +-----------+------------------------------------------------------------+\n   | ``\'d\'``   | Decimal Integer. Outputs the number in base 10.            |\n   +-----------+------------------------------------------------------------+\n   | ``\'o\'``   | Octal format. Outputs the number in base 8.                |\n   +-----------+------------------------------------------------------------+\n   | ``\'x\'``   | Hex format. Outputs the number in base 16, using lower-    |\n   |           | case letters for the digits above 9.                       |\n   +-----------+------------------------------------------------------------+\n   | ``\'X\'``   | Hex format. Outputs the number in base 16, using upper-    |\n   |           | case letters for the digits above 9.                       |\n   +-----------+------------------------------------------------------------+\n   | ``\'n\'``   | Number. This is the same as ``\'d\'``, except that it uses   |\n   |           | the current locale setting to insert the appropriate       |\n   |           | number separator characters.                               |\n   +-----------+------------------------------------------------------------+\n   | None      | The same as ``\'d\'``.                                       |\n   +-----------+------------------------------------------------------------+\n\nIn addition to the above presentation types, integers can be formatted\nwith the floating point presentation types listed below (except\n``\'n\'`` and None). When doing so, ``float()`` is used to convert the\ninteger to a floating point number before formatting.\n\nThe available presentation types for floating point and decimal values\nare:\n\n   +-----------+------------------------------------------------------------+\n   | Type      | Meaning                                                    |\n   +===========+============================================================+\n   | ``\'e\'``   | Exponent notation. Prints the number in scientific         |\n   |           | notation using the letter \'e\' to indicate the exponent.    |\n   +-----------+------------------------------------------------------------+\n   | ``\'E\'``   | Exponent notation. Same as ``\'e\'`` except it uses an upper |\n   |           | case \'E\' as the separator character.                       |\n   +-----------+------------------------------------------------------------+\n   | ``\'f\'``   | Fixed point. Displays the number as a fixed-point number.  |\n   +-----------+------------------------------------------------------------+\n   | ``\'F\'``   | Fixed point. Same as ``\'f\'``, but converts ``nan`` to      |\n   |           | ``NAN`` and ``inf`` to ``INF``.                            |\n   +-----------+------------------------------------------------------------+\n   | ``\'g\'``   | General format.  For a given precision ``p >= 1``, this    |\n   |           | rounds the number to ``p`` significant digits and then     |\n   |           | formats the result in either fixed-point format or in      |\n   |           | scientific notation, depending on its magnitude.  The      |\n   |           | precise rules are as follows: suppose that the result      |\n   |           | formatted with presentation type ``\'e\'`` and precision     |\n   |           | ``p-1`` would have exponent ``exp``.  Then if ``-4 <= exp  |\n   |           | < p``, the number is formatted with presentation type      |\n   |           | ``\'f\'`` and precision ``p-1-exp``. Otherwise, the number   |\n   |           | is formatted with presentation type ``\'e\'`` and precision  |\n   |           | ``p-1``. In both cases insignificant trailing zeros are    |\n   |           | removed from the significand, and the decimal point is     |\n   |           | also removed if there are no remaining digits following    |\n   |           | it.  Positive and negative infinity, positive and negative |\n   |           | zero, and nans, are formatted as ``inf``, ``-inf``, ``0``, |\n   |           | ``-0`` and ``nan`` respectively, regardless of the         |\n   |           | precision.  A precision of ``0`` is treated as equivalent  |\n   |           | to a precision of ``1``.                                   |\n   +-----------+------------------------------------------------------------+\n   | ``\'G\'``   | General format. Same as ``\'g\'`` except switches to ``\'E\'`` |\n   |           | if the number gets too large. The representations of       |\n   |           | infinity and NaN are uppercased, too.                      |\n   +-----------+------------------------------------------------------------+\n   | ``\'n\'``   | Number. This is the same as ``\'g\'``, except that it uses   |\n   |           | the current locale setting to insert the appropriate       |\n   |           | number separator characters.                               |\n   +-----------+------------------------------------------------------------+\n   | ``\'%\'``   | Percentage. Multiplies the number by 100 and displays in   |\n   |           | fixed (``\'f\'``) format, followed by a percent sign.        |\n   +-----------+------------------------------------------------------------+\n   | None      | Similar to ``\'g\'``, except with at least one digit past    |\n   |           | the decimal point and a default precision of 12. This is   |\n   |           | intended to match ``str()``, except you can add the other  |\n   |           | format modifiers.                                          |\n   +-----------+------------------------------------------------------------+\n\n\nFormat examples\n===============\n\nThis section contains examples of the new format syntax and comparison\nwith the old ``%``-formatting.\n\nIn most of the cases the syntax is similar to the old\n``%``-formatting, with the addition of the ``{}`` and with ``:`` used\ninstead of ``%``. For example, ``\'%03.2f\'`` can be translated to\n``\'{:03.2f}\'``.\n\nThe new format syntax also supports new and different options, shown\nin the follow examples.\n\nAccessing arguments by position:\n\n   >>> \'{0}, {1}, {2}\'.format(\'a\', \'b\', \'c\')\n   \'a, b, c\'\n   >>> \'{}, {}, {}\'.format(\'a\', \'b\', \'c\')  # 3.1+ only\n   \'a, b, c\'\n   >>> \'{2}, {1}, {0}\'.format(\'a\', \'b\', \'c\')\n   \'c, b, a\'\n   >>> \'{2}, {1}, {0}\'.format(*\'abc\')      # unpacking argument sequence\n   \'c, b, a\'\n   >>> \'{0}{1}{0}\'.format(\'abra\', \'cad\')   # arguments\' indices can be repeated\n   \'abracadabra\'\n\nAccessing arguments by name:\n\n   >>> \'Coordinates: {latitude}, {longitude}\'.format(latitude=\'37.24N\', longitude=\'-115.81W\')\n   \'Coordinates: 37.24N, -115.81W\'\n   >>> coord = {\'latitude\': \'37.24N\', \'longitude\': \'-115.81W\'}\n   >>> \'Coordinates: {latitude}, {longitude}\'.format(**coord)\n   \'Coordinates: 37.24N, -115.81W\'\n\nAccessing arguments\' attributes:\n\n   >>> c = 3-5j\n   >>> (\'The complex number {0} is formed from the real part {0.real} \'\n   ...  \'and the imaginary part {0.imag}.\').format(c)\n   \'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.\'\n   >>> class Point:\n   ...     def __init__(self, x, y):\n   ...         self.x, self.y = x, y\n   ...     def __str__(self):\n   ...         return \'Point({self.x}, {self.y})\'.format(self=self)\n   ...\n   >>> str(Point(4, 2))\n   \'Point(4, 2)\'\n\nAccessing arguments\' items:\n\n   >>> coord = (3, 5)\n   >>> \'X: {0[0]};  Y: {0[1]}\'.format(coord)\n   \'X: 3;  Y: 5\'\n\nReplacing ``%s`` and ``%r``:\n\n   >>> "repr() shows quotes: {!r}; str() doesn\'t: {!s}".format(\'test1\', \'test2\')\n   "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n\nAligning the text and specifying a width:\n\n   >>> \'{:<30}\'.format(\'left aligned\')\n   \'left aligned                  \'\n   >>> \'{:>30}\'.format(\'right aligned\')\n   \'                 right aligned\'\n   >>> \'{:^30}\'.format(\'centered\')\n   \'           centered           \'\n   >>> \'{:*^30}\'.format(\'centered\')  # use \'*\' as a fill char\n   \'***********centered***********\'\n\nReplacing ``%+f``, ``%-f``, and ``% f`` and specifying a sign:\n\n   >>> \'{:+f}; {:+f}\'.format(3.14, -3.14)  # show it always\n   \'+3.140000; -3.140000\'\n   >>> \'{: f}; {: f}\'.format(3.14, -3.14)  # show a space for positive numbers\n   \' 3.140000; -3.140000\'\n   >>> \'{:-f}; {:-f}\'.format(3.14, -3.14)  # show only the minus -- same as \'{:f}; {:f}\'\n   \'3.140000; -3.140000\'\n\nReplacing ``%x`` and ``%o`` and converting the value to different\nbases:\n\n   >>> # format also supports binary numbers\n   >>> "int: {0:d};  hex: {0:x};  oct: {0:o};  bin: {0:b}".format(42)\n   \'int: 42;  hex: 2a;  oct: 52;  bin: 101010\'\n   >>> # with 0x, 0o, or 0b as prefix:\n   >>> "int: {0:d};  hex: {0:#x};  oct: {0:#o};  bin: {0:#b}".format(42)\n   \'int: 42;  hex: 0x2a;  oct: 0o52;  bin: 0b101010\'\n\nUsing the comma as a thousands separator:\n\n   >>> \'{:,}\'.format(1234567890)\n   \'1,234,567,890\'\n\nExpressing a percentage:\n\n   >>> points = 19\n   >>> total = 22\n   >>> \'Correct answers: {:.2%}.\'.format(points/total)\n   \'Correct answers: 86.36%\'\n\nUsing type-specific formatting:\n\n   >>> import datetime\n   >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n   >>> \'{:%Y-%m-%d %H:%M:%S}\'.format(d)\n   \'2010-07-04 12:15:58\'\n\nNesting arguments and more complex examples:\n\n   >>> for align, text in zip(\'<^>\', [\'left\', \'center\', \'right\']):\n   ...     \'{0:{align}{fill}16}\'.format(text, fill=align, align=align)\n   ...\n   \'left<<<<<<<<<<<<\'\n   \'^^^^^center^^^^^\'\n   \'>>>>>>>>>>>right\'\n   >>>\n   >>> octets = [192, 168, 0, 1]\n   >>> \'{:02X}{:02X}{:02X}{:02X}\'.format(*octets)\n   \'C0A80001\'\n   >>> int(_, 16)\n   3232235521\n   >>>\n   >>> width = 5\n   >>> for num in range(5,12):\n   ...     for base in \'dXob\':\n   ...         print(\'{0:{width}{base}}\'.format(num, base=base, width=width), end=\' \')\n   ...     print()\n   ...\n       5     5     5   101\n       6     6     6   110\n       7     7     7   111\n       8     8    10  1000\n       9     9    11  1001\n      10     A    12  1010\n      11     B    13  1011\n',
  'function': '\nFunction definitions\n********************\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n   funcdef        ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n   decorators     ::= decorator+\n   decorator      ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n   dotted_name    ::= identifier ("." identifier)*\n   parameter_list ::= (defparameter ",")*\n                      (  "*" [parameter] ("," defparameter)*\n                      [, "**" parameter]\n                      | "**" parameter\n                      | defparameter [","] )\n   parameter      ::= identifier [":" expression]\n   defparameter   ::= parameter ["=" expression]\n   funcname       ::= identifier\n\nA function definition is an executable statement.  Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function).  This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition.  The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object.  Multiple decorators are applied in\nnested fashion. For example, the following code\n\n   @f1(arg)\n   @f2\n   def func(): pass\n\nis equivalent to\n\n   def func(): pass\n   func = f1(arg)(f2(func))\n\nWhen one or more parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted.  If a parameter has a default value, all following\nparameters up until the "``*``" must also have a default value ---\nthis is a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that that same "pre-computed" value is\nused for each call.  This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended.  A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n   def whats_on_the_telly(penguin=None):\n       if penguin is None:\n           penguin = []\n       penguin.append("property of the zoo")\n       return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values.  If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple.  If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after "``*``" or "``*identifier``" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "``: expression``"\nfollowing the parameter name.  Any parameter may have an annotation\neven those of the form ``*identifier`` or ``**identifier``.  Functions\nmay have "return" annotation of the form "``-> expression``" after the\nparameter list.  These annotations can be any valid Python expression\nand are evaluated when the function definition is executed.\nAnnotations may be evaluated in a different order than they appear in\nthe source code.  The presence of annotations does not change the\nsemantics of a function.  The annotation values are available as\nvalues of a dictionary keyed by the parameters\' names in the\n``__annotations__`` attribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions.  This uses lambda forms,\ndescribed in section *Lambdas*.  Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form.  The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects.  A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around.  Free variables used in the\nnested function can access the local variables of the function\ncontaining the def.  See section *Naming and binding* for details.\n',
  'global': '\nThe ``global`` statement\n************************\n\n   global_stmt ::= "global" identifier ("," identifier)*\n\nThe ``global`` statement is a declaration which holds for the entire\ncurrent code block.  It means that the listed identifiers are to be\ninterpreted as globals.  It would be impossible to assign to a global\nvariable without ``global``, although free variables may refer to\nglobals without being declared global.\n\nNames listed in a ``global`` statement must not be used in the same\ncode block textually preceding that ``global`` statement.\n\nNames listed in a ``global`` statement must not be defined as formal\nparameters or in a ``for`` loop control target, ``class`` definition,\nfunction definition, or ``import`` statement.\n\n**CPython implementation detail:** The current implementation does not\nenforce the latter two restrictions, but programs should not abuse\nthis freedom, as future implementations may enforce them or silently\nchange the meaning of the program.\n\n**Programmer\'s note:** the ``global`` is a directive to the parser.\nIt applies only to code parsed at the same time as the ``global``\nstatement. In particular, a ``global`` statement contained in a string\nor code object supplied to the built-in ``exec()`` function does not\naffect the code block *containing* the function call, and code\ncontained in such a string is unaffected by ``global`` statements in\nthe code containing the function call.  The same applies to the\n``eval()`` and ``compile()`` functions.\n',
  'id-classes': '\nReserved classes of identifiers\n*******************************\n\nCertain classes of identifiers (besides keywords) have special\nmeanings.  These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n   Not imported by ``from module import *``.  The special identifier\n   ``_`` is used in the interactive interpreter to store the result of\n   the last evaluation; it is stored in the ``builtins`` module.  When\n   not in interactive mode, ``_`` has no special meaning and is not\n   defined. See section *The import statement*.\n\n   Note: The name ``_`` is often used in conjunction with\n     internationalization; refer to the documentation for the\n     ``gettext`` module for more information on this convention.\n\n``__*__``\n   System-defined names. These names are defined by the interpreter\n   and its implementation (including the standard library).  Current\n   system names are discussed in the *Special method names* section\n   and elsewhere.  More will likely be defined in future versions of\n   Python.  *Any* use of ``__*__`` names, in any context, that does\n   not follow explicitly documented use, is subject to breakage\n   without warning.\n\n``__*``\n   Class-private names.  Names in this category, when used within the\n   context of a class definition, are re-written to use a mangled form\n   to help avoid name clashes between "private" attributes of base and\n   derived classes. See section *Identifiers (Names)*.\n',
  'identifiers': '\nIdentifiers and keywords\n************************\n\nIdentifiers (also referred to as *names*) are described by the\nfollowing lexical definitions.\n\nThe syntax of identifiers in Python is based on the Unicode standard\nannex UAX-31, with elaboration and changes as defined below; see also\n**PEP 3131** for further details.\n\nWithin the ASCII range (U+0001..U+007F), the valid characters for\nidentifiers are the same as in Python 2.x: the uppercase and lowercase\nletters ``A`` through ``Z``, the underscore ``_`` and, except for the\nfirst character, the digits ``0`` through ``9``.\n\nPython 3.0 introduces additional characters from outside the ASCII\nrange (see **PEP 3131**).  For these characters, the classification\nuses the version of the Unicode Character Database as included in the\n``unicodedata`` module.\n\nIdentifiers are unlimited in length.  Case is significant.\n\n   identifier  ::= id_start id_continue*\n   id_start    ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>\n   id_continue ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>\n\nThe Unicode category codes mentioned above stand for:\n\n* *Lu* - uppercase letters\n\n* *Ll* - lowercase letters\n\n* *Lt* - titlecase letters\n\n* *Lm* - modifier letters\n\n* *Lo* - other letters\n\n* *Nl* - letter numbers\n\n* *Mn* - nonspacing marks\n\n* *Mc* - spacing combining marks\n\n* *Nd* - decimal numbers\n\n* *Pc* - connector punctuations\n\nAll identifiers are converted into the normal form NFC while parsing;\ncomparison of identifiers is based on NFC.\n\nA non-normative HTML file listing all valid identifier characters for\nUnicode 4.1 can be found at http://www.dcl.hpi.uni-\npotsdam.de/home/loewis/table-3131.html.\n\n\nKeywords\n========\n\nThe following identifiers are used as reserved words, or *keywords* of\nthe language, and cannot be used as ordinary identifiers.  They must\nbe spelled exactly as written here:\n\n   False      class      finally    is         return\n   None       continue   for        lambda     try\n   True       def        from       nonlocal   while\n   and        del        global     not        with\n   as         elif       if         or         yield\n   assert     else       import     pass\n   break      except     in         raise\n\n\nReserved classes of identifiers\n===============================\n\nCertain classes of identifiers (besides keywords) have special\nmeanings.  These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n   Not imported by ``from module import *``.  The special identifier\n   ``_`` is used in the interactive interpreter to store the result of\n   the last evaluation; it is stored in the ``builtins`` module.  When\n   not in interactive mode, ``_`` has no special meaning and is not\n   defined. See section *The import statement*.\n\n   Note: The name ``_`` is often used in conjunction with\n     internationalization; refer to the documentation for the\n     ``gettext`` module for more information on this convention.\n\n``__*__``\n   System-defined names. These names are defined by the interpreter\n   and its implementation (including the standard library).  Current\n   system names are discussed in the *Special method names* section\n   and elsewhere.  More will likely be defined in future versions of\n   Python.  *Any* use of ``__*__`` names, in any context, that does\n   not follow explicitly documented use, is subject to breakage\n   without warning.\n\n``__*``\n   Class-private names.  Names in this category, when used within the\n   context of a class definition, are re-written to use a mangled form\n   to help avoid name clashes between "private" attributes of base and\n   derived classes. See section *Identifiers (Names)*.\n',
  'if': '\nThe ``if`` statement\n********************\n\nThe ``if`` statement is used for conditional execution:\n\n   if_stmt ::= "if" expression ":" suite\n               ( "elif" expression ":" suite )*\n               ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n',
  'imaginary': '\nImaginary literals\n******************\n\nImaginary literals are described by the following lexical definitions:\n\n   imagnumber ::= (floatnumber | intpart) ("j" | "J")\n\nAn imaginary literal yields a complex number with a real part of 0.0.\nComplex numbers are represented as a pair of floating point numbers\nand have the same restrictions on their range.  To create a complex\nnumber with a nonzero real part, add a floating point number to it,\ne.g., ``(3+4j)``.  Some examples of imaginary literals:\n\n   3.14j   10.j    10j     .001j   1e100j  3.14e-10j\n',
- 'import': '\nThe ``import`` statement\n************************\n\n   import_stmt     ::= "import" module ["as" name] ( "," module ["as" name] )*\n                   | "from" relative_module "import" identifier ["as" name]\n                   ( "," identifier ["as" name] )*\n                   | "from" relative_module "import" "(" identifier ["as" name]\n                   ( "," identifier ["as" name] )* [","] ")"\n                   | "from" module "import" "*"\n   module          ::= (identifier ".")* identifier\n   relative_module ::= "."* module | "."+\n   name            ::= identifier\n\nImport statements are executed in two steps: (1) find a module, and\ninitialize it if necessary; (2) define a name or names in the local\nnamespace (of the scope where the ``import`` statement occurs). The\nstatement comes in two forms differing on whether it uses the ``from``\nkeyword. The first form (without ``from``) repeats these steps for\neach identifier in the list. The form with ``from`` performs step (1)\nonce, and then performs step (2) repeatedly. For a reference\nimplementation of step (1), see the ``importlib`` module.\n\nTo understand how step (1) occurs, one must first understand how\nPython handles hierarchical naming of modules. To help organize\nmodules and provide a hierarchy in naming, Python has a concept of\npackages. A package can contain other packages and modules while\nmodules cannot contain other modules or packages. From a file system\nperspective, packages are directories and modules are files. The\noriginal specification for packages is still available to read,\nalthough minor details have changed since the writing of that\ndocument.\n\nOnce the name of the module is known (unless otherwise specified, the\nterm "module" will refer to both packages and modules), searching for\nthe module or package can begin. The first place checked is\n``sys.modules``, the cache of all modules that have been imported\npreviously. If the module is found there then it is used in step (2)\nof import unless ``None`` is found in ``sys.modules``, in which case\n``ImportError`` is raised.\n\nIf the module is not found in the cache, then ``sys.meta_path`` is\nsearched (the specification for ``sys.meta_path`` can be found in\n**PEP 302**). The object is a list of *finder* objects which are\nqueried in order as to whether they know how to load the module by\ncalling their ``find_module()`` method with the name of the module. If\nthe module happens to be contained within a package (as denoted by the\nexistence of a dot in the name), then a second argument to\n``find_module()`` is given as the value of the ``__path__`` attribute\nfrom the parent package (everything up to the last dot in the name of\nthe module being imported). If a finder can find the module it returns\na *loader* (discussed later) or returns ``None``.\n\nIf none of the finders on ``sys.meta_path`` are able to find the\nmodule then some implicitly defined finders are queried.\nImplementations of Python vary in what implicit meta path finders are\ndefined. The one they all do define, though, is one that handles\n``sys.path_hooks``, ``sys.path_importer_cache``, and ``sys.path``.\n\nThe implicit finder searches for the requested module in the "paths"\nspecified in one of two places ("paths" do not have to be file system\npaths). If the module being imported is supposed to be contained\nwithin a package then the second argument passed to ``find_module()``,\n``__path__`` on the parent package, is used as the source of paths. If\nthe module is not contained in a package then ``sys.path`` is used as\nthe source of paths.\n\nOnce the source of paths is chosen it is iterated over to find a\nfinder that can handle that path. The dict at\n``sys.path_importer_cache`` caches finders for paths and is checked\nfor a finder. If the path does not have a finder cached then\n``sys.path_hooks`` is searched by calling each object in the list with\na single argument of the path, returning a finder or raises\n``ImportError``. If a finder is returned then it is cached in\n``sys.path_importer_cache`` and then used for that path entry. If no\nfinder can be found but the path exists then a value of ``None`` is\nstored in ``sys.path_importer_cache`` to signify that an implicit,\nfile-based finder that handles modules stored as individual files\nshould be used for that path. If the path does not exist then a finder\nwhich always returns ``None`` is placed in the cache for the path.\n\nIf no finder can find the module then ``ImportError`` is raised.\nOtherwise some finder returned a loader whose ``load_module()`` method\nis called with the name of the module to load (see **PEP 302** for the\noriginal definition of loaders). A loader has several responsibilities\nto perform on a module it loads. First, if the module already exists\nin ``sys.modules`` (a possibility if the loader is called outside of\nthe import machinery) then it is to use that module for initialization\nand not a new module. But if the module does not exist in\n``sys.modules`` then it is to be added to that dict before\ninitialization begins. If an error occurs during loading of the module\nand it was added to ``sys.modules`` it is to be removed from the dict.\nIf an error occurs but the module was already in ``sys.modules`` it is\nleft in the dict.\n\nThe loader must set several attributes on the module. ``__name__`` is\nto be set to the name of the module. ``__file__`` is to be the "path"\nto the file unless the module is built-in (and thus listed in\n``sys.builtin_module_names``) in which case the attribute is not set.\nIf what is being imported is a package then ``__path__`` is to be set\nto a list of paths to be searched when looking for modules and\npackages contained within the package being imported. ``__package__``\nis optional but should be set to the name of package that contains the\nmodule or package (the empty string is used for module not contained\nin a package). ``__loader__`` is also optional but should be set to\nthe loader object that is loading the module.\n\nIf an error occurs during loading then the loader raises\n``ImportError`` if some other exception is not already being\npropagated. Otherwise the loader returns the module that was loaded\nand initialized.\n\nWhen step (1) finishes without raising an exception, step (2) can\nbegin.\n\nThe first form of ``import`` statement binds the module name in the\nlocal namespace to the module object, and then goes on to import the\nnext identifier, if any.  If the module name is followed by ``as``,\nthe name following ``as`` is used as the local name for the module.\n\nThe ``from`` form does not bind the module name: it goes through the\nlist of identifiers, looks each one of them up in the module found in\nstep (1), and binds the name in the local namespace to the object thus\nfound.  As with the first form of ``import``, an alternate local name\ncan be supplied by specifying "``as`` localname".  If a name is not\nfound, ``ImportError`` is raised.  If the list of identifiers is\nreplaced by a star (``\'*\'``), all public names defined in the module\nare bound in the local namespace of the ``import`` statement..\n\nThe *public names* defined by a module are determined by checking the\nmodule\'s namespace for a variable named ``__all__``; if defined, it\nmust be a sequence of strings which are names defined or imported by\nthat module.  The names given in ``__all__`` are all considered public\nand are required to exist.  If ``__all__`` is not defined, the set of\npublic names includes all names found in the module\'s namespace which\ndo not begin with an underscore character (``\'_\'``). ``__all__``\nshould contain the entire public API. It is intended to avoid\naccidentally exporting items that are not part of the API (such as\nlibrary modules which were imported and used within the module).\n\nThe ``from`` form with ``*`` may only occur in a module scope.  The\nwild card form of import --- ``import *`` --- is only allowed at the\nmodule level. Attempting to use it in class or function definitions\nwill raise a ``SyntaxError``.\n\nWhen specifying what module to import you do not have to specify the\nabsolute name of the module. When a module or package is contained\nwithin another package it is possible to make a relative import within\nthe same top package without having to mention the package name. By\nusing leading dots in the specified module or package after ``from``\nyou can specify how high to traverse up the current package hierarchy\nwithout specifying exact names. One leading dot means the current\npackage where the module making the import exists. Two dots means up\none package level. Three dots is up two levels, etc. So if you execute\n``from . import mod`` from a module in the ``pkg`` package then you\nwill end up importing ``pkg.mod``. If you execute ``from ..subpkg2\nimport mod`` from within ``pkg.subpkg1`` you will import\n``pkg.subpkg2.mod``. The specification for relative imports is\ncontained within **PEP 328**.\n\n``importlib.import_module()`` is provided to support applications that\ndetermine which modules need to be loaded dynamically.\n\n\nFuture statements\n=================\n\nA *future statement* is a directive to the compiler that a particular\nmodule should be compiled using syntax or semantics that will be\navailable in a specified future release of Python.  The future\nstatement is intended to ease migration to future versions of Python\nthat introduce incompatible changes to the language.  It allows use of\nthe new features on a per-module basis before the release in which the\nfeature becomes standard.\n\n   future_statement ::= "from" "__future__" "import" feature ["as" name]\n                        ("," feature ["as" name])*\n                        | "from" "__future__" "import" "(" feature ["as" name]\n                        ("," feature ["as" name])* [","] ")"\n   feature          ::= identifier\n   name             ::= identifier\n\nA future statement must appear near the top of the module.  The only\nlines that can appear before a future statement are:\n\n* the module docstring (if any),\n\n* comments,\n\n* blank lines, and\n\n* other future statements.\n\nThe features recognized by Python 3.0 are ``absolute_import``,\n``division``, ``generators``, ``unicode_literals``,\n``print_function``, ``nested_scopes`` and ``with_statement``.  They\nare all redundant because they are always enabled, and only kept for\nbackwards compatibility.\n\nA future statement is recognized and treated specially at compile\ntime: Changes to the semantics of core constructs are often\nimplemented by generating different code.  It may even be the case\nthat a new feature introduces new incompatible syntax (such as a new\nreserved word), in which case the compiler may need to parse the\nmodule differently.  Such decisions cannot be pushed off until\nruntime.\n\nFor any given release, the compiler knows which feature names have\nbeen defined, and raises a compile-time error if a future statement\ncontains a feature not known to it.\n\nThe direct runtime semantics are the same as for any import statement:\nthere is a standard module ``__future__``, described later, and it\nwill be imported in the usual way at the time the future statement is\nexecuted.\n\nThe interesting runtime semantics depend on the specific feature\nenabled by the future statement.\n\nNote that there is nothing special about the statement:\n\n   import __future__ [as name]\n\nThat is not a future statement; it\'s an ordinary import statement with\nno special semantics or syntax restrictions.\n\nCode compiled by calls to the built-in functions ``exec()`` and\n``compile()`` that occur in a module ``M`` containing a future\nstatement will, by default, use the new syntax or semantics associated\nwith the future statement.  This can be controlled by optional\narguments to ``compile()`` --- see the documentation of that function\nfor details.\n\nA future statement typed at an interactive interpreter prompt will\ntake effect for the rest of the interpreter session.  If an\ninterpreter is started with the *-i* option, is passed a script name\nto execute, and the script includes a future statement, it will be in\neffect in the interactive session started after the script is\nexecuted.\n\nSee also:\n\n   **PEP 236** - Back to the __future__\n      The original proposal for the __future__ mechanism.\n',
+ 'import': '\nThe ``import`` statement\n************************\n\n   import_stmt     ::= "import" module ["as" name] ( "," module ["as" name] )*\n                   | "from" relative_module "import" identifier ["as" name]\n                   ( "," identifier ["as" name] )*\n                   | "from" relative_module "import" "(" identifier ["as" name]\n                   ( "," identifier ["as" name] )* [","] ")"\n                   | "from" module "import" "*"\n   module          ::= (identifier ".")* identifier\n   relative_module ::= "."* module | "."+\n   name            ::= identifier\n\nImport statements are executed in two steps: (1) find a module, and\ninitialize it if necessary; (2) define a name or names in the local\nnamespace (of the scope where the ``import`` statement occurs). The\nstatement comes in two forms differing on whether it uses the ``from``\nkeyword. The first form (without ``from``) repeats these steps for\neach identifier in the list. The form with ``from`` performs step (1)\nonce, and then performs step (2) repeatedly. For a reference\nimplementation of step (1), see the ``importlib`` module.\n\nTo understand how step (1) occurs, one must first understand how\nPython handles hierarchical naming of modules. To help organize\nmodules and provide a hierarchy in naming, Python has a concept of\npackages. A package can contain other packages and modules while\nmodules cannot contain other modules or packages. From a file system\nperspective, packages are directories and modules are files. The\noriginal specification for packages is still available to read,\nalthough minor details have changed since the writing of that\ndocument.\n\nOnce the name of the module is known (unless otherwise specified, the\nterm "module" will refer to both packages and modules), searching for\nthe module or package can begin. The first place checked is\n``sys.modules``, the cache of all modules that have been imported\npreviously. If the module is found there then it is used in step (2)\nof import unless ``None`` is found in ``sys.modules``, in which case\n``ImportError`` is raised.\n\nIf the module is not found in the cache, then ``sys.meta_path`` is\nsearched (the specification for ``sys.meta_path`` can be found in\n**PEP 302**). The object is a list of *finder* objects which are\nqueried in order as to whether they know how to load the module by\ncalling their ``find_module()`` method with the name of the module. If\nthe module happens to be contained within a package (as denoted by the\nexistence of a dot in the name), then a second argument to\n``find_module()`` is given as the value of the ``__path__`` attribute\nfrom the parent package (everything up to the last dot in the name of\nthe module being imported). If a finder can find the module it returns\na *loader* (discussed later) or returns ``None``.\n\nIf none of the finders on ``sys.meta_path`` are able to find the\nmodule then some implicitly defined finders are queried.\nImplementations of Python vary in what implicit meta path finders are\ndefined. The one they all do define, though, is one that handles\n``sys.path_hooks``, ``sys.path_importer_cache``, and ``sys.path``.\n\nThe implicit finder searches for the requested module in the "paths"\nspecified in one of two places ("paths" do not have to be file system\npaths). If the module being imported is supposed to be contained\nwithin a package then the second argument passed to ``find_module()``,\n``__path__`` on the parent package, is used as the source of paths. If\nthe module is not contained in a package then ``sys.path`` is used as\nthe source of paths.\n\nOnce the source of paths is chosen it is iterated over to find a\nfinder that can handle that path. The dict at\n``sys.path_importer_cache`` caches finders for paths and is checked\nfor a finder. If the path does not have a finder cached then\n``sys.path_hooks`` is searched by calling each object in the list with\na single argument of the path, returning a finder or raises\n``ImportError``. If a finder is returned then it is cached in\n``sys.path_importer_cache`` and then used for that path entry. If no\nfinder can be found but the path exists then a value of ``None`` is\nstored in ``sys.path_importer_cache`` to signify that an implicit,\nfile-based finder that handles modules stored as individual files\nshould be used for that path. If the path does not exist then a finder\nwhich always returns ``None`` is placed in the cache for the path.\n\nIf no finder can find the module then ``ImportError`` is raised.\nOtherwise some finder returned a loader whose ``load_module()`` method\nis called with the name of the module to load (see **PEP 302** for the\noriginal definition of loaders). A loader has several responsibilities\nto perform on a module it loads. First, if the module already exists\nin ``sys.modules`` (a possibility if the loader is called outside of\nthe import machinery) then it is to use that module for initialization\nand not a new module. But if the module does not exist in\n``sys.modules`` then it is to be added to that dict before\ninitialization begins. If an error occurs during loading of the module\nand it was added to ``sys.modules`` it is to be removed from the dict.\nIf an error occurs but the module was already in ``sys.modules`` it is\nleft in the dict.\n\nThe loader must set several attributes on the module. ``__name__`` is\nto be set to the name of the module. ``__file__`` is to be the "path"\nto the file unless the module is built-in (and thus listed in\n``sys.builtin_module_names``) in which case the attribute is not set.\nIf what is being imported is a package then ``__path__`` is to be set\nto a list of paths to be searched when looking for modules and\npackages contained within the package being imported. ``__package__``\nis optional but should be set to the name of package that contains the\nmodule or package (the empty string is used for module not contained\nin a package). ``__loader__`` is also optional but should be set to\nthe loader object that is loading the module.\n\nIf an error occurs during loading then the loader raises\n``ImportError`` if some other exception is not already being\npropagated. Otherwise the loader returns the module that was loaded\nand initialized.\n\nWhen step (1) finishes without raising an exception, step (2) can\nbegin.\n\nThe first form of ``import`` statement binds the module name in the\nlocal namespace to the module object, and then goes on to import the\nnext identifier, if any.  If the module name is followed by ``as``,\nthe name following ``as`` is used as the local name for the module.\n\nThe ``from`` form does not bind the module name: it goes through the\nlist of identifiers, looks each one of them up in the module found in\nstep (1), and binds the name in the local namespace to the object thus\nfound.  As with the first form of ``import``, an alternate local name\ncan be supplied by specifying "``as`` localname".  If a name is not\nfound, ``ImportError`` is raised.  If the list of identifiers is\nreplaced by a star (``\'*\'``), all public names defined in the module\nare bound in the local namespace of the ``import`` statement.\n\nThe *public names* defined by a module are determined by checking the\nmodule\'s namespace for a variable named ``__all__``; if defined, it\nmust be a sequence of strings which are names defined or imported by\nthat module.  The names given in ``__all__`` are all considered public\nand are required to exist.  If ``__all__`` is not defined, the set of\npublic names includes all names found in the module\'s namespace which\ndo not begin with an underscore character (``\'_\'``). ``__all__``\nshould contain the entire public API. It is intended to avoid\naccidentally exporting items that are not part of the API (such as\nlibrary modules which were imported and used within the module).\n\nThe ``from`` form with ``*`` may only occur in a module scope.  The\nwild card form of import --- ``import *`` --- is only allowed at the\nmodule level. Attempting to use it in class or function definitions\nwill raise a ``SyntaxError``.\n\nWhen specifying what module to import you do not have to specify the\nabsolute name of the module. When a module or package is contained\nwithin another package it is possible to make a relative import within\nthe same top package without having to mention the package name. By\nusing leading dots in the specified module or package after ``from``\nyou can specify how high to traverse up the current package hierarchy\nwithout specifying exact names. One leading dot means the current\npackage where the module making the import exists. Two dots means up\none package level. Three dots is up two levels, etc. So if you execute\n``from . import mod`` from a module in the ``pkg`` package then you\nwill end up importing ``pkg.mod``. If you execute ``from ..subpkg2\nimport mod`` from within ``pkg.subpkg1`` you will import\n``pkg.subpkg2.mod``. The specification for relative imports is\ncontained within **PEP 328**.\n\n``importlib.import_module()`` is provided to support applications that\ndetermine which modules need to be loaded dynamically.\n\n\nFuture statements\n=================\n\nA *future statement* is a directive to the compiler that a particular\nmodule should be compiled using syntax or semantics that will be\navailable in a specified future release of Python.  The future\nstatement is intended to ease migration to future versions of Python\nthat introduce incompatible changes to the language.  It allows use of\nthe new features on a per-module basis before the release in which the\nfeature becomes standard.\n\n   future_statement ::= "from" "__future__" "import" feature ["as" name]\n                        ("," feature ["as" name])*\n                        | "from" "__future__" "import" "(" feature ["as" name]\n                        ("," feature ["as" name])* [","] ")"\n   feature          ::= identifier\n   name             ::= identifier\n\nA future statement must appear near the top of the module.  The only\nlines that can appear before a future statement are:\n\n* the module docstring (if any),\n\n* comments,\n\n* blank lines, and\n\n* other future statements.\n\nThe features recognized by Python 3.0 are ``absolute_import``,\n``division``, ``generators``, ``unicode_literals``,\n``print_function``, ``nested_scopes`` and ``with_statement``.  They\nare all redundant because they are always enabled, and only kept for\nbackwards compatibility.\n\nA future statement is recognized and treated specially at compile\ntime: Changes to the semantics of core constructs are often\nimplemented by generating different code.  It may even be the case\nthat a new feature introduces new incompatible syntax (such as a new\nreserved word), in which case the compiler may need to parse the\nmodule differently.  Such decisions cannot be pushed off until\nruntime.\n\nFor any given release, the compiler knows which feature names have\nbeen defined, and raises a compile-time error if a future statement\ncontains a feature not known to it.\n\nThe direct runtime semantics are the same as for any import statement:\nthere is a standard module ``__future__``, described later, and it\nwill be imported in the usual way at the time the future statement is\nexecuted.\n\nThe interesting runtime semantics depend on the specific feature\nenabled by the future statement.\n\nNote that there is nothing special about the statement:\n\n   import __future__ [as name]\n\nThat is not a future statement; it\'s an ordinary import statement with\nno special semantics or syntax restrictions.\n\nCode compiled by calls to the built-in functions ``exec()`` and\n``compile()`` that occur in a module ``M`` containing a future\nstatement will, by default, use the new syntax or semantics associated\nwith the future statement.  This can be controlled by optional\narguments to ``compile()`` --- see the documentation of that function\nfor details.\n\nA future statement typed at an interactive interpreter prompt will\ntake effect for the rest of the interpreter session.  If an\ninterpreter is started with the *-i* option, is passed a script name\nto execute, and the script includes a future statement, it will be in\neffect in the interactive session started after the script is\nexecuted.\n\nSee also:\n\n   **PEP 236** - Back to the __future__\n      The original proposal for the __future__ mechanism.\n',
  'in': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation.  Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n   comparison    ::= or_expr ( comp_operator or_expr )*\n   comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n                     | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects.  The objects need not have the same type.\nIf both are numbers, they are converted to a common type.  Otherwise,\nthe ``==`` and ``!=`` operators *always* consider objects of different\ntypes to be unequal, while the ``<``, ``>``, ``>=`` and ``<=``\noperators raise a ``TypeError`` when comparing objects of different\ntypes that do not implement these operators for the given pair of\ntypes.  You can control comparison behavior of objects of non-built-in\ntypes by defining rich comparison methods like ``__gt__()``, described\nin section *Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values ``float(\'NaN\')`` and ``Decimal(\'NaN\')`` are special. The\n  are identical to themselves, ``x is x`` but are not equal to\n  themselves, ``x != x``.  Additionally, comparing any value to a\n  not-a-number value will return ``False``.  For example, both ``3 <\n  float(\'NaN\')`` and ``float(\'NaN\') < 3`` will return ``False``.\n\n* Bytes objects are compared lexicographically using the numeric\n  values of their elements.\n\n* Strings are compared lexicographically using the numeric equivalents\n  (the result of the built-in function ``ord()``) of their characters.\n  [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison of\n  corresponding elements.  This means that to compare equal, each\n  element must compare equal and the two sequences must be of the same\n  type and have the same length.\n\n  If not equal, the sequences are ordered the same as their first\n  differing elements.  For example, ``[1,2,x] <= [1,2,y]`` has the\n  same value as ``x <= y``.  If the corresponding element does not\n  exist, the shorter sequence is ordered first (for example, ``[1,2] <\n  [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if they have the\n  same ``(key, value)`` pairs. Order comparisons ``(\'<\', \'<=\', \'>=\',\n  \'>\')`` raise ``TypeError``.\n\n* Sets and frozensets define comparison operators to mean subset and\n  superset tests.  Those relations do not define total orderings (the\n  two sets ``{1,2}`` and {2,3} are not equal, nor subsets of one\n  another, nor supersets of one another).  Accordingly, sets are not\n  appropriate arguments for functions which depend on total ordering.\n  For example, ``min()``, ``max()``, and ``sorted()`` produce\n  undefined results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they are\n  the same object; the choice whether one object is considered smaller\n  or larger than another one is made arbitrarily but consistently\n  within one execution of a program.\n\nComparison of objects of the differing types depends on whether either\nof the types provide explicit support for the comparison.  Most\nnumeric types can be compared with one another, but comparisons of\n``float`` and ``Decimal`` are not supported to avoid the inevitable\nconfusion arising from representation issues such as ``float(\'1.1\')``\nbeing inexactly represented and therefore not exactly equal to\n``Decimal(\'1.1\')`` which is.  When cross-type comparison is not\nsupported, the comparison method returns ``NotImplemented``.  This can\ncreate the illusion of non-transitivity between supported cross-type\ncomparisons and unsupported comparisons.  For example, ``Decimal(2) ==\n2`` and ``2 == float(2)`` but ``Decimal(2) != float(2)``.\n\nThe operators ``in`` and ``not in`` test for membership.  ``x in s``\nevaluates to true if *x* is a member of *s*, and false otherwise.  ``x\nnot in s`` returns the negation of ``x in s``.  All built-in sequences\nand set types support this as well as dictionary, for which ``in``\ntests whether a the dictionary has a given key. For container types\nsuch as list, tuple, set, frozenset, dict, or collections.deque, the\nexpression ``x in y`` is equivalent to ``any(x is e or x == e for e in\ny)``.\n\nFor the string and bytes types, ``x in y`` is true if and only if *x*\nis a substring of *y*.  An equivalent test is ``y.find(x) != -1``.\nEmpty strings are always considered to be a substring of any other\nstring, so ``"" in "abc"`` will return ``True``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` but do\ndefine ``__iter__()``, ``x in y`` is true if some value ``z`` with ``x\n== z`` is produced while iterating over ``y``.  If an exception is\nraised during the iteration, it is as if ``in`` raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n``__getitem__()``, ``x in y`` is true if and only if there is a non-\nnegative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception.  (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object.  ``x is\nnot y`` yields the inverse truth value. [4]\n',
  'integers': '\nInteger literals\n****************\n\nInteger literals are described by the following lexical definitions:\n\n   integer        ::= decimalinteger | octinteger | hexinteger | bininteger\n   decimalinteger ::= nonzerodigit digit* | "0"+\n   nonzerodigit   ::= "1"..."9"\n   digit          ::= "0"..."9"\n   octinteger     ::= "0" ("o" | "O") octdigit+\n   hexinteger     ::= "0" ("x" | "X") hexdigit+\n   bininteger     ::= "0" ("b" | "B") bindigit+\n   octdigit       ::= "0"..."7"\n   hexdigit       ::= digit | "a"..."f" | "A"..."F"\n   bindigit       ::= "0" | "1"\n\nThere is no limit for the length of integer literals apart from what\ncan be stored in available memory.\n\nNote that leading zeros in a non-zero decimal number are not allowed.\nThis is for disambiguation with C-style octal literals, which Python\nused before version 3.0.\n\nSome examples of integer literals:\n\n   7     2147483647                        0o177    0b100110111\n   3     79228162514264337593543950336     0o377    0x100000000\n         79228162514264337593543950336              0xdeadbeef\n',
  'lambda': '\nLambdas\n*******\n\n   lambda_form        ::= "lambda" [parameter_list]: expression\n   lambda_form_nocond ::= "lambda" [parameter_list]: expression_nocond\n\nLambda forms (lambda expressions) have the same syntactic position as\nexpressions.  They are a shorthand to create anonymous functions; the\nexpression ``lambda arguments: expression`` yields a function object.\nThe unnamed object behaves like a function object defined with\n\n   def <lambda>(arguments):\n       return expression\n\nSee section *Function definitions* for the syntax of parameter lists.\nNote that functions created with lambda forms cannot contain\nstatements or annotations.\n',
@@ -50,7 +50,7 @@
  'numbers': "\nNumeric literals\n****************\n\nThere are three types of numeric literals: integers, floating point\nnumbers, and imaginary numbers.  There are no complex literals\n(complex numbers can be formed by adding a real number and an\nimaginary number).\n\nNote that numeric literals do not include a sign; a phrase like ``-1``\nis actually an expression composed of the unary operator '``-``' and\nthe literal ``1``.\n",
  'numeric-types': "\nEmulating numeric types\n***********************\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n   These methods are called to implement the binary arithmetic\n   operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n   ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n   ``|``).  For instance, to evaluate the expression ``x + y``, where\n   *x* is an instance of a class that has an ``__add__()`` method,\n   ``x.__add__(y)`` is called.  The ``__divmod__()`` method should be\n   the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n   should not be related to ``__truediv__()``.  Note that\n   ``__pow__()`` should be defined to accept an optional third\n   argument if the ternary version of the built-in ``pow()`` function\n   is to be supported.\n\n   If one of those methods does not support the operation with the\n   supplied arguments, it should return ``NotImplemented``.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n   These methods are called to implement the binary arithmetic\n   operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n   ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n   ``|``) with reflected (swapped) operands. These functions are only\n   called if the left operand does not support the corresponding\n   operation and the operands are of different types. [2]  For\n   instance, to evaluate the expression ``x - y``, where *y* is an\n   instance of a class that has an ``__rsub__()`` method,\n   ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns\n   *NotImplemented*.\n\n   Note that ternary ``pow()`` will not try calling ``__rpow__()``\n   (the coercion rules would become too complicated).\n\n   Note: If the right operand's type is a subclass of the left operand's\n     type and that subclass provides the reflected method for the\n     operation, this method will be called before the left operand's\n     non-reflected method.  This behavior allows subclasses to\n     override their ancestors' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n   These methods are called to implement the augmented arithmetic\n   assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n   ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``).  These methods\n   should attempt to do the operation in-place (modifying *self*) and\n   return the result (which could be, but does not have to be,\n   *self*).  If a specific method is not defined, the augmented\n   assignment falls back to the normal methods.  For instance, to\n   execute the statement ``x += y``, where *x* is an instance of a\n   class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n   called.  If *x* is an instance of a class that does not define a\n   ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n   considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n   Called to implement the unary arithmetic operations (``-``, ``+``,\n   ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n   Called to implement the built-in functions ``complex()``,\n   ``int()``, ``float()`` and ``round()``.  Should return a value of\n   the appropriate type.\n\nobject.__index__(self)\n\n   Called to implement ``operator.index()``.  Also called whenever\n   Python needs an integer object (such as in slicing, or in the\n   built-in ``bin()``, ``hex()`` and ``oct()`` functions). Must return\n   an integer.\n",
  'objects': '\nObjects, values and types\n*************************\n\n*Objects* are Python\'s abstraction for data.  All data in a Python\nprogram is represented by objects or by relations between objects. (In\na sense, and in conformance to Von Neumann\'s model of a "stored\nprogram computer," code is also represented by objects.)\n\nEvery object has an identity, a type and a value.  An object\'s\n*identity* never changes once it has been created; you may think of it\nas the object\'s address in memory.  The \'``is``\' operator compares the\nidentity of two objects; the ``id()`` function returns an integer\nrepresenting its identity (currently implemented as its address). An\nobject\'s *type* is also unchangeable. [1] An object\'s type determines\nthe operations that the object supports (e.g., "does it have a\nlength?") and also defines the possible values for objects of that\ntype.  The ``type()`` function returns an object\'s type (which is an\nobject itself).  The *value* of some objects can change.  Objects\nwhose value can change are said to be *mutable*; objects whose value\nis unchangeable once they are created are called *immutable*. (The\nvalue of an immutable container object that contains a reference to a\nmutable object can change when the latter\'s value is changed; however\nthe container is still considered immutable, because the collection of\nobjects it contains cannot be changed.  So, immutability is not\nstrictly the same as having an unchangeable value, it is more subtle.)\nAn object\'s mutability is determined by its type; for instance,\nnumbers, strings and tuples are immutable, while dictionaries and\nlists are mutable.\n\nObjects are never explicitly destroyed; however, when they become\nunreachable they may be garbage-collected.  An implementation is\nallowed to postpone garbage collection or omit it altogether --- it is\na matter of implementation quality how garbage collection is\nimplemented, as long as no objects are collected that are still\nreachable.\n\n**CPython implementation detail:** CPython currently uses a reference-\ncounting scheme with (optional) delayed detection of cyclically linked\ngarbage, which collects most objects as soon as they become\nunreachable, but is not guaranteed to collect garbage containing\ncircular references.  See the documentation of the ``gc`` module for\ninformation on controlling the collection of cyclic garbage. Other\nimplementations act differently and CPython may change.\n\nNote that the use of the implementation\'s tracing or debugging\nfacilities may keep objects alive that would normally be collectable.\nAlso note that catching an exception with a \'``try``...``except``\'\nstatement may keep objects alive.\n\nSome objects contain references to "external" resources such as open\nfiles or windows.  It is understood that these resources are freed\nwhen the object is garbage-collected, but since garbage collection is\nnot guaranteed to happen, such objects also provide an explicit way to\nrelease the external resource, usually a ``close()`` method. Programs\nare strongly recommended to explicitly close such objects.  The\n\'``try``...``finally``\' statement and the \'``with``\' statement provide\nconvenient ways to do this.\n\nSome objects contain references to other objects; these are called\n*containers*. Examples of containers are tuples, lists and\ndictionaries.  The references are part of a container\'s value.  In\nmost cases, when we talk about the value of a container, we imply the\nvalues, not the identities of the contained objects; however, when we\ntalk about the mutability of a container, only the identities of the\nimmediately contained objects are implied.  So, if an immutable\ncontainer (like a tuple) contains a reference to a mutable object, its\nvalue changes if that mutable object is changed.\n\nTypes affect almost all aspects of object behavior.  Even the\nimportance of object identity is affected in some sense: for immutable\ntypes, operations that compute new values may actually return a\nreference to any existing object with the same type and value, while\nfor mutable objects this is not allowed.  E.g., after ``a = 1; b =\n1``, ``a`` and ``b`` may or may not refer to the same object with the\nvalue one, depending on the implementation, but after ``c = []; d =\n[]``, ``c`` and ``d`` are guaranteed to refer to two different,\nunique, newly created empty lists. (Note that ``c = d = []`` assigns\nthe same object to both ``c`` and ``d``.)\n',
- 'operator-summary': '\nSummary\n*******\n\nThe following table summarizes the operator precedences in Python,\nfrom lowest precedence (least binding) to highest precedence (most\nbinding).  Operators in the same box have the same precedence.  Unless\nthe syntax is explicitly given, operators are binary.  Operators in\nthe same box group left to right (except for comparisons, including\ntests, which all have the same precedence and chain from left to right\n--- see section *Comparisons* --- and exponentiation, which groups\nfrom right to left).\n\n+-------------------------------------------------+---------------------------------------+\n| Operator                                        | Description                           |\n+=================================================+=======================================+\n| ``lambda``                                      | Lambda expression                     |\n+-------------------------------------------------+---------------------------------------+\n| ``if`` -- ``else``                              | Conditional expression                |\n+-------------------------------------------------+---------------------------------------+\n| ``or``                                          | Boolean OR                            |\n+-------------------------------------------------+---------------------------------------+\n| ``and``                                         | Boolean AND                           |\n+-------------------------------------------------+---------------------------------------+\n| ``not`` *x*                                     | Boolean NOT                           |\n+-------------------------------------------------+---------------------------------------+\n| ``in``, ``not`` ``in``, ``is``, ``is not``,     | Comparisons, including membership     |\n| ``<``, ``<=``, ``>``, ``>=``, ``!=``, ``==``    | tests and identity tests,             |\n+-------------------------------------------------+---------------------------------------+\n| ``|``                                           | Bitwise OR                            |\n+-------------------------------------------------+---------------------------------------+\n| ``^``                                           | Bitwise XOR                           |\n+-------------------------------------------------+---------------------------------------+\n| ``&``                                           | Bitwise AND                           |\n+-------------------------------------------------+---------------------------------------+\n| ``<<``, ``>>``                                  | Shifts                                |\n+-------------------------------------------------+---------------------------------------+\n| ``+``, ``-``                                    | Addition and subtraction              |\n+-------------------------------------------------+---------------------------------------+\n| ``*``, ``/``, ``//``, ``%``                     | Multiplication, division, remainder   |\n|                                                 | [5]                                   |\n+-------------------------------------------------+---------------------------------------+\n| ``+x``, ``-x``, ``~x``                          | Positive, negative, bitwise NOT       |\n+-------------------------------------------------+---------------------------------------+\n| ``**``                                          | Exponentiation [6]                    |\n+-------------------------------------------------+---------------------------------------+\n| ``x[index]``, ``x[index:index]``,               | Subscription, slicing, call,          |\n| ``x(arguments...)``, ``x.attribute``            | attribute reference                   |\n+-------------------------------------------------+---------------------------------------+\n| ``(expressions...)``, ``[expressions...]``,     | Binding or tuple display, list        |\n| ``{key:datum...}``,                             | display, dictionary display,          |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While ``abs(x%y) < abs(y)`` is true mathematically, for floats it\n    may not be true numerically due to roundoff.  For example, and\n    assuming a platform on which a Python float is an IEEE 754 double-\n    precision number, in order that ``-1e-100 % 1e100`` have the same\n    sign as ``1e100``, the computed result is ``-1e-100 + 1e100``,\n    which is numerically exactly equal to ``1e100``.  Function\n    ``fmod()`` in the ``math`` module returns a result whose sign\n    matches the sign of the first argument instead, and so returns\n    ``-1e-100`` in this case. Which approach is more appropriate\n    depends on the application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n    possible for ``x//y`` to be one larger than ``(x-x%y)//y`` due to\n    rounding.  In such cases, Python returns the latter result, in\n    order to preserve that ``divmod(x,y)[0] * y + x % y`` be very\n    close to ``x``.\n\n[3] While comparisons between strings make sense at the byte level,\n    they may be counter-intuitive to users.  For example, the strings\n    ``"\\u00C7"`` and ``"\\u0327\\u0043"`` compare differently, even\n    though they both represent the same unicode character (LATIN\n    CAPITAL LETTER C WITH CEDILLA).  To compare strings in a human\n    recognizable way, compare using ``unicodedata.normalize()``.\n\n[4] Due to automatic garbage-collection, free lists, and the dynamic\n    nature of descriptors, you may notice seemingly unusual behaviour\n    in certain uses of the ``is`` operator, like those involving\n    comparisons between instance methods, or constants.  Check their\n    documentation for more info.\n\n[5] The ``%`` is also used for string formatting; the same precedence\n    applies.\n\n[6] The power operator ``**`` binds less tightly than an arithmetic or\n    bitwise unary operator on its right, that is, ``2**-1`` is\n    ``0.5``.\n',
+ 'operator-summary': '\nSummary\n*******\n\nThe following table summarizes the operator precedences in Python,\nfrom lowest precedence (least binding) to highest precedence (most\nbinding).  Operators in the same box have the same precedence.  Unless\nthe syntax is explicitly given, operators are binary.  Operators in\nthe same box group left to right (except for comparisons, including\ntests, which all have the same precedence and chain from left to right\n--- see section *Comparisons* --- and exponentiation, which groups\nfrom right to left).\n\n+-------------------------------------------------+---------------------------------------+\n| Operator                                        | Description                           |\n+=================================================+=======================================+\n| ``lambda``                                      | Lambda expression                     |\n+-------------------------------------------------+---------------------------------------+\n| ``if`` -- ``else``                              | Conditional expression                |\n+-------------------------------------------------+---------------------------------------+\n| ``or``                                          | Boolean OR                            |\n+-------------------------------------------------+---------------------------------------+\n| ``and``                                         | Boolean AND                           |\n+-------------------------------------------------+---------------------------------------+\n| ``not`` *x*                                     | Boolean NOT                           |\n+-------------------------------------------------+---------------------------------------+\n| ``in``, ``not`` ``in``, ``is``, ``is not``,     | Comparisons, including membership     |\n| ``<``, ``<=``, ``>``, ``>=``, ``!=``, ``==``    | tests and identity tests,             |\n+-------------------------------------------------+---------------------------------------+\n| ``|``                                           | Bitwise OR                            |\n+-------------------------------------------------+---------------------------------------+\n| ``^``                                           | Bitwise XOR                           |\n+-------------------------------------------------+---------------------------------------+\n| ``&``                                           | Bitwise AND                           |\n+-------------------------------------------------+---------------------------------------+\n| ``<<``, ``>>``                                  | Shifts                                |\n+-------------------------------------------------+---------------------------------------+\n| ``+``, ``-``                                    | Addition and subtraction              |\n+-------------------------------------------------+---------------------------------------+\n| ``*``, ``/``, ``//``, ``%``                     | Multiplication, division, remainder   |\n|                                                 | [5]                                   |\n+-------------------------------------------------+---------------------------------------+\n| ``+x``, ``-x``, ``~x``                          | Positive, negative, bitwise NOT       |\n+-------------------------------------------------+---------------------------------------+\n| ``**``                                          | Exponentiation [6]                    |\n+-------------------------------------------------+---------------------------------------+\n| ``x[index]``, ``x[index:index]``,               | Subscription, slicing, call,          |\n| ``x(arguments...)``, ``x.attribute``            | attribute reference                   |\n+-------------------------------------------------+---------------------------------------+\n| ``(expressions...)``, ``[expressions...]``,     | Binding or tuple display, list        |\n| ``{key:datum...}``, ``{expressions...}``        | display, dictionary display, set      |\n|                                                 | display                               |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While ``abs(x%y) < abs(y)`` is true mathematically, for floats it\n    may not be true numerically due to roundoff.  For example, and\n    assuming a platform on which a Python float is an IEEE 754 double-\n    precision number, in order that ``-1e-100 % 1e100`` have the same\n    sign as ``1e100``, the computed result is ``-1e-100 + 1e100``,\n    which is numerically exactly equal to ``1e100``.  The function\n    ``math.fmod()`` returns a result whose sign matches the sign of\n    the first argument instead, and so returns ``-1e-100`` in this\n    case. Which approach is more appropriate depends on the\n    application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n    possible for ``x//y`` to be one larger than ``(x-x%y)//y`` due to\n    rounding.  In such cases, Python returns the latter result, in\n    order to preserve that ``divmod(x,y)[0] * y + x % y`` be very\n    close to ``x``.\n\n[3] While comparisons between strings make sense at the byte level,\n    they may be counter-intuitive to users.  For example, the strings\n    ``"\\u00C7"`` and ``"\\u0327\\u0043"`` compare differently, even\n    though they both represent the same unicode character (LATIN\n    CAPITAL LETTER C WITH CEDILLA).  To compare strings in a human\n    recognizable way, compare using ``unicodedata.normalize()``.\n\n[4] Due to automatic garbage-collection, free lists, and the dynamic\n    nature of descriptors, you may notice seemingly unusual behaviour\n    in certain uses of the ``is`` operator, like those involving\n    comparisons between instance methods, or constants.  Check their\n    documentation for more info.\n\n[5] The ``%`` operator is also used for string formatting; the same\n    precedence applies.\n\n[6] The power operator ``**`` binds less tightly than an arithmetic or\n    bitwise unary operator on its right, that is, ``2**-1`` is\n    ``0.5``.\n',
  'pass': '\nThe ``pass`` statement\n**********************\n\n   pass_stmt ::= "pass"\n\n``pass`` is a null operation --- when it is executed, nothing happens.\nIt is useful as a placeholder when a statement is required\nsyntactically, but no code needs to be executed, for example:\n\n   def f(arg): pass    # a function that does nothing (yet)\n\n   class C: pass       # a class with no methods (yet)\n',
  'power': '\nThe power operator\n******************\n\nThe power operator binds more tightly than unary operators on its\nleft; it binds less tightly than unary operators on its right.  The\nsyntax is:\n\n   power ::= primary ["**" u_expr]\n\nThus, in an unparenthesized sequence of power and unary operators, the\noperators are evaluated from right to left (this does not constrain\nthe evaluation order for the operands): ``-1**2`` results in ``-1``.\n\nThe power operator has the same semantics as the built-in ``pow()``\nfunction, when called with two arguments: it yields its left argument\nraised to the power of its right argument.  The numeric arguments are\nfirst converted to a common type, and the result is of that type.\n\nFor int operands, the result has the same type as the operands unless\nthe second argument is negative; in that case, all arguments are\nconverted to float and a float result is delivered. For example,\n``10**2`` returns ``100``, but ``10**-2`` returns ``0.01``.\n\nRaising ``0.0`` to a negative power results in a\n``ZeroDivisionError``. Raising a negative number to a fractional power\nresults in a ``complex`` number. (In earlier versions it raised a\n``ValueError``.)\n',
  'raise': '\nThe ``raise`` statement\n***********************\n\n   raise_stmt ::= "raise" [expression ["from" expression]]\n\nIf no expressions are present, ``raise`` re-raises the last exception\nthat was active in the current scope.  If no exception is active in\nthe current scope, a ``TypeError`` exception is raised indicating that\nthis is an error (if running under IDLE, a ``queue.Empty`` exception\nis raised instead).\n\nOtherwise, ``raise`` evaluates the first expression as the exception\nobject.  It must be either a subclass or an instance of\n``BaseException``. If it is a class, the exception instance will be\nobtained when needed by instantiating the class with no arguments.\n\nThe *type* of the exception is the exception instance\'s class, the\n*value* is the instance itself.\n\nA traceback object is normally created automatically when an exception\nis raised and attached to it as the ``__traceback__`` attribute, which\nis writable. You can create an exception and set your own traceback in\none step using the ``with_traceback()`` exception method (which\nreturns the same exception instance, with its traceback set to its\nargument), like so:\n\n   raise Exception("foo occurred").with_traceback(tracebackobj)\n\nThe ``from`` clause is used for exception chaining: if given, the\nsecond *expression* must be another exception class or instance, which\nwill then be attached to the raised exception as the ``__cause__``\nattribute (which is writable).  If the raised exception is not\nhandled, both exceptions will be printed:\n\n   >>> try:\n   ...     print(1 / 0)\n   ... except Exception as exc:\n   ...     raise RuntimeError("Something bad happened") from exc\n   ...\n   Traceback (most recent call last):\n     File "<stdin>", line 2, in <module>\n   ZeroDivisionError: int division or modulo by zero\n\n   The above exception was the direct cause of the following exception:\n\n   Traceback (most recent call last):\n     File "<stdin>", line 4, in <module>\n   RuntimeError: Something bad happened\n\nA similar mechanism works implicitly if an exception is raised inside\nan exception handler: the previous exception is then attached as the\nnew exception\'s ``__context__`` attribute:\n\n   >>> try:\n   ...     print(1 / 0)\n   ... except:\n   ...     raise RuntimeError("Something bad happened")\n   ...\n   Traceback (most recent call last):\n     File "<stdin>", line 2, in <module>\n   ZeroDivisionError: int division or modulo by zero\n\n   During handling of the above exception, another exception occurred:\n\n   Traceback (most recent call last):\n     File "<stdin>", line 4, in <module>\n   RuntimeError: Something bad happened\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information about handling exceptions is in section\n*The try statement*.\n',
@@ -59,7 +59,7 @@
  'shifting': '\nShifting operations\n*******************\n\nThe shifting operations have lower priority than the arithmetic\noperations:\n\n   shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n\nThese operators accept integers as arguments.  They shift the first\nargument to the left or right by the number of bits given by the\nsecond argument.\n\nA right shift by *n* bits is defined as division by ``pow(2,n)``.  A\nleft shift by *n* bits is defined as multiplication with ``pow(2,n)``.\n\nNote: In the current implementation, the right-hand operand is required to\n  be at most ``sys.maxsize``.  If the right-hand operand is larger\n  than ``sys.maxsize`` an ``OverflowError`` exception is raised.\n',
  'slicings': '\nSlicings\n********\n\nA slicing selects a range of items in a sequence object (e.g., a\nstring, tuple or list).  Slicings may be used as expressions or as\ntargets in assignment or ``del`` statements.  The syntax for a\nslicing:\n\n   slicing      ::= primary "[" slice_list "]"\n   slice_list   ::= slice_item ("," slice_item)* [","]\n   slice_item   ::= expression | proper_slice\n   proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]\n   lower_bound  ::= expression\n   upper_bound  ::= expression\n   stride       ::= expression\n\nThere is ambiguity in the formal syntax here: anything that looks like\nan expression list also looks like a slice list, so any subscription\ncan be interpreted as a slicing.  Rather than further complicating the\nsyntax, this is disambiguated by defining that in this case the\ninterpretation as a subscription takes priority over the\ninterpretation as a slicing (this is the case if the slice list\ncontains no proper slice).\n\nThe semantics for a slicing are as follows.  The primary must evaluate\nto a mapping object, and it is indexed (using the same\n``__getitem__()`` method as normal subscription) with a key that is\nconstructed from the slice list, as follows.  If the slice list\ncontains at least one comma, the key is a tuple containing the\nconversion of the slice items; otherwise, the conversion of the lone\nslice item is the key.  The conversion of a slice item that is an\nexpression is that expression.  The conversion of a proper slice is a\nslice object (see section *The standard type hierarchy*) whose\n``start``, ``stop`` and ``step`` attributes are the values of the\nexpressions given as lower bound, upper bound and stride,\nrespectively, substituting ``None`` for missing expressions.\n',
  'specialattrs': "\nSpecial Attributes\n******************\n\nThe implementation adds a few special read-only attributes to several\nobject types, where they are relevant.  Some of these are not reported\nby the ``dir()`` built-in function.\n\nobject.__dict__\n\n   A dictionary or other mapping object used to store an object's\n   (writable) attributes.\n\ninstance.__class__\n\n   The class to which a class instance belongs.\n\nclass.__bases__\n\n   The tuple of base classes of a class object.\n\nclass.__name__\n\n   The name of the class or type.\n\nThe following attributes are only supported by *new-style class*es.\n\nclass.__mro__\n\n   This attribute is a tuple of classes that are considered when\n   looking for base classes during method resolution.\n\nclass.mro()\n\n   This method can be overridden by a metaclass to customize the\n   method resolution order for its instances.  It is called at class\n   instantiation, and its result is stored in ``__mro__``.\n\nclass.__subclasses__()\n\n   Each new-style class keeps a list of weak references to its\n   immediate subclasses.  This method returns a list of all those\n   references still alive. Example:\n\n      >>> int.__subclasses__()\n      [<type 'bool'>]\n\n-[ Footnotes ]-\n\n[1] Additional information on these special methods may be found in\n    the Python Reference Manual (*Basic customization*).\n\n[2] As a consequence, the list ``[1, 2]`` is considered equal to\n    ``[1.0, 2.0]``, and similarly for tuples.\n\n[3] They must have since the parser can't tell the type of the\n    operands.\n\n[4] To format only a tuple you should therefore provide a singleton\n    tuple whose only element is the tuple to be formatted.\n",
- 'specialnames': '\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators.  For instance, if a class defines\na method named ``__getitem__()``, and ``x`` is an instance of this\nclass, then ``x[i]`` is roughly equivalent to ``type(x).__getitem__(x,\ni)``.  Except where mentioned, attempts to execute an operation raise\nan exception when no appropriate method is defined (typically\n``AttributeError`` or ``TypeError``).\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled.  For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense.  (One example of this is the\n``NodeList`` interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n   Called to create a new instance of class *cls*.  ``__new__()`` is a\n   static method (special-cased so you need not declare it as such)\n   that takes the class of which an instance was requested as its\n   first argument.  The remaining arguments are those passed to the\n   object constructor expression (the call to the class).  The return\n   value of ``__new__()`` should be the new object instance (usually\n   an instance of *cls*).\n\n   Typical implementations create a new instance of the class by\n   invoking the superclass\'s ``__new__()`` method using\n   ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n   arguments and then modifying the newly-created instance as\n   necessary before returning it.\n\n   If ``__new__()`` returns an instance of *cls*, then the new\n   instance\'s ``__init__()`` method will be invoked like\n   ``__init__(self[, ...])``, where *self* is the new instance and the\n   remaining arguments are the same as were passed to ``__new__()``.\n\n   If ``__new__()`` does not return an instance of *cls*, then the new\n   instance\'s ``__init__()`` method will not be invoked.\n\n   ``__new__()`` is intended mainly to allow subclasses of immutable\n   types (like int, str, or tuple) to customize instance creation.  It\n   is also commonly overridden in custom metaclasses in order to\n   customize class creation.\n\nobject.__init__(self[, ...])\n\n   Called when the instance is created.  The arguments are those\n   passed to the class constructor expression.  If a base class has an\n   ``__init__()`` method, the derived class\'s ``__init__()`` method,\n   if any, must explicitly call it to ensure proper initialization of\n   the base class part of the instance; for example:\n   ``BaseClass.__init__(self, [args...])``.  As a special constraint\n   on constructors, no value may be returned; doing so will cause a\n   ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n   Called when the instance is about to be destroyed.  This is also\n   called a destructor.  If a base class has a ``__del__()`` method,\n   the derived class\'s ``__del__()`` method, if any, must explicitly\n   call it to ensure proper deletion of the base class part of the\n   instance.  Note that it is possible (though not recommended!) for\n   the ``__del__()`` method to postpone destruction of the instance by\n   creating a new reference to it.  It may then be called at a later\n   time when this new reference is deleted.  It is not guaranteed that\n   ``__del__()`` methods are called for objects that still exist when\n   the interpreter exits.\n\n   Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n     decrements the reference count for ``x`` by one, and the latter\n     is only called when ``x``\'s reference count reaches zero.  Some\n     common situations that may prevent the reference count of an\n     object from going to zero include: circular references between\n     objects (e.g., a doubly-linked list or a tree data structure with\n     parent and child pointers); a reference to the object on the\n     stack frame of a function that caught an exception (the traceback\n     stored in ``sys.exc_info()[2]`` keeps the stack frame alive); or\n     a reference to the object on the stack frame that raised an\n     unhandled exception in interactive mode (the traceback stored in\n     ``sys.last_traceback`` keeps the stack frame alive).  The first\n     situation can only be remedied by explicitly breaking the cycles;\n     the latter two situations can be resolved by storing ``None`` in\n     ``sys.last_traceback``. Circular references which are garbage are\n     detected when the option cycle detector is enabled (it\'s on by\n     default), but can only be cleaned up if there are no Python-\n     level ``__del__()`` methods involved. Refer to the documentation\n     for the ``gc`` module for more information about how\n     ``__del__()`` methods are handled by the cycle detector,\n     particularly the description of the ``garbage`` value.\n\n   Warning: Due to the precarious circumstances under which ``__del__()``\n     methods are invoked, exceptions that occur during their execution\n     are ignored, and a warning is printed to ``sys.stderr`` instead.\n     Also, when ``__del__()`` is invoked in response to a module being\n     deleted (e.g., when execution of the program is done), other\n     globals referenced by the ``__del__()`` method may already have\n     been deleted or in the process of being torn down (e.g. the\n     import machinery shutting down).  For this reason, ``__del__()``\n     methods should do the absolute minimum needed to maintain\n     external invariants.  Starting with version 1.5, Python\n     guarantees that globals whose name begins with a single\n     underscore are deleted from their module before other globals are\n     deleted; if no other references to such globals exist, this may\n     help in assuring that imported modules are still available at the\n     time when the ``__del__()`` method is called.\n\nobject.__repr__(self)\n\n   Called by the ``repr()`` built-in function to compute the\n   "official" string representation of an object.  If at all possible,\n   this should look like a valid Python expression that could be used\n   to recreate an object with the same value (given an appropriate\n   environment).  If this is not possible, a string of the form\n   ``<...some useful description...>`` should be returned. The return\n   value must be a string object. If a class defines ``__repr__()``\n   but not ``__str__()``, then ``__repr__()`` is also used when an\n   "informal" string representation of instances of that class is\n   required.\n\n   This is typically used for debugging, so it is important that the\n   representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n   Called by the ``str()`` built-in function and by the ``print()``\n   function to compute the "informal" string representation of an\n   object.  This differs from ``__repr__()`` in that it does not have\n   to be a valid Python expression: a more convenient or concise\n   representation may be used instead. The return value must be a\n   string object.\n\nobject.__format__(self, format_spec)\n\n   Called by the ``format()`` built-in function (and by extension, the\n   ``format()`` method of class ``str``) to produce a "formatted"\n   string representation of an object. The ``format_spec`` argument is\n   a string that contains a description of the formatting options\n   desired. The interpretation of the ``format_spec`` argument is up\n   to the type implementing ``__format__()``, however most classes\n   will either delegate formatting to one of the built-in types, or\n   use a similar formatting option syntax.\n\n   See *Format Specification Mini-Language* for a description of the\n   standard formatting syntax.\n\n   The return value must be a string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n   These are the so-called "rich comparison" methods. The\n   correspondence between operator symbols and method names is as\n   follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n   ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` calls\n   ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls\n   ``x.__ge__(y)``.\n\n   A rich comparison method may return the singleton\n   ``NotImplemented`` if it does not implement the operation for a\n   given pair of arguments. By convention, ``False`` and ``True`` are\n   returned for a successful comparison. However, these methods can\n   return any value, so if the comparison operator is used in a\n   Boolean context (e.g., in the condition of an ``if`` statement),\n   Python will call ``bool()`` on the value to determine if the result\n   is true or false.\n\n   There are no implied relationships among the comparison operators.\n   The truth of ``x==y`` does not imply that ``x!=y`` is false.\n   Accordingly, when defining ``__eq__()``, one should also define\n   ``__ne__()`` so that the operators will behave as expected.  See\n   the paragraph on ``__hash__()`` for some important notes on\n   creating *hashable* objects which support custom comparison\n   operations and are usable as dictionary keys.\n\n   There are no swapped-argument versions of these methods (to be used\n   when the left argument does not support the operation but the right\n   argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n   other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n   reflection, and ``__eq__()`` and ``__ne__()`` are their own\n   reflection.\n\n   Arguments to rich comparison methods are never coerced.\n\n   To automatically generate ordering operations from a single root\n   operation, see ``functools.total_ordering()``.\n\nobject.__hash__(self)\n\n   Called by built-in function ``hash()`` and for operations on\n   members of hashed collections including ``set``, ``frozenset``, and\n   ``dict``.  ``__hash__()`` should return an integer.  The only\n   required property is that objects which compare equal have the same\n   hash value; it is advised to somehow mix together (e.g. using\n   exclusive or) the hash values for the components of the object that\n   also play a part in comparison of objects.\n\n   If a class does not define an ``__eq__()`` method it should not\n   define a ``__hash__()`` operation either; if it defines\n   ``__eq__()`` but not ``__hash__()``, its instances will not be\n   usable as items in hashable collections.  If a class defines\n   mutable objects and implements an ``__eq__()`` method, it should\n   not implement ``__hash__()``, since the implementation of hashable\n   collections requires that a key\'s hash value is immutable (if the\n   object\'s hash value changes, it will be in the wrong hash bucket).\n\n   User-defined classes have ``__eq__()`` and ``__hash__()`` methods\n   by default; with them, all objects compare unequal (except with\n   themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n   Classes which inherit a ``__hash__()`` method from a parent class\n   but change the meaning of ``__eq__()`` such that the hash value\n   returned is no longer appropriate (e.g. by switching to a value-\n   based concept of equality instead of the default identity based\n   equality) can explicitly flag themselves as being unhashable by\n   setting ``__hash__ = None`` in the class definition. Doing so means\n   that not only will instances of the class raise an appropriate\n   ``TypeError`` when a program attempts to retrieve their hash value,\n   but they will also be correctly identified as unhashable when\n   checking ``isinstance(obj, collections.Hashable)`` (unlike classes\n   which define their own ``__hash__()`` to explicitly raise\n   ``TypeError``).\n\n   If a class that overrides ``__eq__()`` needs to retain the\n   implementation of ``__hash__()`` from a parent class, the\n   interpreter must be told this explicitly by setting ``__hash__ =\n   <ParentClass>.__hash__``. Otherwise the inheritance of\n   ``__hash__()`` will be blocked, just as if ``__hash__`` had been\n   explicitly set to ``None``.\n\nobject.__bool__(self)\n\n   Called to implement truth value testing and the built-in operation\n   ``bool()``; should return ``False`` or ``True``.  When this method\n   is not defined, ``__len__()`` is called, if it is defined, and the\n   object is considered true if its result is nonzero.  If a class\n   defines neither ``__len__()`` nor ``__bool__()``, all its instances\n   are considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n   Called when an attribute lookup has not found the attribute in the\n   usual places (i.e. it is not an instance attribute nor is it found\n   in the class tree for ``self``).  ``name`` is the attribute name.\n   This method should return the (computed) attribute value or raise\n   an ``AttributeError`` exception.\n\n   Note that if the attribute is found through the normal mechanism,\n   ``__getattr__()`` is not called.  (This is an intentional asymmetry\n   between ``__getattr__()`` and ``__setattr__()``.) This is done both\n   for efficiency reasons and because otherwise ``__getattr__()``\n   would have no way to access other attributes of the instance.  Note\n   that at least for instance variables, you can fake total control by\n   not inserting any values in the instance attribute dictionary (but\n   instead inserting them in another object).  See the\n   ``__getattribute__()`` method below for a way to actually get total\n   control over attribute access.\n\nobject.__getattribute__(self, name)\n\n   Called unconditionally to implement attribute accesses for\n   instances of the class. If the class also defines\n   ``__getattr__()``, the latter will not be called unless\n   ``__getattribute__()`` either calls it explicitly or raises an\n   ``AttributeError``. This method should return the (computed)\n   attribute value or raise an ``AttributeError`` exception. In order\n   to avoid infinite recursion in this method, its implementation\n   should always call the base class method with the same name to\n   access any attributes it needs, for example,\n   ``object.__getattribute__(self, name)``.\n\n   Note: This method may still be bypassed when looking up special methods\n     as the result of implicit invocation via language syntax or\n     built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n   Called when an attribute assignment is attempted.  This is called\n   instead of the normal mechanism (i.e. store the value in the\n   instance dictionary). *name* is the attribute name, *value* is the\n   value to be assigned to it.\n\n   If ``__setattr__()`` wants to assign to an instance attribute, it\n   should call the base class method with the same name, for example,\n   ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n   Like ``__setattr__()`` but for attribute deletion instead of\n   assignment.  This should only be implemented if ``del obj.name`` is\n   meaningful for the object.\n\nobject.__dir__(self)\n\n   Called when ``dir()`` is called on the object.  A list must be\n   returned.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in the\nclass dictionary of another class, known as the *owner* class.  In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n   Called to get the attribute of the owner class (class attribute\n   access) or of an instance of that class (instance attribute\n   access). *owner* is always the owner class, while *instance* is the\n   instance that the attribute was accessed through, or ``None`` when\n   the attribute is accessed through the *owner*.  This method should\n   return the (computed) attribute value or raise an\n   ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n   Called to set the attribute on an instance *instance* of the owner\n   class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n   Called to delete the attribute on an instance *instance* of the\n   owner class.\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol:  ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead.  Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n   The simplest and least common call is when user code directly\n   invokes a descriptor method:    ``x.__get__(a)``.\n\nInstance Binding\n   If binding to an object instance, ``a.x`` is transformed into the\n   call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n   If binding to a class, ``A.x`` is transformed into the call:\n   ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n   If ``a`` is an instance of ``super``, then the binding ``super(B,\n   obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n   ``A`` immediately preceding ``B`` and then invokes the descriptor\n   with the call: ``A.__dict__[\'m\'].__get__(obj, A)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined.  A descriptor can define\nany combination of ``__get__()``, ``__set__()`` and ``__delete__()``.\nIf it does not define ``__get__()``, then accessing the attribute will\nreturn the descriptor object itself unless there is a value in the\nobject\'s instance dictionary.  If the descriptor defines ``__set__()``\nand/or ``__delete__()``, it is a data descriptor; if it defines\nneither, it is a non-data descriptor.  Normally, data descriptors\ndefine both ``__get__()`` and ``__set__()``, while non-data\ndescriptors have just the ``__get__()`` method.  Data descriptors with\n``__set__()`` and ``__get__()`` defined always override a redefinition\nin an instance dictionary.  In contrast, non-data descriptors can be\noverridden by instances.\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors.  Accordingly, instances can\nredefine and override methods.  This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage.  This wastes space for objects having very few instance\nvariables.  The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable.  Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n   This class variable can be assigned a string, iterable, or sequence\n   of strings with variable names used by instances.  If defined in a\n   class, *__slots__* reserves space for the declared variables and\n   prevents the automatic creation of *__dict__* and *__weakref__* for\n   each instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n  attribute of that class will always be accessible, so a *__slots__*\n  definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n  variables not listed in the *__slots__* definition.  Attempts to\n  assign to an unlisted variable name raises ``AttributeError``. If\n  dynamic assignment of new variables is desired, then add\n  ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n  declaration.\n\n* Without a *__weakref__* variable for each instance, classes defining\n  *__slots__* do not support weak references to its instances. If weak\n  reference support is needed, then add ``\'__weakref__\'`` to the\n  sequence of strings in the *__slots__* declaration.\n\n* *__slots__* are implemented at the class level by creating\n  descriptors (*Implementing Descriptors*) for each variable name.  As\n  a result, class attributes cannot be used to set default values for\n  instance variables defined by *__slots__*; otherwise, the class\n  attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n  where it is defined.  As a result, subclasses will have a *__dict__*\n  unless they also define *__slots__* (which must only contain names\n  of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the instance\n  variable defined by the base class slot is inaccessible (except by\n  retrieving its descriptor directly from the base class). This\n  renders the meaning of the program undefined.  In the future, a\n  check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n  "variable-length" built-in types such as ``int``, ``str`` and\n  ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n  also be used; however, in the future, special meaning may be\n  assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n  *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using ``type()``. A class\ndefinition is read into a separate namespace and the value of class\nname is bound to the result of ``type(name, bases, dict)``.\n\nWhen the class definition is read, if a callable ``metaclass`` keyword\nargument is passed after the bases in the class definition, the\ncallable given will be called instead of ``type()``.  If other keyword\narguments are passed, they will also be passed to the metaclass.  This\nallows classes or functions to be written which monitor or alter the\nclass creation process:\n\n* Modifying the class dictionary prior to the class being created.\n\n* Returning an instance of another class -- essentially performing the\n  role of a factory function.\n\nThese steps will have to be performed in the metaclass\'s ``__new__()``\nmethod -- ``type.__new__()`` can then be called from this method to\ncreate a class with different properties.  This example adds a new\nelement to the class dictionary before creating the class:\n\n   class metacls(type):\n       def __new__(mcs, name, bases, dict):\n           dict[\'foo\'] = \'metacls was here\'\n           return type.__new__(mcs, name, bases, dict)\n\nYou can of course also override other class methods (or add new\nmethods); for example defining a custom ``__call__()`` method in the\nmetaclass allows custom behavior when the class is called, e.g. not\nalways creating a new instance.\n\nIf the metaclass has a ``__prepare__()`` attribute (usually\nimplemented as a class or static method), it is called before the\nclass body is evaluated with the name of the class and a tuple of its\nbases for arguments.  It should return an object that supports the\nmapping interface that will be used to store the namespace of the\nclass.  The default is a plain dictionary.  This could be used, for\nexample, to keep track of the order that class attributes are declared\nin by returning an ordered dictionary.\n\nThe appropriate metaclass is determined by the following precedence\nrules:\n\n* If the ``metaclass`` keyword argument is passed with the bases, it\n  is used.\n\n* Otherwise, if there is at least one base class, its metaclass is\n  used.\n\n* Otherwise, the default metaclass (``type``) is used.\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored including logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n``collections.OrderedDict`` to remember the order that class members\nwere defined:\n\n   class OrderedClass(type):\n\n        @classmethod\n        def __prepare__(metacls, name, bases, **kwds):\n           return collections.OrderedDict()\n\n        def __new__(cls, name, bases, classdict):\n           result = type.__new__(cls, name, bases, dict(classdict))\n           result.members = tuple(classdict)\n           return result\n\n   class A(metaclass=OrderedClass):\n       def one(self): pass\n       def two(self): pass\n       def three(self): pass\n       def four(self): pass\n\n   >>> A.members\n   (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s ``__prepare__()`` method which returns an\nempty ``collections.OrderedDict``.  That mapping records the methods\nand attributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s ``__new__()`` method gets\ninvoked.  That method builds the new type and it saves the ordered\ndictionary keys in an attribute called ``members``.\n\n\nCustomizing instance and subclass checks\n========================================\n\nThe following methods are used to override the default behavior of the\n``isinstance()`` and ``issubclass()`` built-in functions.\n\nIn particular, the metaclass ``abc.ABCMeta`` implements these methods\nin order to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n   Return true if *instance* should be considered a (direct or\n   indirect) instance of *class*. If defined, called to implement\n   ``isinstance(instance, class)``.\n\nclass.__subclasscheck__(self, subclass)\n\n   Return true if *subclass* should be considered a (direct or\n   indirect) subclass of *class*.  If defined, called to implement\n   ``issubclass(subclass, class)``.\n\nNote that these methods are looked up on the type (metaclass) of a\nclass.  They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also:\n\n   **PEP 3119** - Introducing Abstract Base Classes\n      Includes the specification for customizing ``isinstance()`` and\n      ``issubclass()`` behavior through ``__instancecheck__()`` and\n      ``__subclasscheck__()``, with motivation for this functionality\n      in the context of adding Abstract Base Classes (see the ``abc``\n      module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n   Called when the instance is "called" as a function; if this method\n   is defined, ``x(arg1, arg2, ...)`` is a shorthand for\n   ``x.__call__(arg1, arg2, ...)``.\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well.  The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items.  It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``get()``,\n``clear()``, ``setdefault()``, ``pop()``, ``popitem()``, ``copy()``,\nand ``update()`` behaving similar to those for Python\'s standard\ndictionary objects.  The ``collections`` module provides a\n``MutableMapping`` abstract base class to help create those methods\nfrom a base set of ``__getitem__()``, ``__setitem__()``,\n``__delitem__()``, and ``keys()``. Mutable sequences should provide\nmethods ``append()``, ``count()``, ``index()``, ``extend()``,\n``insert()``, ``pop()``, ``remove()``, ``reverse()`` and ``sort()``,\nlike Python standard list objects.  Finally, sequence types should\nimplement addition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods ``__add__()``, ``__radd__()``,\n``__iadd__()``, ``__mul__()``, ``__rmul__()`` and ``__imul__()``\ndescribed below; they should not define other numerical operators.  It\nis recommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should search the mapping\'s keys; for\nsequences, it should search through the values.  It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``keys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n   Called to implement the built-in function ``len()``.  Should return\n   the length of the object, an integer ``>=`` 0.  Also, an object\n   that doesn\'t define a ``__bool__()`` method and whose ``__len__()``\n   method returns zero is considered to be false in a Boolean context.\n\nNote: Slicing is done exclusively with the following three methods.  A\n  call like\n\n     a[1:2] = b\n\n  is translated to\n\n     a[slice(1, 2, None)] = b\n\n  and so forth.  Missing slice items are always filled in with\n  ``None``.\n\nobject.__getitem__(self, key)\n\n   Called to implement evaluation of ``self[key]``. For sequence\n   types, the accepted keys should be integers and slice objects.\n   Note that the special interpretation of negative indexes (if the\n   class wishes to emulate a sequence type) is up to the\n   ``__getitem__()`` method. If *key* is of an inappropriate type,\n   ``TypeError`` may be raised; if of a value outside the set of\n   indexes for the sequence (after any special interpretation of\n   negative values), ``IndexError`` should be raised. For mapping\n   types, if *key* is missing (not in the container), ``KeyError``\n   should be raised.\n\n   Note: ``for`` loops expect that an ``IndexError`` will be raised for\n     illegal indexes to allow proper detection of the end of the\n     sequence.\n\nobject.__setitem__(self, key, value)\n\n   Called to implement assignment to ``self[key]``.  Same note as for\n   ``__getitem__()``.  This should only be implemented for mappings if\n   the objects support changes to the values for keys, or if new keys\n   can be added, or for sequences if elements can be replaced.  The\n   same exceptions should be raised for improper *key* values as for\n   the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n   Called to implement deletion of ``self[key]``.  Same note as for\n   ``__getitem__()``.  This should only be implemented for mappings if\n   the objects support removal of keys, or for sequences if elements\n   can be removed from the sequence.  The same exceptions should be\n   raised for improper *key* values as for the ``__getitem__()``\n   method.\n\nobject.__iter__(self)\n\n   This method is called when an iterator is required for a container.\n   This method should return a new iterator object that can iterate\n   over all the objects in the container.  For mappings, it should\n   iterate over the keys of the container, and should also be made\n   available as the method ``keys()``.\n\n   Iterator objects also need to implement this method; they are\n   required to return themselves.  For more information on iterator\n   objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n   Called (if present) by the ``reversed()`` built-in to implement\n   reverse iteration.  It should return a new iterator object that\n   iterates over all the objects in the container in reverse order.\n\n   If the ``__reversed__()`` method is not provided, the\n   ``reversed()`` built-in will fall back to using the sequence\n   protocol (``__len__()`` and ``__getitem__()``).  Objects that\n   support the sequence protocol should only provide\n   ``__reversed__()`` if they can provide an implementation that is\n   more efficient than the one provided by ``reversed()``.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence.  However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n   Called to implement membership test operators.  Should return true\n   if *item* is in *self*, false otherwise.  For mapping objects, this\n   should consider the keys of the mapping rather than the values or\n   the key-item pairs.\n\n   For objects that don\'t define ``__contains__()``, the membership\n   test first tries iteration via ``__iter__()``, then the old\n   sequence iteration protocol via ``__getitem__()``, see *this\n   section in the language reference*.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n   These methods are called to implement the binary arithmetic\n   operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n   ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n   ``|``).  For instance, to evaluate the expression ``x + y``, where\n   *x* is an instance of a class that has an ``__add__()`` method,\n   ``x.__add__(y)`` is called.  The ``__divmod__()`` method should be\n   the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n   should not be related to ``__truediv__()``.  Note that\n   ``__pow__()`` should be defined to accept an optional third\n   argument if the ternary version of the built-in ``pow()`` function\n   is to be supported.\n\n   If one of those methods does not support the operation with the\n   supplied arguments, it should return ``NotImplemented``.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n   These methods are called to implement the binary arithmetic\n   operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n   ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n   ``|``) with reflected (swapped) operands. These functions are only\n   called if the left operand does not support the corresponding\n   operation and the operands are of different types. [2]  For\n   instance, to evaluate the expression ``x - y``, where *y* is an\n   instance of a class that has an ``__rsub__()`` method,\n   ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns\n   *NotImplemented*.\n\n   Note that ternary ``pow()`` will not try calling ``__rpow__()``\n   (the coercion rules would become too complicated).\n\n   Note: If the right operand\'s type is a subclass of the left operand\'s\n     type and that subclass provides the reflected method for the\n     operation, this method will be called before the left operand\'s\n     non-reflected method.  This behavior allows subclasses to\n     override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n   These methods are called to implement the augmented arithmetic\n   assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n   ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``).  These methods\n   should attempt to do the operation in-place (modifying *self*) and\n   return the result (which could be, but does not have to be,\n   *self*).  If a specific method is not defined, the augmented\n   assignment falls back to the normal methods.  For instance, to\n   execute the statement ``x += y``, where *x* is an instance of a\n   class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n   called.  If *x* is an instance of a class that does not define a\n   ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n   considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n   Called to implement the unary arithmetic operations (``-``, ``+``,\n   ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n   Called to implement the built-in functions ``complex()``,\n   ``int()``, ``float()`` and ``round()``.  Should return a value of\n   the appropriate type.\n\nobject.__index__(self)\n\n   Called to implement ``operator.index()``.  Also called whenever\n   Python needs an integer object (such as in slicing, or in the\n   built-in ``bin()``, ``hex()`` and ``oct()`` functions). Must return\n   an integer.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code.  Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n   Enter the runtime context related to this object. The ``with``\n   statement will bind this method\'s return value to the target(s)\n   specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n   Exit the runtime context related to this object. The parameters\n   describe the exception that caused the context to be exited. If the\n   context was exited without an exception, all three arguments will\n   be ``None``.\n\n   If an exception is supplied, and the method wishes to suppress the\n   exception (i.e., prevent it from being propagated), it should\n   return a true value. Otherwise, the exception will be processed\n   normally upon exit from this method.\n\n   Note that ``__exit__()`` methods should not reraise the passed-in\n   exception; this is the caller\'s responsibility.\n\nSee also:\n\n   **PEP 0343** - The "with" statement\n      The specification, background, and examples for the Python\n      ``with`` statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary.  That behaviour is the reason why\nthe following code raises an exception:\n\n   >>> class C(object):\n   ...     pass\n   ...\n   >>> c = C()\n   >>> c.__len__ = lambda: 5\n   >>> len(c)\n   Traceback (most recent call last):\n     File "<stdin>", line 1, in <module>\n   TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as ``__hash__()`` and ``__repr__()`` that are implemented\nby all objects, including type objects. If the implicit lookup of\nthese methods used the conventional lookup process, they would fail\nwhen invoked on the type object itself:\n\n   >>> 1 .__hash__() == hash(1)\n   True\n   >>> int.__hash__() == hash(int)\n   Traceback (most recent call last):\n     File "<stdin>", line 1, in <module>\n   TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n   >>> type(1).__hash__(1) == hash(1)\n   True\n   >>> type(int).__hash__(int) == hash(int)\n   True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe ``__getattribute__()`` method even of the object\'s metaclass:\n\n   >>> class Meta(type):\n   ...    def __getattribute__(*args):\n   ...       print("Metaclass getattribute invoked")\n   ...       return type.__getattribute__(*args)\n   ...\n   >>> class C(object, metaclass=Meta):\n   ...     def __len__(self):\n   ...         return 10\n   ...     def __getattribute__(*args):\n   ...         print("Class getattribute invoked")\n   ...         return object.__getattribute__(*args)\n   ...\n   >>> c = C()\n   >>> c.__len__()                 # Explicit lookup via instance\n   Class getattribute invoked\n   10\n   >>> type(c).__len__(c)          # Explicit lookup via type\n   Metaclass getattribute invoked\n   10\n   >>> len(c)                      # Implicit lookup\n   10\n\nBypassing the ``__getattribute__()`` machinery in this fashion\nprovides significant scope for speed optimisations within the\ninterpreter, at the cost of some flexibility in the handling of\nspecial methods (the special method *must* be set on the class object\nitself in order to be consistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type, under\n    certain controlled conditions. It generally isn\'t a good idea\n    though, since it can lead to some very strange behaviour if it is\n    handled incorrectly.\n\n[2] For operands of the same type, it is assumed that if the non-\n    reflected method (such as ``__add__()``) fails the operation is\n    not supported, which is why the reflected method is not called.\n',
+ 'specialnames': '\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators.  For instance, if a class defines\na method named ``__getitem__()``, and ``x`` is an instance of this\nclass, then ``x[i]`` is roughly equivalent to ``type(x).__getitem__(x,\ni)``.  Except where mentioned, attempts to execute an operation raise\nan exception when no appropriate method is defined (typically\n``AttributeError`` or ``TypeError``).\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled.  For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense.  (One example of this is the\n``NodeList`` interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n   Called to create a new instance of class *cls*.  ``__new__()`` is a\n   static method (special-cased so you need not declare it as such)\n   that takes the class of which an instance was requested as its\n   first argument.  The remaining arguments are those passed to the\n   object constructor expression (the call to the class).  The return\n   value of ``__new__()`` should be the new object instance (usually\n   an instance of *cls*).\n\n   Typical implementations create a new instance of the class by\n   invoking the superclass\'s ``__new__()`` method using\n   ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n   arguments and then modifying the newly-created instance as\n   necessary before returning it.\n\n   If ``__new__()`` returns an instance of *cls*, then the new\n   instance\'s ``__init__()`` method will be invoked like\n   ``__init__(self[, ...])``, where *self* is the new instance and the\n   remaining arguments are the same as were passed to ``__new__()``.\n\n   If ``__new__()`` does not return an instance of *cls*, then the new\n   instance\'s ``__init__()`` method will not be invoked.\n\n   ``__new__()`` is intended mainly to allow subclasses of immutable\n   types (like int, str, or tuple) to customize instance creation.  It\n   is also commonly overridden in custom metaclasses in order to\n   customize class creation.\n\nobject.__init__(self[, ...])\n\n   Called when the instance is created.  The arguments are those\n   passed to the class constructor expression.  If a base class has an\n   ``__init__()`` method, the derived class\'s ``__init__()`` method,\n   if any, must explicitly call it to ensure proper initialization of\n   the base class part of the instance; for example:\n   ``BaseClass.__init__(self, [args...])``.  As a special constraint\n   on constructors, no value may be returned; doing so will cause a\n   ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n   Called when the instance is about to be destroyed.  This is also\n   called a destructor.  If a base class has a ``__del__()`` method,\n   the derived class\'s ``__del__()`` method, if any, must explicitly\n   call it to ensure proper deletion of the base class part of the\n   instance.  Note that it is possible (though not recommended!) for\n   the ``__del__()`` method to postpone destruction of the instance by\n   creating a new reference to it.  It may then be called at a later\n   time when this new reference is deleted.  It is not guaranteed that\n   ``__del__()`` methods are called for objects that still exist when\n   the interpreter exits.\n\n   Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n     decrements the reference count for ``x`` by one, and the latter\n     is only called when ``x``\'s reference count reaches zero.  Some\n     common situations that may prevent the reference count of an\n     object from going to zero include: circular references between\n     objects (e.g., a doubly-linked list or a tree data structure with\n     parent and child pointers); a reference to the object on the\n     stack frame of a function that caught an exception (the traceback\n     stored in ``sys.exc_info()[2]`` keeps the stack frame alive); or\n     a reference to the object on the stack frame that raised an\n     unhandled exception in interactive mode (the traceback stored in\n     ``sys.last_traceback`` keeps the stack frame alive).  The first\n     situation can only be remedied by explicitly breaking the cycles;\n     the latter two situations can be resolved by storing ``None`` in\n     ``sys.last_traceback``. Circular references which are garbage are\n     detected when the option cycle detector is enabled (it\'s on by\n     default), but can only be cleaned up if there are no Python-\n     level ``__del__()`` methods involved. Refer to the documentation\n     for the ``gc`` module for more information about how\n     ``__del__()`` methods are handled by the cycle detector,\n     particularly the description of the ``garbage`` value.\n\n   Warning: Due to the precarious circumstances under which ``__del__()``\n     methods are invoked, exceptions that occur during their execution\n     are ignored, and a warning is printed to ``sys.stderr`` instead.\n     Also, when ``__del__()`` is invoked in response to a module being\n     deleted (e.g., when execution of the program is done), other\n     globals referenced by the ``__del__()`` method may already have\n     been deleted or in the process of being torn down (e.g. the\n     import machinery shutting down).  For this reason, ``__del__()``\n     methods should do the absolute minimum needed to maintain\n     external invariants.  Starting with version 1.5, Python\n     guarantees that globals whose name begins with a single\n     underscore are deleted from their module before other globals are\n     deleted; if no other references to such globals exist, this may\n     help in assuring that imported modules are still available at the\n     time when the ``__del__()`` method is called.\n\nobject.__repr__(self)\n\n   Called by the ``repr()`` built-in function to compute the\n   "official" string representation of an object.  If at all possible,\n   this should look like a valid Python expression that could be used\n   to recreate an object with the same value (given an appropriate\n   environment).  If this is not possible, a string of the form\n   ``<...some useful description...>`` should be returned. The return\n   value must be a string object. If a class defines ``__repr__()``\n   but not ``__str__()``, then ``__repr__()`` is also used when an\n   "informal" string representation of instances of that class is\n   required.\n\n   This is typically used for debugging, so it is important that the\n   representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n   Called by the ``str()`` built-in function and by the ``print()``\n   function to compute the "informal" string representation of an\n   object.  This differs from ``__repr__()`` in that it does not have\n   to be a valid Python expression: a more convenient or concise\n   representation may be used instead. The return value must be a\n   string object.\n\nobject.__format__(self, format_spec)\n\n   Called by the ``format()`` built-in function (and by extension, the\n   ``format()`` method of class ``str``) to produce a "formatted"\n   string representation of an object. The ``format_spec`` argument is\n   a string that contains a description of the formatting options\n   desired. The interpretation of the ``format_spec`` argument is up\n   to the type implementing ``__format__()``, however most classes\n   will either delegate formatting to one of the built-in types, or\n   use a similar formatting option syntax.\n\n   See *Format Specification Mini-Language* for a description of the\n   standard formatting syntax.\n\n   The return value must be a string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n   These are the so-called "rich comparison" methods. The\n   correspondence between operator symbols and method names is as\n   follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n   ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` calls\n   ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls\n   ``x.__ge__(y)``.\n\n   A rich comparison method may return the singleton\n   ``NotImplemented`` if it does not implement the operation for a\n   given pair of arguments. By convention, ``False`` and ``True`` are\n   returned for a successful comparison. However, these methods can\n   return any value, so if the comparison operator is used in a\n   Boolean context (e.g., in the condition of an ``if`` statement),\n   Python will call ``bool()`` on the value to determine if the result\n   is true or false.\n\n   There are no implied relationships among the comparison operators.\n   The truth of ``x==y`` does not imply that ``x!=y`` is false.\n   Accordingly, when defining ``__eq__()``, one should also define\n   ``__ne__()`` so that the operators will behave as expected.  See\n   the paragraph on ``__hash__()`` for some important notes on\n   creating *hashable* objects which support custom comparison\n   operations and are usable as dictionary keys.\n\n   There are no swapped-argument versions of these methods (to be used\n   when the left argument does not support the operation but the right\n   argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n   other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n   reflection, and ``__eq__()`` and ``__ne__()`` are their own\n   reflection.\n\n   Arguments to rich comparison methods are never coerced.\n\n   To automatically generate ordering operations from a single root\n   operation, see ``functools.total_ordering()``.\n\nobject.__hash__(self)\n\n   Called by built-in function ``hash()`` and for operations on\n   members of hashed collections including ``set``, ``frozenset``, and\n   ``dict``.  ``__hash__()`` should return an integer.  The only\n   required property is that objects which compare equal have the same\n   hash value; it is advised to somehow mix together (e.g. using\n   exclusive or) the hash values for the components of the object that\n   also play a part in comparison of objects.\n\n   If a class does not define an ``__eq__()`` method it should not\n   define a ``__hash__()`` operation either; if it defines\n   ``__eq__()`` but not ``__hash__()``, its instances will not be\n   usable as items in hashable collections.  If a class defines\n   mutable objects and implements an ``__eq__()`` method, it should\n   not implement ``__hash__()``, since the implementation of hashable\n   collections requires that a key\'s hash value is immutable (if the\n   object\'s hash value changes, it will be in the wrong hash bucket).\n\n   User-defined classes have ``__eq__()`` and ``__hash__()`` methods\n   by default; with them, all objects compare unequal (except with\n   themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n   Classes which inherit a ``__hash__()`` method from a parent class\n   but change the meaning of ``__eq__()`` such that the hash value\n   returned is no longer appropriate (e.g. by switching to a value-\n   based concept of equality instead of the default identity based\n   equality) can explicitly flag themselves as being unhashable by\n   setting ``__hash__ = None`` in the class definition. Doing so means\n   that not only will instances of the class raise an appropriate\n   ``TypeError`` when a program attempts to retrieve their hash value,\n   but they will also be correctly identified as unhashable when\n   checking ``isinstance(obj, collections.Hashable)`` (unlike classes\n   which define their own ``__hash__()`` to explicitly raise\n   ``TypeError``).\n\n   If a class that overrides ``__eq__()`` needs to retain the\n   implementation of ``__hash__()`` from a parent class, the\n   interpreter must be told this explicitly by setting ``__hash__ =\n   <ParentClass>.__hash__``. Otherwise the inheritance of\n   ``__hash__()`` will be blocked, just as if ``__hash__`` had been\n   explicitly set to ``None``.\n\nobject.__bool__(self)\n\n   Called to implement truth value testing and the built-in operation\n   ``bool()``; should return ``False`` or ``True``.  When this method\n   is not defined, ``__len__()`` is called, if it is defined, and the\n   object is considered true if its result is nonzero.  If a class\n   defines neither ``__len__()`` nor ``__bool__()``, all its instances\n   are considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n   Called when an attribute lookup has not found the attribute in the\n   usual places (i.e. it is not an instance attribute nor is it found\n   in the class tree for ``self``).  ``name`` is the attribute name.\n   This method should return the (computed) attribute value or raise\n   an ``AttributeError`` exception.\n\n   Note that if the attribute is found through the normal mechanism,\n   ``__getattr__()`` is not called.  (This is an intentional asymmetry\n   between ``__getattr__()`` and ``__setattr__()``.) This is done both\n   for efficiency reasons and because otherwise ``__getattr__()``\n   would have no way to access other attributes of the instance.  Note\n   that at least for instance variables, you can fake total control by\n   not inserting any values in the instance attribute dictionary (but\n   instead inserting them in another object).  See the\n   ``__getattribute__()`` method below for a way to actually get total\n   control over attribute access.\n\nobject.__getattribute__(self, name)\n\n   Called unconditionally to implement attribute accesses for\n   instances of the class. If the class also defines\n   ``__getattr__()``, the latter will not be called unless\n   ``__getattribute__()`` either calls it explicitly or raises an\n   ``AttributeError``. This method should return the (computed)\n   attribute value or raise an ``AttributeError`` exception. In order\n   to avoid infinite recursion in this method, its implementation\n   should always call the base class method with the same name to\n   access any attributes it needs, for example,\n   ``object.__getattribute__(self, name)``.\n\n   Note: This method may still be bypassed when looking up special methods\n     as the result of implicit invocation via language syntax or\n     built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n   Called when an attribute assignment is attempted.  This is called\n   instead of the normal mechanism (i.e. store the value in the\n   instance dictionary). *name* is the attribute name, *value* is the\n   value to be assigned to it.\n\n   If ``__setattr__()`` wants to assign to an instance attribute, it\n   should call the base class method with the same name, for example,\n   ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n   Like ``__setattr__()`` but for attribute deletion instead of\n   assignment.  This should only be implemented if ``del obj.name`` is\n   meaningful for the object.\n\nobject.__dir__(self)\n\n   Called when ``dir()`` is called on the object.  A list must be\n   returned.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in the\nclass dictionary of another class, known as the *owner* class.  In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n   Called to get the attribute of the owner class (class attribute\n   access) or of an instance of that class (instance attribute\n   access). *owner* is always the owner class, while *instance* is the\n   instance that the attribute was accessed through, or ``None`` when\n   the attribute is accessed through the *owner*.  This method should\n   return the (computed) attribute value or raise an\n   ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n   Called to set the attribute on an instance *instance* of the owner\n   class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n   Called to delete the attribute on an instance *instance* of the\n   owner class.\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol:  ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead.  Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n   The simplest and least common call is when user code directly\n   invokes a descriptor method:    ``x.__get__(a)``.\n\nInstance Binding\n   If binding to an object instance, ``a.x`` is transformed into the\n   call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n   If binding to a class, ``A.x`` is transformed into the call:\n   ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n   If ``a`` is an instance of ``super``, then the binding ``super(B,\n   obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n   ``A`` immediately preceding ``B`` and then invokes the descriptor\n   with the call: ``A.__dict__[\'m\'].__get__(obj, A)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined.  A descriptor can define\nany combination of ``__get__()``, ``__set__()`` and ``__delete__()``.\nIf it does not define ``__get__()``, then accessing the attribute will\nreturn the descriptor object itself unless there is a value in the\nobject\'s instance dictionary.  If the descriptor defines ``__set__()``\nand/or ``__delete__()``, it is a data descriptor; if it defines\nneither, it is a non-data descriptor.  Normally, data descriptors\ndefine both ``__get__()`` and ``__set__()``, while non-data\ndescriptors have just the ``__get__()`` method.  Data descriptors with\n``__set__()`` and ``__get__()`` defined always override a redefinition\nin an instance dictionary.  In contrast, non-data descriptors can be\noverridden by instances.\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors.  Accordingly, instances can\nredefine and override methods.  This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage.  This wastes space for objects having very few instance\nvariables.  The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable.  Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n   This class variable can be assigned a string, iterable, or sequence\n   of strings with variable names used by instances.  If defined in a\n   class, *__slots__* reserves space for the declared variables and\n   prevents the automatic creation of *__dict__* and *__weakref__* for\n   each instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n  attribute of that class will always be accessible, so a *__slots__*\n  definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n  variables not listed in the *__slots__* definition.  Attempts to\n  assign to an unlisted variable name raises ``AttributeError``. If\n  dynamic assignment of new variables is desired, then add\n  ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n  declaration.\n\n* Without a *__weakref__* variable for each instance, classes defining\n  *__slots__* do not support weak references to its instances. If weak\n  reference support is needed, then add ``\'__weakref__\'`` to the\n  sequence of strings in the *__slots__* declaration.\n\n* *__slots__* are implemented at the class level by creating\n  descriptors (*Implementing Descriptors*) for each variable name.  As\n  a result, class attributes cannot be used to set default values for\n  instance variables defined by *__slots__*; otherwise, the class\n  attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n  where it is defined.  As a result, subclasses will have a *__dict__*\n  unless they also define *__slots__* (which must only contain names\n  of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the instance\n  variable defined by the base class slot is inaccessible (except by\n  retrieving its descriptor directly from the base class). This\n  renders the meaning of the program undefined.  In the future, a\n  check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n  "variable-length" built-in types such as ``int``, ``str`` and\n  ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n  also be used; however, in the future, special meaning may be\n  assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n  *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using ``type()``. A class\ndefinition is read into a separate namespace and the value of class\nname is bound to the result of ``type(name, bases, dict)``.\n\nWhen the class definition is read, if a callable ``metaclass`` keyword\nargument is passed after the bases in the class definition, the\ncallable given will be called instead of ``type()``.  If other keyword\narguments are passed, they will also be passed to the metaclass.  This\nallows classes or functions to be written which monitor or alter the\nclass creation process:\n\n* Modifying the class dictionary prior to the class being created.\n\n* Returning an instance of another class -- essentially performing the\n  role of a factory function.\n\nThese steps will have to be performed in the metaclass\'s ``__new__()``\nmethod -- ``type.__new__()`` can then be called from this method to\ncreate a class with different properties.  This example adds a new\nelement to the class dictionary before creating the class:\n\n   class metacls(type):\n       def __new__(mcs, name, bases, dict):\n           dict[\'foo\'] = \'metacls was here\'\n           return type.__new__(mcs, name, bases, dict)\n\nYou can of course also override other class methods (or add new\nmethods); for example defining a custom ``__call__()`` method in the\nmetaclass allows custom behavior when the class is called, e.g. not\nalways creating a new instance.\n\nIf the metaclass has a ``__prepare__()`` attribute (usually\nimplemented as a class or static method), it is called before the\nclass body is evaluated with the name of the class and a tuple of its\nbases for arguments.  It should return an object that supports the\nmapping interface that will be used to store the namespace of the\nclass.  The default is a plain dictionary.  This could be used, for\nexample, to keep track of the order that class attributes are declared\nin by returning an ordered dictionary.\n\nThe appropriate metaclass is determined by the following precedence\nrules:\n\n* If the ``metaclass`` keyword argument is passed with the bases, it\n  is used.\n\n* Otherwise, if there is at least one base class, its metaclass is\n  used.\n\n* Otherwise, the default metaclass (``type``) is used.\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored including logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n``collections.OrderedDict`` to remember the order that class members\nwere defined:\n\n   class OrderedClass(type):\n\n        @classmethod\n        def __prepare__(metacls, name, bases, **kwds):\n           return collections.OrderedDict()\n\n        def __new__(cls, name, bases, classdict):\n           result = type.__new__(cls, name, bases, dict(classdict))\n           result.members = tuple(classdict)\n           return result\n\n   class A(metaclass=OrderedClass):\n       def one(self): pass\n       def two(self): pass\n       def three(self): pass\n       def four(self): pass\n\n   >>> A.members\n   (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s ``__prepare__()`` method which returns an\nempty ``collections.OrderedDict``.  That mapping records the methods\nand attributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s ``__new__()`` method gets\ninvoked.  That method builds the new type and it saves the ordered\ndictionary keys in an attribute called ``members``.\n\n\nCustomizing instance and subclass checks\n========================================\n\nThe following methods are used to override the default behavior of the\n``isinstance()`` and ``issubclass()`` built-in functions.\n\nIn particular, the metaclass ``abc.ABCMeta`` implements these methods\nin order to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n   Return true if *instance* should be considered a (direct or\n   indirect) instance of *class*. If defined, called to implement\n   ``isinstance(instance, class)``.\n\nclass.__subclasscheck__(self, subclass)\n\n   Return true if *subclass* should be considered a (direct or\n   indirect) subclass of *class*.  If defined, called to implement\n   ``issubclass(subclass, class)``.\n\nNote that these methods are looked up on the type (metaclass) of a\nclass.  They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also:\n\n   **PEP 3119** - Introducing Abstract Base Classes\n      Includes the specification for customizing ``isinstance()`` and\n      ``issubclass()`` behavior through ``__instancecheck__()`` and\n      ``__subclasscheck__()``, with motivation for this functionality\n      in the context of adding Abstract Base Classes (see the ``abc``\n      module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n   Called when the instance is "called" as a function; if this method\n   is defined, ``x(arg1, arg2, ...)`` is a shorthand for\n   ``x.__call__(arg1, arg2, ...)``.\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well.  The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items.  It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``get()``,\n``clear()``, ``setdefault()``, ``pop()``, ``popitem()``, ``copy()``,\nand ``update()`` behaving similar to those for Python\'s standard\ndictionary objects.  The ``collections`` module provides a\n``MutableMapping`` abstract base class to help create those methods\nfrom a base set of ``__getitem__()``, ``__setitem__()``,\n``__delitem__()``, and ``keys()``. Mutable sequences should provide\nmethods ``append()``, ``count()``, ``index()``, ``extend()``,\n``insert()``, ``pop()``, ``remove()``, ``reverse()`` and ``sort()``,\nlike Python standard list objects.  Finally, sequence types should\nimplement addition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods ``__add__()``, ``__radd__()``,\n``__iadd__()``, ``__mul__()``, ``__rmul__()`` and ``__imul__()``\ndescribed below; they should not define other numerical operators.  It\nis recommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should search the mapping\'s keys; for\nsequences, it should search through the values.  It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``keys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n   Called to implement the built-in function ``len()``.  Should return\n   the length of the object, an integer ``>=`` 0.  Also, an object\n   that doesn\'t define a ``__bool__()`` method and whose ``__len__()``\n   method returns zero is considered to be false in a Boolean context.\n\nNote: Slicing is done exclusively with the following three methods.  A\n  call like\n\n     a[1:2] = b\n\n  is translated to\n\n     a[slice(1, 2, None)] = b\n\n  and so forth.  Missing slice items are always filled in with\n  ``None``.\n\nobject.__getitem__(self, key)\n\n   Called to implement evaluation of ``self[key]``. For sequence\n   types, the accepted keys should be integers and slice objects.\n   Note that the special interpretation of negative indexes (if the\n   class wishes to emulate a sequence type) is up to the\n   ``__getitem__()`` method. If *key* is of an inappropriate type,\n   ``TypeError`` may be raised; if of a value outside the set of\n   indexes for the sequence (after any special interpretation of\n   negative values), ``IndexError`` should be raised. For mapping\n   types, if *key* is missing (not in the container), ``KeyError``\n   should be raised.\n\n   Note: ``for`` loops expect that an ``IndexError`` will be raised for\n     illegal indexes to allow proper detection of the end of the\n     sequence.\n\nobject.__setitem__(self, key, value)\n\n   Called to implement assignment to ``self[key]``.  Same note as for\n   ``__getitem__()``.  This should only be implemented for mappings if\n   the objects support changes to the values for keys, or if new keys\n   can be added, or for sequences if elements can be replaced.  The\n   same exceptions should be raised for improper *key* values as for\n   the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n   Called to implement deletion of ``self[key]``.  Same note as for\n   ``__getitem__()``.  This should only be implemented for mappings if\n   the objects support removal of keys, or for sequences if elements\n   can be removed from the sequence.  The same exceptions should be\n   raised for improper *key* values as for the ``__getitem__()``\n   method.\n\nobject.__iter__(self)\n\n   This method is called when an iterator is required for a container.\n   This method should return a new iterator object that can iterate\n   over all the objects in the container.  For mappings, it should\n   iterate over the keys of the container, and should also be made\n   available as the method ``keys()``.\n\n   Iterator objects also need to implement this method; they are\n   required to return themselves.  For more information on iterator\n   objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n   Called (if present) by the ``reversed()`` built-in to implement\n   reverse iteration.  It should return a new iterator object that\n   iterates over all the objects in the container in reverse order.\n\n   If the ``__reversed__()`` method is not provided, the\n   ``reversed()`` built-in will fall back to using the sequence\n   protocol (``__len__()`` and ``__getitem__()``).  Objects that\n   support the sequence protocol should only provide\n   ``__reversed__()`` if they can provide an implementation that is\n   more efficient than the one provided by ``reversed()``.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence.  However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n   Called to implement membership test operators.  Should return true\n   if *item* is in *self*, false otherwise.  For mapping objects, this\n   should consider the keys of the mapping rather than the values or\n   the key-item pairs.\n\n   For objects that don\'t define ``__contains__()``, the membership\n   test first tries iteration via ``__iter__()``, then the old\n   sequence iteration protocol via ``__getitem__()``, see *this\n   section in the language reference*.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n   These methods are called to implement the binary arithmetic\n   operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n   ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n   ``|``).  For instance, to evaluate the expression ``x + y``, where\n   *x* is an instance of a class that has an ``__add__()`` method,\n   ``x.__add__(y)`` is called.  The ``__divmod__()`` method should be\n   the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n   should not be related to ``__truediv__()``.  Note that\n   ``__pow__()`` should be defined to accept an optional third\n   argument if the ternary version of the built-in ``pow()`` function\n   is to be supported.\n\n   If one of those methods does not support the operation with the\n   supplied arguments, it should return ``NotImplemented``.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n   These methods are called to implement the binary arithmetic\n   operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n   ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n   ``|``) with reflected (swapped) operands. These functions are only\n   called if the left operand does not support the corresponding\n   operation and the operands are of different types. [2]  For\n   instance, to evaluate the expression ``x - y``, where *y* is an\n   instance of a class that has an ``__rsub__()`` method,\n   ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns\n   *NotImplemented*.\n\n   Note that ternary ``pow()`` will not try calling ``__rpow__()``\n   (the coercion rules would become too complicated).\n\n   Note: If the right operand\'s type is a subclass of the left operand\'s\n     type and that subclass provides the reflected method for the\n     operation, this method will be called before the left operand\'s\n     non-reflected method.  This behavior allows subclasses to\n     override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n   These methods are called to implement the augmented arithmetic\n   assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n   ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``).  These methods\n   should attempt to do the operation in-place (modifying *self*) and\n   return the result (which could be, but does not have to be,\n   *self*).  If a specific method is not defined, the augmented\n   assignment falls back to the normal methods.  For instance, to\n   execute the statement ``x += y``, where *x* is an instance of a\n   class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n   called.  If *x* is an instance of a class that does not define a\n   ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n   considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n   Called to implement the unary arithmetic operations (``-``, ``+``,\n   ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n   Called to implement the built-in functions ``complex()``,\n   ``int()``, ``float()`` and ``round()``.  Should return a value of\n   the appropriate type.\n\nobject.__index__(self)\n\n   Called to implement ``operator.index()``.  Also called whenever\n   Python needs an integer object (such as in slicing, or in the\n   built-in ``bin()``, ``hex()`` and ``oct()`` functions). Must return\n   an integer.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code.  Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n   Enter the runtime context related to this object. The ``with``\n   statement will bind this method\'s return value to the target(s)\n   specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n   Exit the runtime context related to this object. The parameters\n   describe the exception that caused the context to be exited. If the\n   context was exited without an exception, all three arguments will\n   be ``None``.\n\n   If an exception is supplied, and the method wishes to suppress the\n   exception (i.e., prevent it from being propagated), it should\n   return a true value. Otherwise, the exception will be processed\n   normally upon exit from this method.\n\n   Note that ``__exit__()`` methods should not reraise the passed-in\n   exception; this is the caller\'s responsibility.\n\nSee also:\n\n   **PEP 0343** - The "with" statement\n      The specification, background, and examples for the Python\n      ``with`` statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary.  That behaviour is the reason why\nthe following code raises an exception:\n\n   >>> class C:\n   ...     pass\n   ...\n   >>> c = C()\n   >>> c.__len__ = lambda: 5\n   >>> len(c)\n   Traceback (most recent call last):\n     File "<stdin>", line 1, in <module>\n   TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as ``__hash__()`` and ``__repr__()`` that are implemented\nby all objects, including type objects. If the implicit lookup of\nthese methods used the conventional lookup process, they would fail\nwhen invoked on the type object itself:\n\n   >>> 1 .__hash__() == hash(1)\n   True\n   >>> int.__hash__() == hash(int)\n   Traceback (most recent call last):\n     File "<stdin>", line 1, in <module>\n   TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n   >>> type(1).__hash__(1) == hash(1)\n   True\n   >>> type(int).__hash__(int) == hash(int)\n   True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe ``__getattribute__()`` method even of the object\'s metaclass:\n\n   >>> class Meta(type):\n   ...    def __getattribute__(*args):\n   ...       print("Metaclass getattribute invoked")\n   ...       return type.__getattribute__(*args)\n   ...\n   >>> class C(object, metaclass=Meta):\n   ...     def __len__(self):\n   ...         return 10\n   ...     def __getattribute__(*args):\n   ...         print("Class getattribute invoked")\n   ...         return object.__getattribute__(*args)\n   ...\n   >>> c = C()\n   >>> c.__len__()                 # Explicit lookup via instance\n   Class getattribute invoked\n   10\n   >>> type(c).__len__(c)          # Explicit lookup via type\n   Metaclass getattribute invoked\n   10\n   >>> len(c)                      # Implicit lookup\n   10\n\nBypassing the ``__getattribute__()`` machinery in this fashion\nprovides significant scope for speed optimisations within the\ninterpreter, at the cost of some flexibility in the handling of\nspecial methods (the special method *must* be set on the class object\nitself in order to be consistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type, under\n    certain controlled conditions. It generally isn\'t a good idea\n    though, since it can lead to some very strange behaviour if it is\n    handled incorrectly.\n\n[2] For operands of the same type, it is assumed that if the non-\n    reflected method (such as ``__add__()``) fails the operation is\n    not supported, which is why the reflected method is not called.\n',
  'string-methods': '\nString Methods\n**************\n\nString objects support the methods listed below.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, bytes, bytearray, list,\ntuple, range* section. To output formatted strings, see the *String\nFormatting* section. Also, see the ``re`` module for string functions\nbased on regular expressions.\n\nstr.capitalize()\n\n   Return a copy of the string with its first character capitalized\n   and the rest lowercased.\n\nstr.center(width[, fillchar])\n\n   Return centered in a string of length *width*. Padding is done\n   using the specified *fillchar* (default is a space).\n\nstr.count(sub[, start[, end]])\n\n   Return the number of non-overlapping occurrences of substring *sub*\n   in the range [*start*, *end*].  Optional arguments *start* and\n   *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n   Return an encoded version of the string as a bytes object. Default\n   encoding is ``\'utf-8\'``. *errors* may be given to set a different\n   error handling scheme. The default for *errors* is ``\'strict\'``,\n   meaning that encoding errors raise a ``UnicodeError``. Other\n   possible values are ``\'ignore\'``, ``\'replace\'``,\n   ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and any other name\n   registered via ``codecs.register_error()``, see section *Codec Base\n   Classes*. For a list of possible encodings, see section *Standard\n   Encodings*.\n\n   Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n   Return ``True`` if the string ends with the specified *suffix*,\n   otherwise return ``False``.  *suffix* can also be a tuple of\n   suffixes to look for.  With optional *start*, test beginning at\n   that position.  With optional *end*, stop comparing at that\n   position.\n\nstr.expandtabs([tabsize])\n\n   Return a copy of the string where all tab characters are replaced\n   by one or more spaces, depending on the current column and the\n   given tab size.  The column number is reset to zero after each\n   newline occurring in the string. If *tabsize* is not given, a tab\n   size of ``8`` characters is assumed.  This doesn\'t understand other\n   non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n   Return the lowest index in the string where substring *sub* is\n   found, such that *sub* is contained in the slice ``s[start:end]``.\n   Optional arguments *start* and *end* are interpreted as in slice\n   notation.  Return ``-1`` if *sub* is not found.\n\nstr.format(*args, **kwargs)\n\n   Perform a string formatting operation.  The string on which this\n   method is called can contain literal text or replacement fields\n   delimited by braces ``{}``.  Each replacement field contains either\n   the numeric index of a positional argument, or the name of a\n   keyword argument.  Returns a copy of the string where each\n   replacement field is replaced with the string value of the\n   corresponding argument.\n\n   >>> "The sum of 1 + 2 is {0}".format(1+2)\n   \'The sum of 1 + 2 is 3\'\n\n   See *Format String Syntax* for a description of the various\n   formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n   Similar to ``str.format(**mapping)``, except that ``mapping`` is\n   used directly and not copied to a ``dict`` .  This is useful if for\n   example ``mapping`` is a dict subclass:\n\n   >>> class Default(dict):\n   ...     def __missing__(self, key):\n   ...         return key\n   ...\n   >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n   \'Guido was born in country\'\n\n   New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n   Like ``find()``, but raise ``ValueError`` when the substring is not\n   found.\n\nstr.isalnum()\n\n   Return true if all characters in the string are alphanumeric and\n   there is at least one character, false otherwise.\n\nstr.isalpha()\n\n   Return true if all characters in the string are alphabetic and\n   there is at least one character, false otherwise.\n\nstr.isdecimal()\n\n   Return true if all characters in the string are decimal characters\n   and there is at least one character, false otherwise. Decimal\n   characters include digit characters, and all characters that that\n   can be used to form decimal-radix numbers, e.g. U+0660, ARABIC-\n   INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n   Return true if all characters in the string are digits and there is\n   at least one character, false otherwise.\n\nstr.isidentifier()\n\n   Return true if the string is a valid identifier according to the\n   language definition, section *Identifiers and keywords*.\n\nstr.islower()\n\n   Return true if all cased characters in the string are lowercase and\n   there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n   Return true if all characters in the string are numeric characters,\n   and there is at least one character, false otherwise. Numeric\n   characters include digit characters, and all characters that have\n   the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n   ONE FIFTH.\n\nstr.isprintable()\n\n   Return true if all characters in the string are printable or the\n   string is empty, false otherwise.  Nonprintable characters are\n   those characters defined in the Unicode character database as\n   "Other" or "Separator", excepting the ASCII space (0x20) which is\n   considered printable.  (Note that printable characters in this\n   context are those which should not be escaped when ``repr()`` is\n   invoked on a string.  It has no bearing on the handling of strings\n   written to ``sys.stdout`` or ``sys.stderr``.)\n\nstr.isspace()\n\n   Return true if there are only whitespace characters in the string\n   and there is at least one character, false otherwise.\n\nstr.istitle()\n\n   Return true if the string is a titlecased string and there is at\n   least one character, for example uppercase characters may only\n   follow uncased characters and lowercase characters only cased ones.\n   Return false otherwise.\n\nstr.isupper()\n\n   Return true if all cased characters in the string are uppercase and\n   there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n   Return a string which is the concatenation of the strings in the\n   *iterable* *iterable*.  A ``TypeError`` will be raised if there are\n   any non-string values in *seq*, including ``bytes`` objects.  The\n   separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n   Return the string left justified in a string of length *width*.\n   Padding is done using the specified *fillchar* (default is a\n   space).  The original string is returned if *width* is less than\n   ``len(s)``.\n\nstr.lower()\n\n   Return a copy of the string converted to lowercase.\n\nstr.lstrip([chars])\n\n   Return a copy of the string with leading characters removed.  The\n   *chars* argument is a string specifying the set of characters to be\n   removed.  If omitted or ``None``, the *chars* argument defaults to\n   removing whitespace.  The *chars* argument is not a prefix; rather,\n   all combinations of its values are stripped:\n\n   >>> \'   spacious   \'.lstrip()\n   \'spacious   \'\n   >>> \'www.example.com\'.lstrip(\'cmowz.\')\n   \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n   This static method returns a translation table usable for\n   ``str.translate()``.\n\n   If there is only one argument, it must be a dictionary mapping\n   Unicode ordinals (integers) or characters (strings of length 1) to\n   Unicode ordinals, strings (of arbitrary lengths) or None.\n   Character keys will then be converted to ordinals.\n\n   If there are two arguments, they must be strings of equal length,\n   and in the resulting dictionary, each character in x will be mapped\n   to the character at the same position in y.  If there is a third\n   argument, it must be a string, whose characters will be mapped to\n   None in the result.\n\nstr.partition(sep)\n\n   Split the string at the first occurrence of *sep*, and return a\n   3-tuple containing the part before the separator, the separator\n   itself, and the part after the separator.  If the separator is not\n   found, return a 3-tuple containing the string itself, followed by\n   two empty strings.\n\nstr.replace(old, new[, count])\n\n   Return a copy of the string with all occurrences of substring *old*\n   replaced by *new*.  If the optional argument *count* is given, only\n   the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n   Return the highest index in the string where substring *sub* is\n   found, such that *sub* is contained within ``s[start:end]``.\n   Optional arguments *start* and *end* are interpreted as in slice\n   notation.  Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n   Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n   is not found.\n\nstr.rjust(width[, fillchar])\n\n   Return the string right justified in a string of length *width*.\n   Padding is done using the specified *fillchar* (default is a\n   space). The original string is returned if *width* is less than\n   ``len(s)``.\n\nstr.rpartition(sep)\n\n   Split the string at the last occurrence of *sep*, and return a\n   3-tuple containing the part before the separator, the separator\n   itself, and the part after the separator.  If the separator is not\n   found, return a 3-tuple containing two empty strings, followed by\n   the string itself.\n\nstr.rsplit([sep[, maxsplit]])\n\n   Return a list of the words in the string, using *sep* as the\n   delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n   are done, the *rightmost* ones.  If *sep* is not specified or\n   ``None``, any whitespace string is a separator.  Except for\n   splitting from the right, ``rsplit()`` behaves like ``split()``\n   which is described in detail below.\n\nstr.rstrip([chars])\n\n   Return a copy of the string with trailing characters removed.  The\n   *chars* argument is a string specifying the set of characters to be\n   removed.  If omitted or ``None``, the *chars* argument defaults to\n   removing whitespace.  The *chars* argument is not a suffix; rather,\n   all combinations of its values are stripped:\n\n   >>> \'   spacious   \'.rstrip()\n   \'   spacious\'\n   >>> \'mississippi\'.rstrip(\'ipz\')\n   \'mississ\'\n\nstr.split([sep[, maxsplit]])\n\n   Return a list of the words in the string, using *sep* as the\n   delimiter string.  If *maxsplit* is given, at most *maxsplit*\n   splits are done (thus, the list will have at most ``maxsplit+1``\n   elements).  If *maxsplit* is not specified, then there is no limit\n   on the number of splits (all possible splits are made).\n\n   If *sep* is given, consecutive delimiters are not grouped together\n   and are deemed to delimit empty strings (for example,\n   ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``).  The *sep*\n   argument may consist of multiple characters (for example,\n   ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n   an empty string with a specified separator returns ``[\'\']``.\n\n   If *sep* is not specified or is ``None``, a different splitting\n   algorithm is applied: runs of consecutive whitespace are regarded\n   as a single separator, and the result will contain no empty strings\n   at the start or end if the string has leading or trailing\n   whitespace.  Consequently, splitting an empty string or a string\n   consisting of just whitespace with a ``None`` separator returns\n   ``[]``.\n\n   For example, ``\' 1  2   3  \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n   and ``\'  1  2   3  \'.split(None, 1)`` returns ``[\'1\', \'2   3  \']``.\n\nstr.splitlines([keepends])\n\n   Return a list of the lines in the string, breaking at line\n   boundaries.  Line breaks are not included in the resulting list\n   unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n   Return ``True`` if string starts with the *prefix*, otherwise\n   return ``False``. *prefix* can also be a tuple of prefixes to look\n   for.  With optional *start*, test string beginning at that\n   position.  With optional *end*, stop comparing string at that\n   position.\n\nstr.strip([chars])\n\n   Return a copy of the string with the leading and trailing\n   characters removed. The *chars* argument is a string specifying the\n   set of characters to be removed. If omitted or ``None``, the\n   *chars* argument defaults to removing whitespace. The *chars*\n   argument is not a prefix or suffix; rather, all combinations of its\n   values are stripped:\n\n   >>> \'   spacious   \'.strip()\n   \'spacious\'\n   >>> \'www.example.com\'.strip(\'cmowz.\')\n   \'example\'\n\nstr.swapcase()\n\n   Return a copy of the string with uppercase characters converted to\n   lowercase and vice versa.\n\nstr.title()\n\n   Return a titlecased version of the string where words start with an\n   uppercase character and the remaining characters are lowercase.\n\n   The algorithm uses a simple language-independent definition of a\n   word as groups of consecutive letters.  The definition works in\n   many contexts but it means that apostrophes in contractions and\n   possessives form word boundaries, which may not be the desired\n   result:\n\n      >>> "they\'re bill\'s friends from the UK".title()\n      "They\'Re Bill\'S Friends From The Uk"\n\n   A workaround for apostrophes can be constructed using regular\n   expressions:\n\n      >>> import re\n      >>> def titlecase(s):\n              return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n                            lambda mo: mo.group(0)[0].upper() +\n                                       mo.group(0)[1:].lower(),\n                            s)\n\n      >>> titlecase("they\'re bill\'s friends.")\n      "They\'re Bill\'s Friends."\n\nstr.translate(map)\n\n   Return a copy of the *s* where all characters have been mapped\n   through the *map* which must be a dictionary of Unicode ordinals\n   (integers) to Unicode ordinals, strings or ``None``.  Unmapped\n   characters are left untouched. Characters mapped to ``None`` are\n   deleted.\n\n   You can use ``str.maketrans()`` to create a translation map from\n   character-to-character mappings in different formats.\n\n   Note: An even more flexible approach is to create a custom character\n     mapping codec using the ``codecs`` module (see\n     ``encodings.cp1251`` for an example).\n\nstr.upper()\n\n   Return a copy of the string converted to uppercase.\n\nstr.zfill(width)\n\n   Return the numeric string left filled with zeros in a string of\n   length *width*.  A sign prefix is handled correctly.  The original\n   string is returned if *width* is less than ``len(s)``.\n',
  'strings': '\nString and Bytes literals\n*************************\n\nString literals are described by the following lexical definitions:\n\n   stringliteral   ::= [stringprefix](shortstring | longstring)\n   stringprefix    ::= "r" | "R"\n   shortstring     ::= "\'" shortstringitem* "\'" | \'"\' shortstringitem* \'"\'\n   longstring      ::= "\'\'\'" longstringitem* "\'\'\'" | \'"""\' longstringitem* \'"""\'\n   shortstringitem ::= shortstringchar | stringescapeseq\n   longstringitem  ::= longstringchar | stringescapeseq\n   shortstringchar ::= <any source character except "\\" or newline or the quote>\n   longstringchar  ::= <any source character except "\\">\n   stringescapeseq ::= "\\" <any source character>\n\n   bytesliteral   ::= bytesprefix(shortbytes | longbytes)\n   bytesprefix    ::= "b" | "B" | "br" | "Br" | "bR" | "BR"\n   shortbytes     ::= "\'" shortbytesitem* "\'" | \'"\' shortbytesitem* \'"\'\n   longbytes      ::= "\'\'\'" longbytesitem* "\'\'\'" | \'"""\' longbytesitem* \'"""\'\n   shortbytesitem ::= shortbyteschar | bytesescapeseq\n   longbytesitem  ::= longbyteschar | bytesescapeseq\n   shortbyteschar ::= <any ASCII character except "\\" or newline or the quote>\n   longbyteschar  ::= <any ASCII character except "\\">\n   bytesescapeseq ::= "\\" <any ASCII character>\n\nOne syntactic restriction not indicated by these productions is that\nwhitespace is not allowed between the ``stringprefix`` or\n``bytesprefix`` and the rest of the literal. The source character set\nis defined by the encoding declaration; it is UTF-8 if no encoding\ndeclaration is given in the source file; see section *Encoding\ndeclarations*.\n\nIn plain English: Both types of literals can be enclosed in matching\nsingle quotes (``\'``) or double quotes (``"``).  They can also be\nenclosed in matching groups of three single or double quotes (these\nare generally referred to as *triple-quoted strings*).  The backslash\n(``\\``) character is used to escape characters that otherwise have a\nspecial meaning, such as newline, backslash itself, or the quote\ncharacter.\n\nBytes literals are always prefixed with ``\'b\'`` or ``\'B\'``; they\nproduce an instance of the ``bytes`` type instead of the ``str`` type.\nThey may only contain ASCII characters; bytes with a numeric value of\n128 or greater must be expressed with escapes.\n\nBoth string and bytes literals may optionally be prefixed with a\nletter ``\'r\'`` or ``\'R\'``; such strings are called *raw strings* and\ntreat backslashes as literal characters.  As a result, in string\nliterals, ``\'\\U\'`` and ``\'\\u\'`` escapes in raw strings are not treated\nspecially.\n\nIn triple-quoted strings, unescaped newlines and quotes are allowed\n(and are retained), except that three unescaped quotes in a row\nterminate the string.  (A "quote" is the character used to open the\nstring, i.e. either ``\'`` or ``"``.)\n\nUnless an ``\'r\'`` or ``\'R\'`` prefix is present, escape sequences in\nstrings are interpreted according to rules similar to those used by\nStandard C.  The recognized escape sequences are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence   | Meaning                           | Notes   |\n+===================+===================================+=========+\n| ``\\newline``      | Backslash and newline ignored     |         |\n+-------------------+-----------------------------------+---------+\n| ``\\\\``            | Backslash (``\\``)                 |         |\n+-------------------+-----------------------------------+---------+\n| ``\\\'``            | Single quote (``\'``)              |         |\n+-------------------+-----------------------------------+---------+\n| ``\\"``            | Double quote (``"``)              |         |\n+-------------------+-----------------------------------+---------+\n| ``\\a``            | ASCII Bell (BEL)                  |         |\n+-------------------+-----------------------------------+---------+\n| ``\\b``            | ASCII Backspace (BS)              |         |\n+-------------------+-----------------------------------+---------+\n| ``\\f``            | ASCII Formfeed (FF)               |         |\n+-------------------+-----------------------------------+---------+\n| ``\\n``            | ASCII Linefeed (LF)               |         |\n+-------------------+-----------------------------------+---------+\n| ``\\r``            | ASCII Carriage Return (CR)        |         |\n+-------------------+-----------------------------------+---------+\n| ``\\t``            | ASCII Horizontal Tab (TAB)        |         |\n+-------------------+-----------------------------------+---------+\n| ``\\v``            | ASCII Vertical Tab (VT)           |         |\n+-------------------+-----------------------------------+---------+\n| ``\\ooo``          | Character with octal value *ooo*  | (1,3)   |\n+-------------------+-----------------------------------+---------+\n| ``\\xhh``          | Character with hex value *hh*     | (2,3)   |\n+-------------------+-----------------------------------+---------+\n\nEscape sequences only recognized in string literals are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence   | Meaning                           | Notes   |\n+===================+===================================+=========+\n| ``\\N{name}``      | Character named *name* in the     |         |\n|                   | Unicode database                  |         |\n+-------------------+-----------------------------------+---------+\n| ``\\uxxxx``        | Character with 16-bit hex value   | (4)     |\n|                   | *xxxx*                            |         |\n+-------------------+-----------------------------------+---------+\n| ``\\Uxxxxxxxx``    | Character with 32-bit hex value   | (5)     |\n|                   | *xxxxxxxx*                        |         |\n+-------------------+-----------------------------------+---------+\n\nNotes:\n\n1. As in Standard C, up to three octal digits are accepted.\n\n2. Unlike in Standard C, exactly two hex digits are required.\n\n3. In a bytes literal, hexadecimal and octal escapes denote the byte\n   with the given value. In a string literal, these escapes denote a\n   Unicode character with the given value.\n\n4. Individual code units which form parts of a surrogate pair can be\n   encoded using this escape sequence.  Exactly four hex digits are\n   required.\n\n5. Any Unicode character can be encoded this way, but characters\n   outside the Basic Multilingual Plane (BMP) will be encoded using a\n   surrogate pair if Python is compiled to use 16-bit code units (the\n   default).  Exactly eight hex digits are required.\n\nUnlike Standard C, all unrecognized escape sequences are left in the\nstring unchanged, i.e., *the backslash is left in the string*.  (This\nbehavior is useful when debugging: if an escape sequence is mistyped,\nthe resulting output is more easily recognized as broken.)  It is also\nimportant to note that the escape sequences only recognized in string\nliterals fall into the category of unrecognized escapes for bytes\nliterals.\n\nEven in a raw string, string quotes can be escaped with a backslash,\nbut the backslash remains in the string; for example, ``r"\\""`` is a\nvalid string literal consisting of two characters: a backslash and a\ndouble quote; ``r"\\"`` is not a valid string literal (even a raw\nstring cannot end in an odd number of backslashes).  Specifically, *a\nraw string cannot end in a single backslash* (since the backslash\nwould escape the following quote character).  Note also that a single\nbackslash followed by a newline is interpreted as those two characters\nas part of the string, *not* as a line continuation.\n',
  'subscriptions': '\nSubscriptions\n*************\n\nA subscription selects an item of a sequence (string, tuple or list)\nor mapping (dictionary) object:\n\n   subscription ::= primary "[" expression_list "]"\n\nThe primary must evaluate to an object that supports subscription,\ne.g. a list or dictionary.  User-defined objects can support\nsubscription by defining a ``__getitem__()`` method.\n\nFor built-in objects, there are two types of objects that support\nsubscription:\n\nIf the primary is a mapping, the expression list must evaluate to an\nobject whose value is one of the keys of the mapping, and the\nsubscription selects the value in the mapping that corresponds to that\nkey.  (The expression list is a tuple except if it has exactly one\nitem.)\n\nIf the primary is a sequence, the expression (list) must evaluate to\nan integer or a slice (as discussed in the following section).\n\nThe formal syntax makes no special provision for negative indices in\nsequences; however, built-in sequences all provide a ``__getitem__()``\nmethod that interprets negative indices by adding the length of the\nsequence to the index (so that ``x[-1]`` selects the last item of\n``x``).  The resulting value must be a nonnegative integer less than\nthe number of items in the sequence, and the subscription selects the\nitem whose index is that value (counting from zero). Since the support\nfor negative indices and slicing occurs in the object\'s\n``__getitem__()`` method, subclasses overriding this method will need\nto explicitly add that support.\n\nA string\'s items are characters.  A character is not a separate data\ntype but a string of exactly one character.\n',
@@ -70,7 +70,7 @@
  'typesmapping': '\nMapping Types --- ``dict``\n**************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects.  There is currently only one standard\nmapping type, the *dictionary*.  (For other containers see the built\nin ``list``, ``set``, and ``tuple`` classes, and the ``collections``\nmodule.)\n\nA dictionary\'s keys are *almost* arbitrary values.  Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys.  Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as ``1`` and ``1.0``) then they can be used interchangeably to\nindex the same dictionary entry.  (Note however, that since computers\nstore floating-point numbers as approximations it is usually unwise to\nuse them as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of\n``key: value`` pairs within braces, for example: ``{\'jack\': 4098,\n\'sjoerd\': 4127}`` or ``{4098: \'jack\', 4127: \'sjoerd\'}``, or by the\n``dict`` constructor.\n\nclass class dict([arg])\n\n   Return a new dictionary initialized from an optional positional\n   argument or from a set of keyword arguments.  If no arguments are\n   given, return a new empty dictionary.  If the positional argument\n   *arg* is a mapping object, return a dictionary mapping the same\n   keys to the same values as does the mapping object.  Otherwise the\n   positional argument must be a sequence, a container that supports\n   iteration, or an iterator object.  The elements of the argument\n   must each also be of one of those kinds, and each must in turn\n   contain exactly two objects.  The first is used as a key in the new\n   dictionary, and the second as the key\'s value.  If a given key is\n   seen more than once, the last value associated with it is retained\n   in the new dictionary.\n\n   If keyword arguments are given, the keywords themselves with their\n   associated values are added as items to the dictionary.  If a key\n   is specified both in the positional argument and as a keyword\n   argument, the value associated with the keyword is retained in the\n   dictionary.  For example, these all return a dictionary equal to\n   ``{"one": 1, "two": 2}``:\n\n   * ``dict(one=1, two=2)``\n\n   * ``dict({\'one\': 1, \'two\': 2})``\n\n   * ``dict(zip((\'one\', \'two\'), (1, 2)))``\n\n   * ``dict([[\'two\', 2], [\'one\', 1]])``\n\n   The first example only works for keys that are valid Python\n   identifiers; the others work with any valid keys.\n\n   These are the operations that dictionaries support (and therefore,\n   custom mapping types should support too):\n\n   len(d)\n\n      Return the number of items in the dictionary *d*.\n\n   d[key]\n\n      Return the item of *d* with key *key*.  Raises a ``KeyError`` if\n      *key* is not in the map.\n\n      If a subclass of dict defines a method ``__missing__()``, if the\n      key *key* is not present, the ``d[key]`` operation calls that\n      method with the key *key* as argument.  The ``d[key]`` operation\n      then returns or raises whatever is returned or raised by the\n      ``__missing__(key)`` call if the key is not present. No other\n      operations or methods invoke ``__missing__()``. If\n      ``__missing__()`` is not defined, ``KeyError`` is raised.\n      ``__missing__()`` must be a method; it cannot be an instance\n      variable. For an example, see ``collections.defaultdict``.\n\n   d[key] = value\n\n      Set ``d[key]`` to *value*.\n\n   del d[key]\n\n      Remove ``d[key]`` from *d*.  Raises a ``KeyError`` if *key* is\n      not in the map.\n\n   key in d\n\n      Return ``True`` if *d* has a key *key*, else ``False``.\n\n   key not in d\n\n      Equivalent to ``not key in d``.\n\n   iter(d)\n\n      Return an iterator over the keys of the dictionary.  This is a\n      shortcut for ``iter(d.keys())``.\n\n   clear()\n\n      Remove all items from the dictionary.\n\n   copy()\n\n      Return a shallow copy of the dictionary.\n\n   classmethod fromkeys(seq[, value])\n\n      Create a new dictionary with keys from *seq* and values set to\n      *value*.\n\n      ``fromkeys()`` is a class method that returns a new dictionary.\n      *value* defaults to ``None``.\n\n   get(key[, default])\n\n      Return the value for *key* if *key* is in the dictionary, else\n      *default*. If *default* is not given, it defaults to ``None``,\n      so that this method never raises a ``KeyError``.\n\n   items()\n\n      Return a new view of the dictionary\'s items (``(key, value)``\n      pairs).  See below for documentation of view objects.\n\n   keys()\n\n      Return a new view of the dictionary\'s keys.  See below for\n      documentation of view objects.\n\n   pop(key[, default])\n\n      If *key* is in the dictionary, remove it and return its value,\n      else return *default*.  If *default* is not given and *key* is\n      not in the dictionary, a ``KeyError`` is raised.\n\n   popitem()\n\n      Remove and return an arbitrary ``(key, value)`` pair from the\n      dictionary.\n\n      ``popitem()`` is useful to destructively iterate over a\n      dictionary, as often used in set algorithms.  If the dictionary\n      is empty, calling ``popitem()`` raises a ``KeyError``.\n\n   setdefault(key[, default])\n\n      If *key* is in the dictionary, return its value.  If not, insert\n      *key* with a value of *default* and return *default*.  *default*\n      defaults to ``None``.\n\n   update([other])\n\n      Update the dictionary with the key/value pairs from *other*,\n      overwriting existing keys.  Return ``None``.\n\n      ``update()`` accepts either another dictionary object or an\n      iterable of key/value pairs (as tuples or other iterables of\n      length two).  If keyword arguments are specified, the dictionary\n      is then updated with those key/value pairs: ``d.update(red=1,\n      blue=2)``.\n\n   values()\n\n      Return a new view of the dictionary\'s values.  See below for\n      documentation of view objects.\n\n\nDictionary view objects\n=======================\n\nThe objects returned by ``dict.keys()``, ``dict.values()`` and\n``dict.items()`` are *view objects*.  They provide a dynamic view on\nthe dictionary\'s entries, which means that when the dictionary\nchanges, the view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n   Return the number of entries in the dictionary.\n\niter(dictview)\n\n   Return an iterator over the keys, values or items (represented as\n   tuples of ``(key, value)``) in the dictionary.\n\n   Keys and values are iterated over in an arbitrary order which is\n   non-random, varies across Python implementations, and depends on\n   the dictionary\'s history of insertions and deletions. If keys,\n   values and items views are iterated over with no intervening\n   modifications to the dictionary, the order of items will directly\n   correspond.  This allows the creation of ``(value, key)`` pairs\n   using ``zip()``: ``pairs = zip(d.values(), d.keys())``.  Another\n   way to create the same list is ``pairs = [(v, k) for (k, v) in\n   d.items()]``.\n\n   Iterating views while adding or deleting entries in the dictionary\n   may raise a ``RuntimeError`` or fail to iterate over all entries.\n\nx in dictview\n\n   Return ``True`` if *x* is in the underlying dictionary\'s keys,\n   values or items (in the latter case, *x* should be a ``(key,\n   value)`` tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that ``(key, value)`` pairs are unique\nand hashable, then the items view is also set-like.  (Values views are\nnot treated as set-like since the entries are generally not unique.)\nFor set-like views, all of the operations defined for the abstract\nbase class ``collections.Set`` are available (for example, ``==``,\n``<``, or ``^``).\n\nAn example of dictionary view usage:\n\n   >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n   >>> keys = dishes.keys()\n   >>> values = dishes.values()\n\n   >>> # iteration\n   >>> n = 0\n   >>> for val in values:\n   ...     n += val\n   >>> print(n)\n   504\n\n   >>> # keys and values are iterated over in the same order\n   >>> list(keys)\n   [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n   >>> list(values)\n   [2, 1, 1, 500]\n\n   >>> # view objects are dynamic and reflect dict changes\n   >>> del dishes[\'eggs\']\n   >>> del dishes[\'sausage\']\n   >>> list(keys)\n   [\'spam\', \'bacon\']\n\n   >>> # set operations\n   >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n   {\'bacon\'}\n   >>> keys ^ {\'sausage\', \'juice\'}\n   {\'juice\', \'eggs\', \'bacon\', \'spam\'}\n',
  'typesmethods': "\nMethods\n*******\n\nMethods are functions that are called using the attribute notation.\nThere are two flavors: built-in methods (such as ``append()`` on\nlists) and class instance methods.  Built-in methods are described\nwith the types that support them.\n\nIf you access a method (a function defined in a class namespace)\nthrough an instance, you get a special object: a *bound method* (also\ncalled *instance method*) object. When called, it will add the\n``self`` argument to the argument list.  Bound methods have two\nspecial read-only attributes: ``m.__self__`` is the object on which\nthe method operates, and ``m.__func__`` is the function implementing\nthe method.  Calling ``m(arg-1, arg-2, ..., arg-n)`` is completely\nequivalent to calling ``m.__func__(m.__self__, arg-1, arg-2, ...,\narg-n)``.\n\nLike function objects, bound method objects support getting arbitrary\nattributes.  However, since method attributes are actually stored on\nthe underlying function object (``meth.__func__``), setting method\nattributes on bound methods is disallowed.  Attempting to set a method\nattribute results in a ``TypeError`` being raised.  In order to set a\nmethod attribute, you need to explicitly set it on the underlying\nfunction object:\n\n   class C:\n       def method(self):\n           pass\n\n   c = C()\n   c.method.__func__.whoami = 'my name is c'\n\nSee *The standard type hierarchy* for more information.\n",
  'typesmodules': "\nModules\n*******\n\nThe only special operation on a module is attribute access:\n``m.name``, where *m* is a module and *name* accesses a name defined\nin *m*'s symbol table. Module attributes can be assigned to.  (Note\nthat the ``import`` statement is not, strictly speaking, an operation\non a module object; ``import foo`` does not require a module object\nnamed *foo* to exist, rather it requires an (external) *definition*\nfor a module named *foo* somewhere.)\n\nA special member of every module is ``__dict__``. This is the\ndictionary containing the module's symbol table. Modifying this\ndictionary will actually change the module's symbol table, but direct\nassignment to the ``__dict__`` attribute is not possible (you can\nwrite ``m.__dict__['a'] = 1``, which defines ``m.a`` to be ``1``, but\nyou can't write ``m.__dict__ = {}``).  Modifying ``__dict__`` directly\nis not recommended.\n\nModules built into the interpreter are written like this: ``<module\n'sys' (built-in)>``.  If loaded from a file, they are written as\n``<module 'os' from '/usr/local/lib/pythonX.Y/os.pyc'>``.\n",
- 'typesseq': '\nSequence Types --- ``str``, ``bytes``, ``bytearray``, ``list``, ``tuple``, ``range``\n************************************************************************************\n\nThere are six sequence types: strings, byte sequences (``bytes``\nobjects), byte arrays (``bytearray`` objects), lists, tuples, and\nrange objects.  For other containers see the built in ``dict`` and\n``set`` classes, and the ``collections`` module.\n\nStrings contain Unicode characters.  Their literals are written in\nsingle or double quotes: ``\'xyzzy\'``, ``"frobozz"``.  See *String and\nBytes literals* for more about string literals.  In addition to the\nfunctionality described here, there are also string-specific methods\ndescribed in the *String Methods* section.\n\nBytes and bytearray objects contain single bytes -- the former is\nimmutable while the latter is a mutable sequence.  Bytes objects can\nbe constructed the constructor, ``bytes()``, and from literals; use a\n``b`` prefix with normal string syntax: ``b\'xyzzy\'``.  To construct\nbyte arrays, use the ``bytearray()`` function.\n\nWhile string objects are sequences of characters (represented by\nstrings of length 1), bytes and bytearray objects are sequences of\n*integers* (between 0 and 255), representing the ASCII value of single\nbytes.  That means that for a bytes or bytearray object *b*, ``b[0]``\nwill be an integer, while ``b[0:1]`` will be a bytes or bytearray\nobject of length 1.  The representation of bytes objects uses the\nliteral format (``b\'...\'``) since it is generally more useful than\ne.g. ``bytes([50, 19, 100])``.  You can always convert a bytes object\ninto a list of integers using ``list(b)``.\n\nAlso, while in previous Python versions, byte strings and Unicode\nstrings could be exchanged for each other rather freely (barring\nencoding issues), strings and bytes are now completely separate\nconcepts.  There\'s no implicit en-/decoding if you pass an object of\nthe wrong type.  A string always compares unequal to a bytes or\nbytearray object.\n\nLists are constructed with square brackets, separating items with\ncommas: ``[a, b, c]``.  Tuples are constructed by the comma operator\n(not within square brackets), with or without enclosing parentheses,\nbut an empty tuple must have the enclosing parentheses, such as ``a,\nb, c`` or ``()``.  A single item tuple must have a trailing comma,\nsuch as ``(d,)``.\n\nObjects of type range are created using the ``range()`` function.\nThey don\'t support slicing, concatenation or repetition, and using\n``in``, ``not in``, ``min()`` or ``max()`` on them is inefficient.\n\nMost sequence types support the following operations.  The ``in`` and\n``not in`` operations have the same priorities as the comparison\noperations.  The ``+`` and ``*`` operations have the same priority as\nthe corresponding numeric operations. [3] Additional methods are\nprovided for *Mutable Sequence Types*.\n\nThis table lists the sequence operations sorted in ascending priority\n(operations in the same box have the same priority).  In the table,\n*s* and *t* are sequences of the same type; *n*, *i* and *j* are\nintegers:\n\n+--------------------+----------------------------------+------------+\n| Operation          | Result                           | Notes      |\n+====================+==================================+============+\n| ``x in s``         | ``True`` if an item of *s* is    | (1)        |\n|                    | equal to *x*, else ``False``     |            |\n+--------------------+----------------------------------+------------+\n| ``x not in s``     | ``False`` if an item of *s* is   | (1)        |\n|                    | equal to *x*, else ``True``      |            |\n+--------------------+----------------------------------+------------+\n| ``s + t``          | the concatenation of *s* and *t* | (6)        |\n+--------------------+----------------------------------+------------+\n| ``s * n, n * s``   | *n* shallow copies of *s*        | (2)        |\n|                    | concatenated                     |            |\n+--------------------+----------------------------------+------------+\n| ``s[i]``           | *i*\'th item of *s*, origin 0     | (3)        |\n+--------------------+----------------------------------+------------+\n| ``s[i:j]``         | slice of *s* from *i* to *j*     | (3)(4)     |\n+--------------------+----------------------------------+------------+\n| ``s[i:j:k]``       | slice of *s* from *i* to *j*     | (3)(5)     |\n|                    | with step *k*                    |            |\n+--------------------+----------------------------------+------------+\n| ``len(s)``         | length of *s*                    |            |\n+--------------------+----------------------------------+------------+\n| ``min(s)``         | smallest item of *s*             |            |\n+--------------------+----------------------------------+------------+\n| ``max(s)``         | largest item of *s*              |            |\n+--------------------+----------------------------------+------------+\n\nSequence types also support comparisons.  In particular, tuples and\nlists are compared lexicographically by comparing corresponding\nelements.  This means that to compare equal, every element must\ncompare equal and the two sequences must be of the same type and have\nthe same length.  (For full details see *Comparisons* in the language\nreference.)\n\nNotes:\n\n1. When *s* is a string object, the ``in`` and ``not in`` operations\n   act like a substring test.\n\n2. Values of *n* less than ``0`` are treated as ``0`` (which yields an\n   empty sequence of the same type as *s*).  Note also that the copies\n   are shallow; nested structures are not copied.  This often haunts\n   new Python programmers; consider:\n\n   >>> lists = [[]] * 3\n   >>> lists\n   [[], [], []]\n   >>> lists[0].append(3)\n   >>> lists\n   [[3], [3], [3]]\n\n   What has happened is that ``[[]]`` is a one-element list containing\n   an empty list, so all three elements of ``[[]] * 3`` are (pointers\n   to) this single empty list.  Modifying any of the elements of\n   ``lists`` modifies this single list. You can create a list of\n   different lists this way:\n\n   >>> lists = [[] for i in range(3)]\n   >>> lists[0].append(3)\n   >>> lists[1].append(5)\n   >>> lists[2].append(7)\n   >>> lists\n   [[3], [5], [7]]\n\n3. If *i* or *j* is negative, the index is relative to the end of the\n   string: ``len(s) + i`` or ``len(s) + j`` is substituted.  But note\n   that ``-0`` is still ``0``.\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n   items with index *k* such that ``i <= k < j``.  If *i* or *j* is\n   greater than ``len(s)``, use ``len(s)``.  If *i* is omitted or\n   ``None``, use ``0``.  If *j* is omitted or ``None``, use\n   ``len(s)``.  If *i* is greater than or equal to *j*, the slice is\n   empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n   sequence of items with index  ``x = i + n*k`` such that ``0 <= n <\n   (j-i)/k``.  In other words, the indices are ``i``, ``i+k``,\n   ``i+2*k``, ``i+3*k`` and so on, stopping when *j* is reached (but\n   never including *j*).  If *i* or *j* is greater than ``len(s)``,\n   use ``len(s)``.  If *i* or *j* are omitted or ``None``, they become\n   "end" values (which end depends on the sign of *k*).  Note, *k*\n   cannot be zero. If *k* is ``None``, it is treated like ``1``.\n\n6. **CPython implementation detail:** If *s* and *t* are both strings,\n   some Python implementations such as CPython can usually perform an\n   in-place optimization for assignments of the form ``s = s + t`` or\n   ``s += t``.  When applicable, this optimization makes quadratic\n   run-time much less likely.  This optimization is both version and\n   implementation dependent.  For performance sensitive code, it is\n   preferable to use the ``str.join()`` method which assures\n   consistent linear concatenation performance across versions and\n   implementations.\n\n\nString Methods\n==============\n\nString objects support the methods listed below.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, bytes, bytearray, list,\ntuple, range* section. To output formatted strings, see the *String\nFormatting* section. Also, see the ``re`` module for string functions\nbased on regular expressions.\n\nstr.capitalize()\n\n   Return a copy of the string with its first character capitalized\n   and the rest lowercased.\n\nstr.center(width[, fillchar])\n\n   Return centered in a string of length *width*. Padding is done\n   using the specified *fillchar* (default is a space).\n\nstr.count(sub[, start[, end]])\n\n   Return the number of non-overlapping occurrences of substring *sub*\n   in the range [*start*, *end*].  Optional arguments *start* and\n   *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n   Return an encoded version of the string as a bytes object. Default\n   encoding is ``\'utf-8\'``. *errors* may be given to set a different\n   error handling scheme. The default for *errors* is ``\'strict\'``,\n   meaning that encoding errors raise a ``UnicodeError``. Other\n   possible values are ``\'ignore\'``, ``\'replace\'``,\n   ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and any other name\n   registered via ``codecs.register_error()``, see section *Codec Base\n   Classes*. For a list of possible encodings, see section *Standard\n   Encodings*.\n\n   Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n   Return ``True`` if the string ends with the specified *suffix*,\n   otherwise return ``False``.  *suffix* can also be a tuple of\n   suffixes to look for.  With optional *start*, test beginning at\n   that position.  With optional *end*, stop comparing at that\n   position.\n\nstr.expandtabs([tabsize])\n\n   Return a copy of the string where all tab characters are replaced\n   by one or more spaces, depending on the current column and the\n   given tab size.  The column number is reset to zero after each\n   newline occurring in the string. If *tabsize* is not given, a tab\n   size of ``8`` characters is assumed.  This doesn\'t understand other\n   non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n   Return the lowest index in the string where substring *sub* is\n   found, such that *sub* is contained in the slice ``s[start:end]``.\n   Optional arguments *start* and *end* are interpreted as in slice\n   notation.  Return ``-1`` if *sub* is not found.\n\nstr.format(*args, **kwargs)\n\n   Perform a string formatting operation.  The string on which this\n   method is called can contain literal text or replacement fields\n   delimited by braces ``{}``.  Each replacement field contains either\n   the numeric index of a positional argument, or the name of a\n   keyword argument.  Returns a copy of the string where each\n   replacement field is replaced with the string value of the\n   corresponding argument.\n\n   >>> "The sum of 1 + 2 is {0}".format(1+2)\n   \'The sum of 1 + 2 is 3\'\n\n   See *Format String Syntax* for a description of the various\n   formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n   Similar to ``str.format(**mapping)``, except that ``mapping`` is\n   used directly and not copied to a ``dict`` .  This is useful if for\n   example ``mapping`` is a dict subclass:\n\n   >>> class Default(dict):\n   ...     def __missing__(self, key):\n   ...         return key\n   ...\n   >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n   \'Guido was born in country\'\n\n   New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n   Like ``find()``, but raise ``ValueError`` when the substring is not\n   found.\n\nstr.isalnum()\n\n   Return true if all characters in the string are alphanumeric and\n   there is at least one character, false otherwise.\n\nstr.isalpha()\n\n   Return true if all characters in the string are alphabetic and\n   there is at least one character, false otherwise.\n\nstr.isdecimal()\n\n   Return true if all characters in the string are decimal characters\n   and there is at least one character, false otherwise. Decimal\n   characters include digit characters, and all characters that that\n   can be used to form decimal-radix numbers, e.g. U+0660, ARABIC-\n   INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n   Return true if all characters in the string are digits and there is\n   at least one character, false otherwise.\n\nstr.isidentifier()\n\n   Return true if the string is a valid identifier according to the\n   language definition, section *Identifiers and keywords*.\n\nstr.islower()\n\n   Return true if all cased characters in the string are lowercase and\n   there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n   Return true if all characters in the string are numeric characters,\n   and there is at least one character, false otherwise. Numeric\n   characters include digit characters, and all characters that have\n   the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n   ONE FIFTH.\n\nstr.isprintable()\n\n   Return true if all characters in the string are printable or the\n   string is empty, false otherwise.  Nonprintable characters are\n   those characters defined in the Unicode character database as\n   "Other" or "Separator", excepting the ASCII space (0x20) which is\n   considered printable.  (Note that printable characters in this\n   context are those which should not be escaped when ``repr()`` is\n   invoked on a string.  It has no bearing on the handling of strings\n   written to ``sys.stdout`` or ``sys.stderr``.)\n\nstr.isspace()\n\n   Return true if there are only whitespace characters in the string\n   and there is at least one character, false otherwise.\n\nstr.istitle()\n\n   Return true if the string is a titlecased string and there is at\n   least one character, for example uppercase characters may only\n   follow uncased characters and lowercase characters only cased ones.\n   Return false otherwise.\n\nstr.isupper()\n\n   Return true if all cased characters in the string are uppercase and\n   there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n   Return a string which is the concatenation of the strings in the\n   *iterable* *iterable*.  A ``TypeError`` will be raised if there are\n   any non-string values in *seq*, including ``bytes`` objects.  The\n   separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n   Return the string left justified in a string of length *width*.\n   Padding is done using the specified *fillchar* (default is a\n   space).  The original string is returned if *width* is less than\n   ``len(s)``.\n\nstr.lower()\n\n   Return a copy of the string converted to lowercase.\n\nstr.lstrip([chars])\n\n   Return a copy of the string with leading characters removed.  The\n   *chars* argument is a string specifying the set of characters to be\n   removed.  If omitted or ``None``, the *chars* argument defaults to\n   removing whitespace.  The *chars* argument is not a prefix; rather,\n   all combinations of its values are stripped:\n\n   >>> \'   spacious   \'.lstrip()\n   \'spacious   \'\n   >>> \'www.example.com\'.lstrip(\'cmowz.\')\n   \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n   This static method returns a translation table usable for\n   ``str.translate()``.\n\n   If there is only one argument, it must be a dictionary mapping\n   Unicode ordinals (integers) or characters (strings of length 1) to\n   Unicode ordinals, strings (of arbitrary lengths) or None.\n   Character keys will then be converted to ordinals.\n\n   If there are two arguments, they must be strings of equal length,\n   and in the resulting dictionary, each character in x will be mapped\n   to the character at the same position in y.  If there is a third\n   argument, it must be a string, whose characters will be mapped to\n   None in the result.\n\nstr.partition(sep)\n\n   Split the string at the first occurrence of *sep*, and return a\n   3-tuple containing the part before the separator, the separator\n   itself, and the part after the separator.  If the separator is not\n   found, return a 3-tuple containing the string itself, followed by\n   two empty strings.\n\nstr.replace(old, new[, count])\n\n   Return a copy of the string with all occurrences of substring *old*\n   replaced by *new*.  If the optional argument *count* is given, only\n   the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n   Return the highest index in the string where substring *sub* is\n   found, such that *sub* is contained within ``s[start:end]``.\n   Optional arguments *start* and *end* are interpreted as in slice\n   notation.  Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n   Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n   is not found.\n\nstr.rjust(width[, fillchar])\n\n   Return the string right justified in a string of length *width*.\n   Padding is done using the specified *fillchar* (default is a\n   space). The original string is returned if *width* is less than\n   ``len(s)``.\n\nstr.rpartition(sep)\n\n   Split the string at the last occurrence of *sep*, and return a\n   3-tuple containing the part before the separator, the separator\n   itself, and the part after the separator.  If the separator is not\n   found, return a 3-tuple containing two empty strings, followed by\n   the string itself.\n\nstr.rsplit([sep[, maxsplit]])\n\n   Return a list of the words in the string, using *sep* as the\n   delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n   are done, the *rightmost* ones.  If *sep* is not specified or\n   ``None``, any whitespace string is a separator.  Except for\n   splitting from the right, ``rsplit()`` behaves like ``split()``\n   which is described in detail below.\n\nstr.rstrip([chars])\n\n   Return a copy of the string with trailing characters removed.  The\n   *chars* argument is a string specifying the set of characters to be\n   removed.  If omitted or ``None``, the *chars* argument defaults to\n   removing whitespace.  The *chars* argument is not a suffix; rather,\n   all combinations of its values are stripped:\n\n   >>> \'   spacious   \'.rstrip()\n   \'   spacious\'\n   >>> \'mississippi\'.rstrip(\'ipz\')\n   \'mississ\'\n\nstr.split([sep[, maxsplit]])\n\n   Return a list of the words in the string, using *sep* as the\n   delimiter string.  If *maxsplit* is given, at most *maxsplit*\n   splits are done (thus, the list will have at most ``maxsplit+1``\n   elements).  If *maxsplit* is not specified, then there is no limit\n   on the number of splits (all possible splits are made).\n\n   If *sep* is given, consecutive delimiters are not grouped together\n   and are deemed to delimit empty strings (for example,\n   ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``).  The *sep*\n   argument may consist of multiple characters (for example,\n   ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n   an empty string with a specified separator returns ``[\'\']``.\n\n   If *sep* is not specified or is ``None``, a different splitting\n   algorithm is applied: runs of consecutive whitespace are regarded\n   as a single separator, and the result will contain no empty strings\n   at the start or end if the string has leading or trailing\n   whitespace.  Consequently, splitting an empty string or a string\n   consisting of just whitespace with a ``None`` separator returns\n   ``[]``.\n\n   For example, ``\' 1  2   3  \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n   and ``\'  1  2   3  \'.split(None, 1)`` returns ``[\'1\', \'2   3  \']``.\n\nstr.splitlines([keepends])\n\n   Return a list of the lines in the string, breaking at line\n   boundaries.  Line breaks are not included in the resulting list\n   unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n   Return ``True`` if string starts with the *prefix*, otherwise\n   return ``False``. *prefix* can also be a tuple of prefixes to look\n   for.  With optional *start*, test string beginning at that\n   position.  With optional *end*, stop comparing string at that\n   position.\n\nstr.strip([chars])\n\n   Return a copy of the string with the leading and trailing\n   characters removed. The *chars* argument is a string specifying the\n   set of characters to be removed. If omitted or ``None``, the\n   *chars* argument defaults to removing whitespace. The *chars*\n   argument is not a prefix or suffix; rather, all combinations of its\n   values are stripped:\n\n   >>> \'   spacious   \'.strip()\n   \'spacious\'\n   >>> \'www.example.com\'.strip(\'cmowz.\')\n   \'example\'\n\nstr.swapcase()\n\n   Return a copy of the string with uppercase characters converted to\n   lowercase and vice versa.\n\nstr.title()\n\n   Return a titlecased version of the string where words start with an\n   uppercase character and the remaining characters are lowercase.\n\n   The algorithm uses a simple language-independent definition of a\n   word as groups of consecutive letters.  The definition works in\n   many contexts but it means that apostrophes in contractions and\n   possessives form word boundaries, which may not be the desired\n   result:\n\n      >>> "they\'re bill\'s friends from the UK".title()\n      "They\'Re Bill\'S Friends From The Uk"\n\n   A workaround for apostrophes can be constructed using regular\n   expressions:\n\n      >>> import re\n      >>> def titlecase(s):\n              return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n                            lambda mo: mo.group(0)[0].upper() +\n                                       mo.group(0)[1:].lower(),\n                            s)\n\n      >>> titlecase("they\'re bill\'s friends.")\n      "They\'re Bill\'s Friends."\n\nstr.translate(map)\n\n   Return a copy of the *s* where all characters have been mapped\n   through the *map* which must be a dictionary of Unicode ordinals\n   (integers) to Unicode ordinals, strings or ``None``.  Unmapped\n   characters are left untouched. Characters mapped to ``None`` are\n   deleted.\n\n   You can use ``str.maketrans()`` to create a translation map from\n   character-to-character mappings in different formats.\n\n   Note: An even more flexible approach is to create a custom character\n     mapping codec using the ``codecs`` module (see\n     ``encodings.cp1251`` for an example).\n\nstr.upper()\n\n   Return a copy of the string converted to uppercase.\n\nstr.zfill(width)\n\n   Return the numeric string left filled with zeros in a string of\n   length *width*.  A sign prefix is handled correctly.  The original\n   string is returned if *width* is less than ``len(s)``.\n\n\nOld String Formatting Operations\n================================\n\nNote: The formatting operations described here are obsolete and may go\n  away in future versions of Python.  Use the new *String Formatting*\n  in new code.\n\nString objects have one unique built-in operation: the ``%`` operator\n(modulo). This is also known as the string *formatting* or\n*interpolation* operator. Given ``format % values`` (where *format* is\na string), ``%`` conversion specifications in *format* are replaced\nwith zero or more elements of *values*. The effect is similar to the\nusing ``sprintf()`` in the C language.\n\nIf *format* requires a single argument, *values* may be a single non-\ntuple object. [4]  Otherwise, *values* must be a tuple with exactly\nthe number of items specified by the format string, or a single\nmapping object (for example, a dictionary).\n\nA conversion specifier contains two or more characters and has the\nfollowing components, which must occur in this order:\n\n1. The ``\'%\'`` character, which marks the start of the specifier.\n\n2. Mapping key (optional), consisting of a parenthesised sequence of\n   characters (for example, ``(somename)``).\n\n3. Conversion flags (optional), which affect the result of some\n   conversion types.\n\n4. Minimum field width (optional).  If specified as an ``\'*\'``\n   (asterisk), the actual width is read from the next element of the\n   tuple in *values*, and the object to convert comes after the\n   minimum field width and optional precision.\n\n5. Precision (optional), given as a ``\'.\'`` (dot) followed by the\n   precision.  If specified as ``\'*\'`` (an asterisk), the actual width\n   is read from the next element of the tuple in *values*, and the\n   value to convert comes after the precision.\n\n6. Length modifier (optional).\n\n7. Conversion type.\n\nWhen the right argument is a dictionary (or other mapping type), then\nthe formats in the string *must* include a parenthesised mapping key\ninto that dictionary inserted immediately after the ``\'%\'`` character.\nThe mapping key selects the value to be formatted from the mapping.\nFor example:\n\n>>> print(\'%(language)s has %(number)03d quote types.\' %\n...       {\'language\': "Python", "number": 2})\nPython has 002 quote types.\n\nIn this case no ``*`` specifiers may occur in a format (since they\nrequire a sequential parameter list).\n\nThe conversion flag characters are:\n\n+-----------+-----------------------------------------------------------------------+\n| Flag      | Meaning                                                               |\n+===========+=======================================================================+\n| ``\'#\'``   | The value conversion will use the "alternate form" (where defined     |\n|           | below).                                                               |\n+-----------+-----------------------------------------------------------------------+\n| ``\'0\'``   | The conversion will be zero padded for numeric values.                |\n+-----------+-----------------------------------------------------------------------+\n| ``\'-\'``   | The converted value is left adjusted (overrides the ``\'0\'``           |\n|           | conversion if both are given).                                        |\n+-----------+-----------------------------------------------------------------------+\n| ``\' \'``   | (a space) A blank should be left before a positive number (or empty   |\n|           | string) produced by a signed conversion.                              |\n+-----------+-----------------------------------------------------------------------+\n| ``\'+\'``   | A sign character (``\'+\'`` or ``\'-\'``) will precede the conversion     |\n|           | (overrides a "space" flag).                                           |\n+-----------+-----------------------------------------------------------------------+\n\nA length modifier (``h``, ``l``, or ``L``) may be present, but is\nignored as it is not necessary for Python -- so e.g. ``%ld`` is\nidentical to ``%d``.\n\nThe conversion types are:\n\n+--------------+-------------------------------------------------------+---------+\n| Conversion   | Meaning                                               | Notes   |\n+==============+=======================================================+=========+\n| ``\'d\'``      | Signed integer decimal.                               |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'i\'``      | Signed integer decimal.                               |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'o\'``      | Signed octal value.                                   | (1)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'u\'``      | Obsolete type -- it is identical to ``\'d\'``.          | (7)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'x\'``      | Signed hexadecimal (lowercase).                       | (2)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'X\'``      | Signed hexadecimal (uppercase).                       | (2)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'e\'``      | Floating point exponential format (lowercase).        | (3)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'E\'``      | Floating point exponential format (uppercase).        | (3)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'f\'``      | Floating point decimal format.                        | (3)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'F\'``      | Floating point decimal format.                        | (3)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'g\'``      | Floating point format. Uses lowercase exponential     | (4)     |\n|              | format if exponent is less than -4 or not less than   |         |\n|              | precision, decimal format otherwise.                  |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'G\'``      | Floating point format. Uses uppercase exponential     | (4)     |\n|              | format if exponent is less than -4 or not less than   |         |\n|              | precision, decimal format otherwise.                  |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'c\'``      | Single character (accepts integer or single character |         |\n|              | string).                                              |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'r\'``      | String (converts any Python object using ``repr()``). | (5)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'s\'``      | String (converts any Python object using ``str()``).  |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'%\'``      | No argument is converted, results in a ``\'%\'``        |         |\n|              | character in the result.                              |         |\n+--------------+-------------------------------------------------------+---------+\n\nNotes:\n\n1. The alternate form causes a leading zero (``\'0\'``) to be inserted\n   between left-hand padding and the formatting of the number if the\n   leading character of the result is not already a zero.\n\n2. The alternate form causes a leading ``\'0x\'`` or ``\'0X\'`` (depending\n   on whether the ``\'x\'`` or ``\'X\'`` format was used) to be inserted\n   between left-hand padding and the formatting of the number if the\n   leading character of the result is not already a zero.\n\n3. The alternate form causes the result to always contain a decimal\n   point, even if no digits follow it.\n\n   The precision determines the number of digits after the decimal\n   point and defaults to 6.\n\n4. The alternate form causes the result to always contain a decimal\n   point, and trailing zeroes are not removed as they would otherwise\n   be.\n\n   The precision determines the number of significant digits before\n   and after the decimal point and defaults to 6.\n\n5. The precision determines the maximal number of characters used.\n\n1. See **PEP 237**.\n\nSince Python strings have an explicit length, ``%s`` conversions do\nnot assume that ``\'\\0\'`` is the end of the string.\n\nChanged in version 3.1: ``%f`` conversions for numbers whose absolute\nvalue is over 1e50 are no longer replaced by ``%g`` conversions.\n\nAdditional string operations are defined in standard modules\n``string`` and ``re``.\n\n\nRange Type\n==========\n\nThe ``range`` type is an immutable sequence which is commonly used for\nlooping.  The advantage of the ``range`` type is that an ``range``\nobject will always take the same amount of memory, no matter the size\nof the range it represents.  There are no consistent performance\nadvantages.\n\nRange objects have relatively little behavior: they support indexing,\niteration, the ``len()`` function, and the following methods.\n\nrange.count(x)\n\n   Return the number of *i*\'s for which ``s[i] == x``.  Normally the\n   result will be 0 or 1, but it could be greater if *x* defines an\n   unusual equality function.\n\n      New in version 3.2.\n\nrange.index(x)\n\n   Return the smallest *i* such that ``s[i] == x``.  Raises\n   ``ValueError`` when *x* is not in the range.\n\n      New in version 3.2.\n\n\nMutable Sequence Types\n======================\n\nList and bytearray objects support additional operations that allow\nin-place modification of the object.  Other mutable sequence types\n(when added to the language) should also support these operations.\nStrings and tuples are immutable sequence types: such objects cannot\nbe modified once created. The following operations are defined on\nmutable sequence types (where *x* is an arbitrary object).\n\nNote that while lists allow their items to be of any type, bytearray\nobject "items" are all integers in the range 0 <= x < 256.\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation                      | Result                           | Notes                 |\n+================================+==================================+=======================+\n| ``s[i] = x``                   | item *i* of *s* is replaced by   |                       |\n|                                | *x*                              |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t``                 | slice of *s* from *i* to *j* is  |                       |\n|                                | replaced by the contents of the  |                       |\n|                                | iterable *t*                     |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]``                 | same as ``s[i:j] = []``          |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t``               | the elements of ``s[i:j:k]`` are | (1)                   |\n|                                | replaced by those of *t*         |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]``               | removes the elements of          |                       |\n|                                | ``s[i:j:k]`` from the list       |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)``                | same as ``s[len(s):len(s)] =     |                       |\n|                                | [x]``                            |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)``                | same as ``s[len(s):len(s)] = x`` | (2)                   |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)``                 | return number of *i*\'s for which |                       |\n|                                | ``s[i] == x``                    |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])``       | return smallest *k* such that    | (3)                   |\n|                                | ``s[k] == x`` and ``i <= k < j`` |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)``             | same as ``s[i:i] = [x]``         | (4)                   |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])``                 | same as ``x = s[i]; del s[i];    | (5)                   |\n|                                | return x``                       |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)``                | same as ``del s[s.index(x)]``    | (3)                   |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()``                | reverses the items of *s* in     | (6)                   |\n|                                | place                            |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([key[, reverse]])``   | sort the items of *s* in place   | (6), (7), (8)         |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. *x* can be any iterable object.\n\n3. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n   index is passed as the second or third parameter to the ``index()``\n   method, the sequence length is added, as for slice indices.  If it\n   is still negative, it is truncated to zero, as for slice indices.\n\n4. When a negative index is passed as the first parameter to the\n   ``insert()`` method, the sequence length is added, as for slice\n   indices.  If it is still negative, it is truncated to zero, as for\n   slice indices.\n\n5. The optional argument *i* defaults to ``-1``, so that by default\n   the last item is removed and returned.\n\n6. The ``sort()`` and ``reverse()`` methods modify the sequence in\n   place for economy of space when sorting or reversing a large\n   sequence.  To remind you that they operate by side effect, they\n   don\'t return the sorted or reversed sequence.\n\n7. The ``sort()`` method takes optional arguments for controlling the\n   comparisons.  Each must be specified as a keyword argument.\n\n   *key* specifies a function of one argument that is used to extract\n   a comparison key from each list element: ``key=str.lower``.  The\n   default value is ``None``. Use ``functools.cmp_to_key()`` to\n   convert an old-style *cmp* function to a *key* function.\n\n   *reverse* is a boolean value.  If set to ``True``, then the list\n   elements are sorted as if each comparison were reversed.\n\n   The ``sort()`` method is guaranteed to be stable.  A sort is stable\n   if it guarantees not to change the relative order of elements that\n   compare equal --- this is helpful for sorting in multiple passes\n   (for example, sort by department, then by salary grade).\n\n   **CPython implementation detail:** While a list is being sorted,\n   the effect of attempting to mutate, or even inspect, the list is\n   undefined.  The C implementation of Python makes the list appear\n   empty for the duration, and raises ``ValueError`` if it can detect\n   that the list has been mutated during a sort.\n\n8. ``sort()`` is not supported by ``bytearray`` objects.\n\n\nBytes and Byte Array Methods\n============================\n\nBytes and bytearray objects, being "strings of bytes", have all\nmethods found on strings, with the exception of ``encode()``,\n``format()`` and ``isidentifier()``, which do not make sense with\nthese types.  For converting the objects to strings, they have a\n``decode()`` method.\n\nWherever one of these methods needs to interpret the bytes as\ncharacters (e.g. the ``is...()`` methods), the ASCII character set is\nassumed.\n\nNote: The methods on bytes and bytearray objects don\'t accept strings as\n  their arguments, just as the methods on strings don\'t accept bytes\n  as their arguments.  For example, you have to write\n\n     a = "abc"\n     b = a.replace("a", "f")\n\n  and\n\n     a = b"abc"\n     b = a.replace(b"a", b"f")\n\nbytes.decode(encoding="utf-8", errors="strict")\nbytearray.decode(encoding="utf-8", errors="strict")\n\n   Return a string decoded from the given bytes.  Default encoding is\n   ``\'utf-8\'``. *errors* may be given to set a different error\n   handling scheme.  The default for *errors* is ``\'strict\'``, meaning\n   that encoding errors raise a ``UnicodeError``.  Other possible\n   values are ``\'ignore\'``, ``\'replace\'`` and any other name\n   registered via ``codecs.register_error()``, see section *Codec Base\n   Classes*. For a list of possible encodings, see section *Standard\n   Encodings*.\n\n   Changed in version 3.1: Added support for keyword arguments.\n\nThe bytes and bytearray types have an additional class method:\n\nclassmethod bytes.fromhex(string)\nclassmethod bytearray.fromhex(string)\n\n   This ``bytes`` class method returns a bytes or bytearray object,\n   decoding the given string object.  The string must contain two\n   hexadecimal digits per byte, spaces are ignored.\n\n   >>> bytes.fromhex(\'f0 f1f2  \')\n   b\'\\xf0\\xf1\\xf2\'\n\nThe maketrans and translate methods differ in semantics from the\nversions available on strings:\n\nbytes.translate(table[, delete])\nbytearray.translate(table[, delete])\n\n   Return a copy of the bytes or bytearray object where all bytes\n   occurring in the optional argument *delete* are removed, and the\n   remaining bytes have been mapped through the given translation\n   table, which must be a bytes object of length 256.\n\n   You can use the ``bytes.maketrans()`` method to create a\n   translation table.\n\n   Set the *table* argument to ``None`` for translations that only\n   delete characters:\n\n      >>> b\'read this short text\'.translate(None, b\'aeiou\')\n      b\'rd ths shrt txt\'\n\nstatic bytes.maketrans(from, to)\nstatic bytearray.maketrans(from, to)\n\n   This static method returns a translation table usable for\n   ``bytes.translate()`` that will map each character in *from* into\n   the character at the same position in *to*; *from* and *to* must be\n   bytes objects and have the same length.\n\n   New in version 3.1.\n',
+ 'typesseq': '\nSequence Types --- ``str``, ``bytes``, ``bytearray``, ``list``, ``tuple``, ``range``\n************************************************************************************\n\nThere are six sequence types: strings, byte sequences (``bytes``\nobjects), byte arrays (``bytearray`` objects), lists, tuples, and\nrange objects.  For other containers see the built in ``dict`` and\n``set`` classes, and the ``collections`` module.\n\nStrings contain Unicode characters.  Their literals are written in\nsingle or double quotes: ``\'xyzzy\'``, ``"frobozz"``.  See *String and\nBytes literals* for more about string literals.  In addition to the\nfunctionality described here, there are also string-specific methods\ndescribed in the *String Methods* section.\n\nBytes and bytearray objects contain single bytes -- the former is\nimmutable while the latter is a mutable sequence.  Bytes objects can\nbe constructed the constructor, ``bytes()``, and from literals; use a\n``b`` prefix with normal string syntax: ``b\'xyzzy\'``.  To construct\nbyte arrays, use the ``bytearray()`` function.\n\nWhile string objects are sequences of characters (represented by\nstrings of length 1), bytes and bytearray objects are sequences of\n*integers* (between 0 and 255), representing the ASCII value of single\nbytes.  That means that for a bytes or bytearray object *b*, ``b[0]``\nwill be an integer, while ``b[0:1]`` will be a bytes or bytearray\nobject of length 1.  The representation of bytes objects uses the\nliteral format (``b\'...\'``) since it is generally more useful than\ne.g. ``bytes([50, 19, 100])``.  You can always convert a bytes object\ninto a list of integers using ``list(b)``.\n\nAlso, while in previous Python versions, byte strings and Unicode\nstrings could be exchanged for each other rather freely (barring\nencoding issues), strings and bytes are now completely separate\nconcepts.  There\'s no implicit en-/decoding if you pass an object of\nthe wrong type.  A string always compares unequal to a bytes or\nbytearray object.\n\nLists are constructed with square brackets, separating items with\ncommas: ``[a, b, c]``.  Tuples are constructed by the comma operator\n(not within square brackets), with or without enclosing parentheses,\nbut an empty tuple must have the enclosing parentheses, such as ``a,\nb, c`` or ``()``.  A single item tuple must have a trailing comma,\nsuch as ``(d,)``.\n\nObjects of type range are created using the ``range()`` function.\nThey don\'t support concatenation or repetition, and using ``min()`` or\n``max()`` on them is inefficient.\n\nMost sequence types support the following operations.  The ``in`` and\n``not in`` operations have the same priorities as the comparison\noperations.  The ``+`` and ``*`` operations have the same priority as\nthe corresponding numeric operations. [3] Additional methods are\nprovided for *Mutable Sequence Types*.\n\nThis table lists the sequence operations sorted in ascending priority\n(operations in the same box have the same priority).  In the table,\n*s* and *t* are sequences of the same type; *n*, *i*, *j* and *k* are\nintegers.\n\n+--------------------+----------------------------------+------------+\n| Operation          | Result                           | Notes      |\n+====================+==================================+============+\n| ``x in s``         | ``True`` if an item of *s* is    | (1)        |\n|                    | equal to *x*, else ``False``     |            |\n+--------------------+----------------------------------+------------+\n| ``x not in s``     | ``False`` if an item of *s* is   | (1)        |\n|                    | equal to *x*, else ``True``      |            |\n+--------------------+----------------------------------+------------+\n| ``s + t``          | the concatenation of *s* and *t* | (6)        |\n+--------------------+----------------------------------+------------+\n| ``s * n, n * s``   | *n* shallow copies of *s*        | (2)        |\n|                    | concatenated                     |            |\n+--------------------+----------------------------------+------------+\n| ``s[i]``           | *i*\'th item of *s*, origin 0     | (3)        |\n+--------------------+----------------------------------+------------+\n| ``s[i:j]``         | slice of *s* from *i* to *j*     | (3)(4)     |\n+--------------------+----------------------------------+------------+\n| ``s[i:j:k]``       | slice of *s* from *i* to *j*     | (3)(5)     |\n|                    | with step *k*                    |            |\n+--------------------+----------------------------------+------------+\n| ``len(s)``         | length of *s*                    |            |\n+--------------------+----------------------------------+------------+\n| ``min(s)``         | smallest item of *s*             |            |\n+--------------------+----------------------------------+------------+\n| ``max(s)``         | largest item of *s*              |            |\n+--------------------+----------------------------------+------------+\n| ``s.index(i)``     | index of the first occurence of  |            |\n|                    | *i* in *s*                       |            |\n+--------------------+----------------------------------+------------+\n| ``s.count(i)``     | total number of occurences of    |            |\n|                    | *i* in *s*                       |            |\n+--------------------+----------------------------------+------------+\n\nSequence types also support comparisons.  In particular, tuples and\nlists are compared lexicographically by comparing corresponding\nelements.  This means that to compare equal, every element must\ncompare equal and the two sequences must be of the same type and have\nthe same length.  (For full details see *Comparisons* in the language\nreference.)\n\nNotes:\n\n1. When *s* is a string object, the ``in`` and ``not in`` operations\n   act like a substring test.\n\n2. Values of *n* less than ``0`` are treated as ``0`` (which yields an\n   empty sequence of the same type as *s*).  Note also that the copies\n   are shallow; nested structures are not copied.  This often haunts\n   new Python programmers; consider:\n\n   >>> lists = [[]] * 3\n   >>> lists\n   [[], [], []]\n   >>> lists[0].append(3)\n   >>> lists\n   [[3], [3], [3]]\n\n   What has happened is that ``[[]]`` is a one-element list containing\n   an empty list, so all three elements of ``[[]] * 3`` are (pointers\n   to) this single empty list.  Modifying any of the elements of\n   ``lists`` modifies this single list. You can create a list of\n   different lists this way:\n\n   >>> lists = [[] for i in range(3)]\n   >>> lists[0].append(3)\n   >>> lists[1].append(5)\n   >>> lists[2].append(7)\n   >>> lists\n   [[3], [5], [7]]\n\n3. If *i* or *j* is negative, the index is relative to the end of the\n   string: ``len(s) + i`` or ``len(s) + j`` is substituted.  But note\n   that ``-0`` is still ``0``.\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n   items with index *k* such that ``i <= k < j``.  If *i* or *j* is\n   greater than ``len(s)``, use ``len(s)``.  If *i* is omitted or\n   ``None``, use ``0``.  If *j* is omitted or ``None``, use\n   ``len(s)``.  If *i* is greater than or equal to *j*, the slice is\n   empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n   sequence of items with index  ``x = i + n*k`` such that ``0 <= n <\n   (j-i)/k``.  In other words, the indices are ``i``, ``i+k``,\n   ``i+2*k``, ``i+3*k`` and so on, stopping when *j* is reached (but\n   never including *j*).  If *i* or *j* is greater than ``len(s)``,\n   use ``len(s)``.  If *i* or *j* are omitted or ``None``, they become\n   "end" values (which end depends on the sign of *k*).  Note, *k*\n   cannot be zero. If *k* is ``None``, it is treated like ``1``.\n\n6. **CPython implementation detail:** If *s* and *t* are both strings,\n   some Python implementations such as CPython can usually perform an\n   in-place optimization for assignments of the form ``s = s + t`` or\n   ``s += t``.  When applicable, this optimization makes quadratic\n   run-time much less likely.  This optimization is both version and\n   implementation dependent.  For performance sensitive code, it is\n   preferable to use the ``str.join()`` method which assures\n   consistent linear concatenation performance across versions and\n   implementations.\n\n\nString Methods\n==============\n\nString objects support the methods listed below.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, bytes, bytearray, list,\ntuple, range* section. To output formatted strings, see the *String\nFormatting* section. Also, see the ``re`` module for string functions\nbased on regular expressions.\n\nstr.capitalize()\n\n   Return a copy of the string with its first character capitalized\n   and the rest lowercased.\n\nstr.center(width[, fillchar])\n\n   Return centered in a string of length *width*. Padding is done\n   using the specified *fillchar* (default is a space).\n\nstr.count(sub[, start[, end]])\n\n   Return the number of non-overlapping occurrences of substring *sub*\n   in the range [*start*, *end*].  Optional arguments *start* and\n   *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n   Return an encoded version of the string as a bytes object. Default\n   encoding is ``\'utf-8\'``. *errors* may be given to set a different\n   error handling scheme. The default for *errors* is ``\'strict\'``,\n   meaning that encoding errors raise a ``UnicodeError``. Other\n   possible values are ``\'ignore\'``, ``\'replace\'``,\n   ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and any other name\n   registered via ``codecs.register_error()``, see section *Codec Base\n   Classes*. For a list of possible encodings, see section *Standard\n   Encodings*.\n\n   Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n   Return ``True`` if the string ends with the specified *suffix*,\n   otherwise return ``False``.  *suffix* can also be a tuple of\n   suffixes to look for.  With optional *start*, test beginning at\n   that position.  With optional *end*, stop comparing at that\n   position.\n\nstr.expandtabs([tabsize])\n\n   Return a copy of the string where all tab characters are replaced\n   by one or more spaces, depending on the current column and the\n   given tab size.  The column number is reset to zero after each\n   newline occurring in the string. If *tabsize* is not given, a tab\n   size of ``8`` characters is assumed.  This doesn\'t understand other\n   non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n   Return the lowest index in the string where substring *sub* is\n   found, such that *sub* is contained in the slice ``s[start:end]``.\n   Optional arguments *start* and *end* are interpreted as in slice\n   notation.  Return ``-1`` if *sub* is not found.\n\nstr.format(*args, **kwargs)\n\n   Perform a string formatting operation.  The string on which this\n   method is called can contain literal text or replacement fields\n   delimited by braces ``{}``.  Each replacement field contains either\n   the numeric index of a positional argument, or the name of a\n   keyword argument.  Returns a copy of the string where each\n   replacement field is replaced with the string value of the\n   corresponding argument.\n\n   >>> "The sum of 1 + 2 is {0}".format(1+2)\n   \'The sum of 1 + 2 is 3\'\n\n   See *Format String Syntax* for a description of the various\n   formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n   Similar to ``str.format(**mapping)``, except that ``mapping`` is\n   used directly and not copied to a ``dict`` .  This is useful if for\n   example ``mapping`` is a dict subclass:\n\n   >>> class Default(dict):\n   ...     def __missing__(self, key):\n   ...         return key\n   ...\n   >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n   \'Guido was born in country\'\n\n   New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n   Like ``find()``, but raise ``ValueError`` when the substring is not\n   found.\n\nstr.isalnum()\n\n   Return true if all characters in the string are alphanumeric and\n   there is at least one character, false otherwise.\n\nstr.isalpha()\n\n   Return true if all characters in the string are alphabetic and\n   there is at least one character, false otherwise.\n\nstr.isdecimal()\n\n   Return true if all characters in the string are decimal characters\n   and there is at least one character, false otherwise. Decimal\n   characters include digit characters, and all characters that that\n   can be used to form decimal-radix numbers, e.g. U+0660, ARABIC-\n   INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n   Return true if all characters in the string are digits and there is\n   at least one character, false otherwise.\n\nstr.isidentifier()\n\n   Return true if the string is a valid identifier according to the\n   language definition, section *Identifiers and keywords*.\n\nstr.islower()\n\n   Return true if all cased characters in the string are lowercase and\n   there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n   Return true if all characters in the string are numeric characters,\n   and there is at least one character, false otherwise. Numeric\n   characters include digit characters, and all characters that have\n   the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n   ONE FIFTH.\n\nstr.isprintable()\n\n   Return true if all characters in the string are printable or the\n   string is empty, false otherwise.  Nonprintable characters are\n   those characters defined in the Unicode character database as\n   "Other" or "Separator", excepting the ASCII space (0x20) which is\n   considered printable.  (Note that printable characters in this\n   context are those which should not be escaped when ``repr()`` is\n   invoked on a string.  It has no bearing on the handling of strings\n   written to ``sys.stdout`` or ``sys.stderr``.)\n\nstr.isspace()\n\n   Return true if there are only whitespace characters in the string\n   and there is at least one character, false otherwise.\n\nstr.istitle()\n\n   Return true if the string is a titlecased string and there is at\n   least one character, for example uppercase characters may only\n   follow uncased characters and lowercase characters only cased ones.\n   Return false otherwise.\n\nstr.isupper()\n\n   Return true if all cased characters in the string are uppercase and\n   there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n   Return a string which is the concatenation of the strings in the\n   *iterable* *iterable*.  A ``TypeError`` will be raised if there are\n   any non-string values in *seq*, including ``bytes`` objects.  The\n   separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n   Return the string left justified in a string of length *width*.\n   Padding is done using the specified *fillchar* (default is a\n   space).  The original string is returned if *width* is less than\n   ``len(s)``.\n\nstr.lower()\n\n   Return a copy of the string converted to lowercase.\n\nstr.lstrip([chars])\n\n   Return a copy of the string with leading characters removed.  The\n   *chars* argument is a string specifying the set of characters to be\n   removed.  If omitted or ``None``, the *chars* argument defaults to\n   removing whitespace.  The *chars* argument is not a prefix; rather,\n   all combinations of its values are stripped:\n\n   >>> \'   spacious   \'.lstrip()\n   \'spacious   \'\n   >>> \'www.example.com\'.lstrip(\'cmowz.\')\n   \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n   This static method returns a translation table usable for\n   ``str.translate()``.\n\n   If there is only one argument, it must be a dictionary mapping\n   Unicode ordinals (integers) or characters (strings of length 1) to\n   Unicode ordinals, strings (of arbitrary lengths) or None.\n   Character keys will then be converted to ordinals.\n\n   If there are two arguments, they must be strings of equal length,\n   and in the resulting dictionary, each character in x will be mapped\n   to the character at the same position in y.  If there is a third\n   argument, it must be a string, whose characters will be mapped to\n   None in the result.\n\nstr.partition(sep)\n\n   Split the string at the first occurrence of *sep*, and return a\n   3-tuple containing the part before the separator, the separator\n   itself, and the part after the separator.  If the separator is not\n   found, return a 3-tuple containing the string itself, followed by\n   two empty strings.\n\nstr.replace(old, new[, count])\n\n   Return a copy of the string with all occurrences of substring *old*\n   replaced by *new*.  If the optional argument *count* is given, only\n   the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n   Return the highest index in the string where substring *sub* is\n   found, such that *sub* is contained within ``s[start:end]``.\n   Optional arguments *start* and *end* are interpreted as in slice\n   notation.  Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n   Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n   is not found.\n\nstr.rjust(width[, fillchar])\n\n   Return the string right justified in a string of length *width*.\n   Padding is done using the specified *fillchar* (default is a\n   space). The original string is returned if *width* is less than\n   ``len(s)``.\n\nstr.rpartition(sep)\n\n   Split the string at the last occurrence of *sep*, and return a\n   3-tuple containing the part before the separator, the separator\n   itself, and the part after the separator.  If the separator is not\n   found, return a 3-tuple containing two empty strings, followed by\n   the string itself.\n\nstr.rsplit([sep[, maxsplit]])\n\n   Return a list of the words in the string, using *sep* as the\n   delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n   are done, the *rightmost* ones.  If *sep* is not specified or\n   ``None``, any whitespace string is a separator.  Except for\n   splitting from the right, ``rsplit()`` behaves like ``split()``\n   which is described in detail below.\n\nstr.rstrip([chars])\n\n   Return a copy of the string with trailing characters removed.  The\n   *chars* argument is a string specifying the set of characters to be\n   removed.  If omitted or ``None``, the *chars* argument defaults to\n   removing whitespace.  The *chars* argument is not a suffix; rather,\n   all combinations of its values are stripped:\n\n   >>> \'   spacious   \'.rstrip()\n   \'   spacious\'\n   >>> \'mississippi\'.rstrip(\'ipz\')\n   \'mississ\'\n\nstr.split([sep[, maxsplit]])\n\n   Return a list of the words in the string, using *sep* as the\n   delimiter string.  If *maxsplit* is given, at most *maxsplit*\n   splits are done (thus, the list will have at most ``maxsplit+1``\n   elements).  If *maxsplit* is not specified, then there is no limit\n   on the number of splits (all possible splits are made).\n\n   If *sep* is given, consecutive delimiters are not grouped together\n   and are deemed to delimit empty strings (for example,\n   ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``).  The *sep*\n   argument may consist of multiple characters (for example,\n   ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n   an empty string with a specified separator returns ``[\'\']``.\n\n   If *sep* is not specified or is ``None``, a different splitting\n   algorithm is applied: runs of consecutive whitespace are regarded\n   as a single separator, and the result will contain no empty strings\n   at the start or end if the string has leading or trailing\n   whitespace.  Consequently, splitting an empty string or a string\n   consisting of just whitespace with a ``None`` separator returns\n   ``[]``.\n\n   For example, ``\' 1  2   3  \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n   and ``\'  1  2   3  \'.split(None, 1)`` returns ``[\'1\', \'2   3  \']``.\n\nstr.splitlines([keepends])\n\n   Return a list of the lines in the string, breaking at line\n   boundaries.  Line breaks are not included in the resulting list\n   unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n   Return ``True`` if string starts with the *prefix*, otherwise\n   return ``False``. *prefix* can also be a tuple of prefixes to look\n   for.  With optional *start*, test string beginning at that\n   position.  With optional *end*, stop comparing string at that\n   position.\n\nstr.strip([chars])\n\n   Return a copy of the string with the leading and trailing\n   characters removed. The *chars* argument is a string specifying the\n   set of characters to be removed. If omitted or ``None``, the\n   *chars* argument defaults to removing whitespace. The *chars*\n   argument is not a prefix or suffix; rather, all combinations of its\n   values are stripped:\n\n   >>> \'   spacious   \'.strip()\n   \'spacious\'\n   >>> \'www.example.com\'.strip(\'cmowz.\')\n   \'example\'\n\nstr.swapcase()\n\n   Return a copy of the string with uppercase characters converted to\n   lowercase and vice versa.\n\nstr.title()\n\n   Return a titlecased version of the string where words start with an\n   uppercase character and the remaining characters are lowercase.\n\n   The algorithm uses a simple language-independent definition of a\n   word as groups of consecutive letters.  The definition works in\n   many contexts but it means that apostrophes in contractions and\n   possessives form word boundaries, which may not be the desired\n   result:\n\n      >>> "they\'re bill\'s friends from the UK".title()\n      "They\'Re Bill\'S Friends From The Uk"\n\n   A workaround for apostrophes can be constructed using regular\n   expressions:\n\n      >>> import re\n      >>> def titlecase(s):\n              return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n                            lambda mo: mo.group(0)[0].upper() +\n                                       mo.group(0)[1:].lower(),\n                            s)\n\n      >>> titlecase("they\'re bill\'s friends.")\n      "They\'re Bill\'s Friends."\n\nstr.translate(map)\n\n   Return a copy of the *s* where all characters have been mapped\n   through the *map* which must be a dictionary of Unicode ordinals\n   (integers) to Unicode ordinals, strings or ``None``.  Unmapped\n   characters are left untouched. Characters mapped to ``None`` are\n   deleted.\n\n   You can use ``str.maketrans()`` to create a translation map from\n   character-to-character mappings in different formats.\n\n   Note: An even more flexible approach is to create a custom character\n     mapping codec using the ``codecs`` module (see\n     ``encodings.cp1251`` for an example).\n\nstr.upper()\n\n   Return a copy of the string converted to uppercase.\n\nstr.zfill(width)\n\n   Return the numeric string left filled with zeros in a string of\n   length *width*.  A sign prefix is handled correctly.  The original\n   string is returned if *width* is less than ``len(s)``.\n\n\nOld String Formatting Operations\n================================\n\nNote: The formatting operations described here are obsolete and may go\n  away in future versions of Python.  Use the new *String Formatting*\n  in new code.\n\nString objects have one unique built-in operation: the ``%`` operator\n(modulo). This is also known as the string *formatting* or\n*interpolation* operator. Given ``format % values`` (where *format* is\na string), ``%`` conversion specifications in *format* are replaced\nwith zero or more elements of *values*. The effect is similar to the\nusing ``sprintf()`` in the C language.\n\nIf *format* requires a single argument, *values* may be a single non-\ntuple object. [4]  Otherwise, *values* must be a tuple with exactly\nthe number of items specified by the format string, or a single\nmapping object (for example, a dictionary).\n\nA conversion specifier contains two or more characters and has the\nfollowing components, which must occur in this order:\n\n1. The ``\'%\'`` character, which marks the start of the specifier.\n\n2. Mapping key (optional), consisting of a parenthesised sequence of\n   characters (for example, ``(somename)``).\n\n3. Conversion flags (optional), which affect the result of some\n   conversion types.\n\n4. Minimum field width (optional).  If specified as an ``\'*\'``\n   (asterisk), the actual width is read from the next element of the\n   tuple in *values*, and the object to convert comes after the\n   minimum field width and optional precision.\n\n5. Precision (optional), given as a ``\'.\'`` (dot) followed by the\n   precision.  If specified as ``\'*\'`` (an asterisk), the actual width\n   is read from the next element of the tuple in *values*, and the\n   value to convert comes after the precision.\n\n6. Length modifier (optional).\n\n7. Conversion type.\n\nWhen the right argument is a dictionary (or other mapping type), then\nthe formats in the string *must* include a parenthesised mapping key\ninto that dictionary inserted immediately after the ``\'%\'`` character.\nThe mapping key selects the value to be formatted from the mapping.\nFor example:\n\n>>> print(\'%(language)s has %(number)03d quote types.\' %\n...       {\'language\': "Python", "number": 2})\nPython has 002 quote types.\n\nIn this case no ``*`` specifiers may occur in a format (since they\nrequire a sequential parameter list).\n\nThe conversion flag characters are:\n\n+-----------+-----------------------------------------------------------------------+\n| Flag      | Meaning                                                               |\n+===========+=======================================================================+\n| ``\'#\'``   | The value conversion will use the "alternate form" (where defined     |\n|           | below).                                                               |\n+-----------+-----------------------------------------------------------------------+\n| ``\'0\'``   | The conversion will be zero padded for numeric values.                |\n+-----------+-----------------------------------------------------------------------+\n| ``\'-\'``   | The converted value is left adjusted (overrides the ``\'0\'``           |\n|           | conversion if both are given).                                        |\n+-----------+-----------------------------------------------------------------------+\n| ``\' \'``   | (a space) A blank should be left before a positive number (or empty   |\n|           | string) produced by a signed conversion.                              |\n+-----------+-----------------------------------------------------------------------+\n| ``\'+\'``   | A sign character (``\'+\'`` or ``\'-\'``) will precede the conversion     |\n|           | (overrides a "space" flag).                                           |\n+-----------+-----------------------------------------------------------------------+\n\nA length modifier (``h``, ``l``, or ``L``) may be present, but is\nignored as it is not necessary for Python -- so e.g. ``%ld`` is\nidentical to ``%d``.\n\nThe conversion types are:\n\n+--------------+-------------------------------------------------------+---------+\n| Conversion   | Meaning                                               | Notes   |\n+==============+=======================================================+=========+\n| ``\'d\'``      | Signed integer decimal.                               |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'i\'``      | Signed integer decimal.                               |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'o\'``      | Signed octal value.                                   | (1)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'u\'``      | Obsolete type -- it is identical to ``\'d\'``.          | (7)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'x\'``      | Signed hexadecimal (lowercase).                       | (2)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'X\'``      | Signed hexadecimal (uppercase).                       | (2)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'e\'``      | Floating point exponential format (lowercase).        | (3)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'E\'``      | Floating point exponential format (uppercase).        | (3)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'f\'``      | Floating point decimal format.                        | (3)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'F\'``      | Floating point decimal format.                        | (3)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'g\'``      | Floating point format. Uses lowercase exponential     | (4)     |\n|              | format if exponent is less than -4 or not less than   |         |\n|              | precision, decimal format otherwise.                  |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'G\'``      | Floating point format. Uses uppercase exponential     | (4)     |\n|              | format if exponent is less than -4 or not less than   |         |\n|              | precision, decimal format otherwise.                  |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'c\'``      | Single character (accepts integer or single character |         |\n|              | string).                                              |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'r\'``      | String (converts any Python object using ``repr()``). | (5)     |\n+--------------+-------------------------------------------------------+---------+\n| ``\'s\'``      | String (converts any Python object using ``str()``).  |         |\n+--------------+-------------------------------------------------------+---------+\n| ``\'%\'``      | No argument is converted, results in a ``\'%\'``        |         |\n|              | character in the result.                              |         |\n+--------------+-------------------------------------------------------+---------+\n\nNotes:\n\n1. The alternate form causes a leading zero (``\'0\'``) to be inserted\n   between left-hand padding and the formatting of the number if the\n   leading character of the result is not already a zero.\n\n2. The alternate form causes a leading ``\'0x\'`` or ``\'0X\'`` (depending\n   on whether the ``\'x\'`` or ``\'X\'`` format was used) to be inserted\n   between left-hand padding and the formatting of the number if the\n   leading character of the result is not already a zero.\n\n3. The alternate form causes the result to always contain a decimal\n   point, even if no digits follow it.\n\n   The precision determines the number of digits after the decimal\n   point and defaults to 6.\n\n4. The alternate form causes the result to always contain a decimal\n   point, and trailing zeroes are not removed as they would otherwise\n   be.\n\n   The precision determines the number of significant digits before\n   and after the decimal point and defaults to 6.\n\n5. The precision determines the maximal number of characters used.\n\n1. See **PEP 237**.\n\nSince Python strings have an explicit length, ``%s`` conversions do\nnot assume that ``\'\\0\'`` is the end of the string.\n\nChanged in version 3.1: ``%f`` conversions for numbers whose absolute\nvalue is over 1e50 are no longer replaced by ``%g`` conversions.\n\nAdditional string operations are defined in standard modules\n``string`` and ``re``.\n\n\nRange Type\n==========\n\nThe ``range`` type is an immutable sequence which is commonly used for\nlooping.  The advantage of the ``range`` type is that an ``range``\nobject will always take the same amount of memory, no matter the size\nof the range it represents.\n\nRange objects have relatively little behavior: they support indexing,\ncontains, iteration, the ``len()`` function, and the following\nmethods:\n\nrange.count(x)\n\n   Return the number of *i*\'s for which ``s[i] == x``.\n\n      New in version 3.2.\n\nrange.index(x)\n\n   Return the smallest *i* such that ``s[i] == x``.  Raises\n   ``ValueError`` when *x* is not in the range.\n\n      New in version 3.2.\n\n\nMutable Sequence Types\n======================\n\nList and bytearray objects support additional operations that allow\nin-place modification of the object.  Other mutable sequence types\n(when added to the language) should also support these operations.\nStrings and tuples are immutable sequence types: such objects cannot\nbe modified once created. The following operations are defined on\nmutable sequence types (where *x* is an arbitrary object).\n\nNote that while lists allow their items to be of any type, bytearray\nobject "items" are all integers in the range 0 <= x < 256.\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation                      | Result                           | Notes                 |\n+================================+==================================+=======================+\n| ``s[i] = x``                   | item *i* of *s* is replaced by   |                       |\n|                                | *x*                              |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t``                 | slice of *s* from *i* to *j* is  |                       |\n|                                | replaced by the contents of the  |                       |\n|                                | iterable *t*                     |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]``                 | same as ``s[i:j] = []``          |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t``               | the elements of ``s[i:j:k]`` are | (1)                   |\n|                                | replaced by those of *t*         |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]``               | removes the elements of          |                       |\n|                                | ``s[i:j:k]`` from the list       |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)``                | same as ``s[len(s):len(s)] =     |                       |\n|                                | [x]``                            |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)``                | same as ``s[len(s):len(s)] = x`` | (2)                   |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)``                 | return number of *i*\'s for which |                       |\n|                                | ``s[i] == x``                    |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])``       | return smallest *k* such that    | (3)                   |\n|                                | ``s[k] == x`` and ``i <= k < j`` |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)``             | same as ``s[i:i] = [x]``         | (4)                   |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])``                 | same as ``x = s[i]; del s[i];    | (5)                   |\n|                                | return x``                       |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)``                | same as ``del s[s.index(x)]``    | (3)                   |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()``                | reverses the items of *s* in     | (6)                   |\n|                                | place                            |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([key[, reverse]])``   | sort the items of *s* in place   | (6), (7), (8)         |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. *x* can be any iterable object.\n\n3. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n   index is passed as the second or third parameter to the ``index()``\n   method, the sequence length is added, as for slice indices.  If it\n   is still negative, it is truncated to zero, as for slice indices.\n\n4. When a negative index is passed as the first parameter to the\n   ``insert()`` method, the sequence length is added, as for slice\n   indices.  If it is still negative, it is truncated to zero, as for\n   slice indices.\n\n5. The optional argument *i* defaults to ``-1``, so that by default\n   the last item is removed and returned.\n\n6. The ``sort()`` and ``reverse()`` methods modify the sequence in\n   place for economy of space when sorting or reversing a large\n   sequence.  To remind you that they operate by side effect, they\n   don\'t return the sorted or reversed sequence.\n\n7. The ``sort()`` method takes optional arguments for controlling the\n   comparisons.  Each must be specified as a keyword argument.\n\n   *key* specifies a function of one argument that is used to extract\n   a comparison key from each list element: ``key=str.lower``.  The\n   default value is ``None``. Use ``functools.cmp_to_key()`` to\n   convert an old-style *cmp* function to a *key* function.\n\n   *reverse* is a boolean value.  If set to ``True``, then the list\n   elements are sorted as if each comparison were reversed.\n\n   The ``sort()`` method is guaranteed to be stable.  A sort is stable\n   if it guarantees not to change the relative order of elements that\n   compare equal --- this is helpful for sorting in multiple passes\n   (for example, sort by department, then by salary grade).\n\n   **CPython implementation detail:** While a list is being sorted,\n   the effect of attempting to mutate, or even inspect, the list is\n   undefined.  The C implementation of Python makes the list appear\n   empty for the duration, and raises ``ValueError`` if it can detect\n   that the list has been mutated during a sort.\n\n8. ``sort()`` is not supported by ``bytearray`` objects.\n\n\nBytes and Byte Array Methods\n============================\n\nBytes and bytearray objects, being "strings of bytes", have all\nmethods found on strings, with the exception of ``encode()``,\n``format()`` and ``isidentifier()``, which do not make sense with\nthese types.  For converting the objects to strings, they have a\n``decode()`` method.\n\nWherever one of these methods needs to interpret the bytes as\ncharacters (e.g. the ``is...()`` methods), the ASCII character set is\nassumed.\n\nNote: The methods on bytes and bytearray objects don\'t accept strings as\n  their arguments, just as the methods on strings don\'t accept bytes\n  as their arguments.  For example, you have to write\n\n     a = "abc"\n     b = a.replace("a", "f")\n\n  and\n\n     a = b"abc"\n     b = a.replace(b"a", b"f")\n\nbytes.decode(encoding="utf-8", errors="strict")\nbytearray.decode(encoding="utf-8", errors="strict")\n\n   Return a string decoded from the given bytes.  Default encoding is\n   ``\'utf-8\'``. *errors* may be given to set a different error\n   handling scheme.  The default for *errors* is ``\'strict\'``, meaning\n   that encoding errors raise a ``UnicodeError``.  Other possible\n   values are ``\'ignore\'``, ``\'replace\'`` and any other name\n   registered via ``codecs.register_error()``, see section *Codec Base\n   Classes*. For a list of possible encodings, see section *Standard\n   Encodings*.\n\n   Changed in version 3.1: Added support for keyword arguments.\n\nThe bytes and bytearray types have an additional class method:\n\nclassmethod bytes.fromhex(string)\nclassmethod bytearray.fromhex(string)\n\n   This ``bytes`` class method returns a bytes or bytearray object,\n   decoding the given string object.  The string must contain two\n   hexadecimal digits per byte, spaces are ignored.\n\n   >>> bytes.fromhex(\'f0 f1f2  \')\n   b\'\\xf0\\xf1\\xf2\'\n\nThe maketrans and translate methods differ in semantics from the\nversions available on strings:\n\nbytes.translate(table[, delete])\nbytearray.translate(table[, delete])\n\n   Return a copy of the bytes or bytearray object where all bytes\n   occurring in the optional argument *delete* are removed, and the\n   remaining bytes have been mapped through the given translation\n   table, which must be a bytes object of length 256.\n\n   You can use the ``bytes.maketrans()`` method to create a\n   translation table.\n\n   Set the *table* argument to ``None`` for translations that only\n   delete characters:\n\n      >>> b\'read this short text\'.translate(None, b\'aeiou\')\n      b\'rd ths shrt txt\'\n\nstatic bytes.maketrans(from, to)\nstatic bytearray.maketrans(from, to)\n\n   This static method returns a translation table usable for\n   ``bytes.translate()`` that will map each character in *from* into\n   the character at the same position in *to*; *from* and *to* must be\n   bytes objects and have the same length.\n\n   New in version 3.1.\n',
  'typesseq-mutable': '\nMutable Sequence Types\n**********************\n\nList and bytearray objects support additional operations that allow\nin-place modification of the object.  Other mutable sequence types\n(when added to the language) should also support these operations.\nStrings and tuples are immutable sequence types: such objects cannot\nbe modified once created. The following operations are defined on\nmutable sequence types (where *x* is an arbitrary object).\n\nNote that while lists allow their items to be of any type, bytearray\nobject "items" are all integers in the range 0 <= x < 256.\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation                      | Result                           | Notes                 |\n+================================+==================================+=======================+\n| ``s[i] = x``                   | item *i* of *s* is replaced by   |                       |\n|                                | *x*                              |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t``                 | slice of *s* from *i* to *j* is  |                       |\n|                                | replaced by the contents of the  |                       |\n|                                | iterable *t*                     |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]``                 | same as ``s[i:j] = []``          |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t``               | the elements of ``s[i:j:k]`` are | (1)                   |\n|                                | replaced by those of *t*         |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]``               | removes the elements of          |                       |\n|                                | ``s[i:j:k]`` from the list       |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)``                | same as ``s[len(s):len(s)] =     |                       |\n|                                | [x]``                            |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)``                | same as ``s[len(s):len(s)] = x`` | (2)                   |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)``                 | return number of *i*\'s for which |                       |\n|                                | ``s[i] == x``                    |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])``       | return smallest *k* such that    | (3)                   |\n|                                | ``s[k] == x`` and ``i <= k < j`` |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)``             | same as ``s[i:i] = [x]``         | (4)                   |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])``                 | same as ``x = s[i]; del s[i];    | (5)                   |\n|                                | return x``                       |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)``                | same as ``del s[s.index(x)]``    | (3)                   |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()``                | reverses the items of *s* in     | (6)                   |\n|                                | place                            |                       |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([key[, reverse]])``   | sort the items of *s* in place   | (6), (7), (8)         |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. *x* can be any iterable object.\n\n3. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n   index is passed as the second or third parameter to the ``index()``\n   method, the sequence length is added, as for slice indices.  If it\n   is still negative, it is truncated to zero, as for slice indices.\n\n4. When a negative index is passed as the first parameter to the\n   ``insert()`` method, the sequence length is added, as for slice\n   indices.  If it is still negative, it is truncated to zero, as for\n   slice indices.\n\n5. The optional argument *i* defaults to ``-1``, so that by default\n   the last item is removed and returned.\n\n6. The ``sort()`` and ``reverse()`` methods modify the sequence in\n   place for economy of space when sorting or reversing a large\n   sequence.  To remind you that they operate by side effect, they\n   don\'t return the sorted or reversed sequence.\n\n7. The ``sort()`` method takes optional arguments for controlling the\n   comparisons.  Each must be specified as a keyword argument.\n\n   *key* specifies a function of one argument that is used to extract\n   a comparison key from each list element: ``key=str.lower``.  The\n   default value is ``None``. Use ``functools.cmp_to_key()`` to\n   convert an old-style *cmp* function to a *key* function.\n\n   *reverse* is a boolean value.  If set to ``True``, then the list\n   elements are sorted as if each comparison were reversed.\n\n   The ``sort()`` method is guaranteed to be stable.  A sort is stable\n   if it guarantees not to change the relative order of elements that\n   compare equal --- this is helpful for sorting in multiple passes\n   (for example, sort by department, then by salary grade).\n\n   **CPython implementation detail:** While a list is being sorted,\n   the effect of attempting to mutate, or even inspect, the list is\n   undefined.  The C implementation of Python makes the list appear\n   empty for the duration, and raises ``ValueError`` if it can detect\n   that the list has been mutated during a sort.\n\n8. ``sort()`` is not supported by ``bytearray`` objects.\n',
  'unary': '\nUnary arithmetic and bitwise operations\n***************************************\n\nAll unary arithmetic and bitwise operations have the same priority:\n\n   u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n\nThe unary ``-`` (minus) operator yields the negation of its numeric\nargument.\n\nThe unary ``+`` (plus) operator yields its numeric argument unchanged.\n\nThe unary ``~`` (invert) operator yields the bitwise inversion of its\ninteger argument.  The bitwise inversion of ``x`` is defined as\n``-(x+1)``.  It only applies to integral numbers.\n\nIn all three cases, if the argument does not have the proper type, a\n``TypeError`` exception is raised.\n',
  'while': '\nThe ``while`` statement\n***********************\n\nThe ``while`` statement is used for repeated execution as long as an\nexpression is true:\n\n   while_stmt ::= "while" expression ":" suite\n                  ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the ``else`` clause, if present, is\nexecuted and the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite.  A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ngoes back to testing the expression.\n',

Modified: python/branches/py3k-cdecimal/Lib/random.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/random.py	(original)
+++ python/branches/py3k-cdecimal/Lib/random.py	Sun Jan  2 13:18:37 2011
@@ -43,6 +43,7 @@
 from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin
 from os import urandom as _urandom
 import collections as _collections
+from hashlib import sha512 as _sha512
 
 __all__ = ["Random","seed","random","uniform","randint","choice","sample",
            "randrange","shuffle","normalvariate","lognormvariate",
@@ -110,10 +111,12 @@
                 import time
                 a = int(time.time() * 256) # use fractional seconds
 
-        if version == 2 and isinstance(a, (str, bytes, bytearray)):
-            if isinstance(a, str):
-                a = a.encode("utf8")
-            a = int.from_bytes(a, 'big')
+        if version == 2:
+            if isinstance(a, (str, bytes, bytearray)):
+                if isinstance(a, str):
+                    a = a.encode("utf8")
+                a += _sha512(a).digest()
+                a = int.from_bytes(a, 'big')
 
         super().seed(a)
         self.gauss_next = None

Modified: python/branches/py3k-cdecimal/Lib/shelve.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/shelve.py	(original)
+++ python/branches/py3k-cdecimal/Lib/shelve.py	Sun Jan  2 13:18:37 2011
@@ -73,6 +73,7 @@
     def __repr__(self):
         return '<Closed Dictionary>'
 
+
 class Shelf(collections.MutableMapping):
     """Base class for shelf implementations.
 
@@ -88,7 +89,7 @@
         self._protocol = protocol
         self.writeback = writeback
         self.cache = {}
-        self.keyencoding = "utf-8"
+        self.keyencoding = keyencoding
 
     def __iter__(self):
         for k in self.dict.keys():

Modified: python/branches/py3k-cdecimal/Lib/shutil.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/shutil.py	(original)
+++ python/branches/py3k-cdecimal/Lib/shutil.py	Sun Jan  2 13:18:37 2011
@@ -370,7 +370,7 @@
     archive that is being built. If not provided, the current owner and group
     will be used.
 
-    The output tar file will be named 'base_dir' +  ".tar", possibly plus
+    The output tar file will be named 'base_name' +  ".tar", possibly plus
     the appropriate compression extension (".gz", or ".bz2").
 
     Returns the output filename.
@@ -440,7 +440,7 @@
 def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None):
     """Create a zip file from all the files under 'base_dir'.
 
-    The output zip file will be named 'base_dir' + ".zip".  Uses either the
+    The output zip file will be named 'base_name' + ".zip".  Uses either the
     "zipfile" Python module (if available) or the InfoZIP "zip" utility
     (if installed and found on the default search path).  If neither tool is
     available, raises ExecError.  Returns the name of the output zip

Modified: python/branches/py3k-cdecimal/Lib/site.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/site.py	(original)
+++ python/branches/py3k-cdecimal/Lib/site.py	Sun Jan  2 13:18:37 2011
@@ -55,6 +55,7 @@
 import sys
 import os
 import builtins
+import traceback
 
 # Prefixes for site-packages; add additional prefixes like /usr/local here
 PREFIXES = [sys.prefix, sys.exec_prefix]
@@ -141,17 +142,26 @@
     except IOError:
         return
     with f:
-        for line in f:
+        for n, line in enumerate(f):
             if line.startswith("#"):
                 continue
-            if line.startswith(("import ", "import\t")):
-                exec(line)
-                continue
-            line = line.rstrip()
-            dir, dircase = makepath(sitedir, line)
-            if not dircase in known_paths and os.path.exists(dir):
-                sys.path.append(dir)
-                known_paths.add(dircase)
+            try:
+                if line.startswith(("import ", "import\t")):
+                    exec(line)
+                    continue
+                line = line.rstrip()
+                dir, dircase = makepath(sitedir, line)
+                if not dircase in known_paths and os.path.exists(dir):
+                    sys.path.append(dir)
+                    known_paths.add(dircase)
+            except Exception as err:
+                print("Error processing line {:d} of {}:\n".format(n+1, fullname),
+                      file=sys.stderr)
+                for record in traceback.format_exception(*sys.exc_info()):
+                    for line in record.splitlines():
+                        print('  '+line, file=sys.stderr)
+                print("\nRemainder of file ignored", file=sys.stderr)
+                break
     if reset:
         known_paths = None
     return known_paths

Modified: python/branches/py3k-cdecimal/Lib/smtpd.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/smtpd.py	(original)
+++ python/branches/py3k-cdecimal/Lib/smtpd.py	Sun Jan  2 13:18:37 2011
@@ -109,6 +109,9 @@
     COMMAND = 0
     DATA = 1
 
+    data_size_limit = 33554432
+    command_size_limit = 512
+
     def __init__(self, server, conn, addr):
         asynchat.async_chat.__init__(self, conn)
         self.smtp_server = server
@@ -121,6 +124,7 @@
         self.rcpttos = []
         self.received_data = ''
         self.fqdn = socket.getfqdn()
+        self.num_bytes = 0
         try:
             self.peer = conn.getpeername()
         except socket.error as err:
@@ -262,6 +266,15 @@
 
     # Implementation of base class abstract method
     def collect_incoming_data(self, data):
+        limit = None
+        if self.smtp_state == self.COMMAND:
+            limit = self.command_size_limit
+        elif self.smtp_state == self.DATA:
+            limit = self.data_size_limit
+        if limit and self.num_bytes > limit:
+            return
+        elif limit:
+            self.num_bytes += len(data)
         self.received_lines.append(str(data, "utf8"))
 
     # Implementation of base class abstract method
@@ -270,6 +283,11 @@
         print('Data:', repr(line), file=DEBUGSTREAM)
         self.received_lines = []
         if self.smtp_state == self.COMMAND:
+            if self.num_bytes > self.command_size_limit:
+                self.push('500 Error: line too long')
+                self.num_bytes = 0
+                return
+            self.num_bytes = 0
             if not line:
                 self.push('500 Error: bad syntax')
                 return
@@ -290,6 +308,11 @@
         else:
             if self.smtp_state != self.DATA:
                 self.push('451 Internal confusion')
+                self.num_bytes = 0
+                return
+            if self.num_bytes > self.data_size_limit:
+                self.push('552 Error: Too much mail data')
+                self.num_bytes = 0
                 return
             # Remove extraneous carriage returns and de-transparency according
             # to RFC 821, Section 4.5.2.
@@ -307,6 +330,7 @@
             self.rcpttos = []
             self.mailfrom = None
             self.smtp_state = self.COMMAND
+            self.num_bytes = 0
             self.set_terminator(b'\r\n')
             if not status:
                 self.push('250 Ok')

Modified: python/branches/py3k-cdecimal/Lib/subprocess.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/subprocess.py	(original)
+++ python/branches/py3k-cdecimal/Lib/subprocess.py	Sun Jan  2 13:18:37 2011
@@ -27,10 +27,10 @@
 
 class Popen(args, bufsize=0, executable=None,
             stdin=None, stdout=None, stderr=None,
-            preexec_fn=None, close_fds=False, shell=False,
+            preexec_fn=None, close_fds=True, shell=False,
             cwd=None, env=None, universal_newlines=False,
             startupinfo=None, creationflags=0,
-            restore_signals=True, start_new_session=False):
+            restore_signals=True, start_new_session=False, pass_fds=()):
 
 
 Arguments are:
@@ -39,12 +39,12 @@
 program to execute is normally the first item in the args sequence or
 string, but can be explicitly set by using the executable argument.
 
-On UNIX, with shell=False (default): In this case, the Popen class
+On POSIX, with shell=False (default): In this case, the Popen class
 uses os.execvp() to execute the child program.  args should normally
 be a sequence.  A string will be treated as a sequence with the string
 as the only item (the program to execute).
 
-On UNIX, with shell=True: If args is a string, it specifies the
+On POSIX, with shell=True: If args is a string, it specifies the
 command string to execute through the shell.  If args is a sequence,
 the first item specifies the command string, and any additional items
 will be treated as additional shell arguments.
@@ -73,14 +73,19 @@
 stderr data from the applications should be captured into the same
 file handle as for stdout.
 
-On UNIX, if preexec_fn is set to a callable object, this object will be
+On POSIX, if preexec_fn is set to a callable object, this object will be
 called in the child process just before the child is executed.  The use
 of preexec_fn is not thread safe, using it in the presence of threads
 could lead to a deadlock in the child process before the new executable
 is executed.
 
 If close_fds is true, all file descriptors except 0, 1 and 2 will be
-closed before the child process is executed.
+closed before the child process is executed.  The default for close_fds
+varies by platform:  Always true on POSIX.  True when stdin/stdout/stderr
+are None on Windows, false otherwise.
+
+pass_fds is an optional sequence of file descriptors to keep open between the
+parent and child.  Providing any pass_fds implicitly sets close_fds to true.
 
 if shell is true, the specified command will be executed through the
 shell.
@@ -88,12 +93,12 @@
 If cwd is not None, the current directory will be changed to cwd
 before the child is executed.
 
-On UNIX, if restore_signals is True all signals that Python sets to
+On POSIX, if restore_signals is True all signals that Python sets to
 SIG_IGN are restored to SIG_DFL in the child process before the exec.
 Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals.  This
 parameter does nothing on Windows.
 
-On UNIX, if start_new_session is True, the setsid() system call will be made
+On POSIX, if start_new_session is True, the setsid() system call will be made
 in the child process prior to executing the command.
 
 If env is not None, it defines the environment variables for the new
@@ -101,7 +106,7 @@
 
 If universal_newlines is true, the file objects stdout and stderr are
 opened as a text files, but lines may be terminated by any of '\n',
-the Unix end-of-line convention, '\r', the Macintosh convention or
+the Unix end-of-line convention, '\r', the old Macintosh convention or
 '\r\n', the Windows convention.  All of these external representations
 are seen as '\n' by the Python program.  Note: This feature is only
 available if Python is built with universal newline support (the
@@ -242,7 +247,7 @@
 returncode
     The child return code.  A None value indicates that the process
     hasn't terminated yet.  A negative value -N indicates that the
-    child was terminated by signal N (UNIX only).
+    child was terminated by signal N (POSIX only).
 
 
 Replacing older functions with the subprocess module
@@ -339,6 +344,7 @@
 import gc
 import signal
 import builtins
+import warnings
 
 # Exception classes used by this module.
 class CalledProcessError(Exception):
@@ -378,7 +384,6 @@
         import _posixsubprocess
     except ImportError:
         _posixsubprocess = None
-        import warnings
         warnings.warn("The _posixsubprocess module is not being used. "
                       "Child process reliability may suffer if your "
                       "program uses threads.", RuntimeWarning)
@@ -388,6 +393,23 @@
     # POSIX defines PIPE_BUF as >= 512.
     _PIPE_BUF = getattr(select, 'PIPE_BUF', 512)
 
+    if _posixsubprocess:
+        _create_pipe = _posixsubprocess.cloexec_pipe
+    else:
+        def _create_pipe():
+            try:
+                cloexec_flag = fcntl.FD_CLOEXEC
+            except AttributeError:
+                cloexec_flag = 1
+
+            fds = os.pipe()
+
+            old = fcntl.fcntl(fds[0], fcntl.F_GETFD)
+            fcntl.fcntl(fds[0], fcntl.F_SETFD, old | cloexec_flag)
+            old = fcntl.fcntl(fds[1], fcntl.F_GETFD)
+            fcntl.fcntl(fds[1], fcntl.F_SETFD, old | cloexec_flag)
+
+            return fds
 
 __all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "getstatusoutput",
            "getoutput", "check_output", "CalledProcessError"]
@@ -562,7 +584,7 @@
 
 # Various tools for executing commands and looking at their output and status.
 #
-# NB This only works (and is only relevant) for UNIX.
+# NB This only works (and is only relevant) for POSIX.
 
 def getstatusoutput(cmd):
     """Return (status, output) of executing cmd in a shell.
@@ -602,13 +624,17 @@
     return getstatusoutput(cmd)[1]
 
 
+_PLATFORM_DEFAULT_CLOSE_FDS = object()
+
+
 class Popen(object):
     def __init__(self, args, bufsize=0, executable=None,
                  stdin=None, stdout=None, stderr=None,
-                 preexec_fn=None, close_fds=False, shell=False,
-                 cwd=None, env=None, universal_newlines=False,
+                 preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS,
+                 shell=False, cwd=None, env=None, universal_newlines=False,
                  startupinfo=None, creationflags=0,
-                 restore_signals=True, start_new_session=False):
+                 restore_signals=True, start_new_session=False,
+                 pass_fds=()):
         """Create new Popen instance."""
         _cleanup()
 
@@ -622,12 +648,24 @@
             if preexec_fn is not None:
                 raise ValueError("preexec_fn is not supported on Windows "
                                  "platforms")
-            if close_fds and (stdin is not None or stdout is not None or
-                              stderr is not None):
-                raise ValueError("close_fds is not supported on Windows "
-                                 "platforms if you redirect stdin/stdout/stderr")
+            any_stdio_set = (stdin is not None or stdout is not None or
+                             stderr is not None)
+            if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS:
+                if any_stdio_set:
+                    close_fds = False
+                else:
+                    close_fds = True
+            elif close_fds and any_stdio_set:
+                raise ValueError(
+                        "close_fds is not supported on Windows platforms"
+                        " if you redirect stdin/stdout/stderr")
         else:
             # POSIX
+            if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS:
+                close_fds = True
+            if pass_fds and not close_fds:
+                warnings.warn("pass_fds overriding close_fds.", RuntimeWarning)
+                close_fds = True
             if startupinfo is not None:
                 raise ValueError("startupinfo is only supported on Windows "
                                  "platforms")
@@ -662,7 +700,7 @@
          errread, errwrite) = self._get_handles(stdin, stdout, stderr)
 
         self._execute_child(args, executable, preexec_fn, close_fds,
-                            cwd, env, universal_newlines,
+                            pass_fds, cwd, env, universal_newlines,
                             startupinfo, creationflags, shell,
                             p2cread, p2cwrite,
                             c2pread, c2pwrite,
@@ -697,6 +735,16 @@
         data = data.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
         return data.decode(encoding)
 
+    def __enter__(self):
+        return self
+
+    def __exit__(self, type, value, traceback):
+        if self.stdout:
+            self.stdout.close()
+        if self.stderr:
+            self.stderr.close()
+        if self.stdin:
+            self.stdin.close()
 
     def __del__(self, _maxsize=sys.maxsize, _active=_active):
         if not self._child_created:
@@ -829,7 +877,7 @@
 
 
         def _execute_child(self, args, executable, preexec_fn, close_fds,
-                           cwd, env, universal_newlines,
+                           pass_fds, cwd, env, universal_newlines,
                            startupinfo, creationflags, shell,
                            p2cread, p2cwrite,
                            c2pread, c2pwrite,
@@ -837,6 +885,8 @@
                            unused_restore_signals, unused_start_new_session):
             """Execute program (MS Windows version)"""
 
+            assert not pass_fds, "pass_fds not supported on Windows."
+
             if not isinstance(args, str):
                 args = list2cmdline(args)
 
@@ -935,6 +985,7 @@
 
         def _readerthread(self, fh, buffer):
             buffer.append(fh.read())
+            fh.close()
 
 
         def _communicate(self, input):
@@ -1007,7 +1058,7 @@
             if stdin is None:
                 pass
             elif stdin == PIPE:
-                p2cread, p2cwrite = os.pipe()
+                p2cread, p2cwrite = _create_pipe()
             elif isinstance(stdin, int):
                 p2cread = stdin
             else:
@@ -1017,7 +1068,7 @@
             if stdout is None:
                 pass
             elif stdout == PIPE:
-                c2pread, c2pwrite = os.pipe()
+                c2pread, c2pwrite = _create_pipe()
             elif isinstance(stdout, int):
                 c2pwrite = stdout
             else:
@@ -1027,7 +1078,7 @@
             if stderr is None:
                 pass
             elif stderr == PIPE:
-                errread, errwrite = os.pipe()
+                errread, errwrite = _create_pipe()
             elif stderr == STDOUT:
                 errwrite = c2pwrite
             elif isinstance(stderr, int):
@@ -1041,23 +1092,24 @@
                     errread, errwrite)
 
 
-        def _set_cloexec_flag(self, fd):
-            try:
-                cloexec_flag = fcntl.FD_CLOEXEC
-            except AttributeError:
-                cloexec_flag = 1
-
-            old = fcntl.fcntl(fd, fcntl.F_GETFD)
-            fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag)
-
-
         def _close_fds(self, but):
             os.closerange(3, but)
             os.closerange(but + 1, MAXFD)
 
 
+        def _close_all_but_a_sorted_few_fds(self, fds_to_keep):
+            # precondition: fds_to_keep must be sorted and unique
+            start_fd = 3
+            for fd in fds_to_keep:
+                if fd >= start_fd:
+                    os.closerange(start_fd, fd)
+                    start_fd = fd + 1
+            if start_fd <= MAXFD:
+                os.closerange(start_fd, MAXFD)
+
+
         def _execute_child(self, args, executable, preexec_fn, close_fds,
-                           cwd, env, universal_newlines,
+                           pass_fds, cwd, env, universal_newlines,
                            startupinfo, creationflags, shell,
                            p2cread, p2cwrite,
                            c2pread, c2pwrite,
@@ -1081,10 +1133,9 @@
             # For transferring possible exec failure from child to parent.
             # Data format: "exception name:hex errno:description"
             # Pickle is not used; it is complex and involves memory allocation.
-            errpipe_read, errpipe_write = os.pipe()
+            errpipe_read, errpipe_write = _create_pipe()
             try:
                 try:
-                    self._set_cloexec_flag(errpipe_write)
 
                     if _posixsubprocess:
                         # We must avoid complex work that could involve
@@ -1105,9 +1156,11 @@
                             executable_list = tuple(
                                 os.path.join(os.fsencode(dir), executable)
                                 for dir in os.get_exec_path(env))
+                        fds_to_keep = set(pass_fds)
+                        fds_to_keep.add(errpipe_write)
                         self.pid = _posixsubprocess.fork_exec(
                                 args, executable_list,
-                                close_fds, cwd, env_list,
+                                close_fds, sorted(fds_to_keep), cwd, env_list,
                                 p2cread, p2cwrite, c2pread, c2pwrite,
                                 errread, errwrite,
                                 errpipe_read, errpipe_write,
@@ -1161,7 +1214,14 @@
 
                                 # Close all other fds, if asked for
                                 if close_fds:
-                                    self._close_fds(but=errpipe_write)
+                                    if pass_fds:
+                                        fds_to_keep = set(pass_fds)
+                                        fds_to_keep.add(errpipe_write)
+                                        self._close_all_but_a_sorted_few_fds(
+                                                sorted(fds_to_keep))
+                                    else:
+                                        self._close_fds(but=errpipe_write)
+
 
                                 if cwd is not None:
                                     os.chdir(cwd)
@@ -1236,7 +1296,11 @@
                 os.close(errpipe_read)
 
             if data:
-                _eintr_retry_call(os.waitpid, self.pid, 0)
+                try:
+                    _eintr_retry_call(os.waitpid, self.pid, 0)
+                except OSError as e:
+                    if e.errno != errno.ECHILD:
+                        raise
                 try:
                     exception_name, hex_errno, err_msg = data.split(b':', 2)
                 except ValueError:
@@ -1299,7 +1363,15 @@
             """Wait for child process to terminate.  Returns returncode
             attribute."""
             if self.returncode is None:
-                pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
+                try:
+                    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
+                except OSError as e:
+                    if e.errno != errno.ECHILD:
+                        raise
+                    # This happens if SIGCLD is set to be ignored or waiting
+                    # for child processes has otherwise been disabled for our
+                    # process.  This child is dead, we can't get the status.
+                    sts = 0
                 self._handle_exitstatus(sts)
             return self.returncode
 

Modified: python/branches/py3k-cdecimal/Lib/sysconfig.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/sysconfig.py	(original)
+++ python/branches/py3k-cdecimal/Lib/sysconfig.py	Sun Jan  2 13:18:37 2011
@@ -25,8 +25,10 @@
         'platstdlib': '{platbase}/lib/python{py_version_short}',
         'purelib': '{base}/lib/python{py_version_short}/site-packages',
         'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
-        'include': '{base}/include/python{py_version_short}',
-        'platinclude': '{platbase}/include/python{py_version_short}',
+        'include':
+            '{base}/include/python{py_version_short}{abiflags}',
+        'platinclude':
+            '{platbase}/include/python{py_version_short}{abiflags}',
         'scripts': '{base}/bin',
         'data': '{base}',
         },
@@ -317,7 +319,9 @@
     """Return the path of the Makefile."""
     if _PYTHON_BUILD:
         return os.path.join(_PROJECT_BASE, "Makefile")
-    return os.path.join(get_path('stdlib'), "config", "Makefile")
+    return os.path.join(get_path('stdlib'),
+                        'config-{}{}'.format(_PY_VERSION_SHORT, sys.abiflags),
+                        'Makefile')
 
 
 def _init_posix(vars):
@@ -471,6 +475,11 @@
         _CONFIG_VARS['base'] = _PREFIX
         _CONFIG_VARS['platbase'] = _EXEC_PREFIX
         _CONFIG_VARS['projectbase'] = _PROJECT_BASE
+        try:
+            _CONFIG_VARS['abiflags'] = sys.abiflags
+        except AttributeError:
+            # sys.abiflags may not be defined on all platforms.
+            _CONFIG_VARS['abiflags'] = ''
 
         if os.name in ('nt', 'os2'):
             _init_non_posix(_CONFIG_VARS)

Modified: python/branches/py3k-cdecimal/Lib/tabnanny.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tabnanny.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tabnanny.py	Sun Jan  2 13:18:37 2011
@@ -264,7 +264,7 @@
         return a
 
 def format_witnesses(w):
-    firsts = map(lambda tup: str(tup[0]), w)
+    firsts = (str(tup[0]) for tup in w)
     prefix = "at tab size"
     if len(w) > 1:
         prefix = prefix + "s"

Modified: python/branches/py3k-cdecimal/Lib/telnetlib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/telnetlib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/telnetlib.py	Sun Jan  2 13:18:37 2011
@@ -236,7 +236,7 @@
 
         """
         if self.debuglevel > 0:
-            print('Telnet(%s,%d):' % (self.host, self.port), end=' ')
+            print('Telnet(%s,%s):' % (self.host, self.port), end=' ')
             if args:
                 print(msg % args)
             else:

Modified: python/branches/py3k-cdecimal/Lib/tempfile.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tempfile.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tempfile.py	Sun Jan  2 13:18:37 2011
@@ -29,6 +29,8 @@
 
 # Imports.
 
+import warnings as _warnings
+import sys as _sys
 import io as _io
 import os as _os
 import errno as _errno
@@ -617,22 +619,40 @@
     """
 
     def __init__(self, suffix="", prefix=template, dir=None):
-        self.name = mkdtemp(suffix, prefix, dir)
         self._closed = False
+        self.name = None # Handle mkdtemp throwing an exception
+        self.name = mkdtemp(suffix, prefix, dir)
+
+    def __repr__(self):
+        return "<{} {!r}>".format(self.__class__.__name__, self.name)
 
     def __enter__(self):
         return self.name
 
-    def cleanup(self):
-        if not self._closed:
-            self._rmtree(self.name)
+    def cleanup(self, _warn=False):
+        if self.name and not self._closed:
+            try:
+                self._rmtree(self.name)
+            except (TypeError, AttributeError) as ex:
+                # Issue #10188: Emit a warning on stderr
+                # if the directory could not be cleaned
+                # up due to missing globals
+                if "None" not in str(ex):
+                    raise
+                print("ERROR: {!r} while cleaning up {!r}".format(ex, self,),
+                      file=_sys.stderr)
+                return
             self._closed = True
+            if _warn:
+                self._warn("Implicitly cleaning up {!r}".format(self),
+                           ResourceWarning)
 
     def __exit__(self, exc, value, tb):
         self.cleanup()
 
-    __del__ = cleanup
-
+    def __del__(self):
+        # Issue a ResourceWarning if implicit cleanup needed
+        self.cleanup(_warn=True)
 
     # XXX (ncoghlan): The following code attempts to make
     # this class tolerant of the module nulling out process
@@ -644,6 +664,7 @@
     _remove = staticmethod(_os.remove)
     _rmdir = staticmethod(_os.rmdir)
     _os_error = _os.error
+    _warn = _warnings.warn
 
     def _rmtree(self, path):
         # Essentially a stripped down version of shutil.rmtree.  We can't

Modified: python/branches/py3k-cdecimal/Lib/test/crashers/README
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/crashers/README	(original)
+++ python/branches/py3k-cdecimal/Lib/test/crashers/README	Sun Jan  2 13:18:37 2011
@@ -1,20 +1,16 @@
-This directory only contains tests for outstanding bugs that cause
-the interpreter to segfault.  Ideally this directory should always
-be empty.  Sometimes it may not be easy to fix the underlying cause.
+This directory only contains tests for outstanding bugs that cause the
+interpreter to segfault.  Ideally this directory should always be empty, but
+sometimes it may not be easy to fix the underlying cause and the bug is deemed
+too obscure to invest the effort.
 
 Each test should fail when run from the command line:
 
 	./python Lib/test/crashers/weakref_in_del.py
 
-Each test should have a link to the bug report:
-
-	# http://python.org/sf/BUG#
-
-Put as much info into a docstring or comments to help determine
-the cause of the failure.  Particularly note if the cause is
-system or environment dependent and what the variables are.
-
-Once the crash is fixed, the test case should be moved into an appropriate
-test (even if it was originally from the test suite).  This ensures the
-regression doesn't happen again.  And if it does, it should be easier
-to track down.
+Put as much info into a docstring or comments to help determine the cause of the
+failure, as well as a bugs.python.org issue number if it exists.  Particularly
+note if the cause is system or environment dependent and what the variables are.
+
+Once the crash is fixed, the test case should be moved into an appropriate test
+(even if it was originally from the test suite).  This ensures the regression
+doesn't happen again.  And if it does, it should be easier to track down.

Modified: python/branches/py3k-cdecimal/Lib/test/datetimetester.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/datetimetester.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/datetimetester.py	Sun Jan  2 13:18:37 2011
@@ -38,11 +38,6 @@
 INF = float("inf")
 NAN = float("nan")
 
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(
-    float.__getformat__("double").startswith("IEEE"),
-    "test requires IEEE 754 doubles")
-
 
 #############################################################################
 # module tests
@@ -407,7 +402,7 @@
         self.assertRaises(ZeroDivisionError, lambda: a / 0.0)
         self.assertRaises(TypeError, lambda: a / '')
 
-    @requires_IEEE_754
+    @support.requires_IEEE_754
     def test_disallowed_special(self):
         a = timedelta(42)
         self.assertRaises(ValueError, a.__mul__, NAN)
@@ -589,7 +584,7 @@
         self.assertRaises(OverflowError, day.__truediv__, 1e-10)
         self.assertRaises(OverflowError, day.__truediv__, 9e-10)
 
-    @requires_IEEE_754
+    @support.requires_IEEE_754
     def _test_overflow_special(self):
         day = timedelta(1)
         self.assertRaises(OverflowError, day.__mul__, INF)
@@ -2513,11 +2508,17 @@
 
         # Check that an invalid tzname result raises an exception.
         class Badtzname(tzinfo):
-            def tzname(self, dt): return 42
+            tz = 42
+            def tzname(self, dt): return self.tz
         t = time(2, 3, 4, tzinfo=Badtzname())
         self.assertEqual(t.strftime("%H:%M:%S"), "02:03:04")
         self.assertRaises(TypeError, t.strftime, "%Z")
 
+        # Issue #6697:
+        if '_Fast' in str(type(self)):
+            Badtzname.tz = '\ud800'
+            self.assertRaises(ValueError, t.strftime, "%Z")
+
     def test_hash_edge_cases(self):
         # Offsets that overflow a basic time.
         t1 = self.theclass(0, 1, 2, 3, tzinfo=FixedOffset(1439, ""))

Modified: python/branches/py3k-cdecimal/Lib/test/pystone.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/pystone.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/pystone.py	Sun Jan  2 13:18:37 2011
@@ -72,7 +72,7 @@
 Char1Glob = '\0'
 Char2Glob = '\0'
 Array1Glob = [0]*51
-Array2Glob = list(map(lambda x: x[:], [Array1Glob]*51))
+Array2Glob = [x[:] for x in [Array1Glob]*51]
 PtrGlb = None
 PtrGlbNext = None
 

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	Sun Jan  2 13:18:37 2011
@@ -167,6 +167,7 @@
 import tempfile
 import platform
 import sysconfig
+import logging
 
 
 # Some times __path__ and __file__ are not absolute (e.g. while running from
@@ -526,7 +527,7 @@
         def tests_and_args():
             for test in tests:
                 args_tuple = (
-                    (test, verbose, quiet, testdir),
+                    (test, verbose, quiet),
                     dict(huntrleaks=huntrleaks, use_resources=use_resources,
                         debug=debug)
                 )
@@ -598,16 +599,15 @@
             if trace:
                 # If we're tracing code coverage, then we don't exit with status
                 # if on a false return value from main.
-                tracer.runctx('runtest(test, verbose, quiet, testdir)',
+                tracer.runctx('runtest(test, verbose, quiet)',
                               globals=globals(), locals=vars())
             else:
                 try:
-                    result = runtest(test, verbose, quiet,
-                                     testdir, huntrleaks, debug)
+                    result = runtest(test, verbose, quiet, huntrleaks, debug)
                     accumulate_result(test, result)
                     if verbose3 and result[0] == FAILED:
                         print("Re-running test {} in verbose mode".format(test))
-                        runtest(test, True, quiet, testdir, huntrleaks, debug)
+                        runtest(test, True, quiet, huntrleaks, debug)
                 except KeyboardInterrupt:
                     interrupted = True
                     break
@@ -677,8 +677,7 @@
             sys.stdout.flush()
             try:
                 verbose = True
-                ok = runtest(test, True, quiet, testdir,
-                             huntrleaks, debug)
+                ok = runtest(test, True, quiet, huntrleaks, debug)
             except KeyboardInterrupt:
                 # print a newline separate from the ^C
                 print()
@@ -744,14 +743,13 @@
         errors="backslashreplace")
 
 def runtest(test, verbose, quiet,
-            testdir=None, huntrleaks=False, debug=False, use_resources=None):
+            huntrleaks=False, debug=False, use_resources=None):
     """Run a single test.
 
     test -- the name of the test
     verbose -- if true, print more messages
     quiet -- if true, don't print 'skipped' messages (probably redundant)
     test_times -- a list of (time, test_name) pairs
-    testdir -- test directory
     huntrleaks -- run multiple times to test for leaks; requires a debug
                   build; a triple corresponding to -R's three arguments
 
@@ -768,8 +766,7 @@
     if use_resources is not None:
         support.use_resources = use_resources
     try:
-        return runtest_inner(test, verbose, quiet,
-                             testdir, huntrleaks, debug)
+        return runtest_inner(test, verbose, quiet, huntrleaks, debug)
     finally:
         cleanup_test_droppings(test, verbose)
 
@@ -814,7 +811,8 @@
 
     resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr',
                  'os.environ', 'sys.path', 'sys.path_hooks', '__import__',
-                 'warnings.filters', 'asyncore.socket_map')
+                 'warnings.filters', 'asyncore.socket_map',
+                 'logging._handlers', 'logging._handlerList')
 
     def get_sys_argv(self):
         return id(sys.argv), sys.argv, sys.argv[:]
@@ -882,6 +880,20 @@
             asyncore.close_all(ignore_all=True)
             asyncore.socket_map.update(saved_map)
 
+    def get_logging__handlers(self):
+        # _handlers is a WeakValueDictionary
+        return id(logging._handlers), logging._handlers, logging._handlers.copy()
+    def restore_logging__handlers(self, saved_handlers):
+        # Can't easily revert the logging state
+        pass
+
+    def get_logging__handlerList(self):
+        # _handlerList is a list of weakrefs to handlers
+        return id(logging._handlerList), logging._handlerList, logging._handlerList[:]
+    def restore_logging__handlerList(self, saved_handlerList):
+        # Can't easily revert the logging state
+        pass
+
     def resource_info(self):
         for name in self.resources:
             method_suffix = name.replace('.', '_')
@@ -915,10 +927,8 @@
         return False
 
 
-def runtest_inner(test, verbose, quiet,
-                  testdir=None, huntrleaks=False, debug=False):
+def runtest_inner(test, verbose, quiet, huntrleaks=False, debug=False):
     support.unload(test)
-    testdir = findtestdir(testdir)
     if verbose:
         capture_stdout = None
     else:
@@ -1468,16 +1478,7 @@
         assert self.isvalid()
         return self.expected
 
-if __name__ == '__main__':
-    # findtestdir() gets the dirname out of __file__, so we have to make it
-    # absolute before changing the working directory.
-    # For example __file__ may be relative when running trace or profile.
-    # See issue #9323.
-    __file__ = os.path.abspath(__file__)
-
-    # sanity check
-    assert __file__ == os.path.abspath(sys.argv[0])
-
+def _make_temp_dir_for_build(TEMPDIR):
     # When tests are run from the Python build directory, it is best practice
     # to keep the test files in a subfolder.  It eases the cleanup of leftover
     # files using command "make distclean".
@@ -1493,6 +1494,31 @@
     TESTCWD = 'test_python_{}'.format(os.getpid())
 
     TESTCWD = os.path.join(TEMPDIR, TESTCWD)
+    return TEMPDIR, TESTCWD
+
+if __name__ == '__main__':
+    # Remove regrtest.py's own directory from the module search path. Despite
+    # the elimination of implicit relative imports, this is still needed to
+    # ensure that submodules of the test package do not inappropriately appear
+    # as top-level modules even when people (or buildbots!) invoke regrtest.py
+    # directly instead of using the -m switch
+    mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
+    i = len(sys.path)
+    while i >= 0:
+        i -= 1
+        if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
+            del sys.path[i]
+
+    # findtestdir() gets the dirname out of __file__, so we have to make it
+    # absolute before changing the working directory.
+    # For example __file__ may be relative when running trace or profile.
+    # See issue #9323.
+    __file__ = os.path.abspath(__file__)
+
+    # sanity check
+    assert __file__ == os.path.abspath(sys.argv[0])
+
+    TEMPDIR, TESTCWD = _make_temp_dir_for_build(TEMPDIR)
 
     # Run the tests in a context manager that temporary changes the CWD to a
     # temporary and writable directory. If it's not possible to create or

Modified: python/branches/py3k-cdecimal/Lib/test/script_helper.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/script_helper.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/script_helper.py	Sun Jan  2 13:18:37 2011
@@ -3,6 +3,7 @@
 
 import sys
 import os
+import re
 import os.path
 import tempfile
 import subprocess
@@ -12,7 +13,7 @@
 import zipfile
 
 from imp import source_from_cache
-from test.support import make_legacy_pyc
+from test.support import make_legacy_pyc, strip_python_stderr
 
 # Executing the interpreter in a subprocess
 def _assert_python(expected_success, *args, **env_vars):
@@ -34,6 +35,7 @@
         p.stdout.close()
         p.stderr.close()
     rc = p.returncode
+    err =  strip_python_stderr(err)
     if (rc and expected_success) or (not rc and not expected_success):
         raise AssertionError(
             "Process return code is %d, "

Modified: python/branches/py3k-cdecimal/Lib/test/support.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/support.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/support.py	Sun Jan  2 13:18:37 2011
@@ -21,7 +21,7 @@
 import imp
 import time
 import sysconfig
-
+import logging.handlers
 
 try:
     import _thread
@@ -42,7 +42,8 @@
     "set_memlimit", "bigmemtest", "bigaddrspacetest", "BasicTestRunner",
     "run_unittest", "run_doctest", "threading_setup", "threading_cleanup",
     "reap_children", "cpython_only", "check_impl_detail", "get_attribute",
-    "swap_item", "swap_attr", "can_symlink", "skip_unless_symlink"]
+    "swap_item", "swap_attr", "requires_IEEE_754",
+    "TestHandler", "Matcher", "can_symlink", "skip_unless_symlink"]
 
 
 class Error(Exception):
@@ -366,6 +367,11 @@
         return (len(x) > len(y)) - (len(x) < len(y))
     return (x > y) - (x < y)
 
+# decorator for skipping tests on non-IEEE 754 platforms
+requires_IEEE_754 = unittest.skipUnless(
+    float.__getformat__("double").startswith("IEEE"),
+    "test requires IEEE 754 doubles")
+
 is_jython = sys.platform.startswith('java')
 
 # Filename used for testing
@@ -868,6 +874,9 @@
 def captured_stdout():
     return captured_output("stdout")
 
+def captured_stderr():
+    return captured_output("stderr")
+
 def captured_stdin():
     return captured_output("stdin")
 
@@ -1256,27 +1265,6 @@
             except:
                 break
 
-try:
-    from .symlink_support import enable_symlink_privilege
-except:
-    enable_symlink_privilege = lambda: True
-
-def can_symlink():
-    """It's no longer sufficient to test for the presence of symlink in the
-    os module - on Windows XP and earlier, os.symlink exists but a
-    NotImplementedError is thrown.
-    """
-    has_symlink = hasattr(os, 'symlink')
-    is_old_windows = sys.platform == "win32" and sys.getwindowsversion().major < 6
-    has_privilege = False if is_old_windows else enable_symlink_privilege()
-    return has_symlink and (not is_old_windows) and has_privilege
-
-def skip_unless_symlink(test):
-    """Skip decorator for tests that require functional symlink"""
-    selector = can_symlink()
-    msg = "Requires functional symlink implementation"
-    return [unittest.skip(msg)(test), test][selector]
-
 @contextlib.contextmanager
 def swap_attr(obj, attr, new_val):
     """Temporary swap out an attribute with a new object.
@@ -1359,3 +1347,88 @@
         if v > 0:
             args.append('-' + opt * v)
     return args
+
+#============================================================
+# Support for assertions about logging.
+#============================================================
+
+class TestHandler(logging.handlers.BufferingHandler):
+    def __init__(self, matcher):
+        # BufferingHandler takes a "capacity" argument
+        # so as to know when to flush. As we're overriding
+        # shouldFlush anyway, we can set a capacity of zero.
+        # You can call flush() manually to clear out the
+        # buffer.
+        logging.handlers.BufferingHandler.__init__(self, 0)
+        self.matcher = matcher
+
+    def shouldFlush(self):
+        return False
+
+    def emit(self, record):
+        self.format(record)
+        self.buffer.append(record.__dict__)
+
+    def matches(self, **kwargs):
+        """
+        Look for a saved dict whose keys/values match the supplied arguments.
+        """
+        result = False
+        for d in self.buffer:
+            if self.matcher.matches(d, **kwargs):
+                result = True
+                break
+        return result
+
+class Matcher(object):
+
+    _partial_matches = ('msg', 'message')
+
+    def matches(self, d, **kwargs):
+        """
+        Try to match a single dict with the supplied arguments.
+
+        Keys whose values are strings and which are in self._partial_matches
+        will be checked for partial (i.e. substring) matches. You can extend
+        this scheme to (for example) do regular expression matching, etc.
+        """
+        result = True
+        for k in kwargs:
+            v = kwargs[k]
+            dv = d.get(k)
+            if not self.match_value(k, dv, v):
+                result = False
+                break
+        return result
+
+    def match_value(self, k, dv, v):
+        """
+        Try to match a single stored value (dv) with a supplied value (v).
+        """
+        if type(v) != type(dv):
+            result = False
+        elif type(dv) is not str or k not in self._partial_matches:
+            result = (v == dv)
+        else:
+            result = dv.find(v) >= 0
+        return result
+
+
+_can_symlink = None
+def can_symlink():
+    global _can_symlink
+    if _can_symlink is not None:
+        return _can_symlink
+    try:
+        os.symlink(TESTFN, TESTFN + "can_symlink")
+        can = True
+    except (OSError, NotImplementedError):
+        can = False
+    _can_symlink = can
+    return can
+
+def skip_unless_symlink(test):
+    """Skip decorator for tests that require functional symlink"""
+    ok = can_symlink()
+    msg = "Requires functional symlink implementation"
+    return test if ok else unittest.skip(msg)(test)

Deleted: python/branches/py3k-cdecimal/Lib/test/symlink_support.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/symlink_support.py	Sun Jan  2 13:18:37 2011
+++ (empty file)
@@ -1,206 +0,0 @@
-"""
-A module built to test if the current process has the privilege to
-create symlinks on Windows.
-"""
-
-# allow script to run natively under python 2.6+
-from __future__ import print_function
-
-import ctypes
-from ctypes import wintypes
-
-GetCurrentProcess = ctypes.windll.kernel32.GetCurrentProcess
-GetCurrentProcess.restype = wintypes.HANDLE
-OpenProcessToken = ctypes.windll.advapi32.OpenProcessToken
-OpenProcessToken.argtypes = (wintypes.HANDLE, wintypes.DWORD,
-                             ctypes.POINTER(wintypes.HANDLE))
-OpenProcessToken.restype = wintypes.BOOL
-
-class LUID(ctypes.Structure):
-    _fields_ = [
-            ('low_part', wintypes.DWORD),
-            ('high_part', wintypes.LONG),
-            ]
-
-    def __eq__(self, other):
-        return (
-                self.high_part == other.high_part and
-                self.low_part == other.low_part
-                )
-
-    def __ne__(self, other):
-        return not (self==other)
-
-LookupPrivilegeValue = ctypes.windll.advapi32.LookupPrivilegeValueW
-LookupPrivilegeValue.argtypes = (
-        wintypes.LPWSTR, # system name
-        wintypes.LPWSTR, # name
-        ctypes.POINTER(LUID),
-        )
-LookupPrivilegeValue.restype = wintypes.BOOL
-
-class TOKEN_INFORMATION_CLASS:
-    TokenUser = 1
-    TokenGroups = 2
-    TokenPrivileges = 3
-    # ... see http://msdn.microsoft.com/en-us/library/aa379626%28VS.85%29.aspx
-
-SE_PRIVILEGE_ENABLED_BY_DEFAULT = (0x00000001)
-SE_PRIVILEGE_ENABLED            = (0x00000002)
-SE_PRIVILEGE_REMOVED            = (0x00000004)
-SE_PRIVILEGE_USED_FOR_ACCESS    = (0x80000000)
-
-class LUID_AND_ATTRIBUTES(ctypes.Structure):
-    _fields_ = [
-            ('LUID', LUID),
-            ('attributes', wintypes.DWORD),
-            ]
-
-    def is_enabled(self):
-        return bool(self.attributes & SE_PRIVILEGE_ENABLED)
-
-    def enable(self):
-        self.attributes |= SE_PRIVILEGE_ENABLED
-
-    def get_name(self):
-        size = wintypes.DWORD(10240)
-        buf = ctypes.create_unicode_buffer(size.value)
-        res = LookupPrivilegeName(None, self.LUID, buf, size)
-        if res == 0:
-            raise RuntimeError
-        return buf[:size.value]
-
-    def __str__(self):
-        name = self.name
-        fmt = ['{name}', '{name} (enabled)'][self.is_enabled()]
-        return fmt.format(**vars())
-
-LookupPrivilegeName = ctypes.windll.advapi32.LookupPrivilegeNameW
-LookupPrivilegeName.argtypes = (
-        wintypes.LPWSTR, # lpSystemName
-        ctypes.POINTER(LUID), # lpLuid
-        wintypes.LPWSTR, # lpName
-        ctypes.POINTER(wintypes.DWORD), #cchName
-        )
-LookupPrivilegeName.restype = wintypes.BOOL
-
-class TOKEN_PRIVILEGES(ctypes.Structure):
-    _fields_ = [
-            ('count', wintypes.DWORD),
-            ('privileges', LUID_AND_ATTRIBUTES*0),
-            ]
-
-    def get_array(self):
-        array_type = LUID_AND_ATTRIBUTES*self.count
-        privileges = ctypes.cast(self.privileges,
-                                 ctypes.POINTER(array_type)).contents
-        return privileges
-
-    def __iter__(self):
-        return iter(self.get_array())
-
-PTOKEN_PRIVILEGES = ctypes.POINTER(TOKEN_PRIVILEGES)
-
-GetTokenInformation = ctypes.windll.advapi32.GetTokenInformation
-GetTokenInformation.argtypes = [
-        wintypes.HANDLE, # TokenHandle
-        ctypes.c_uint, # TOKEN_INFORMATION_CLASS value
-        ctypes.c_void_p, # TokenInformation
-        wintypes.DWORD, # TokenInformationLength
-        ctypes.POINTER(wintypes.DWORD), # ReturnLength
-        ]
-GetTokenInformation.restype = wintypes.BOOL
-
-# http://msdn.microsoft.com/en-us/library/aa375202%28VS.85%29.aspx
-AdjustTokenPrivileges = ctypes.windll.advapi32.AdjustTokenPrivileges
-AdjustTokenPrivileges.restype = wintypes.BOOL
-AdjustTokenPrivileges.argtypes = [
-        wintypes.HANDLE,                # TokenHandle
-        wintypes.BOOL,                  # DisableAllPrivileges
-        PTOKEN_PRIVILEGES,              # NewState (optional)
-        wintypes.DWORD,                 # BufferLength of PreviousState
-        PTOKEN_PRIVILEGES,              # PreviousState (out, optional)
-        ctypes.POINTER(wintypes.DWORD), # ReturnLength
-        ]
-
-def get_process_token():
-    "Get the current process token"
-    token = wintypes.HANDLE()
-    TOKEN_ALL_ACCESS = 0xf01ff
-    res = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, token)
-    if not res > 0:
-        raise RuntimeError("Couldn't get process token")
-    return token
-
-def get_symlink_luid():
-    "Get the LUID for the SeCreateSymbolicLinkPrivilege"
-    symlink_luid = LUID()
-    res = LookupPrivilegeValue(None, "SeCreateSymbolicLinkPrivilege",
-                               symlink_luid)
-    if not res > 0:
-        raise RuntimeError("Couldn't lookup privilege value")
-    return symlink_luid
-
-def get_privilege_information():
-    "Get all privileges associated with the current process."
-    # first call with zero length to determine what size buffer we need
-
-    return_length = wintypes.DWORD()
-    params = [
-            get_process_token(),
-            TOKEN_INFORMATION_CLASS.TokenPrivileges,
-            None,
-            0,
-            return_length,
-            ]
-
-    res = GetTokenInformation(*params)
-
-    # assume we now have the necessary length in return_length
-
-    buffer = ctypes.create_string_buffer(return_length.value)
-    params[2] = buffer
-    params[3] = return_length.value
-
-    res = GetTokenInformation(*params)
-    assert res > 0, "Error in second GetTokenInformation (%d)" % res
-
-    privileges = ctypes.cast(buffer, ctypes.POINTER(TOKEN_PRIVILEGES)).contents
-    return privileges
-
-def report_privilege_information():
-    "Report all privilege information assigned to the current process."
-    privileges = get_privilege_information()
-    print("found {0} privileges".format(privileges.count))
-    tuple(map(print, privileges))
-
-def enable_symlink_privilege():
-    """
-    Try to assign the symlink privilege to the current process token.
-    Return True if the assignment is successful.
-    """
-    # create a space in memory for a TOKEN_PRIVILEGES structure
-    #  with one element
-    size = ctypes.sizeof(TOKEN_PRIVILEGES)
-    size += ctypes.sizeof(LUID_AND_ATTRIBUTES)
-    buffer = ctypes.create_string_buffer(size)
-    tp = ctypes.cast(buffer, ctypes.POINTER(TOKEN_PRIVILEGES)).contents
-    tp.count = 1
-    tp.get_array()[0].enable()
-    tp.get_array()[0].LUID = get_symlink_luid()
-    token = get_process_token()
-    res = AdjustTokenPrivileges(token, False, tp, 0, None, None)
-    if res == 0:
-        raise RuntimeError("Error in AdjustTokenPrivileges")
-
-    ERROR_NOT_ALL_ASSIGNED = 1300
-    return ctypes.windll.kernel32.GetLastError() != ERROR_NOT_ALL_ASSIGNED
-
-def main():
-    assigned = enable_symlink_privilege()
-    msg = ['failure', 'success'][assigned]
-
-    print("Symlink privilege assignment completed with {0}".format(msg))
-
-if __name__ == '__main__':
-    main()

Modified: python/branches/py3k-cdecimal/Lib/test/test_abc.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_abc.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_abc.py	Sun Jan  2 13:18:37 2011
@@ -192,8 +192,8 @@
     def test_register_non_class(self):
         class A(metaclass=abc.ABCMeta):
             pass
-        self.assertRaisesRegexp(TypeError, "Can only register classes",
-                                A.register, 4)
+        self.assertRaisesRegex(TypeError, "Can only register classes",
+                               A.register, 4)
 
     def test_registration_transitiveness(self):
         class A(metaclass=abc.ABCMeta):

Modified: python/branches/py3k-cdecimal/Lib/test/test_argparse.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_argparse.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_argparse.py	Sun Jan  2 13:18:37 2011
@@ -1708,7 +1708,8 @@
     def assertArgumentParserError(self, *args, **kwargs):
         self.assertRaises(ArgumentParserError, *args, **kwargs)
 
-    def _get_parser(self, subparser_help=False, prefix_chars=None):
+    def _get_parser(self, subparser_help=False, prefix_chars=None,
+                    aliases=False):
         # create a parser with a subparsers argument
         if prefix_chars:
             parser = ErrorRaisingArgumentParser(
@@ -1724,13 +1725,21 @@
             'bar', type=float, help='bar help')
 
         # check that only one subparsers argument can be added
-        subparsers = parser.add_subparsers(help='command help')
+        subparsers_kwargs = {}
+        if aliases:
+            subparsers_kwargs['metavar'] = 'COMMAND'
+            subparsers_kwargs['title'] = 'commands'
+        else:
+            subparsers_kwargs['help'] = 'command help'
+        subparsers = parser.add_subparsers(**subparsers_kwargs)
         self.assertArgumentParserError(parser.add_subparsers)
 
         # add first sub-parser
         parser1_kwargs = dict(description='1 description')
         if subparser_help:
             parser1_kwargs['help'] = '1 help'
+        if aliases:
+            parser1_kwargs['aliases'] = ['1alias1', '1alias2']
         parser1 = subparsers.add_parser('1', **parser1_kwargs)
         parser1.add_argument('-w', type=int, help='w help')
         parser1.add_argument('x', choices='abc', help='x help')
@@ -1947,6 +1956,44 @@
               -y {1,2,3}  y help
             '''))
 
+    def test_alias_invocation(self):
+        parser = self._get_parser(aliases=True)
+        self.assertEqual(
+            parser.parse_known_args('0.5 1alias1 b'.split()),
+            (NS(foo=False, bar=0.5, w=None, x='b'), []),
+        )
+        self.assertEqual(
+            parser.parse_known_args('0.5 1alias2 b'.split()),
+            (NS(foo=False, bar=0.5, w=None, x='b'), []),
+        )
+
+    def test_error_alias_invocation(self):
+        parser = self._get_parser(aliases=True)
+        self.assertArgumentParserError(parser.parse_args,
+                                       '0.5 1alias3 b'.split())
+
+    def test_alias_help(self):
+        parser = self._get_parser(aliases=True, subparser_help=True)
+        self.maxDiff = None
+        self.assertEqual(parser.format_help(), textwrap.dedent("""\
+            usage: PROG [-h] [--foo] bar COMMAND ...
+
+            main description
+
+            positional arguments:
+              bar                   bar help
+
+            optional arguments:
+              -h, --help            show this help message and exit
+              --foo                 foo help
+
+            commands:
+              COMMAND
+                1 (1alias1, 1alias2)
+                                    1 help
+                2                   2 help
+            """))
+
 # ============
 # Groups tests
 # ============
@@ -4315,7 +4362,7 @@
         items = [
             name
             for name, value in vars(argparse).items()
-            if not name.startswith("_")
+            if not (name.startswith("_") or name == 'ngettext')
             if not inspect.ismodule(value)
         ]
         self.assertEqual(sorted(items), sorted(argparse.__all__))

Modified: python/branches/py3k-cdecimal/Lib/test/test_array.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_array.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_array.py	Sun Jan  2 13:18:37 2011
@@ -22,7 +22,7 @@
 
 class ArraySubclassWithKwargs(array.array):
     def __init__(self, typecode, newarg=None):
-        array.array.__init__(typecode)
+        array.array.__init__(self, typecode)
 
 tests = [] # list to accumulate all tests
 typecodes = "ubBhHiIlLfd"
@@ -504,6 +504,12 @@
             array.array(self.typecode)
         )
 
+        a = 5 * array.array(self.typecode, self.example[:1])
+        self.assertEqual(
+            a,
+            array.array(self.typecode, [a[0]] * 5)
+        )
+
         self.assertRaises(TypeError, a.__mul__, "bad")
 
     def test_imul(self):

Modified: python/branches/py3k-cdecimal/Lib/test/test_asyncore.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_asyncore.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_asyncore.py	Sun Jan  2 13:18:37 2011
@@ -312,8 +312,8 @@
         d = asyncore.dispatcher(socket.socket())
         # make sure the error message no longer refers to the socket
         # object but the dispatcher instance instead
-        self.assertRaisesRegexp(AttributeError, 'dispatcher instance',
-                                getattr, d, 'foo')
+        self.assertRaisesRegex(AttributeError, 'dispatcher instance',
+                               getattr, d, 'foo')
         # cheap inheritance with the underlying socket is supposed
         # to still work but a DeprecationWarning is expected
         with warnings.catch_warnings(record=True) as w:

Modified: python/branches/py3k-cdecimal/Lib/test/test_bool.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_bool.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_bool.py	Sun Jan  2 13:18:37 2011
@@ -174,8 +174,8 @@
         self.assertIs(hasattr([], "wobble"), False)
 
     def test_callable(self):
-        self.assertIs(hasattr(len, '__call__'), True)
-        self.assertIs(hasattr(1, '__call__'), False)
+        self.assertIs(callable(len), True)
+        self.assertIs(callable(1), False)
 
     def test_isinstance(self):
         self.assertIs(isinstance(True, bool), True)

Modified: python/branches/py3k-cdecimal/Lib/test/test_builtin.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_builtin.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_builtin.py	Sun Jan  2 13:18:37 2011
@@ -6,6 +6,7 @@
 import warnings
 import collections
 import io
+import ast
 import types
 import builtins
 import random
@@ -207,22 +208,39 @@
         self.assertTrue(isinstance(x, int))
         self.assertEqual(-x, sys.maxsize+1)
 
-    # XXX(nnorwitz): This test case for callable should probably be removed.
     def test_callable(self):
-        self.assertTrue(hasattr(len, '__call__'))
+        self.assertTrue(callable(len))
+        self.assertFalse(callable("a"))
+        self.assertTrue(callable(callable))
+        self.assertTrue(callable(lambda x, y: x + y))
+        self.assertFalse(callable(__builtins__))
         def f(): pass
-        self.assertTrue(hasattr(f, '__call__'))
-        class C:
+        self.assertTrue(callable(f))
+
+        class C1:
             def meth(self): pass
-        self.assertTrue(hasattr(C, '__call__'))
-        x = C()
-        self.assertTrue(hasattr(x.meth, '__call__'))
-        self.assertTrue(not hasattr(x, '__call__'))
-        class D(C):
+        self.assertTrue(callable(C1))
+        c = C1()
+        self.assertTrue(callable(c.meth))
+        self.assertFalse(callable(c))
+
+        # __call__ is looked up on the class, not the instance
+        c.__call__ = None
+        self.assertFalse(callable(c))
+        c.__call__ = lambda self: 0
+        self.assertFalse(callable(c))
+        del c.__call__
+        self.assertFalse(callable(c))
+
+        class C2(object):
             def __call__(self): pass
-        y = D()
-        self.assertTrue(hasattr(y, '__call__'))
-        y()
+        c2 = C2()
+        self.assertTrue(callable(c2))
+        c2.__call__ = None
+        self.assertTrue(callable(c2))
+        class C3(C2): pass
+        c3 = C3()
+        self.assertTrue(callable(c3))
 
     def test_chr(self):
         self.assertEqual(chr(32), ' ')
@@ -268,6 +286,34 @@
         self.assertRaises(TypeError, compile, chr(0), 'f', 'exec')
         self.assertRaises(ValueError, compile, str('a = 1'), 'f', 'bad')
 
+        # test the optimize argument
+
+        codestr = '''def f():
+        """doc"""
+        try:
+            assert False
+        except AssertionError:
+            return (True, f.__doc__)
+        else:
+            return (False, f.__doc__)
+        '''
+        def f(): """doc"""
+        values = [(-1, __debug__, f.__doc__),
+                  (0, True, 'doc'),
+                  (1, False, 'doc'),
+                  (2, False, None)]
+        for optval, debugval, docstring in values:
+            # test both direct compilation and compilation via AST
+            codeobjs = []
+            codeobjs.append(compile(codestr, "<test>", "exec", optimize=optval))
+            tree = ast.parse(codestr)
+            codeobjs.append(compile(tree, "<test>", "exec", optimize=optval))
+            for code in codeobjs:
+                ns = {}
+                exec(code, ns)
+                rv = ns['f']()
+                self.assertEqual(rv, (debugval, docstring))
+
     def test_delattr(self):
         sys.spam = 1
         delattr(sys, 'spam')

Modified: python/branches/py3k-cdecimal/Lib/test/test_calendar.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_calendar.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_calendar.py	Sun Jan  2 13:18:37 2011
@@ -430,6 +430,26 @@
         with self.assertRaises(calendar.IllegalMonthError):
             calendar.monthrange(2004, 13)
 
+class LeapdaysTestCase(unittest.TestCase):
+    def test_no_range(self):
+        # test when no range i.e. two identical years as args
+        self.assertEqual(calendar.leapdays(2010,2010), 0)
+
+    def test_no_leapdays(self):
+        # test when no leap years in range
+        self.assertEqual(calendar.leapdays(2010,2011), 0)
+
+    def test_no_leapdays_upper_boundary(self):
+        # test no leap years in range, when upper boundary is a leap year
+        self.assertEqual(calendar.leapdays(2010,2012), 0)
+
+    def test_one_leapday_lower_boundary(self):
+        # test when one leap year in range, lower boundary is leap year
+        self.assertEqual(calendar.leapdays(2012,2013), 1)
+
+    def test_several_leapyears_in_range(self):
+        self.assertEqual(calendar.leapdays(1997,2020), 5)
+
 
 def test_main():
     support.run_unittest(
@@ -439,6 +459,7 @@
         SundayTestCase,
         TimegmTestCase,
         MonthRangeTestCase,
+        LeapdaysTestCase,
     )
 
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_cfgparser.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_cfgparser.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_cfgparser.py	Sun Jan  2 13:18:37 2011
@@ -2,8 +2,10 @@
 import configparser
 import io
 import os
-import unittest
+import sys
 import textwrap
+import unittest
+import warnings
 
 from test import support
 
@@ -28,10 +30,12 @@
     allow_no_value = False
     delimiters = ('=', ':')
     comment_prefixes = (';', '#')
+    inline_comment_prefixes = (';', '#')
     empty_lines_in_values = True
     dict_type = configparser._default_dict
     strict = False
     default_section = configparser.DEFAULTSECT
+    interpolation = configparser._UNSET
 
     def newconfig(self, defaults=None):
         arguments = dict(
@@ -39,12 +43,15 @@
             allow_no_value=self.allow_no_value,
             delimiters=self.delimiters,
             comment_prefixes=self.comment_prefixes,
+            inline_comment_prefixes=self.inline_comment_prefixes,
             empty_lines_in_values=self.empty_lines_in_values,
             dict_type=self.dict_type,
             strict=self.strict,
             default_section=self.default_section,
+            interpolation=self.interpolation,
         )
-        return self.config_class(**arguments)
+        instance = self.config_class(**arguments)
+        return instance
 
     def fromstring(self, string, defaults=None):
         cf = self.newconfig(defaults)
@@ -68,12 +75,16 @@
         if self.allow_no_value:
             E.append('NoValue')
         E.sort()
+        F = [('baz', 'qwe'), ('foo', 'bar3')]
 
         # API access
         L = cf.sections()
         L.sort()
         eq = self.assertEqual
         eq(L, E)
+        L = cf.items('Spacey Bar From The Beginning')
+        L.sort()
+        eq(L, F)
 
         # mapping access
         L = [section for section in cf]
@@ -81,6 +92,15 @@
         E.append(self.default_section)
         E.sort()
         eq(L, E)
+        L = cf['Spacey Bar From The Beginning'].items()
+        L = sorted(list(L))
+        eq(L, F)
+        L = cf.items()
+        L = sorted(list(L))
+        self.assertEqual(len(L), len(E))
+        for name, section in L:
+            eq(name, section.name)
+        eq(cf.defaults(), cf[self.default_section])
 
         # The use of spaces in the section names serves as a
         # regression test for SourceForge bug #583248:
@@ -100,6 +120,7 @@
         self.assertAlmostEqual(cf.getfloat('Types', 'float'), 0.44)
         eq(cf.get('Types', 'float'), "0.44")
         eq(cf.getboolean('Types', 'boolean'), False)
+        eq(cf.get('Types', '123'), 'strange but acceptable')
         if self.allow_no_value:
             eq(cf.get('NoValue', 'option-without-value'), None)
 
@@ -117,15 +138,21 @@
         eq(cf.getint('Types', 'int', fallback=18), 42)
         eq(cf.getint('Types', 'no-such-int', fallback=18), 18)
         eq(cf.getint('Types', 'no-such-int', fallback="18"), "18") # sic!
+        with self.assertRaises(configparser.NoOptionError):
+            cf.getint('Types', 'no-such-int')
         self.assertAlmostEqual(cf.getfloat('Types', 'float',
                                            fallback=0.0), 0.44)
         self.assertAlmostEqual(cf.getfloat('Types', 'no-such-float',
                                            fallback=0.0), 0.0)
         eq(cf.getfloat('Types', 'no-such-float', fallback="0.0"), "0.0") # sic!
+        with self.assertRaises(configparser.NoOptionError):
+            cf.getfloat('Types', 'no-such-float')
         eq(cf.getboolean('Types', 'boolean', fallback=True), False)
         eq(cf.getboolean('Types', 'no-such-boolean', fallback="yes"),
            "yes") # sic!
         eq(cf.getboolean('Types', 'no-such-boolean', fallback=True), True)
+        with self.assertRaises(configparser.NoOptionError):
+            cf.getboolean('Types', 'no-such-boolean')
         eq(cf.getboolean('No Such Types', 'boolean', fallback=True), True)
         if self.allow_no_value:
             eq(cf.get('NoValue', 'option-without-value', fallback=False), None)
@@ -152,11 +179,65 @@
            'this line is much, much longer than my editor\nlikes it.')
         if self.allow_no_value:
             eq(cf['NoValue']['option-without-value'], None)
+        # test vars= and fallback=
+        eq(cf['Foo Bar'].get('foo', 'baz'), 'bar1')
+        eq(cf['Foo Bar'].get('foo', fallback='baz'), 'bar1')
+        eq(cf['Foo Bar'].get('foo', vars={'foo': 'baz'}), 'baz')
+        with self.assertRaises(KeyError):
+            cf['No Such Foo Bar']['foo']
+        with self.assertRaises(KeyError):
+            cf['Foo Bar']['no-such-foo']
+        with self.assertRaises(KeyError):
+            cf['No Such Foo Bar'].get('foo', fallback='baz')
+        eq(cf['Foo Bar'].get('no-such-foo', 'baz'), 'baz')
+        eq(cf['Foo Bar'].get('no-such-foo', fallback='baz'), 'baz')
+        eq(cf['Foo Bar'].get('no-such-foo'), None)
+        eq(cf['Spacey Bar'].get('foo', None), 'bar2')
+        eq(cf['Spacey Bar'].get('foo', fallback=None), 'bar2')
+        with self.assertRaises(KeyError):
+            cf['No Such Spacey Bar'].get('foo', None)
+        eq(cf['Types'].getint('int', 18), 42)
+        eq(cf['Types'].getint('int', fallback=18), 42)
+        eq(cf['Types'].getint('no-such-int', 18), 18)
+        eq(cf['Types'].getint('no-such-int', fallback=18), 18)
+        eq(cf['Types'].getint('no-such-int', "18"), "18") # sic!
+        eq(cf['Types'].getint('no-such-int', fallback="18"), "18") # sic!
+        eq(cf['Types'].getint('no-such-int'), None)
+        self.assertAlmostEqual(cf['Types'].getfloat('float', 0.0), 0.44)
+        self.assertAlmostEqual(cf['Types'].getfloat('float',
+                                                    fallback=0.0), 0.44)
+        self.assertAlmostEqual(cf['Types'].getfloat('no-such-float', 0.0), 0.0)
+        self.assertAlmostEqual(cf['Types'].getfloat('no-such-float',
+                                                    fallback=0.0), 0.0)
+        eq(cf['Types'].getfloat('no-such-float', "0.0"), "0.0") # sic!
+        eq(cf['Types'].getfloat('no-such-float', fallback="0.0"), "0.0") # sic!
+        eq(cf['Types'].getfloat('no-such-float'), None)
+        eq(cf['Types'].getboolean('boolean', True), False)
+        eq(cf['Types'].getboolean('boolean', fallback=True), False)
+        eq(cf['Types'].getboolean('no-such-boolean', "yes"), "yes") # sic!
+        eq(cf['Types'].getboolean('no-such-boolean', fallback="yes"),
+           "yes") # sic!
+        eq(cf['Types'].getboolean('no-such-boolean', True), True)
+        eq(cf['Types'].getboolean('no-such-boolean', fallback=True), True)
+        eq(cf['Types'].getboolean('no-such-boolean'), None)
+        if self.allow_no_value:
+            eq(cf['NoValue'].get('option-without-value', False), None)
+            eq(cf['NoValue'].get('option-without-value', fallback=False), None)
+            eq(cf['NoValue'].get('no-such-option-without-value', False), False)
+            eq(cf['NoValue'].get('no-such-option-without-value',
+                      fallback=False), False)
+
+        # Make sure the right things happen for remove_section() and
+        # remove_option(); added to include check for SourceForge bug #123324.
 
-        # Make sure the right things happen for remove_option();
-        # added to include check for SourceForge bug #123324:
+        cf[self.default_section]['this_value'] = '1'
+        cf[self.default_section]['that_value'] = '2'
 
-        # API acceess
+        # API access
+        self.assertTrue(cf.remove_section('Spaces'))
+        self.assertFalse(cf.has_option('Spaces', 'key with spaces'))
+        self.assertFalse(cf.remove_section('Spaces'))
+        self.assertFalse(cf.remove_section(self.default_section))
         self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
                         "remove_option() failed to report existence of option")
         self.assertFalse(cf.has_option('Foo Bar', 'foo'),
@@ -164,6 +245,11 @@
         self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
                     "remove_option() failed to report non-existence of option"
                     " that was removed")
+        self.assertTrue(cf.has_option('Foo Bar', 'this_value'))
+        self.assertFalse(cf.remove_option('Foo Bar', 'this_value'))
+        self.assertTrue(cf.remove_option(self.default_section, 'this_value'))
+        self.assertFalse(cf.has_option('Foo Bar', 'this_value'))
+        self.assertFalse(cf.remove_option(self.default_section, 'this_value'))
 
         with self.assertRaises(configparser.NoSectionError) as cm:
             cf.remove_option('No Such Section', 'foo')
@@ -173,13 +259,29 @@
            'this line is much, much longer than my editor\nlikes it.')
 
         # mapping access
+        del cf['Types']
+        self.assertFalse('Types' in cf)
+        with self.assertRaises(KeyError):
+            del cf['Types']
+        with self.assertRaises(ValueError):
+            del cf[self.default_section]
         del cf['Spacey Bar']['foo']
         self.assertFalse('foo' in cf['Spacey Bar'])
         with self.assertRaises(KeyError):
             del cf['Spacey Bar']['foo']
+        self.assertTrue('that_value' in cf['Spacey Bar'])
+        with self.assertRaises(KeyError):
+            del cf['Spacey Bar']['that_value']
+        del cf[self.default_section]['that_value']
+        self.assertFalse('that_value' in cf['Spacey Bar'])
+        with self.assertRaises(KeyError):
+            del cf[self.default_section]['that_value']
         with self.assertRaises(KeyError):
             del cf['No Such Section']['foo']
 
+        # Don't add new asserts below in this method as most of the options
+        # and sections are now removed.
+
     def test_basic(self):
         config_string = """\
 [Foo Bar]
@@ -208,6 +310,7 @@
 int {0[1]} 42
 float {0[0]} 0.44
 boolean {0[0]} NO
+123 {0[1]} strange but acceptable
 """.format(self.delimiters, self.comment_prefixes)
         if self.allow_no_value:
             config_string += (
@@ -280,6 +383,7 @@
                 "int": 42,
                 "float": 0.44,
                 "boolean": False,
+                123: "strange but acceptable",
             },
         }
         if self.allow_no_value:
@@ -292,6 +396,11 @@
         cf.read_dict(config)
         self.basic_test(cf)
         if self.strict:
+            with self.assertRaises(configparser.DuplicateSectionError):
+                cf.read_dict({
+                    '1': {'key': 'value'},
+                    1: {'key2': 'value2'},
+                })
             with self.assertRaises(configparser.DuplicateOptionError):
                 cf.read_dict({
                     "Duplicate Options Here": {
@@ -301,13 +410,16 @@
                 })
         else:
             cf.read_dict({
+                'section': {'key': 'value'},
+                'SECTION': {'key2': 'value2'},
+            })
+            cf.read_dict({
                 "Duplicate Options Here": {
                     'option': 'with a value',
                     'OPTION': 'with another value',
                 },
             })
 
-
     def test_case_sensitivity(self):
         cf = self.newconfig()
         cf.add_section("A")
@@ -325,6 +437,7 @@
             # section names are case-sensitive
             cf.set("b", "A", "value")
         self.assertTrue(cf.has_option("a", "b"))
+        self.assertFalse(cf.has_option("b", "b"))
         cf.set("A", "A-B", "A-B value")
         for opt in ("a-b", "A-b", "a-B", "A-B"):
             self.assertTrue(
@@ -357,7 +470,7 @@
         L = [section for section in cf]
         L.sort()
         eq = self.assertEqual
-        elem_eq = self.assertItemsEqual
+        elem_eq = self.assertCountEqual
         eq(L, sorted(["A", "B", self.default_section, "a"]))
         eq(cf["a"].keys(), {"b"})
         eq(cf["a"]["b"], "value",
@@ -541,32 +654,36 @@
             )
 
         cf = self.fromstring(config_string)
-        output = io.StringIO()
-        cf.write(output)
-        expect_string = (
-            "[{default_section}]\n"
-            "foo {equals} another very\n"
-            "\tlong line\n"
-            "\n"
-            "[Long Line]\n"
-            "foo {equals} this line is much, much longer than my editor\n"
-            "\tlikes it.\n"
-            "\n"
-            "[Long Line - With Comments!]\n"
-            "test {equals} we\n"
-            "\talso\n"
-            "\tcomments\n"
-            "\tmultiline\n"
-            "\n".format(equals=self.delimiters[0],
-                        default_section=self.default_section)
-            )
-        if self.allow_no_value:
-            expect_string += (
-                "[Valueless]\n"
-                "option-without-value\n"
+        for space_around_delimiters in (True, False):
+            output = io.StringIO()
+            cf.write(output, space_around_delimiters=space_around_delimiters)
+            delimiter = self.delimiters[0]
+            if space_around_delimiters:
+                delimiter = " {} ".format(delimiter)
+            expect_string = (
+                "[{default_section}]\n"
+                "foo{equals}another very\n"
+                "\tlong line\n"
+                "\n"
+                "[Long Line]\n"
+                "foo{equals}this line is much, much longer than my editor\n"
+                "\tlikes it.\n"
                 "\n"
+                "[Long Line - With Comments!]\n"
+                "test{equals}we\n"
+                "\talso\n"
+                "\tcomments\n"
+                "\tmultiline\n"
+                "\n".format(equals=delimiter,
+                            default_section=self.default_section)
                 )
-        self.assertEqual(output.getvalue(), expect_string)
+            if self.allow_no_value:
+                expect_string += (
+                    "[Valueless]\n"
+                    "option-without-value\n"
+                    "\n"
+                    )
+            self.assertEqual(output.getvalue(), expect_string)
 
     def test_set_string_types(self):
         cf = self.fromstring("[sect]\n"
@@ -635,15 +752,17 @@
             "name{equals}%(reference)s\n".format(equals=self.delimiters[0]))
 
     def check_items_config(self, expected):
-        cf = self.fromstring(
-            "[section]\n"
-            "name {0[0]} value\n"
-            "key{0[1]} |%(name)s| \n"
-            "getdefault{0[1]} |%(default)s|\n".format(self.delimiters),
-            defaults={"default": "<default>"})
-        L = list(cf.items("section"))
+        cf = self.fromstring("""
+            [section]
+            name {0[0]} %(value)s
+            key{0[1]} |%(name)s|
+            getdefault{0[1]} |%(default)s|
+        """.format(self.delimiters), defaults={"default": "<default>"})
+        L = list(cf.items("section", vars={'value': 'value'}))
         L.sort()
         self.assertEqual(L, expected)
+        with self.assertRaises(configparser.NoSectionError):
+            cf.items("no such section")
 
 
 class StrictTestCase(BasicTestCase):
@@ -655,11 +774,6 @@
     config_class = configparser.ConfigParser
 
     def test_interpolation(self):
-        rawval = {
-            configparser.ConfigParser: ("something %(with11)s "
-                                        "lots of interpolation (11 steps)"),
-            configparser.SafeConfigParser: "%(with1)s",
-        }
         cf = self.get_interpolation_config()
         eq = self.assertEqual
         eq(cf.get("Foo", "bar"), "something with interpolation (1 step)")
@@ -668,52 +782,107 @@
         eq(cf.get("Foo", "bar10"),
            "something with lots of interpolation (10 steps)")
         e = self.get_error(cf, configparser.InterpolationDepthError, "Foo", "bar11")
-        self.assertEqual(e.args, ("bar11", "Foo", rawval[self.config_class]))
+        if self.interpolation == configparser._UNSET:
+            self.assertEqual(e.args, ("bar11", "Foo", "%(with1)s"))
+        elif isinstance(self.interpolation, configparser.LegacyInterpolation):
+            self.assertEqual(e.args, ("bar11", "Foo",
+                "something %(with11)s lots of interpolation (11 steps)"))
 
     def test_interpolation_missing_value(self):
-        rawval = {
-            configparser.ConfigParser: '%(reference)s',
-            configparser.SafeConfigParser: '',
-        }
         cf = self.get_interpolation_config()
         e = self.get_error(cf, configparser.InterpolationMissingOptionError,
                            "Interpolation Error", "name")
         self.assertEqual(e.reference, "reference")
         self.assertEqual(e.section, "Interpolation Error")
         self.assertEqual(e.option, "name")
-        self.assertEqual(e.args, ('name', 'Interpolation Error',
-                                  rawval[self.config_class], 'reference'))
+        if self.interpolation == configparser._UNSET:
+            self.assertEqual(e.args, ('name', 'Interpolation Error',
+                                    '', 'reference'))
+        elif isinstance(self.interpolation, configparser.LegacyInterpolation):
+            self.assertEqual(e.args, ('name', 'Interpolation Error',
+                                    '%(reference)s', 'reference'))
 
     def test_items(self):
         self.check_items_config([('default', '<default>'),
                                  ('getdefault', '|<default>|'),
                                  ('key', '|value|'),
-                                 ('name', 'value')])
+                                 ('name', 'value'),
+                                 ('value', 'value')])
+
+    def test_safe_interpolation(self):
+        # See http://www.python.org/sf/511737
+        cf = self.fromstring("[section]\n"
+                             "option1{eq}xxx\n"
+                             "option2{eq}%(option1)s/xxx\n"
+                             "ok{eq}%(option1)s/%%s\n"
+                             "not_ok{eq}%(option2)s/%%s".format(
+                                 eq=self.delimiters[0]))
+        self.assertEqual(cf.get("section", "ok"), "xxx/%s")
+        if self.interpolation == configparser._UNSET:
+            self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
+        elif isinstance(self.interpolation, configparser.LegacyInterpolation):
+            with self.assertRaises(TypeError):
+                cf.get("section", "not_ok")
+
+    def test_set_malformatted_interpolation(self):
+        cf = self.fromstring("[sect]\n"
+                             "option1{eq}foo\n".format(eq=self.delimiters[0]))
+
+        self.assertEqual(cf.get('sect', "option1"), "foo")
+
+        self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
+        self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
+        self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
+
+        self.assertEqual(cf.get('sect', "option1"), "foo")
+
+        # bug #5741: double percents are *not* malformed
+        cf.set("sect", "option2", "foo%%bar")
+        self.assertEqual(cf.get("sect", "option2"), "foo%bar")
 
     def test_set_nonstring_types(self):
+        cf = self.fromstring("[sect]\n"
+                             "option1{eq}foo\n".format(eq=self.delimiters[0]))
+        # Check that we get a TypeError when setting non-string values
+        # in an existing section:
+        self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
+        self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
+        self.assertRaises(TypeError, cf.set, "sect", "option1", object())
+        self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
+        self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
+        self.assertRaises(TypeError, cf.set, "sect", "option2", object())
+        self.assertRaises(TypeError, cf.set, "sect", 123, "invalid opt name!")
+        self.assertRaises(TypeError, cf.add_section, 123)
+
+    def test_add_section_default(self):
         cf = self.newconfig()
-        cf.add_section('non-string')
-        cf.set('non-string', 'int', 1)
-        cf.set('non-string', 'list', [0, 1, 1, 2, 3, 5, 8, 13, '%('])
-        cf.set('non-string', 'dict', {'pi': 3.14159, '%(': 1,
-                                      '%(list)': '%(list)'})
-        cf.set('non-string', 'string_with_interpolation', '%(list)s')
-        self.assertEqual(cf.get('non-string', 'int', raw=True), 1)
-        self.assertRaises(TypeError, cf.get, 'non-string', 'int')
-        self.assertEqual(cf.get('non-string', 'list', raw=True),
-                         [0, 1, 1, 2, 3, 5, 8, 13, '%('])
-        self.assertRaises(TypeError, cf.get, 'non-string', 'list')
-        self.assertEqual(cf.get('non-string', 'dict', raw=True),
-                         {'pi': 3.14159, '%(': 1, '%(list)': '%(list)'})
-        self.assertRaises(TypeError, cf.get, 'non-string', 'dict')
-        self.assertEqual(cf.get('non-string', 'string_with_interpolation',
-                                raw=True), '%(list)s')
-        self.assertRaises(ValueError, cf.get, 'non-string',
-                          'string_with_interpolation', raw=False)
+        self.assertRaises(ValueError, cf.add_section, self.default_section)
+
+class ConfigParserTestCaseLegacyInterpolation(ConfigParserTestCase):
+    config_class = configparser.ConfigParser
+    interpolation = configparser.LegacyInterpolation()
+
+    def test_set_malformatted_interpolation(self):
+        cf = self.fromstring("[sect]\n"
+                             "option1{eq}foo\n".format(eq=self.delimiters[0]))
+
+        self.assertEqual(cf.get('sect', "option1"), "foo")
+
+        cf.set("sect", "option1", "%foo")
+        self.assertEqual(cf.get('sect', "option1"), "%foo")
+        cf.set("sect", "option1", "foo%")
+        self.assertEqual(cf.get('sect', "option1"), "foo%")
+        cf.set("sect", "option1", "f%oo")
+        self.assertEqual(cf.get('sect', "option1"), "f%oo")
+
+        # bug #5741: double percents are *not* malformed
+        cf.set("sect", "option2", "foo%%bar")
+        self.assertEqual(cf.get("sect", "option2"), "foo%%bar")
 
 class ConfigParserTestCaseNonStandardDelimiters(ConfigParserTestCase):
     delimiters = (':=', '$')
     comment_prefixes = ('//', '"')
+    inline_comment_prefixes = ('//', '"')
 
 class ConfigParserTestCaseNonStandardDefaultSection(ConfigParserTestCase):
     default_section = 'general'
@@ -765,7 +934,8 @@
         self.check_items_config([('default', '<default>'),
                                  ('getdefault', '|%(default)s|'),
                                  ('key', '|%(name)s|'),
-                                 ('name', 'value')])
+                                 ('name', '%(value)s'),
+                                 ('value', 'value')])
 
     def test_set_nonstring_types(self):
         cf = self.newconfig()
@@ -777,14 +947,25 @@
         self.assertEqual(cf.get('non-string', 'list'),
                          [0, 1, 1, 2, 3, 5, 8, 13])
         self.assertEqual(cf.get('non-string', 'dict'), {'pi': 3.14159})
+        cf.add_section(123)
+        cf.set(123, 'this is sick', True)
+        self.assertEqual(cf.get(123, 'this is sick'), True)
+        if cf._dict.__class__ is configparser._default_dict:
+            # would not work for SortedDict; only checking for the most common
+            # default dictionary (OrderedDict)
+            cf.optionxform = lambda x: x
+            cf.set('non-string', 1, 1)
+            self.assertEqual(cf.get('non-string', 1), 1)
 
 class RawConfigParserTestCaseNonStandardDelimiters(RawConfigParserTestCase):
     delimiters = (':=', '$')
     comment_prefixes = ('//', '"')
+    inline_comment_prefixes = ('//', '"')
 
-class RawConfigParserTestSambaConf(BasicTestCase):
+class RawConfigParserTestSambaConf(CfgParserTestCaseClass):
     config_class = configparser.RawConfigParser
-    comment_prefixes = ('#', ';', '//', '----')
+    comment_prefixes = ('#', ';', '----')
+    inline_comment_prefixes = ('//',)
     empty_lines_in_values = False
 
     def test_reading(self):
@@ -801,61 +982,124 @@
         self.assertEqual(cf.get("global", "hosts allow"), "127.")
         self.assertEqual(cf.get("tmp", "echo command"), "cat %s; rm %s")
 
-class SafeConfigParserTestCase(ConfigParserTestCase):
-    config_class = configparser.SafeConfigParser
-
-    def test_safe_interpolation(self):
-        # See http://www.python.org/sf/511737
-        cf = self.fromstring("[section]\n"
-                             "option1{eq}xxx\n"
-                             "option2{eq}%(option1)s/xxx\n"
-                             "ok{eq}%(option1)s/%%s\n"
-                             "not_ok{eq}%(option2)s/%%s".format(
-                                 eq=self.delimiters[0]))
-        self.assertEqual(cf.get("section", "ok"), "xxx/%s")
-        self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
-
-    def test_set_malformatted_interpolation(self):
-        cf = self.fromstring("[sect]\n"
-                             "option1{eq}foo\n".format(eq=self.delimiters[0]))
-
-        self.assertEqual(cf.get('sect', "option1"), "foo")
-
-        self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
-        self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
-        self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
+class ConfigParserTestCaseExtendedInterpolation(BasicTestCase):
+    config_class = configparser.ConfigParser
+    interpolation = configparser.ExtendedInterpolation()
+    default_section = 'common'
 
-        self.assertEqual(cf.get('sect', "option1"), "foo")
+    def test_extended_interpolation(self):
+        cf = self.fromstring(textwrap.dedent("""
+            [common]
+            favourite Beatle = Paul
+            favourite color = green
+
+            [tom]
+            favourite band = ${favourite color} day
+            favourite pope = John ${favourite Beatle} II
+            sequel = ${favourite pope}I
+
+            [ambv]
+            favourite Beatle = George
+            son of Edward VII = ${favourite Beatle} V
+            son of George V = ${son of Edward VII}I
+
+            [stanley]
+            favourite Beatle = ${ambv:favourite Beatle}
+            favourite pope = ${tom:favourite pope}
+            favourite color = black
+            favourite state of mind = paranoid
+            favourite movie = soylent ${common:favourite color}
+            favourite song = ${favourite color} sabbath - ${favourite state of mind}
+        """).strip())
 
-        # bug #5741: double percents are *not* malformed
-        cf.set("sect", "option2", "foo%%bar")
-        self.assertEqual(cf.get("sect", "option2"), "foo%bar")
+        eq = self.assertEqual
+        eq(cf['common']['favourite Beatle'], 'Paul')
+        eq(cf['common']['favourite color'], 'green')
+        eq(cf['tom']['favourite Beatle'], 'Paul')
+        eq(cf['tom']['favourite color'], 'green')
+        eq(cf['tom']['favourite band'], 'green day')
+        eq(cf['tom']['favourite pope'], 'John Paul II')
+        eq(cf['tom']['sequel'], 'John Paul III')
+        eq(cf['ambv']['favourite Beatle'], 'George')
+        eq(cf['ambv']['favourite color'], 'green')
+        eq(cf['ambv']['son of Edward VII'], 'George V')
+        eq(cf['ambv']['son of George V'], 'George VI')
+        eq(cf['stanley']['favourite Beatle'], 'George')
+        eq(cf['stanley']['favourite color'], 'black')
+        eq(cf['stanley']['favourite state of mind'], 'paranoid')
+        eq(cf['stanley']['favourite movie'], 'soylent green')
+        eq(cf['stanley']['favourite pope'], 'John Paul II')
+        eq(cf['stanley']['favourite song'],
+           'black sabbath - paranoid')
+
+    def test_endless_loop(self):
+        cf = self.fromstring(textwrap.dedent("""
+            [one for you]
+            ping = ${one for me:pong}
+
+            [one for me]
+            pong = ${one for you:ping}
+
+            [selfish]
+            me = ${me}
+        """).strip())
+
+        with self.assertRaises(configparser.InterpolationDepthError):
+            cf['one for you']['ping']
+        with self.assertRaises(configparser.InterpolationDepthError):
+            cf['selfish']['me']
+
+    def test_strange_options(self):
+        cf = self.fromstring("""
+            [dollars]
+            $var = $$value
+            $var2 = ${$var}
+            ${sick} = cannot interpolate me
+
+            [interpolated]
+            $other = ${dollars:$var}
+            $trying = ${dollars:${sick}}
+        """)
 
-    def test_set_nonstring_types(self):
-        cf = self.fromstring("[sect]\n"
-                             "option1{eq}foo\n".format(eq=self.delimiters[0]))
-        # Check that we get a TypeError when setting non-string values
-        # in an existing section:
-        self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
-        self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
-        self.assertRaises(TypeError, cf.set, "sect", "option1", object())
-        self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
-        self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
-        self.assertRaises(TypeError, cf.set, "sect", "option2", object())
+        self.assertEqual(cf['dollars']['$var'], '$value')
+        self.assertEqual(cf['interpolated']['$other'], '$value')
+        self.assertEqual(cf['dollars']['${sick}'], 'cannot interpolate me')
+        exception_class = configparser.InterpolationMissingOptionError
+        with self.assertRaises(exception_class) as cm:
+            cf['interpolated']['$trying']
+        self.assertEqual(cm.exception.reference, 'dollars:${sick')
+        self.assertEqual(cm.exception.args[2], '}') #rawval
+
+
+    def test_other_errors(self):
+        cf = self.fromstring("""
+            [interpolation fail]
+            case1 = ${where's the brace
+            case2 = ${does_not_exist}
+            case3 = ${wrong_section:wrong_value}
+            case4 = ${i:like:colon:characters}
+            case5 = $100 for Fail No 5!
+        """)
 
-    def test_add_section_default(self):
-        cf = self.newconfig()
-        self.assertRaises(ValueError, cf.add_section, self.default_section)
+        with self.assertRaises(configparser.InterpolationSyntaxError):
+            cf['interpolation fail']['case1']
+        with self.assertRaises(configparser.InterpolationMissingOptionError):
+            cf['interpolation fail']['case2']
+        with self.assertRaises(configparser.InterpolationMissingOptionError):
+            cf['interpolation fail']['case3']
+        with self.assertRaises(configparser.InterpolationSyntaxError):
+            cf['interpolation fail']['case4']
+        with self.assertRaises(configparser.InterpolationSyntaxError):
+            cf['interpolation fail']['case5']
+        with self.assertRaises(ValueError):
+            cf['interpolation fail']['case6'] = "BLACK $ABBATH"
 
-class SafeConfigParserTestCaseNonStandardDelimiters(SafeConfigParserTestCase):
-    delimiters = (':=', '$')
-    comment_prefixes = ('//', '"')
 
-class SafeConfigParserTestCaseNoValue(SafeConfigParserTestCase):
+class ConfigParserTestCaseNoValue(ConfigParserTestCase):
     allow_no_value = True
 
-class SafeConfigParserTestCaseTrickyFile(CfgParserTestCaseClass):
-    config_class = configparser.SafeConfigParser
+class ConfigParserTestCaseTrickyFile(CfgParserTestCaseClass):
+    config_class = configparser.ConfigParser
     delimiters = {'='}
     comment_prefixes = {'#'}
     allow_no_value = True
@@ -918,8 +1162,10 @@
         return sio.getvalue()
 
     def test_none_as_value_stringified(self):
-        output = self.prepare(configparser.ConfigParser)
-        self.assertEqual(output, self.expected_output)
+        cp = configparser.ConfigParser(allow_no_value=False)
+        cp.add_section("section")
+        with self.assertRaises(TypeError):
+            cp.set("section", "option", None)
 
     def test_none_as_value_stringified_raw(self):
         output = self.prepare(configparser.RawConfigParser)
@@ -951,7 +1197,8 @@
 
 class CompatibleTestCase(CfgParserTestCaseClass):
     config_class = configparser.RawConfigParser
-    comment_prefixes = configparser._COMPATIBLE
+    comment_prefixes = '#;'
+    inline_comment_prefixes = ';'
 
     def test_comment_handling(self):
         config_string = textwrap.dedent("""\
@@ -964,30 +1211,132 @@
         ; a space must precede an inline comment
         """)
         cf = self.fromstring(config_string)
-        self.assertEqual(cf.get('Commented Bar', 'foo'), 'bar # not a comment!')
+        self.assertEqual(cf.get('Commented Bar', 'foo'),
+                         'bar # not a comment!')
         self.assertEqual(cf.get('Commented Bar', 'baz'), 'qwe')
-        self.assertEqual(cf.get('Commented Bar', 'quirk'), 'this;is not a comment')
+        self.assertEqual(cf.get('Commented Bar', 'quirk'),
+                         'this;is not a comment')
 
+class CopyTestCase(BasicTestCase):
+    config_class = configparser.ConfigParser
+
+    def fromstring(self, string, defaults=None):
+        cf = self.newconfig(defaults)
+        cf.read_string(string)
+        cf_copy = self.newconfig()
+        cf_copy.read_dict(cf)
+        # we have to clean up option duplicates that appeared because of
+        # the magic DEFAULTSECT behaviour.
+        for section in cf_copy.values():
+            if section.name == self.default_section:
+                continue
+            for default, value in cf[self.default_section].items():
+                if section[default] == value:
+                    del section[default]
+        return cf_copy
+
+class CoverageOneHundredTestCase(unittest.TestCase):
+    """Covers edge cases in the codebase."""
+
+    def test_duplicate_option_error(self):
+        error = configparser.DuplicateOptionError('section', 'option')
+        self.assertEqual(error.section, 'section')
+        self.assertEqual(error.option, 'option')
+        self.assertEqual(error.source, None)
+        self.assertEqual(error.lineno, None)
+        self.assertEqual(error.args, ('section', 'option', None, None))
+        self.assertEqual(str(error), "Option 'option' in section 'section' "
+                                     "already exists")
+
+    def test_interpolation_depth_error(self):
+        error = configparser.InterpolationDepthError('option', 'section',
+                                                     'rawval')
+        self.assertEqual(error.args, ('option', 'section', 'rawval'))
+        self.assertEqual(error.option, 'option')
+        self.assertEqual(error.section, 'section')
+
+    def test_parsing_error(self):
+        with self.assertRaises(ValueError) as cm:
+            configparser.ParsingError()
+        self.assertEqual(str(cm.exception), "Required argument `source' not "
+                                            "given.")
+        with self.assertRaises(ValueError) as cm:
+            configparser.ParsingError(source='source', filename='filename')
+        self.assertEqual(str(cm.exception), "Cannot specify both `filename' "
+                                            "and `source'. Use `source'.")
+        error = configparser.ParsingError(filename='source')
+        self.assertEqual(error.source, 'source')
+        with warnings.catch_warnings(record=True) as w:
+            warnings.simplefilter("always", DeprecationWarning)
+            self.assertEqual(error.filename, 'source')
+            error.filename = 'filename'
+            self.assertEqual(error.source, 'filename')
+        for warning in w:
+            self.assertTrue(warning.category is DeprecationWarning)
+
+    def test_interpolation_validation(self):
+        parser = configparser.ConfigParser()
+        parser.read_string("""
+            [section]
+            invalid_percent = %
+            invalid_reference = %(()
+            invalid_variable = %(does_not_exist)s
+        """)
+        with self.assertRaises(configparser.InterpolationSyntaxError) as cm:
+            parser['section']['invalid_percent']
+        self.assertEqual(str(cm.exception), "'%' must be followed by '%' or "
+                                            "'(', found: '%'")
+        with self.assertRaises(configparser.InterpolationSyntaxError) as cm:
+            parser['section']['invalid_reference']
+        self.assertEqual(str(cm.exception), "bad interpolation variable "
+                                            "reference '%(()'")
+
+    def test_readfp_deprecation(self):
+        sio = io.StringIO("""
+        [section]
+        option = value
+        """)
+        parser = configparser.ConfigParser()
+        with warnings.catch_warnings(record=True) as w:
+            warnings.simplefilter("always", DeprecationWarning)
+            parser.readfp(sio, filename='StringIO')
+        for warning in w:
+            self.assertTrue(warning.category is DeprecationWarning)
+        self.assertEqual(len(parser), 2)
+        self.assertEqual(parser['section']['option'], 'value')
+
+    def test_safeconfigparser_deprecation(self):
+        with warnings.catch_warnings(record=True) as w:
+            warnings.simplefilter("always", DeprecationWarning)
+            parser = configparser.SafeConfigParser()
+        for warning in w:
+            self.assertTrue(warning.category is DeprecationWarning)
+
+    def test_sectionproxy_repr(self):
+        parser = configparser.ConfigParser()
+        parser.read_string("""
+            [section]
+            key = value
+        """)
+        self.assertEqual(repr(parser['section']), '<Section: section>')
 
 def test_main():
     support.run_unittest(
         ConfigParserTestCase,
         ConfigParserTestCaseNonStandardDelimiters,
+        ConfigParserTestCaseNoValue,
+        ConfigParserTestCaseExtendedInterpolation,
+        ConfigParserTestCaseLegacyInterpolation,
+        ConfigParserTestCaseTrickyFile,
         MultilineValuesTestCase,
         RawConfigParserTestCase,
         RawConfigParserTestCaseNonStandardDelimiters,
         RawConfigParserTestSambaConf,
-        SafeConfigParserTestCase,
-        SafeConfigParserTestCaseNonStandardDelimiters,
-        SafeConfigParserTestCaseNoValue,
-        SafeConfigParserTestCaseTrickyFile,
         SortedTestCase,
         Issue7005TestCase,
         StrictTestCase,
         CompatibleTestCase,
+        CopyTestCase,
         ConfigParserTestCaseNonStandardDefaultSection,
+        CoverageOneHundredTestCase,
         )
-
-
-if __name__ == "__main__":
-    test_main()

Modified: python/branches/py3k-cdecimal/Lib/test/test_cgi.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_cgi.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_cgi.py	Sun Jan  2 13:18:37 2011
@@ -131,7 +131,7 @@
             if isinstance(expect, dict):
                 # test dict interface
                 self.assertEqual(len(expect), len(fs))
-                self.assertItemsEqual(expect.keys(), fs.keys())
+                self.assertCountEqual(expect.keys(), fs.keys())
                 ##self.assertEqual(norm(expect.values()), norm(fs.values()))
                 ##self.assertEqual(norm(expect.items()), norm(fs.items()))
                 self.assertEqual(fs.getvalue("nonexistent field", "default"), "default")

Modified: python/branches/py3k-cdecimal/Lib/test/test_cmath.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_cmath.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_cmath.py	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,5 @@
-from test.support import run_unittest
-from test.test_math import parse_testfile, test_file, requires_IEEE_754
+from test.support import run_unittest, requires_IEEE_754
+from test.test_math import parse_testfile, test_file
 import unittest
 import cmath, math
 from cmath import phase, polar, rect, pi
@@ -312,10 +312,8 @@
                 self.rAssertAlmostEqual(math.log(v, base), z.real)
                 self.assertEqual(0., z.imag)
 
+    @requires_IEEE_754
     def test_specific_values(self):
-        if not float.__getformat__("double").startswith("IEEE"):
-            return
-
         def rect_complex(z):
             """Wrapped version of rect that accepts a complex number instead of
             two float arguments."""
@@ -460,9 +458,11 @@
         self.assertEqual(abs(complex(INF, NAN)), INF)
         self.assertTrue(math.isnan(abs(complex(NAN, NAN))))
 
+
+    @requires_IEEE_754
+    def test_abs_overflows(self):
         # result overflows
-        if float.__getformat__("double").startswith("IEEE"):
-            self.assertRaises(OverflowError, abs, complex(1.4e308, 1.4e308))
+        self.assertRaises(OverflowError, abs, complex(1.4e308, 1.4e308))
 
     def assertCEqual(self, a, b):
         eps = 1E-7

Modified: python/branches/py3k-cdecimal/Lib/test/test_cmd_line.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_cmd_line.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_cmd_line.py	Sun Jan  2 13:18:37 2011
@@ -221,6 +221,24 @@
         self.assertIn(path1.encode('ascii'), out)
         self.assertIn(path2.encode('ascii'), out)
 
+    def test_displayhook_unencodable(self):
+        for encoding in ('ascii', 'latin1', 'utf8'):
+            env = os.environ.copy()
+            env['PYTHONIOENCODING'] = encoding
+            p = subprocess.Popen(
+                [sys.executable, '-i'],
+                stdin=subprocess.PIPE,
+                stdout=subprocess.PIPE,
+                stderr=subprocess.STDOUT,
+                env=env)
+            # non-ascii, surrogate, non-BMP printable, non-BMP unprintable
+            text = "a=\xe9 b=\uDC80 c=\U00010000 d=\U0010FFFF"
+            p.stdin.write(ascii(text).encode('ascii') + b"\n")
+            p.stdin.write(b'exit()\n')
+            data = kill_python(p)
+            escaped = repr(text).encode(encoding, 'backslashreplace')
+            self.assertIn(escaped, data)
+
 
 def test_main():
     test.support.run_unittest(CmdLineTest)

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	Sun Jan  2 13:18:37 2011
@@ -544,6 +544,12 @@
         self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode,
                           b"\xff", "strict", True)
 
+    def test_nonbmp(self):
+        self.assertEqual("\U00010203".encode(self.encoding),
+                         b'\x00\xd8\x03\xde')
+        self.assertEqual(b'\x00\xd8\x03\xde'.decode(self.encoding),
+                         "\U00010203")
+
 class UTF16BETest(ReadTest):
     encoding = "utf-16-be"
 
@@ -566,6 +572,12 @@
         self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode,
                           b"\xff", "strict", True)
 
+    def test_nonbmp(self):
+        self.assertEqual("\U00010203".encode(self.encoding),
+                         b'\xd8\x00\xde\x03')
+        self.assertEqual(b'\xd8\x00\xde\x03'.decode(self.encoding),
+                         "\U00010203")
+
 class UTF8Test(ReadTest):
     encoding = "utf-8"
 
@@ -1659,6 +1671,54 @@
                 self.assertEqual(f.read(), data * 2)
 
 
+bytes_transform_encodings = [
+    "base64_codec",
+    "uu_codec",
+    "quopri_codec",
+    "hex_codec",
+]
+try:
+    import zlib
+except ImportError:
+    pass
+else:
+    bytes_transform_encodings.append("zlib_codec")
+try:
+    import bz2
+except ImportError:
+    pass
+else:
+    bytes_transform_encodings.append("bz2_codec")
+
+class TransformCodecTest(unittest.TestCase):
+
+    def test_basics(self):
+        binput = bytes(range(256))
+        for encoding in bytes_transform_encodings:
+            # generic codecs interface
+            (o, size) = codecs.getencoder(encoding)(binput)
+            self.assertEqual(size, len(binput))
+            (i, size) = codecs.getdecoder(encoding)(o)
+            self.assertEqual(size, len(o))
+            self.assertEqual(i, binput)
+
+    def test_read(self):
+        for encoding in bytes_transform_encodings:
+            sin = codecs.encode(b"\x80", encoding)
+            reader = codecs.getreader(encoding)(io.BytesIO(sin))
+            sout = reader.read()
+            self.assertEqual(sout, b"\x80")
+
+    def test_readline(self):
+        for encoding in bytes_transform_encodings:
+            if encoding in ['uu_codec', 'zlib_codec']:
+                continue
+            sin = codecs.encode(b"\x80", encoding)
+            reader = codecs.getreader(encoding)(io.BytesIO(sin))
+            sout = reader.readline()
+            self.assertEqual(sout, b"\x80")
+
+
 def test_main():
     support.run_unittest(
         UTF32Test,
@@ -1686,6 +1746,7 @@
         TypesTest,
         SurrogateEscapeTest,
         BomTest,
+        TransformCodecTest,
     )
 
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_collections.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_collections.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_collections.py	Sun Jan  2 13:18:37 2011
@@ -356,8 +356,14 @@
         for x in samples:
             self.assertIsInstance(x, Iterator)
             self.assertTrue(issubclass(type(x), Iterator), repr(type(x)))
-        self.validate_abstract_methods(Iterator, '__next__')
-        self.validate_isinstance(Iterator, '__next__')
+        self.validate_abstract_methods(Iterator, '__next__', '__iter__')
+
+        # Issue 10565
+        class NextOnly:
+            def __next__(self):
+                yield 1
+                raise StopIteration
+        self.assertNotIsInstance(NextOnly(), Iterator)
 
     def test_Sized(self):
         non_samples = [None, 42, 3.14, 1j,
@@ -828,6 +834,10 @@
         self.assertEqual(list(d.items()),
             [('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5), ('f', 6), ('g', 7)])
 
+    def test_abc(self):
+        self.assertIsInstance(OrderedDict(), MutableMapping)
+        self.assertTrue(issubclass(OrderedDict, MutableMapping))
+
     def test_clear(self):
         pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
         shuffle(pairs)
@@ -886,6 +896,17 @@
         self.assertEqual(len(od), 0)
         self.assertEqual(od.pop(k, 12345), 12345)
 
+        # make sure pop still works when __missing__ is defined
+        class Missing(OrderedDict):
+            def __missing__(self, key):
+                return 0
+        m = Missing(a=1)
+        self.assertEqual(m.pop('b', 5), 5)
+        self.assertEqual(m.pop('a', 6), 1)
+        self.assertEqual(m.pop('a', 6), 6)
+        with self.assertRaises(KeyError):
+            m.pop('a')
+
     def test_equality(self):
         pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
         shuffle(pairs)
@@ -970,6 +991,12 @@
         # make sure 'x' is added to the end
         self.assertEqual(list(od.items())[-1], ('x', 10))
 
+        # make sure setdefault still works when __missing__ is defined
+        class Missing(OrderedDict):
+            def __missing__(self, key):
+                return 0
+        self.assertEqual(Missing().setdefault(5, 9), 9)
+
     def test_reinsert(self):
         # Given insert a, insert b, delete a, re-insert a,
         # verify that a is now later than b.
@@ -1000,6 +1027,14 @@
         od = OrderedDict(**d)
         self.assertGreater(sys.getsizeof(od), sys.getsizeof(d))
 
+    def test_override_update(self):
+        # Verify that subclasses can override update() without breaking __init__()
+        class MyOD(OrderedDict):
+            def update(self, *args, **kwds):
+                raise Exception()
+        items = [('a', 1), ('c', 3), ('b', 2)]
+        self.assertEqual(list(MyOD(items).items()), items)
+
 class GeneralMappingTests(mapping_tests.BasicTestMappingProtocol):
     type2test = OrderedDict
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_compileall.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_compileall.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_compileall.py	Sun Jan  2 13:18:37 2011
@@ -11,7 +11,7 @@
 import unittest
 import io
 
-from test import support
+from test import support, script_helper
 
 class CompileallTests(unittest.TestCase):
 
@@ -88,6 +88,15 @@
         compileall.compile_file(data_file)
         self.assertFalse(os.path.exists(os.path.join(data_dir, '__pycache__')))
 
+    def test_optimize(self):
+        # make sure compiling with different optimization settings than the
+        # interpreter's creates the correct file names
+        optimize = 1 if __debug__ else 0
+        compileall.compile_dir(self.directory, quiet=True, optimize=optimize)
+        cached = imp.cache_from_source(self.source_path,
+                                       debug_override=not optimize)
+        self.assertTrue(os.path.isfile(cached))
+
 
 class EncodingTest(unittest.TestCase):
     """Issue 6716: compileall should escape source code when printing errors
@@ -115,126 +124,218 @@
 class CommandLineTests(unittest.TestCase):
     """Test compileall's CLI."""
 
+    def assertRunOK(self, *args, **env_vars):
+        rc, out, err = script_helper.assert_python_ok(
+                        '-S', '-m', 'compileall', *args, **env_vars)
+        self.assertEqual(b'', err)
+        return out
+
+    def assertRunNotOK(self, *args, **env_vars):
+        rc, out, err = script_helper.assert_python_failure(
+                        '-S', '-m', 'compileall', *args, **env_vars)
+        return rc, out, err
+
+    def assertCompiled(self, fn):
+        self.assertTrue(os.path.exists(imp.cache_from_source(fn)))
+
+    def assertNotCompiled(self, fn):
+        self.assertFalse(os.path.exists(imp.cache_from_source(fn)))
+
     def setUp(self):
         self.addCleanup(self._cleanup)
         self.directory = tempfile.mkdtemp()
         self.pkgdir = os.path.join(self.directory, 'foo')
         os.mkdir(self.pkgdir)
-        # Touch the __init__.py and a package module.
-        with open(os.path.join(self.pkgdir, '__init__.py'), 'w'):
-            pass
-        with open(os.path.join(self.pkgdir, 'bar.py'), 'w'):
-            pass
-        sys.path.insert(0, self.directory)
+        self.pkgdir_cachedir = os.path.join(self.pkgdir, '__pycache__')
+        # Create the __init__.py and a package module.
+        self.initfn = script_helper.make_script(self.pkgdir, '__init__', '')
+        self.barfn = script_helper.make_script(self.pkgdir, 'bar', '')
 
     def _cleanup(self):
         support.rmtree(self.directory)
-        assert sys.path[0] == self.directory, 'Missing path'
-        del sys.path[0]
+
+    def test_no_args_compiles_path(self):
+        # Note that -l is implied for the no args case.
+        bazfn = script_helper.make_script(self.directory, 'baz', '')
+        self.assertRunOK(PYTHONPATH=self.directory)
+        self.assertCompiled(bazfn)
+        self.assertNotCompiled(self.initfn)
+        self.assertNotCompiled(self.barfn)
 
     # Ensure that the default behavior of compileall's CLI is to create
     # PEP 3147 pyc/pyo files.
     for name, ext, switch in [
         ('normal', 'pyc', []),
         ('optimize', 'pyo', ['-O']),
-        ('doubleoptimize', 'pyo', ['-OO'])
+        ('doubleoptimize', 'pyo', ['-OO']),
     ]:
         def f(self, ext=ext, switch=switch):
-            retcode = subprocess.call(
-                [sys.executable] + switch +
-                ['-m', 'compileall', '-q', self.pkgdir])
-            self.assertEqual(retcode, 0)
+            script_helper.assert_python_ok(*(switch +
+                ['-m', 'compileall', '-q', self.pkgdir]))
             # Verify the __pycache__ directory contents.
-            cachedir = os.path.join(self.pkgdir, '__pycache__')
-            self.assertTrue(os.path.exists(cachedir))
+            self.assertTrue(os.path.exists(self.pkgdir_cachedir))
             expected = sorted(base.format(imp.get_tag(), ext) for base in
                               ('__init__.{}.{}', 'bar.{}.{}'))
-            self.assertEqual(sorted(os.listdir(cachedir)), expected)
+            self.assertEqual(sorted(os.listdir(self.pkgdir_cachedir)), expected)
             # Make sure there are no .pyc files in the source directory.
-            self.assertFalse([pyc_file for pyc_file in os.listdir(self.pkgdir)
-                              if pyc_file.endswith(ext)])
+            self.assertFalse([fn for fn in os.listdir(self.pkgdir)
+                              if fn.endswith(ext)])
         locals()['test_pep3147_paths_' + name] = f
 
     def test_legacy_paths(self):
         # Ensure that with the proper switch, compileall leaves legacy
         # pyc/pyo files, and no __pycache__ directory.
-        retcode = subprocess.call(
-            (sys.executable, '-m', 'compileall', '-b', '-q', self.pkgdir))
-        self.assertEqual(retcode, 0)
+        self.assertRunOK('-b', '-q', self.pkgdir)
         # Verify the __pycache__ directory contents.
-        cachedir = os.path.join(self.pkgdir, '__pycache__')
-        self.assertFalse(os.path.exists(cachedir))
+        self.assertFalse(os.path.exists(self.pkgdir_cachedir))
         expected = sorted(['__init__.py', '__init__.pyc', 'bar.py', 'bar.pyc'])
         self.assertEqual(sorted(os.listdir(self.pkgdir)), expected)
 
     def test_multiple_runs(self):
         # Bug 8527 reported that multiple calls produced empty
         # __pycache__/__pycache__ directories.
-        retcode = subprocess.call(
-            (sys.executable, '-m', 'compileall', '-q', self.pkgdir))
-        self.assertEqual(retcode, 0)
+        self.assertRunOK('-q', self.pkgdir)
         # Verify the __pycache__ directory contents.
-        cachedir = os.path.join(self.pkgdir, '__pycache__')
-        self.assertTrue(os.path.exists(cachedir))
-        cachecachedir = os.path.join(cachedir, '__pycache__')
+        self.assertTrue(os.path.exists(self.pkgdir_cachedir))
+        cachecachedir = os.path.join(self.pkgdir_cachedir, '__pycache__')
         self.assertFalse(os.path.exists(cachecachedir))
         # Call compileall again.
-        retcode = subprocess.call(
-            (sys.executable, '-m', 'compileall', '-q', self.pkgdir))
-        self.assertEqual(retcode, 0)
-        self.assertTrue(os.path.exists(cachedir))
+        self.assertRunOK('-q', self.pkgdir)
+        self.assertTrue(os.path.exists(self.pkgdir_cachedir))
         self.assertFalse(os.path.exists(cachecachedir))
 
     def test_force(self):
-        retcode = subprocess.call(
-            (sys.executable, '-m', 'compileall', '-q', self.pkgdir))
-        self.assertEqual(retcode, 0)
-        pycpath = imp.cache_from_source(os.path.join(self.pkgdir, 'bar.py'))
+        self.assertRunOK('-q', self.pkgdir)
+        pycpath = imp.cache_from_source(self.barfn)
         # set atime/mtime backward to avoid file timestamp resolution issues
         os.utime(pycpath, (time.time()-60,)*2)
-        access = os.stat(pycpath).st_mtime
-        retcode = subprocess.call(
-            (sys.executable, '-m', 'compileall', '-q', '-f', self.pkgdir))
-        self.assertEqual(retcode, 0)
-        access2 = os.stat(pycpath).st_mtime
-        self.assertNotEqual(access, access2)
-
-    def test_legacy(self):
-        # create a new module
-        newpackage = os.path.join(self.pkgdir, 'spam')
-        os.mkdir(newpackage)
-        with open(os.path.join(newpackage, '__init__.py'), 'w'):
-            pass
-        with open(os.path.join(newpackage, 'ham.py'), 'w'):
-            pass
-        sourcefile = os.path.join(newpackage, 'ham.py')
-
-        retcode = subprocess.call(
-                (sys.executable, '-m', 'compileall',  '-q', '-l', self.pkgdir))
-        self.assertEqual(retcode, 0)
-        self.assertFalse(os.path.exists(imp.cache_from_source(sourcefile)))
-
-        retcode = subprocess.call(
-                (sys.executable, '-m', 'compileall', '-q', self.pkgdir))
-        self.assertEqual(retcode, 0)
-        self.assertTrue(os.path.exists(imp.cache_from_source(sourcefile)))
+        mtime = os.stat(pycpath).st_mtime
+        # without force, no recompilation
+        self.assertRunOK('-q', self.pkgdir)
+        mtime2 = os.stat(pycpath).st_mtime
+        self.assertEqual(mtime, mtime2)
+        # now force it.
+        self.assertRunOK('-q', '-f', self.pkgdir)
+        mtime2 = os.stat(pycpath).st_mtime
+        self.assertNotEqual(mtime, mtime2)
+
+    def test_recursion_control(self):
+        subpackage = os.path.join(self.pkgdir, 'spam')
+        os.mkdir(subpackage)
+        subinitfn = script_helper.make_script(subpackage, '__init__', '')
+        hamfn = script_helper.make_script(subpackage, 'ham', '')
+        self.assertRunOK('-q', '-l', self.pkgdir)
+        self.assertNotCompiled(subinitfn)
+        self.assertFalse(os.path.exists(os.path.join(subpackage, '__pycache__')))
+        self.assertRunOK('-q', self.pkgdir)
+        self.assertCompiled(subinitfn)
+        self.assertCompiled(hamfn)
 
     def test_quiet(self):
-        noise = subprocess.getoutput('{} -m compileall {}'.format(
-                                     sys.executable, self.pkgdir))
-        quiet = subprocess.getoutput(('{} -m compileall -f -q {}'.format(
-                                     sys.executable, self.pkgdir)))
-        self.assertGreater(len(noise), len(quiet))
+        noisy = self.assertRunOK(self.pkgdir)
+        quiet = self.assertRunOK('-q', self.pkgdir)
+        self.assertNotEqual(b'', noisy)
+        self.assertEqual(b'', quiet)
 
     def test_regexp(self):
-        retcode = subprocess.call(
-            (sys.executable, '-m', 'compileall', '-q', '-x', 'bar.*', self.pkgdir))
-        self.assertEqual(retcode, 0)
-
-        sourcefile = os.path.join(self.pkgdir, 'bar.py')
-        self.assertFalse(os.path.exists(imp.cache_from_source(sourcefile)))
-        sourcefile = os.path.join(self.pkgdir, '__init__.py')
-        self.assertTrue(os.path.exists(imp.cache_from_source(sourcefile)))
+        self.assertRunOK('-q', '-x', 'ba.*', self.pkgdir)
+        self.assertNotCompiled(self.barfn)
+        self.assertCompiled(self.initfn)
+
+    def test_multiple_dirs(self):
+        pkgdir2 = os.path.join(self.directory, 'foo2')
+        os.mkdir(pkgdir2)
+        init2fn = script_helper.make_script(pkgdir2, '__init__', '')
+        bar2fn = script_helper.make_script(pkgdir2, 'bar2', '')
+        self.assertRunOK('-q', self.pkgdir, pkgdir2)
+        self.assertCompiled(self.initfn)
+        self.assertCompiled(self.barfn)
+        self.assertCompiled(init2fn)
+        self.assertCompiled(bar2fn)
+
+    def test_d_takes_exactly_one_dir(self):
+        rc, out, err = self.assertRunNotOK('-d', 'foo')
+        self.assertEqual(out, b'')
+        self.assertRegex(err, b'-d')
+        rc, out, err = self.assertRunNotOK('-d', 'foo', 'bar')
+        self.assertEqual(out, b'')
+        self.assertRegex(err, b'-d')
+
+    def test_d_compile_error(self):
+        script_helper.make_script(self.pkgdir, 'crunchyfrog', 'bad(syntax')
+        rc, out, err = self.assertRunNotOK('-q', '-d', 'dinsdale', self.pkgdir)
+        self.assertRegex(out, b'File "dinsdale')
+
+    def test_d_runtime_error(self):
+        bazfn = script_helper.make_script(self.pkgdir, 'baz', 'raise Exception')
+        self.assertRunOK('-q', '-d', 'dinsdale', self.pkgdir)
+        fn = script_helper.make_script(self.pkgdir, 'bing', 'import baz')
+        pyc = imp.cache_from_source(bazfn)
+        os.rename(pyc, os.path.join(self.pkgdir, 'baz.pyc'))
+        os.remove(bazfn)
+        rc, out, err = script_helper.assert_python_failure(fn)
+        self.assertRegex(err, b'File "dinsdale')
+
+    def test_include_bad_file(self):
+        rc, out, err = self.assertRunNotOK(
+            '-i', os.path.join(self.directory, 'nosuchfile'), self.pkgdir)
+        self.assertRegex(out, b'rror.*nosuchfile')
+        self.assertNotRegex(err, b'Traceback')
+        self.assertFalse(os.path.exists(imp.cache_from_source(
+                                            self.pkgdir_cachedir)))
+
+    def test_include_file_with_arg(self):
+        f1 = script_helper.make_script(self.pkgdir, 'f1', '')
+        f2 = script_helper.make_script(self.pkgdir, 'f2', '')
+        f3 = script_helper.make_script(self.pkgdir, 'f3', '')
+        f4 = script_helper.make_script(self.pkgdir, 'f4', '')
+        with open(os.path.join(self.directory, 'l1'), 'w') as l1:
+            l1.write(os.path.join(self.pkgdir, 'f1.py')+os.linesep)
+            l1.write(os.path.join(self.pkgdir, 'f2.py')+os.linesep)
+        self.assertRunOK('-i', os.path.join(self.directory, 'l1'), f4)
+        self.assertCompiled(f1)
+        self.assertCompiled(f2)
+        self.assertNotCompiled(f3)
+        self.assertCompiled(f4)
+
+    def test_include_file_no_arg(self):
+        f1 = script_helper.make_script(self.pkgdir, 'f1', '')
+        f2 = script_helper.make_script(self.pkgdir, 'f2', '')
+        f3 = script_helper.make_script(self.pkgdir, 'f3', '')
+        f4 = script_helper.make_script(self.pkgdir, 'f4', '')
+        with open(os.path.join(self.directory, 'l1'), 'w') as l1:
+            l1.write(os.path.join(self.pkgdir, 'f2.py')+os.linesep)
+        self.assertRunOK('-i', os.path.join(self.directory, 'l1'))
+        self.assertNotCompiled(f1)
+        self.assertCompiled(f2)
+        self.assertNotCompiled(f3)
+        self.assertNotCompiled(f4)
+
+    def test_include_on_stdin(self):
+        f1 = script_helper.make_script(self.pkgdir, 'f1', '')
+        f2 = script_helper.make_script(self.pkgdir, 'f2', '')
+        f3 = script_helper.make_script(self.pkgdir, 'f3', '')
+        f4 = script_helper.make_script(self.pkgdir, 'f4', '')
+        p = script_helper.spawn_python('-m', 'compileall', '-i', '-')
+        p.stdin.write((f3+os.linesep).encode('ascii'))
+        script_helper.kill_python(p)
+        self.assertNotCompiled(f1)
+        self.assertNotCompiled(f2)
+        self.assertCompiled(f3)
+        self.assertNotCompiled(f4)
+
+    def test_compiles_as_much_as_possible(self):
+        bingfn = script_helper.make_script(self.pkgdir, 'bing', 'syntax(error')
+        rc, out, err = self.assertRunNotOK('nosuchfile', self.initfn,
+                                           bingfn, self.barfn)
+        self.assertRegex(out, b'rror')
+        self.assertNotCompiled(bingfn)
+        self.assertCompiled(self.initfn)
+        self.assertCompiled(self.barfn)
+
+    def test_invalid_arg_produces_message(self):
+        out = self.assertRunOK('badfilename')
+        self.assertRegex(out, b"Can't list badfilename")
 
 
 def test_main():

Modified: python/branches/py3k-cdecimal/Lib/test/test_complex.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_complex.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_complex.py	Sun Jan  2 13:18:37 2011
@@ -220,6 +220,7 @@
         self.assertEqual(complex(NS(1+10j)), 1+10j)
         self.assertRaises(TypeError, complex, OS(None))
         self.assertRaises(TypeError, complex, NS(None))
+        self.assertRaises(TypeError, complex, {})
 
         self.assertAlmostEqual(complex("1+10j"), 1+10j)
         self.assertAlmostEqual(complex(10), 10+0j)
@@ -325,6 +326,8 @@
 
         # check that complex accepts long unicode strings
         self.assertEqual(type(complex("1"*500)), complex)
+        # check whitespace processing
+        self.assertEqual(complex('\N{EM SPACE}(\N{EN SPACE}1+1j ) '), 1+1j)
 
         class EvilExc(Exception):
             pass
@@ -378,28 +381,48 @@
         for num in nums:
             self.assertAlmostEqual((num.real**2 + num.imag**2)  ** 0.5, abs(num))
 
-    def test_repr(self):
-        self.assertEqual(repr(1+6j), '(1+6j)')
-        self.assertEqual(repr(1-6j), '(1-6j)')
-
-        self.assertNotEqual(repr(-(1+0j)), '(-1+-0j)')
+    def test_repr_str(self):
+        def test(v, expected, test_fn=self.assertEqual):
+            test_fn(repr(v), expected)
+            test_fn(str(v), expected)
+
+        test(1+6j, '(1+6j)')
+        test(1-6j, '(1-6j)')
+
+        test(-(1+0j), '(-1+-0j)', test_fn=self.assertNotEqual)
+
+        test(complex(1., INF), "(1+infj)")
+        test(complex(1., -INF), "(1-infj)")
+        test(complex(INF, 1), "(inf+1j)")
+        test(complex(-INF, INF), "(-inf+infj)")
+        test(complex(NAN, 1), "(nan+1j)")
+        test(complex(1, NAN), "(1+nanj)")
+        test(complex(NAN, NAN), "(nan+nanj)")
+
+        test(complex(0, INF), "infj")
+        test(complex(0, -INF), "-infj")
+        test(complex(0, NAN), "nanj")
 
         self.assertEqual(1-6j,complex(repr(1-6j)))
         self.assertEqual(1+6j,complex(repr(1+6j)))
         self.assertEqual(-6j,complex(repr(-6j)))
         self.assertEqual(6j,complex(repr(6j)))
 
-        self.assertEqual(repr(complex(1., INF)), "(1+infj)")
-        self.assertEqual(repr(complex(1., -INF)), "(1-infj)")
-        self.assertEqual(repr(complex(INF, 1)), "(inf+1j)")
-        self.assertEqual(repr(complex(-INF, INF)), "(-inf+infj)")
-        self.assertEqual(repr(complex(NAN, 1)), "(nan+1j)")
-        self.assertEqual(repr(complex(1, NAN)), "(1+nanj)")
-        self.assertEqual(repr(complex(NAN, NAN)), "(nan+nanj)")
-
-        self.assertEqual(repr(complex(0, INF)), "infj")
-        self.assertEqual(repr(complex(0, -INF)), "-infj")
-        self.assertEqual(repr(complex(0, NAN)), "nanj")
+    @support.requires_IEEE_754
+    def test_negative_zero_repr_str(self):
+        def test(v, expected, test_fn=self.assertEqual):
+            test_fn(repr(v), expected)
+            test_fn(str(v), expected)
+
+        test(complex(0., 1.),   "1j")
+        test(complex(-0., 1.),  "(-0+1j)")
+        test(complex(0., -1.),  "-1j")
+        test(complex(-0., -1.), "(-0-1j)")
+
+        test(complex(0., 0.),   "0j")
+        test(complex(0., -0.),  "-0j")
+        test(complex(-0., 0.),  "(-0+0j)")
+        test(complex(-0., -0.), "(-0-0j)")
 
     def test_neg(self):
         self.assertEqual(-(1+6j), -1-6j)
@@ -428,15 +451,14 @@
         self.assertEqual(complex(0, INF).__getnewargs__(), (0.0, INF))
         self.assertEqual(complex(INF, 0).__getnewargs__(), (INF, 0.0))
 
-    if float.__getformat__("double").startswith("IEEE"):
-        def test_plus_minus_0j(self):
-            # test that -0j and 0j literals are not identified
-            z1, z2 = 0j, -0j
-            self.assertEqual(atan2(z1.imag, -1.), atan2(0., -1.))
-            self.assertEqual(atan2(z2.imag, -1.), atan2(-0., -1.))
+    @support.requires_IEEE_754
+    def test_plus_minus_0j(self):
+        # test that -0j and 0j literals are not identified
+        z1, z2 = 0j, -0j
+        self.assertEqual(atan2(z1.imag, -1.), atan2(0., -1.))
+        self.assertEqual(atan2(z2.imag, -1.), atan2(-0., -1.))
 
-    @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
-                         "test requires IEEE 754 doubles")
+    @support.requires_IEEE_754
     def test_negated_imaginary_literal(self):
         z0 = -0j
         z1 = -7j
@@ -452,15 +474,13 @@
         self.assertFloatsAreIdentical(z2.real, -0.0)
         self.assertFloatsAreIdentical(z2.imag, -INF)
 
-    @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
-                         "test requires IEEE 754 doubles")
+    @support.requires_IEEE_754
     def test_overflow(self):
         self.assertEqual(complex("1e500"), complex(INF, 0.0))
         self.assertEqual(complex("-1e500j"), complex(0.0, -INF))
         self.assertEqual(complex("-1e500+1.8e308j"), complex(-INF, INF))
 
-    @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
-                         "test requires IEEE 754 doubles")
+    @support.requires_IEEE_754
     def test_repr_roundtrip(self):
         vals = [0.0, 1e-500, 1e-315, 1e-200, 0.0123, 3.1415, 1e50, INF, NAN]
         vals += [-v for v in vals]
@@ -555,8 +575,28 @@
         self.assertEqual(format(1.5e21+3j, '^40,.2f'), ' 1,500,000,000,000,000,000,000.00+3.00j ')
         self.assertEqual(format(1.5e21+3000j, ',.2f'), '1,500,000,000,000,000,000,000.00+3,000.00j')
 
-        # alternate is invalid
-        self.assertRaises(ValueError, (1.5+0.5j).__format__, '#f')
+        # Issue 7094: Alternate formatting (specified by #)
+        self.assertEqual(format(1+1j, '.0e'), '1e+00+1e+00j')
+        self.assertEqual(format(1+1j, '#.0e'), '1.e+00+1.e+00j')
+        self.assertEqual(format(1+1j, '.0f'), '1+1j')
+        self.assertEqual(format(1+1j, '#.0f'), '1.+1.j')
+        self.assertEqual(format(1.1+1.1j, 'g'), '1.1+1.1j')
+        self.assertEqual(format(1.1+1.1j, '#g'), '1.10000+1.10000j')
+
+        # Alternate doesn't make a difference for these, they format the same with or without it
+        self.assertEqual(format(1+1j, '.1e'),  '1.0e+00+1.0e+00j')
+        self.assertEqual(format(1+1j, '#.1e'), '1.0e+00+1.0e+00j')
+        self.assertEqual(format(1+1j, '.1f'),  '1.0+1.0j')
+        self.assertEqual(format(1+1j, '#.1f'), '1.0+1.0j')
+
+        # Misc. other alternate tests
+        self.assertEqual(format((-1.5+0.5j), '#f'), '-1.500000+0.500000j')
+        self.assertEqual(format((-1.5+0.5j), '#.0f'), '-2.+0.j')
+        self.assertEqual(format((-1.5+0.5j), '#e'), '-1.500000e+00+5.000000e-01j')
+        self.assertEqual(format((-1.5+0.5j), '#.0e'), '-2.e+00+5.e-01j')
+        self.assertEqual(format((-1.5+0.5j), '#g'), '-1.50000+0.500000j')
+        self.assertEqual(format((-1.5+0.5j), '.0g'), '-2+0.5j')
+        self.assertEqual(format((-1.5+0.5j), '#.0g'), '-2.+0.5j')
 
         # zero padding is invalid
         self.assertRaises(ValueError, (1.5+0.5j).__format__, '010f')

Modified: python/branches/py3k-cdecimal/Lib/test/test_concurrent_futures.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_concurrent_futures.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_concurrent_futures.py	Sun Jan  2 13:18:37 2011
@@ -24,7 +24,7 @@
 from concurrent import futures
 from concurrent.futures._base import (
     PENDING, RUNNING, CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED, Future,
-    LOGGER, STDERR_HANDLER, wait)
+    LOGGER, wait)
 import concurrent.futures.process
 
 def create_future(state=PENDING, exception=None, result=None):
@@ -75,15 +75,27 @@
 
     def _wait_on_event(self, handle):
         if sys.platform.startswith('win'):
+            # WaitForSingleObject returns 0 if handle is signaled.
             r = ctypes.windll.kernel32.WaitForSingleObject(handle, 60 * 1000)
-            assert r == 0
+            if r != 0:
+                message = (
+                    'WaitForSingleObject({}, ...) failed with {}, '
+                    'GetLastError() = {}'.format(
+                            handle, r, ctypes.GetLastError()))
+                logging.critical(message)
+                assert False, message
         else:
             self.CALL_LOCKS[handle].wait()
 
     def _signal_event(self, handle):
         if sys.platform.startswith('win'):
-            r = ctypes.windll.kernel32.SetEvent(handle)
-            assert r != 0
+            r = ctypes.windll.kernel32.SetEvent(handle)  # Returns 0 on failure.
+            if r == 0:
+                message = (
+                    'SetEvent({}) failed with {}, GetLastError() = {}'.format(
+                            handle, r, ctypes.GetLastError()))
+                logging.critical(message)
+                assert False, message
         else:
             self.CALL_LOCKS[handle].set()
 
@@ -113,6 +125,8 @@
         if sys.platform.startswith('win'):
             ctypes.windll.kernel32.CloseHandle(self._called_event)
             ctypes.windll.kernel32.CloseHandle(self._can_finish)
+            self._called_event = None
+            self._can_finish = None
         else:
             del self.CALL_LOCKS[self._called_event]
             del self.CALL_LOCKS[self._can_finish]
@@ -363,8 +377,6 @@
 
             self.assertEqual(set([future1, future2]), finished)
             self.assertEqual(set(), pending)
-
-
         finally:
             call1.close()
             call2.close()
@@ -620,11 +632,7 @@
         self.assertTrue(was_cancelled)
 
     def test_done_callback_raises(self):
-        LOGGER.removeHandler(STDERR_HANDLER)
-        logging_stream = io.StringIO()
-        handler = logging.StreamHandler(logging_stream)
-        LOGGER.addHandler(handler)
-        try:
+        with test.support.captured_stderr() as stderr:
             raising_was_called = False
             fn_was_called = False
 
@@ -643,10 +651,7 @@
             f.set_result(5)
             self.assertTrue(raising_was_called)
             self.assertTrue(fn_was_called)
-            self.assertIn('Exception: doh!', logging_stream.getvalue())
-        finally:
-            LOGGER.removeHandler(handler)
-            LOGGER.addHandler(STDERR_HANDLER)
+            self.assertIn('Exception: doh!', stderr.getvalue())
 
     def test_done_callback_already_successful(self):
         callback_result = None
@@ -682,18 +687,18 @@
         self.assertTrue(was_cancelled)
 
     def test_repr(self):
-        self.assertRegexpMatches(repr(PENDING_FUTURE),
-                                 '<Future at 0x[0-9a-f]+ state=pending>')
-        self.assertRegexpMatches(repr(RUNNING_FUTURE),
-                                 '<Future at 0x[0-9a-f]+ state=running>')
-        self.assertRegexpMatches(repr(CANCELLED_FUTURE),
-                                 '<Future at 0x[0-9a-f]+ state=cancelled>')
-        self.assertRegexpMatches(repr(CANCELLED_AND_NOTIFIED_FUTURE),
-                                 '<Future at 0x[0-9a-f]+ state=cancelled>')
-        self.assertRegexpMatches(
+        self.assertRegex(repr(PENDING_FUTURE),
+                         '<Future at 0x[0-9a-f]+ state=pending>')
+        self.assertRegex(repr(RUNNING_FUTURE),
+                         '<Future at 0x[0-9a-f]+ state=running>')
+        self.assertRegex(repr(CANCELLED_FUTURE),
+                         '<Future at 0x[0-9a-f]+ state=cancelled>')
+        self.assertRegex(repr(CANCELLED_AND_NOTIFIED_FUTURE),
+                         '<Future at 0x[0-9a-f]+ state=cancelled>')
+        self.assertRegex(
                 repr(EXCEPTION_FUTURE),
                 '<Future at 0x[0-9a-f]+ state=finished raised IOError>')
-        self.assertRegexpMatches(
+        self.assertRegex(
                 repr(SUCCESSFUL_FUTURE),
                 '<Future at 0x[0-9a-f]+ state=finished returned int>')
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_contextlib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_contextlib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_contextlib.py	Sun Jan  2 13:18:37 2011
@@ -231,7 +231,7 @@
     def test_contextdecorator_with_exception(self):
         context = mycontext()
 
-        with self.assertRaisesRegexp(NameError, 'foo'):
+        with self.assertRaisesRegex(NameError, 'foo'):
             with context:
                 raise NameError('foo')
         self.assertIsNotNone(context.exc)
@@ -265,7 +265,7 @@
             self.assertTrue(context.started)
             raise NameError('foo')
 
-        with self.assertRaisesRegexp(NameError, 'foo'):
+        with self.assertRaisesRegex(NameError, 'foo'):
             test()
         self.assertIsNotNone(context.exc)
         self.assertIs(context.exc[0], NameError)

Modified: python/branches/py3k-cdecimal/Lib/test/test_csv.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_csv.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_csv.py	Sun Jan  2 13:18:37 2011
@@ -313,22 +313,17 @@
         expected_dialects = csv.list_dialects() + [name]
         expected_dialects.sort()
         csv.register_dialect(name, myexceltsv)
-        try:
-            self.assertTrue(csv.get_dialect(name).delimiter, '\t')
-            got_dialects = csv.list_dialects()
-            got_dialects.sort()
-            self.assertEqual(expected_dialects, got_dialects)
-        finally:
-            csv.unregister_dialect(name)
+        self.addCleanup(csv.unregister_dialect, name)
+        self.assertEqual(csv.get_dialect(name).delimiter, '\t')
+        got_dialects = sorted(csv.list_dialects())
+        self.assertEqual(expected_dialects, got_dialects)
 
     def test_register_kwargs(self):
         name = 'fedcba'
         csv.register_dialect(name, delimiter=';')
-        try:
-            self.assertTrue(csv.get_dialect(name).delimiter, '\t')
-            self.assertTrue(list(csv.reader('X;Y;Z', name)), ['X', 'Y', 'Z'])
-        finally:
-            csv.unregister_dialect(name)
+        self.addCleanup(csv.unregister_dialect, name)
+        self.assertEqual(csv.get_dialect(name).delimiter, ';')
+        self.assertEqual([['X', 'Y', 'Z']], list(csv.reader(['X;Y;Z'], name)))
 
     def test_incomplete_dialect(self):
         class myexceltsv(csv.Dialect):

Modified: python/branches/py3k-cdecimal/Lib/test/test_dbm_gnu.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_dbm_gnu.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_dbm_gnu.py	Sun Jan  2 13:18:37 2011
@@ -32,6 +32,10 @@
             key_set.remove(key)
             key = self.g.nextkey(key)
         self.assertRaises(KeyError, lambda: self.g['xxx'])
+        # get() and setdefault() work as in the dict interface
+        self.assertEqual(self.g.get(b'xxx', b'foo'), b'foo')
+        self.assertEqual(self.g.setdefault(b'xxx', b'foo'), b'foo')
+        self.assertEqual(self.g[b'xxx'], b'foo')
 
     def test_error_conditions(self):
         # Try to open a non-existent database.

Modified: python/branches/py3k-cdecimal/Lib/test/test_decimal.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_decimal.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_decimal.py	Sun Jan  2 13:18:37 2011
@@ -32,7 +32,8 @@
 import unittest
 from decimal import *
 import numbers
-from test.support import run_unittest, run_doctest, is_resource_enabled
+from test.support import (run_unittest, run_doctest, is_resource_enabled,
+                          requires_IEEE_754)
 from test.support import check_warnings
 import random
 try:
@@ -61,11 +62,6 @@
         )
     setcontext(DefaultTestContext)
 
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(
-    float.__getformat__("double").startswith("IEEE"),
-    "test requires IEEE 754 doubles")
-
 TESTDATADIR = 'decimaltestdata'
 if __name__ == '__main__':
     file = sys.argv[0]
@@ -818,6 +814,18 @@
 
             # issue 6850
             ('a=-7.0', '0.12345', 'aaaa0.1'),
+
+            # Issue 7094: Alternate formatting (specified by #)
+            ('.0e', '1.0', '1e+0'),
+            ('#.0e', '1.0', '1.e+0'),
+            ('.0f', '1.0', '1'),
+            ('#.0f', '1.0', '1.'),
+            ('g', '1.1', '1.1'),
+            ('#g', '1.1', '1.1'),
+            ('.0g', '1', '1'),
+            ('#.0g', '1', '1.'),
+            ('.0%', '1.0', '100%'),
+            ('#.0%', '1.0', '100.%'),
             ]
         for fmt, d, result in test_values:
             self.assertEqual(format(Decimal(d), fmt), result)

Modified: python/branches/py3k-cdecimal/Lib/test/test_descr.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_descr.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_descr.py	Sun Jan  2 13:18:37 2011
@@ -4233,20 +4233,26 @@
         self.C = C
 
     def test_iter_keys(self):
-        # Testing dict-proxy iterkeys...
-        keys = [ key for key in self.C.__dict__.keys() ]
+        # Testing dict-proxy keys...
+        it = self.C.__dict__.keys()
+        self.assertNotIsInstance(it, list)
+        keys = list(it)
         keys.sort()
         self.assertEqual(keys, ['__dict__', '__doc__', '__module__',
             '__weakref__', 'meth'])
 
     def test_iter_values(self):
-        # Testing dict-proxy itervalues...
-        values = [ values for values in self.C.__dict__.values() ]
+        # Testing dict-proxy values...
+        it = self.C.__dict__.values()
+        self.assertNotIsInstance(it, list)
+        values = list(it)
         self.assertEqual(len(values), 5)
 
     def test_iter_items(self):
         # Testing dict-proxy iteritems...
-        keys = [ key for (key, value) in self.C.__dict__.items() ]
+        it = self.C.__dict__.items()
+        self.assertNotIsInstance(it, list)
+        keys = [item[0] for item in it]
         keys.sort()
         self.assertEqual(keys, ['__dict__', '__doc__', '__module__',
             '__weakref__', 'meth'])
@@ -4262,6 +4268,11 @@
             pass
         self.assertEqual(type(C.__dict__), type(B.__dict__))
 
+    def test_repr(self):
+        # Testing dict_proxy.__repr__
+        dict_ = {k: v for k, v in self.C.__dict__.items()}
+        self.assertEqual(repr(self.C.__dict__), 'dict_proxy({!r})'.format(dict_))
+
 
 class PTypesLongInitTest(unittest.TestCase):
     # This is in its own TestCase so that it can be run before any other tests.

Modified: python/branches/py3k-cdecimal/Lib/test/test_difflib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_difflib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_difflib.py	Sun Jan  2 13:18:37 2011
@@ -4,8 +4,64 @@
 import doctest
 import sys
 
-class TestSFbugs(unittest.TestCase):
 
+class TestWithAscii(unittest.TestCase):
+    def test_one_insert(self):
+        sm = difflib.SequenceMatcher(None, 'b' * 100, 'a' + 'b' * 100)
+        self.assertAlmostEqual(sm.ratio(), 0.995, places=3)
+        self.assertEqual(list(sm.get_opcodes()),
+            [   ('insert', 0, 0, 0, 1),
+                ('equal', 0, 100, 1, 101)])
+        self.assertEqual(sm.bpopular, set())
+        sm = difflib.SequenceMatcher(None, 'b' * 100, 'b' * 50 + 'a' + 'b' * 50)
+        self.assertAlmostEqual(sm.ratio(), 0.995, places=3)
+        self.assertEqual(list(sm.get_opcodes()),
+            [   ('equal', 0, 50, 0, 50),
+                ('insert', 50, 50, 50, 51),
+                ('equal', 50, 100, 51, 101)])
+        self.assertEqual(sm.bpopular, set())
+
+    def test_one_delete(self):
+        sm = difflib.SequenceMatcher(None, 'a' * 40 + 'c' + 'b' * 40, 'a' * 40 + 'b' * 40)
+        self.assertAlmostEqual(sm.ratio(), 0.994, places=3)
+        self.assertEqual(list(sm.get_opcodes()),
+            [   ('equal', 0, 40, 0, 40),
+                ('delete', 40, 41, 40, 40),
+                ('equal', 41, 81, 40, 80)])
+
+    def test_bjunk(self):
+        sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ',
+                a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40)
+        self.assertEqual(sm.bjunk, set())
+
+        sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ',
+                a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40 + ' ' * 20)
+        self.assertEqual(sm.bjunk, {' '})
+
+        sm = difflib.SequenceMatcher(isjunk=lambda x: x in [' ', 'b'],
+                a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40 + ' ' * 20)
+        self.assertEqual(sm.bjunk, {' ', 'b'})
+
+
+class TestAutojunk(unittest.TestCase):
+    """Tests for the autojunk parameter added in 2.7"""
+    def test_one_insert_homogenous_sequence(self):
+        # By default autojunk=True and the heuristic kicks in for a sequence
+        # of length 200+
+        seq1 = 'b' * 200
+        seq2 = 'a' + 'b' * 200
+
+        sm = difflib.SequenceMatcher(None, seq1, seq2)
+        self.assertAlmostEqual(sm.ratio(), 0, places=3)
+        self.assertEqual(sm.bpopular, {'b'})
+
+        # Now turn the heuristic off
+        sm = difflib.SequenceMatcher(None, seq1, seq2, autojunk=False)
+        self.assertAlmostEqual(sm.ratio(), 0.9975, places=3)
+        self.assertEqual(sm.bpopular, set())
+
+
+class TestSFbugs(unittest.TestCase):
     def test_ratio_for_null_seqn(self):
         # Check clearing of SF bug 763023
         s = difflib.SequenceMatcher(None, [], [])
@@ -184,7 +240,9 @@
 def test_main():
     difflib.HtmlDiff._default_prefix = 0
     Doctests = doctest.DocTestSuite(difflib)
-    run_unittest(TestSFpatches, TestSFbugs, TestOutputFormat, Doctests)
+    run_unittest(
+        TestWithAscii, TestAutojunk, TestSFpatches, TestSFbugs,
+        TestOutputFormat, Doctests)
 
 if __name__ == '__main__':
     test_main()

Modified: python/branches/py3k-cdecimal/Lib/test/test_dis.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_dis.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_dis.py	Sun Jan  2 13:18:37 2011
@@ -354,14 +354,14 @@
     def test_code_info(self):
         self.maxDiff = 1000
         for x, expected in self.test_pairs:
-            self.assertRegexpMatches(dis.code_info(x), expected)
+            self.assertRegex(dis.code_info(x), expected)
 
     def test_show_code(self):
         self.maxDiff = 1000
         for x, expected in self.test_pairs:
             with captured_stdout() as output:
                 dis.show_code(x)
-            self.assertRegexpMatches(output.getvalue(), expected+"\n")
+            self.assertRegex(output.getvalue(), expected+"\n")
 
 def test_main():
     run_unittest(DisTests, CodeInfoTests)

Modified: python/branches/py3k-cdecimal/Lib/test/test_float.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_float.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_float.py	Sun Jan  2 13:18:37 2011
@@ -16,10 +16,6 @@
                                          "requires __getformat__")
 requires_setformat = unittest.skipUnless(hasattr(float, "__setformat__"),
                                          "requires __setformat__")
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(have_getformat and
-    float.__getformat__("double").startswith("IEEE"),
-    "test requires IEEE 754 doubles")
 
 #locate file with float format test values
 test_dir = os.path.dirname(__file__) or os.curdir
@@ -43,14 +39,30 @@
         self.assertRaises(ValueError, float, "+.inf")
         self.assertRaises(ValueError, float, ".")
         self.assertRaises(ValueError, float, "-.")
+        self.assertRaises(ValueError, float, b"-")
+        self.assertRaises(TypeError, float, {})
+        # Lone surrogate
+        self.assertRaises(UnicodeEncodeError, float, '\uD8F0')
         # check that we don't accept alternate exponent markers
         self.assertRaises(ValueError, float, "-1.7d29")
         self.assertRaises(ValueError, float, "3D-14")
-        self.assertEqual(float(b"  \u0663.\u0661\u0664  ".decode('raw-unicode-escape')), 3.14)
+        self.assertEqual(float("  \u0663.\u0661\u0664  "), 3.14)
+        self.assertEqual(float("\N{EM SPACE}3.14\N{EN SPACE}"), 3.14)
         # extra long strings should not be a problem
         float(b'.' + b'1'*1000)
         float('.' + '1'*1000)
 
+    def test_error_message(self):
+        testlist = ('\xbd', '123\xbd', '  123 456  ')
+        for s in testlist:
+            try:
+                float(s)
+            except ValueError as e:
+                self.assertIn(s.strip(), e.args[0])
+            else:
+                self.fail("Expected int(%r) to raise a ValueError", s)
+
+
     @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
     def test_float_with_comma(self):
         # set locale to something that doesn't use '.' for the decimal point
@@ -180,7 +192,27 @@
         # distingishes -0.0 and 0.0.
         self.assertEqual((a, copysign(1.0, a)), (b, copysign(1.0, b)))
 
-    @requires_IEEE_754
+    @support.requires_IEEE_754
+    def test_float_mod(self):
+        # Check behaviour of % operator for IEEE 754 special cases.
+        # In particular, check signs of zeros.
+        mod = operator.mod
+
+        self.assertEqualAndEqualSign(mod(-1.0, 1.0), 0.0)
+        self.assertEqualAndEqualSign(mod(-1e-100, 1.0), 1.0)
+        self.assertEqualAndEqualSign(mod(-0.0, 1.0), 0.0)
+        self.assertEqualAndEqualSign(mod(0.0, 1.0), 0.0)
+        self.assertEqualAndEqualSign(mod(1e-100, 1.0), 1e-100)
+        self.assertEqualAndEqualSign(mod(1.0, 1.0), 0.0)
+
+        self.assertEqualAndEqualSign(mod(-1.0, -1.0), -0.0)
+        self.assertEqualAndEqualSign(mod(-1e-100, -1.0), -1e-100)
+        self.assertEqualAndEqualSign(mod(-0.0, -1.0), -0.0)
+        self.assertEqualAndEqualSign(mod(0.0, -1.0), -0.0)
+        self.assertEqualAndEqualSign(mod(1e-100, -1.0), -1.0)
+        self.assertEqualAndEqualSign(mod(1.0, -1.0), -0.0)
+
+    @support.requires_IEEE_754
     def test_float_pow(self):
         # test builtin pow and ** operator for IEEE 754 special cases.
         # Special cases taken from section F.9.4.4 of the C99 specification
@@ -467,7 +499,7 @@
 
 class IEEEFormatTestCase(unittest.TestCase):
 
-    @requires_IEEE_754
+    @support.requires_IEEE_754
     def test_double_specials_do_unpack(self):
         for fmt, data in [('>d', BE_DOUBLE_INF),
                           ('>d', BE_DOUBLE_NAN),
@@ -475,7 +507,7 @@
                           ('<d', LE_DOUBLE_NAN)]:
             struct.unpack(fmt, data)
 
-    @requires_IEEE_754
+    @support.requires_IEEE_754
     def test_float_specials_do_unpack(self):
         for fmt, data in [('>f', BE_FLOAT_INF),
                           ('>f', BE_FLOAT_NAN),
@@ -538,7 +570,7 @@
         self.assertEqual(format(INF, 'f'), 'inf')
         self.assertEqual(format(INF, 'F'), 'INF')
 
-    @requires_IEEE_754
+    @support.requires_IEEE_754
     def test_format_testfile(self):
         with open(format_testfile) as testfile:
             for line in testfile:
@@ -622,7 +654,7 @@
             self.assertEqual(repr(float(s)), str(float(s)))
             self.assertEqual(repr(float(negs)), str(float(negs)))
 
- at requires_IEEE_754
+ at support.requires_IEEE_754
 class RoundTestCase(unittest.TestCase):
 
     def test_inf_nan(self):
@@ -706,11 +738,8 @@
         def test(fmt, value, expected):
             # Test with both % and format().
             self.assertEqual(fmt % value, expected, fmt)
-            if not '#' in fmt:
-                # Until issue 7094 is implemented, format() for floats doesn't
-                #  support '#' formatting
-                fmt = fmt[1:] # strip off the %
-                self.assertEqual(format(value, fmt), expected, fmt)
+            fmt = fmt[1:] # strip off the %
+            self.assertEqual(format(value, fmt), expected, fmt)
 
         for fmt in ['%e', '%f', '%g', '%.0e', '%.6f', '%.20g',
                     '%#e', '%#f', '%#g', '%#.20e', '%#.15f', '%#.3g']:

Modified: python/branches/py3k-cdecimal/Lib/test/test_fork1.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_fork1.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_fork1.py	Sun Jan  2 13:18:37 2011
@@ -8,13 +8,14 @@
 import time
 
 from test.fork_wait import ForkWait
-from test.support import run_unittest, reap_children, get_attribute, import_module
+from test.support import (run_unittest, reap_children, get_attribute,
+                          import_module, verbose)
+
 threading = import_module('threading')
 
 # Skip test if fork does not exist.
 get_attribute(os, 'fork')
 
-
 class ForkTest(ForkWait):
     def wait_impl(self, cpid):
         for i in range(10):
@@ -28,7 +29,8 @@
         self.assertEqual(spid, cpid)
         self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
 
-    def test_import_lock_fork(self):
+    def test_threaded_import_lock_fork(self):
+        """Check fork() in main thread works while a subthread is doing an import"""
         import_started = threading.Event()
         fake_module_name = "fake test module"
         partial_module = "partial"
@@ -45,11 +47,16 @@
         import_started.wait()
         pid = os.fork()
         try:
+            # PyOS_BeforeFork should have waited for the import to complete
+            # before forking, so the child can recreate the import lock
+            # correctly, but also won't see a partially initialised module
             if not pid:
                 m = __import__(fake_module_name)
                 if m == complete_module:
                     os._exit(0)
                 else:
+                    if verbose > 1:
+                        print("Child encountered partial module")
                     os._exit(1)
             else:
                 t.join()
@@ -63,6 +70,39 @@
             except OSError:
                 pass
 
+
+    def test_nested_import_lock_fork(self):
+        """Check fork() in main thread works while the main thread is doing an import"""
+        # Issue 9573: this used to trigger RuntimeError in the child process
+        def fork_with_import_lock(level):
+            release = 0
+            in_child = False
+            try:
+                try:
+                    for i in range(level):
+                        imp.acquire_lock()
+                        release += 1
+                    pid = os.fork()
+                    in_child = not pid
+                finally:
+                    for i in range(release):
+                        imp.release_lock()
+            except RuntimeError:
+                if in_child:
+                    if verbose > 1:
+                        print("RuntimeError in child")
+                    os._exit(1)
+                raise
+            if in_child:
+                os._exit(0)
+            self.wait_impl(pid)
+
+        # Check this works with various levels of nested
+        # import in the main thread
+        for level in range(5):
+            fork_with_import_lock(level)
+
+
 def test_main():
     run_unittest(ForkTest)
     reap_children()

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	Sun Jan  2 13:18:37 2011
@@ -1,7 +1,7 @@
 """Tests for Lib/fractions.py."""
 
 from decimal import Decimal
-from test.support import run_unittest
+from test.support import run_unittest, requires_IEEE_754
 import math
 import numbers
 import operator
@@ -12,11 +12,6 @@
 F = fractions.Fraction
 gcd = fractions.gcd
 
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(
-    float.__getformat__("double").startswith("IEEE"),
-    "test requires IEEE 754 doubles")
-
 class DummyFloat(object):
     """Dummy float class for testing comparisons with Fractions"""
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_functools.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_functools.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_functools.py	Sun Jan  2 13:18:37 2011
@@ -146,6 +146,32 @@
         join = self.thetype(''.join)
         self.assertEqual(join(data), '0123456789')
 
+    def test_repr(self):
+        args = (object(), object())
+        args_repr = ', '.join(repr(a) for a in args)
+        kwargs = {'a': object(), 'b': object()}
+        kwargs_repr = ', '.join("%s=%r" % (k, v) for k, v in kwargs.items())
+        if self.thetype is functools.partial:
+            name = 'functools.partial'
+        else:
+            name = self.thetype.__name__
+
+        f = self.thetype(capture)
+        self.assertEqual('{}({!r})'.format(name, capture),
+                         repr(f))
+
+        f = self.thetype(capture, *args)
+        self.assertEqual('{}({!r}, {})'.format(name, capture, args_repr),
+                         repr(f))
+
+        f = self.thetype(capture, **kwargs)
+        self.assertEqual('{}({!r}, {})'.format(name, capture, kwargs_repr),
+                         repr(f))
+
+        f = self.thetype(capture, *args, **kwargs)
+        self.assertEqual('{}({!r}, {}, {})'.format(name, capture, args_repr, kwargs_repr),
+                         repr(f))
+
     def test_pickle(self):
         f = self.thetype(signature, 'asdf', bar=True)
         f.add_something_to__dict__ = True
@@ -163,6 +189,9 @@
 
     thetype = PythonPartial
 
+    # the python version hasn't a nice repr
+    def test_repr(self): pass
+
     # the python version isn't picklable
     def test_pickle(self): pass
 
@@ -501,6 +530,11 @@
         def orig(x, y):
             return 3*x+y
         f = functools.lru_cache(maxsize=20)(orig)
+        hits, misses, maxsize, currsize = f.cache_info()
+        self.assertEqual(maxsize, 20)
+        self.assertEqual(currsize, 0)
+        self.assertEqual(hits, 0)
+        self.assertEqual(misses, 0)
 
         domain = range(5)
         for i in range(1000):
@@ -508,21 +542,29 @@
             actual = f(x, y)
             expected = orig(x, y)
             self.assertEqual(actual, expected)
-        self.assertTrue(f.cache_hits > f.cache_misses)
-        self.assertEqual(f.cache_hits + f.cache_misses, 1000)
+        hits, misses, maxsize, currsize = f.cache_info()
+        self.assertTrue(hits > misses)
+        self.assertEqual(hits + misses, 1000)
+        self.assertEqual(currsize, 20)
 
         f.cache_clear()   # test clearing
-        self.assertEqual(f.cache_hits, 0)
-        self.assertEqual(f.cache_misses, 0)
+        hits, misses, maxsize, currsize = f.cache_info()
+        self.assertEqual(hits, 0)
+        self.assertEqual(misses, 0)
+        self.assertEqual(currsize, 0)
         f(x, y)
-        self.assertEqual(f.cache_hits, 0)
-        self.assertEqual(f.cache_misses, 1)
+        hits, misses, maxsize, currsize = f.cache_info()
+        self.assertEqual(hits, 0)
+        self.assertEqual(misses, 1)
+        self.assertEqual(currsize, 1)
 
         # Test bypassing the cache
         self.assertIs(f.__wrapped__, orig)
         f.__wrapped__(x, y)
-        self.assertEqual(f.cache_hits, 0)
-        self.assertEqual(f.cache_misses, 1)
+        hits, misses, maxsize, currsize = f.cache_info()
+        self.assertEqual(hits, 0)
+        self.assertEqual(misses, 1)
+        self.assertEqual(currsize, 1)
 
         # test size zero (which means "never-cache")
         @functools.lru_cache(0)
@@ -530,10 +572,15 @@
             nonlocal f_cnt
             f_cnt += 1
             return 20
+        self.assertEqual(f.cache_info().maxsize, 0)
         f_cnt = 0
         for i in range(5):
             self.assertEqual(f(), 20)
         self.assertEqual(f_cnt, 5)
+        hits, misses, maxsize, currsize = f.cache_info()
+        self.assertEqual(hits, 0)
+        self.assertEqual(misses, 5)
+        self.assertEqual(currsize, 0)
 
         # test size one
         @functools.lru_cache(1)
@@ -541,10 +588,15 @@
             nonlocal f_cnt
             f_cnt += 1
             return 20
+        self.assertEqual(f.cache_info().maxsize, 1)
         f_cnt = 0
         for i in range(5):
             self.assertEqual(f(), 20)
         self.assertEqual(f_cnt, 1)
+        hits, misses, maxsize, currsize = f.cache_info()
+        self.assertEqual(hits, 4)
+        self.assertEqual(misses, 1)
+        self.assertEqual(currsize, 1)
 
         # test size two
         @functools.lru_cache(2)
@@ -552,11 +604,30 @@
             nonlocal f_cnt
             f_cnt += 1
             return x*10
+        self.assertEqual(f.cache_info().maxsize, 2)
         f_cnt = 0
         for x in 7, 9, 7, 9, 7, 9, 8, 8, 8, 9, 9, 9, 8, 8, 8, 7:
             #    *  *              *                          *
             self.assertEqual(f(x), x*10)
         self.assertEqual(f_cnt, 4)
+        hits, misses, maxsize, currsize = f.cache_info()
+        self.assertEqual(hits, 12)
+        self.assertEqual(misses, 4)
+        self.assertEqual(currsize, 2)
+
+    def test_lru_with_maxsize_none(self):
+        @functools.lru_cache(maxsize=None)
+        def fib(n):
+            if n < 2:
+                return n
+            return fib(n-1) + fib(n-2)
+        self.assertEqual([fib(n) for n in range(16)],
+            [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610])
+        self.assertEqual(fib.cache_info(),
+            functools._CacheInfo(hits=28, misses=16, maxsize=None, currsize=16))
+        fib.cache_clear()
+        self.assertEqual(fib.cache_info(),
+            functools._CacheInfo(hits=0, misses=0, maxsize=None, currsize=0))
 
 def test_main(verbose=None):
     test_classes = (

Modified: python/branches/py3k-cdecimal/Lib/test/test_grp.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_grp.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_grp.py	Sun Jan  2 13:18:37 2011
@@ -33,12 +33,16 @@
             e2 = grp.getgrgid(e.gr_gid)
             self.check_value(e2)
             self.assertEqual(e2.gr_gid, e.gr_gid)
-            e2 = grp.getgrnam(e.gr_name)
+            name = e.gr_name
+            if name.startswith('+') or name.startswith('-'):
+                # NIS-related entry
+                continue
+            e2 = grp.getgrnam(name)
             self.check_value(e2)
             # There are instances where getgrall() returns group names in
             # lowercase while getgrgid() returns proper casing.
             # Discovered on Ubuntu 5.04 (custom).
-            self.assertEqual(e2.gr_name.lower(), e.gr_name.lower())
+            self.assertEqual(e2.gr_name.lower(), name.lower())
 
     def test_errors(self):
         self.assertRaises(TypeError, grp.getgrgid)

Modified: python/branches/py3k-cdecimal/Lib/test/test_htmlparser.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_htmlparser.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_htmlparser.py	Sun Jan  2 13:18:37 2011
@@ -8,10 +8,10 @@
 
 class EventCollector(html.parser.HTMLParser):
 
-    def __init__(self):
+    def __init__(self, *args, **kw):
         self.events = []
         self.append = self.events.append
-        html.parser.HTMLParser.__init__(self)
+        html.parser.HTMLParser.__init__(self, *args, **kw)
 
     def get_events(self):
         # Normalize the list of events so that buffer artefacts don't
@@ -72,8 +72,10 @@
 
 class TestCaseBase(unittest.TestCase):
 
-    def _run_check(self, source, expected_events, collector=EventCollector):
-        parser = collector()
+    def _run_check(self, source, expected_events, collector=None):
+        if collector is None:
+            collector = EventCollector()
+        parser = collector
         for s in source:
             parser.feed(s)
         parser.close()
@@ -84,7 +86,7 @@
                       "\nReceived:\n" + pprint.pformat(events))
 
     def _run_check_extra(self, source, events):
-        self._run_check(source, events, EventCollectorExtra)
+        self._run_check(source, events, EventCollectorExtra())
 
     def _parse_error(self, source):
         def parse(source=source):
@@ -321,8 +323,47 @@
                 ])
 
 
+class HTMLParserTolerantTestCase(TestCaseBase):
+
+    def setUp(self):
+        self.collector = EventCollector(strict=False)
+
+    def test_tolerant_parsing(self):
+        self._run_check('<html <html>te>>xt&a<<bc</a></html>\n'
+                        '<img src="URL><//img></html</html>', [
+                             ('data', '<html '),
+                             ('starttag', 'html', []),
+                             ('data', 'te>>xt'),
+                             ('entityref', 'a'),
+                             ('data', '<<bc'),
+                             ('endtag', 'a'),
+                             ('endtag', 'html'),
+                             ('data', '\n<img src="URL><//img></html'),
+                             ('endtag', 'html')],
+                        collector = self.collector)
+
+    def test_comma_between_attributes(self):
+        self._run_check('<form action="/xxx.php?a=1&amp;b=2&amp", '
+                        'method="post">', [
+                            ('starttag', 'form',
+                                [('action', '/xxx.php?a=1&b=2&amp'),
+                                 ('method', 'post')])],
+                        collector = self.collector)
+
+    def test_weird_chars_in_unquoted_attribute_values(self):
+        self._run_check('<form action=bogus|&#()value>', [
+                            ('starttag', 'form',
+                                [('action', 'bogus|&#()value')])],
+                        collector = self.collector)
+
+    def test_unescape_function(self):
+        p = html.parser.HTMLParser()
+        self.assertEqual(p.unescape('&#bad;'),'&#bad;')
+        self.assertEqual(p.unescape('&#0038;'),'&')
+
+
 def test_main():
-    support.run_unittest(HTMLParserTestCase)
+    support.run_unittest(HTMLParserTestCase, HTMLParserTolerantTestCase)
 
 
 if __name__ == "__main__":

Modified: python/branches/py3k-cdecimal/Lib/test/test_http_cookies.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_http_cookies.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_http_cookies.py	Sun Jan  2 13:18:37 2011
@@ -69,6 +69,14 @@
         </script>
         """)
 
+    def test_extended_encode(self):
+        # Issue 9824: some browsers don't follow the standard; we now
+        # encode , and ; to keep them from tripping up.
+        C = cookies.SimpleCookie()
+        C['val'] = "some,funky;stuff"
+        self.assertEqual(C.output(['val']),
+            'Set-Cookie: val="some\\054funky\\073stuff"')
+
     def test_special_attrs(self):
         # 'expires'
         C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"')

Modified: python/branches/py3k-cdecimal/Lib/test/test_httplib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_httplib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_httplib.py	Sun Jan  2 13:18:37 2011
@@ -230,6 +230,22 @@
         conn.send(io.BytesIO(expected))
         self.assertEqual(expected, sock.data)
 
+    def test_send_iter(self):
+        expected = b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \
+                   b'Accept-Encoding: identity\r\nContent-Length: 11\r\n' \
+                   b'\r\nonetwothree'
+
+        def body():
+            yield b"one"
+            yield b"two"
+            yield b"three"
+
+        conn = client.HTTPConnection('example.com')
+        sock = FakeSocket("")
+        conn.sock = sock
+        conn.request('GET', '/foo', body(), {'Content-Length': '11'})
+        self.assertEquals(sock.data, expected)
+
     def test_chunked(self):
         chunked_start = (
             'HTTP/1.1 200 OK\r\n'
@@ -317,6 +333,33 @@
         self.assertEqual("Basic realm=\"example\"",
                          resp.getheader("www-authenticate"))
 
+    # Test lines overflowing the max line size (_MAXLINE in http.client)
+
+    def test_overflowing_status_line(self):
+        body = "HTTP/1.1 200 Ok" + "k" * 65536 + "\r\n"
+        resp = client.HTTPResponse(FakeSocket(body))
+        self.assertRaises((client.LineTooLong, client.BadStatusLine), resp.begin)
+
+    def test_overflowing_header_line(self):
+        body = (
+            'HTTP/1.1 200 OK\r\n'
+            'X-Foo: bar' + 'r' * 65536 + '\r\n\r\n'
+        )
+        resp = client.HTTPResponse(FakeSocket(body))
+        self.assertRaises(client.LineTooLong, resp.begin)
+
+    def test_overflowing_chunked_line(self):
+        body = (
+            'HTTP/1.1 200 OK\r\n'
+            'Transfer-Encoding: chunked\r\n\r\n'
+            + '0' * 65536 + 'a\r\n'
+            'hello world\r\n'
+            '0\r\n'
+        )
+        resp = client.HTTPResponse(FakeSocket(body))
+        resp.begin()
+        self.assertRaises(client.LineTooLong, resp.read)
+
 class OfflineTest(TestCase):
     def test_responses(self):
         self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")

Modified: python/branches/py3k-cdecimal/Lib/test/test_httpservers.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_httpservers.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_httpservers.py	Sun Jan  2 13:18:37 2011
@@ -566,6 +566,19 @@
         self.assertEqual(sum(r == b'Connection: close\r\n' for r in result[1:-1]), 1)
         self.handler = usual_handler        # Restore to avoid breaking any subsequent tests.
 
+    def test_request_length(self):
+        # Issue #10714: huge request lines are discarded, to avoid Denial
+        # of Service attacks.
+        result = self.send_typical_request(b'GET ' + b'x' * 65537)
+        self.assertEqual(result[0], b'HTTP/1.1 414 Request-URI Too Long\r\n')
+        self.assertFalse(self.handler.get_called)
+
+    def test_header_length(self):
+        # Issue #6791: same for headers
+        result = self.send_typical_request(
+            b'GET / HTTP/1.1\r\nX-Foo: bar' + b'r' * 65537 + b'\r\n\r\n')
+        self.assertEqual(result[0], b'HTTP/1.1 400 Line too long\r\n')
+        self.assertFalse(self.handler.get_called)
 
 class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
     """ Test url parsing """

Modified: python/branches/py3k-cdecimal/Lib/test/test_import.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_import.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_import.py	Sun Jan  2 13:18:37 2011
@@ -9,11 +9,13 @@
 import stat
 import sys
 import unittest
+import textwrap
 
 from test.support import (
     EnvironmentVarGuard, TESTFN, check_warnings, forget, is_jython,
     make_legacy_pyc, rmtree, run_unittest, swap_attr, swap_item, temp_umask,
     unlink, unload)
+from test import script_helper
 
 
 def remove_files(name):
@@ -284,6 +286,17 @@
         self.assertEqual("Import by filename is not supported.",
                          c.exception.args[0])
 
+    def test_import_in_del_does_not_crash(self):
+        # Issue 4236
+        testfn = script_helper.make_script('', TESTFN, textwrap.dedent("""\
+            import sys
+            class C:
+               def __del__(self):
+                  import imp
+            sys.argv.insert(0, C())
+            """))
+        script_helper.assert_python_ok(testfn)
+
 
 class PycRewritingTests(unittest.TestCase):
     # Test that the `co_filename` attribute on code objects always points

Modified: python/branches/py3k-cdecimal/Lib/test/test_inspect.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_inspect.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_inspect.py	Sun Jan  2 13:18:37 2011
@@ -6,9 +6,11 @@
 import linecache
 import datetime
 import collections
+import os
+import shutil
 from os.path import normcase
 
-from test.support import run_unittest
+from test.support import run_unittest, TESTFN, DirsOnSysPath
 
 from test import inspect_fodder as mod
 from test import inspect_fodder2 as mod2
@@ -194,12 +196,12 @@
 
 class GetSourceBase(unittest.TestCase):
     # Subclasses must override.
-    fodderFile = None
+    fodderModule = None
 
     def __init__(self, *args, **kwargs):
         unittest.TestCase.__init__(self, *args, **kwargs)
 
-        with open(inspect.getsourcefile(self.fodderFile)) as fp:
+        with open(inspect.getsourcefile(self.fodderModule)) as fp:
             self.source = fp.read()
 
     def sourcerange(self, top, bottom):
@@ -211,7 +213,7 @@
                          self.sourcerange(top, bottom))
 
 class TestRetrievingSourceCode(GetSourceBase):
-    fodderFile = mod
+    fodderModule = mod
 
     def test_getclasses(self):
         classes = inspect.getmembers(mod, inspect.isclass)
@@ -297,7 +299,7 @@
         inspect.getmodule(compile('a=10','','single'))
 
 class TestDecorators(GetSourceBase):
-    fodderFile = mod2
+    fodderModule = mod2
 
     def test_wrapped_decorator(self):
         self.assertSourceEqual(mod2.wrapped, 14, 17)
@@ -306,7 +308,7 @@
         self.assertSourceEqual(mod2.gone, 9, 10)
 
 class TestOneliners(GetSourceBase):
-    fodderFile = mod2
+    fodderModule = mod2
     def test_oneline_lambda(self):
         # Test inspect.getsource with a one-line lambda function.
         self.assertSourceEqual(mod2.oll, 25, 25)
@@ -348,7 +350,7 @@
         self.assertSourceEqual(mod2.anonymous, 55, 55)
 
 class TestBuggyCases(GetSourceBase):
-    fodderFile = mod2
+    fodderModule = mod2
 
     def test_with_comment(self):
         self.assertSourceEqual(mod2.with_comment, 58, 59)
@@ -388,6 +390,24 @@
         self.assertEqual(inspect.findsource(co), (lines,0))
         self.assertEqual(inspect.getsource(co), lines[0])
 
+class TestNoEOL(GetSourceBase):
+    def __init__(self, *args, **kwargs):
+        self.tempdir = TESTFN + '_dir'
+        os.mkdir(self.tempdir)
+        with open(os.path.join(self.tempdir,
+                               'inspect_fodder3%spy' % os.extsep), 'w') as f:
+            f.write("class X:\n    pass # No EOL")
+        with DirsOnSysPath(self.tempdir):
+            import inspect_fodder3 as mod3
+        self.fodderModule = mod3
+        GetSourceBase.__init__(self, *args, **kwargs)
+
+    def tearDown(self):
+        shutil.rmtree(self.tempdir)
+
+    def test_class(self):
+        self.assertSourceEqual(self.fodderModule.X, 1, 2)
+
 # Helper for testing classify_class_attrs.
 def attrs_wo_objs(cls):
     return [t[:3] for t in inspect.classify_class_attrs(cls)]
@@ -931,13 +951,22 @@
         # Running after the first yield
         next(self.generator)
 
+    def test_easy_debugging(self):
+        # repr() and str() of a generator state should contain the state name
+        names = 'GEN_CREATED GEN_RUNNING GEN_SUSPENDED GEN_CLOSED'.split()
+        for name in names:
+            state = getattr(inspect, name)
+            self.assertIn(name, repr(state))
+            self.assertIn(name, str(state))
+
 
 def test_main():
     run_unittest(
         TestDecorators, TestRetrievingSourceCode, TestOneliners, TestBuggyCases,
         TestInterpreterStack, TestClassesAndFunctions, TestPredicates,
         TestGetcallargsFunctions, TestGetcallargsMethods,
-        TestGetcallargsUnboundMethods, TestGetattrStatic, TestGetGeneratorState
+        TestGetcallargsUnboundMethods, TestGetattrStatic, TestGetGeneratorState,
+        TestNoEOL
     )
 
 if __name__ == "__main__":

Modified: python/branches/py3k-cdecimal/Lib/test/test_int.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_int.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_int.py	Sun Jan  2 13:18:37 2011
@@ -20,7 +20,8 @@
         ('  1\02  ', ValueError),
         ('', ValueError),
         (' ', ValueError),
-        ('  \t\t  ', ValueError)
+        ('  \t\t  ', ValueError),
+        ("\u0200", ValueError)
 ]
 
 class IntTestCases(unittest.TestCase):
@@ -35,6 +36,8 @@
         self.assertEqual(int(3.5), 3)
         self.assertEqual(int(-3.5), -3)
         self.assertEqual(int("-3"), -3)
+        self.assertEqual(int(" -3 "), -3)
+        self.assertEqual(int("\N{EM SPACE}-3\N{EN SPACE}"), -3)
         # Different base:
         self.assertEqual(int("10",16), 16)
         # Test conversion from strings and various anomalies
@@ -302,6 +305,16 @@
                     self.fail("Failed to raise TypeError with %s" %
                               ((base, trunc_result_base),))
 
+    def test_error_message(self):
+        testlist = ('\xbd', '123\xbd', '  123 456  ')
+        for s in testlist:
+            try:
+                int(s)
+            except ValueError as e:
+                self.assertIn(s.strip(), e.args[0])
+            else:
+                self.fail("Expected int(%r) to raise a ValueError", s)
+
 def test_main():
     run_unittest(IntTestCases)
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_io.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_io.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_io.py	Sun Jan  2 13:18:37 2011
@@ -730,6 +730,13 @@
         self.assertRaises(self.UnsupportedOperation, bufio.tell)
         self.assertRaises(self.UnsupportedOperation, bufio.seek, 0)
 
+    def test_readonly_attributes(self):
+        raw = self.MockRawIO()
+        buf = self.tp(raw)
+        x = self.MockRawIO()
+        with self.assertRaises(AttributeError):
+            buf.raw = x
+
 
 class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
     read_mode = "rb"
@@ -2245,6 +2252,12 @@
         self.assertRaises(self.UnsupportedOperation, txt.tell)
         self.assertRaises(self.UnsupportedOperation, txt.seek, 0)
 
+    def test_readonly_attributes(self):
+        txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
+        buf = self.BytesIO(self.testdata)
+        with self.assertRaises(AttributeError):
+            txt.buffer = buf
+
 class CTextIOWrapperTest(TextIOWrapperTest):
 
     def test_initialization(self):
@@ -2653,12 +2666,50 @@
     def test_interrupted_write_text(self):
         self.check_interrupted_write("xy", b"xy", mode="w", encoding="ascii")
 
+    def check_reentrant_write(self, data, **fdopen_kwargs):
+        def on_alarm(*args):
+            # Will be called reentrantly from the same thread
+            wio.write(data)
+            1/0
+        signal.signal(signal.SIGALRM, on_alarm)
+        r, w = os.pipe()
+        wio = self.io.open(w, **fdopen_kwargs)
+        try:
+            signal.alarm(1)
+            # Either the reentrant call to wio.write() fails with RuntimeError,
+            # or the signal handler raises ZeroDivisionError.
+            with self.assertRaises((ZeroDivisionError, RuntimeError)) as cm:
+                while 1:
+                    for i in range(100):
+                        wio.write(data)
+                        wio.flush()
+                    # Make sure the buffer doesn't fill up and block further writes
+                    os.read(r, len(data) * 100)
+            exc = cm.exception
+            if isinstance(exc, RuntimeError):
+                self.assertTrue(str(exc).startswith("reentrant call"), str(exc))
+        finally:
+            wio.close()
+            os.close(r)
+
+    def test_reentrant_write_buffered(self):
+        self.check_reentrant_write(b"xy", mode="wb")
+
+    def test_reentrant_write_text(self):
+        self.check_reentrant_write("xy", mode="w", encoding="ascii")
+
+
 class CSignalsTest(SignalsTest):
     io = io
 
 class PySignalsTest(SignalsTest):
     io = pyio
 
+    # Handling reentrancy issues would slow down _pyio even more, so the
+    # tests are disabled.
+    test_reentrant_write_buffered = None
+    test_reentrant_write_text = None
+
 
 def test_main():
     tests = (CIOTest, PyIOTest,

Modified: python/branches/py3k-cdecimal/Lib/test/test_itertools.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_itertools.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_itertools.py	Sun Jan  2 13:18:37 2011
@@ -56,6 +56,24 @@
     return prod(range(1, n+1))
 
 class TestBasicOps(unittest.TestCase):
+
+    def test_accumulate(self):
+        self.assertEqual(list(accumulate(range(10))),               # one positional arg
+                          [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])
+        self.assertEqual(list(accumulate(iterable=range(10))),      # kw arg
+                          [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])
+        for typ in int, complex, Decimal, Fraction:                 # multiple types
+            self.assertEqual(
+                list(accumulate(map(typ, range(10)))),
+                list(map(typ, [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])))
+        self.assertEqual(list(accumulate('abc')), ['a', 'ab', 'abc'])   # works with non-numeric
+        self.assertEqual(list(accumulate([])), [])                  # empty iterable
+        self.assertEqual(list(accumulate([7])), [7])                # iterable of length one
+        self.assertRaises(TypeError, accumulate, range(10), 5)      # too many args
+        self.assertRaises(TypeError, accumulate)                    # too few args
+        self.assertRaises(TypeError, accumulate, x=range(10))       # unexpected kwd arg
+        self.assertRaises(TypeError, list, accumulate([1, []]))     # args that don't add
+
     def test_chain(self):
 
         def chain2(*iterables):
@@ -788,6 +806,11 @@
         self.assertRaises(ValueError, islice, range(10), 1, 'a', 1)
         self.assertEqual(len(list(islice(count(), 1, 10, maxsize))), 1)
 
+        # Issue #10323:  Less islice in a predictable state
+        c = count()
+        self.assertEqual(list(islice(c, 1, 3, 50)), [1])
+        self.assertEqual(next(c), 3)
+
     def test_takewhile(self):
         data = [1, 3, 5, 20, 2, 4, 6, 8]
         underten = lambda x: x<10
@@ -927,6 +950,9 @@
 
 class TestExamples(unittest.TestCase):
 
+    def test_accumlate(self):
+        self.assertEqual(list(accumulate([1,2,3,4,5])), [1, 3, 6, 10, 15])
+
     def test_chain(self):
         self.assertEqual(''.join(chain('ABC', 'DEF')), 'ABCDEF')
 
@@ -1014,6 +1040,10 @@
         next(iterator)
         del container, iterator
 
+    def test_accumulate(self):
+        a = []
+        self.makecycle(accumulate([1,2,a,3]), a)
+
     def test_chain(self):
         a = []
         self.makecycle(chain(a), a)
@@ -1183,6 +1213,17 @@
 
 class TestVariousIteratorArgs(unittest.TestCase):
 
+    def test_accumulate(self):
+        s = [1,2,3,4,5]
+        r = [1,3,6,10,15]
+        n = len(s)
+        for g in (G, I, Ig, L, R):
+            self.assertEqual(list(accumulate(g(s))), r)
+        self.assertEqual(list(accumulate(S(s))), [])
+        self.assertRaises(TypeError, accumulate, X(s))
+        self.assertRaises(TypeError, accumulate, N(s))
+        self.assertRaises(ZeroDivisionError, list, accumulate(E(s)))
+
     def test_chain(self):
         for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
             for g in (G, I, Ig, S, L, R):

Modified: python/branches/py3k-cdecimal/Lib/test/test_json.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_json.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_json.py	Sun Jan  2 13:18:37 2011
@@ -5,12 +5,12 @@
 be run.
 """
 
-import json.tests
+from test import json_tests
 import test.support
 
 
 def test_main():
-    test.support.run_unittest(json.tests.test_suite())
+    test.support.run_unittest(json_tests.test_suite())
 
 
 if __name__ == "__main__":

Modified: python/branches/py3k-cdecimal/Lib/test/test_listcomps.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_listcomps.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_listcomps.py	Sun Jan  2 13:18:37 2011
@@ -146,299 +146,3 @@
 
 if __name__ == "__main__":
     test_main(verbose=True)
-doctests = """
-########### Tests borrowed from or inspired by test_genexps.py ############
-
-Test simple loop with conditional
-
-    >>> sum([i*i for i in range(100) if i&1 == 1])
-    166650
-
-Test simple nesting
-
-    >>> [(i,j) for i in range(3) for j in range(4)]
-    [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)]
-
-Test nesting with the inner expression dependent on the outer
-
-    >>> [(i,j) for i in range(4) for j in range(i)]
-    [(1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (3, 2)]
-
-Make sure the induction variable is not exposed
-
-    >>> i = 20
-    >>> sum([i*i for i in range(100)])
-    328350
-
-    >>> i
-    20
-
-Verify that syntax error's are raised for listcomps used as lvalues
-
-    >>> [y for y in (1,2)] = 10          # doctest: +IGNORE_EXCEPTION_DETAIL
-    Traceback (most recent call last):
-       ...
-    SyntaxError: ...
-
-    >>> [y for y in (1,2)] += 10         # doctest: +IGNORE_EXCEPTION_DETAIL
-    Traceback (most recent call last):
-       ...
-    SyntaxError: ...
-
-
-########### Tests borrowed from or inspired by test_generators.py ############
-
-Make a nested list comprehension that acts like range()
-
-    >>> def frange(n):
-    ...     return [i for i in range(n)]
-    >>> frange(10)
-    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
-Same again, only as a lambda expression instead of a function definition
-
-    >>> lrange = lambda n:  [i for i in range(n)]
-    >>> lrange(10)
-    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
-Generators can call other generators:
-
-    >>> def grange(n):
-    ...     for x in [i for i in range(n)]:
-    ...         yield x
-    >>> list(grange(5))
-    [0, 1, 2, 3, 4]
-
-
-Make sure that None is a valid return value
-
-    >>> [None for i in range(10)]
-    [None, None, None, None, None, None, None, None, None, None]
-
-########### Tests for various scoping corner cases ############
-
-Return lambdas that use the iteration variable as a default argument
-
-    >>> items = [(lambda i=i: i) for i in range(5)]
-    >>> [x() for x in items]
-    [0, 1, 2, 3, 4]
-
-Same again, only this time as a closure variable
-
-    >>> items = [(lambda: i) for i in range(5)]
-    >>> [x() for x in items]
-    [4, 4, 4, 4, 4]
-
-Another way to test that the iteration variable is local to the list comp
-
-    >>> items = [(lambda: i) for i in range(5)]
-    >>> i = 20
-    >>> [x() for x in items]
-    [4, 4, 4, 4, 4]
-
-And confirm that a closure can jump over the list comp scope
-
-    >>> items = [(lambda: y) for i in range(5)]
-    >>> y = 2
-    >>> [x() for x in items]
-    [2, 2, 2, 2, 2]
-
-We also repeat each of the above scoping tests inside a function
-
-    >>> def test_func():
-    ...     items = [(lambda i=i: i) for i in range(5)]
-    ...     return [x() for x in items]
-    >>> test_func()
-    [0, 1, 2, 3, 4]
-
-    >>> def test_func():
-    ...     items = [(lambda: i) for i in range(5)]
-    ...     return [x() for x in items]
-    >>> test_func()
-    [4, 4, 4, 4, 4]
-
-    >>> def test_func():
-    ...     items = [(lambda: i) for i in range(5)]
-    ...     i = 20
-    ...     return [x() for x in items]
-    >>> test_func()
-    [4, 4, 4, 4, 4]
-
-    >>> def test_func():
-    ...     items = [(lambda: y) for i in range(5)]
-    ...     y = 2
-    ...     return [x() for x in items]
-    >>> test_func()
-    [2, 2, 2, 2, 2]
-
-"""
-
-
-__test__ = {'doctests' : doctests}
-
-def test_main(verbose=None):
-    import sys
-    from test import support
-    from test import test_listcomps
-    support.run_doctest(test_listcomps, verbose)
-
-    # verify reference counting
-    if verbose and hasattr(sys, "gettotalrefcount"):
-        import gc
-        counts = [None] * 5
-        for i in range(len(counts)):
-            support.run_doctest(test_genexps, verbose)
-            gc.collect()
-            counts[i] = sys.gettotalrefcount()
-        print(counts)
-
-if __name__ == "__main__":
-    test_main(verbose=True)
-doctests = """
-########### Tests borrowed from or inspired by test_genexps.py ############
-
-Test simple loop with conditional
-
-    >>> sum([i*i for i in range(100) if i&1 == 1])
-    166650
-
-Test simple nesting
-
-    >>> [(i,j) for i in range(3) for j in range(4)]
-    [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)]
-
-Test nesting with the inner expression dependent on the outer
-
-    >>> [(i,j) for i in range(4) for j in range(i)]
-    [(1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (3, 2)]
-
-Make sure the induction variable is not exposed
-
-    >>> i = 20
-    >>> sum([i*i for i in range(100)])
-    328350
-
-    >>> i
-    20
-
-Verify that syntax error's are raised for listcomps used as lvalues
-
-    >>> [y for y in (1,2)] = 10          # doctest: +IGNORE_EXCEPTION_DETAIL
-    Traceback (most recent call last):
-       ...
-    SyntaxError: ...
-
-    >>> [y for y in (1,2)] += 10         # doctest: +IGNORE_EXCEPTION_DETAIL
-    Traceback (most recent call last):
-       ...
-    SyntaxError: ...
-
-
-########### Tests borrowed from or inspired by test_generators.py ############
-
-Make a nested list comprehension that acts like range()
-
-    >>> def frange(n):
-    ...     return [i for i in range(n)]
-    >>> frange(10)
-    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
-Same again, only as a lambda expression instead of a function definition
-
-    >>> lrange = lambda n:  [i for i in range(n)]
-    >>> lrange(10)
-    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-
-Generators can call other generators:
-
-    >>> def grange(n):
-    ...     for x in [i for i in range(n)]:
-    ...         yield x
-    >>> list(grange(5))
-    [0, 1, 2, 3, 4]
-
-
-Make sure that None is a valid return value
-
-    >>> [None for i in range(10)]
-    [None, None, None, None, None, None, None, None, None, None]
-
-########### Tests for various scoping corner cases ############
-
-Return lambdas that use the iteration variable as a default argument
-
-    >>> items = [(lambda i=i: i) for i in range(5)]
-    >>> [x() for x in items]
-    [0, 1, 2, 3, 4]
-
-Same again, only this time as a closure variable
-
-    >>> items = [(lambda: i) for i in range(5)]
-    >>> [x() for x in items]
-    [4, 4, 4, 4, 4]
-
-Another way to test that the iteration variable is local to the list comp
-
-    >>> items = [(lambda: i) for i in range(5)]
-    >>> i = 20
-    >>> [x() for x in items]
-    [4, 4, 4, 4, 4]
-
-And confirm that a closure can jump over the list comp scope
-
-    >>> items = [(lambda: y) for i in range(5)]
-    >>> y = 2
-    >>> [x() for x in items]
-    [2, 2, 2, 2, 2]
-
-We also repeat each of the above scoping tests inside a function
-
-    >>> def test_func():
-    ...     items = [(lambda i=i: i) for i in range(5)]
-    ...     return [x() for x in items]
-    >>> test_func()
-    [0, 1, 2, 3, 4]
-
-    >>> def test_func():
-    ...     items = [(lambda: i) for i in range(5)]
-    ...     return [x() for x in items]
-    >>> test_func()
-    [4, 4, 4, 4, 4]
-
-    >>> def test_func():
-    ...     items = [(lambda: i) for i in range(5)]
-    ...     i = 20
-    ...     return [x() for x in items]
-    >>> test_func()
-    [4, 4, 4, 4, 4]
-
-    >>> def test_func():
-    ...     items = [(lambda: y) for i in range(5)]
-    ...     y = 2
-    ...     return [x() for x in items]
-    >>> test_func()
-    [2, 2, 2, 2, 2]
-
-"""
-
-
-__test__ = {'doctests' : doctests}
-
-def test_main(verbose=None):
-    import sys
-    from test import support
-    from test import test_listcomps
-    support.run_doctest(test_listcomps, verbose)
-
-    # verify reference counting
-    if verbose and hasattr(sys, "gettotalrefcount"):
-        import gc
-        counts = [None] * 5
-        for i in range(len(counts)):
-            support.run_doctest(test_listcomps, verbose)
-            gc.collect()
-            counts[i] = sys.gettotalrefcount()
-        print(counts)
-
-if __name__ == "__main__":
-    test_main(verbose=True)

Modified: python/branches/py3k-cdecimal/Lib/test/test_logging.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_logging.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_logging.py	Sun Jan  2 13:18:37 2011
@@ -67,8 +67,12 @@
         try:
             self.saved_handlers = logging._handlers.copy()
             self.saved_handler_list = logging._handlerList[:]
-            self.saved_loggers = logger_dict.copy()
+            self.saved_loggers = saved_loggers = logger_dict.copy()
             self.saved_level_names = logging._levelNames.copy()
+            self.logger_states = logger_states = {}
+            for name in saved_loggers:
+                logger_states[name] = getattr(saved_loggers[name],
+                                              'disabled', None)
         finally:
             logging._releaseLock()
 
@@ -86,8 +90,12 @@
         self.root_hdlr = logging.StreamHandler(self.stream)
         self.root_formatter = logging.Formatter(self.log_format)
         self.root_hdlr.setFormatter(self.root_formatter)
-        self.assertFalse(self.logger1.hasHandlers())
-        self.assertFalse(self.logger2.hasHandlers())
+        if self.logger1.hasHandlers():
+            hlist = self.logger1.handlers + self.root_logger.handlers
+            raise AssertionError('Unexpected handlers: %s' % hlist)
+        if self.logger2.hasHandlers():
+            hlist = self.logger2.handlers + self.root_logger.handlers
+            raise AssertionError('Unexpected handlers: %s' % hlist)
         self.root_logger.addHandler(self.root_hdlr)
         self.assertTrue(self.logger1.hasHandlers())
         self.assertTrue(self.logger2.hasHandlers())
@@ -112,6 +120,10 @@
             loggerDict = logging.getLogger().manager.loggerDict
             loggerDict.clear()
             loggerDict.update(self.saved_loggers)
+            logger_states = self.logger_states
+            for name in self.logger_states:
+                if logger_states[name] is not None:
+                    self.saved_loggers[name].disabled = logger_states[name]
         finally:
             logging._releaseLock()
 
@@ -907,7 +919,8 @@
     def test_encoding_plain_file(self):
         # In Python 2.x, a plain file object is treated as having no encoding.
         log = logging.getLogger("test")
-        fn = tempfile.mktemp(".log", "test_logging-1-")
+        fd, fn = tempfile.mkstemp(".log", "test_logging-1-")
+        os.close(fd)
         # the non-ascii data we write to the log.
         data = "foo\x80"
         try:
@@ -1799,7 +1812,7 @@
 class DerivedLogRecord(logging.LogRecord):
     pass
 
-class LogRecordClassTest(BaseTest):
+class LogRecordFactoryTest(BaseTest):
 
     def setUp(self):
         class CheckingFilter(logging.Filter):
@@ -1817,17 +1830,17 @@
         BaseTest.setUp(self)
         self.filter = CheckingFilter(DerivedLogRecord)
         self.root_logger.addFilter(self.filter)
-        self.orig_cls = logging.getLogRecordClass()
+        self.orig_factory = logging.getLogRecordFactory()
 
     def tearDown(self):
         self.root_logger.removeFilter(self.filter)
         BaseTest.tearDown(self)
-        logging.setLogRecordClass(self.orig_cls)
+        logging.setLogRecordFactory(self.orig_factory)
 
     def test_logrecord_class(self):
         self.assertRaises(TypeError, self.root_logger.warning,
                           self.next_message())
-        logging.setLogRecordClass(DerivedLogRecord)
+        logging.setLogRecordFactory(DerivedLogRecord)
         self.root_logger.error(self.next_message())
         self.assert_log_lines([
            ('root', 'ERROR', '2'),
@@ -1885,7 +1898,7 @@
         return logging.makeLogRecord(result)
 
     def test_percent(self):
-        "Test %-formatting"
+        # Test %-formatting
         r = self.get_record()
         f = logging.Formatter('${%(message)s}')
         self.assertEqual(f.format(r), '${Message with 2 placeholders}')
@@ -1898,7 +1911,7 @@
         self.assertFalse(f.usesTime())
 
     def test_braces(self):
-        "Test {}-formatting"
+        # Test {}-formatting
         r = self.get_record()
         f = logging.Formatter('$%{message}%$', style='{')
         self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
@@ -1911,7 +1924,7 @@
         self.assertFalse(f.usesTime())
 
     def test_dollars(self):
-        "Test $-formatting"
+        # Test $-formatting
         r = self.get_record()
         f = logging.Formatter('$message', style='$')
         self.assertEqual(f.format(r), 'Message with 2 placeholders')
@@ -1927,17 +1940,54 @@
         f = logging.Formatter('asctime', style='$')
         self.assertFalse(f.usesTime())
 
+class LastResortTest(BaseTest):
+    def test_last_resort(self):
+        # Test the last resort handler
+        root = self.root_logger
+        root.removeHandler(self.root_hdlr)
+        old_stderr = sys.stderr
+        old_lastresort = logging.lastResort
+        old_raise_exceptions = logging.raiseExceptions
+        try:
+            sys.stderr = sio = io.StringIO()
+            root.warning('This is your final chance!')
+            self.assertEqual(sio.getvalue(), 'This is your final chance!\n')
+            #No handlers and no last resort, so 'No handlers' message
+            logging.lastResort = None
+            sys.stderr = sio = io.StringIO()
+            root.warning('This is your final chance!')
+            self.assertEqual(sio.getvalue(), 'No handlers could be found for logger "root"\n')
+            # 'No handlers' message only printed once
+            sys.stderr = sio = io.StringIO()
+            root.warning('This is your final chance!')
+            self.assertEqual(sio.getvalue(), '')
+            root.manager.emittedNoHandlerWarning = False
+            #If raiseExceptions is False, no message is printed
+            logging.raiseExceptions = False
+            sys.stderr = sio = io.StringIO()
+            root.warning('This is your final chance!')
+            self.assertEqual(sio.getvalue(), '')
+        finally:
+            sys.stderr = old_stderr
+            root.addHandler(self.root_hdlr)
+            logging.lastResort = old_lastresort
+            logging.raiseExceptions = old_raise_exceptions
+
+
 class BaseFileTest(BaseTest):
     "Base class for handler tests that write log files"
 
     def setUp(self):
         BaseTest.setUp(self)
-        self.fn = tempfile.mktemp(".log", "test_logging-2-")
+        fd, self.fn = tempfile.mkstemp(".log", "test_logging-2-")
+        os.close(fd)
         self.rmfiles = []
 
     def tearDown(self):
         for fn in self.rmfiles:
             os.unlink(fn)
+        if os.path.exists(self.fn):
+            os.unlink(self.fn)
         BaseTest.tearDown(self)
 
     def assertLogFile(self, filename):
@@ -1966,7 +2016,6 @@
     def test_file_created(self):
         # checks that the file is created and assumes it was created
         # by us
-        self.assertFalse(os.path.exists(self.fn))
         rh = logging.handlers.RotatingFileHandler(self.fn)
         rh.emit(self.next_rec())
         self.assertLogFile(self.fn)
@@ -2015,8 +2064,9 @@
                  ConfigFileTest, SocketHandlerTest, MemoryTest,
                  EncodingTest, WarningsTest, ConfigDictTest, ManagerTest,
                  FormatterTest,
-                 LogRecordClassTest, ChildLoggerTest, QueueHandlerTest,
+                 LogRecordFactoryTest, ChildLoggerTest, QueueHandlerTest,
                  RotatingFileHandlerTest,
+                 LastResortTest,
                  #TimedRotatingFileHandlerTest
                 )
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_long.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_long.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_long.py	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,6 @@
 import unittest
 from test import support
+
 import sys
 
 import random
@@ -15,11 +16,6 @@
     def __str__(self):
         return self.format % self.args
 
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(
-    float.__getformat__("double").startswith("IEEE"),
-    "test requires IEEE 754 doubles")
-
 # SHIFT should match the value in longintrepr.h for best testing.
 SHIFT = sys.int_info.bits_per_digit
 BASE = 2 ** SHIFT
@@ -276,7 +272,7 @@
         digits = digits or [0]
         return '-'[:sign] + \
                {2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \
-               "".join(map(lambda i: "0123456789abcdef"[i], digits))
+               "".join("0123456789abcdef"[i] for i in digits)
 
     def check_format_1(self, x):
         for base, mapper in (8, oct), (10, repr), (16, hex):
@@ -371,8 +367,7 @@
                 return 1729
         self.assertEqual(int(LongTrunc()), 1729)
 
-    @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
-                         "test requires IEEE 754 doubles")
+    @support.requires_IEEE_754
     def test_float_conversion(self):
 
         exact_values = [0, 1, 2,
@@ -703,7 +698,7 @@
         self.assertEqual(expected, got, "Incorrectly rounded division {}/{}: "
                          "expected {}, got {}".format(a, b, expected, got))
 
-    @requires_IEEE_754
+    @support.requires_IEEE_754
     def test_correctly_rounded_true_division(self):
         # more stringent tests than those above, checking that the
         # result of true division of ints is always correctly rounded.

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	Sun Jan  2 13:18:37 2011
@@ -1,7 +1,7 @@
 # Python test set -- math module
 # XXXX Should not do tests around zero only
 
-from test.support import run_unittest, verbose
+from test.support import run_unittest, verbose, requires_IEEE_754
 import unittest
 import math
 import os
@@ -15,11 +15,6 @@
 INF = float('inf')
 NINF = float('-inf')
 
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(
-    float.__getformat__("double").startswith("IEEE"),
-    "test requires IEEE 754 doubles")
-
 # detect evidence of double-rounding: fsum is not always correctly
 # rounded on machines that suffer from double rounding.
 x, y = 1e16, 2.9999 # use temporary values to defeat peephole optimizer

Modified: python/branches/py3k-cdecimal/Lib/test/test_memoryview.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_memoryview.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_memoryview.py	Sun Jan  2 13:18:37 2011
@@ -226,7 +226,7 @@
             self.assertTrue(wr() is None, wr())
 
     def _check_released(self, m, tp):
-        check = self.assertRaisesRegexp(ValueError, "released")
+        check = self.assertRaisesRegex(ValueError, "released")
         with check: bytes(m)
         with check: m.tobytes()
         with check: m.tolist()

Modified: python/branches/py3k-cdecimal/Lib/test/test_multiprocessing.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_multiprocessing.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_multiprocessing.py	Sun Jan  2 13:18:37 2011
@@ -815,8 +815,6 @@
 #
 #
 
- at unittest.skipUnless(HAS_SHAREDCTYPES,
-                     "requires multiprocessing.sharedctypes")
 class _TestValue(BaseTestCase):
 
     ALLOWED_TYPES = ('processes',)
@@ -828,6 +826,10 @@
         ('c', latin('x'), latin('y'))
         ]
 
+    def setUp(self):
+        if not HAS_SHAREDCTYPES:
+            self.skipTest("requires multiprocessing.sharedctypes")
+
     @classmethod
     def _test(cls, values):
         for sv, cv in zip(values, cls.codes_values):
@@ -1662,12 +1664,14 @@
         ('y', c_double)
         ]
 
- at unittest.skipUnless(HAS_SHAREDCTYPES,
-                     "requires multiprocessing.sharedctypes")
 class _TestSharedCTypes(BaseTestCase):
 
     ALLOWED_TYPES = ('processes',)
 
+    def setUp(self):
+        if not HAS_SHAREDCTYPES:
+            self.skipTest("requires multiprocessing.sharedctypes")
+
     @classmethod
     def _double(cls, x, y, foo, arr, string):
         x.value *= 2

Modified: python/branches/py3k-cdecimal/Lib/test/test_netrc.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_netrc.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_netrc.py	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,13 @@
 from test import support
 
 TEST_NETRC = """
+
+ #this is a comment
+#this is a comment
+# this is a comment
+
 machine foo login log1 password pass1 account acct1
+machine bar login log1 password pass# account acct1
 
 macdef macro1
 line1
@@ -28,17 +34,21 @@
         fp = open(temp_filename, mode)
         fp.write(TEST_NETRC)
         fp.close()
+        self.nrc = netrc.netrc(temp_filename)
 
     def tearDown(self):
         os.unlink(temp_filename)
 
     def test_case_1(self):
-        nrc = netrc.netrc(temp_filename)
-        self.assertTrue(nrc.macros == {'macro1':['line1\n', 'line2\n'],
-                                           'macro2':['line3\n', 'line4\n']}
-                                           )
-        self.assertTrue(nrc.hosts['foo'] == ('log1', 'acct1', 'pass1'))
-        self.assertTrue(nrc.hosts['default'] == ('log2', None, 'pass2'))
+        self.assertEqual(self.nrc.hosts['foo'], ('log1', 'acct1', 'pass1'))
+        self.assertEqual(self.nrc.hosts['default'], ('log2', None, 'pass2'))
+
+    def test_macros(self):
+        self.assertEqual(self.nrc.macros, {'macro1':['line1\n', 'line2\n'],
+                                           'macro2':['line3\n', 'line4\n']})
+
+    def test_parses_passwords_with_hash_character(self):
+        self.assertEqual(self.nrc.hosts['bar'], ('log1', 'acct1', 'pass#'))
 
 def test_main():
     support.run_unittest(NetrcTestCase)

Modified: python/branches/py3k-cdecimal/Lib/test/test_normalization.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_normalization.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_normalization.py	Sun Jan  2 13:18:37 2011
@@ -45,6 +45,7 @@
                                         check=check_version)
         except (IOError, HTTPException):
             self.skipTest("Could not retrieve " + TESTDATAURL)
+        self.addCleanup(testdata.close)
         for line in testdata:
             if '#' in line:
                 line = line.split('#')[0]
@@ -54,9 +55,6 @@
             if line.startswith("@Part"):
                 part = line.split()[0]
                 continue
-            if part == "@Part3":
-                # XXX we don't support PRI #29 yet, so skip these tests for now
-                continue
             try:
                 c1,c2,c3,c4,c5 = [unistr(x) for x in line.split(';')[:-1]]
             except RangeError:

Modified: python/branches/py3k-cdecimal/Lib/test/test_ntpath.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_ntpath.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_ntpath.py	Sun Jan  2 13:18:37 2011
@@ -248,7 +248,7 @@
             self.assertFalse(ntpath.sameopenfile(tf1.fileno(), tf2.fileno()))
             # Make sure invalid values don't cause issues on win32
             if sys.platform == "win32":
-                with self.assertRaises(ValueError):
+                with self.assertRaises(OSError):
                     # Invalid file descriptors shouldn't display assert
                     # dialogs (#4804)
                     ntpath.sameopenfile(-1, -1)

Modified: python/branches/py3k-cdecimal/Lib/test/test_os.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_os.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_os.py	Sun Jan  2 13:18:37 2011
@@ -630,6 +630,28 @@
                             'dir5', 'dir6')
         os.makedirs(path)
 
+    def test_exist_ok_existing_directory(self):
+        path = os.path.join(support.TESTFN, 'dir1')
+        mode = 0o777
+        old_mask = os.umask(0o022)
+        os.makedirs(path, mode)
+        self.assertRaises(OSError, os.makedirs, path, mode)
+        self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False)
+        self.assertRaises(OSError, os.makedirs, path, 0o776, exist_ok=True)
+        os.makedirs(path, mode=mode, exist_ok=True)
+        os.umask(old_mask)
+
+    def test_exist_ok_existing_regular_file(self):
+        base = support.TESTFN
+        path = os.path.join(support.TESTFN, 'dir1')
+        f = open(path, 'w')
+        f.write('abc')
+        f.close()
+        self.assertRaises(OSError, os.makedirs, path)
+        self.assertRaises(OSError, os.makedirs, path, exist_ok=False)
+        self.assertRaises(OSError, os.makedirs, path, exist_ok=True)
+        os.remove(path)
+
     def tearDown(self):
         path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3',
                             'dir4', 'dir5', 'dir6')
@@ -860,6 +882,42 @@
         if hasattr(os, "write"):
             self.check(os.write, b" ")
 
+
+class LinkTests(unittest.TestCase):
+    def setUp(self):
+        self.file1 = support.TESTFN
+        self.file2 = os.path.join(support.TESTFN + "2")
+
+    def tearDown(self):
+        for file in (self.file1, self.file2):
+            if os.path.exists(file):
+                os.unlink(file)
+
+    def _test_link(self, file1, file2):
+        with open(file1, "w") as f1:
+            f1.write("test")
+
+        os.link(file1, file2)
+        with open(file1, "r") as f1, open(file2, "r") as f2:
+            self.assertTrue(os.path.sameopenfile(f1.fileno(), f2.fileno()))
+
+    def test_link(self):
+        self._test_link(self.file1, self.file2)
+
+    def test_link_bytes(self):
+        self._test_link(bytes(self.file1, sys.getfilesystemencoding()),
+                        bytes(self.file2, sys.getfilesystemencoding()))
+
+    def test_unicode_name(self):
+        try:
+            os.fsencode("\xf1")
+        except UnicodeError:
+            raise unittest.SkipTest("Unable to encode for this platform.")
+
+        self.file1 += "\xf1"
+        self.file2 = self.file1 + "2"
+        self._test_link(self.file1, self.file2)
+
 if sys.platform != 'win32':
     class Win32ErrorTests(unittest.TestCase):
         pass
@@ -1048,13 +1106,15 @@
                                 "win_console_handler.py"), tagname],
                    creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
         # Let the interpreter startup before we send signals. See #3137.
-        count, max = 0, 20
+        count, max = 0, 100
         while count < max and proc.poll() is None:
             if m[0] == 1:
                 break
-            time.sleep(0.5)
+            time.sleep(0.1)
             count += 1
         else:
+            # Forcefully kill the process if we weren't able to signal it.
+            os.kill(proc.pid, signal.SIGINT)
             self.fail("Subprocess didn't finish initialization")
         os.kill(proc.pid, event)
         # proc.send_signal(event) could also be done here.
@@ -1088,12 +1148,6 @@
         self._kill_with_event(signal.CTRL_BREAK_EVENT, "CTRL_BREAK_EVENT")
 
 
-def skipUnlessWindows6(test):
-    if (hasattr(sys, 'getwindowsversion')
-        and sys.getwindowsversion().major >= 6):
-        return test
-    return unittest.skip("Requires Windows Vista or later")(test)
-
 @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
 @support.skip_unless_symlink
 class Win32SymlinkTests(unittest.TestCase):
@@ -1221,6 +1275,7 @@
         FSEncodingTests,
         PidTests,
         LoginTests,
+        LinkTests,
     )
 
 if __name__ == "__main__":

Modified: python/branches/py3k-cdecimal/Lib/test/test_pdb.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_pdb.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_pdb.py	Sun Jan  2 13:18:37 2011
@@ -29,7 +29,7 @@
     """This tests the custom displayhook for pdb.
 
     >>> def test_function(foo, bar):
-    ...     import pdb; pdb.Pdb().set_trace()
+    ...     import pdb; pdb.Pdb(nosigint=True).set_trace()
     ...     pass
 
     >>> with PdbTestInput([
@@ -69,7 +69,7 @@
     ...     return foo.upper()
 
     >>> def test_function():
-    ...     import pdb; pdb.Pdb().set_trace()
+    ...     import pdb; pdb.Pdb(nosigint=True).set_trace()
     ...     ret = test_function_2('baz')
     ...     print(ret)
 
@@ -168,7 +168,7 @@
     """Test basic commands related to breakpoints.
 
     >>> def test_function():
-    ...     import pdb; pdb.Pdb().set_trace()
+    ...     import pdb; pdb.Pdb(nosigint=True).set_trace()
     ...     print(1)
     ...     print(2)
     ...     print(3)
@@ -192,6 +192,9 @@
     ...     'ignore 1 10',
     ...     'condition 1 1 < 2',
     ...     'break 4',
+    ...     'break 4',
+    ...     'break',
+    ...     'clear 3',
     ...     'break',
     ...     'condition 1',
     ...     'enable 1',
@@ -220,6 +223,17 @@
     New condition set for breakpoint 1.
     (Pdb) break 4
     Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
+    (Pdb) break 4
+    Breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
+    (Pdb) break
+    Num Type         Disp Enb   Where
+    1   breakpoint   keep no    at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
+            stop only if 1 < 2
+            ignore next 10 hits
+    2   breakpoint   keep yes   at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
+    3   breakpoint   keep yes   at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
+    (Pdb) clear 3
+    Deleted breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
     (Pdb) break
     Num Type         Disp Enb   Where
     1   breakpoint   keep no    at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
@@ -244,10 +258,10 @@
     Clear all breaks? y
     Deleted breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
     (Pdb) tbreak 5
-    Breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5
+    Breakpoint 4 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5
     (Pdb) continue
     2
-    Deleted breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5
+    Deleted breakpoint 4 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5
     > <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(5)test_function()
     -> print(3)
     (Pdb) break
@@ -283,7 +297,7 @@
     ...     return foo
 
     >>> def test_function():
-    ...     import pdb; pdb.Pdb().set_trace()
+    ...     import pdb; pdb.Pdb(nosigint=True).set_trace()
     ...     ret = test_function_2('baz')
 
     >>> with PdbTestInput([  # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
@@ -306,7 +320,7 @@
     -> ret = test_function_2('baz')
     (Pdb) list
       1         def test_function():
-      2             import pdb; pdb.Pdb().set_trace()
+      2             import pdb; pdb.Pdb(nosigint=True).set_trace()
       3  ->         ret = test_function_2('baz')
     [EOF]
     (Pdb) step
@@ -369,7 +383,7 @@
     ...         print('Exception!')
 
     >>> def test_function():
-    ...     import pdb; pdb.Pdb().set_trace()
+    ...     import pdb; pdb.Pdb(nosigint=True).set_trace()
     ...     test_function_2()
     ...     print('Not reached.')
 
@@ -402,7 +416,7 @@
     -> 1/0
     (Pdb) list
       1         def test_function():
-      2             import pdb; pdb.Pdb().set_trace()
+      2             import pdb; pdb.Pdb(nosigint=True).set_trace()
       3  ->         test_function_2()
       4             print('Not reached.')
     [EOF]
@@ -426,7 +440,7 @@
 
     >>> def skip_module():
     ...     import string
-    ...     import pdb; pdb.Pdb(skip=['stri*']).set_trace()
+    ...     import pdb; pdb.Pdb(skip=['stri*'], nosigint=True).set_trace()
     ...     string.capwords('FOO')
 
     >>> with PdbTestInput([
@@ -455,7 +469,7 @@
     >>> def skip_module():
     ...     def callback():
     ...         return None
-    ...     import pdb; pdb.Pdb(skip=['module_to_skip*']).set_trace()
+    ...     import pdb; pdb.Pdb(skip=['module_to_skip*'], nosigint=True).set_trace()
     ...     mod.foo_pony(callback)
 
     >>> with PdbTestInput([
@@ -496,7 +510,7 @@
     """Test that "continue" and "next" work properly in bottom frame (issue #5294).
 
     >>> def test_function():
-    ...     import pdb, sys; inst = pdb.Pdb()
+    ...     import pdb, sys; inst = pdb.Pdb(nosigint=True)
     ...     inst.set_trace()
     ...     inst.botframe = sys._getframe()  # hackery to get the right botframe
     ...     print(1)
@@ -536,7 +550,8 @@
 
 def pdb_invoke(method, arg):
     """Run pdb.method(arg)."""
-    import pdb; getattr(pdb, method)(arg)
+    import pdb
+    getattr(pdb.Pdb(nosigint=True), method)(arg)
 
 
 def test_pdb_run_with_incorrect_argument():

Modified: python/branches/py3k-cdecimal/Lib/test/test_posixpath.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_posixpath.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_posixpath.py	Sun Jan  2 13:18:37 2011
@@ -180,7 +180,8 @@
     @unittest.skipIf(
         sys.platform.startswith('win'),
         "posixpath.samefile does not work on links in Windows")
-    @support.skip_unless_symlink
+    @unittest.skipUnless(hasattr(os, "symlink"),
+                         "Missing symlink implementation")
     def test_samefile_on_links(self):
         test_fn1 = support.TESTFN + "1"
         test_fn2 = support.TESTFN + "2"
@@ -204,7 +205,8 @@
     @unittest.skipIf(
         sys.platform.startswith('win'),
         "posixpath.samestat does not work on links in Windows")
-    @support.skip_unless_symlink
+    @unittest.skipUnless(hasattr(os, "symlink"),
+                         "Missing symlink implementation")
     def test_samestat_on_links(self):
         test_fn1 = support.TESTFN + "1"
         test_fn2 = support.TESTFN + "2"
@@ -273,7 +275,8 @@
         self.assertEqual(posixpath.normpath(b"///..//./foo/.//bar"),
                          b"/foo/bar")
 
-    @support.skip_unless_symlink
+    @unittest.skipUnless(hasattr(os, "symlink"),
+                         "Missing symlink implementation")
     @skip_if_ABSTFN_contains_backslash
     def test_realpath_basic(self):
         # Basic operation.
@@ -283,7 +286,8 @@
         finally:
             support.unlink(ABSTFN)
 
-    @support.skip_unless_symlink
+    @unittest.skipUnless(hasattr(os, "symlink"),
+                         "Missing symlink implementation")
     @skip_if_ABSTFN_contains_backslash
     def test_realpath_symlink_loops(self):
         # Bug #930024, return the path unchanged if we get into an infinite
@@ -307,7 +311,8 @@
             support.unlink(ABSTFN+"1")
             support.unlink(ABSTFN+"2")
 
-    @support.skip_unless_symlink
+    @unittest.skipUnless(hasattr(os, "symlink"),
+                         "Missing symlink implementation")
     @skip_if_ABSTFN_contains_backslash
     def test_realpath_resolve_parents(self):
         # We also need to resolve any symlinks in the parents of a relative
@@ -328,7 +333,8 @@
             safe_rmdir(ABSTFN + "/y")
             safe_rmdir(ABSTFN)
 
-    @support.skip_unless_symlink
+    @unittest.skipUnless(hasattr(os, "symlink"),
+                         "Missing symlink implementation")
     @skip_if_ABSTFN_contains_backslash
     def test_realpath_resolve_before_normalizing(self):
         # Bug #990669: Symbolic links should be resolved before we
@@ -358,7 +364,8 @@
             safe_rmdir(ABSTFN + "/k")
             safe_rmdir(ABSTFN)
 
-    @support.skip_unless_symlink
+    @unittest.skipUnless(hasattr(os, "symlink"),
+                         "Missing symlink implementation")
     @skip_if_ABSTFN_contains_backslash
     def test_realpath_resolve_first(self):
         # Bug #1213894: The first component of the path, if not absolute,

Modified: python/branches/py3k-cdecimal/Lib/test/test_pydoc.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_pydoc.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_pydoc.py	Sun Jan  2 13:18:37 2011
@@ -1,17 +1,20 @@
-import sys
 import os
-import os.path
+import sys
 import difflib
-import subprocess
-import re
-import pydoc
 import inspect
-import unittest
+import pydoc
+import re
+import string
+import subprocess
 import test.support
+import time
+import unittest
 import xml.etree
+import textwrap
+from io import StringIO
 from contextlib import contextmanager
-from test.support import (
-    TESTFN, forget, rmtree, EnvironmentVarGuard, reap_children)
+from test.support import TESTFN, forget, rmtree, EnvironmentVarGuard, \
+     reap_children, captured_output
 
 from test import pydoc_mod
 
@@ -219,19 +222,27 @@
 
     output = doc.docmodule(module)
 
-    # cleanup the extra text formatting that pydoc preforms
+    # clean up the extra text formatting that pydoc performs
     patt = re.compile('\b.')
     output = patt.sub('', output)
     return output.strip(), loc
 
 def print_diffs(text1, text2):
     "Prints unified diffs for two texts"
+    # XXX now obsolete, use unittest built-in support
     lines1 = text1.splitlines(True)
     lines2 = text2.splitlines(True)
     diffs = difflib.unified_diff(lines1, lines2, n=0, fromfile='expected',
                                  tofile='got')
     print('\n' + ''.join(diffs))
 
+def get_html_title(text):
+    # Bit of hack, but good enough for test purposes
+    header, _, _ = text.partition("</head>")
+    _, _, title = header.partition("<title>")
+    title, _, _ = title.partition("</title>")
+    return title
+
 
 class PyDocDocTest(unittest.TestCase):
 
@@ -327,6 +338,41 @@
         self.assertEqual(stripid("<type 'exceptions.Exception'>"),
                          "<type 'exceptions.Exception'>")
 
+    @unittest.skipIf(sys.flags.optimize >= 2,
+                     'Docstrings are omitted with -O2 and above')
+    def test_help_output_redirect(self):
+        # issue 940286, if output is set in Helper, then all output from
+        # Helper.help should be redirected
+        old_pattern = expected_text_pattern
+        getpager_old = pydoc.getpager
+        getpager_new = lambda: (lambda x: x)
+        self.maxDiff = None
+
+        buf = StringIO()
+        helper = pydoc.Helper(output=buf)
+        unused, doc_loc = get_pydoc_text(pydoc_mod)
+        module = "test.pydoc_mod"
+        help_header = """
+        Help on module test.pydoc_mod in test:
+
+        """.lstrip()
+        help_header = textwrap.dedent(help_header)
+        expected_help_pattern = help_header + expected_text_pattern
+
+        pydoc.getpager = getpager_new
+        try:
+            with captured_output('stdout') as output, \
+                 captured_output('stderr') as err:
+                helper.help(module)
+                result = buf.getvalue().strip()
+                expected_text = expected_help_pattern % \
+                                (doc_loc, inspect.getabsfile(pydoc_mod))
+                self.assertEqual('', output.getvalue())
+                self.assertEqual('', err.getvalue())
+                self.assertEqual(expected_text, result)
+        finally:
+            pydoc.getpager = getpager_old
+
 
 class TestDescriptions(unittest.TestCase):
 
@@ -336,16 +382,8 @@
         doc = pydoc.render_doc(pydocfodder)
         self.assertIn("pydocfodder", doc)
 
-    def test_classic_class(self):
-        class C: "Classic class"
-        c = C()
-        self.assertEqual(pydoc.describe(C), 'class C')
-        self.assertEqual(pydoc.describe(c), 'C')
-        expected = 'C in module %s' % __name__
-        self.assertIn(expected, pydoc.render_doc(c))
-
     def test_class(self):
-        class C(object): "New-style class"
+        class C: "New-style class"
         c = C()
 
         self.assertEqual(pydoc.describe(C), 'class C')
@@ -354,8 +392,78 @@
         self.assertIn(expected, pydoc.render_doc(c))
 
 
+class PyDocServerTest(unittest.TestCase):
+    """Tests for pydoc._start_server"""
+
+    def test_server(self):
+
+        # Minimal test that starts the server, then stops it.
+        def my_url_handler(url, content_type):
+            text = 'the URL sent was: (%s, %s)' % (url, content_type)
+            return text
+
+        serverthread = pydoc._start_server(my_url_handler, port=0)
+        starttime = time.time()
+        timeout = 1  #seconds
+
+        while serverthread.serving:
+            time.sleep(.01)
+            if serverthread.serving and time.time() - starttime > timeout:
+                serverthread.stop()
+                break
+
+        self.assertEqual(serverthread.error, None)
+
+
+class PyDocUrlHandlerTest(unittest.TestCase):
+    """Tests for pydoc._url_handler"""
+
+    def test_content_type_err(self):
+        err = 'Error: unknown content type '
+        f = pydoc._url_handler
+        result = f("", "")
+        self.assertEqual(result, err + "''")
+        result = f("", "foobar")
+        self.assertEqual(result, err + "'foobar'")
+
+    def test_url_requests(self):
+        # Test for the correct title in the html pages returned.
+        # This tests the different parts of the URL handler without
+        # getting too picky about the exact html.
+        requests = [
+            ("", "Python: Index of Modules"),
+            ("get?key=", "Python: Index of Modules"),
+            ("index", "Python: Index of Modules"),
+            ("topics", "Python: Topics"),
+            ("keywords", "Python: Keywords"),
+            ("pydoc", "Python: module pydoc"),
+            ("get?key=pydoc", "Python: module pydoc"),
+            ("search?key=pydoc", "Python: Search Results"),
+            ("def", "Python: KEYWORD def"),
+            ("STRINGS", "Python: TOPIC STRINGS"),
+            ("foobar", "Python: Error"),
+            ("getfile?key=foobar", "Python: Read Error"),
+            ]
+
+        for url, title in requests:
+            text = pydoc._url_handler(url, "text/html")
+            result = get_html_title(text)
+            self.assertEqual(result, title)
+
+        path = string.__file__
+        title = "Python: getfile " + path
+        url = "getfile?key=" + path
+        text = pydoc._url_handler(url, "text/html")
+        result = get_html_title(text)
+        self.assertEqual(result, title)
+
+
 def test_main():
-    test.support.run_unittest(PyDocDocTest, TestDescriptions)
+    test.support.run_unittest(PyDocDocTest,
+                              TestDescriptions,
+                              PyDocServerTest,
+                              PyDocUrlHandlerTest,
+                              )
 
 if __name__ == "__main__":
     test_main()

Modified: python/branches/py3k-cdecimal/Lib/test/test_pyexpat.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_pyexpat.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_pyexpat.py	Sun Jan  2 13:18:37 2011
@@ -203,6 +203,8 @@
 
         operations = out.out
         self._verify_parse_output(operations)
+        # Issue #6697.
+        self.assertRaises(AttributeError, getattr, parser, '\uD800')
 
     def test_parse_file(self):
         # Try parsing a file

Modified: python/branches/py3k-cdecimal/Lib/test/test_random.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_random.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_random.py	Sun Jan  2 13:18:37 2011
@@ -246,8 +246,8 @@
              '0x1.1ebb4352e4c4dp-1', '0x1.1a7422abf9c11p-1'])
         self.gen.seed("the quick brown fox", version=2)
         self.assertEqual([self.gen.random().hex() for i in range(4)],
-            ['0x1.1294009b9eda4p-2', '0x1.2ff96171b0010p-1',
-             '0x1.459e0989bd8e0p-5', '0x1.8b5f55892ddcbp-1'])
+            ['0x1.1239ddfb11b7cp-3', '0x1.b3cbb5c51b120p-4',
+             '0x1.8c4f55116b60fp-1', '0x1.63eb525174a27p-1'])
 
     def test_setstate_first_arg(self):
         self.assertRaises(ValueError, self.gen.setstate, (1, None, None))

Modified: python/branches/py3k-cdecimal/Lib/test/test_range.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_range.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_range.py	Sun Jan  2 13:18:37 2011
@@ -136,7 +136,12 @@
         self.assertNotIn(-b, seq)
         self.assertEqual(len(seq), 2)
 
-        self.assertRaises(OverflowError, len, range(0, sys.maxsize**10))
+        self.assertRaises(OverflowError, len,
+                          range(-sys.maxsize, sys.maxsize))
+        self.assertRaises(OverflowError, len,
+                          range(0, 2*sys.maxsize))
+        self.assertRaises(OverflowError, len,
+                          range(0, sys.maxsize**10))
 
     def test_invalid_invocation(self):
         self.assertRaises(TypeError, range)
@@ -248,6 +253,8 @@
         always_equal = AlwaysEqual()
         self.assertEqual(range(10).count(always_equal), 10)
 
+        self.assertEqual(len(range(sys.maxsize, sys.maxsize+10)), 10)
+
     def test_repr(self):
         self.assertEqual(repr(range(1)), 'range(0, 1)')
         self.assertEqual(repr(range(1, 2)), 'range(1, 2)')
@@ -349,6 +356,70 @@
             test_id = "reversed(range({}, {}, {}))".format(start, end, step)
             self.assert_iterators_equal(iter1, iter2, test_id, limit=100)
 
+    def test_slice(self):
+        def check(start, stop, step=None):
+            i = slice(start, stop, step)
+            self.assertEqual(list(r[i]), list(r)[i])
+            self.assertEqual(len(r[i]), len(list(r)[i]))
+        for r in [range(10),
+                  range(0),
+                  range(1, 9, 3),
+                  range(8, 0, -3),
+                  range(sys.maxsize+1, sys.maxsize+10),
+                  ]:
+            check(0, 2)
+            check(0, 20)
+            check(1, 2)
+            check(20, 30)
+            check(-30, -20)
+            check(-1, 100, 2)
+            check(0, -1)
+            check(-1, -3, -1)
+
+    def test_contains(self):
+        r = range(10)
+        self.assertIn(0, r)
+        self.assertIn(1, r)
+        self.assertIn(5.0, r)
+        self.assertNotIn(5.1, r)
+        self.assertNotIn(-1, r)
+        self.assertNotIn(10, r)
+        self.assertNotIn("", r)
+        r = range(9, -1, -1)
+        self.assertIn(0, r)
+        self.assertIn(1, r)
+        self.assertIn(5.0, r)
+        self.assertNotIn(5.1, r)
+        self.assertNotIn(-1, r)
+        self.assertNotIn(10, r)
+        self.assertNotIn("", r)
+        r = range(0, 10, 2)
+        self.assertIn(0, r)
+        self.assertNotIn(1, r)
+        self.assertNotIn(5.0, r)
+        self.assertNotIn(5.1, r)
+        self.assertNotIn(-1, r)
+        self.assertNotIn(10, r)
+        self.assertNotIn("", r)
+        r = range(9, -1, -2)
+        self.assertNotIn(0, r)
+        self.assertIn(1, r)
+        self.assertIn(5.0, r)
+        self.assertNotIn(5.1, r)
+        self.assertNotIn(-1, r)
+        self.assertNotIn(10, r)
+        self.assertNotIn("", r)
+
+    def test_reverse_iteration(self):
+        for r in [range(10),
+                  range(0),
+                  range(1, 9, 3),
+                  range(8, 0, -3),
+                  range(sys.maxsize+1, sys.maxsize+10),
+                  ]:
+            self.assertEqual(list(reversed(r)), list(r)[::-1])
+
+
 def test_main():
     test.support.run_unittest(RangeTest)
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_runpy.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_runpy.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_runpy.py	Sun Jan  2 13:18:37 2011
@@ -329,7 +329,7 @@
 
     def _check_import_error(self, script_name, msg):
         msg = re.escape(msg)
-        self.assertRaisesRegexp(ImportError, msg, run_path, script_name)
+        self.assertRaisesRegex(ImportError, msg, run_path, script_name)
 
     def test_basic_script(self):
         with temp_dir() as script_dir:
@@ -403,7 +403,7 @@
             script_name = self._make_test_script(script_dir, mod_name, source)
             zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
             msg = "recursion depth exceeded"
-            self.assertRaisesRegexp(RuntimeError, msg, run_path, zip_name)
+            self.assertRaisesRegex(RuntimeError, msg, run_path, zip_name)
 
 
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_shelve.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_shelve.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_shelve.py	Sun Jan  2 13:18:37 2011
@@ -122,6 +122,19 @@
         self.assertEqual(len(d1), 1)
         self.assertEqual(len(d2), 1)
 
+    def test_keyencoding(self):
+        d = {}
+        key = 'Pöp'
+        # the default keyencoding is utf-8
+        shelve.Shelf(d)[key] = [1]
+        self.assertIn(key.encode('utf-8'), d)
+        # but a different one can be given
+        shelve.Shelf(d, keyencoding='latin1')[key] = [1]
+        self.assertIn(key.encode('latin1'), d)
+        # with all consequences
+        s = shelve.Shelf(d, keyencoding='ascii')
+        self.assertRaises(UnicodeEncodeError, s.__setitem__, key, [1])
+
     def test_writeback_also_writes_immediately(self):
         # Issue 5754
         d = {}

Modified: python/branches/py3k-cdecimal/Lib/test/test_shutil.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_shutil.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_shutil.py	Sun Jan  2 13:18:37 2011
@@ -271,24 +271,35 @@
             shutil.rmtree(src_dir)
             shutil.rmtree(os.path.dirname(dst_dir))
 
-    @support.skip_unless_symlink
+    @unittest.skipUnless(hasattr(os, 'link'), 'requires os.link')
     def test_dont_copy_file_onto_link_to_itself(self):
+        # Temporarily disable test on Windows.
+        if os.name == 'nt':
+            return
         # bug 851123.
         os.mkdir(TESTFN)
         src = os.path.join(TESTFN, 'cheese')
         dst = os.path.join(TESTFN, 'shop')
         try:
-            f = open(src, 'w')
-            f.write('cheddar')
-            f.close()
-
-            if hasattr(os, "link"):
-                os.link(src, dst)
-                self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
-                with open(src, 'r') as f:
-                    self.assertEqual(f.read(), 'cheddar')
-                os.remove(dst)
+            with open(src, 'w') as f:
+                f.write('cheddar')
+            os.link(src, dst)
+            self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
+            with open(src, 'r') as f:
+                self.assertEqual(f.read(), 'cheddar')
+            os.remove(dst)
+        finally:
+            shutil.rmtree(TESTFN, ignore_errors=True)
 
+    @support.skip_unless_symlink
+    def test_dont_copy_file_onto_symlink_to_itself(self):
+        # bug 851123.
+        os.mkdir(TESTFN)
+        src = os.path.join(TESTFN, 'cheese')
+        dst = os.path.join(TESTFN, 'shop')
+        try:
+            with open(src, 'w') as f:
+                f.write('cheddar')
             # Using `src` here would mean we end up with a symlink pointing
             # to TESTFN/TESTFN/cheese, while it should point at
             # TESTFN/cheese.
@@ -298,10 +309,7 @@
                 self.assertEqual(f.read(), 'cheddar')
             os.remove(dst)
         finally:
-            try:
-                shutil.rmtree(TESTFN)
-            except OSError:
-                pass
+            shutil.rmtree(TESTFN, ignore_errors=True)
 
     @support.skip_unless_symlink
     def test_rmtree_on_symlink(self):
@@ -328,26 +336,26 @@
             finally:
                 os.remove(TESTFN)
 
-    @unittest.skipUnless(hasattr(os, 'mkfifo'), 'requires os.mkfifo')
-    def test_copytree_named_pipe(self):
-        os.mkdir(TESTFN)
-        try:
-            subdir = os.path.join(TESTFN, "subdir")
-            os.mkdir(subdir)
-            pipe = os.path.join(subdir, "mypipe")
-            os.mkfifo(pipe)
+        @support.skip_unless_symlink
+        def test_copytree_named_pipe(self):
+            os.mkdir(TESTFN)
             try:
-                shutil.copytree(TESTFN, TESTFN2)
-            except shutil.Error as e:
-                errors = e.args[0]
-                self.assertEqual(len(errors), 1)
-                src, dst, error_msg = errors[0]
-                self.assertEqual("`%s` is a named pipe" % pipe, error_msg)
-            else:
-                self.fail("shutil.Error should have been raised")
-        finally:
-            shutil.rmtree(TESTFN, ignore_errors=True)
-            shutil.rmtree(TESTFN2, ignore_errors=True)
+                subdir = os.path.join(TESTFN, "subdir")
+                os.mkdir(subdir)
+                pipe = os.path.join(subdir, "mypipe")
+                os.mkfifo(pipe)
+                try:
+                    shutil.copytree(TESTFN, TESTFN2)
+                except shutil.Error as e:
+                    errors = e.args[0]
+                    self.assertEqual(len(errors), 1)
+                    src, dst, error_msg = errors[0]
+                    self.assertEqual("`%s` is a named pipe" % pipe, error_msg)
+                else:
+                    self.fail("shutil.Error should have been raised")
+            finally:
+                shutil.rmtree(TESTFN, ignore_errors=True)
+                shutil.rmtree(TESTFN2, ignore_errors=True)
 
     def test_copytree_special_func(self):
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_site.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_site.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_site.py	Sun Jan  2 13:18:37 2011
@@ -6,9 +6,11 @@
 """
 import unittest
 from test.support import run_unittest, TESTFN, EnvironmentVarGuard
+from test.support import captured_stderr
 import builtins
 import os
 import sys
+import re
 import encodings
 import subprocess
 import sysconfig
@@ -90,6 +92,58 @@
         finally:
             pth_file.cleanup()
 
+    def make_pth(self, contents, pth_dir='.', pth_name=TESTFN):
+        # Create a .pth file and return its (abspath, basename).
+        pth_dir = os.path.abspath(pth_dir)
+        pth_basename = pth_name + '.pth'
+        pth_fn = os.path.join(pth_dir, pth_basename)
+        pth_file = open(pth_fn, 'w', encoding='utf-8')
+        self.addCleanup(lambda: os.remove(pth_fn))
+        pth_file.write(contents)
+        pth_file.close()
+        return pth_dir, pth_basename
+
+    def test_addpackage_import_bad_syntax(self):
+        # Issue 10642
+        pth_dir, pth_fn = self.make_pth("import bad)syntax\n")
+        with captured_stderr() as err_out:
+            site.addpackage(pth_dir, pth_fn, set())
+        self.assertRegex(err_out.getvalue(), "line 1")
+        self.assertRegex(err_out.getvalue(),
+            re.escape(os.path.join(pth_dir, pth_fn)))
+        # XXX: the previous two should be independent checks so that the
+        # order doesn't matter.  The next three could be a single check
+        # but my regex foo isn't good enough to write it.
+        self.assertRegex(err_out.getvalue(), 'Traceback')
+        self.assertRegex(err_out.getvalue(), r'import bad\)syntax')
+        self.assertRegex(err_out.getvalue(), 'SyntaxError')
+
+    def test_addpackage_import_bad_exec(self):
+        # Issue 10642
+        pth_dir, pth_fn = self.make_pth("randompath\nimport nosuchmodule\n")
+        with captured_stderr() as err_out:
+            site.addpackage(pth_dir, pth_fn, set())
+        self.assertRegex(err_out.getvalue(), "line 2")
+        self.assertRegex(err_out.getvalue(),
+            re.escape(os.path.join(pth_dir, pth_fn)))
+        # XXX: ditto previous XXX comment.
+        self.assertRegex(err_out.getvalue(), 'Traceback')
+        self.assertRegex(err_out.getvalue(), 'ImportError')
+
+    @unittest.skipIf(sys.platform == "win32", "Windows does not raise an "
+                      "error for file paths containing null characters")
+    def test_addpackage_import_bad_pth_file(self):
+        # Issue 5258
+        pth_dir, pth_fn = self.make_pth("abc\x00def\n")
+        with captured_stderr() as err_out:
+            site.addpackage(pth_dir, pth_fn, set())
+        self.assertRegex(err_out.getvalue(), "line 1")
+        self.assertRegex(err_out.getvalue(),
+            re.escape(os.path.join(pth_dir, pth_fn)))
+        # XXX: ditto previous XXX comment.
+        self.assertRegex(err_out.getvalue(), 'Traceback')
+        self.assertRegex(err_out.getvalue(), 'TypeError')
+
     def test_addsitedir(self):
         # Same tests for test_addpackage since addsitedir() essentially just
         # calls addpackage() for every .pth file in the directory

Modified: python/branches/py3k-cdecimal/Lib/test/test_smtpd.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_smtpd.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_smtpd.py	Sun Jan  2 13:18:37 2011
@@ -121,6 +121,24 @@
         self.assertEqual(self.channel.socket.last,
                          b'451 Internal confusion\r\n')
 
+    def test_command_too_long(self):
+        self.write_line(b'MAIL from ' +
+                        b'a' * self.channel.command_size_limit +
+                        b'@example')
+        self.assertEqual(self.channel.socket.last,
+                         b'500 Error: line too long\r\n')
+
+    def test_data_too_long(self):
+        # Small hack. Setting limit to 2K octets here will save us some time.
+        self.channel.data_size_limit = 2048
+        self.write_line(b'MAIL From:eggs at example')
+        self.write_line(b'RCPT To:spam at example')
+        self.write_line(b'DATA')
+        self.write_line(b'A' * self.channel.data_size_limit +
+                        b'A\r\n.')
+        self.assertEqual(self.channel.socket.last,
+                         b'552 Error: Too much mail data\r\n')
+
     def test_need_MAIL(self):
         self.write_line(b'RCPT to:spam at example')
         self.assertEqual(self.channel.socket.last,

Modified: python/branches/py3k-cdecimal/Lib/test/test_smtplib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_smtplib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_smtplib.py	Sun Jan  2 13:18:37 2011
@@ -319,12 +319,12 @@
         self.assertEqual(self.output.getvalue(), mexpect)
         debugout = smtpd.DEBUGSTREAM.getvalue()
         sender = re.compile("^sender: foo at bar.com$", re.MULTILINE)
-        self.assertRegexpMatches(debugout, sender)
+        self.assertRegex(debugout, sender)
         for addr in ('John', 'Sally', 'Fred', 'root at localhost',
                      'warped at silly.walks.com'):
             to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
                                  re.MULTILINE)
-            self.assertRegexpMatches(debugout, to_addr)
+            self.assertRegex(debugout, to_addr)
 
     def testSendMessageWithSomeAddresses(self):
         # Make sure nothing breaks if not all of the three 'to' headers exist
@@ -347,11 +347,11 @@
         self.assertEqual(self.output.getvalue(), mexpect)
         debugout = smtpd.DEBUGSTREAM.getvalue()
         sender = re.compile("^sender: foo at bar.com$", re.MULTILINE)
-        self.assertRegexpMatches(debugout, sender)
+        self.assertRegex(debugout, sender)
         for addr in ('John', 'Dinsdale'):
             to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
                                  re.MULTILINE)
-            self.assertRegexpMatches(debugout, to_addr)
+            self.assertRegex(debugout, to_addr)
 
 
 class NonConnectingTests(unittest.TestCase):

Modified: python/branches/py3k-cdecimal/Lib/test/test_socket.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_socket.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_socket.py	Sun Jan  2 13:18:37 2011
@@ -667,6 +667,8 @@
                                type=socket.SOCK_STREAM, proto=0,
                                flags=socket.AI_PASSIVE)
         self.assertEqual(a, b)
+        # Issue #6697.
+        self.assertRaises(UnicodeEncodeError, socket.getaddrinfo, 'localhost', '\uD800')
 
     def test_getnameinfo(self):
         # only IP addresses are allowed

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	Sun Jan  2 13:18:37 2011
@@ -185,17 +185,17 @@
 
     def test_errors(self):
         sock = socket.socket()
-        self.assertRaisesRegexp(ValueError,
+        self.assertRaisesRegex(ValueError,
                         "certfile must be specified",
                         ssl.wrap_socket, sock, keyfile=CERTFILE)
-        self.assertRaisesRegexp(ValueError,
+        self.assertRaisesRegex(ValueError,
                         "certfile must be specified for server-side operations",
                         ssl.wrap_socket, sock, server_side=True)
-        self.assertRaisesRegexp(ValueError,
+        self.assertRaisesRegex(ValueError,
                         "certfile must be specified for server-side operations",
                         ssl.wrap_socket, sock, server_side=True, certfile="")
         s = ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE)
-        self.assertRaisesRegexp(ValueError, "can't connect in server-side mode",
+        self.assertRaisesRegex(ValueError, "can't connect in server-side mode",
                                 s.connect, (HOST, 8080))
         with self.assertRaises(IOError) as cm:
             with socket.socket() as sock:
@@ -310,7 +310,7 @@
         ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
         ctx.set_ciphers("ALL")
         ctx.set_ciphers("DEFAULT")
-        with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"):
+        with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
             ctx.set_ciphers("^$:,;?*'dorothyx")
 
     @skip_if_broken_ubuntu_ssl
@@ -358,24 +358,24 @@
         with self.assertRaises(IOError) as cm:
             ctx.load_cert_chain(WRONGCERT)
         self.assertEqual(cm.exception.errno, errno.ENOENT)
-        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+        with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
             ctx.load_cert_chain(BADCERT)
-        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+        with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
             ctx.load_cert_chain(EMPTYCERT)
         # Separate key and cert
         ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
         ctx.load_cert_chain(ONLYCERT, ONLYKEY)
         ctx.load_cert_chain(certfile=ONLYCERT, keyfile=ONLYKEY)
         ctx.load_cert_chain(certfile=BYTES_ONLYCERT, keyfile=BYTES_ONLYKEY)
-        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+        with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
             ctx.load_cert_chain(ONLYCERT)
-        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+        with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
             ctx.load_cert_chain(ONLYKEY)
-        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+        with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
             ctx.load_cert_chain(certfile=ONLYKEY, keyfile=ONLYCERT)
         # Mismatching key and cert
         ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
-        with self.assertRaisesRegexp(ssl.SSLError, "key values mismatch"):
+        with self.assertRaisesRegex(ssl.SSLError, "key values mismatch"):
             ctx.load_cert_chain(SVN_PYTHON_ORG_ROOT_CERT, ONLYKEY)
 
     def test_load_verify_locations(self):
@@ -389,7 +389,7 @@
         with self.assertRaises(IOError) as cm:
             ctx.load_verify_locations(WRONGCERT)
         self.assertEqual(cm.exception.errno, errno.ENOENT)
-        with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+        with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
             ctx.load_verify_locations(BADCERT)
         ctx.load_verify_locations(CERTFILE, CAPATH)
         ctx.load_verify_locations(CERTFILE, capath=BYTES_CAPATH)
@@ -434,8 +434,8 @@
             # this should fail because we have no verification certs
             s = ssl.wrap_socket(socket.socket(socket.AF_INET),
                                 cert_reqs=ssl.CERT_REQUIRED)
-            self.assertRaisesRegexp(ssl.SSLError, "certificate verify failed",
-                                    s.connect, ("svn.python.org", 443))
+            self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
+                                   s.connect, ("svn.python.org", 443))
             s.close()
 
             # this should succeed because we specify the root cert
@@ -469,7 +469,7 @@
             # This should fail because we have no verification certs
             ctx.verify_mode = ssl.CERT_REQUIRED
             s = ctx.wrap_socket(socket.socket(socket.AF_INET))
-            self.assertRaisesRegexp(ssl.SSLError, "certificate verify failed",
+            self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
                                     s.connect, ("svn.python.org", 443))
             s.close()
             # This should succeed because we specify the root cert
@@ -587,7 +587,7 @@
                                 cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT")
             s.connect(remote)
             # Error checking can happen at instantiation or when connecting
-            with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"):
+            with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
                 with socket.socket(socket.AF_INET) as sock:
                     s = ssl.wrap_socket(sock,
                                         cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
@@ -1499,8 +1499,8 @@
                     c.settimeout(0.2)
                     c.connect((host, port))
                     # Will attempt handshake and time out
-                    self.assertRaisesRegexp(ssl.SSLError, "timed out",
-                                            ssl.wrap_socket, c)
+                    self.assertRaisesRegex(socket.timeout, "timed out",
+                                           ssl.wrap_socket, c)
                 finally:
                     c.close()
                 try:
@@ -1508,8 +1508,8 @@
                     c = ssl.wrap_socket(c)
                     c.settimeout(0.2)
                     # Will attempt handshake and time out
-                    self.assertRaisesRegexp(ssl.SSLError, "timed out",
-                                            c.connect, (host, port))
+                    self.assertRaisesRegex(socket.timeout, "timed out",
+                                           c.connect, (host, port))
                 finally:
                     c.close()
             finally:

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	Sun Jan  2 13:18:37 2011
@@ -82,58 +82,52 @@
         # Test some of the new features in detail
         # (format, argument, big-endian result, little-endian result, asymmetric)
         tests = [
-            ('c', 'a', 'a', 'a', 0),
-            ('xc', 'a', '\0a', '\0a', 0),
-            ('cx', 'a', 'a\0', 'a\0', 0),
-            ('s', 'a', 'a', 'a', 0),
-            ('0s', 'helloworld', '', '', 1),
-            ('1s', 'helloworld', 'h', 'h', 1),
-            ('9s', 'helloworld', 'helloworl', 'helloworl', 1),
-            ('10s', 'helloworld', 'helloworld', 'helloworld', 0),
-            ('11s', 'helloworld', 'helloworld\0', 'helloworld\0', 1),
-            ('20s', 'helloworld', 'helloworld'+10*'\0', 'helloworld'+10*'\0', 1),
-            ('b', 7, '\7', '\7', 0),
-            ('b', -7, '\371', '\371', 0),
-            ('B', 7, '\7', '\7', 0),
-            ('B', 249, '\371', '\371', 0),
-            ('h', 700, '\002\274', '\274\002', 0),
-            ('h', -700, '\375D', 'D\375', 0),
-            ('H', 700, '\002\274', '\274\002', 0),
-            ('H', 0x10000-700, '\375D', 'D\375', 0),
-            ('i', 70000000, '\004,\035\200', '\200\035,\004', 0),
-            ('i', -70000000, '\373\323\342\200', '\200\342\323\373', 0),
-            ('I', 70000000, '\004,\035\200', '\200\035,\004', 0),
-            ('I', 0x100000000-70000000, '\373\323\342\200', '\200\342\323\373', 0),
-            ('l', 70000000, '\004,\035\200', '\200\035,\004', 0),
-            ('l', -70000000, '\373\323\342\200', '\200\342\323\373', 0),
-            ('L', 70000000, '\004,\035\200', '\200\035,\004', 0),
-            ('L', 0x100000000-70000000, '\373\323\342\200', '\200\342\323\373', 0),
-            ('f', 2.0, '@\000\000\000', '\000\000\000@', 0),
-            ('d', 2.0, '@\000\000\000\000\000\000\000',
-                       '\000\000\000\000\000\000\000@', 0),
-            ('f', -2.0, '\300\000\000\000', '\000\000\000\300', 0),
-            ('d', -2.0, '\300\000\000\000\000\000\000\000',
-                       '\000\000\000\000\000\000\000\300', 0),
-                ('?', 0, '\0', '\0', 0),
-                ('?', 3, '\1', '\1', 1),
-                ('?', True, '\1', '\1', 0),
-                ('?', [], '\0', '\0', 1),
-                ('?', (1,), '\1', '\1', 1),
+            ('c', b'a', b'a', b'a', 0),
+            ('xc', b'a', b'\0a', b'\0a', 0),
+            ('cx', b'a', b'a\0', b'a\0', 0),
+            ('s', b'a', b'a', b'a', 0),
+            ('0s', b'helloworld', b'', b'', 1),
+            ('1s', b'helloworld', b'h', b'h', 1),
+            ('9s', b'helloworld', b'helloworl', b'helloworl', 1),
+            ('10s', b'helloworld', b'helloworld', b'helloworld', 0),
+            ('11s', b'helloworld', b'helloworld\0', b'helloworld\0', 1),
+            ('20s', b'helloworld', b'helloworld'+10*b'\0', b'helloworld'+10*b'\0', 1),
+            ('b', 7, b'\7', b'\7', 0),
+            ('b', -7, b'\371', b'\371', 0),
+            ('B', 7, b'\7', b'\7', 0),
+            ('B', 249, b'\371', b'\371', 0),
+            ('h', 700, b'\002\274', b'\274\002', 0),
+            ('h', -700, b'\375D', b'D\375', 0),
+            ('H', 700, b'\002\274', b'\274\002', 0),
+            ('H', 0x10000-700, b'\375D', b'D\375', 0),
+            ('i', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+            ('i', -70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+            ('I', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+            ('I', 0x100000000-70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+            ('l', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+            ('l', -70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+            ('L', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+            ('L', 0x100000000-70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+            ('f', 2.0, b'@\000\000\000', b'\000\000\000@', 0),
+            ('d', 2.0, b'@\000\000\000\000\000\000\000',
+                       b'\000\000\000\000\000\000\000@', 0),
+            ('f', -2.0, b'\300\000\000\000', b'\000\000\000\300', 0),
+            ('d', -2.0, b'\300\000\000\000\000\000\000\000',
+                        b'\000\000\000\000\000\000\000\300', 0),
+            ('?', 0, b'\0', b'\0', 0),
+            ('?', 3, b'\1', b'\1', 1),
+            ('?', True, b'\1', b'\1', 0),
+            ('?', [], b'\0', b'\0', 1),
+            ('?', (1,), b'\1', b'\1', 1),
         ]
 
         for fmt, arg, big, lil, asy in tests:
-            big = bytes(big, "latin-1")
-            lil = bytes(lil, "latin-1")
             for (xfmt, exp) in [('>'+fmt, big), ('!'+fmt, big), ('<'+fmt, lil),
                                 ('='+fmt, ISBIGENDIAN and big or lil)]:
                 res = struct.pack(xfmt, arg)
                 self.assertEqual(res, exp)
                 self.assertEqual(struct.calcsize(xfmt), len(res))
                 rev = struct.unpack(xfmt, res)[0]
-                if isinstance(arg, str):
-                    # Strings are returned as bytes since you can't know the
-                    # encoding of the string when packed.
-                    arg = bytes(arg, 'latin1')
                 if rev != arg:
                     self.assertTrue(asy)
 
@@ -334,15 +328,14 @@
     def test_p_code(self):
         # Test p ("Pascal string") code.
         for code, input, expected, expectedback in [
-                ('p','abc', '\x00', b''),
-                ('1p', 'abc', '\x00', b''),
-                ('2p', 'abc', '\x01a', b'a'),
-                ('3p', 'abc', '\x02ab', b'ab'),
-                ('4p', 'abc', '\x03abc', b'abc'),
-                ('5p', 'abc', '\x03abc\x00', b'abc'),
-                ('6p', 'abc', '\x03abc\x00\x00', b'abc'),
-                ('1000p', 'x'*1000, '\xff' + 'x'*999, b'x'*255)]:
-            expected = bytes(expected, "latin-1")
+                ('p',  b'abc', b'\x00',            b''),
+                ('1p', b'abc', b'\x00',            b''),
+                ('2p', b'abc', b'\x01a',           b'a'),
+                ('3p', b'abc', b'\x02ab',          b'ab'),
+                ('4p', b'abc', b'\x03abc',         b'abc'),
+                ('5p', b'abc', b'\x03abc\x00',     b'abc'),
+                ('6p', b'abc', b'\x03abc\x00\x00', b'abc'),
+                ('1000p', b'x'*1000, b'\xff' + b'x'*999, b'x'*255)]:
             got = struct.pack(code, input)
             self.assertEqual(got, expected)
             (got,) = struct.unpack(code, got)
@@ -401,15 +394,11 @@
         s = struct.Struct(fmt)
         for cls in (bytes, bytearray):
             data = cls(test_string)
-            if not isinstance(data, (bytes, bytearray)):
-                bytes_data = bytes(data, 'latin1')
-            else:
-                bytes_data = data
             self.assertEqual(s.unpack_from(data), (b'abcd',))
             self.assertEqual(s.unpack_from(data, 2), (b'cd01',))
             self.assertEqual(s.unpack_from(data, 4), (b'0123',))
             for i in range(6):
-                self.assertEqual(s.unpack_from(data, i), (bytes_data[i:i+4],))
+                self.assertEqual(s.unpack_from(data, i), (data[i:i+4],))
             for i in range(6, len(test_string) + 1):
                 self.assertRaises(struct.error, s.unpack_from, data, i)
         for cls in (bytes, bytearray):

Modified: python/branches/py3k-cdecimal/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_subprocess.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_subprocess.py	Sun Jan  2 13:18:37 2011
@@ -9,6 +9,8 @@
 import time
 import re
 import sysconfig
+import warnings
+import select
 try:
     import gc
 except ImportError:
@@ -364,22 +366,28 @@
         self.assertEqual(stdout, b"banana")
         self.assertStderrEqual(stderr, b"pineapple")
 
-    # This test is Linux specific for simplicity to at least have
-    # some coverage.  It is not a platform specific bug.
-    @unittest.skipUnless(os.path.isdir('/proc/%d/fd' % os.getpid()),
-                         "Linux specific")
     # Test for the fd leak reported in http://bugs.python.org/issue2791.
     def test_communicate_pipe_fd_leak(self):
-        fd_directory = '/proc/%d/fd' % os.getpid()
-        num_fds_before_popen = len(os.listdir(fd_directory))
-        p = subprocess.Popen([sys.executable, "-c", "print()"],
-                             stdout=subprocess.PIPE)
-        p.communicate()
-        num_fds_after_communicate = len(os.listdir(fd_directory))
-        del p
-        num_fds_after_destruction = len(os.listdir(fd_directory))
-        self.assertEqual(num_fds_before_popen, num_fds_after_destruction)
-        self.assertEqual(num_fds_before_popen, num_fds_after_communicate)
+        for stdin_pipe in (False, True):
+            for stdout_pipe in (False, True):
+                for stderr_pipe in (False, True):
+                    options = {}
+                    if stdin_pipe:
+                        options['stdin'] = subprocess.PIPE
+                    if stdout_pipe:
+                        options['stdout'] = subprocess.PIPE
+                    if stderr_pipe:
+                        options['stderr'] = subprocess.PIPE
+                    if not options:
+                        continue
+                    p = subprocess.Popen((sys.executable, "-c", "pass"), **options)
+                    p.communicate()
+                    if p.stdin is not None:
+                        self.assertTrue(p.stdin.closed)
+                    if p.stdout is not None:
+                        self.assertTrue(p.stdout.closed)
+                    if p.stderr is not None:
+                        self.assertTrue(p.stderr.closed)
 
     def test_communicate_returns(self):
         # communicate() should return None if no redirection is active
@@ -963,6 +971,125 @@
         exitcode = subprocess.call([program, "-c", "pass"], env=envb)
         self.assertEqual(exitcode, 0)
 
+    def test_pipe_cloexec(self):
+        sleeper = support.findfile("input_reader.py", subdir="subprocessdata")
+        fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
+
+        p1 = subprocess.Popen([sys.executable, sleeper],
+                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+                              stderr=subprocess.PIPE, close_fds=False)
+
+        self.addCleanup(p1.communicate, b'')
+
+        p2 = subprocess.Popen([sys.executable, fd_status],
+                              stdout=subprocess.PIPE, close_fds=False)
+
+        output, error = p2.communicate()
+        result_fds = set(map(int, output.split(b',')))
+        unwanted_fds = set([p1.stdin.fileno(), p1.stdout.fileno(),
+                            p1.stderr.fileno()])
+
+        self.assertFalse(result_fds & unwanted_fds,
+                         "Expected no fds from %r to be open in child, "
+                         "found %r" %
+                              (unwanted_fds, result_fds & unwanted_fds))
+
+    def test_pipe_cloexec_real_tools(self):
+        qcat = support.findfile("qcat.py", subdir="subprocessdata")
+        qgrep = support.findfile("qgrep.py", subdir="subprocessdata")
+
+        subdata = b'zxcvbn'
+        data = subdata * 4 + b'\n'
+
+        p1 = subprocess.Popen([sys.executable, qcat],
+                              stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+                              close_fds=False)
+
+        p2 = subprocess.Popen([sys.executable, qgrep, subdata],
+                              stdin=p1.stdout, stdout=subprocess.PIPE,
+                              close_fds=False)
+
+        self.addCleanup(p1.wait)
+        self.addCleanup(p2.wait)
+        self.addCleanup(p1.terminate)
+        self.addCleanup(p2.terminate)
+
+        p1.stdin.write(data)
+        p1.stdin.close()
+
+        readfiles, ignored1, ignored2 = select.select([p2.stdout], [], [], 10)
+
+        self.assertTrue(readfiles, "The child hung")
+        self.assertEqual(p2.stdout.read(), data)
+
+    def test_close_fds(self):
+        fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
+
+        fds = os.pipe()
+        self.addCleanup(os.close, fds[0])
+        self.addCleanup(os.close, fds[1])
+
+        open_fds = set(fds)
+
+        p = subprocess.Popen([sys.executable, fd_status],
+                             stdout=subprocess.PIPE, close_fds=False)
+        output, ignored = p.communicate()
+        remaining_fds = set(map(int, output.split(b',')))
+
+        self.assertEqual(remaining_fds & open_fds, open_fds,
+                         "Some fds were closed")
+
+        p = subprocess.Popen([sys.executable, fd_status],
+                             stdout=subprocess.PIPE, close_fds=True)
+        output, ignored = p.communicate()
+        remaining_fds = set(map(int, output.split(b',')))
+
+        self.assertFalse(remaining_fds & open_fds,
+                         "Some fds were left open")
+        self.assertIn(1, remaining_fds, "Subprocess failed")
+
+    def test_pass_fds(self):
+        fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
+
+        open_fds = set()
+
+        for x in range(5):
+            fds = os.pipe()
+            self.addCleanup(os.close, fds[0])
+            self.addCleanup(os.close, fds[1])
+            open_fds.update(fds)
+
+        for fd in open_fds:
+            p = subprocess.Popen([sys.executable, fd_status],
+                                 stdout=subprocess.PIPE, close_fds=True,
+                                 pass_fds=(fd, ))
+            output, ignored = p.communicate()
+
+            remaining_fds = set(map(int, output.split(b',')))
+            to_be_closed = open_fds - {fd}
+
+            self.assertIn(fd, remaining_fds, "fd to be passed not passed")
+            self.assertFalse(remaining_fds & to_be_closed,
+                             "fd to be closed passed")
+
+            # pass_fds overrides close_fds with a warning.
+            with self.assertWarns(RuntimeWarning) as context:
+                self.assertFalse(subprocess.call(
+                        [sys.executable, "-c", "import sys; sys.exit(0)"],
+                        close_fds=False, pass_fds=(fd, )))
+            self.assertIn('overriding close_fds', str(context.warning))
+
+    def test_wait_when_sigchild_ignored(self):
+        # NOTE: sigchild_ignore.py may not be an effective test on all OSes.
+        sigchild_ignore = support.findfile("sigchild_ignore.py",
+                                           subdir="subprocessdata")
+        p = subprocess.Popen([sys.executable, sigchild_ignore],
+                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        stdout, stderr = p.communicate()
+        self.assertEqual(0, p.returncode, "sigchild_ignore.py exited"
+                         " non-zero with this error:\n%s" %
+                         stderr.decode('utf8'))
+
 
 @unittest.skipUnless(mswindows, "Windows specific tests")
 class Win32ProcessTestCase(BaseTestCase):
@@ -1183,6 +1310,47 @@
         # call() function with sequence argument with spaces on Windows
         self.with_spaces([sys.executable, self.fname, "ab cd"])
 
+
+class ContextManagerTests(ProcessTestCase):
+
+    def test_pipe(self):
+        with subprocess.Popen([sys.executable, "-c",
+                               "import sys;"
+                               "sys.stdout.write('stdout');"
+                               "sys.stderr.write('stderr');"],
+                              stdout=subprocess.PIPE,
+                              stderr=subprocess.PIPE) as proc:
+            self.assertEqual(proc.stdout.read(), b"stdout")
+            self.assertStderrEqual(proc.stderr.read(), b"stderr")
+
+        self.assertTrue(proc.stdout.closed)
+        self.assertTrue(proc.stderr.closed)
+
+    def test_returncode(self):
+        with subprocess.Popen([sys.executable, "-c",
+                               "import sys; sys.exit(100)"]) as proc:
+            proc.wait()
+        self.assertEqual(proc.returncode, 100)
+
+    def test_communicate_stdin(self):
+        with subprocess.Popen([sys.executable, "-c",
+                              "import sys;"
+                              "sys.exit(sys.stdin.read() == 'context')"],
+                             stdin=subprocess.PIPE) as proc:
+            proc.communicate(b"context")
+            self.assertEqual(proc.returncode, 1)
+
+    def test_invalid_args(self):
+        with self.assertRaises(EnvironmentError) as c:
+            with subprocess.Popen(['nonexisting_i_hope'],
+                                  stdout=subprocess.PIPE,
+                                  stderr=subprocess.PIPE) as proc:
+                pass
+
+            if c.exception.errno != errno.ENOENT:  # ignore "no such file"
+                raise c.exception
+
+
 def test_main():
     unit_tests = (ProcessTestCase,
                   POSIXProcessTestCase,
@@ -1191,7 +1359,8 @@
                   CommandTests,
                   ProcessTestCaseNoPoll,
                   HelperFunctionTests,
-                  CommandsWithSpaces)
+                  CommandsWithSpaces,
+                  ContextManagerTests)
 
     support.run_unittest(*unit_tests)
     support.reap_children()

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	Sun Jan  2 13:18:37 2011
@@ -569,7 +569,7 @@
     TPFLAGS_HEAPTYPE = 1<<9
 
     def setUp(self):
-        self.c = len(struct.pack('c', ' '))
+        self.c = len(struct.pack('c', b' '))
         self.H = len(struct.pack('H', 0))
         self.i = len(struct.pack('i', 0))
         self.l = len(struct.pack('l', 0))
@@ -782,8 +782,8 @@
         # reverse
         check(reversed(''), size(h + 'PP'))
         # range
-        check(range(1), size(h + '3P'))
-        check(range(66000), size(h + '3P'))
+        check(range(1), size(h + '4P'))
+        check(range(66000), size(h + '4P'))
         # set
         # frozenset
         PySet_MINSIZE = 8

Modified: python/branches/py3k-cdecimal/Lib/test/test_syslog.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_syslog.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_syslog.py	Sun Jan  2 13:18:37 2011
@@ -11,6 +11,8 @@
 
     def test_openlog(self):
         syslog.openlog('python')
+        # Issue #6697.
+        self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
 
     def test_syslog(self):
         syslog.openlog('python')

Modified: python/branches/py3k-cdecimal/Lib/test/test_telnetlib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_telnetlib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_telnetlib.py	Sun Jan  2 13:18:37 2011
@@ -342,6 +342,16 @@
         expected = "send b'xxx'\n"
         self.assertIn(expected, telnet._messages)
 
+    def test_debug_accepts_str_port(self):
+        # Issue 10695
+        with test_socket([]):
+            telnet = TelnetAlike('dummy', '0')
+            telnet._messages = ''
+        telnet.set_debuglevel(1)
+        telnet.msg('test')
+        self.assertRegex(telnet._messages, r'0.*test')
+
+
 def test_main(verbose=None):
     support.run_unittest(GeneralTests, ReadTests, WriteTests, OptionTests)
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_tempfile.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_tempfile.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_tempfile.py	Sun Jan  2 13:18:37 2011
@@ -925,6 +925,15 @@
             f.write(b"Hello world!")
         return tmp
 
+    def test_mkdtemp_failure(self):
+        # Check no additional exception if mkdtemp fails
+        # Previously would raise AttributeError instead
+        # (noted as part of Issue #10188)
+        with tempfile.TemporaryDirectory() as nonexistent:
+            pass
+        with self.assertRaises(os.error):
+            tempfile.TemporaryDirectory(dir=nonexistent)
+
     def test_explicit_cleanup(self):
         # A TemporaryDirectory is deleted when cleaned up
         dir = tempfile.mkdtemp()
@@ -955,20 +964,56 @@
     def test_del_on_shutdown(self):
         # A TemporaryDirectory may be cleaned up during shutdown
         # Make sure it works with the relevant modules nulled out
-        dir = tempfile.mkdtemp()
-        try:
+        with self.do_create() as dir:
             d = self.do_create(dir=dir)
             # Mimic the nulling out of modules that
             # occurs during system shutdown
             modules = [os, os.path]
             if has_stat:
                 modules.append(stat)
-            with NulledModules(*modules):
-                d.cleanup()
+            # Currently broken, so suppress the warning
+            # that is otherwise emitted on stdout
+            with support.captured_stderr() as err:
+                with NulledModules(*modules):
+                    d.cleanup()
+            # Currently broken, so stop spurious exception by
+            # indicating the object has already been closed
+            d._closed = True
+            # And this assert will fail, as expected by the
+            # unittest decorator...
             self.assertFalse(os.path.exists(d.name),
                         "TemporaryDirectory %s exists after cleanup" % d.name)
-        finally:
-            os.rmdir(dir)
+
+    def test_warnings_on_cleanup(self):
+        # Two kinds of warning on shutdown
+        #   Issue 10888: may write to stderr if modules are nulled out
+        #   ResourceWarning will be triggered by __del__
+        with self.do_create() as dir:
+            if os.sep != '\\':
+                # Embed a backslash in order to make sure string escaping
+                # in the displayed error message is dealt with correctly
+                suffix = '\\check_backslash_handling'
+            else:
+                suffix = ''
+            d = self.do_create(dir=dir, suf=suffix)
+
+            #Check for the Issue 10888 message
+            modules = [os, os.path]
+            if has_stat:
+                modules.append(stat)
+            with support.captured_stderr() as err:
+                with NulledModules(*modules):
+                    d.cleanup()
+            message = err.getvalue().replace('\\\\', '\\')
+            self.assertIn("while cleaning up",  message)
+            self.assertIn(d.name,  message)
+
+            # Check for the resource warning
+            with support.check_warnings(('Implicitly', ResourceWarning), quiet=False):
+                warnings.filterwarnings("always", category=ResourceWarning)
+                d.__del__()
+            self.assertFalse(os.path.exists(d.name),
+                        "TemporaryDirectory %s exists after __del__" % d.name)
 
     def test_multiple_close(self):
         # Can be cleaned-up many times without error

Modified: python/branches/py3k-cdecimal/Lib/test/test_threadsignals.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_threadsignals.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_threadsignals.py	Sun Jan  2 13:18:37 2011
@@ -6,6 +6,7 @@
 import sys
 from test.support import run_unittest, import_module
 thread = import_module('_thread')
+import time
 
 if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos':
     raise unittest.SkipTest("Can't test signal on %s" % sys.platform)
@@ -34,12 +35,12 @@
     signalled_all.release()
 
 class ThreadSignals(unittest.TestCase):
-    """Test signal handling semantics of threads.
-       We spawn a thread, have the thread send two signals, and
-       wait for it to finish. Check that we got both signals
-       and that they were run by the main thread.
-    """
+
     def test_signals(self):
+        # Test signal handling semantics of threads.
+        # We spawn a thread, have the thread send two signals, and
+        # wait for it to finish. Check that we got both signals
+        # and that they were run by the main thread.
         signalled_all.acquire()
         self.spawnSignallingThread()
         signalled_all.acquire()
@@ -66,6 +67,120 @@
     def spawnSignallingThread(self):
         thread.start_new_thread(send_signals, ())
 
+    def alarm_interrupt(self, sig, frame):
+        raise KeyboardInterrupt
+
+    def test_lock_acquire_interruption(self):
+        # Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
+        # in a deadlock.
+        oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt)
+        try:
+            lock = thread.allocate_lock()
+            lock.acquire()
+            signal.alarm(1)
+            self.assertRaises(KeyboardInterrupt, lock.acquire)
+        finally:
+            signal.signal(signal.SIGALRM, oldalrm)
+
+    def test_rlock_acquire_interruption(self):
+        # Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
+        # in a deadlock.
+        oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt)
+        try:
+            rlock = thread.RLock()
+            # For reentrant locks, the initial acquisition must be in another
+            # thread.
+            def other_thread():
+                rlock.acquire()
+            thread.start_new_thread(other_thread, ())
+            # Wait until we can't acquire it without blocking...
+            while rlock.acquire(blocking=False):
+                rlock.release()
+                time.sleep(0.01)
+            signal.alarm(1)
+            self.assertRaises(KeyboardInterrupt, rlock.acquire)
+        finally:
+            signal.signal(signal.SIGALRM, oldalrm)
+
+    def acquire_retries_on_intr(self, lock):
+        self.sig_recvd = False
+        def my_handler(signal, frame):
+            self.sig_recvd = True
+        old_handler = signal.signal(signal.SIGUSR1, my_handler)
+        try:
+            def other_thread():
+                # Acquire the lock in a non-main thread, so this test works for
+                # RLocks.
+                lock.acquire()
+                # Wait until the main thread is blocked in the lock acquire, and
+                # then wake it up with this.
+                time.sleep(0.5)
+                os.kill(process_pid, signal.SIGUSR1)
+                # Let the main thread take the interrupt, handle it, and retry
+                # the lock acquisition.  Then we'll let it run.
+                time.sleep(0.5)
+                lock.release()
+            thread.start_new_thread(other_thread, ())
+            # Wait until we can't acquire it without blocking...
+            while lock.acquire(blocking=False):
+                lock.release()
+                time.sleep(0.01)
+            result = lock.acquire()  # Block while we receive a signal.
+            self.assertTrue(self.sig_recvd)
+            self.assertTrue(result)
+        finally:
+            signal.signal(signal.SIGUSR1, old_handler)
+
+    def test_lock_acquire_retries_on_intr(self):
+        self.acquire_retries_on_intr(thread.allocate_lock())
+
+    def test_rlock_acquire_retries_on_intr(self):
+        self.acquire_retries_on_intr(thread.RLock())
+
+    def test_interrupted_timed_acquire(self):
+        # Test to make sure we recompute lock acquisition timeouts when we
+        # receive a signal.  Check this by repeatedly interrupting a lock
+        # acquire in the main thread, and make sure that the lock acquire times
+        # out after the right amount of time.
+        # NOTE: this test only behaves as expected if C signals get delivered
+        # to the main thread.  Otherwise lock.acquire() itself doesn't get
+        # interrupted and the test trivially succeeds.
+        self.start = None
+        self.end = None
+        self.sigs_recvd = 0
+        done = thread.allocate_lock()
+        done.acquire()
+        lock = thread.allocate_lock()
+        lock.acquire()
+        def my_handler(signum, frame):
+            self.sigs_recvd += 1
+        old_handler = signal.signal(signal.SIGUSR1, my_handler)
+        try:
+            def timed_acquire():
+                self.start = time.time()
+                lock.acquire(timeout=0.5)
+                self.end = time.time()
+            def send_signals():
+                for _ in range(40):
+                    time.sleep(0.02)
+                    os.kill(process_pid, signal.SIGUSR1)
+                done.release()
+
+            # Send the signals from the non-main thread, since the main thread
+            # is the only one that can process signals.
+            thread.start_new_thread(send_signals, ())
+            timed_acquire()
+            # Wait for thread to finish
+            done.acquire()
+            # This allows for some timing and scheduling imprecision
+            self.assertLess(self.end - self.start, 2.0)
+            self.assertGreater(self.end - self.start, 0.3)
+            # If the signal is received several times before PyErr_CheckSignals()
+            # is called, the handler will get called less than 40 times.
+            self.assertGreater(self.sigs_recvd, 20)
+        finally:
+            signal.signal(signal.SIGUSR1, old_handler)
+
 
 def test_main():
     global signal_blackboard

Modified: python/branches/py3k-cdecimal/Lib/test/test_time.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_time.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_time.py	Sun Jan  2 13:18:37 2011
@@ -126,9 +126,9 @@
     def test_asctime_bounding_check(self):
         self._bounds_checking(time.asctime)
 
+    @unittest.skipIf(not hasattr(time, "tzset"),
+        "time module has no attribute tzset")
     def test_tzset(self):
-        if not hasattr(time, "tzset"):
-            return # Can't test this; don't want the test suite to fail
 
         from os import environ
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_trace.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_trace.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_trace.py	Sun Jan  2 13:18:37 2011
@@ -330,7 +330,7 @@
             lines, cov, module = line.split()[:3]
             coverage[module] = (int(lines), int(cov[:-1]))
         # XXX This is needed to run regrtest.py as a script
-        modname = trace.fullmodname(sys.modules[modname].__file__)
+        modname = trace._fullmodname(sys.modules[modname].__file__)
         self.assertIn(modname, coverage)
         self.assertEqual(coverage[modname], (5, 100))
 
@@ -340,7 +340,7 @@
 class Test_Ignore(unittest.TestCase):
     def test_ignored(self):
         jn = os.path.join
-        ignore = trace.Ignore(['x', 'y.z'], [jn('foo', 'bar')])
+        ignore = trace._Ignore(['x', 'y.z'], [jn('foo', 'bar')])
         self.assertTrue(ignore.names('x.py', 'x'))
         self.assertFalse(ignore.names('xy.py', 'xy'))
         self.assertFalse(ignore.names('y.py', 'y'))

Modified: python/branches/py3k-cdecimal/Lib/test/test_tuple.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_tuple.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_tuple.py	Sun Jan  2 13:18:37 2011
@@ -6,7 +6,7 @@
     type2test = tuple
 
     def test_constructors(self):
-        super().test_len()
+        super().test_constructors()
         # calling built-in types without argument must return empty
         self.assertEqual(tuple(), ())
         t0_3 = (0, 1, 2, 3)

Modified: python/branches/py3k-cdecimal/Lib/test/test_types.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_types.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_types.py	Sun Jan  2 13:18:37 2011
@@ -396,13 +396,9 @@
             self.assertEqual(len(format(0, cfmt)), len(format(x, cfmt)))
 
     def test_float__format__(self):
-        # these should be rewritten to use both format(x, spec) and
-        # x.__format__(spec)
-
         def test(f, format_spec, result):
-            assert type(f) == float
-            assert type(format_spec) == str
             self.assertEqual(f.__format__(format_spec), result)
+            self.assertEqual(format(f, format_spec), result)
 
         test(0.0, 'f', '0.000000')
 
@@ -516,9 +512,27 @@
                 self.assertRaises(ValueError, format, 1e-100, format_spec)
                 self.assertRaises(ValueError, format, -1e-100, format_spec)
 
-        # Alternate formatting is not supported
-        self.assertRaises(ValueError, format, 0.0, '#')
-        self.assertRaises(ValueError, format, 0.0, '#20f')
+        # Alternate float formatting
+        test(1.0, '.0e', '1e+00')
+        test(1.0, '#.0e', '1.e+00')
+        test(1.0, '.0f', '1')
+        test(1.0, '#.0f', '1.')
+        test(1.1, 'g', '1.1')
+        test(1.1, '#g', '1.10000')
+        test(1.0, '.0%', '100%')
+        test(1.0, '#.0%', '100.%')
+
+        # Issue 7094: Alternate formatting (specified by #)
+        test(1.0, '0e',  '1.000000e+00')
+        test(1.0, '#0e', '1.000000e+00')
+        test(1.0, '0f',  '1.000000' )
+        test(1.0, '#0f', '1.000000')
+        test(1.0, '.1e',  '1.0e+00')
+        test(1.0, '#.1e', '1.0e+00')
+        test(1.0, '.1f',  '1.0')
+        test(1.0, '#.1f', '1.0')
+        test(1.0, '.1%',  '100.0%')
+        test(1.0, '#.1%', '100.0%')
 
         # Issue 6902
         test(12345.6, "0<20", '12345.60000000000000')

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	Sun Jan  2 13:18:37 2011
@@ -1168,8 +1168,13 @@
         # Error handling (wrong arguments)
         self.assertRaises(TypeError, "hello".encode, 42, 42, 42)
 
-        # Error handling (PyUnicode_EncodeDecimal())
-        self.assertRaises(UnicodeError, int, "\u0200")
+        # Error handling (lone surrogate in PyUnicode_TransformDecimalToASCII())
+        self.assertRaises(UnicodeError, int, "\ud800")
+        self.assertRaises(UnicodeError, int, "\udf00")
+        self.assertRaises(UnicodeError, float, "\ud800")
+        self.assertRaises(UnicodeError, float, "\udf00")
+        self.assertRaises(UnicodeError, complex, "\ud800")
+        self.assertRaises(UnicodeError, complex, "\udf00")
 
     def test_codecs(self):
         # Encoding
@@ -1427,7 +1432,7 @@
 
         # non-ascii format, ascii argument: ensure that PyUnicode_FromFormat()
         # raises an error for a non-ascii format string.
-        self.assertRaisesRegexp(ValueError,
+        self.assertRaisesRegex(ValueError,
             '^PyUnicode_FromFormatV\(\) expects an ASCII-encoded format '
             'string, got a non-ASCII byte: 0xe9$',
             format_unicode, b'unicode\xe9=%s', 'ascii')
@@ -1439,6 +1444,7 @@
     # Test PyUnicode_AsWideChar()
     def test_aswidechar(self):
         from _testcapi import unicode_aswidechar
+        support.import_module('ctypes')
         from ctypes import c_wchar, sizeof
 
         wchar, size = unicode_aswidechar('abcdef', 2)
@@ -1475,6 +1481,7 @@
     # Test PyUnicode_AsWideCharString()
     def test_aswidecharstring(self):
         from _testcapi import unicode_aswidecharstring
+        support.import_module('ctypes')
         from ctypes import c_wchar, sizeof
 
         wchar, size = unicode_aswidecharstring('abc')

Modified: python/branches/py3k-cdecimal/Lib/test/test_unicodedata.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_unicodedata.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_unicodedata.py	Sun Jan  2 13:18:37 2011
@@ -188,9 +188,22 @@
 
     def test_pr29(self):
         # http://www.unicode.org/review/pr-29.html
-        for text in ("\u0b47\u0300\u0b3e", "\u1100\u0300\u1161"):
+        # See issues #1054943 and #10254.
+        composed = ("\u0b47\u0300\u0b3e", "\u1100\u0300\u1161",
+                    'Li\u030dt-s\u1e73\u0301',
+                    '\u092e\u093e\u0930\u094d\u0915 \u091c\u093c'
+                    + '\u0941\u0915\u0947\u0930\u092c\u0930\u094d\u0917',
+                    '\u0915\u093f\u0930\u094d\u0917\u093f\u091c\u093c'
+                    + '\u0938\u094d\u0924\u093e\u0928')
+        for text in composed:
             self.assertEqual(self.db.normalize('NFC', text), text)
 
+    def test_issue10254(self):
+        # Crash reported in #10254
+        a = 'C\u0338' * 20  + 'C\u0327'
+        b = 'C\u0338' * 20  + '\xC7'
+        self.assertEqual(self.db.normalize('NFC', a), b)
+
     def test_east_asian_width(self):
         eaw = self.db.east_asian_width
         self.assertRaises(TypeError, eaw, b'a')

Modified: python/branches/py3k-cdecimal/Lib/test/test_unittest.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_unittest.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_unittest.py	Sun Jan  2 13:18:37 2011
@@ -4,8 +4,13 @@
 
 
 def test_main():
+    # used by regrtest
     support.run_unittest(unittest.test.suite())
     support.reap_children()
 
+def load_tests(*_):
+    # used by unittest
+    return unittest.test.suite()
+
 if __name__ == "__main__":
     test_main()

Modified: python/branches/py3k-cdecimal/Lib/test/test_urllib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_urllib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_urllib.py	Sun Jan  2 13:18:37 2011
@@ -139,8 +139,10 @@
 
     def fakehttp(self, fakedata):
         class FakeSocket(io.BytesIO):
+            io_refs = 1
             def sendall(self, str): pass
             def makefile(self, *args, **kwds):
+                self.io_refs += 1
                 return self
             def read(self, amt=None):
                 if self.closed: return b""
@@ -148,6 +150,10 @@
             def readline(self, length=None):
                 if self.closed: return b""
                 return io.BytesIO.readline(self, length)
+            def close(self):
+                self.io_refs -= 1
+                if self.io_refs == 0:
+                    io.BytesIO.close(self)
         class FakeHTTPConnection(http.client.HTTPConnection):
             def connect(self):
                 self.sock = FakeSocket(fakedata)
@@ -157,8 +163,8 @@
     def unfakehttp(self):
         http.client.HTTPConnection = self._connection_class
 
-    def test_read(self):
-        self.fakehttp(b"Hello!")
+    def check_read(self, ver):
+        self.fakehttp(b"HTTP/" + ver + b" 200 OK\r\n\r\nHello!")
         try:
             fp = urlopen("http://python.org/")
             self.assertEqual(fp.readline(), b"Hello!")
@@ -168,6 +174,17 @@
         finally:
             self.unfakehttp()
 
+    def test_read_0_9(self):
+        # "0.9" response accepted (but not "simple responses" without
+        # a status line)
+        self.check_read(b"0.9")
+
+    def test_read_1_0(self):
+        self.check_read(b"1.0")
+
+    def test_read_1_1(self):
+        self.check_read(b"1.1")
+
     def test_read_bogus(self):
         # urlopen() should raise IOError for many error codes.
         self.fakehttp(b'''HTTP/1.1 401 Authentication Required
@@ -191,7 +208,7 @@
             self.unfakehttp()
 
     def test_userpass_inurl(self):
-        self.fakehttp(b"Hello!")
+        self.fakehttp(b"HTTP/1.0 200 OK\r\n\r\nHello!")
         try:
             fp = urlopen("http://user:pass@python.org/")
             self.assertEqual(fp.readline(), b"Hello!")

Modified: python/branches/py3k-cdecimal/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_urllib2.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_urllib2.py	Sun Jan  2 13:18:37 2011
@@ -4,6 +4,7 @@
 import os
 import io
 import socket
+import array
 
 import urllib.request
 from urllib.request import Request, OpenerDirector
@@ -765,7 +766,7 @@
         o = h.parent = MockOpener()
 
         url = "http://example.com/"
-        for method, data in [("GET", None), ("POST", "blah")]:
+        for method, data in [("GET", None), ("POST", b"blah")]:
             req = Request(url, data, {"Foo": "bar"})
             req.timeout = None
             req.add_unredirected_header("Spam", "eggs")
@@ -795,7 +796,7 @@
 
         # check adding of standard headers
         o.addheaders = [("Spam", "eggs")]
-        for data in "", None:  # POST, GET
+        for data in b"", None:  # POST, GET
             req = Request("http://example.com/", data)
             r = MockResponse(200, "OK", {}, "")
             newreq = h.do_request_(req)
@@ -821,6 +822,48 @@
             self.assertEqual(req.unredirected_hdrs["Host"], "baz")
             self.assertEqual(req.unredirected_hdrs["Spam"], "foo")
 
+        # Check iterable body support
+        def iterable_body():
+            yield b"one"
+            yield b"two"
+            yield b"three"
+
+        for headers in {}, {"Content-Length": 11}:
+            req = Request("http://example.com/", iterable_body(), headers)
+            if not headers:
+                # Having an iterable body without a Content-Length should
+                # raise an exception
+                self.assertRaises(ValueError, h.do_request_, req)
+            else:
+                newreq = h.do_request_(req)
+
+        # A file object
+
+        file_obj = io.StringIO()
+        file_obj.write("Something\nSomething\nSomething\n")
+
+        for headers in {}, {"Content-Length": 30}:
+            req = Request("http://example.com/", file_obj, headers)
+            if not headers:
+                # Having an iterable body without a Content-Length should
+                # raise an exception
+                self.assertRaises(ValueError, h.do_request_, req)
+            else:
+                newreq = h.do_request_(req)
+                self.assertEqual(int(newreq.get_header('Content-length')),30)
+
+        file_obj.close()
+
+        # array.array Iterable - Content Length is calculated
+
+        iterable_array = array.array("I",[1,2,3,4])
+
+        for headers in {}, {"Content-Length": 16}:
+            req = Request("http://example.com/", iterable_array, headers)
+            newreq = h.do_request_(req)
+            self.assertEqual(int(newreq.get_header('Content-length')),16)
+
+
     def test_http_doubleslash(self):
         # Checks the presence of any unnecessary double slash in url does not
         # break anything. Previously, a double slash directly after the host
@@ -828,7 +871,7 @@
         h = urllib.request.AbstractHTTPHandler()
         o = h.parent = MockOpener()
 
-        data = ""
+        data = b""
         ds_urls = [
             "http://example.com/foo/bar/baz.html",
             "http://example.com//foo/bar/baz.html",

Modified: python/branches/py3k-cdecimal/Lib/test/test_urllibnet.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_urllibnet.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_urllibnet.py	Sun Jan  2 13:18:37 2011
@@ -13,7 +13,7 @@
 
 class URLTimeoutTest(unittest.TestCase):
 
-    TIMEOUT = 10.0
+    TIMEOUT = 30.0
 
     def setUp(self):
         socket.setdefaulttimeout(self.TIMEOUT)

Modified: python/branches/py3k-cdecimal/Lib/test/test_urlparse.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_urlparse.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_urlparse.py	Sun Jan  2 13:18:37 2011
@@ -24,6 +24,17 @@
     ("&a=b", [('a', 'b')]),
     ("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]),
     ("a=1&a=2", [('a', '1'), ('a', '2')]),
+    (b"", []),
+    (b"&", []),
+    (b"&&", []),
+    (b"=", [(b'', b'')]),
+    (b"=a", [(b'', b'a')]),
+    (b"a", [(b'a', b'')]),
+    (b"a=", [(b'a', b'')]),
+    (b"a=", [(b'a', b'')]),
+    (b"&a=b", [(b'a', b'b')]),
+    (b"a=a+b&b=b+c", [(b'a', b'a b'), (b'b', b'b c')]),
+    (b"a=1&a=2", [(b'a', b'1'), (b'a', b'2')]),
 ]
 
 class UrlParseTestCase(unittest.TestCase):
@@ -86,7 +97,7 @@
 
 
     def test_roundtrips(self):
-        testcases = [
+        str_cases = [
             ('file:///tmp/junk.txt',
              ('file', '', '/tmp/junk.txt', '', '', ''),
              ('file', '', '/tmp/junk.txt', '', '')),
@@ -110,16 +121,21 @@
             ('git+ssh', 'git at github.com','/user/project.git',
              '','',''),
             ('git+ssh', 'git at github.com','/user/project.git',
-             '', ''))
+             '', '')),
             ]
-        for url, parsed, split in testcases:
+        def _encode(t):
+            return (t[0].encode('ascii'),
+                    tuple(x.encode('ascii') for x in t[1]),
+                    tuple(x.encode('ascii') for x in t[2]))
+        bytes_cases = [_encode(x) for x in str_cases]
+        for url, parsed, split in str_cases + bytes_cases:
             self.checkRoundtrips(url, parsed, split)
 
     def test_http_roundtrips(self):
         # urllib.parse.urlsplit treats 'http:' as an optimized special case,
         # so we test both 'http:' and 'https:' in all the following.
         # Three cheers for white box knowledge!
-        testcases = [
+        str_cases = [
             ('://www.python.org',
              ('www.python.org', '', '', '', ''),
              ('www.python.org', '', '', '')),
@@ -136,19 +152,34 @@
              ('a', '/b/c/d', 'p', 'q', 'f'),
              ('a', '/b/c/d;p', 'q', 'f')),
             ]
-        for scheme in ('http', 'https'):
-            for url, parsed, split in testcases:
-                url = scheme + url
-                parsed = (scheme,) + parsed
-                split = (scheme,) + split
-                self.checkRoundtrips(url, parsed, split)
+        def _encode(t):
+            return (t[0].encode('ascii'),
+                    tuple(x.encode('ascii') for x in t[1]),
+                    tuple(x.encode('ascii') for x in t[2]))
+        bytes_cases = [_encode(x) for x in str_cases]
+        str_schemes = ('http', 'https')
+        bytes_schemes = (b'http', b'https')
+        str_tests = str_schemes, str_cases
+        bytes_tests = bytes_schemes, bytes_cases
+        for schemes, test_cases in (str_tests, bytes_tests):
+            for scheme in schemes:
+                for url, parsed, split in test_cases:
+                    url = scheme + url
+                    parsed = (scheme,) + parsed
+                    split = (scheme,) + split
+                    self.checkRoundtrips(url, parsed, split)
 
     def checkJoin(self, base, relurl, expected):
-        self.assertEqual(urllib.parse.urljoin(base, relurl), expected,
-                         (base, relurl, expected))
+        str_components = (base, relurl, expected)
+        self.assertEqual(urllib.parse.urljoin(base, relurl), expected)
+        bytes_components = baseb, relurlb, expectedb = [
+                            x.encode('ascii') for x in str_components]
+        self.assertEqual(urllib.parse.urljoin(baseb, relurlb), expectedb)
 
     def test_unparse_parse(self):
-        for u in ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',]:
+        str_cases = ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',]
+        bytes_cases = [x.encode('ascii') for x in str_cases]
+        for u in str_cases + bytes_cases:
             self.assertEqual(urllib.parse.urlunsplit(urllib.parse.urlsplit(u)), u)
             self.assertEqual(urllib.parse.urlunparse(urllib.parse.urlparse(u)), u)
 
@@ -296,6 +327,9 @@
         #self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser
         self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') #relaxed parser
 
+        # Test for issue9721
+        self.checkJoin('http://a/b/c/de', ';x','http://a/b/c/;x')
+
     def test_urljoins(self):
         self.checkJoin(SIMPLE_BASE, 'g:h','g:h')
         self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g')
@@ -328,7 +362,7 @@
         self.checkJoin(SIMPLE_BASE, 'http:g?y/./x','http://a/b/c/g?y/./x')
 
     def test_RFC2732(self):
-        for url, hostname, port in [
+        str_cases = [
             ('http://Test.python.org:5432/foo/', 'test.python.org', 5432),
             ('http://12.34.56.78:5432/foo/', '12.34.56.78', 5432),
             ('http://[::1]:5432/foo/', '::1', 5432),
@@ -349,20 +383,26 @@
             ('http://[::12.34.56.78]/foo/', '::12.34.56.78', None),
             ('http://[::ffff:12.34.56.78]/foo/',
              '::ffff:12.34.56.78', None),
-            ]:
+            ]
+        def _encode(t):
+            return t[0].encode('ascii'), t[1].encode('ascii'), t[2]
+        bytes_cases = [_encode(x) for x in str_cases]
+        for url, hostname, port in str_cases + bytes_cases:
             urlparsed = urllib.parse.urlparse(url)
             self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port))
 
-        for invalid_url in [
+        str_cases = [
                 'http://::12.34.56.78]/',
                 'http://[::1/foo/',
                 'ftp://[::1/foo/bad]/bad',
                 'http://[::1/foo/bad]/bad',
-                'http://[::ffff:12.34.56.78']:
+                'http://[::ffff:12.34.56.78']
+        bytes_cases = [x.encode('ascii') for x in str_cases]
+        for invalid_url in str_cases + bytes_cases:
             self.assertRaises(ValueError, urllib.parse.urlparse, invalid_url)
 
     def test_urldefrag(self):
-        for url, defrag, frag in [
+        str_cases = [
             ('http://python.org#frag', 'http://python.org', 'frag'),
             ('http://python.org', 'http://python.org', ''),
             ('http://python.org/#frag', 'http://python.org/', 'frag'),
@@ -373,8 +413,16 @@
             ('http://python.org/p?q', 'http://python.org/p?q', ''),
             (RFC1808_BASE, 'http://a/b/c/d;p?q', 'f'),
             (RFC2396_BASE, 'http://a/b/c/d;p?q', ''),
-            ]:
-            self.assertEqual(urllib.parse.urldefrag(url), (defrag, frag))
+        ]
+        def _encode(t):
+            return type(t)(x.encode('ascii') for x in t)
+        bytes_cases = [_encode(x) for x in str_cases]
+        for url, defrag, frag in str_cases + bytes_cases:
+            result = urllib.parse.urldefrag(url)
+            self.assertEqual(result.geturl(), url)
+            self.assertEqual(result, (defrag, frag))
+            self.assertEqual(result.url, defrag)
+            self.assertEqual(result.fragment, frag)
 
     def test_urlsplit_attributes(self):
         url = "HTTP://WWW.PYTHON.ORG/doc/#frag"
@@ -390,7 +438,8 @@
         self.assertEqual(p.port, None)
         # geturl() won't return exactly the original URL in this case
         # since the scheme is always case-normalized
-        #self.assertEqual(p.geturl(), url)
+        # We handle this by ignoring the first 4 characters of the URL
+        self.assertEqual(p.geturl()[4:], url[4:])
 
         url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag"
         p = urllib.parse.urlsplit(url)
@@ -422,6 +471,45 @@
         self.assertEqual(p.port, 80)
         self.assertEqual(p.geturl(), url)
 
+        # And check them all again, only with bytes this time
+        url = b"HTTP://WWW.PYTHON.ORG/doc/#frag"
+        p = urllib.parse.urlsplit(url)
+        self.assertEqual(p.scheme, b"http")
+        self.assertEqual(p.netloc, b"WWW.PYTHON.ORG")
+        self.assertEqual(p.path, b"/doc/")
+        self.assertEqual(p.query, b"")
+        self.assertEqual(p.fragment, b"frag")
+        self.assertEqual(p.username, None)
+        self.assertEqual(p.password, None)
+        self.assertEqual(p.hostname, b"www.python.org")
+        self.assertEqual(p.port, None)
+        self.assertEqual(p.geturl()[4:], url[4:])
+
+        url = b"http://User:Pass@www.python.org:080/doc/?query=yes#frag"
+        p = urllib.parse.urlsplit(url)
+        self.assertEqual(p.scheme, b"http")
+        self.assertEqual(p.netloc, b"User:Pass at www.python.org:080")
+        self.assertEqual(p.path, b"/doc/")
+        self.assertEqual(p.query, b"query=yes")
+        self.assertEqual(p.fragment, b"frag")
+        self.assertEqual(p.username, b"User")
+        self.assertEqual(p.password, b"Pass")
+        self.assertEqual(p.hostname, b"www.python.org")
+        self.assertEqual(p.port, 80)
+        self.assertEqual(p.geturl(), url)
+
+        url = b"http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag"
+        p = urllib.parse.urlsplit(url)
+        self.assertEqual(p.scheme, b"http")
+        self.assertEqual(p.netloc, b"User at example.com:Pass at www.python.org:080")
+        self.assertEqual(p.path, b"/doc/")
+        self.assertEqual(p.query, b"query=yes")
+        self.assertEqual(p.fragment, b"frag")
+        self.assertEqual(p.username, b"User at example.com")
+        self.assertEqual(p.password, b"Pass")
+        self.assertEqual(p.hostname, b"www.python.org")
+        self.assertEqual(p.port, 80)
+        self.assertEqual(p.geturl(), url)
 
     def test_attributes_bad_port(self):
         """Check handling of non-integer ports."""
@@ -433,6 +521,15 @@
         self.assertEqual(p.netloc, "www.example.net:foo")
         self.assertRaises(ValueError, lambda: p.port)
 
+        # Once again, repeat ourselves to test bytes
+        p = urllib.parse.urlsplit(b"http://www.example.net:foo")
+        self.assertEqual(p.netloc, b"www.example.net:foo")
+        self.assertRaises(ValueError, lambda: p.port)
+
+        p = urllib.parse.urlparse(b"http://www.example.net:foo")
+        self.assertEqual(p.netloc, b"www.example.net:foo")
+        self.assertRaises(ValueError, lambda: p.port)
+
     def test_attributes_without_netloc(self):
         # This example is straight from RFC 3261.  It looks like it
         # should allow the username, hostname, and port to be filled
@@ -456,10 +553,30 @@
         self.assertEqual(p.port, None)
         self.assertEqual(p.geturl(), uri)
 
+        # You guessed it, repeating the test with bytes input
+        uri = b"sip:alice at atlanta.com;maddr=239.255.255.1;ttl=15"
+        p = urllib.parse.urlsplit(uri)
+        self.assertEqual(p.netloc, b"")
+        self.assertEqual(p.username, None)
+        self.assertEqual(p.password, None)
+        self.assertEqual(p.hostname, None)
+        self.assertEqual(p.port, None)
+        self.assertEqual(p.geturl(), uri)
+
+        p = urllib.parse.urlparse(uri)
+        self.assertEqual(p.netloc, b"")
+        self.assertEqual(p.username, None)
+        self.assertEqual(p.password, None)
+        self.assertEqual(p.hostname, None)
+        self.assertEqual(p.port, None)
+        self.assertEqual(p.geturl(), uri)
+
     def test_noslash(self):
         # Issue 1637: http://foo.com?query is legal
         self.assertEqual(urllib.parse.urlparse("http://example.com?blahblah=/foo"),
                          ('http', 'example.com', '', '', 'blahblah=/foo', ''))
+        self.assertEqual(urllib.parse.urlparse(b"http://example.com?blahblah=/foo"),
+                         (b'http', b'example.com', b'', b'', b'blahblah=/foo', b''))
 
     def test_withoutscheme(self):
         # Test urlparse without scheme
@@ -472,6 +589,13 @@
                 ('','www.python.org:80','','','',''))
         self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
                 ('http','www.python.org:80','','','',''))
+        # Repeat for bytes input
+        self.assertEqual(urllib.parse.urlparse(b"path"),
+                (b'',b'',b'path',b'',b'',b''))
+        self.assertEqual(urllib.parse.urlparse(b"//www.python.org:80"),
+                (b'',b'www.python.org:80',b'',b'',b'',b''))
+        self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
+                (b'http',b'www.python.org:80',b'',b'',b'',b''))
 
     def test_portseparator(self):
         # Issue 754016 makes changes for port separator ':' from scheme separator
@@ -481,6 +605,13 @@
         self.assertEqual(urllib.parse.urlparse("https:"),('https','','','','',''))
         self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
                 ('http','www.python.org:80','','','',''))
+        # As usual, need to check bytes input as well
+        self.assertEqual(urllib.parse.urlparse(b"path:80"),
+                (b'',b'',b'path:80',b'',b'',b''))
+        self.assertEqual(urllib.parse.urlparse(b"http:"),(b'http',b'',b'',b'',b'',b''))
+        self.assertEqual(urllib.parse.urlparse(b"https:"),(b'https',b'',b'',b'',b'',b''))
+        self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
+                (b'http',b'www.python.org:80',b'',b'',b'',b''))
 
     def test_usingsys(self):
         # Issue 3314: sys module is used in the error
@@ -492,6 +623,71 @@
                          ('s3', 'foo.com', '/stuff', '', '', ''))
         self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"),
                          ('x-newscheme', 'foo.com', '/stuff', '', '', ''))
+        # And for bytes...
+        self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"),
+                         (b's3', b'foo.com', b'/stuff', b'', b'', b''))
+        self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"),
+                         (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b''))
+
+    def test_mixed_types_rejected(self):
+        # Several functions that process either strings or ASCII encoded bytes
+        # accept multiple arguments. Check they reject mixed type input
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urlparse("www.python.org", b"http")
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urlparse(b"www.python.org", "http")
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urlsplit("www.python.org", b"http")
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urlsplit(b"www.python.org", "http")
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urlunparse(( b"http", "www.python.org","","","",""))
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urlunparse(("http", b"www.python.org","","","",""))
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urlunsplit((b"http", "www.python.org","","",""))
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urlunsplit(("http", b"www.python.org","","",""))
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urljoin("http://python.org", b"http://python.org")
+        with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+            urllib.parse.urljoin(b"http://python.org", "http://python.org")
+
+    def _check_result_type(self, str_type):
+        num_args = len(str_type._fields)
+        bytes_type = str_type._encoded_counterpart
+        self.assertIs(bytes_type._decoded_counterpart, str_type)
+        str_args = ('',) * num_args
+        bytes_args = (b'',) * num_args
+        str_result = str_type(*str_args)
+        bytes_result = bytes_type(*bytes_args)
+        encoding = 'ascii'
+        errors = 'strict'
+        self.assertEqual(str_result, str_args)
+        self.assertEqual(bytes_result.decode(), str_args)
+        self.assertEqual(bytes_result.decode(), str_result)
+        self.assertEqual(bytes_result.decode(encoding), str_args)
+        self.assertEqual(bytes_result.decode(encoding), str_result)
+        self.assertEqual(bytes_result.decode(encoding, errors), str_args)
+        self.assertEqual(bytes_result.decode(encoding, errors), str_result)
+        self.assertEqual(bytes_result, bytes_args)
+        self.assertEqual(str_result.encode(), bytes_args)
+        self.assertEqual(str_result.encode(), bytes_result)
+        self.assertEqual(str_result.encode(encoding), bytes_args)
+        self.assertEqual(str_result.encode(encoding), bytes_result)
+        self.assertEqual(str_result.encode(encoding, errors), bytes_args)
+        self.assertEqual(str_result.encode(encoding, errors), bytes_result)
+
+    def test_result_pairs(self):
+        # Check encoding and decoding between result pairs
+        result_types = [
+          urllib.parse.DefragResult,
+          urllib.parse.SplitResult,
+          urllib.parse.ParseResult,
+        ]
+        for result_type in result_types:
+            self._check_result_type(result_type)
+
 
 def test_main():
     support.run_unittest(UrlParseTestCase)

Modified: python/branches/py3k-cdecimal/Lib/test/test_weakset.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_weakset.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_weakset.py	Sun Jan  2 13:18:37 2011
@@ -50,7 +50,8 @@
     def test_contains(self):
         for c in self.letters:
             self.assertEqual(c in self.s, c in self.d)
-        self.assertRaises(TypeError, self.s.__contains__, [[]])
+        # 1 is not weakref'able, but that TypeError is caught by __contains__
+        self.assertNotIn(1, self.s)
         self.assertIn(self.obj, self.fs)
         del self.obj
         self.assertNotIn(ustr('F'), self.fs)

Modified: python/branches/py3k-cdecimal/Lib/test/test_winsound.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_winsound.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_winsound.py	Sun Jan  2 13:18:37 2011
@@ -249,6 +249,7 @@
         p = subprocess.Popen([cscript_path, check_script],
                              stdout=subprocess.PIPE)
         __have_soundcard_cache = not p.wait()
+        p.stdout.close()
     return __have_soundcard_cache
 
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_wsgiref.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_wsgiref.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_wsgiref.py	Sun Jan  2 13:18:37 2011
@@ -342,6 +342,10 @@
         self.checkReqURI("http://127.0.0.1/sp%C3%A4m", SCRIPT_NAME="/späm")
         self.checkReqURI("http://127.0.0.1/spammity/spam",
             SCRIPT_NAME="/spammity", PATH_INFO="/spam")
+        self.checkReqURI("http://127.0.0.1/spammity/spam;ham",
+            SCRIPT_NAME="/spammity", PATH_INFO="/spam;ham")
+        self.checkReqURI("http://127.0.0.1/spammity/spam;cookie=1234,5678",
+            SCRIPT_NAME="/spammity", PATH_INFO="/spam;cookie=1234,5678")
         self.checkReqURI("http://127.0.0.1/spammity/spam?say=ni",
             SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni")
         self.checkReqURI("http://127.0.0.1/spammity/spam", 0,

Modified: python/branches/py3k-cdecimal/Lib/test/test_xml_etree.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_xml_etree.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_xml_etree.py	Sun Jan  2 13:18:37 2011
@@ -1841,6 +1841,15 @@
 
     """
 
+def check_issue10777():
+    """
+    Registering a namespace twice caused a "dictionary changed size during
+    iteration" bug.
+
+    >>> ET.register_namespace('test10777', 'http://myuri/')
+    >>> ET.register_namespace('test10777', 'http://myuri/')
+    """
+
 # --------------------------------------------------------------------
 
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_xml_etree_c.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_xml_etree_c.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_xml_etree_c.py	Sun Jan  2 13:18:37 2011
@@ -8,10 +8,26 @@
 # cElementTree specific tests
 
 def sanity():
-    """
+    r"""
     Import sanity.
 
     >>> from xml.etree import cElementTree
+
+    Issue #6697.
+
+    >>> e = cElementTree.Element('a')
+    >>> getattr(e, '\uD800')           # doctest: +ELLIPSIS
+    Traceback (most recent call last):
+      ...
+    UnicodeEncodeError: ...
+
+    >>> p = cElementTree.XMLParser()
+    >>> p.version.split()[0]
+    'Expat'
+    >>> getattr(p, '\uD800')
+    Traceback (most recent call last):
+     ...
+    AttributeError: 'XMLParser' object has no attribute '\ud800'
     """
 
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_xmlrpc.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_xmlrpc.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_xmlrpc.py	Sun Jan  2 13:18:37 2011
@@ -715,8 +715,8 @@
         t.encode_threshold = None
         t.fake_gzip = True
         p = xmlrpclib.ServerProxy(URL, transport=t)
-        cm = self.assertRaisesRegexp(xmlrpclib.ProtocolError,
-                                     re.compile(r"\b400\b"))
+        cm = self.assertRaisesRegex(xmlrpclib.ProtocolError,
+                                    re.compile(r"\b400\b"))
         with cm:
             p.pow(6, 8)
 

Modified: python/branches/py3k-cdecimal/Lib/test/test_zipfile.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_zipfile.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_zipfile.py	Sun Jan  2 13:18:37 2011
@@ -6,6 +6,7 @@
 
 import io
 import os
+import sys
 import imp
 import time
 import shutil
@@ -23,6 +24,7 @@
 TESTFN2 = TESTFN + "2"
 TESTFNDIR = TESTFN + "d"
 FIXEDTEST_SIZE = 1000
+DATAFILES_DIR = 'zipfile_datafiles'
 
 SMALL_TEST_DATA = [('_ziptest1', '1q2w3e4r5t'),
                    ('ziptest2dir/_ziptest2', 'qawsedrftg'),
@@ -487,6 +489,13 @@
         except zipfile.BadZipFile:
             self.assertTrue(zipfp2.fp is None, 'zipfp is not closed')
 
+    def test_unicode_filenames(self):
+        # bug #10801
+        fname = findfile('zip_cp437_header.zip')
+        with zipfile.ZipFile(fname) as zipfp:
+            for name in zipfp.namelist():
+                zipfp.open(name).close()
+
     def tearDown(self):
         unlink(TESTFN)
         unlink(TESTFN2)
@@ -609,7 +618,7 @@
 
 class PyZipFileTests(unittest.TestCase):
     def test_write_pyfile(self):
-        with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
+        with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
             fn = __file__
             if fn.endswith('.pyc') or fn.endswith('.pyo'):
                 path_split = fn.split(os.sep)
@@ -627,7 +636,7 @@
             self.assertTrue(bn + 'o' in zipfp.namelist() or
                             bn + 'c' in zipfp.namelist())
 
-        with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
+        with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
             fn = __file__
             if fn.endswith(('.pyc', '.pyo')):
                 fn = fn[:-1]
@@ -643,7 +652,7 @@
         import email
         packagedir = os.path.dirname(email.__file__)
 
-        with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
+        with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
             zipfp.writepy(packagedir)
 
             # Check for a couple of modules at different levels of the
@@ -654,6 +663,22 @@
             self.assertTrue('email/mime/text.pyo' in names or
                             'email/mime/text.pyc' in names)
 
+    def test_write_with_optimization(self):
+        import email
+        packagedir = os.path.dirname(email.__file__)
+        # use .pyc if running test in optimization mode,
+        # use .pyo if running test in debug mode
+        optlevel = 1 if __debug__ else 0
+        ext = '.pyo' if optlevel == 1 else '.pyc'
+
+        with TemporaryFile() as t, \
+                 zipfile.PyZipFile(t, "w", optimize=optlevel) as zipfp:
+            zipfp.writepy(packagedir)
+
+            names = zipfp.namelist()
+            self.assertIn('email/__init__' + ext, names)
+            self.assertIn('email/mime/text' + ext, names)
+
     def test_write_python_directory(self):
         os.mkdir(TESTFN2)
         try:
@@ -666,26 +691,25 @@
             with open(os.path.join(TESTFN2, "mod2.txt"), "w") as fp:
                 fp.write("bla bla bla\n")
 
-            zipfp  = zipfile.PyZipFile(TemporaryFile(), "w")
-            zipfp.writepy(TESTFN2)
+            with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
+                zipfp.writepy(TESTFN2)
 
-            names = zipfp.namelist()
-            self.assertTrue('mod1.pyc' in names or 'mod1.pyo' in names)
-            self.assertTrue('mod2.pyc' in names or 'mod2.pyo' in names)
-            self.assertNotIn('mod2.txt', names)
+                names = zipfp.namelist()
+                self.assertTrue('mod1.pyc' in names or 'mod1.pyo' in names)
+                self.assertTrue('mod2.pyc' in names or 'mod2.pyo' in names)
+                self.assertNotIn('mod2.txt', names)
 
         finally:
             shutil.rmtree(TESTFN2)
 
     def test_write_non_pyfile(self):
-        with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
+        with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
             with open(TESTFN, 'w') as f:
                 f.write('most definitely not a python file')
             self.assertRaises(RuntimeError, zipfp.writepy, TESTFN)
             os.remove(TESTFN)
 
 
-
 class OtherTests(unittest.TestCase):
     zips_with_bad_crc = {
         zipfile.ZIP_STORED: (
@@ -1074,6 +1098,12 @@
         self.zip2.setpassword(b"12345")
         self.assertEqual(self.zip2.read("zero"), self.plain2)
 
+    def test_unicode_password(self):
+        self.assertRaises(TypeError, self.zip.setpassword, "unicode")
+        self.assertRaises(TypeError, self.zip.read, "test.txt", "python")
+        self.assertRaises(TypeError, self.zip.open, "test.txt", pwd="python")
+        self.assertRaises(TypeError, self.zip.extract, "test.txt", pwd="python")
+
 
 class TestsWithRandomBinaryFiles(unittest.TestCase):
     def setUp(self):

Modified: python/branches/py3k-cdecimal/Lib/test/test_zipimport_support.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_zipimport_support.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_zipimport_support.py	Sun Jan  2 13:18:37 2011
@@ -200,7 +200,7 @@
                         pass
 
                     import pdb
-                    pdb.runcall(f)
+                    pdb.Pdb(nosigint=True).runcall(f)
                     """)
         with temp_dir() as d:
             script_name = make_script(d, 'script', test_src)

Modified: python/branches/py3k-cdecimal/Lib/test/test_zlib.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/test_zlib.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/test_zlib.py	Sun Jan  2 13:18:37 2011
@@ -143,7 +143,7 @@
     def test_incomplete_stream(self):
         # An useful error message is given
         x = zlib.compress(HAMLET_SCENE)
-        self.assertRaisesRegexp(zlib.error,
+        self.assertRaisesRegex(zlib.error,
             "Error -5 while decompressing data: incomplete or truncated stream",
             zlib.decompress, x[:-1])
 

Modified: python/branches/py3k-cdecimal/Lib/test/win_console_handler.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/test/win_console_handler.py	(original)
+++ python/branches/py3k-cdecimal/Lib/test/win_console_handler.py	Sun Jan  2 13:18:37 2011
@@ -40,7 +40,7 @@
         print("Unable to add SetConsoleCtrlHandler")
         exit(-1)
 
-    # Awaken mail process
+    # Awake main process
     m = mmap.mmap(-1, 1, sys.argv[1])
     m[0] = 1
 

Modified: python/branches/py3k-cdecimal/Lib/threading.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/threading.py	(original)
+++ python/branches/py3k-cdecimal/Lib/threading.py	Sun Jan  2 13:18:37 2011
@@ -55,8 +55,14 @@
         def _note(self, format, *args):
             if self._verbose:
                 format = format % args
-                format = "%s: %s\n" % (
-                    current_thread().name, format)
+                # Issue #4188: calling current_thread() can incur an infinite
+                # recursion if it has to create a DummyThread on the fly.
+                ident = _get_ident()
+                try:
+                    name = _active[ident].name
+                except KeyError:
+                    name = "<OS thread %d>" % ident
+                format = "%s: %s\n" % (name, format)
                 _sys.stderr.write(format)
 
 else:

Modified: python/branches/py3k-cdecimal/Lib/tkinter/__init__.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tkinter/__init__.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tkinter/__init__.py	Sun Jan  2 13:18:37 2011
@@ -216,8 +216,8 @@
         self._master.deletecommand(cbname)
     def trace_vinfo(self):
         """Return all trace callback information."""
-        return map(self._tk.split, self._tk.splitlist(
-            self._tk.call("trace", "vinfo", self._name)))
+        return [self._tk.split(x) for x in self._tk.splitlist(
+            self._tk.call("trace", "vinfo", self._name))]
     def __eq__(self, other):
         """Comparison for equality (==).
 
@@ -855,7 +855,7 @@
                      includeids and 'includeids' or None))
         if isinstance(data, str):
             data = [self.tk.split(data)]
-        return map(self.__winfo_parseitem, data)
+        return [self.__winfo_parseitem(x) for x in  data]
     def __winfo_parseitem(self, t):
         """Internal function."""
         return t[:1] + tuple(map(self.__winfo_getint, t[1:]))
@@ -1200,8 +1200,8 @@
         self.configure({key: value})
     def keys(self):
         """Return a list of all resource names of this widget."""
-        return map(lambda x: x[0][1:],
-               self.tk.split(self.tk.call(self._w, 'configure')))
+        return [x[0][1:] for x in
+                self.tk.split(self.tk.call(self._w, 'configure'))]
     def __str__(self):
         """Return the window path name of this widget."""
         return self._w
@@ -1223,18 +1223,18 @@
     def pack_slaves(self):
         """Return a list of all slaves of this widget
         in its packing order."""
-        return map(self._nametowidget,
-               self.tk.splitlist(
-                   self.tk.call('pack', 'slaves', self._w)))
+        return [self._nametowidget(x) for x in
+                self.tk.splitlist(
+                   self.tk.call('pack', 'slaves', self._w))]
     slaves = pack_slaves
     # Place method that applies to the master
     def place_slaves(self):
         """Return a list of all slaves of this widget
         in its packing order."""
-        return map(self._nametowidget,
-               self.tk.splitlist(
+        return [self._nametowidget(x) for x in
+                self.tk.splitlist(
                    self.tk.call(
-                       'place', 'slaves', self._w)))
+                       'place', 'slaves', self._w))]
     # Grid methods that apply to the master
     def grid_bbox(self, column=None, row=None, col2=None, row2=None):
         """Return a tuple of integer coordinates for the bounding
@@ -1338,9 +1338,9 @@
             args = args + ('-row', row)
         if column is not None:
             args = args + ('-column', column)
-        return map(self._nametowidget,
-               self.tk.splitlist(self.tk.call(
-                   ('grid', 'slaves', self._w) + args)))
+        return [self._nametowidget(x) for x in
+                self.tk.splitlist(self.tk.call(
+                   ('grid', 'slaves', self._w) + args))]
 
     # Support for the "event" command, new in Tk 4.2.
     # By Case Roole.
@@ -1494,7 +1494,7 @@
         if len(wlist) > 1:
             wlist = (wlist,) # Tk needs a list of windows here
         args = ('wm', 'colormapwindows', self._w) + wlist
-        return map(self._nametowidget, self.tk.call(args))
+        return [self._nametowidget(x) for x in  self.tk.call(args)]
     colormapwindows = wm_colormapwindows
     def wm_command(self, value=None):
         """Store VALUE in WM_COMMAND property. It is the command
@@ -2157,9 +2157,9 @@
     def coords(self, *args):
         """Return a list of coordinates for the item given in ARGS."""
         # XXX Should use _flatten on args
-        return map(getdouble,
+        return [getdouble(x) for x in
                            self.tk.splitlist(
-                   self.tk.call((self._w, 'coords') + args)))
+                   self.tk.call((self._w, 'coords') + args))]
     def _create(self, itemType, args, kw): # Args: (val, val, ..., cnf={})
         """Internal function."""
         args = _flatten(args)

Modified: python/branches/py3k-cdecimal/Lib/tkinter/scrolledtext.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tkinter/scrolledtext.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tkinter/scrolledtext.py	Sun Jan  2 13:18:37 2011
@@ -30,8 +30,8 @@
         # Copy geometry methods of self.frame without overriding Text
         # methods -- hack!
         text_meths = vars(Text).keys()
-        methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys()
-        methods = set(methods).difference(text_meths)
+        methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
+        methods = methods.difference(text_meths)
 
         for m in methods:
             if m[0] != '_' and m != 'config' and m != 'configure':
@@ -42,11 +42,10 @@
 
 
 def example():
-    import __main__
     from tkinter.constants import END
 
     stext = ScrolledText(bg='white', height=10)
-    stext.insert(END, __main__.__doc__)
+    stext.insert(END, __doc__)
     stext.pack(fill=BOTH, side=LEFT, expand=True)
     stext.focus_set()
     stext.mainloop()

Modified: python/branches/py3k-cdecimal/Lib/tkinter/test/test_ttk/test_widgets.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tkinter/test/test_ttk/test_widgets.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tkinter/test/test_ttk/test_widgets.py	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,6 @@
 import unittest
 import tkinter
+import os
 from tkinter import ttk
 from test.support import requires, run_unittest
 
@@ -925,7 +926,8 @@
         self.assertRaises(tkinter.TclError, self.tv.heading, '#0',
             anchor=1)
 
-
+    # XXX skipping for now; should be fixed to work with newer ttk
+    @unittest.skip
     def test_heading_callback(self):
         def simulate_heading_click(x, y):
             support.simulate_mouse_click(self.tv, x, y)

Modified: python/branches/py3k-cdecimal/Lib/tkinter/tix.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/tkinter/tix.py	(original)
+++ python/branches/py3k-cdecimal/Lib/tkinter/tix.py	Sun Jan  2 13:18:37 2011
@@ -268,10 +268,10 @@
         return self.tk.call('tixForm', 'info', self._w, option)
 
     def slaves(self):
-        return map(self._nametowidget,
-                   self.tk.splitlist(
+        return [self._nametowidget(x) for x in
+                self.tk.splitlist(
                        self.tk.call(
-                       'tixForm', 'slaves', self._w)))
+                       'tixForm', 'slaves', self._w))]
 
 
 

Modified: python/branches/py3k-cdecimal/Lib/turtle.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/turtle.py	(original)
+++ python/branches/py3k-cdecimal/Lib/turtle.py	Sun Jan  2 13:18:37 2011
@@ -752,7 +752,7 @@
         [(0.0, 9.9999999999999982), (0.0, -9.9999999999999982),
         (9.9999999999999982, 0.0)]
         >>> """
-        cl = list(self.cv.coords(item))
+        cl = self.cv.coords(item)
         pl = [(cl[i], -cl[i+1]) for i in range(0, len(cl), 2)]
         return  pl
 

Modified: python/branches/py3k-cdecimal/Lib/turtledemo/about_turtledemo.txt
==============================================================================
--- python/branches/py3k-cdecimal/Lib/turtledemo/about_turtledemo.txt	(original)
+++ python/branches/py3k-cdecimal/Lib/turtledemo/about_turtledemo.txt	Sun Jan  2 13:18:37 2011
@@ -1,9 +1,9 @@
 
     --------------------------------------
-        About turtleDemo.py
+        About this viewer
     --------------------------------------
 
-    Tiny demo Viewer to view turtle graphics example scripts.
+    Tiny demo viewer to view turtle graphics example scripts.
 
     Quickly and dirtyly assembled by Gregor Lingl.
     June, 2006

Modified: python/branches/py3k-cdecimal/Lib/turtledemo/demohelp.txt
==============================================================================
--- python/branches/py3k-cdecimal/Lib/turtledemo/demohelp.txt	(original)
+++ python/branches/py3k-cdecimal/Lib/turtledemo/demohelp.txt	Sun Jan  2 13:18:37 2011
@@ -53,12 +53,7 @@
 
    (2) How to add your own demos to the demo repository
 
-   - scriptname: must begin with tdemo_ ,
-     so it must have the form tdemo_<your-script-name>.py
-
-   - place: same directory as turtleDemo.py or some
-     subdirectory, the name of which must also begin with
-     tdemo_.....
+   - place: same directory as turtledemo/__main__.py
 
    - requirements on source code:
        code must contain a main() function which will

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	Sun Jan  2 13:18:37 2011
@@ -6,10 +6,12 @@
 import pprint
 import re
 import warnings
+import collections
 
 from . import result
 from .util import (strclass, safe_repr, sorted_list_difference,
-                   unorderable_list_difference)
+                   unorderable_list_difference, _count_diff_all_purpose,
+                   _count_diff_hashable)
 
 __unittest = True
 
@@ -24,7 +26,6 @@
     Usually you can use TestResult.skip() or one of the skipping decorators
     instead of raising this directly.
     """
-    pass
 
 class _ExpectedFailure(Exception):
     """
@@ -41,7 +42,17 @@
     """
     The test was supposed to fail, but it didn't!
     """
-    pass
+
+
+class _Outcome(object):
+    def __init__(self):
+        self.success = True
+        self.skipped = None
+        self.unexpectedSuccess = None
+        self.expectedFailure = None
+        self.errors = []
+        self.failures = []
+
 
 def _id(obj):
     return obj
@@ -93,7 +104,7 @@
 class _AssertRaisesBaseContext(object):
 
     def __init__(self, expected, test_case, callable_obj=None,
-                  expected_regexp=None):
+                  expected_regex=None):
         self.expected = expected
         self.failureException = test_case.failureException
         if callable_obj is not None:
@@ -103,9 +114,9 @@
                 self.obj_name = str(callable_obj)
         else:
             self.obj_name = None
-        if isinstance(expected_regexp, (bytes, str)):
-            expected_regexp = re.compile(expected_regexp)
-        self.expected_regexp = expected_regexp
+        if isinstance(expected_regex, (bytes, str)):
+            expected_regex = re.compile(expected_regex)
+        self.expected_regex = expected_regex
 
 
 class _AssertRaisesContext(_AssertRaisesBaseContext):
@@ -131,13 +142,13 @@
             return False
         # store exception, without traceback, for later retrieval
         self.exception = exc_value.with_traceback(None)
-        if self.expected_regexp is None:
+        if self.expected_regex is None:
             return True
 
-        expected_regexp = self.expected_regexp
-        if not expected_regexp.search(str(exc_value)):
+        expected_regex = self.expected_regex
+        if not expected_regex.search(str(exc_value)):
             raise self.failureException('"%s" does not match "%s"' %
-                     (expected_regexp.pattern, str(exc_value)))
+                     (expected_regex.pattern, str(exc_value)))
         return True
 
 
@@ -171,8 +182,8 @@
                 continue
             if first_matching is None:
                 first_matching = w
-            if (self.expected_regexp is not None and
-                not self.expected_regexp.search(str(w))):
+            if (self.expected_regex is not None and
+                not self.expected_regex.search(str(w))):
                 continue
             # store warning for later retrieval
             self.warning = w
@@ -182,7 +193,7 @@
         # Now we simply try to choose a helpful failure message
         if first_matching is not None:
             raise self.failureException('"%s" does not match "%s"' %
-                     (self.expected_regexp.pattern, str(first_matching)))
+                     (self.expected_regex.pattern, str(first_matching)))
         if self.obj_name:
             raise self.failureException("{0} not triggered by {1}"
                 .format(exc_name, self.obj_name))
@@ -244,7 +255,7 @@
     # objects used in assert methods) will be printed on failure in *addition*
     # to any explicit message passed.
 
-    longMessage = False
+    longMessage = True
 
     # 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
@@ -262,7 +273,7 @@
            not have a method with the specified name.
         """
         self._testMethodName = methodName
-        self._resultForDoCleanups = None
+        self._outcomeForDoCleanups = None
         try:
             testMethod = getattr(self, methodName)
         except AttributeError:
@@ -366,6 +377,36 @@
                           RuntimeWarning, 2)
             result.addSuccess(self)
 
+    def _executeTestPart(self, function, outcome, isTest=False):
+        try:
+            function()
+        except KeyboardInterrupt:
+            raise
+        except SkipTest as e:
+            outcome.success = False
+            outcome.skipped = str(e)
+        except _UnexpectedSuccess:
+            exc_info = sys.exc_info()
+            outcome.success = False
+            if isTest:
+                outcome.unexpectedSuccess = exc_info
+            else:
+                outcome.errors.append(exc_info)
+        except _ExpectedFailure:
+            outcome.success = False
+            exc_info = sys.exc_info()
+            if isTest:
+                outcome.expectedFailure = exc_info
+            else:
+                outcome.errors.append(exc_info)
+        except self.failureException:
+            outcome.success = False
+            outcome.failures.append(sys.exc_info())
+            exc_info = sys.exc_info()
+        except:
+            outcome.success = False
+            outcome.errors.append(sys.exc_info())
+
     def run(self, result=None):
         orig_result = result
         if result is None:
@@ -374,7 +415,6 @@
             if startTestRun is not None:
                 startTestRun()
 
-        self._resultForDoCleanups = result
         result.startTest(self)
 
         testMethod = getattr(self, self._testMethodName)
@@ -389,51 +429,42 @@
                 result.stopTest(self)
             return
         try:
-            success = False
-            try:
-                self.setUp()
-            except SkipTest as e:
-                self._addSkip(result, str(e))
-            except Exception:
-                result.addError(self, sys.exc_info())
+            outcome = _Outcome()
+            self._outcomeForDoCleanups = outcome
+
+            self._executeTestPart(self.setUp, outcome)
+            if outcome.success:
+                self._executeTestPart(testMethod, outcome, isTest=True)
+                self._executeTestPart(self.tearDown, outcome)
+
+            self.doCleanups()
+            if outcome.success:
+                result.addSuccess(self)
             else:
-                try:
-                    testMethod()
-                except self.failureException:
-                    result.addFailure(self, sys.exc_info())
-                except _ExpectedFailure as e:
-                    addExpectedFailure = getattr(result, 'addExpectedFailure', None)
-                    if addExpectedFailure is not None:
-                        addExpectedFailure(self, e.exc_info)
-                    else:
-                        warnings.warn("TestResult has no addExpectedFailure method, reporting as passes",
-                                      RuntimeWarning)
-                        result.addSuccess(self)
-                except _UnexpectedSuccess:
+                if outcome.skipped is not None:
+                    self._addSkip(result, outcome.skipped)
+                for exc_info in outcome.errors:
+                    result.addError(self, exc_info)
+                for exc_info in outcome.failures:
+                    result.addFailure(self, exc_info)
+                if outcome.unexpectedSuccess is not None:
                     addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
                     if addUnexpectedSuccess is not None:
                         addUnexpectedSuccess(self)
                     else:
                         warnings.warn("TestResult has no addUnexpectedSuccess method, reporting as failures",
                                       RuntimeWarning)
-                        result.addFailure(self, sys.exc_info())
-                except SkipTest as e:
-                    self._addSkip(result, str(e))
-                except Exception:
-                    result.addError(self, sys.exc_info())
-                else:
-                    success = True
+                        result.addFailure(self, outcome.unexpectedSuccess)
+
+                if outcome.expectedFailure is not None:
+                    addExpectedFailure = getattr(result, 'addExpectedFailure', None)
+                    if addExpectedFailure is not None:
+                        addExpectedFailure(self, outcome.expectedFailure)
+                    else:
+                        warnings.warn("TestResult has no addExpectedFailure method, reporting as passes",
+                                      RuntimeWarning)
+                        result.addSuccess(self)
 
-                try:
-                    self.tearDown()
-                except Exception:
-                    result.addError(self, sys.exc_info())
-                    success = False
-
-            cleanUpSuccess = self.doCleanups()
-            success = success and cleanUpSuccess
-            if success:
-                result.addSuccess(self)
         finally:
             result.stopTest(self)
             if orig_result is None:
@@ -444,16 +475,15 @@
     def doCleanups(self):
         """Execute all cleanup functions. Normally called for you after
         tearDown."""
-        result = self._resultForDoCleanups
-        ok = True
+        outcome = self._outcomeForDoCleanups or _Outcome()
         while self._cleanups:
-            function, args, kwargs = self._cleanups.pop(-1)
-            try:
-                function(*args, **kwargs)
-            except Exception:
-                ok = False
-                result.addError(self, sys.exc_info())
-        return ok
+            function, args, kwargs = self._cleanups.pop()
+            part = lambda: function(*args, **kwargs)
+            self._executeTestPart(part, outcome)
+
+        # return this for backwards compatibility
+        # even though we no longer us it internally
+        return outcome.success
 
     def __call__(self, *args, **kwds):
         return self.run(*args, **kwds)
@@ -476,15 +506,15 @@
         raise self.failureException(msg)
 
     def assertFalse(self, expr, msg=None):
-        "Fail the test if the expression is true."
+        """Check that the expression is false."""
         if expr:
-            msg = self._formatMessage(msg, "%s is not False" % safe_repr(expr))
+            msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr))
             raise self.failureException(msg)
 
     def assertTrue(self, expr, msg=None):
-        """Fail the test unless the expression is true."""
+        """Check that the expression is true."""
         if not expr:
-            msg = self._formatMessage(msg, "%s is not True" % safe_repr(expr))
+            msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
             raise self.failureException(msg)
 
     def _formatMessage(self, msg, standardMsg):
@@ -687,34 +717,6 @@
         msg = self._formatMessage(msg, standardMsg)
         raise self.failureException(msg)
 
-    # Synonyms for assertion methods
-
-    # The plurals are undocumented.  Keep them that way to discourage use.
-    # Do not add more.  Do not remove.
-    # Going through a deprecation cycle on these would annoy many people.
-    assertEquals = assertEqual
-    assertNotEquals = assertNotEqual
-    assertAlmostEquals = assertAlmostEqual
-    assertNotAlmostEquals = assertNotAlmostEqual
-    assert_ = assertTrue
-
-    # These fail* assertion method names are pending deprecation and will
-    # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578
-    def _deprecate(original_func):
-        def deprecated_func(*args, **kwargs):
-            warnings.warn(
-                'Please use {0} instead.'.format(original_func.__name__),
-                DeprecationWarning, 2)
-            return original_func(*args, **kwargs)
-        return deprecated_func
-
-    failUnlessEqual = _deprecate(assertEqual)
-    failIfEqual = _deprecate(assertNotEqual)
-    failUnlessAlmostEqual = _deprecate(assertAlmostEqual)
-    failIfAlmostEqual = _deprecate(assertNotAlmostEqual)
-    failUnless = _deprecate(assertTrue)
-    failUnlessRaises = _deprecate(assertRaises)
-    failIf = _deprecate(assertFalse)
 
     def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
         """An equality assertion for ordered sequences (like lists and tuples).
@@ -931,17 +933,19 @@
             standardMsg = self._truncateMessage(standardMsg, diff)
             self.fail(self._formatMessage(msg, standardMsg))
 
-    def assertDictContainsSubset(self, expected, actual, msg=None):
-        """Checks whether actual is a superset of expected."""
+    def assertDictContainsSubset(self, subset, dictionary, msg=None):
+        """Checks whether dictionary is a superset of subset."""
+        warnings.warn('assertDictContainsSubset is deprecated',
+                      DeprecationWarning)
         missing = []
         mismatched = []
-        for key, value in expected.items():
-            if key not in actual:
+        for key, value in subset.items():
+            if key not in dictionary:
                 missing.append(key)
-            elif value != actual[key]:
+            elif value != dictionary[key]:
                 mismatched.append('%s, expected: %s, actual: %s' %
                                   (safe_repr(key), safe_repr(value),
-                                   safe_repr(actual[key])))
+                                   safe_repr(dictionary[key])))
 
         if not (missing or mismatched):
             return
@@ -1000,42 +1004,38 @@
             self.fail(self._formatMessage(msg, standardMsg))
 
 
-    def assertItemsEqual(self, expected_seq, actual_seq, msg=None):
-        """An unordered sequence / set specific comparison. It asserts that
-        expected_seq and actual_seq contain the same elements. It is
-        the equivalent of::
+    def assertCountEqual(self, first, second, msg=None):
+        """An unordered sequence comparison asserting that the same elements,
+        regardless of order.  If the same element occurs more than once,
+        it verifies that the elements occur the same number of times.
 
-            self.assertEqual(sorted(expected_seq), sorted(actual_seq))
+            self.assertEqual(Counter(list(first)),
+                             Counter(list(second)))
 
-        Raises with an error message listing which elements of expected_seq
-        are missing from actual_seq and vice versa if any.
-
-        Asserts that each element has the same count in both sequences.
-        Example:
+         Example:
             - [0, 1, 1] and [1, 0, 1] compare equal.
             - [0, 0, 1] and [0, 1] compare unequal.
+
         """
+        actual_seq, expected_seq = list(first), list(second)
         try:
-            expected = sorted(expected_seq)
-            actual = sorted(actual_seq)
+            actual = collections.Counter(actual_seq)
+            expected = collections.Counter(expected_seq)
         except TypeError:
-            # Unsortable items (example: set(), complex(), ...)
-            expected = list(expected_seq)
-            actual = list(actual_seq)
-            missing, unexpected = unorderable_list_difference(expected, actual)
+            # Handle case with unhashable elements
+            differences = _count_diff_all_purpose(actual_seq, expected_seq)
         else:
-            return self.assertSequenceEqual(expected, actual, msg=msg)
+            if actual == expected:
+                return
+            differences = _count_diff_hashable(actual_seq, expected_seq)
 
-        errors = []
-        if missing:
-            errors.append('Expected, but missing:\n    %s' %
-                           safe_repr(missing))
-        if unexpected:
-            errors.append('Unexpected, but present:\n    %s' %
-                           safe_repr(unexpected))
-        if errors:
-            standardMsg = '\n'.join(errors)
-            self.fail(self._formatMessage(msg, standardMsg))
+        if differences:
+            standardMsg = 'Element counts were not equal:\n'
+            lines = ['First has %d, Second has %d:  %r' % diff for diff in differences]
+            diffMsg = '\n'.join(lines)
+            standardMsg = self._truncateMessage(standardMsg, diffMsg)
+            msg = self._formatMessage(msg, standardMsg)
+            self.fail(msg)
 
     def assertMultiLineEqual(self, first, second, msg=None):
         """Assert that two multi-line strings are equal."""
@@ -1103,27 +1103,27 @@
             standardMsg = '%s is an instance of %r' % (safe_repr(obj), cls)
             self.fail(self._formatMessage(msg, standardMsg))
 
-    def assertRaisesRegexp(self, expected_exception, expected_regexp,
-                           callable_obj=None, *args, **kwargs):
-        """Asserts that the message in a raised exception matches a regexp.
+    def assertRaisesRegex(self, expected_exception, expected_regex,
+                          callable_obj=None, *args, **kwargs):
+        """Asserts that the message in a raised exception matches a regex.
 
         Args:
             expected_exception: Exception class expected to be raised.
-            expected_regexp: Regexp (re pattern object or string) expected
+            expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
             callable_obj: Function to be called.
             args: Extra args.
             kwargs: Extra kwargs.
         """
         context = _AssertRaisesContext(expected_exception, self, callable_obj,
-                                       expected_regexp)
+                                       expected_regex)
         if callable_obj is None:
             return context
         with context:
             callable_obj(*args, **kwargs)
 
-    def assertWarnsRegexp(self, expected_warning, expected_regexp,
-                          callable_obj=None, *args, **kwargs):
+    def assertWarnsRegex(self, expected_warning, expected_regex,
+                         callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
@@ -1131,42 +1131,65 @@
 
         Args:
             expected_warning: Warning class expected to be triggered.
-            expected_regexp: Regexp (re pattern object or string) expected
+            expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
             callable_obj: Function to be called.
             args: Extra args.
             kwargs: Extra kwargs.
         """
         context = _AssertWarnsContext(expected_warning, self, callable_obj,
-                                      expected_regexp)
+                                      expected_regex)
         if callable_obj is None:
             return context
         with context:
             callable_obj(*args, **kwargs)
 
-    def assertRegexpMatches(self, text, expected_regexp, msg=None):
+    def assertRegex(self, text, expected_regex, msg=None):
         """Fail the test unless the text matches the regular expression."""
-        if isinstance(expected_regexp, (str, bytes)):
-            expected_regexp = re.compile(expected_regexp)
-        if not expected_regexp.search(text):
-            msg = msg or "Regexp didn't match"
-            msg = '%s: %r not found in %r' % (msg, expected_regexp.pattern, text)
+        if isinstance(expected_regex, (str, bytes)):
+            assert expected_regex, "expected_regex must not be empty."
+            expected_regex = re.compile(expected_regex)
+        if not expected_regex.search(text):
+            msg = msg or "Regex didn't match"
+            msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
             raise self.failureException(msg)
 
-    def assertNotRegexpMatches(self, text, unexpected_regexp, msg=None):
+    def assertNotRegex(self, text, unexpected_regex, msg=None):
         """Fail the test if the text matches the regular expression."""
-        if isinstance(unexpected_regexp, (str, bytes)):
-            unexpected_regexp = re.compile(unexpected_regexp)
-        match = unexpected_regexp.search(text)
+        if isinstance(unexpected_regex, (str, bytes)):
+            unexpected_regex = re.compile(unexpected_regex)
+        match = unexpected_regex.search(text)
         if match:
-            msg = msg or "Regexp matched"
+            msg = msg or "Regex matched"
             msg = '%s: %r matches %r in %r' % (msg,
                                                text[match.start():match.end()],
-                                               unexpected_regexp.pattern,
+                                               unexpected_regex.pattern,
                                                text)
             raise self.failureException(msg)
 
 
+    def _deprecate(original_func):
+        def deprecated_func(*args, **kwargs):
+            warnings.warn(
+                'Please use {0} instead.'.format(original_func.__name__),
+                DeprecationWarning, 2)
+            return original_func(*args, **kwargs)
+        return deprecated_func
+
+    # The fail* methods can be removed in 3.3, the 5 assert* methods will
+    # have to stay around for a few more versions.  See #9424.
+    failUnlessEqual = assertEquals = _deprecate(assertEqual)
+    failIfEqual = assertNotEquals = _deprecate(assertNotEqual)
+    failUnlessAlmostEqual = assertAlmostEquals = _deprecate(assertAlmostEqual)
+    failIfAlmostEqual = assertNotAlmostEquals = _deprecate(assertNotAlmostEqual)
+    failUnless = assert_ = _deprecate(assertTrue)
+    failUnlessRaises = _deprecate(assertRaises)
+    failIf = _deprecate(assertFalse)
+    assertRaisesRegexp = _deprecate(assertRaisesRegex)
+    assertRegexpMatches = _deprecate(assertRegex)
+
+
+
 class FunctionTestCase(TestCase):
     """A test case that wraps a test function.
 

Modified: python/branches/py3k-cdecimal/Lib/unittest/main.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/main.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/main.py	Sun Jan  2 13:18:37 2011
@@ -58,7 +58,24 @@
                                                in MyTestCase
 """
 
+def _convert_name(name):
+    # on Linux / Mac OS X 'foo.PY' is not importable, but on
+    # Windows it is. Simpler to do a case insensitive match
+    # a better check would be to check that the name is a
+    # valid Python module name.
+    if os.path.isfile(name) and name.lower().endswith('.py'):
+        if os.path.isabs(name):
+            rel_path = os.path.relpath(name, os.getcwd())
+            if os.path.isabs(rel_path) or rel_path.startswith(os.pardir):
+                return name
+            name = rel_path
+        # on Windows both '\' and '/' are used as path
+        # separators. Better to replace both than rely on os.path.sep
+        return name[:-3].replace('\\', '.').replace('/', '.')
+    return name
 
+def _convert_names(names):
+    return [_convert_name(name) for name in names]
 
 class TestProgram(object):
     """A command-line program that runs a set of tests; this is primarily
@@ -67,12 +84,12 @@
     USAGE = USAGE_FROM_MODULE
 
     # defaults for testing
-    failfast = catchbreak = buffer = progName = None
+    failfast = catchbreak = buffer = progName = warnings = None
 
     def __init__(self, module='__main__', defaultTest=None, argv=None,
                     testRunner=None, testLoader=loader.defaultTestLoader,
                     exit=True, verbosity=1, failfast=None, catchbreak=None,
-                    buffer=None):
+                    buffer=None, warnings=None):
         if isinstance(module, str):
             self.module = __import__(module)
             for part in module.split('.')[1:]:
@@ -87,6 +104,18 @@
         self.catchbreak = catchbreak
         self.verbosity = verbosity
         self.buffer = buffer
+        if warnings is None and not sys.warnoptions:
+            # even if DreprecationWarnings are ignored by default
+            # print them anyway unless other warnings settings are
+            # specified by the warnings arg or the -W python flag
+            self.warnings = 'default'
+        else:
+            # here self.warnings is set either to the value passed
+            # to the warnings args or to None.
+            # If the user didn't pass a value self.warnings will
+            # be None. This means that the behavior is unchanged
+            # and depends on the values passed to -W.
+            self.warnings = warnings
         self.defaultTest = defaultTest
         self.testRunner = testRunner
         self.testLoader = testLoader
@@ -118,38 +147,48 @@
         long_opts = ['help', 'verbose', 'quiet', 'failfast', 'catch', 'buffer']
         try:
             options, args = getopt.getopt(argv[1:], 'hHvqfcb', long_opts)
-            for opt, value in options:
-                if opt in ('-h','-H','--help'):
-                    self.usageExit()
-                if opt in ('-q','--quiet'):
-                    self.verbosity = 0
-                if opt in ('-v','--verbose'):
-                    self.verbosity = 2
-                if opt in ('-f','--failfast'):
-                    if self.failfast is None:
-                        self.failfast = True
-                    # Should this raise an exception if -f is not valid?
-                if opt in ('-c','--catch'):
-                    if self.catchbreak is None:
-                        self.catchbreak = True
-                    # Should this raise an exception if -c is not valid?
-                if opt in ('-b','--buffer'):
-                    if self.buffer is None:
-                        self.buffer = True
-                    # Should this raise an exception if -b is not valid?
-            if len(args) == 0 and self.defaultTest is None:
-                # createTests will load tests from self.module
-                self.testNames = None
-            elif len(args) > 0:
-                self.testNames = args
-                if __name__ == '__main__':
-                    # to support python -m unittest ...
-                    self.module = None
-            else:
-                self.testNames = (self.defaultTest,)
-            self.createTests()
         except getopt.error as msg:
             self.usageExit(msg)
+            return
+
+        for opt, value in options:
+            if opt in ('-h','-H','--help'):
+                self.usageExit()
+            if opt in ('-q','--quiet'):
+                self.verbosity = 0
+            if opt in ('-v','--verbose'):
+                self.verbosity = 2
+            if opt in ('-f','--failfast'):
+                if self.failfast is None:
+                    self.failfast = True
+                # Should this raise an exception if -f is not valid?
+            if opt in ('-c','--catch'):
+                if self.catchbreak is None:
+                    self.catchbreak = True
+                # Should this raise an exception if -c is not valid?
+            if opt in ('-b','--buffer'):
+                if self.buffer is None:
+                    self.buffer = True
+                # Should this raise an exception if -b is not valid?
+
+        if len(args) == 0 and self.module is None:
+            # this allows "python -m unittest -v" to still work for
+            # test discovery. This means -c / -b / -v / -f options will
+            # be handled twice, which is harmless but not ideal.
+            self._do_discovery(argv[1:])
+            return
+
+        if len(args) == 0 and self.defaultTest is None:
+            # createTests will load tests from self.module
+            self.testNames = None
+        elif len(args) > 0:
+            self.testNames = _convert_names(args)
+            if __name__ == '__main__':
+                # to support python -m unittest ...
+                self.module = None
+        else:
+            self.testNames = (self.defaultTest,)
+        self.createTests()
 
     def createTests(self):
         if self.testNames is None:
@@ -220,7 +259,8 @@
             try:
                 testRunner = self.testRunner(verbosity=self.verbosity,
                                              failfast=self.failfast,
-                                             buffer=self.buffer)
+                                             buffer=self.buffer,
+                                             warnings=self.warnings)
             except TypeError:
                 # didn't accept the verbosity, buffer or failfast arguments
                 testRunner = self.testRunner()

Modified: python/branches/py3k-cdecimal/Lib/unittest/runner.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/runner.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/runner.py	Sun Jan  2 13:18:37 2011
@@ -2,6 +2,7 @@
 
 import sys
 import time
+import warnings
 
 from . import result
 from .signals import registerResult
@@ -124,13 +125,16 @@
     """
     resultclass = TextTestResult
 
-    def __init__(self, stream=sys.stderr, descriptions=True, verbosity=1,
-                 failfast=False, buffer=False, resultclass=None):
+    def __init__(self, stream=None, descriptions=True, verbosity=1,
+                 failfast=False, buffer=False, resultclass=None, warnings=None):
+        if stream is None:
+            stream = sys.stderr
         self.stream = _WritelnDecorator(stream)
         self.descriptions = descriptions
         self.verbosity = verbosity
         self.failfast = failfast
         self.buffer = buffer
+        self.warnings = warnings
         if resultclass is not None:
             self.resultclass = resultclass
 
@@ -143,17 +147,30 @@
         registerResult(result)
         result.failfast = self.failfast
         result.buffer = self.buffer
-        startTime = time.time()
-        startTestRun = getattr(result, 'startTestRun', None)
-        if startTestRun is not None:
-            startTestRun()
-        try:
-            test(result)
-        finally:
-            stopTestRun = getattr(result, 'stopTestRun', None)
-            if stopTestRun is not None:
-                stopTestRun()
-        stopTime = time.time()
+        with warnings.catch_warnings():
+            if self.warnings:
+                # if self.warnings is set, use it to filter all the warnings
+                warnings.simplefilter(self.warnings)
+                # if the filter is 'default' or 'always', special-case the
+                # warnings from the deprecated unittest methods to show them
+                # no more than once per module, because they can be fairly
+                # noisy.  The -Wd and -Wa flags can be used to bypass this
+                # only when self.warnings is None.
+                if self.warnings in ['default', 'always']:
+                    warnings.filterwarnings('module',
+                            category=DeprecationWarning,
+                            message='Please use assert\w+ instead.')
+            startTime = time.time()
+            startTestRun = getattr(result, 'startTestRun', None)
+            if startTestRun is not None:
+                startTestRun()
+            try:
+                test(result)
+            finally:
+                stopTestRun = getattr(result, 'stopTestRun', None)
+                if stopTestRun is not None:
+                    stopTestRun()
+            stopTime = time.time()
         timeTaken = stopTime - startTime
         result.printErrors()
         if hasattr(result, 'separator2'):

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	Sun Jan  2 13:18:37 2011
@@ -104,6 +104,7 @@
         if topLevel:
             self._tearDownPreviousClass(None, result)
             self._handleModuleTearDown(result)
+            result._testRunEntered = False
         return result
 
     def debug(self):

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_assertions.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_assertions.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_assertions.py	Sun Jan  2 13:18:37 2011
@@ -92,15 +92,15 @@
         else:
             self.fail("assertRaises() didn't let exception pass through")
 
-    def testAssertNotRegexpMatches(self):
-        self.assertNotRegexpMatches('Ala ma kota', r'r+')
+    def testAssertNotRegex(self):
+        self.assertNotRegex('Ala ma kota', r'r+')
         try:
-            self.assertNotRegexpMatches('Ala ma kota', r'k.t', 'Message')
+            self.assertNotRegex('Ala ma kota', r'k.t', 'Message')
         except self.failureException as e:
             self.assertIn("'kot'", e.args[0])
             self.assertIn('Message', e.args[0])
         else:
-            self.fail('assertNotRegexpMatches should have failed.')
+            self.fail('assertNotRegex should have failed.')
 
 
 class TestLongMessage(unittest.TestCase):
@@ -127,7 +127,7 @@
         self.testableFalse = TestableTestFalse('testTest')
 
     def testDefault(self):
-        self.assertFalse(unittest.TestCase.longMessage)
+        self.assertTrue(unittest.TestCase.longMessage)
 
     def test_formatMsg(self):
         self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo")
@@ -153,26 +153,26 @@
                 test = self.testableTrue
             return getattr(test, methodName)
 
-        for i, expected_regexp in enumerate(errors):
+        for i, expected_regex in enumerate(errors):
             testMethod = getMethod(i)
             kwargs = {}
             withMsg = i % 2
             if withMsg:
                 kwargs = {"msg": "oops"}
 
-            with self.assertRaisesRegexp(self.failureException,
-                                         expected_regexp=expected_regexp):
+            with self.assertRaisesRegex(self.failureException,
+                                        expected_regex=expected_regex):
                 testMethod(*args, **kwargs)
 
     def testAssertTrue(self):
         self.assertMessages('assertTrue', (False,),
-                            ["^False is not True$", "^oops$", "^False is not True$",
-                             "^False is not True : oops$"])
+                            ["^False is not true$", "^oops$", "^False is not true$",
+                             "^False is not true : oops$"])
 
     def testAssertFalse(self):
         self.assertMessages('assertFalse', (True,),
-                            ["^True is not False$", "^oops$", "^True is not False$",
-                             "^True is not False : oops$"])
+                            ["^True is not false$", "^oops$", "^True is not false$",
+                             "^True is not false : oops$"])
 
     def testNotEqual(self):
         self.assertMessages('assertNotEqual', (1, 1),
@@ -229,12 +229,6 @@
                              "^Missing: 'key'$",
                              "^Missing: 'key' : oops$"])
 
-    def testAssertItemsEqual(self):
-        self.assertMessages('assertItemsEqual', ([], [None]),
-                            [r"\[None\]$", "^oops$",
-                             r"\[None\]$",
-                             r"\[None\] : oops$"])
-
     def testAssertMultiLineEqual(self):
         self.assertMessages('assertMultiLineEqual', ("", "foo"),
                             [r"\+ foo$", "^oops$",

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_break.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_break.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_break.py	Sun Jan  2 13:18:37 2011
@@ -209,7 +209,8 @@
 
         self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None,
                                                      'verbosity': verbosity,
-                                                     'failfast': failfast})])
+                                                     'failfast': failfast,
+                                                     'warnings': None})])
         self.assertEqual(FakeRunner.runArgs, [test])
         self.assertEqual(p.result, result)
 
@@ -222,7 +223,8 @@
 
         self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None,
                                                      'verbosity': verbosity,
-                                                     'failfast': failfast})])
+                                                     'failfast': failfast,
+                                                     'warnings': None})])
         self.assertEqual(FakeRunner.runArgs, [test])
         self.assertEqual(p.result, result)
 

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_case.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_case.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_case.py	Sun Jan  2 13:18:37 2011
@@ -177,8 +177,8 @@
                 super(Foo, self).test()
                 raise RuntimeError('raised by Foo.test')
 
-        expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
-                    'stopTest']
+        expected = ['startTest', 'setUp', 'test', 'tearDown',
+                    'addError', 'stopTest']
         Foo(events).run(result)
         self.assertEqual(events, expected)
 
@@ -195,8 +195,8 @@
                 super(Foo, self).test()
                 raise RuntimeError('raised by Foo.test')
 
-        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addError',
-                    'tearDown', 'stopTest', 'stopTestRun']
+        expected = ['startTestRun', 'startTest', 'setUp', 'test',
+                    'tearDown', 'addError', 'stopTest', 'stopTestRun']
         Foo(events).run()
         self.assertEqual(events, expected)
 
@@ -216,8 +216,8 @@
                 super(Foo, self).test()
                 self.fail('raised by Foo.test')
 
-        expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
-                    'stopTest']
+        expected = ['startTest', 'setUp', 'test', 'tearDown',
+                    'addFailure', 'stopTest']
         Foo(events).run(result)
         self.assertEqual(events, expected)
 
@@ -231,8 +231,8 @@
                 super(Foo, self).test()
                 self.fail('raised by Foo.test')
 
-        expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addFailure',
-                    'tearDown', 'stopTest', 'stopTestRun']
+        expected = ['startTestRun', 'startTest', 'setUp', 'test',
+                    'tearDown', 'addFailure', 'stopTest', 'stopTestRun']
         events = []
         Foo(events).run()
         self.assertEqual(events, expected)
@@ -672,46 +672,68 @@
         else:
             self.fail('assertMultiLineEqual did not fail')
 
-    def testAssertItemsEqual(self):
+    def testAssertCountEqual(self):
         a = object()
-        self.assertItemsEqual([1, 2, 3], [3, 2, 1])
-        self.assertItemsEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
-        self.assertItemsEqual([a, a, 2, 2, 3], (a, 2, 3, a, 2))
-        self.assertItemsEqual([1, "2", "a", "a"], ["a", "2", True, "a"])
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertCountEqual([1, 2, 3], [3, 2, 1])
+        self.assertCountEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
+        self.assertCountEqual([a, a, 2, 2, 3], (a, 2, 3, a, 2))
+        self.assertCountEqual([1, "2", "a", "a"], ["a", "2", True, "a"])
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [1, 2] + [3] * 100, [1] * 100 + [2, 3])
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [1, "2", "a", "a"], ["a", "2", True, 1])
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [10], [10, 11])
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [10, 11], [10])
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [10, 11, 10], [10, 11])
 
         # Test that sequences of unhashable objects can be tested for sameness:
-        self.assertItemsEqual([[1, 2], [3, 4], 0], [False, [3, 4], [1, 2]])
+        self.assertCountEqual([[1, 2], [3, 4], 0], [False, [3, 4], [1, 2]])
+        # Test that iterator of unhashable objects can be tested for sameness:
+        self.assertCountEqual(iter([1, 2, [], 3, 4]),
+                              iter([1, 2, [], 3, 4]))
 
         # hashable types, but not orderable
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [], [divmod, 'x', 1, 5j, 2j, frozenset()])
         # comparing dicts
-        self.assertItemsEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
+        self.assertCountEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
         # comparing heterogenous non-hashable sequences
-        self.assertItemsEqual([1, 'x', divmod, []], [divmod, [], 'x', 1])
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertCountEqual([1, 'x', divmod, []], [divmod, [], 'x', 1])
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [], [divmod, [], 'x', 1, 5j, 2j, set()])
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [[1]], [[2]])
 
         # Same elements, but not same sequence length
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [1, 1, 2], [2, 1])
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [1, 1, "2", "a", "a"], ["2", "2", True, "a"])
-        self.assertRaises(self.failureException, self.assertItemsEqual,
+        self.assertRaises(self.failureException, self.assertCountEqual,
                           [1, {'b': 2}, None, True], [{'b': 2}, True, None])
 
+        # Same elements which don't reliably compare, in
+        # different order, see issue 10242
+        a = [{2,4}, {1,2}]
+        b = a[::-1]
+        self.assertCountEqual(a, b)
+
+        # test utility functions supporting assertCountEqual()
+
+        diffs = set(unittest.util._count_diff_all_purpose('aaabccd', 'abbbcce'))
+        expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}
+        self.assertEqual(diffs, expected)
+
+        diffs = unittest.util._count_diff_all_purpose([[]], [])
+        self.assertEqual(diffs, [(1, 0, [])])
+
+        diffs = set(unittest.util._count_diff_hashable('aaabccd', 'abbbcce'))
+        expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}
+        self.assertEqual(diffs, expected)
+
     def testAssertSetEqual(self):
         set1 = set()
         set2 = set()
@@ -865,44 +887,44 @@
         self.assertIsNotNone('DjZoPloGears on Rails')
         self.assertRaises(self.failureException, self.assertIsNotNone, None)
 
-    def testAssertRegexpMatches(self):
-        self.assertRegexpMatches('asdfabasdf', r'ab+')
-        self.assertRaises(self.failureException, self.assertRegexpMatches,
+    def testAssertRegex(self):
+        self.assertRegex('asdfabasdf', r'ab+')
+        self.assertRaises(self.failureException, self.assertRegex,
                           'saaas', r'aaaa')
 
-    def testAssertRaisesRegexp(self):
+    def testAssertRaisesRegex(self):
         class ExceptionMock(Exception):
             pass
 
         def Stub():
             raise ExceptionMock('We expect')
 
-        self.assertRaisesRegexp(ExceptionMock, re.compile('expect$'), Stub)
-        self.assertRaisesRegexp(ExceptionMock, 'expect$', Stub)
+        self.assertRaisesRegex(ExceptionMock, re.compile('expect$'), Stub)
+        self.assertRaisesRegex(ExceptionMock, 'expect$', Stub)
 
-    def testAssertNotRaisesRegexp(self):
-        self.assertRaisesRegexp(
+    def testAssertNotRaisesRegex(self):
+        self.assertRaisesRegex(
                 self.failureException, '^Exception not raised by <lambda>$',
-                self.assertRaisesRegexp, Exception, re.compile('x'),
+                self.assertRaisesRegex, Exception, re.compile('x'),
                 lambda: None)
-        self.assertRaisesRegexp(
+        self.assertRaisesRegex(
                 self.failureException, '^Exception not raised by <lambda>$',
-                self.assertRaisesRegexp, Exception, 'x',
+                self.assertRaisesRegex, Exception, 'x',
                 lambda: None)
 
-    def testAssertRaisesRegexpMismatch(self):
+    def testAssertRaisesRegexMismatch(self):
         def Stub():
             raise Exception('Unexpected')
 
-        self.assertRaisesRegexp(
+        self.assertRaisesRegex(
                 self.failureException,
                 r'"\^Expected\$" does not match "Unexpected"',
-                self.assertRaisesRegexp, Exception, '^Expected$',
+                self.assertRaisesRegex, Exception, '^Expected$',
                 Stub)
-        self.assertRaisesRegexp(
+        self.assertRaisesRegex(
                 self.failureException,
                 r'"\^Expected\$" does not match "Unexpected"',
-                self.assertRaisesRegexp, Exception,
+                self.assertRaisesRegex, Exception,
                 re.compile('^Expected$'), Stub)
 
     def testAssertRaisesExcValue(self):
@@ -986,26 +1008,26 @@
                 with self.assertWarns(DeprecationWarning):
                     _runtime_warn()
 
-    def testAssertWarnsRegexpCallable(self):
+    def testAssertWarnsRegexCallable(self):
         def _runtime_warn(msg):
             warnings.warn(msg, RuntimeWarning)
-        self.assertWarnsRegexp(RuntimeWarning, "o+",
-                               _runtime_warn, "foox")
+        self.assertWarnsRegex(RuntimeWarning, "o+",
+                              _runtime_warn, "foox")
         # Failure when no warning is triggered
         with self.assertRaises(self.failureException):
-            self.assertWarnsRegexp(RuntimeWarning, "o+",
-                                   lambda: 0)
+            self.assertWarnsRegex(RuntimeWarning, "o+",
+                                  lambda: 0)
         # Failure when another warning is triggered
         with warnings.catch_warnings():
             # Force default filter (in case tests are run with -We)
             warnings.simplefilter("default", RuntimeWarning)
             with self.assertRaises(self.failureException):
-                self.assertWarnsRegexp(DeprecationWarning, "o+",
-                                       _runtime_warn, "foox")
+                self.assertWarnsRegex(DeprecationWarning, "o+",
+                                      _runtime_warn, "foox")
         # Failure when message doesn't match
         with self.assertRaises(self.failureException):
-            self.assertWarnsRegexp(RuntimeWarning, "o+",
-                                   _runtime_warn, "barz")
+            self.assertWarnsRegex(RuntimeWarning, "o+",
+                                  _runtime_warn, "barz")
         # A little trickier: we ask RuntimeWarnings to be raised, and then
         # check for some of them.  It is implementation-defined whether
         # non-matching RuntimeWarnings are simply re-raised, or produce a
@@ -1013,15 +1035,15 @@
         with warnings.catch_warnings():
             warnings.simplefilter("error", RuntimeWarning)
             with self.assertRaises((RuntimeWarning, self.failureException)):
-                self.assertWarnsRegexp(RuntimeWarning, "o+",
-                                       _runtime_warn, "barz")
+                self.assertWarnsRegex(RuntimeWarning, "o+",
+                                      _runtime_warn, "barz")
 
-    def testAssertWarnsRegexpContext(self):
-        # Same as above, but with assertWarnsRegexp as a context manager
+    def testAssertWarnsRegexContext(self):
+        # Same as above, but with assertWarnsRegex as a context manager
         def _runtime_warn(msg):
             warnings.warn(msg, RuntimeWarning)
         _runtime_warn_lineno = inspect.getsourcelines(_runtime_warn)[1]
-        with self.assertWarnsRegexp(RuntimeWarning, "o+") as cm:
+        with self.assertWarnsRegex(RuntimeWarning, "o+") as cm:
             _runtime_warn("foox")
         self.assertIsInstance(cm.warning, RuntimeWarning)
         self.assertEqual(cm.warning.args[0], "foox")
@@ -1029,18 +1051,18 @@
         self.assertEqual(cm.lineno, _runtime_warn_lineno + 1)
         # Failure when no warning is triggered
         with self.assertRaises(self.failureException):
-            with self.assertWarnsRegexp(RuntimeWarning, "o+"):
+            with self.assertWarnsRegex(RuntimeWarning, "o+"):
                 pass
         # Failure when another warning is triggered
         with warnings.catch_warnings():
             # Force default filter (in case tests are run with -We)
             warnings.simplefilter("default", RuntimeWarning)
             with self.assertRaises(self.failureException):
-                with self.assertWarnsRegexp(DeprecationWarning, "o+"):
+                with self.assertWarnsRegex(DeprecationWarning, "o+"):
                     _runtime_warn("foox")
         # Failure when message doesn't match
         with self.assertRaises(self.failureException):
-            with self.assertWarnsRegexp(RuntimeWarning, "o+"):
+            with self.assertWarnsRegex(RuntimeWarning, "o+"):
                 _runtime_warn("barz")
         # A little trickier: we ask RuntimeWarnings to be raised, and then
         # check for some of them.  It is implementation-defined whether
@@ -1049,42 +1071,49 @@
         with warnings.catch_warnings():
             warnings.simplefilter("error", RuntimeWarning)
             with self.assertRaises((RuntimeWarning, self.failureException)):
-                with self.assertWarnsRegexp(RuntimeWarning, "o+"):
+                with self.assertWarnsRegex(RuntimeWarning, "o+"):
                     _runtime_warn("barz")
 
-    def testSynonymAssertMethodNames(self):
-        """Test undocumented method name synonyms.
+    def testDeprecatedMethodNames(self):
+        """Test that the deprecated methods raise a DeprecationWarning.
 
-        Please do not use these methods names in your own code.
-
-        This test confirms their continued existence and functionality
-        in order to avoid breaking existing code.
-        """
-        self.assertNotEquals(3, 5)
-        self.assertEquals(3, 3)
-        self.assertAlmostEquals(2.0, 2.0)
-        self.assertNotAlmostEquals(3.0, 5.0)
-        self.assert_(True)
-
-    def testPendingDeprecationMethodNames(self):
-        """Test fail* methods pending deprecation, they will warn in 3.2.
-
-        Do not use these methods.  They will go away in 3.3.
+        The fail* methods will be removed in 3.3. The assert* methods will
+        have to stay around for a few more versions.  See #9424.
         """
         old = (
             (self.failIfEqual, (3, 5)),
+            (self.assertNotEquals, (3, 5)),
             (self.failUnlessEqual, (3, 3)),
+            (self.assertEquals, (3, 3)),
             (self.failUnlessAlmostEqual, (2.0, 2.0)),
+            (self.assertAlmostEquals, (2.0, 2.0)),
             (self.failIfAlmostEqual, (3.0, 5.0)),
+            (self.assertNotAlmostEquals, (3.0, 5.0)),
             (self.failUnless, (True,)),
+            (self.assert_, (True,)),
             (self.failUnlessRaises, (TypeError, lambda _: 3.14 + 'spam')),
             (self.failIf, (False,)),
-            (self.assertSameElements, ([1, 1, 2, 3], [1, 2, 3]))
+            (self.assertSameElements, ([1, 1, 2, 3], [1, 2, 3])),
+            (self.assertDictContainsSubset, (dict(a=1, b=2), dict(a=1, b=2, c=3))),
+            (self.assertRaisesRegexp, (KeyError, 'foo', lambda: {}['foo'])),
+            (self.assertRegexpMatches, ('bar', 'bar')),
         )
         for meth, args in old:
-            with support.check_warnings(('', DeprecationWarning)) as w:
+            with self.assertWarns(DeprecationWarning):
                 meth(*args)
-            self.assertEqual(len(w.warnings), 1)
+
+    def testDeprecatedFailMethods(self):
+        """Test that the deprecated fail* methods get removed in 3.3"""
+        if sys.version_info[:2] < (3, 3):
+            return
+        deprecated_names = [
+            'failIfEqual', 'failUnlessEqual', 'failUnlessAlmostEqual',
+            'failIfAlmostEqual', 'failUnless', 'failUnlessRaises', 'failIf',
+            'assertSameElements', 'assertDictContainsSubset',
+        ]
+        for deprecated_name in deprecated_names:
+            with self.assertRaises(AttributeError):
+                getattr(self, deprecated_name)  # remove these in 3.3
 
     def testDeepcopy(self):
         # Issue: 5660
@@ -1113,3 +1142,82 @@
             # exercise the TestCase instance in a way that will invoke
             # the type equality lookup mechanism
             unpickled_test.assertEqual(set(), set())
+
+    def testKeyboardInterrupt(self):
+        def _raise(self=None):
+            raise KeyboardInterrupt
+        def nothing(self):
+            pass
+
+        class Test1(unittest.TestCase):
+            test_something = _raise
+
+        class Test2(unittest.TestCase):
+            setUp = _raise
+            test_something = nothing
+
+        class Test3(unittest.TestCase):
+            test_something = nothing
+            tearDown = _raise
+
+        class Test4(unittest.TestCase):
+            def test_something(self):
+                self.addCleanup(_raise)
+
+        for klass in (Test1, Test2, Test3, Test4):
+            with self.assertRaises(KeyboardInterrupt):
+                klass('test_something').run()
+
+    def testSkippingEverywhere(self):
+        def _skip(self=None):
+            raise unittest.SkipTest('some reason')
+        def nothing(self):
+            pass
+
+        class Test1(unittest.TestCase):
+            test_something = _skip
+
+        class Test2(unittest.TestCase):
+            setUp = _skip
+            test_something = nothing
+
+        class Test3(unittest.TestCase):
+            test_something = nothing
+            tearDown = _skip
+
+        class Test4(unittest.TestCase):
+            def test_something(self):
+                self.addCleanup(_skip)
+
+        for klass in (Test1, Test2, Test3, Test4):
+            result = unittest.TestResult()
+            klass('test_something').run(result)
+            self.assertEqual(len(result.skipped), 1)
+            self.assertEqual(result.testsRun, 1)
+
+    def testSystemExit(self):
+        def _raise(self=None):
+            raise SystemExit
+        def nothing(self):
+            pass
+
+        class Test1(unittest.TestCase):
+            test_something = _raise
+
+        class Test2(unittest.TestCase):
+            setUp = _raise
+            test_something = nothing
+
+        class Test3(unittest.TestCase):
+            test_something = nothing
+            tearDown = _raise
+
+        class Test4(unittest.TestCase):
+            def test_something(self):
+                self.addCleanup(_raise)
+
+        for klass in (Test1, Test2, Test3, Test4):
+            result = unittest.TestResult()
+            klass('test_something').run(result)
+            self.assertEqual(len(result.errors), 1)
+            self.assertEqual(result.testsRun, 1)

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_discovery.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_discovery.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_discovery.py	Sun Jan  2 13:18:37 2011
@@ -231,6 +231,19 @@
         program.parseArgs(['something'])
         self.assertTrue(self.called)
 
+    def test_command_line_handling_discover_by_default_with_options(self):
+        program = TestableTestProgram()
+        program.module = None
+
+        args = ['something', '-v', '-b', '-v', '-c', '-f']
+        self.called = False
+        def do_discovery(argv):
+            self.called = True
+            self.assertEqual(argv, args[1:])
+        program._do_discovery = do_discovery
+        program.parseArgs(args)
+        self.assertTrue(self.called)
+
 
     def test_command_line_handling_do_discovery_too_many_arguments(self):
         class Stop(Exception):
@@ -354,7 +367,7 @@
         expected_dir = os.path.abspath('foo')
         msg = re.escape(r"'foo' module incorrectly imported from %r. Expected %r. "
                 "Is this module globally installed?" % (mod_dir, expected_dir))
-        self.assertRaisesRegexp(
+        self.assertRaisesRegex(
             ImportError, '^%s$' % msg, loader.discover,
             start_dir='foo', pattern='foo.py'
         )

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_functiontestcase.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_functiontestcase.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_functiontestcase.py	Sun Jan  2 13:18:37 2011
@@ -58,8 +58,8 @@
         def tearDown():
             events.append('tearDown')
 
-        expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
-                    'stopTest']
+        expected = ['startTest', 'setUp', 'test', 'tearDown',
+                    'addError', 'stopTest']
         unittest.FunctionTestCase(test, setUp, tearDown).run(result)
         self.assertEqual(events, expected)
 
@@ -84,8 +84,8 @@
         def tearDown():
             events.append('tearDown')
 
-        expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
-                    'stopTest']
+        expected = ['startTest', 'setUp', 'test', 'tearDown',
+                    'addFailure', 'stopTest']
         unittest.FunctionTestCase(test, setUp, tearDown).run(result)
         self.assertEqual(events, expected)
 

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_loader.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_loader.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_loader.py	Sun Jan  2 13:18:37 2011
@@ -186,7 +186,7 @@
         self.assertEqual(suite.countTestCases(), 1)
         test = list(suite)[0]
 
-        self.assertRaisesRegexp(TypeError, "some failure", test.m)
+        self.assertRaisesRegex(TypeError, "some failure", test.m)
 
     ################################################################
     ### /Tests for TestLoader.loadTestsFromModule()

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_program.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_program.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_program.py	Sun Jan  2 13:18:37 2011
@@ -99,6 +99,7 @@
     defaultTest = None
     testRunner = None
     testLoader = unittest.defaultTestLoader
+    module = '__main__'
     progName = 'test'
     test = 'test'
     def __init__(self, *args):
@@ -182,6 +183,27 @@
                 program.parseArgs([None, opt])
                 self.assertEqual(getattr(program, attr), not_none)
 
+    def testWarning(self):
+        """Test the warnings argument"""
+        # see #10535
+        class FakeTP(unittest.TestProgram):
+            def parseArgs(self, *args, **kw): pass
+            def runTests(self, *args, **kw): pass
+        warnoptions = sys.warnoptions
+        try:
+            sys.warnoptions[:] = []
+            # no warn options, no arg -> default
+            self.assertEqual(FakeTP().warnings, 'default')
+            # no warn options, w/ arg -> arg value
+            self.assertEqual(FakeTP(warnings='ignore').warnings, 'ignore')
+            sys.warnoptions[:] = ['somevalue']
+            # warn options, no arg -> None
+            # warn options, w/ arg -> arg value
+            self.assertEqual(FakeTP().warnings, None)
+            self.assertEqual(FakeTP(warnings='ignore').warnings, 'ignore')
+        finally:
+            sys.warnoptions[:] = warnoptions
+
     def testRunTestsRunnerClass(self):
         program = self.program
 
@@ -189,12 +211,14 @@
         program.verbosity = 'verbosity'
         program.failfast = 'failfast'
         program.buffer = 'buffer'
+        program.warnings = 'warnings'
 
         program.runTests()
 
         self.assertEqual(FakeRunner.initArgs, {'verbosity': 'verbosity',
                                                 'failfast': 'failfast',
-                                                'buffer': 'buffer'})
+                                                'buffer': 'buffer',
+                                                'warnings': 'warnings'})
         self.assertEqual(FakeRunner.test, 'test')
         self.assertIs(program.result, RESULT)
 
@@ -250,6 +274,85 @@
         program.runTests()
         self.assertTrue(self.installed)
 
+    def _patch_isfile(self, names, exists=True):
+        def isfile(path):
+            return path in names
+        original = os.path.isfile
+        os.path.isfile = isfile
+        def restore():
+            os.path.isfile = original
+        self.addCleanup(restore)
+
+
+    def testParseArgsFileNames(self):
+        # running tests with filenames instead of module names
+        program = self.program
+        argv = ['progname', 'foo.py', 'bar.Py', 'baz.PY', 'wing.txt']
+        self._patch_isfile(argv)
+
+        program.createTests = lambda: None
+        program.parseArgs(argv)
+
+        # note that 'wing.txt' is not a Python file so the name should
+        # *not* be converted to a module name
+        expected = ['foo', 'bar', 'baz', 'wing.txt']
+        self.assertEqual(program.testNames, expected)
+
+
+    def testParseArgsFilePaths(self):
+        program = self.program
+        argv = ['progname', 'foo/bar/baz.py', 'green\\red.py']
+        self._patch_isfile(argv)
+
+        program.createTests = lambda: None
+        program.parseArgs(argv)
+
+        expected = ['foo.bar.baz', 'green.red']
+        self.assertEqual(program.testNames, expected)
+
+
+    def testParseArgsNonExistentFiles(self):
+        program = self.program
+        argv = ['progname', 'foo/bar/baz.py', 'green\\red.py']
+        self._patch_isfile([])
+
+        program.createTests = lambda: None
+        program.parseArgs(argv)
+
+        self.assertEqual(program.testNames, argv[1:])
+
+    def testParseArgsAbsolutePathsThatCanBeConverted(self):
+        cur_dir = os.getcwd()
+        program = self.program
+        def _join(name):
+            return os.path.join(cur_dir, name)
+        argv = ['progname', _join('foo/bar/baz.py'), _join('green\\red.py')]
+        self._patch_isfile(argv)
+
+        program.createTests = lambda: None
+        program.parseArgs(argv)
+
+        expected = ['foo.bar.baz', 'green.red']
+        self.assertEqual(program.testNames, expected)
+
+    def testParseArgsAbsolutePathsThatCannotBeConverted(self):
+        program = self.program
+        # even on Windows '/...' is considered absolute by os.path.abspath
+        argv = ['progname', '/foo/bar/baz.py', '/green/red.py']
+        self._patch_isfile(argv)
+
+        program.createTests = lambda: None
+        program.parseArgs(argv)
+
+        self.assertEqual(program.testNames, argv[1:])
+
+        # it may be better to use platform specific functions to normalise paths
+        # rather than accepting '.PY' and '\' as file seprator on Linux / Mac
+        # it would also be better to check that a filename is a valid module
+        # identifier (we have a regex for this in loader.py)
+        # for invalid filenames should we raise a useful error rather than
+        # leaving the current error message (import of filename fails) in place?
+
 
 if __name__ == '__main__':
     unittest.main()

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	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,8 @@
 import io
+import os
+import sys
 import pickle
+import subprocess
 
 import unittest
 
@@ -31,9 +34,7 @@
                          [(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')),
                           (cleanup2, (), {})])
 
-        result = test.doCleanups()
-        self.assertTrue(result)
-
+        self.assertTrue(test.doCleanups())
         self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))])
 
     def testCleanUpWithErrors(self):
@@ -41,14 +42,12 @@
             def testNothing(self):
                 pass
 
-        class MockResult(object):
+        class MockOutcome(object):
+            success = True
             errors = []
-            def addError(self, test, exc_info):
-                self.errors.append((test, exc_info))
 
-        result = MockResult()
         test = TestableTest('testNothing')
-        test._resultForDoCleanups = result
+        test._outcomeForDoCleanups = MockOutcome
 
         exc1 = Exception('foo')
         exc2 = Exception('bar')
@@ -62,10 +61,11 @@
         test.addCleanup(cleanup2)
 
         self.assertFalse(test.doCleanups())
+        self.assertFalse(MockOutcome.success)
 
-        (test1, (Type1, instance1, _)), (test2, (Type2, instance2, _)) = reversed(MockResult.errors)
-        self.assertEqual((test1, Type1, instance1), (test, Exception, exc1))
-        self.assertEqual((test2, Type2, instance2), (test, Exception, exc2))
+        (Type1, instance1, _), (Type2, instance2, _) = reversed(MockOutcome.errors)
+        self.assertEqual((Type1, instance1), (Exception, exc1))
+        self.assertEqual((Type2, instance2), (Exception, exc2))
 
     def testCleanupInRun(self):
         blowUp = False
@@ -144,6 +144,7 @@
         self.assertFalse(runner.failfast)
         self.assertFalse(runner.buffer)
         self.assertEqual(runner.verbosity, 1)
+        self.assertEqual(runner.warnings, None)
         self.assertTrue(runner.descriptions)
         self.assertEqual(runner.resultclass, unittest.TextTestResult)
 
@@ -244,3 +245,74 @@
 
         expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY)
         self.assertEqual(runner._makeResult(), expectedresult)
+
+    def test_warnings(self):
+        """
+        Check that warnings argument of TextTestRunner correctly affects the
+        behavior of the warnings.
+        """
+        # see #10535 and the _test_warnings file for more information
+
+        def get_parse_out_err(p):
+            return [b.splitlines() for b in p.communicate()]
+        opts = dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+                    cwd=os.path.dirname(__file__))
+        ae_msg = b'Please use assertEqual instead.'
+        at_msg = b'Please use assertTrue instead.'
+
+        # no args -> all the warnings are printed, unittest warnings only once
+        p = subprocess.Popen([sys.executable, '_test_warnings.py'], **opts)
+        out, err = get_parse_out_err(p)
+        self.assertIn(b'OK', err)
+        # check that the total number of warnings in the output is correct
+        self.assertEqual(len(out), 12)
+        # check that the numbers of the different kind of warnings is correct
+        for msg in [b'dw', b'iw', b'uw']:
+            self.assertEqual(out.count(msg), 3)
+        for msg in [ae_msg, at_msg, b'rw']:
+            self.assertEqual(out.count(msg), 1)
+
+        args_list = (
+            # passing 'ignore' as warnings arg -> no warnings
+            [sys.executable, '_test_warnings.py', 'ignore'],
+            # -W doesn't affect the result if the arg is passed
+            [sys.executable, '-Wa', '_test_warnings.py', 'ignore'],
+            # -W affects the result if the arg is not passed
+            [sys.executable, '-Wi', '_test_warnings.py']
+        )
+        # in all these cases no warnings are printed
+        for args in args_list:
+            p = subprocess.Popen(args, **opts)
+            out, err = get_parse_out_err(p)
+            self.assertIn(b'OK', err)
+            self.assertEqual(len(out), 0)
+
+
+        # passing 'always' as warnings arg -> all the warnings printed,
+        #                                     unittest warnings only once
+        p = subprocess.Popen([sys.executable, '_test_warnings.py', 'always'],
+                             **opts)
+        out, err = get_parse_out_err(p)
+        self.assertIn(b'OK', err)
+        self.assertEqual(len(out), 14)
+        for msg in [b'dw', b'iw', b'uw', b'rw']:
+            self.assertEqual(out.count(msg), 3)
+        for msg in [ae_msg, at_msg]:
+            self.assertEqual(out.count(msg), 1)
+
+    def testStdErrLookedUpAtInstantiationTime(self):
+        # see issue 10786
+        old_stderr = sys.stderr
+        f = io.StringIO()
+        sys.stderr = f
+        try:
+            runner = unittest.TextTestRunner()
+            self.assertTrue(runner.stream.stream is f)
+        finally:
+            sys.stderr = old_stderr
+
+    def testSpecifiedStreamUsed(self):
+        # see issue 10786
+        f = io.StringIO()
+        runner = unittest.TextTestRunner(f)
+        self.assertTrue(runner.stream.stream is f)

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	Sun Jan  2 13:18:37 2011
@@ -500,7 +500,7 @@
 
         messages = ('setUpModule', 'tearDownModule', 'setUpClass', 'tearDownClass', 'test_something')
         for phase, msg in enumerate(messages):
-            with self.assertRaisesRegexp(Exception, msg):
+            with self.assertRaisesRegex(Exception, msg):
                 suite.debug()
 
 if __name__ == '__main__':

Modified: python/branches/py3k-cdecimal/Lib/unittest/test/test_suite.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/test/test_suite.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/test/test_suite.py	Sun Jan  2 13:18:37 2011
@@ -353,11 +353,16 @@
                 unittest.TestSuite.__call__(self, *args, **kw)
 
         suite = MySuite()
+        result = unittest.TestResult()
         wrapper = unittest.TestSuite()
         wrapper.addTest(suite)
-        wrapper(unittest.TestResult())
+        wrapper(result)
         self.assertTrue(suite.called)
 
+        # reusing results should be permitted even if abominable
+        self.assertFalse(result._testRunEntered)
+
+
 
 if __name__ == '__main__':
     unittest.main()

Modified: python/branches/py3k-cdecimal/Lib/unittest/util.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/unittest/util.py	(original)
+++ python/branches/py3k-cdecimal/Lib/unittest/util.py	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,7 @@
 """Various utility functions."""
 
+from collections import namedtuple, OrderedDict
+
 __unittest = True
 
 _MAX_LENGTH = 80
@@ -12,7 +14,6 @@
         return result
     return result[:_MAX_LENGTH] + ' [truncated]...'
 
-
 def strclass(cls):
     return "%s.%s" % (cls.__module__, cls.__name__)
 
@@ -77,3 +78,63 @@
 def three_way_cmp(x, y):
     """Return -1 if x < y, 0 if x == y and 1 if x > y"""
     return (x > y) - (x < y)
+
+_Mismatch = namedtuple('Mismatch', 'actual expected value')
+
+def _count_diff_all_purpose(actual, expected):
+    'Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ'
+    # elements need not be hashable
+    s, t = list(actual), list(expected)
+    m, n = len(s), len(t)
+    NULL = object()
+    result = []
+    for i, elem in enumerate(s):
+        if elem is NULL:
+            continue
+        cnt_s = cnt_t = 0
+        for j in range(i, m):
+            if s[j] == elem:
+                cnt_s += 1
+                s[j] = NULL
+        for j, other_elem in enumerate(t):
+            if other_elem == elem:
+                cnt_t += 1
+                t[j] = NULL
+        if cnt_s != cnt_t:
+            diff = _Mismatch(cnt_s, cnt_t, elem)
+            result.append(diff)
+
+    for i, elem in enumerate(t):
+        if elem is NULL:
+            continue
+        cnt_t = 0
+        for j in range(i, n):
+            if t[j] == elem:
+                cnt_t += 1
+                t[j] = NULL
+        diff = _Mismatch(0, cnt_t, elem)
+        result.append(diff)
+    return result
+
+def _ordered_count(iterable):
+    'Return dict of element counts, in the order they were first seen'
+    c = OrderedDict()
+    for elem in iterable:
+        c[elem] = c.get(elem, 0) + 1
+    return c
+
+def _count_diff_hashable(actual, expected):
+    'Returns list of (cnt_act, cnt_exp, elem) triples where the counts differ'
+    # elements must be hashable
+    s, t = _ordered_count(actual), _ordered_count(expected)
+    result = []
+    for elem, cnt_s in s.items():
+        cnt_t = t.get(elem, 0)
+        if cnt_s != cnt_t:
+            diff = _Mismatch(cnt_s, cnt_t, elem)
+            result.append(diff)
+    for elem, cnt_t in t.items():
+        if elem not in s:
+            diff = _Mismatch(0, cnt_t, elem)
+            result.append(diff)
+    return result

Modified: python/branches/py3k-cdecimal/Lib/urllib/parse.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/urllib/parse.py	(original)
+++ python/branches/py3k-cdecimal/Lib/urllib/parse.py	Sun Jan  2 13:18:37 2011
@@ -11,7 +11,7 @@
 RFC 2396:  "Uniform Resource Identifiers (URI)": Generic Syntax by T.
 Berners-Lee, R. Fielding, and L. Masinter, August 1998.
 
-RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zwinski, July 1998.
+RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zawinski, July 1998.
 
 RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June
 1995.
@@ -60,6 +60,7 @@
                 '0123456789'
                 '+-.')
 
+# XXX: Consider replacing with functools.lru_cache
 MAX_CACHE_SIZE = 20
 _parse_cache = {}
 
@@ -69,66 +70,210 @@
     _safe_quoters.clear()
 
 
-class ResultMixin(object):
-    """Shared methods for the parsed result objects."""
+# Helpers for bytes handling
+# For 3.2, we deliberately require applications that
+# handle improperly quoted URLs to do their own
+# decoding and encoding. If valid use cases are
+# presented, we may relax this by using latin-1
+# decoding internally for 3.3
+_implicit_encoding = 'ascii'
+_implicit_errors = 'strict'
+
+def _noop(obj):
+    return obj
+
+def _encode_result(obj, encoding=_implicit_encoding,
+                        errors=_implicit_errors):
+    return obj.encode(encoding, errors)
+
+def _decode_args(args, encoding=_implicit_encoding,
+                       errors=_implicit_errors):
+    return tuple(x.decode(encoding, errors) if x else '' for x in args)
+
+def _coerce_args(*args):
+    # Invokes decode if necessary to create str args
+    # and returns the coerced inputs along with
+    # an appropriate result coercion function
+    #   - noop for str inputs
+    #   - encoding function otherwise
+    str_input = isinstance(args[0], str)
+    for arg in args[1:]:
+        # We special-case the empty string to support the
+        # "scheme=''" default argument to some functions
+        if arg and isinstance(arg, str) != str_input:
+            raise TypeError("Cannot mix str and non-str arguments")
+    if str_input:
+        return args + (_noop,)
+    return _decode_args(args) + (_encode_result,)
+
+# Result objects are more helpful than simple tuples
+class _ResultMixinStr(object):
+    """Standard approach to encoding parsed results from str to bytes"""
+    __slots__ = ()
+
+    def encode(self, encoding='ascii', errors='strict'):
+        return self._encoded_counterpart(*(x.encode(encoding, errors) for x in self))
+
+
+class _ResultMixinBytes(object):
+    """Standard approach to decoding parsed results from bytes to str"""
+    __slots__ = ()
+
+    def decode(self, encoding='ascii', errors='strict'):
+        return self._decoded_counterpart(*(x.decode(encoding, errors) for x in self))
+
+
+class _NetlocResultMixinBase(object):
+    """Shared methods for the parsed result objects containing a netloc element"""
+    __slots__ = ()
 
     @property
     def username(self):
-        netloc = self.netloc
-        if "@" in netloc:
-            userinfo = netloc.rsplit("@", 1)[0]
-            if ":" in userinfo:
-                userinfo = userinfo.split(":", 1)[0]
-            return userinfo
-        return None
+        return self._userinfo[0]
 
     @property
     def password(self):
-        netloc = self.netloc
-        if "@" in netloc:
-            userinfo = netloc.rsplit("@", 1)[0]
-            if ":" in userinfo:
-                return userinfo.split(":", 1)[1]
-        return None
+        return self._userinfo[1]
 
     @property
     def hostname(self):
-        netloc = self.netloc.split('@')[-1]
-        if '[' in netloc and ']' in netloc:
-            return netloc.split(']')[0][1:].lower()
-        elif ':' in netloc:
-            return netloc.split(':')[0].lower()
-        elif netloc == '':
-            return None
-        else:
-            return netloc.lower()
+        hostname = self._hostinfo[0]
+        if not hostname:
+            hostname = None
+        elif hostname is not None:
+            hostname = hostname.lower()
+        return hostname
 
     @property
     def port(self):
-        netloc = self.netloc.split('@')[-1].split(']')[-1]
-        if ':' in netloc:
-            port = netloc.split(':')[1]
-            return int(port, 10)
+        port = self._hostinfo[1]
+        if port is not None:
+            port = int(port, 10)
+        return port
+
+
+class _NetlocResultMixinStr(_NetlocResultMixinBase, _ResultMixinStr):
+    __slots__ = ()
+
+    @property
+    def _userinfo(self):
+        netloc = self.netloc
+        userinfo, have_info, hostinfo = netloc.rpartition('@')
+        if have_info:
+            username, have_password, password = userinfo.partition(':')
+            if not have_password:
+                password = None
         else:
-            return None
+            username = password = None
+        return username, password
+
+    @property
+    def _hostinfo(self):
+        netloc = self.netloc
+        _, _, hostinfo = netloc.rpartition('@')
+        _, have_open_br, bracketed = hostinfo.partition('[')
+        if have_open_br:
+            hostname, _, port = bracketed.partition(']')
+            _, have_port, port = port.partition(':')
+        else:
+            hostname, have_port, port = hostinfo.partition(':')
+        if not have_port:
+            port = None
+        return hostname, port
+
+
+class _NetlocResultMixinBytes(_NetlocResultMixinBase, _ResultMixinBytes):
+    __slots__ = ()
+
+    @property
+    def _userinfo(self):
+        netloc = self.netloc
+        userinfo, have_info, hostinfo = netloc.rpartition(b'@')
+        if have_info:
+            username, have_password, password = userinfo.partition(b':')
+            if not have_password:
+                password = None
+        else:
+            username = password = None
+        return username, password
+
+    @property
+    def _hostinfo(self):
+        netloc = self.netloc
+        _, _, hostinfo = netloc.rpartition(b'@')
+        _, have_open_br, bracketed = hostinfo.partition(b'[')
+        if have_open_br:
+            hostname, _, port = bracketed.partition(b']')
+            _, have_port, port = port.partition(b':')
+        else:
+            hostname, have_port, port = hostinfo.partition(b':')
+        if not have_port:
+            port = None
+        return hostname, port
+
 
 from collections import namedtuple
 
-class SplitResult(namedtuple('SplitResult', 'scheme netloc path query fragment'), ResultMixin):
+_DefragResultBase = namedtuple('DefragResult', 'url fragment')
+_SplitResultBase = namedtuple('SplitResult', 'scheme netloc path query fragment')
+_ParseResultBase = namedtuple('ParseResult', 'scheme netloc path params query fragment')
+
+# For backwards compatibility, alias _NetlocResultMixinStr
+# ResultBase is no longer part of the documented API, but it is
+# retained since deprecating it isn't worth the hassle
+ResultBase = _NetlocResultMixinStr
 
+# Structured result objects for string data
+class DefragResult(_DefragResultBase, _ResultMixinStr):
     __slots__ = ()
+    def geturl(self):
+        if self.fragment:
+            return self.url + '#' + self.fragment
+        else:
+            return self.url
 
+class SplitResult(_SplitResultBase, _NetlocResultMixinStr):
+    __slots__ = ()
     def geturl(self):
         return urlunsplit(self)
 
+class ParseResult(_ParseResultBase, _NetlocResultMixinStr):
+    __slots__ = ()
+    def geturl(self):
+        return urlunparse(self)
 
-class ParseResult(namedtuple('ParseResult', 'scheme netloc path params query fragment'), ResultMixin):
+# Structured result objects for bytes data
+class DefragResultBytes(_DefragResultBase, _ResultMixinBytes):
+    __slots__ = ()
+    def geturl(self):
+        if self.fragment:
+            return self.url + b'#' + self.fragment
+        else:
+            return self.url
 
+class SplitResultBytes(_SplitResultBase, _NetlocResultMixinBytes):
     __slots__ = ()
+    def geturl(self):
+        return urlunsplit(self)
 
+class ParseResultBytes(_ParseResultBase, _NetlocResultMixinBytes):
+    __slots__ = ()
     def geturl(self):
         return urlunparse(self)
 
+# Set up the encode/decode result pairs
+def _fix_result_transcoding():
+    _result_pairs = (
+        (DefragResult, DefragResultBytes),
+        (SplitResult, SplitResultBytes),
+        (ParseResult, ParseResultBytes),
+    )
+    for _decoded, _encoded in _result_pairs:
+        _decoded._encoded_counterpart = _encoded
+        _encoded._decoded_counterpart = _decoded
+
+_fix_result_transcoding()
+del _fix_result_transcoding
 
 def urlparse(url, scheme='', allow_fragments=True):
     """Parse a URL into 6 components:
@@ -136,13 +281,15 @@
     Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
     Note that we don't break the components up in smaller bits
     (e.g. netloc is a single string) and we don't expand % escapes."""
+    url, scheme, _coerce_result = _coerce_args(url, scheme)
     tuple = urlsplit(url, scheme, allow_fragments)
     scheme, netloc, url, query, fragment = tuple
     if scheme in uses_params and ';' in url:
         url, params = _splitparams(url)
     else:
         params = ''
-    return ParseResult(scheme, netloc, url, params, query, fragment)
+    result = ParseResult(scheme, netloc, url, params, query, fragment)
+    return _coerce_result(result)
 
 def _splitparams(url):
     if '/'  in url:
@@ -167,11 +314,12 @@
     Return a 5-tuple: (scheme, netloc, path, query, fragment).
     Note that we don't break the components up in smaller bits
     (e.g. netloc is a single string) and we don't expand % escapes."""
+    url, scheme, _coerce_result = _coerce_args(url, scheme)
     allow_fragments = bool(allow_fragments)
     key = url, scheme, allow_fragments, type(url), type(scheme)
     cached = _parse_cache.get(key, None)
     if cached:
-        return cached
+        return _coerce_result(cached)
     if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth
         clear_cache()
     netloc = query = fragment = ''
@@ -191,7 +339,7 @@
                 url, query = url.split('?', 1)
             v = SplitResult(scheme, netloc, url, query, fragment)
             _parse_cache[key] = v
-            return v
+            return _coerce_result(v)
         if url.endswith(':') or not url[i+1].isdigit():
             for c in url[:i]:
                 if c not in scheme_chars:
@@ -209,17 +357,18 @@
         url, query = url.split('?', 1)
     v = SplitResult(scheme, netloc, url, query, fragment)
     _parse_cache[key] = v
-    return v
+    return _coerce_result(v)
 
 def urlunparse(components):
     """Put a parsed URL back together again.  This may result in a
     slightly different, but equivalent URL, if the URL that was parsed
     originally had redundant delimiters, e.g. a ? with an empty query
     (the draft states that these are equivalent)."""
-    scheme, netloc, url, params, query, fragment = components
+    scheme, netloc, url, params, query, fragment, _coerce_result = (
+                                                  _coerce_args(*components))
     if params:
         url = "%s;%s" % (url, params)
-    return urlunsplit((scheme, netloc, url, query, fragment))
+    return _coerce_result(urlunsplit((scheme, netloc, url, query, fragment)))
 
 def urlunsplit(components):
     """Combine the elements of a tuple as returned by urlsplit() into a
@@ -227,7 +376,8 @@
     This may result in a slightly different, but equivalent URL, if the URL that
     was parsed originally had unnecessary delimiters (for example, a ? with an
     empty query; the RFC states that these are equivalent)."""
-    scheme, netloc, url, query, fragment = components
+    scheme, netloc, url, query, fragment, _coerce_result = (
+                                          _coerce_args(*components))
     if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'):
         if url and url[:1] != '/': url = '/' + url
         url = '//' + (netloc or '') + url
@@ -237,7 +387,7 @@
         url = url + '?' + query
     if fragment:
         url = url + '#' + fragment
-    return url
+    return _coerce_result(url)
 
 def urljoin(base, url, allow_fragments=True):
     """Join a base URL and a possibly relative URL to form an absolute
@@ -246,32 +396,28 @@
         return url
     if not url:
         return base
+    base, url, _coerce_result = _coerce_args(base, url)
     bscheme, bnetloc, bpath, bparams, bquery, bfragment = \
             urlparse(base, '', allow_fragments)
     scheme, netloc, path, params, query, fragment = \
             urlparse(url, bscheme, allow_fragments)
     if scheme != bscheme or scheme not in uses_relative:
-        return url
+        return _coerce_result(url)
     if scheme in uses_netloc:
         if netloc:
-            return urlunparse((scheme, netloc, path,
-                               params, query, fragment))
+            return _coerce_result(urlunparse((scheme, netloc, path,
+                                              params, query, fragment)))
         netloc = bnetloc
     if path[:1] == '/':
-        return urlunparse((scheme, netloc, path,
-                           params, query, fragment))
-    if not path:
+        return _coerce_result(urlunparse((scheme, netloc, path,
+                                          params, query, fragment)))
+    if not path and not params:
         path = bpath
-        if not params:
-            params = bparams
-        else:
-            path = path[:-1]
-            return urlunparse((scheme, netloc, path,
-                                params, query, fragment))
+        params = bparams
         if not query:
             query = bquery
-        return urlunparse((scheme, netloc, path,
-                           params, query, fragment))
+        return _coerce_result(urlunparse((scheme, netloc, path,
+                                          params, query, fragment)))
     segments = bpath.split('/')[:-1] + path.split('/')
     # XXX The stuff below is bogus in various ways...
     if segments[-1] == '.':
@@ -293,8 +439,8 @@
         segments[-1] = ''
     elif len(segments) >= 2 and segments[-1] == '..':
         segments[-2:] = ['']
-    return urlunparse((scheme, netloc, '/'.join(segments),
-                       params, query, fragment))
+    return _coerce_result(urlunparse((scheme, netloc, '/'.join(segments),
+                                      params, query, fragment)))
 
 def urldefrag(url):
     """Removes any existing fragment from URL.
@@ -303,12 +449,14 @@
     the URL contained no fragments, the second element is the
     empty string.
     """
+    url, _coerce_result = _coerce_args(url)
     if '#' in url:
         s, n, p, a, q, frag = urlparse(url)
         defrag = urlunparse((s, n, p, a, q, ''))
-        return defrag, frag
     else:
-        return url, ''
+        frag = ''
+        defrag = url
+    return _coerce_result(DefragResult(defrag, frag))
 
 def unquote_to_bytes(string):
     """unquote_to_bytes('abc%20def') -> b'abc def'."""
@@ -420,6 +568,7 @@
 
     Returns a list, as G-d intended.
     """
+    qs, _coerce_result = _coerce_args(qs)
     pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
     r = []
     for name_value in pairs:
@@ -435,10 +584,9 @@
             else:
                 continue
         if len(nv[1]) or keep_blank_values:
-            name = unquote(nv[0].replace('+', ' '))
-            value = unquote(nv[1].replace('+', ' '))
+            name = _coerce_result(unquote(nv[0].replace('+', ' ')))
+            value = _coerce_result(unquote(nv[1].replace('+', ' ')))
             r.append((name, value))
-
     return r
 
 def unquote_plus(string, encoding='utf-8', errors='replace'):

Modified: python/branches/py3k-cdecimal/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/urllib/request.py	(original)
+++ python/branches/py3k-cdecimal/Lib/urllib/request.py	Sun Jan  2 13:18:37 2011
@@ -94,6 +94,7 @@
 import socket
 import sys
 import time
+import collections
 
 from urllib.error import URLError, HTTPError, ContentTooShortError
 from urllib.parse import (
@@ -274,8 +275,9 @@
     def __init__(self):
         client_version = "Python-urllib/%s" % __version__
         self.addheaders = [('User-agent', client_version)]
-        # manage the individual handlers
+        # self.handlers is retained only for backward compatibility
         self.handlers = []
+        # manage the individual handlers
         self.handle_open = {}
         self.handle_error = {}
         self.process_response = {}
@@ -325,8 +327,6 @@
             added = True
 
         if added:
-            # the handlers must work in an specific order, the order
-            # is specified in a Handler attribute
             bisect.insort(self.handlers, handler)
             handler.add_parent(self)
 
@@ -1053,8 +1053,16 @@
                     'Content-type',
                     'application/x-www-form-urlencoded')
             if not request.has_header('Content-length'):
-                request.add_unredirected_header(
-                    'Content-length', '%d' % len(data))
+                try:
+                    mv = memoryview(data)
+                except TypeError:
+                    if isinstance(data, collections.Iterable):
+                        raise ValueError("Content-Length should be specified \
+                                for iterable data of type %r %r" % (type(data),
+                                data))
+                else:
+                    request.add_unredirected_header(
+                            'Content-length', '%d' % (len(mv) * mv.itemsize))
 
         sel_host = host
         if request.has_proxy():

Modified: python/branches/py3k-cdecimal/Lib/wave.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/wave.py	(original)
+++ python/branches/py3k-cdecimal/Lib/wave.py	Sun Jan  2 13:18:37 2011
@@ -467,11 +467,11 @@
         self._datalength = self._nframes * self._nchannels * self._sampwidth
         self._form_length_pos = self._file.tell()
         self._file.write(struct.pack('<l4s4slhhllhh4s',
-            36 + self._datalength, 'WAVE', 'fmt ', 16,
+            36 + self._datalength, b'WAVE', b'fmt ', 16,
             WAVE_FORMAT_PCM, self._nchannels, self._framerate,
             self._nchannels * self._framerate * self._sampwidth,
             self._nchannels * self._sampwidth,
-            self._sampwidth * 8, 'data'))
+            self._sampwidth * 8, b'data'))
         self._data_length_pos = self._file.tell()
         self._file.write(struct.pack('<l', self._datalength))
         self._headerwritten = True

Modified: python/branches/py3k-cdecimal/Lib/weakref.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/weakref.py	(original)
+++ python/branches/py3k-cdecimal/Lib/weakref.py	Sun Jan  2 13:18:37 2011
@@ -166,7 +166,7 @@
     def popitem(self):
         if self._pending_removals:
             self._commit_removals()
-        while 1:
+        while True:
             key, wr = self.data.popitem()
             o = wr()
             if o is not None:
@@ -324,7 +324,7 @@
         try:
             wr = ref(key)
         except TypeError:
-            return 0
+            return False
         return wr in self.data
 
     def items(self):
@@ -362,7 +362,7 @@
         return list(self.data)
 
     def popitem(self):
-        while 1:
+        while True:
             key, value = self.data.popitem()
             o = key()
             if o is not None:

Modified: python/branches/py3k-cdecimal/Lib/webbrowser.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/webbrowser.py	(original)
+++ python/branches/py3k-cdecimal/Lib/webbrowser.py	Sun Jan  2 13:18:37 2011
@@ -286,12 +286,10 @@
     """Launcher class for Mozilla/Netscape browsers."""
 
     raise_opts = ["-noraise", "-raise"]
-
     remote_args = ['-remote', 'openURL(%s%action)']
     remote_action = ""
     remote_action_newwin = ",new-window"
     remote_action_newtab = ",new-tab"
-
     background = True
 
 Netscape = Mozilla
@@ -304,15 +302,13 @@
     remote_args = ['%action', '%s']
     remote_action = "-n"
     remote_action_newwin = "-w"
-
     background = True
 
 
 class Opera(UnixBrowser):
     "Launcher class for Opera browser."
 
-    raise_opts = ["", "-raise"]
-
+    raise_opts = ["-noraise", ""]
     remote_args = ['-remote', 'openURL(%s%action)']
     remote_action = ""
     remote_action_newwin = ",new-window"

Modified: python/branches/py3k-cdecimal/Lib/wsgiref/util.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/wsgiref/util.py	(original)
+++ python/branches/py3k-cdecimal/Lib/wsgiref/util.py	Sun Jan  2 13:18:37 2011
@@ -64,7 +64,7 @@
     """Return the full request URI, optionally including the query string"""
     url = application_uri(environ)
     from urllib.parse import quote
-    path_info = quote(environ.get('PATH_INFO',''))
+    path_info = quote(environ.get('PATH_INFO',''),safe='/;=,')
     if not environ.get('SCRIPT_NAME'):
         url += path_info[1:]
     else:

Modified: python/branches/py3k-cdecimal/Lib/xml/etree/ElementTree.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/xml/etree/ElementTree.py	(original)
+++ python/branches/py3k-cdecimal/Lib/xml/etree/ElementTree.py	Sun Jan  2 13:18:37 2011
@@ -584,6 +584,8 @@
         self.text = text_or_uri
     def __str__(self):
         return self.text
+    def __repr__(self):
+        return '<QName %r>' % (self.text,)
     def __hash__(self):
         return hash(self.text)
     def __le__(self, other):
@@ -1066,7 +1068,7 @@
 def register_namespace(prefix, uri):
     if re.match("ns\d+$", prefix):
         raise ValueError("Prefix format reserved for internal use")
-    for k, v in _namespace_map.items():
+    for k, v in list(_namespace_map.items()):
         if k == uri or v == prefix:
             del _namespace_map[k]
     _namespace_map[uri] = prefix

Modified: python/branches/py3k-cdecimal/Lib/xmlrpc/client.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/xmlrpc/client.py	(original)
+++ python/branches/py3k-cdecimal/Lib/xmlrpc/client.py	Sun Jan  2 13:18:37 2011
@@ -1297,8 +1297,12 @@
 
     def parse_response(self, response):
         # read response data from httpresponse, and parse it
-        if response.getheader("Content-Encoding", "") == "gzip":
-            stream = GzipDecodedResponse(response)
+        # Check for new http response object, otherwise it is a file object.
+        if hasattr(response, 'getheader'):
+            if response.getheader("Content-Encoding", "") == "gzip":
+                stream = GzipDecodedResponse(response)
+            else:
+                stream = response
         else:
             stream = response
 

Modified: python/branches/py3k-cdecimal/Lib/zipfile.py
==============================================================================
--- python/branches/py3k-cdecimal/Lib/zipfile.py	(original)
+++ python/branches/py3k-cdecimal/Lib/zipfile.py	Sun Jan  2 13:18:37 2011
@@ -473,9 +473,11 @@
     # Search for universal newlines or line chunks.
     PATTERN = re.compile(br'^(?P<chunk>[^\r\n]+)|(?P<newline>\n|\r\n?)')
 
-    def __init__(self, fileobj, mode, zipinfo, decrypter=None):
+    def __init__(self, fileobj, mode, zipinfo, decrypter=None,
+                 close_fileobj=False):
         self._fileobj = fileobj
         self._decrypter = decrypter
+        self._close_fileobj = close_fileobj
 
         self._compress_type = zipinfo.compress_type
         self._compress_size = zipinfo.compress_size
@@ -647,6 +649,12 @@
         self._offset += len(data)
         return data
 
+    def close(self):
+        try:
+            if self._close_fileobj:
+                self._fileobj.close()
+        finally:
+            super().close()
 
 
 class ZipFile:
@@ -869,8 +877,12 @@
 
     def setpassword(self, pwd):
         """Set default password for encrypted files."""
-        assert isinstance(pwd, bytes)
-        self.pwd = pwd
+        if pwd and not isinstance(pwd, bytes):
+            raise TypeError("pwd: expected bytes, got %s" % type(pwd))
+        if pwd:
+            self.pwd = pwd
+        else:
+            self.pwd = None
 
     def read(self, name, pwd=None):
         """Return file bytes (as a string) for name."""
@@ -881,6 +893,8 @@
         """Return file-like object for 'name'."""
         if mode not in ("r", "U", "rU"):
             raise RuntimeError('open() requires mode "r", "U", or "rU"')
+        if pwd and not isinstance(pwd, bytes):
+            raise TypeError("pwd: expected bytes, got %s" % type(pwd))
         if not self.fp:
             raise RuntimeError(
                   "Attempt to read ZIP archive that was already closed")
@@ -898,8 +912,12 @@
             zinfo = name
         else:
             # Get info object for name
-            zinfo = self.getinfo(name)
-
+            try:
+                zinfo = self.getinfo(name)
+            except KeyError:
+                if not self._filePassed:
+                    zef_file.close()
+                raise
         zef_file.seek(zinfo.header_offset, 0)
 
         # Skip the file header:
@@ -912,7 +930,15 @@
         if fheader[_FH_EXTRA_FIELD_LENGTH]:
             zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH])
 
-        if fname != zinfo.orig_filename.encode("utf-8"):
+        if zinfo.flag_bits & 0x800:
+            # UTF-8 filename
+            fname_str = fname.decode("utf-8")
+        else:
+            fname_str = fname.decode("cp437")
+
+        if fname_str != zinfo.orig_filename:
+            if not self._filePassed:
+                zef_file.close()
             raise BadZipFile(
                   'File name in directory %r and header %r differ.'
                   % (zinfo.orig_filename, fname))
@@ -924,6 +950,8 @@
             if not pwd:
                 pwd = self.pwd
             if not pwd:
+                if not self._filePassed:
+                    zef_file.close()
                 raise RuntimeError("File %s is encrypted, "
                                    "password required for extraction" % name)
 
@@ -933,8 +961,8 @@
             #  completely random, while the 12th contains the MSB of the CRC,
             #  or the MSB of the file time depending on the header type
             #  and is used to check the correctness of the password.
-            bytes = zef_file.read(12)
-            h = list(map(zd, bytes[0:12]))
+            header = zef_file.read(12)
+            h = list(map(zd, header[0:12]))
             if zinfo.flag_bits & 0x8:
                 # compare against the file type from extended local headers
                 check_byte = (zinfo._raw_time >> 8) & 0xff
@@ -942,9 +970,12 @@
                 # compare against the CRC otherwise
                 check_byte = (zinfo.CRC >> 24) & 0xff
             if h[11] != check_byte:
+                if not self._filePassed:
+                    zef_file.close()
                 raise RuntimeError("Bad password for file", name)
 
-        return  ZipExtFile(zef_file, mode, zinfo, zd)
+        return ZipExtFile(zef_file, mode, zinfo, zd,
+                          close_fileobj=not self._filePassed)
 
     def extract(self, member, path=None, pwd=None):
         """Extract a member from the archive to the current working directory,
@@ -1276,6 +1307,12 @@
 class PyZipFile(ZipFile):
     """Class to create ZIP archives with Python library files and packages."""
 
+    def __init__(self, file, mode="r", compression=ZIP_STORED,
+                 allowZip64=False, optimize=-1):
+        ZipFile.__init__(self, file, mode=mode, compression=compression,
+                         allowZip64=allowZip64)
+        self._optimize = optimize
+
     def writepy(self, pathname, basename=""):
         """Add all files from "pathname" to the ZIP archive.
 
@@ -1348,44 +1385,63 @@
         archive name, compiling if necessary.  For example, given
         /python/lib/string, return (/python/lib/string.pyc, string).
         """
+        def _compile(file, optimize=-1):
+            import py_compile
+            if self.debug:
+                print("Compiling", file)
+            try:
+                py_compile.compile(file, doraise=True, optimize=optimize)
+            except py_compile.PyCompileError as error:
+                print(err.msg)
+                return False
+            return True
+
         file_py  = pathname + ".py"
         file_pyc = pathname + ".pyc"
         file_pyo = pathname + ".pyo"
         pycache_pyc = imp.cache_from_source(file_py, True)
         pycache_pyo = imp.cache_from_source(file_py, False)
-        if (os.path.isfile(file_pyo) and
-            os.stat(file_pyo).st_mtime >= os.stat(file_py).st_mtime):
-            # Use .pyo file.
-            arcname = fname = file_pyo
-        elif (os.path.isfile(file_pyc) and
-              os.stat(file_pyc).st_mtime >= os.stat(file_py).st_mtime):
-            # Use .pyc file.
-            arcname = fname = file_pyc
-        elif (os.path.isfile(pycache_pyc) and
-              os.stat(pycache_pyc).st_mtime >= os.stat(file_py).st_mtime):
-            # Use the __pycache__/*.pyc file, but write it to the legacy pyc
-            # file name in the archive.
-            fname = pycache_pyc
-            arcname = file_pyc
-        elif (os.path.isfile(pycache_pyo) and
-              os.stat(pycache_pyo).st_mtime >= os.stat(file_py).st_mtime):
-            # Use the __pycache__/*.pyo file, but write it to the legacy pyo
-            # file name in the archive.
-            fname = pycache_pyo
-            arcname = file_pyo
+        if self._optimize == -1:
+            # legacy mode: use whatever file is present
+            if (os.path.isfile(file_pyo) and
+                os.stat(file_pyo).st_mtime >= os.stat(file_py).st_mtime):
+                # Use .pyo file.
+                arcname = fname = file_pyo
+            elif (os.path.isfile(file_pyc) and
+                  os.stat(file_pyc).st_mtime >= os.stat(file_py).st_mtime):
+                # Use .pyc file.
+                arcname = fname = file_pyc
+            elif (os.path.isfile(pycache_pyc) and
+                  os.stat(pycache_pyc).st_mtime >= os.stat(file_py).st_mtime):
+                # Use the __pycache__/*.pyc file, but write it to the legacy pyc
+                # file name in the archive.
+                fname = pycache_pyc
+                arcname = file_pyc
+            elif (os.path.isfile(pycache_pyo) and
+                  os.stat(pycache_pyo).st_mtime >= os.stat(file_py).st_mtime):
+                # Use the __pycache__/*.pyo file, but write it to the legacy pyo
+                # file name in the archive.
+                fname = pycache_pyo
+                arcname = file_pyo
+            else:
+                # Compile py into PEP 3147 pyc file.
+                if _compile(file_py):
+                    fname = (pycache_pyc if __debug__ else pycache_pyo)
+                    arcname = (file_pyc if __debug__ else file_pyo)
+                else:
+                    fname = arcname = file_py
         else:
-            # Compile py into PEP 3147 pyc file.
-            import py_compile
-            if self.debug:
-                print("Compiling", file_py)
-            try:
-                py_compile.compile(file_py, doraise=True)
-            except py_compile.PyCompileError as error:
-                print(err.msg)
-                fname = file_py
+            # new mode: use given optimization level
+            if self._optimize == 0:
+                fname = pycache_pyc
+                arcname = file_pyc
             else:
-                fname = (pycache_pyc if __debug__ else pycache_pyo)
-                arcname = (file_pyc if __debug__ else file_pyo)
+                fname = pycache_pyo
+                arcname = file_pyo
+            if not (os.path.isfile(fname) and
+                    os.stat(fname).st_mtime >= os.stat(file_py).st_mtime):
+                if not _compile(file_py, optimize=self._optimize):
+                    fname = arcname = file_py
         archivename = os.path.split(arcname)[1]
         if basename:
             archivename = "%s/%s" % (basename, archivename)

Modified: python/branches/py3k-cdecimal/Mac/BuildScript/build-installer.py
==============================================================================
--- python/branches/py3k-cdecimal/Mac/BuildScript/build-installer.py	(original)
+++ python/branches/py3k-cdecimal/Mac/BuildScript/build-installer.py	Sun Jan  2 13:18:37 2011
@@ -418,15 +418,16 @@
     #       to install a newer patch level.
 
     for framework in ['Tcl', 'Tk']:
-        fw = dict(lower=framework.lower(),
-                    upper=framework.upper(),
-                    cap=framework.capitalize())
-        fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw
-        sysfw = os.path.join('/System', fwpth)
+        #fw = dict(lower=framework.lower(),
+        #            upper=framework.upper(),
+        #            cap=framework.capitalize())
+        #fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw
+        fwpth = 'Library/Frameworks/Tcl.framework/Versions/Current'
+        sysfw = os.path.join(SDKPATH, 'System', fwpth)
         libfw = os.path.join('/', fwpth)
         usrfw = os.path.join(os.getenv('HOME'), fwpth)
-        version = "%(upper)s_VERSION" % fw
-        if getTclTkVersion(libfw, version) != getTclTkVersion(sysfw, version):
+        #version = "%(upper)s_VERSION" % fw
+        if os.readlink(libfw) != os.readlink(sysfw):
             fatal("Version of %s must match %s" % (libfw, sysfw) )
         if os.path.exists(usrfw):
             fatal("Please rename %s to avoid possible dynamic load issues."
@@ -825,12 +826,29 @@
             os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP)
             os.chown(p, -1, gid)
 
+    LDVERSION=None
+    VERSION=None
+    ABIFLAGS=None
+
+    with open(os.path.join(buildDir, 'Makefile')) as fp:
+        for ln in fp:
+            if ln.startswith('VERSION='):
+                VERSION=ln.split()[1]
+            if ln.startswith('ABIFLAGS='):
+                ABIFLAGS=ln.split()[1]
+
+            if ln.startswith('LDVERSION='):
+                LDVERSION=ln.split()[1]
+
+    LDVERSION = LDVERSION.replace('$(VERSION)', VERSION)
+    LDVERSION = LDVERSION.replace('$(ABIFLAGS)', ABIFLAGS)
+
     # We added some directories to the search path during the configure
     # phase. Remove those because those directories won't be there on
     # the end-users system.
     path =os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework',
                 'Versions', version, 'lib', 'python%s'%(version,),
-                'config', 'Makefile')
+                'config-' + LDVERSION, 'Makefile')
     fp = open(path, 'r')
     data = fp.read()
     fp.close()

Modified: python/branches/py3k-cdecimal/Mac/Makefile.in
==============================================================================
--- python/branches/py3k-cdecimal/Mac/Makefile.in	(original)
+++ python/branches/py3k-cdecimal/Mac/Makefile.in	Sun Jan  2 13:18:37 2011
@@ -202,10 +202,6 @@
 installextras: $(srcdir)/Extras.ReadMe.txt $(srcdir)/Extras.install.py
 	$(INSTALL) -d "$(DESTDIR)$(PYTHONAPPSDIR)/Extras"
 	$(INSTALL) $(srcdir)/Extras.ReadMe.txt "$(DESTDIR)$(PYTHONAPPSDIR)/Extras/ReadMe.txt"
-	$(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/../Demo \
-		"$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo"
-	$(RUNSHARED) $(BUILDPYTHON) $(srcdir)/Extras.install.py $(srcdir)/Demo \
-		"$(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo.Mac"
 
 
 checkapplepython: $(srcdir)/Tools/fixapplepython23.py

Modified: python/branches/py3k-cdecimal/Mac/README
==============================================================================
--- python/branches/py3k-cdecimal/Mac/README	(original)
+++ python/branches/py3k-cdecimal/Mac/README	Sun Jan  2 13:18:37 2011
@@ -188,8 +188,8 @@
 framework itself, the Mac subtree, the applications and the unix tools.
 
 There is an extra target frameworkinstallextras that is not part of the
-normal frameworkinstall which installs the Demo and Tools directories
-into "/Applications/MacPython <VERSION>", this is useful for binary
+normal frameworkinstall which installs the Tools directory into
+"/Applications/MacPython <VERSION>", this is useful for binary
 distributions.
 
 What do all these programs do?

Modified: python/branches/py3k-cdecimal/Makefile.pre.in
==============================================================================
--- python/branches/py3k-cdecimal/Makefile.pre.in	(original)
+++ python/branches/py3k-cdecimal/Makefile.pre.in	Sun Jan  2 13:18:37 2011
@@ -108,9 +108,8 @@
 # Detailed destination directories
 BINLIBDEST=	$(LIBDIR)/python$(VERSION)
 LIBDEST=	$(SCRIPTDIR)/python$(VERSION)
-INCLUDEPY=	$(INCLUDEDIR)/python$(VERSION)
-CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(VERSION)
-LIBP=		$(LIBDIR)/python$(VERSION)
+INCLUDEPY=	$(INCLUDEDIR)/python$(LDVERSION)
+CONFINCLUDEPY=	$(CONFINCLUDEDIR)/python$(LDVERSION)
 
 # Symbols used for using shared libraries
 SO=		@SO@
@@ -155,7 +154,7 @@
 SRCDIRS= 	@SRCDIRS@
 
 # Other subdirectories
-SUBDIRSTOO=	Include Lib Misc Demo
+SUBDIRSTOO=	Include Lib Misc
 
 # Files and directories to be distributed
 CONFIGFILES=	configure configure.in acconfig.h pyconfig.h.in Makefile.pre.in
@@ -167,6 +166,7 @@
 LIBRARY=	@LIBRARY@
 LDLIBRARY=      @LDLIBRARY@
 BLDLIBRARY=     @BLDLIBRARY@
+PY3LIBRARY=     @PY3LIBRARY@
 DLLLIBRARY=	@DLLLIBRARY@
 LDLIBRARYDIR=   @LDLIBRARYDIR@
 INSTSONAME=	@INSTSONAME@
@@ -421,7 +421,7 @@
 
 
 # Build the interpreter
-$(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY)
+$(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY)
 	$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Modules/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
 
 platform: $(BUILDPYTHON)
@@ -455,6 +455,9 @@
 		$(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
 	fi
 
+libpython3.so:	libpython$(LDVERSION).so
+	$(BLDSHARED) -o $@ -Wl,-hl$@ $^
+
 libpython$(VERSION).dylib: $(LIBRARY_OBJS)
 	 $(CC) -dynamiclib -Wl,-single_module $(PY_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
 
@@ -499,7 +502,6 @@
 		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
 	$(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
 	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
-	$(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
 	$(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
 
 # This rule builds the Cygwin Python DLL and import library if configured
@@ -579,7 +581,7 @@
 $(GRAMMAR_H) $(GRAMMAR_C): Parser/pgen.stamp
 Parser/pgen.stamp: $(PGEN) $(GRAMMAR_INPUT)
 		-@$(INSTALL) -d Include
-		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
+		$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
 		-touch Parser/pgen.stamp
 
 $(PGEN):	$(PGENOBJS)
@@ -642,6 +644,9 @@
 				$(BYTESTR_DEPS) \
 				$(srcdir)/Objects/stringlib/formatter.h
 
+Objects/typeobject.o: $(srcdir)/Objects/typeslots.inc
+$(srcdir)/Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
+	$(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > $(srcdir)/Objects/typeslots.inc
 
 ############################################################################
 # Header files
@@ -834,7 +839,13 @@
 		else	true; \
 		fi; \
 	done
-	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
+	$(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(LDVERSION)$(EXE)
+	-if test "$(VERSION)" != "$(LDVERSION)"; then \
+		if test -f $(DESTDIR)$(BINDIR)/$(PYTHON)$(VERSION)$(EXE) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON)$(VERSION)$(EXE); \
+		then rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE); \
+		fi; \
+		(cd $(DESTDIR)$(BINDIR); $(LN) python$(LDVERSION)$(EXE) python$(VERSION)$(EXE)); \
+	fi
 	if test -f $(LDLIBRARY); then \
 		if test -n "$(DLLLIBRARY)" ; then \
 			$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
@@ -844,6 +855,9 @@
 				(cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
 			fi \
 		fi; \
+		if test -n "$(PY3LIBRARY)"; then \
+			$(INSTALL_SHARED) $(PY3LIBRARY) $(DESTDIR)$(LIBDIR)/$(PY3LIBRARY); \
+		fi; \
 	else	true; \
 	fi
 
@@ -853,10 +867,22 @@
 	else true; \
 	fi
 	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON)3$(EXE))
+	-if test "$(VERSION)" != "$(LDVERSION)"; then \
+		rm -f $(DESTDIR)$(BINDIR)/python$(VERSION)-config; \
+		(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(LDVERSION)-config python$(VERSION)-config); \
+		rm -f $(DESTDIR)$(LIBPC)/python-$(LDVERSION).pc; \
+		(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python-$(LDVERSION).pc); \
+	fi
 	-rm -f $(DESTDIR)$(BINDIR)/python3-config
 	(cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python3-config)
 	-rm -f $(DESTDIR)$(LIBPC)/python3.pc
 	(cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python3.pc)
+	-rm -f $(DESTDIR)$(BINDIR)/idle3
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s idle$(VERSION) idle3)
+	-rm -f $(DESTDIR)$(BINDIR)/pydoc3
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s pydoc$(VERSION) pydoc3)
+	-rm -f $(DESTDIR)$(BINDIR)/2to3
+	(cd $(DESTDIR)$(BINDIR); $(LN) -s 2to3-$(VERSION) 2to3)
 
 # Install the manual page
 maninstall:
@@ -879,11 +905,11 @@
 LIBSUBDIRS=	tkinter tkinter/test tkinter/test/test_tkinter \
                 tkinter/test/test_ttk site-packages test \
 		test/mpdecimal \
-		test/decimaltestdata test/xmltestdata \
+		test/decimaltestdata test/xmltestdata test/subprocessdata \
 		test/tracedmodules test/encoded_modules \
 		concurrent concurrent/futures encodings \
 		email email/mime email/test email/test/data \
-		html json json/tests http dbm xmlrpc \
+		html json test/json_tests http dbm xmlrpc \
 		sqlite3 sqlite3/test \
 		logging csv wsgiref urllib \
 		lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
@@ -987,7 +1013,7 @@
 python-config: $(srcdir)/Misc/python-config.in
 	# Substitution happens here, as the completely-expanded BINDIR
 	# is not available in configure
-	sed -e "s, at EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
+	sed -e "s, at EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
 
 # Install the include files
 INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
@@ -1009,13 +1035,13 @@
 
 # Install the library and miscellaneous stuff needed for extending/embedding
 # This goes into $(exec_prefix)
-LIBPL=		$(LIBP)/config
+LIBPL=		$(LIBDEST)/config-$(LDVERSION)
 
 # pkgconfig directory
 LIBPC=		$(LIBDIR)/pkgconfig
 
 libainstall:	all python-config
-	@for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \
+	@for i in $(LIBDIR) $(LIBPL) $(LIBPC); \
 	do \
 		if test ! -d $(DESTDIR)$$i; then \
 			echo "Creating directory $$i"; \
@@ -1045,7 +1071,7 @@
 	$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
 	$(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
 	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
-	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
+	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config
 	rm python-config
 	@if [ -s Modules/python.exp -a \
 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
@@ -1103,7 +1129,7 @@
 		else	true; \
 		fi; \
 	done
-	$(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
+	$(LN) -fsn include/python$(LDVERSION) $(DESTDIR)$(prefix)/Headers
 	sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
 	$(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
 	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
@@ -1115,8 +1141,8 @@
 # Install a number of symlinks to keep software that expects a normal unix
 # install (which includes python-config) happy.
 frameworkinstallmaclib:
-	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
-	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).dylib"
+	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config-$(LDVERSION)/libpython$(VERSION).a"
+	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config-$(LDVERSION)/libpython$(VERSION).dylib"
 	ln -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
 
 # This installs the IDE, the Launcher and other apps into /Applications
@@ -1130,7 +1156,7 @@
 frameworkaltinstallunixtools:
 	cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
 
-# This installs the Demos and Tools into the applications directory.
+# This installs the Tools into the applications directory.
 # It is not part of a normal frameworkinstall
 frameworkinstallextras:
 	cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
@@ -1298,3 +1324,6 @@
 .PHONY: gdbhooks
 
 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
+# Local Variables:
+# mode: makefile
+# End:

Modified: python/branches/py3k-cdecimal/Misc/ACKS
==============================================================================
--- python/branches/py3k-cdecimal/Misc/ACKS	(original)
+++ python/branches/py3k-cdecimal/Misc/ACKS	Sun Jan  2 13:18:37 2011
@@ -12,12 +12,14 @@
 and the list is in rough alphabetical order by last names.
 
 David Abrahams
+Ron Adam
 Jim Ahlstrom
 Farhan Ahmad
 Matthew Ahrens
 Nir Aides
 Yaniv Aknin
 Jyrki Alakuijala
+Ray Allen
 Billy G. Allie
 Kevin Altis
 Joe Amenta
@@ -76,6 +78,7 @@
 Steven Bethard
 Stephen Bevan
 Ron Bickers
+Adrian von Bidder
 David Binger
 Dominic Binks
 Philippe Biondi
@@ -318,6 +321,7 @@
 Hans de Graaff
 Eddy De Greef
 Duncan Grisby
+Eric Groo
 Dag Gruneau
 Michael Guravage
 Lars Gustäbel
@@ -394,6 +398,7 @@
 Fredrik Håård
 Mihai Ibanescu
 Lars Immisch
+Bobby Impollonia
 Meador Inge
 Tony Ingraldi
 John Interrante
@@ -449,6 +454,7 @@
 Steve Kirsch
 Sebastian Kirsche
 Ron Klatchko
+Reid Kleckner
 Bastian Kleineidam
 Bob Kline
 Matthias Klose
@@ -457,6 +463,7 @@
 Pat Knight
 Greg Kochanski
 Damon Kohler
+Vlad Korolev
 Joseph Koshy
 Maksim Kozyarchuk
 Stefan Krah
@@ -469,6 +476,7 @@
 Ivan Krstić
 Andrew Kuchling
 Vladimir Kushnir
+Ross Lagerwall
 Cameron Laird
 Jean-Baptiste "Jiba" Lamy
 Torsten Landschoff
@@ -499,6 +507,7 @@
 Christopher Tur Lesniewski-Laas
 Mark Levinson
 William Lewis
+Xuanji Li
 Robert van Liere
 Ross Light
 Shawn Ligocki
@@ -536,6 +545,7 @@
 Doug Marien
 Alex Martelli
 Anthony Martin
+Owen Martin
 Sébastien Martini
 Roger Masse
 Nick Mathewson
@@ -724,6 +734,7 @@
 George Sakkis
 Rich Salz
 Kevin Samborn
+Adrian Sampson
 Ilya Sandler
 Mark Sapiro
 Ty Sarna
@@ -733,6 +744,7 @@
 Andreas Schawo
 Neil Schemenauer
 David Scherer
+Bob Schmertz
 Gregor Schmid
 Ralf Schmitt
 Michael Schneider
@@ -820,6 +832,7 @@
 Tobias Thelen
 James Thomas
 Robin Thomas
+Jeremy Thurgood
 Eric Tiedemann
 Tracy Tims
 Oren Tirosh
@@ -868,6 +881,7 @@
 Charles Waldman
 Richard Walker
 Larry Wall
+Kevin Walzer
 Rodrigo Steinmuller Wanderley
 Greg Ward
 Barry Warsaw

Modified: python/branches/py3k-cdecimal/Misc/NEWS
==============================================================================
--- python/branches/py3k-cdecimal/Misc/NEWS	(original)
+++ python/branches/py3k-cdecimal/Misc/NEWS	Sun Jan  2 13:18:37 2011
@@ -2,35 +2,389 @@
 Python News
 +++++++++++
 
+What's New in Python 3.2 Release Candidate 1
+============================================
+
+Core and Builtins
+-----------------
+
+- Issue #10780: PyErr_SetFromWindowsErrWithFilename() and
+  PyErr_SetExcFromWindowsErrWithFilename() decode the filename from the
+  filesystem encoding instead of UTF-8.
+
+- Issue #10779: PyErr_WarnExplicit() decodes the filename from the filesystem
+  encoding instead of UTF-8.
+
+- Add sys.flags attribute for the new -q command-line option.
+
+Library
+-------
+
+- Issue #10801: In zipfile, support different encodings for the header and
+  the filenames.
+
+- Issue #6285: IDLE no longer crashes on missing help file; patch by Scott
+  David Daniels.
+
+- Fix collections.OrderedDict.setdefault() so that it works in
+  subclasses that define __missing__().
+
+- Issue #10786: unittest.TextTestRunner default stream no longer bound at
+  import time. `sys.stderr` now looked up at instantiation time.  Fix
+  contributed by Mark Roddy.
+
+- Issue #10753: Characters ';','=' and ',' in the PATH_INFO environment
+  variable won't be quoted when the URI is constructed by the wsgiref.util 's
+  request_uri method. According to RFC 3986, these characters can be a part of
+  params in PATH component of URI and need not be quoted.
+
+- Issue #10738: Fix webbrowser.Opera.raise_opts.
+
+- Issue #9824: SimpleCookie now encodes , and ; in values to cater to how
+  browsers actually parse cookies.
+
+- Issue #9333: os.symlink now available regardless of user privileges.
+  The function now raises OSError on Windows >=6.0 when the user is unable
+  to create symbolic links. XP and 2003 still raise NotImplementedError.
+
+- Issue #10783: struct.pack() no longer implicitly encodes unicode to UTF-8.
+
+- Issue #10730: Add SVG mime types to mimetypes module.
+
+- Issue #10768: Make the Tkinter ScrolledText widget work again.
+
+- Issue #10777: Fix "dictionary changed size during iteration" bug in
+  ElementTree register_namespace().
+
+- Issue #10626: test_logging now preserves logger disabled states.
+
+- Issue #10774: test_logging now removes temp files created during tests.
+
+- Issue #5258/#10642: if site.py encounters a .pth file that generates an error,
+  it now prints the filename, line number, and traceback to stderr and skips
+  the rest of that individual file, instead of stopping processing entirely.
+
+- Issue #10763: subprocess.communicate() closes stdout and stderr if both are
+  pipes (bug specific to Windows).
+
+- Issue #1693546: fix email.message RFC 2231 parameter encoding to be in better
+  compliance (no "s around encoded values).
+
+- Improved the diff message in the unittest module's assertCountEqual().
+
+- Issue #1155362: email.utils.parsedate_tz now handles a missing space before
+  the '-' of a timezone field as well as before a '+'.
+
+- Issue #4871: The zipfile module now gives a more useful error message if
+  an attempt is made to use a string to specify the archive password.
+
+- Issue #10750: The ``raw`` attribute of buffered IO objects is now read-only.
+
+- Deprecated assertDictContainsSubset() in the unittest module.
+
+Build
+-----
+
+- Issue #10679: The "idle", "pydoc" and "2to3" scripts are now installed with
+  a version-specific suffix on "make altinstall".
+
+Tools/Demos
+-----------
+
+- Issue #7962: The Demo directory is gone.  Most of the old and unmaintained
+  demos have been removed, others integrated in documentation or a new
+  Tools/demo subdirectory.
+
+
+What's New in Python 3.2 Beta 2?
+================================
+
+*Release date: 19-Dec-2010*
+
+Core and Builtins
+-----------------
+
+- Issue #8844: Regular and recursive lock acquisitions can now be interrupted
+  by signals on platforms using pthreads.  Patch by Reid Kleckner.
+
+- Issue #4236: PyModule_Create2 now checks the import machinery directly
+  rather than the Py_IsInitialized flag, avoiding a Fatal Python
+  error in certain circumstances when an import is done in __del__.
+
+- Issue #5587: add a repr to dict_proxy objects.  Patch by David Stanek and
+  Daniel Urban.
+
+Library
+-------
+
+- Issue #3243:  Support iterable bodies in httplib. Patch Contributions by
+  Xuanji Li and Chris AtLee.
+
+- Issue #10611: SystemExit exception will no longer kill a unittest run.
+
+- Issue #9857: It is now possible to skip a test in a setUp, tearDown or clean
+  up function.
+
+- Issue #10573: use actual/expected consistently in unittest methods.
+  The order of the args of assertCountEqual is also changed.
+
+- Issue #9286: email.utils.parseaddr no longer concatenates blank-separated
+  words in the local part of email addresses, thereby preserving the input.
+
+- Issue #6791: Limit header line length (to 65535 bytes) in http.client
+  and http.server, to avoid denial of services from the other party.
+
+- Issue #10404: Use ctl-button-1 on OSX for the context menu in Idle.
+
+- Issue #9907: Fix tab handling on OSX when using editline by calling
+  rl_initialize first, then setting our custom defaults, then reading .editrc.
+
+- Issue #4188: Avoid creating dummy thread objects when logging operations
+  from the threading module (with the internal verbose flag activated).
+
+- Issue #10711: Remove HTTP 0.9 support from http.client.  The ``strict``
+  parameter to HTTPConnection and friends is deprecated.
+
+- Issue #9721: Fix the behavior of urljoin when the relative url starts with a
+  ';' character. Patch by Wes Chow.
+
+- Issue #10714: Limit length of incoming request in http.server to 65536 bytes
+  for security reasons.  Initial patch by Ross Lagerwall.
+
+- Issue #9558: Fix distutils.command.build_ext with VS 8.0.
+
+- Issue #10667: Fast path for collections.Counter().
+
+- Issue #10695: passing the port as a string value to telnetlib no longer
+  causes debug mode to fail.
+
+- Issue #1078919: add_header now automatically RFC2231 encodes parameters
+  that contain non-ascii values.
+
+- Issue #10188 (partial resolution): tempfile.TemporaryDirectory emits
+  a warning on sys.stderr rather than throwing a misleading exception
+  if cleanup fails due to nulling out of modules during shutdown.
+  Also avoids an AttributeError when mkdtemp call fails and issues
+  a ResourceWarning on implicit cleanup via __del__.
+
+- Issue #10107: Warn about unsaved files in IDLE on OSX.
+
+- Issue #7213: subprocess.Popen's default for close_fds has been changed.
+  It is now True in most cases other than on Windows when input, output or
+  error handles are provided.
+
+- Issue #6559: subprocess.Popen has a new pass_fds parameter (actually
+  added in 3.2beta1) to allow specifying a specific list of file descriptors
+  to keep open in the child process.
+
+- Issue #1731717: Fixed the problem where subprocess.wait() could cause an
+  OSError exception when The OS had been told to ignore SIGCLD in our process
+  or otherwise not wait for exiting child processes.
+
+Tests
+-----
+
+- Issue #775964: test_grp now skips YP/NIS entries instead of failing when
+  encountering them.
+
+Tools/Demos
+-----------
+
+- Issue #6075: IDLE on Mac OS X now works with both Carbon AquaTk and
+  Cocoa AquaTk.
+
+- Issue #10710: ``Misc/setuid-prog.c`` is removed from the source tree.
+
+- Issue #10706: Remove outdated script runtests.sh.  Either ``make test``
+  or ``python -m test`` should be used instead.
+
+Build
+-----
+
+- The Windows build now uses Tcl/Tk 8.5.9 and sqlite3 3.7.4.
+
+- Issue #9234: argparse supports alias names for subparsers.
+
+
 What's New in Python 3.2 Beta 1?
 ================================
 
-*Release date: XX-Dec-2010*
+*Release date: 05-Dec-2010*
 
 Core and Builtins
 -----------------
 
-- Issue #10474: range().count() should return integers.
+- Issue #10630: Return dict views from the dict proxy keys()/values()/items()
+  methods.
 
-- Issue #10255: Fix reference leak in Py_InitializeEx().  Patch by Neil
-  Schemenauer.
+- Issue #10596: Fix float.__mod__ to have the same behaviour as float.__divmod__
+  with respect to signed zeros.  -4.0 % 4.0 should be 0.0, not -0.0.
 
-- Issue #4925: Add filename to error message when executable can't be found in
-  subprocess.
+- Issue #1772833: Add the -q command-line option to suppress copyright and
+  version output in interactive mode.
+
+- Provide an *optimize* parameter in the built-in compile() function.
+
+- Fixed several corner case issues on Windows in os.stat/os.lstat related to
+  reparse points.
+
+- PEP 384 (Defining a Stable ABI) is implemented.
+
+- Issue #2690: Range objects support negative indices and slicing.
+
+- Issue #9915: Speed up sorting with a key.
+
+- Issue #8685: Speed up set difference ``a - b`` when source set ``a`` is much
+  larger than operand ``b``.  Patch by Andrew Bennetts.
+
+- Issue #10518: Bring back the callable() builtin.
+
+- Issue #7094: Added alternate formatting (specified by '#') to ``__format__``
+  method of float, complex, and Decimal. This allows more precise control over
+  when decimal points are displayed.
+
+- Issue #10474: range.count() should return integers.
 
 - Issue #1574217: isinstance now catches only AttributeError, rather than
   masking all errors.
 
+Library
+-------
+
+- logging: added "handler of last resort". See http://bit.ly/last-resort-handler
+
+- test.support: Added TestHandler and Matcher classes for better support of
+  assertions about logging.
+
+- Issue #4391: Use proper plural forms in argparse.
+
+- Issue #10601: sys.displayhook uses 'backslashreplace' error handler on
+  UnicodeEncodeError.
+
+- Add the "display" and "undisplay" pdb commands.
+
+- Issue #7245: Add a SIGINT handler in pdb that allows to break a program again
+  after a "continue" command.
+
+- Add the "interact" pdb command.
+
+- Issue #7905: Actually respect the keyencoding parameter to shelve.Shelf.
+
+- Issue #1569291: Speed up array.repeat().
+
+- Provide an interface to set the optimization level of compilation in
+  py_compile, compileall and zipfile.PyZipFile.
+
+- Issue #7904: Changes to urllib.parse.urlsplit to handle schemes as defined by
+  RFC3986. Anything before :// is considered a scheme and is followed by an
+  authority (or netloc) and by '/' led path, which is optional.
+
+- Issue #6045: dbm.gnu databases now support get() and setdefault() methods.
+
+- Issue #10620: `python -m unittest` can accept file paths instead of module
+  names for running specific tests.
+
+- Issue #9424: Deprecate the `unittest.TestCase` methods `assertEquals`,
+  `assertNotEquals`, `assertAlmostEquals`, `assertNotAlmostEquals` and `assert_`
+  and replace them with the correct methods in the Python test suite.
+
+- Issue #10272: The ssl module now raises socket.timeout instead of a generic
+  SSLError on socket timeouts.
+
+- Issue #10528: Allow translators to reorder placeholders in localizable
+  messages from argparse.
+
+- Issue #10497: Fix incorrect use of gettext in argparse.
+
+- Issue #10478: Reentrant calls inside buffered IO objects (for example by
+  way of a signal handler) now raise a RuntimeError instead of freezing the
+  current process.
+
+- logging: Added getLogRecordFactory/setLogRecordFactory with docs and tests.
+
+- Issue #10549: Fix pydoc traceback when text-documenting certain classes.
+
+- Issue #2001: New HTML server with enhanced Web page features.  Patch by Ron
+  Adam.
+
+- Issue #10360: In WeakSet, do not raise TypeErrors when testing for membership
+  of non-weakrefable objects.
+
+- Issue #940286: pydoc.Helper.help() ignores input/output init parameters.
+
+- Issue #1745035: Add a command size and data size limit to smtpd.py, to prevent
+  DoS attacks.  Patch by Savio Sena.
+
+- Issue #4925: Add filename to error message when executable can't be found in
+  subprocess.
+
 - Issue #10391: Don't dereference invalid memory in error messages in the ast
   module.
 
-- Issue #9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
-  zero-initialize all fields, fixing compiler warnings seen when building
-  extension modules with gcc with "-Wmissing-field-initializers" (implied
-  by "-W")
+- Issue #10027: st_nlink was not being set on Windows calls to os.stat or
+  os.lstat. Patch by Hirokazu Yamamoto.
 
-Library
--------
+- Issue #9333: Expose os.symlink only when the SeCreateSymbolicLinkPrivilege is
+  held by the user's account, i.e., when the function can actually be used.
+
+- Issue #8879: Add os.link support for Windows.
+
+- Issue #7911: ``unittest.TestCase.longMessage`` defaults to True for improved
+  failure messages by default. Patch by Mark Roddy.
+
+- Issue #1486713: HTMLParser now has an optional tolerant mode where it tries to
+  guess at the correct parsing of invalid html.
+
+- Issue #10554: Add context manager support to subprocess.Popen objects.
+
+- Issue #8989: email.utils.make_msgid now has a domain parameter that can
+  override the domain name used in the generated msgid.
+
+- Issue #9299: Add exist_ok parameter to os.makedirs to suppress the 'File
+  exists' exception when a target directory already exists with the specified
+  mode. Patch by Ray Allen.
+
+- Issue #9573: os.fork() now works correctly when triggered as a side effect of
+  a module import.
+
+- Issue #10464: netrc now correctly handles lines with embedded '#' characters.
+
+- Added itertools.accumulate().
+
+- Issue #4113: Added custom ``__repr__`` method to ``functools.partial``.
+  Original patch by Daniel Urban.
+
+- Issue #10273: Rename `assertRegexpMatches` and `assertRaisesRegexp` to
+  `assertRegex` and `assertRaisesRegex`.
+
+- Issue #10535: Enable silenced warnings in unittest by default.
+
+- Issue #9873: The URL parsing functions in urllib.parse now accept ASCII byte
+  sequences as input in addition to character strings.
+
+- Issue #10586: The statistics API for the new functools.lru_cache has been
+  changed to a single cache_info() method returning a named tuple.
+
+- Issue #10323: itertools.islice() now consumes the minimum number of inputs
+  before stopping.  Formerly, the final state of the underlying iterator was
+  undefined.
+
+- Issue #10565: The collections.Iterator ABC now checks for both __iter__ and
+  __next__.
+
+- Issue #10242: Fixed implementation of unittest.ItemsEqual and gave it a new
+  more informative name, unittest.CountEqual.
+
+- Issue #10561: In pdb, clear the breakpoints by the breakpoint number.
+
+- Issue #2986: difflib.SequenceMatcher gets a new parameter, autojunk, which can
+  be set to False to turn off the previously undocumented 'popularity'
+  heuristic. Patch by Terry Reedy and Eli Bendersky.
+
+- Issue #10534: in difflib, expose bjunk and bpopular sets; deprecate
+  undocumented and now redundant isbjunk and isbpopular methods.
+
+- Issue #9846: zipfile is now correctly closing underlying file objects.
 
 - Issue #10459: Update CJK character names to Unicode 6.0.
 
@@ -47,14 +401,14 @@
   output stream only when end_headers is invoked. This is a speedup and an
   internal optimization.  Patch by endian.
 
-- Issue #10220: Added inspect.getgeneratorstate. Initial patch by
-  Rodolpho Eckhardt.
+- Issue #10220: Added inspect.getgeneratorstate. Initial patch by Rodolpho
+  Eckhardt.
 
 - Issue #10453: compileall now uses argparse instead of getopt, and thus
   provides clean output when called with '-h'.
 
-- Issue #8078: Add constants for higher baud rates in the termios module.
-  Patch by Rodolpho Eckhardt.
+- Issue #8078: Add constants for higher baud rates in the termios module.  Patch
+  by Rodolpho Eckhardt.
 
 - Issue #10407: Fix two NameErrors in distutils.
 
@@ -63,6 +417,20 @@
 - Issue #10467: Fix BytesIO.readinto() after seeking into a position after the
   end of the file.
 
+- configparser: 100% test coverage.
+
+- Issue #10499: configparser supports pluggable interpolation handlers. The
+  default classic interpolation handler is called BasicInterpolation. Another
+  interpolation handler added (ExtendedInterpolation) which supports the syntax
+  used by zc.buildout (e.g. interpolation between sections).
+
+- configparser: the SafeConfigParser class has been renamed to ConfigParser.
+  The legacy ConfigParser class has been removed but its interpolation mechanism
+  is still available as LegacyInterpolation.
+
+- configparser: Usage of RawConfigParser is now discouraged for new projects
+  in favor of ConfigParser(interpolation=None).
+
 - Issue #1682942: configparser supports alternative option/value delimiters.
 
 - Issue #5412: configparser supports mapping protocol access.
@@ -72,7 +440,9 @@
 - Issue #9421: configparser's getint(), getfloat() and getboolean() methods
   accept vars and default arguments just like get() does.
 
-- Issue #9452: configparser supports reading from strings and dictionaries.
+- Issue #9452: configparser supports reading from strings and dictionaries
+  (thanks to the mapping protocol API, the latter can be used to copy data
+  between parsers).
 
 - configparser: accepted INI file structure is now customizable, including
   comment prefixes, name of the DEFAULT section, empty lines in multiline
@@ -82,9 +452,9 @@
 
 - Issue 9926: Wrapped TestSuite subclass does not get __call__ executed.
 
-- Issue #9920: Skip tests for cmath.atan and cmath.atanh applied to
-  complex zeros on systems where the log1p function fails to respect
-  the sign of zero.  This fixes a test failure on AIX.
+- Issue #9920: Skip tests for cmath.atan and cmath.atanh applied to complex
+  zeros on systems where the log1p function fails to respect the sign of zero.
+  This fixes a test failure on AIX.
 
 - Issue #9732: Addition of getattr_static to the inspect module.
 
@@ -98,21 +468,39 @@
 - Issue #10440: Support RUSAGE_THREAD as a constant in the resource module.
   Patch by Robert Collins.
 
-- Issue #10429: IMAP.starttls() stored the capabilities as bytes objects,
-  rather than strings.
+- Issue #10429: IMAP.starttls() stored the capabilities as bytes objects, rather
+  than strings.
 
 C-API
 -----
 
+- Issue #10557: Added a new API function, PyUnicode_TransformDecimalToASCII(),
+  which transforms non-ASCII decimal digits in a Unicode string to their ASCII
+  equivalents.
+
+- Issue #9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
+  zero-initialize all fields, fixing compiler warnings seen when building
+  extension modules with gcc with "-Wmissing-field-initializers" (implied by
+  "-W").
+
+- Issue #10255: Fix reference leak in Py_InitializeEx().  Patch by Neil
+  Schemenauer.
+
+- structseq.h is now included in Python.h.
+
 - Loosen PyArg_ValidateKeywordArguments to allow dict subclasses.
 
 Tests
 -----
 
-- Issue #9424: Replace deprecated assert* methods in the Python test suite.
+- regrtest.py once again ensures the test directory is removed from sys.path
+  when it is invoked directly as the __main__ module.
 
-- Do not fail test_socket when the IP address of the local hostname
-  cannot be looked up.
+- `python -m test` can be used to run the test suite as well as `python -m
+  test.regrtest`.
+
+- Do not fail test_socket when the IP address of the local hostname cannot be
+  looked up.
 
 - Issue #8886: Use context managers throughout test_zipfile. Patch by Eric
   Carstensen.
@@ -123,6 +511,11 @@
 - Issue #10325: Fix two issues in the fallback definitions for PY_ULLONG_MAX and
   PY_LLONG_MAX that made them unsuitable for use in preprocessor conditionals.
 
+Documentation
+-------------
+
+- Issue #10299: List the built-in functions in a table in functions.rst.
+
 
 What's New in Python 3.2 Alpha 4?
 =================================
@@ -545,7 +938,7 @@
 - Issue #9252: PyImport_Import no longer uses a fromlist hack to return the
   module that was imported, but instead gets the module from sys.modules.
 
-- Issue #9212: The range type_items now provides index() and count() methods, to
+- Issue #9213: The range type_items now provides index() and count() methods, to
   conform to the Sequence ABC.  Patch by Daniel Urban and Daniel Stutzbach.
 
 - Issue #7994: Issue a PendingDeprecationWarning if object.__format__ is called
@@ -1228,8 +1621,8 @@
 
 - Issue #8230: Fix Lib/test/sortperf.py.
 
-- Issue #8620: when a Cmd is fed input that reaches EOF without a final newline,
-  it no longer truncates the last character of the last command line.
+- Issue #8620: when a cmd.Cmd() is fed input that reaches EOF without a final
+  newline, it no longer truncates the last character of the last command line.
 
 - Issue #5146: Handle UID THREAD command correctly in imaplib.
 
@@ -1953,7 +2346,7 @@
 - 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 #8899: time.struct_time now has class and attribute docstrings.
 
 - Issue #6470: Drop UNC prefix in FixTk.
 

Modified: python/branches/py3k-cdecimal/Misc/README
==============================================================================
--- python/branches/py3k-cdecimal/Misc/README	(original)
+++ python/branches/py3k-cdecimal/Misc/README	Sun Jan  2 13:18:37 2011
@@ -20,7 +20,6 @@
 NEWS.help               How to edit NEWS
 Porting                 Mini-FAQ on porting to new platforms
 PURIFY.README           Information for Purify users
-pymemcompat.h           Memory interface compatibility file.
 python-config.in        Python script template for python-config
 python.man              UNIX man page for the python interpreter
 python-mode.el          Emacs mode for editing Python programs
@@ -31,9 +30,7 @@
 README.klocwork         Information about running Klocwork's K7 on Python
 README.OpenBSD          Help for building problems on OpenBSD
 README.valgrind         Information for Valgrind users, see valgrind-python.supp
-RFD                     Request For Discussion about a Python newsgroup
 RPM                     (Old) tools to build RPMs
-setuid-prog.c           C helper program for set-uid Python scripts
 SpecialBuilds.txt       Describes extra symbols you can set for debug builds
 TextMate                A TextMate bundle for Python development
 valgrind-python.supp    Valgrind suppression file, see README.valgrind

Deleted: python/branches/py3k-cdecimal/Misc/RFD
==============================================================================
--- python/branches/py3k-cdecimal/Misc/RFD	Sun Jan  2 13:18:37 2011
+++ (empty file)
@@ -1,114 +0,0 @@
-To:  python-list
-Subject: comp.lang.python RFD again
-From: Guido.van.Rossum at cwi.nl
-
-I've followed the recent discussion and trimmed the blurb RFD down a bit
-(and added the word "object-oriented" to the blurb).
-
-I don't think it's too early to *try* to create the newsgroup --
-whether we will succeed may depend on how many Python supporters there
-are outside the mailing list.
-
-I'm personally not worried about moderation, and anyway I haven't
-heard from any volunteers for moderation (and I won't volunteer
-myself) so I suggest that we'll continue to ask for one unmoderated
-newsgroup.
-
-My next action will be to post an updated FAQ (which will hint at the
-upcoming RFD) to comp.lang.misc; then finalize the 1.0.0 release and
-put it on the ftp site.  I'll also try to get it into
-comp.sources.unix or .misc.  And all this before the end of January!
-
---Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum at cwi.nl>
-URL:  <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>
-
-======================================================================
-
-These are the steps required (in case you don't know about the
-newsgroup creation process):
-
-First, we need to draw up an RFD (Request For Discussion).  This is a
-document that tells what the purpose of the group is, and gives a case
-for its creation.  We post this to relevant groups (comp.lang.misc,
-the mailing list, news.groups, etc.)  Discussion is held on
-news.groups.
-
-Then, after a few weeks, we run the official CFV (Call For Votes).
-The votes are then collected over a period of weeks.  We need 100 more
-yes votes than no votes, and a 2/3 majority, to get the group.
-
-There are some restrictions on the vote taker: [s]he cannot actively
-campaign for/against the group during the vote process.  So the main
-benefit to Steve instead of me running the vote is that I will be free
-to campaign for its creation!
-
-The following is our current draft for the RFD.
-
-======================================================================
-
-Request For Discussion: comp.lang.python
-
-
-Purpose
--------
-
-The newsgroup will be for discussion on the Python computer language.
-Possible topics include requests for information, general programming,
-development, and bug reports. The group will be unmoderated.
-
-
-What is Python?
----------------
-
-Python is a relatively new very-high-level language developed in
-Amsterdam.  Python is a simple, object-oriented procedural language,
-with features taken from ABC, Icon, Modula-3, and C/C++.
-
-Its central goal is to provide the best of both worlds: the dynamic
-nature of scripting languages like Perl/TCL/REXX, but also support for
-general programming found in the more traditional languages like Icon,
-C, Modula,...
-
-Python may be FTP'd from the following sites:
-
-	ftp.cwi.nl in directory /pub/python (its "home site", also has a FAQ)
-	ftp.uu.net in directory /languages/python
-	gatekeeper.dec.com in directory /pub/plan/python/cwi
-
-
-Rationale
----------
-
-Currently there is a mailing list with over 130 subscribers.
-The activity of this list is high, and to make handling the
-traffic more reasonable, a newsgroup is being proposed. We
-also feel that comp.lang.misc would not be a suitable forum
-for this volume of discussion on a particular language.
-
-
-Charter
--------
-
-Comp.lang.python is an unmoderated newsgroup which will serve
-as a forum for discussing the Python computer language. The
-group will serve both those who just program in Python and
-those who work on developing the language. Topics that
-may be discussed include:
-
-	- announcements of new versions of the language and
-	  applications written in Python.
-
-	- discussion on the internals of the Python language.
-
-	- general information about the language.
-
-	- discussion on programming in Python.
-
-
-Discussion
-----------
-
-Any objections to this RFD will be considered and, if determined
-to be appropriate, will be incorporated. The discussion period
-will be for a period of 21 days after which the first CFV will be
-issued.

Modified: python/branches/py3k-cdecimal/Misc/RPM/python-3.2.spec
==============================================================================
--- python/branches/py3k-cdecimal/Misc/RPM/python-3.2.spec	(original)
+++ python/branches/py3k-cdecimal/Misc/RPM/python-3.2.spec	Sun Jan  2 13:18:37 2011
@@ -39,7 +39,7 @@
 
 %define name python
 #--start constants--
-%define version 3.2a4
+%define version 3.2b2
 %define libvers 3.2
 #--end constants--
 %define release 1pydotorg

Modified: python/branches/py3k-cdecimal/Misc/SpecialBuilds.txt
==============================================================================
--- python/branches/py3k-cdecimal/Misc/SpecialBuilds.txt	(original)
+++ python/branches/py3k-cdecimal/Misc/SpecialBuilds.txt	Sun Jan  2 13:18:37 2011
@@ -1,17 +1,20 @@
-This file describes some special Python build types enabled via
-compile-time preprocessor defines.
+This file describes some special Python build types enabled via compile-time
+preprocessor defines.
 
-It is best to define these options in the EXTRA_CFLAGS make variable;
+IMPORTANT: if you want to build a debug-enabled Python, it is recommended that
+you use ``./configure --with-pydebug``, rather than the options listed here.
+
+However, if you wish to define some of these options individually, it is best
+to define them in the EXTRA_CFLAGS make variable;
 ``make EXTRA_CFLAGS="-DPy_REF_DEBUG"``.
 
----------------------------------------------------------------------------
-Py_REF_DEBUG                                              introduced in 1.4
-                                                 named REF_DEBUG before 1.4
-
-Turn on aggregate reference counting.  This arranges that extern
-_Py_RefTotal hold a count of all references, the sum of ob_refcnt across
-all objects.  In a debug-mode build, this is where the "8288" comes from
-in
+
+Py_REF_DEBUG
+------------
+
+Turn on aggregate reference counting.  This arranges that extern _Py_RefTotal
+hold a count of all references, the sum of ob_refcnt across all objects.  In a
+debug-mode build, this is where the "8288" comes from in
 
     >>> 23
     23
@@ -19,75 +22,72 @@
     >>>
 
 Note that if this count increases when you're not storing away new objects,
-there's probably a leak.  Remember, though, that in interactive mode the
-special name "_" holds a reference to the last result displayed!
+there's probably a leak.  Remember, though, that in interactive mode the special
+name "_" holds a reference to the last result displayed!
 
-Py_REF_DEBUG also checks after every decref to verify that the refcount
-hasn't gone negative, and causes an immediate fatal error if it has.
+Py_REF_DEBUG also checks after every decref to verify that the refcount hasn't
+gone negative, and causes an immediate fatal error if it has.
 
 Special gimmicks:
 
 sys.gettotalrefcount()
     Return current total of all refcounts.
-    Available under Py_REF_DEBUG in Python 2.3.
-    Before 2.3, Py_TRACE_REFS was required to enable this function.
----------------------------------------------------------------------------
-Py_TRACE_REFS                                             introduced in 1.4
-                                                named TRACE_REFS before 1.4
-
-Turn on heavy reference debugging.  This is major surgery.  Every PyObject
-grows two more pointers, to maintain a doubly-linked list of all live
-heap-allocated objects.  Most built-in type objects are not in this list,
-as they're statically allocated.  Starting in Python 2.3, if COUNT_ALLOCS
-(see below) is also defined, a static type object T does appear in this
-list if at least one object of type T has been created.
+
+
+Py_TRACE_REFS
+-------------
+
+Turn on heavy reference debugging.  This is major surgery.  Every PyObject grows
+two more pointers, to maintain a doubly-linked list of all live heap-allocated
+objects.  Most built-in type objects are not in this list, as they're statically
+allocated.  Starting in Python 2.3, if COUNT_ALLOCS (see below) is also defined,
+a static type object T does appear in this list if at least one object of type T
+has been created.
 
 Note that because the fundamental PyObject layout changes, Python modules
-compiled with Py_TRACE_REFS are incompatible with modules compiled without
-it.
+compiled with Py_TRACE_REFS are incompatible with modules compiled without it.
 
 Py_TRACE_REFS implies Py_REF_DEBUG.
 
 Special gimmicks:
 
 sys.getobjects(max[, type])
-    Return list of the (no more than) max most-recently allocated objects,
-    most recently allocated first in the list, least-recently allocated
-    last in the list.  max=0 means no limit on list length.
-    If an optional type object is passed, the list is also restricted to
-    objects of that type.
-    The return list itself, and some temp objects created just to call
-    sys.getobjects(), are excluded from the return list.  Note that the
-    list returned is just another object, though, so may appear in the
-    return list the next time you call getobjects(); note that every
-    object in the list is kept alive too, simply by virtue of being in
-    the list.
-
-envar PYTHONDUMPREFS
-    If this envar exists, Py_Finalize() arranges to print a list of
-    all still-live heap objects.  This is printed twice, in different
-    formats, before and after Py_Finalize has cleaned up everything it
-    can clean up.  The first output block produces the repr() of each
-    object so is more informative; however, a lot of stuff destined to
-    die is still alive then.  The second output block is much harder
-    to work with (repr() can't be invoked anymore -- the interpreter
-    has been torn down too far), but doesn't list any objects that will
-    die.  The tool script combinerefs.py can be run over this to combine
-    the info from both output blocks.  The second output block, and
+    Return list of the (no more than) max most-recently allocated objects, most
+    recently allocated first in the list, least-recently allocated last in the
+    list.  max=0 means no limit on list length.  If an optional type object is
+    passed, the list is also restricted to objects of that type.  The return
+    list itself, and some temp objects created just to call sys.getobjects(),
+    are excluded from the return list.  Note that the list returned is just
+    another object, though, so may appear in the return list the next time you
+    call getobjects(); note that every object in the list is kept alive too,
+    simply by virtue of being in the list.
+
+envvar PYTHONDUMPREFS
+    If this envvar exists, Py_Finalize() arranges to print a list of all
+    still-live heap objects.  This is printed twice, in different formats,
+    before and after Py_Finalize has cleaned up everything it can clean up.  The
+    first output block produces the repr() of each object so is more
+    informative; however, a lot of stuff destined to die is still alive then.
+    The second output block is much harder to work with (repr() can't be invoked
+    anymore -- the interpreter has been torn down too far), but doesn't list any
+    objects that will die.  The tool script combinerefs.py can be run over this
+    to combine the info from both output blocks.  The second output block, and
     combinerefs.py, were new in Python 2.3b1.
----------------------------------------------------------------------------
-PYMALLOC_DEBUG                                            introduced in 2.3
+
+
+PYMALLOC_DEBUG
+--------------
 
 When pymalloc is enabled (WITH_PYMALLOC is defined), calls to the PyObject_
-memory routines are handled by Python's own small-object allocator, while
-calls to the PyMem_ memory routines are directed to the system malloc/
-realloc/free.  If PYMALLOC_DEBUG is also defined, calls to both PyObject_
-and PyMem_ memory routines are directed to a special debugging mode of
-Python's small-object allocator.
-
-This mode fills dynamically allocated memory blocks with special,
-recognizable bit patterns, and adds debugging info on each end of
-dynamically allocated memory blocks.  The special bit patterns are:
+memory routines are handled by Python's own small-object allocator, while calls
+to the PyMem_ memory routines are directed to the system malloc/ realloc/free.
+If PYMALLOC_DEBUG is also defined, calls to both PyObject_ and PyMem_ memory
+routines are directed to a special debugging mode of Python's small-object
+allocator.
+
+This mode fills dynamically allocated memory blocks with special, recognizable
+bit patterns, and adds debugging info on each end of dynamically allocated
+memory blocks.  The special bit patterns are:
 
 #define CLEANBYTE     0xCB   /* clean (newly allocated) memory */
 #define DEADBYTE      0xDB   /* dead (newly freed) memory */
@@ -96,73 +96,70 @@
 Strings of these bytes are unlikely to be valid addresses, floats, or 7-bit
 ASCII strings.
 
-Let S = sizeof(size_t). 2*S bytes are added at each end of each block of N
-bytes requested.  The memory layout is like so, where p represents the
-address returned by a malloc-like or realloc-like function (p[i:j] means
-the slice of bytes from *(p+i) inclusive up to *(p+j) exclusive; note that
-the treatment of negative indices differs from a Python slice):
+Let S = sizeof(size_t). 2*S bytes are added at each end of each block of N bytes
+requested.  The memory layout is like so, where p represents the address
+returned by a malloc-like or realloc-like function (p[i:j] means the slice of
+bytes from *(p+i) inclusive up to *(p+j) exclusive; note that the treatment of
+negative indices differs from a Python slice):
 
 p[-2*S:-S]
-    Number of bytes originally asked for.  This is a size_t, big-endian
-    (easier to read in a memory dump).
+    Number of bytes originally asked for.  This is a size_t, big-endian (easier
+    to read in a memory dump).
 p[-S:0]
     Copies of FORBIDDENBYTE.  Used to catch under- writes and reads.
 p[0:N]
     The requested memory, filled with copies of CLEANBYTE, used to catch
-    reference to uninitialized memory.
-    When a realloc-like function is called requesting a larger memory
-    block, the new excess bytes are also filled with CLEANBYTE.
-    When a free-like function is called, these are overwritten with
-    DEADBYTE, to catch reference to freed memory.  When a realloc-
-    like function is called requesting a smaller memory block, the excess
-    old bytes are also filled with DEADBYTE.
+    reference to uninitialized memory.  When a realloc-like function is called
+    requesting a larger memory block, the new excess bytes are also filled with
+    CLEANBYTE.  When a free-like function is called, these are overwritten with
+    DEADBYTE, to catch reference to freed memory.  When a realloc- like function
+    is called requesting a smaller memory block, the excess old bytes are also
+    filled with DEADBYTE.
 p[N:N+S]
     Copies of FORBIDDENBYTE.  Used to catch over- writes and reads.
 p[N+S:N+2*S]
     A serial number, incremented by 1 on each call to a malloc-like or
-    realloc-like function.
-    Big-endian size_t.
-    If "bad memory" is detected later, the serial number gives an
-    excellent way to set a breakpoint on the next run, to capture the
-    instant at which this block was passed out.  The static function
-    bumpserialno() in obmalloc.c is the only place the serial number
-    is incremented, and exists so you can set such a breakpoint easily.
-
-A realloc-like or free-like function first checks that the FORBIDDENBYTEs
-at each end are intact.  If they've been altered, diagnostic output is
-written to stderr, and the program is aborted via Py_FatalError().  The
-other main failure mode is provoking a memory error when a program
-reads up one of the special bit patterns and tries to use it as an address.
-If you get in a debugger then and look at the object, you're likely
-to see that it's entirely filled with 0xDB (meaning freed memory is
-getting used) or 0xCB (meaning uninitialized memory is getting used).
+    realloc-like function.  Big-endian size_t.  If "bad memory" is detected
+    later, the serial number gives an excellent way to set a breakpoint on the
+    next run, to capture the instant at which this block was passed out.  The
+    static function bumpserialno() in obmalloc.c is the only place the serial
+    number is incremented, and exists so you can set such a breakpoint easily.
+
+A realloc-like or free-like function first checks that the FORBIDDENBYTEs at
+each end are intact.  If they've been altered, diagnostic output is written to
+stderr, and the program is aborted via Py_FatalError().  The other main failure
+mode is provoking a memory error when a program reads up one of the special bit
+patterns and tries to use it as an address.  If you get in a debugger then and
+look at the object, you're likely to see that it's entirely filled with 0xDB
+(meaning freed memory is getting used) or 0xCB (meaning uninitialized memory is
+getting used).
 
 Note that PYMALLOC_DEBUG requires WITH_PYMALLOC.
 
 Special gimmicks:
 
-envar PYTHONMALLOCSTATS
-    If this envar exists, a report of pymalloc summary statistics is
-    printed to stderr whenever a new arena is allocated, and also
-    by Py_Finalize().
+envvar PYTHONMALLOCSTATS
+    If this envvar exists, a report of pymalloc summary statistics is printed to
+    stderr whenever a new arena is allocated, and also by Py_Finalize().
 
 Changed in 2.5:  The number of extra bytes allocated is 4*sizeof(size_t).
 Before it was 16 on all boxes, reflecting that Python couldn't make use of
 allocations >= 2**32 bytes even on 64-bit boxes before 2.5.
----------------------------------------------------------------------------
-Py_DEBUG                                                  introduced in 1.5
-                                                     named DEBUG before 1.5
+
+
+Py_DEBUG
+--------
 
 This is what is generally meant by "a debug build" of Python.
 
-Py_DEBUG implies LLTRACE, Py_REF_DEBUG, Py_TRACE_REFS, and
-PYMALLOC_DEBUG (if WITH_PYMALLOC is enabled).  In addition, C
-assert()s are enabled (via the C way: by not defining NDEBUG), and
-some routines do additional sanity checks inside "#ifdef Py_DEBUG"
-blocks.
----------------------------------------------------------------------------
-COUNT_ALLOCS                                            introduced in 0.9.9
-                                             partly broken in 2.2 and 2.2.1
+Py_DEBUG implies LLTRACE, Py_REF_DEBUG, Py_TRACE_REFS, and PYMALLOC_DEBUG (if
+WITH_PYMALLOC is enabled).  In addition, C assert()s are enabled (via the C way:
+by not defining NDEBUG), and some routines do additional sanity checks inside
+"#ifdef Py_DEBUG" blocks.
+
+
+COUNT_ALLOCS
+------------
 
 Each type object grows three new members:
 
@@ -178,84 +175,85 @@
      */
     int tp_maxalloc;
 
-Allocation and deallocation code keeps these counts up to date.
-Py_Finalize() displays a summary of the info returned by sys.getcounts()
-(see below), along with assorted other special allocation counts (like
-the number of tuple allocations satisfied by a tuple free-list, the number
-of 1-character strings allocated, etc).
+Allocation and deallocation code keeps these counts up to date.  Py_Finalize()
+displays a summary of the info returned by sys.getcounts() (see below), along
+with assorted other special allocation counts (like the number of tuple
+allocations satisfied by a tuple free-list, the number of 1-character strings
+allocated, etc).
 
 Before Python 2.2, type objects were immortal, and the COUNT_ALLOCS
-implementation relies on that.  As of Python 2.2, heap-allocated type/
-class objects can go away.  COUNT_ALLOCS can blow up in 2.2 and 2.2.1
-because of this; this was fixed in 2.2.2.  Use of COUNT_ALLOCS makes
-all heap-allocated type objects immortal, except for those for which no
-object of that type is ever allocated.
+implementation relies on that.  As of Python 2.2, heap-allocated type/ class
+objects can go away.  COUNT_ALLOCS can blow up in 2.2 and 2.2.1 because of this;
+this was fixed in 2.2.2.  Use of COUNT_ALLOCS makes all heap-allocated type
+objects immortal, except for those for which no object of that type is ever
+allocated.
 
 Starting with Python 2.3, If Py_TRACE_REFS is also defined, COUNT_ALLOCS
-arranges to ensure that the type object for each allocated object
-appears in the doubly-linked list of all objects maintained by
-Py_TRACE_REFS.
+arranges to ensure that the type object for each allocated object appears in the
+doubly-linked list of all objects maintained by Py_TRACE_REFS.
 
 Special gimmicks:
 
 sys.getcounts()
-    Return a list of 4-tuples, one entry for each type object for which
-    at least one object of that type was allocated.  Each tuple is of
-    the form:
+    Return a list of 4-tuples, one entry for each type object for which at least
+    one object of that type was allocated.  Each tuple is of the form:
 
         (tp_name, tp_allocs, tp_frees, tp_maxalloc)
 
-    Each distinct type object gets a distinct entry in this list, even
-    if two or more type objects have the same tp_name (in which case
-    there's no way to distinguish them by looking at this list).  The
-    list is ordered by time of first object allocation:  the type object
-    for which the first allocation of an object of that type occurred
-    most recently is at the front of the list.
----------------------------------------------------------------------------
-LLTRACE                                          introduced well before 1.0
+    Each distinct type object gets a distinct entry in this list, even if two or
+    more type objects have the same tp_name (in which case there's no way to
+    distinguish them by looking at this list).  The list is ordered by time of
+    first object allocation: the type object for which the first allocation of
+    an object of that type occurred most recently is at the front of the list.
+
+
+LLTRACE
+-------
 
 Compile in support for Low Level TRACE-ing of the main interpreter loop.
 
-When this preprocessor symbol is defined, before PyEval_EvalFrame
-(eval_frame in 2.3 and 2.2, eval_code2 before that) executes a frame's code
-it checks the frame's global namespace for a variable "__lltrace__".  If
-such a variable is found, mounds of information about what the interpreter
-is doing are sprayed to stdout, such as every opcode and opcode argument
-and values pushed onto and popped off the value stack.
+When this preprocessor symbol is defined, before PyEval_EvalFrame (eval_frame in
+2.3 and 2.2, eval_code2 before that) executes a frame's code it checks the
+frame's global namespace for a variable "__lltrace__".  If such a variable is
+found, mounds of information about what the interpreter is doing are sprayed to
+stdout, such as every opcode and opcode argument and values pushed onto and
+popped off the value stack.
 
 Not useful very often, but very useful when needed.
 
----------------------------------------------------------------------------
-CALL_PROFILE                                      introduced for Python 2.3
+
+CALL_PROFILE
+------------
 
 Count the number of function calls executed.
 
-When this symbol is defined, the ceval mainloop and helper functions
-count the number of function calls made.  It keeps detailed statistics
-about what kind of object was called and whether the call hit any of
-the special fast paths in the code.
+When this symbol is defined, the ceval mainloop and helper functions count the
+number of function calls made.  It keeps detailed statistics about what kind of
+object was called and whether the call hit any of the special fast paths in the
+code.
+
 
----------------------------------------------------------------------------
-WITH_TSC                                          introduced for Python 2.4
+WITH_TSC
+--------
 
-Super-lowlevel profiling of the interpreter.  When enabled, the sys
-module grows a new function:
+Super-lowlevel profiling of the interpreter.  When enabled, the sys module grows
+a new function:
 
 settscdump(bool)
-    If true, tell the Python interpreter to dump VM measurements to
-    stderr.  If false, turn off dump.  The measurements are based on the
-    processor's time-stamp counter.
-
-This build option requires a small amount of platform specific code.
-Currently this code is present for linux/x86 and any PowerPC platform
-that uses GCC (i.e. OS X and linux/ppc).
-
-On the PowerPC the rate at which the time base register is incremented
-is not defined by the architecture specification, so you'll need to
-find the manual for your specific processor.  For the 750CX, 750CXe
-and 750FX (all sold as the G3) we find:
+    If true, tell the Python interpreter to dump VM measurements to stderr.  If
+    false, turn off dump.  The measurements are based on the processor's
+    time-stamp counter.
+
+This build option requires a small amount of platform specific code.  Currently
+this code is present for linux/x86 and any PowerPC platform that uses GCC
+(i.e. OS X and linux/ppc).
+
+On the PowerPC the rate at which the time base register is incremented is not
+defined by the architecture specification, so you'll need to find the manual for
+your specific processor.  For the 750CX, 750CXe and 750FX (all sold as the G3)
+we find:
 
-    The time base counter is clocked at a frequency that is
-    one-fourth that of the bus clock.
+    The time base counter is clocked at a frequency that is one-fourth that of
+    the bus clock.
 
 This build is enabled by the --with-tsc flag to configure.

Deleted: python/branches/py3k-cdecimal/Misc/pymemcompat.h
==============================================================================
--- python/branches/py3k-cdecimal/Misc/pymemcompat.h	Sun Jan  2 13:18:37 2011
+++ (empty file)
@@ -1,85 +0,0 @@
-/* The idea of this file is that you bundle it with your extension,
-   #include it, program to Python 2.3's memory API and have your
-   extension build with any version of Python from 1.5.2 through to
-   2.3 (and hopefully beyond). */
-
-#ifndef Py_PYMEMCOMPAT_H
-#define Py_PYMEMCOMPAT_H
-
-#include "Python.h"
-
-/* There are three "families" of memory API: the "raw memory", "object
-   memory" and "object" families.  (This is ignoring the matter of the
-   cycle collector, about which more is said below).
-
-   Raw Memory:
-
-       PyMem_Malloc, PyMem_Realloc, PyMem_Free
-
-   Object Memory:
-
-       PyObject_Malloc, PyObject_Realloc, PyObject_Free
-
-   Object:
-
-       PyObject_New, PyObject_NewVar, PyObject_Del
-
-   The raw memory and object memory allocators both mimic the
-   malloc/realloc/free interface from ANSI C, but the object memory
-   allocator can (and, since 2.3, does by default) use a different
-   allocation strategy biased towards lots of "small" allocations.
-
-   The object family is used for allocating Python objects, and the
-   initializers take care of some basic initialization (setting the
-   refcount to 1 and filling out the ob_type field) as well as having
-   a somewhat different interface.
-
-   Do not mix the families!  E.g. do not allocate memory with
-   PyMem_Malloc and free it with PyObject_Free.  You may get away with
-   it quite a lot of the time, but there *are* scenarios where this
-   will break.  You Have Been Warned. 
-
-   Also, in many versions of Python there are an insane amount of
-   memory interfaces to choose from.  Use the ones described above. */
-
-#if PY_VERSION_HEX < 0x01060000
-/* raw memory interface already present */
-
-/* there is no object memory interface in 1.5.2 */
-#define PyObject_Malloc		PyMem_Malloc
-#define PyObject_Realloc	PyMem_Realloc
-#define PyObject_Free		PyMem_Free
-
-/* the object interface is there, but the names have changed */
-#define PyObject_New		PyObject_NEW
-#define PyObject_NewVar		PyObject_NEW_VAR
-#define PyObject_Del		PyMem_Free
-#endif
-
-/* If your object is a container you probably want to support the
-   cycle collector, which was new in Python 2.0.
-
-   Unfortunately, the interface to the collector that was present in
-   Python 2.0 and 2.1 proved to be tricky to use, and so changed in
-   2.2 -- in a way that can't easily be papered over with macros.
-
-   This file contains macros that let you program to the 2.2 GC API.
-   Your module will compile against any Python since version 1.5.2,
-   but the type will only participate in the GC in versions 2.2 and
-   up.  Some work is still necessary on your part to only fill out the
-   tp_traverse and tp_clear fields when they exist and set tp_flags
-   appropriately.
-
-   It is possible to support both the 2.0 and 2.2 GC APIs, but it's
-   not pretty and this comment block is too narrow to contain a
-   description of what's required... */
-
-#if PY_VERSION_HEX < 0x020200B1
-#define PyObject_GC_New         PyObject_New
-#define PyObject_GC_NewVar      PyObject_NewVar
-#define PyObject_GC_Del         PyObject_Del
-#define PyObject_GC_Track(op)
-#define PyObject_GC_UnTrack(op)
-#endif
-
-#endif /* !Py_PYMEMCOMPAT_H */

Modified: python/branches/py3k-cdecimal/Misc/python-wing4.wpr
==============================================================================
--- python/branches/py3k-cdecimal/Misc/python-wing4.wpr	(original)
+++ python/branches/py3k-cdecimal/Misc/python-wing4.wpr	Sun Jan  2 13:18:37 2011
@@ -5,8 +5,10 @@
 ##################################################################
 [project attributes]
 proj.directory-list = [{'dirloc': loc('..'),
-                        'excludes': [u'Lib/__pycache__',
+                        'excludes': [u'Lib/unittest/test/__pycache__',
+                                     u'Lib/__pycache__',
                                      u'Doc/build',
+                                     u'Lib/unittest/__pycache__',
                                      u'build'],
                         'filter': '*',
                         'include_hidden': False,

Modified: python/branches/py3k-cdecimal/Misc/python.man
==============================================================================
--- python/branches/py3k-cdecimal/Misc/python.man	(original)
+++ python/branches/py3k-cdecimal/Misc/python.man	Sun Jan  2 13:18:37 2011
@@ -26,6 +26,9 @@
 .B \-m 
 .I module-name
 ]
+[
+.B \-q
+]
 .br
        [
 .B \-O
@@ -145,6 +148,10 @@
 .B \-O0
 Discard docstrings in addition to the \fB-O\fP optimizations.
 .TP
+.B \-q
+Do not print the version and copyright messages. These messages are 
+also suppressed in non-interactive mode.
+.TP
 .BI "\-Q " argument
 Division control; see PEP 238.  The argument must be one of "old" (the
 default, int/int and long/long return an int or long), "new" (new

Modified: python/branches/py3k-cdecimal/Misc/python.pc.in
==============================================================================
--- python/branches/py3k-cdecimal/Misc/python.pc.in	(original)
+++ python/branches/py3k-cdecimal/Misc/python.pc.in	Sun Jan  2 13:18:37 2011
@@ -1,3 +1,4 @@
+# See: man pkg-config
 prefix=@prefix@
 exec_prefix=@exec_prefix@
 libdir=@libdir@
@@ -9,5 +10,4 @@
 Version: @VERSION@
 Libs.private: @LIBS@
 Libs: -L${libdir} -lpython at VERSION@@ABIFLAGS@
-Cflags: -I${includedir}/python at VERSION@ 
-
+Cflags: -I${includedir}/python at VERSION@@ABIFLAGS@

Deleted: python/branches/py3k-cdecimal/Misc/setuid-prog.c
==============================================================================
--- python/branches/py3k-cdecimal/Misc/setuid-prog.c	Sun Jan  2 13:18:37 2011
+++ (empty file)
@@ -1,176 +0,0 @@
-/*
-   Template for a setuid program that calls a script.
-
-   The script should be in an unwritable directory and should itself
-   be unwritable.  In fact all parent directories up to the root
-   should be unwritable.  The script must not be setuid, that's what
-   this program is for.
-
-   This is a template program.  You need to fill in the name of the
-   script that must be executed.  This is done by changing the
-   definition of FULL_PATH below.
-
-   There are also some rules that should be adhered to when writing
-   the script itself.
-
-   The first and most important rule is to never, ever trust that the
-   user of the program will behave properly.  Program defensively.
-   Check your arguments for reasonableness.  If the user is allowed to
-   create files, check the names of the files.  If the program depends
-   on argv[0] for the action it should perform, check it.
-
-   Assuming the script is a Bourne shell script, the first line of the
-   script should be
-    #!/bin/sh -
-   The - is important, don't omit it.  If you're using esh, the first
-   line should be
-    #!/usr/local/bin/esh -f
-   and for ksh, the first line should be
-    #!/usr/local/bin/ksh -p
-   The script should then set the variable IFS to the string
-   consisting of <space>, <tab>, and <newline>.  After this (*not*
-   before!), the PATH variable should be set to a reasonable value and
-   exported.  Do not expect the PATH to have a reasonable value, so do
-   not trust the old value of PATH.  You should then set the umask of
-   the program by calling
-    umask 077 # or 022 if you want the files to be readable
-   If you plan to change directories, you should either unset CDPATH
-   or set it to a good value.  Setting CDPATH to just ``.'' (dot) is a
-   good idea.
-   If, for some reason, you want to use csh, the first line should be
-    #!/bin/csh -fb
-   You should then set the path variable to something reasonable,
-   without trusting the inherited path.  Here too, you should set the
-   umask using the command
-    umask 077 # or 022 if you want the files to be readable
-*/
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-
-/* CONFIGURATION SECTION */
-
-#ifndef FULL_PATH       /* so that this can be specified from the Makefile */
-/* Uncomment the following line:
-#define FULL_PATH       "/full/path/of/script"
-* Then comment out the #error line. */
-#error "You must define FULL_PATH somewhere"
-#endif
-#ifndef UMASK
-#define UMASK           077
-#endif
-
-/* END OF CONFIGURATION SECTION */
-
-#if defined(__STDC__) && defined(__sgi)
-#define environ _environ
-#endif
-
-/* don't change def_IFS */
-char def_IFS[] = "IFS= \t\n";
-/* you may want to change def_PATH, but you should really change it in */
-/* your script */
-#ifdef __sgi
-char def_PATH[] = "PATH=/usr/bsd:/usr/bin:/bin:/usr/local/bin:/usr/sbin";
-#else
-char def_PATH[] = "PATH=/usr/ucb:/usr/bin:/bin:/usr/local/bin";
-#endif
-/* don't change def_CDPATH */
-char def_CDPATH[] = "CDPATH=.";
-/* don't change def_ENV */
-char def_ENV[] = "ENV=:";
-
-/*
-   This function changes all environment variables that start with LD_
-   into variables that start with XD_.  This is important since we
-   don't want the script that is executed to use any funny shared
-   libraries.
-
-   The other changes to the environment are, strictly speaking, not
-   needed here.  They can safely be done in the script.  They are done
-   here because we don't trust the script writer (just like the script
-   writer shouldn't trust the user of the script).
-   If IFS is set in the environment, set it to space,tab,newline.
-   If CDPATH is set in the environment, set it to ``.''.
-   Set PATH to a reasonable default.
-*/
-void
-clean_environ(void)
-{
-    char **p;
-    extern char **environ;
-
-    for (p = environ; *p; p++) {
-        if (strncmp(*p, "LD_", 3) == 0)
-            **p = 'X';
-        else if (strncmp(*p, "_RLD", 4) == 0)
-            **p = 'X';
-        else if (strncmp(*p, "PYTHON", 6) == 0)
-            **p = 'X';
-        else if (strncmp(*p, "IFS=", 4) == 0)
-            *p = def_IFS;
-        else if (strncmp(*p, "CDPATH=", 7) == 0)
-            *p = def_CDPATH;
-        else if (strncmp(*p, "ENV=", 4) == 0)
-            *p = def_ENV;
-    }
-    putenv(def_PATH);
-}
-
-int
-main(int argc, char **argv)
-{
-    struct stat statb;
-    gid_t egid = getegid();
-    uid_t euid = geteuid();
-
-    /*
-       Sanity check #1.
-       This check should be made compile-time, but that's not possible.
-       If you're sure that you specified a full path name for FULL_PATH,
-       you can omit this check.
-    */
-    if (FULL_PATH[0] != '/') {
-        fprintf(stderr, "%s: %s is not a full path name\n", argv[0],
-            FULL_PATH);
-        fprintf(stderr, "You can only use this wrapper if you\n");
-        fprintf(stderr, "compile it with an absolute path.\n");
-        exit(1);
-    }
-
-    /*
-       Sanity check #2.
-       Check that the owner of the script is equal to either the
-       effective uid or the super user.
-    */
-    if (stat(FULL_PATH, &statb) < 0) {
-        perror("stat");
-        exit(1);
-    }
-    if (statb.st_uid != 0 && statb.st_uid != euid) {
-        fprintf(stderr, "%s: %s has the wrong owner\n", argv[0],
-            FULL_PATH);
-        fprintf(stderr, "The script should be owned by root,\n");
-        fprintf(stderr, "and shouldn't be writable by anyone.\n");
-        exit(1);
-    }
-
-    if (setregid(egid, egid) < 0)
-        perror("setregid");
-    if (setreuid(euid, euid) < 0)
-        perror("setreuid");
-
-    clean_environ();
-
-    umask(UMASK);
-
-    while (**argv == '-')       /* don't let argv[0] start with '-' */
-        (*argv)++;
-    execv(FULL_PATH, argv);
-    fprintf(stderr, "%s: could not execute the script\n", argv[0]);
-    exit(1);
-}

Modified: python/branches/py3k-cdecimal/Modules/_collectionsmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_collectionsmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_collectionsmodule.c	Sun Jan  2 13:18:37 2011
@@ -1518,6 +1518,68 @@
     PyObject_GC_Del,                    /* tp_free */
 };
 
+/* helper function for Counter  *********************************************/
+
+PyDoc_STRVAR(_count_elements_doc,
+"_count_elements(mapping, iterable) -> None\n\
+\n\
+Count elements in the iterable, updating the mappping");
+
+static PyObject *
+_count_elements(PyObject *self, PyObject *args)
+{
+    PyObject *it, *iterable, *mapping, *oldval;
+    PyObject *newval = NULL;
+    PyObject *key = NULL;
+    PyObject *one = NULL;
+
+    if (!PyArg_UnpackTuple(args, "_count_elements", 2, 2, &mapping, &iterable))
+        return NULL;
+
+    if (!PyDict_Check(mapping)) {
+        PyErr_SetString(PyExc_TypeError,
+            "Expected mapping argument to be a dictionary");
+        return NULL;
+    }
+
+    it = PyObject_GetIter(iterable);
+    if (it == NULL)
+        return NULL;
+    one = PyLong_FromLong(1);
+    if (one == NULL) {
+        Py_DECREF(it);
+        return NULL;
+    }
+    while (1) {
+        key = PyIter_Next(it);
+        if (key == NULL) {
+            if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration))
+                PyErr_Clear();
+            break;
+        }
+        oldval = PyDict_GetItem(mapping, key);
+        if (oldval == NULL) {
+            if (PyDict_SetItem(mapping, key, one) == -1)
+                break;
+        } else {
+            newval = PyNumber_Add(oldval, one);
+            if (newval == NULL)
+                break;
+            if (PyDict_SetItem(mapping, key, newval) == -1)
+                break;
+            Py_CLEAR(newval);
+        }
+        Py_DECREF(key);
+    }
+    Py_DECREF(it);
+    Py_XDECREF(key);
+    Py_XDECREF(newval);
+    Py_DECREF(one);
+    if (PyErr_Occurred())
+        return NULL;
+    Py_RETURN_NONE;
+}
+
 /* module level code ********************************************************/
 
 PyDoc_STRVAR(module_doc,
@@ -1526,13 +1588,17 @@
 - defaultdict:  dict subclass with a default value factory\n\
 ");
 
+static struct PyMethodDef module_functions[] = {
+    {"_count_elements", _count_elements,    METH_VARARGS,   _count_elements_doc},
+    {NULL,       NULL}          /* sentinel */
+};
 
 static struct PyModuleDef _collectionsmodule = {
     PyModuleDef_HEAD_INIT,
     "_collections",
     module_doc,
     -1,
-    NULL,
+    module_functions,
     NULL,
     NULL,
     NULL,

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	Sun Jan  2 13:18:37 2011
@@ -1155,7 +1155,7 @@
         result = -1;
         goto done;
     }
-    result = PyUnicode_AsWideChar((PyUnicodeObject *)value,
+    result = PyUnicode_AsWideChar(value,
                                   (wchar_t *)self->b_ptr,
                                   self->b_size/sizeof(wchar_t));
     if (result >= 0 && (size_t)result < self->b_size/sizeof(wchar_t))
@@ -4174,7 +4174,7 @@
         PyObject *np;
         Py_ssize_t start, stop, step, slicelen, cur, i;
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                                  self->b_length, &start, &stop,
                                  &step, &slicelen) < 0) {
             return NULL;
@@ -4308,7 +4308,7 @@
     else if (PySlice_Check(item)) {
         Py_ssize_t start, stop, step, slicelen, otherlen, i, cur;
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                                  self->b_length, &start, &stop,
                                  &step, &slicelen) < 0) {
             return -1;

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	Sun Jan  2 13:18:37 2011
@@ -1214,7 +1214,7 @@
     } else
         Py_INCREF(value);
 
-    len = PyUnicode_AsWideChar((PyUnicodeObject *)value, chars, 2);
+    len = PyUnicode_AsWideChar(value, chars, 2);
     if (len != 1) {
         Py_DECREF(value);
         PyErr_SetString(PyExc_TypeError,
@@ -1292,7 +1292,7 @@
     } else if (size < length-1)
         /* copy terminating NUL character if there is space */
         size += 1;
-    PyUnicode_AsWideChar((PyUnicodeObject *)value, (wchar_t *)ptr, size);
+    PyUnicode_AsWideChar(value, (wchar_t *)ptr, size);
     return value;
 }
 

Modified: python/branches/py3k-cdecimal/Modules/_datetimemodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_datetimemodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_datetimemodule.c	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,6 @@
  */
 
 #include "Python.h"
-#include "modsupport.h"
 #include "structmember.h"
 
 #include <time.h>
@@ -1258,7 +1257,8 @@
             assert(PyUnicode_Check(Zreplacement));
             ptoappend = _PyUnicode_AsStringAndSize(Zreplacement,
                                                   &ntoappend);
-            ntoappend = Py_SIZE(Zreplacement);
+            if (ptoappend == NULL)
+                goto Done;
         }
         else if (ch == 'f') {
             /* format microseconds */

Modified: python/branches/py3k-cdecimal/Modules/_elementtree.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_elementtree.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_elementtree.c	Sun Jan  2 13:18:37 2011
@@ -1272,7 +1272,7 @@
         if (!self->extra)
             return PyList_New(0);
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                 self->extra->length,
                 &start, &stop, &step, &slicelen) < 0) {
             return NULL;
@@ -1331,7 +1331,7 @@
         if (!self->extra)
             element_new_extra(self, NULL);
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                 self->extra->length,
                 &start, &stop, &step, &slicelen) < 0) {
             return -1;
@@ -1483,6 +1483,9 @@
 
     if (PyUnicode_Check(nameobj))
         name = _PyUnicode_AsString(nameobj);
+    
+    if (name == NULL)
+        return NULL;
 
     /* handle common attributes first */
     if (strcmp(name, "tag") == 0) {
@@ -2139,7 +2142,7 @@
     PyObject *position;
     char buffer[256];
 
-    sprintf(buffer, "%s: line %d, column %d", message, line, column);
+    sprintf(buffer, "%.100s: line %d, column %d", message, line, column);
 
     error = PyObject_CallFunction(elementtree_parseerror_obj, "s", buffer);
     if (!error)
@@ -2194,8 +2197,8 @@
         Py_XDECREF(res);
     } else if (!PyErr_Occurred()) {
         /* Report the first error, not the last */
-        char message[128];
-        sprintf(message, "undefined entity &%.100s;", _PyUnicode_AsString(key));
+        char message[128] = "undefined entity ";
+        strncat(message, data_in, data_len < 100?data_len:100);
         expat_set_error(
             message,
             EXPAT(GetErrorLineNumber)(self->parser),
@@ -2796,29 +2799,25 @@
 static PyObject*  
 xmlparser_getattro(XMLParserObject* self, PyObject* nameobj)
 {
-    PyObject* res;
-    char *name = "";
-
-    if (PyUnicode_Check(nameobj))
-        name = _PyUnicode_AsString(nameobj);
-
-    PyErr_Clear();
-
-    if (strcmp(name, "entity") == 0)
-        res = self->entity;
-    else if (strcmp(name, "target") == 0)
-        res = self->target;
-    else if (strcmp(name, "version") == 0) {
-        char buffer[100];
-        sprintf(buffer, "Expat %d.%d.%d", XML_MAJOR_VERSION,
+    if (PyUnicode_Check(nameobj)) {
+        PyObject* res;
+        if (PyUnicode_CompareWithASCIIString(nameobj, "entity") == 0)
+            res = self->entity;
+        else if (PyUnicode_CompareWithASCIIString(nameobj, "target") == 0)
+            res = self->target;
+        else if (PyUnicode_CompareWithASCIIString(nameobj, "version") == 0) {
+            return PyUnicode_FromFormat(
+                "Expat %d.%d.%d", XML_MAJOR_VERSION,
                 XML_MINOR_VERSION, XML_MICRO_VERSION);
-        return PyUnicode_DecodeUTF8(buffer, strlen(buffer), "strict");
-    } else {
-        return PyObject_GenericGetAttr((PyObject*) self, nameobj);
-    }
+        }
+        else
+            goto generic;
 
-    Py_INCREF(res);
-    return res;
+        Py_INCREF(res);
+        return res;
+    }
+  generic:
+    return PyObject_GenericGetAttr((PyObject*) self, nameobj);
 }
 
 static PyTypeObject XMLParser_Type = {

Modified: python/branches/py3k-cdecimal/Modules/_functoolsmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_functoolsmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_functoolsmodule.c	Sun Jan  2 13:18:37 2011
@@ -196,6 +196,48 @@
     {NULL} /* Sentinel */
 };
 
+static PyObject *
+partial_repr(partialobject *pto)
+{
+    PyObject *result;
+    PyObject *arglist;
+    PyObject *tmp;
+    Py_ssize_t i, n;
+
+    arglist = PyUnicode_FromString("");
+    if (arglist == NULL) {
+        return NULL;
+    }
+    /* Pack positional arguments */
+    assert (PyTuple_Check(pto->args));
+    n = PyTuple_GET_SIZE(pto->args);
+    for (i = 0; i < n; i++) {
+        tmp = PyUnicode_FromFormat("%U, %R", arglist,
+                                   PyTuple_GET_ITEM(pto->args, i));
+        Py_DECREF(arglist);
+        if (tmp == NULL)
+            return NULL;
+        arglist = tmp;
+    }
+    /* Pack keyword arguments */
+    assert (pto->kw == Py_None  ||  PyDict_Check(pto->kw));
+    if (pto->kw != Py_None) {
+        PyObject *key, *value;
+        for (i = 0; PyDict_Next(pto->kw, &i, &key, &value);) {
+            tmp = PyUnicode_FromFormat("%U, %U=%R", arglist,
+                                       key, value);
+            Py_DECREF(arglist);
+            if (tmp == NULL)
+                return NULL;
+            arglist = tmp;
+        }
+    }
+    result = PyUnicode_FromFormat("%s(%R%U)", Py_TYPE(pto)->tp_name,
+                                  pto->fn, arglist);
+    Py_DECREF(arglist);
+    return result;
+}
+
 /* Pickle strategy:
    __reduce__ by itself doesn't support getting kwargs in the unpickle
    operation so we define a __setstate__ that replaces all the information
@@ -254,7 +296,7 @@
     0,                                  /* tp_getattr */
     0,                                  /* tp_setattr */
     0,                                  /* tp_reserved */
-    0,                                  /* tp_repr */
+    (reprfunc)partial_repr,             /* tp_repr */
     0,                                  /* tp_as_number */
     0,                                  /* tp_as_sequence */
     0,                                  /* tp_as_mapping */

Modified: python/branches/py3k-cdecimal/Modules/_gdbmmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_gdbmmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_gdbmmodule.c	Sun Jan  2 13:18:37 2011
@@ -135,6 +135,28 @@
     return v;
 }
 
+PyDoc_STRVAR(dbm_get__doc__,
+"get(key[, default]) -> value\n\
+Get the value for key, or default if not present; if not given,\n\
+default is None.");
+
+static PyObject *
+dbm_get(dbmobject *dp, PyObject *args)
+{
+    PyObject *v, *res;
+    PyObject *def = Py_None;
+
+    if (!PyArg_UnpackTuple(args, "get", 1, 2, &v, &def))
+        return NULL;
+    res = dbm_subscript(dp, v);
+    if (res == NULL && PyErr_ExceptionMatches(PyExc_KeyError)) {
+        PyErr_Clear();
+        Py_INCREF(def);
+        return def;
+    }
+    return res;
+}
+
 static int
 dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
 {
@@ -176,6 +198,29 @@
     return 0;
 }
 
+PyDoc_STRVAR(dbm_setdefault__doc__,
+"setdefault(key[, default]) -> value\n\
+Get value for key, or set it to default and return default if not present;\n\
+if not given, default is None.");
+
+static PyObject *
+dbm_setdefault(dbmobject *dp, PyObject *args)
+{
+    PyObject *v, *res;
+    PyObject *def = Py_None;
+
+    if (!PyArg_UnpackTuple(args, "setdefault", 1, 2, &v, &def))
+        return NULL;
+    res = dbm_subscript(dp, v);
+    if (res == NULL && PyErr_ExceptionMatches(PyExc_KeyError)) {
+        PyErr_Clear();
+        if (dbm_ass_sub(dp, v, def) < 0)
+            return NULL;
+        return dbm_subscript(dp, v);
+    }
+    return res;
+}
+
 static PyMappingMethods dbm_as_mapping = {
     (lenfunc)dbm_length,                /*mp_length*/
     (binaryfunc)dbm_subscript,          /*mp_subscript*/
@@ -378,6 +423,8 @@
     {"nextkey",   (PyCFunction)dbm_nextkey, METH_VARARGS, dbm_nextkey__doc__},
     {"reorganize",(PyCFunction)dbm_reorganize,METH_NOARGS, dbm_reorganize__doc__},
     {"sync",      (PyCFunction)dbm_sync,    METH_NOARGS, dbm_sync__doc__},
+    {"get",       (PyCFunction)dbm_get,     METH_VARARGS, dbm_get__doc__},
+    {"setdefault",(PyCFunction)dbm_setdefault,METH_VARARGS, dbm_setdefault__doc__},
     {NULL,              NULL}           /* sentinel */
 };
 

Modified: python/branches/py3k-cdecimal/Modules/_io/bufferedio.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_io/bufferedio.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_io/bufferedio.c	Sun Jan  2 13:18:37 2011
@@ -225,6 +225,7 @@
 
 #ifdef WITH_THREAD
     PyThread_type_lock lock;
+    volatile long owner;
 #endif
 
     Py_ssize_t buffer_size;
@@ -260,17 +261,34 @@
 /* These macros protect the buffered object against concurrent operations. */
 
 #ifdef WITH_THREAD
-#define ENTER_BUFFERED(self) \
-    if (!PyThread_acquire_lock(self->lock, 0)) { \
-        Py_BEGIN_ALLOW_THREADS \
-        PyThread_acquire_lock(self->lock, 1); \
-        Py_END_ALLOW_THREADS \
+
+static int
+_enter_buffered_busy(buffered *self)
+{
+    if (self->owner == PyThread_get_thread_ident()) {
+        PyErr_Format(PyExc_RuntimeError,
+                     "reentrant call inside %R", self);
+        return 0;
     }
+    Py_BEGIN_ALLOW_THREADS
+    PyThread_acquire_lock(self->lock, 1);
+    Py_END_ALLOW_THREADS
+    return 1;
+}
+
+#define ENTER_BUFFERED(self) \
+    ( (PyThread_acquire_lock(self->lock, 0) ? \
+       1 : _enter_buffered_busy(self)) \
+     && (self->owner = PyThread_get_thread_ident(), 1) )
 
 #define LEAVE_BUFFERED(self) \
-    PyThread_release_lock(self->lock);
+    do { \
+        self->owner = 0; \
+        PyThread_release_lock(self->lock); \
+    } while(0);
+
 #else
-#define ENTER_BUFFERED(self)
+#define ENTER_BUFFERED(self) 1
 #define LEAVE_BUFFERED(self)
 #endif
 
@@ -444,7 +462,8 @@
     int r;
 
     CHECK_INITIALIZED(self)
-    ENTER_BUFFERED(self)
+    if (!ENTER_BUFFERED(self))
+        return NULL;
 
     r = buffered_closed(self);
     if (r < 0)
@@ -465,7 +484,8 @@
     /* flush() will most probably re-take the lock, so drop it first */
     LEAVE_BUFFERED(self)
     res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL);
-    ENTER_BUFFERED(self)
+    if (!ENTER_BUFFERED(self))
+        return NULL;
     if (res == NULL) {
         goto end;
     }
@@ -679,6 +699,7 @@
         PyErr_SetString(PyExc_RuntimeError, "can't allocate read lock");
         return -1;
     }
+    self->owner = 0;
 #endif
     /* Find out whether buffer_size is a power of 2 */
     /* XXX is this optimization useful? */
@@ -705,7 +726,8 @@
     CHECK_INITIALIZED(self)
     CHECK_CLOSED(self, "flush of closed file")
 
-    ENTER_BUFFERED(self)
+    if (!ENTER_BUFFERED(self))
+        return NULL;
     res = _bufferedwriter_flush_unlocked(self, 0);
     if (res != NULL && self->readable) {
         /* Rewind the raw stream so that its position corresponds to
@@ -732,7 +754,8 @@
         return NULL;
     }
 
-    ENTER_BUFFERED(self)
+    if (!ENTER_BUFFERED(self))
+        return NULL;
 
     if (self->writable) {
         res = _bufferedwriter_flush_unlocked(self, 1);
@@ -767,7 +790,8 @@
 
     if (n == -1) {
         /* The number of bytes is unspecified, read until the end of stream */
-        ENTER_BUFFERED(self)
+        if (!ENTER_BUFFERED(self))
+            return NULL;
         res = _bufferedreader_read_all(self);
         LEAVE_BUFFERED(self)
     }
@@ -775,7 +799,8 @@
         res = _bufferedreader_read_fast(self, n);
         if (res == Py_None) {
             Py_DECREF(res);
-            ENTER_BUFFERED(self)
+            if (!ENTER_BUFFERED(self))
+                return NULL;
             res = _bufferedreader_read_generic(self, n);
             LEAVE_BUFFERED(self)
         }
@@ -803,7 +828,8 @@
     if (n == 0)
         return PyBytes_FromStringAndSize(NULL, 0);
 
-    ENTER_BUFFERED(self)
+    if (!ENTER_BUFFERED(self))
+        return NULL;
     
     if (self->writable) {
         res = _bufferedwriter_flush_unlocked(self, 1);
@@ -859,7 +885,8 @@
     
     /* TODO: use raw.readinto() instead! */
     if (self->writable) {
-        ENTER_BUFFERED(self)
+        if (!ENTER_BUFFERED(self))
+            return NULL;
         res = _bufferedwriter_flush_unlocked(self, 0);
         LEAVE_BUFFERED(self)
         if (res == NULL)
@@ -903,7 +930,8 @@
         goto end_unlocked;
     }
 
-    ENTER_BUFFERED(self)
+    if (!ENTER_BUFFERED(self))
+        goto end_unlocked;
 
     /* Now we try to get some more from the raw stream */
     if (self->writable) {
@@ -1053,7 +1081,8 @@
         }
     }
 
-    ENTER_BUFFERED(self)
+    if (!ENTER_BUFFERED(self))
+        return NULL;
 
     /* Fallback: invoke raw seek() method and clear buffer */
     if (self->writable) {
@@ -1091,7 +1120,8 @@
         return NULL;
     }
 
-    ENTER_BUFFERED(self)
+    if (!ENTER_BUFFERED(self))
+        return NULL;
 
     if (self->writable) {
         res = _bufferedwriter_flush_unlocked(self, 0);
@@ -1511,7 +1541,7 @@
 };
 
 static PyMemberDef bufferedreader_members[] = {
-    {"raw", T_OBJECT, offsetof(buffered, raw), 0},
+    {"raw", T_OBJECT, offsetof(buffered, raw), READONLY},
     {NULL}
 };
 
@@ -1748,7 +1778,10 @@
         return NULL;
     }
 
-    ENTER_BUFFERED(self)
+    if (!ENTER_BUFFERED(self)) {
+        PyBuffer_Release(&buf);
+        return NULL;
+    }
 
     /* Fast path: the data to write can be fully buffered. */
     if (!VALID_READ_BUFFER(self) && !VALID_WRITE_BUFFER(self)) {
@@ -1893,7 +1926,7 @@
 };
 
 static PyMemberDef bufferedwriter_members[] = {
-    {"raw", T_OBJECT, offsetof(buffered, raw), 0},
+    {"raw", T_OBJECT, offsetof(buffered, raw), READONLY},
     {NULL}
 };
 
@@ -2287,7 +2320,7 @@
 };
 
 static PyMemberDef bufferedrandom_members[] = {
-    {"raw", T_OBJECT, offsetof(buffered, raw), 0},
+    {"raw", T_OBJECT, offsetof(buffered, raw), READONLY},
     {NULL}
 };
 

Modified: python/branches/py3k-cdecimal/Modules/_lsprof.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_lsprof.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_lsprof.c	Sun Jan  2 13:18:37 2011
@@ -1,7 +1,5 @@
 #include "Python.h"
-#include "compile.h"
 #include "frameobject.h"
-#include "structseq.h"
 #include "rotatingtree.h"
 
 #if !defined(HAVE_LONG_LONG)
@@ -180,7 +178,16 @@
         PyObject *mod = fn->m_module;
         const char *modname;
         if (mod && PyUnicode_Check(mod)) {
+            /* XXX: The following will truncate module names with embedded
+             * null-characters.  It is unlikely that this can happen in
+             * practice and the concequences are not serious enough to
+             * introduce extra checks here.
+             */
             modname = _PyUnicode_AsString(mod);
+            if (modname == NULL) {
+                modname = "<encoding error>";
+                PyErr_Clear();
+            }
         }
         else if (mod && PyModule_Check(mod)) {
             modname = PyModule_GetName(mod);

Modified: python/branches/py3k-cdecimal/Modules/_posixsubprocess.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_posixsubprocess.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_posixsubprocess.c	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,10 @@
 /* Authors: Gregory P. Smith & Jeffrey Yasskin */
 #include "Python.h"
+#ifdef HAVE_PIPE2
+#define _GNU_SOURCE
+#endif
 #include <unistd.h>
+#include <fcntl.h>
 
 
 #define POSIX_CALL(call)   if ((call) == -1) goto error
@@ -42,13 +46,14 @@
                        int errread, int errwrite,
                        int errpipe_read, int errpipe_write,
                        int close_fds, int restore_signals,
-                       int call_setsid,
+                       int call_setsid, Py_ssize_t num_fds_to_keep,
+                       PyObject *py_fds_to_keep,
                        PyObject *preexec_fn,
                        PyObject *preexec_fn_args_tuple)
 {
     int i, saved_errno, fd_num;
     PyObject *result;
-    const char* err_msg;
+    const char* err_msg = "";
     /* Buffer large enough to hold a hex integer.  We can't malloc. */
     char hex_errno[sizeof(saved_errno)*2+1];
 
@@ -91,11 +96,28 @@
     /* close() is intentionally not checked for errors here as we are closing */
     /* a large range of fds, some of which may be invalid. */
     if (close_fds) {
-        for (fd_num = 3; fd_num < errpipe_write; ++fd_num) {
-            close(fd_num);
-        }
-        for (fd_num = errpipe_write+1; fd_num < max_fd; ++fd_num) {
-            close(fd_num);
+        Py_ssize_t keep_seq_idx;
+        int start_fd = 3;
+        for (keep_seq_idx = 0; keep_seq_idx < num_fds_to_keep; ++keep_seq_idx) {
+            PyObject* py_keep_fd = PySequence_Fast_GET_ITEM(py_fds_to_keep,
+                                                            keep_seq_idx);
+            int keep_fd = PyLong_AsLong(py_keep_fd);
+            if (keep_fd < 0) {  /* Negative number, overflow or not a Long. */
+                err_msg = "bad value in fds_to_keep.";
+                errno = 0;  /* We don't want to report an OSError. */
+                goto error;
+            }
+            if (keep_fd < start_fd)
+                continue;
+            for (fd_num = start_fd; fd_num < keep_fd; ++fd_num) {
+                close(fd_num);
+            }
+            start_fd = keep_fd + 1;
+        }
+        if (start_fd <= max_fd) {
+            for (fd_num = start_fd; fd_num < max_fd; ++fd_num) {
+                close(fd_num);
+            }
         }
     }
 
@@ -170,7 +192,7 @@
 subprocess_fork_exec(PyObject* self, PyObject *args)
 {
     PyObject *gc_module = NULL;
-    PyObject *executable_list, *py_close_fds;
+    PyObject *executable_list, *py_close_fds, *py_fds_to_keep;
     PyObject *env_list, *preexec_fn;
     PyObject *process_args, *converted_args = NULL, *fast_args = NULL;
     PyObject *preexec_fn_args_tuple = NULL;
@@ -182,11 +204,11 @@
     pid_t pid;
     int need_to_reenable_gc = 0;
     char *const *exec_array, *const *argv = NULL, *const *envp = NULL;
-    Py_ssize_t arg_num;
+    Py_ssize_t arg_num, num_fds_to_keep;
 
     if (!PyArg_ParseTuple(
-            args, "OOOOOiiiiiiiiiiO:fork_exec",
-            &process_args, &executable_list, &py_close_fds,
+            args, "OOOOOOiiiiiiiiiiO:fork_exec",
+            &process_args, &executable_list, &py_close_fds, &py_fds_to_keep,
             &cwd_obj, &env_list,
             &p2cread, &p2cwrite, &c2pread, &c2pwrite,
             &errread, &errwrite, &errpipe_read, &errpipe_write,
@@ -198,6 +220,11 @@
         PyErr_SetString(PyExc_ValueError, "errpipe_write must be >= 3");
         return NULL;
     }
+    num_fds_to_keep = PySequence_Length(py_fds_to_keep);
+    if (num_fds_to_keep < 0) {
+        PyErr_SetString(PyExc_ValueError, "bad fds_to_keep");
+        return NULL;
+    }
 
     /* We need to call gc.disable() when we'll be calling preexec_fn */
     if (preexec_fn != Py_None) {
@@ -298,6 +325,7 @@
                    p2cread, p2cwrite, c2pread, c2pwrite,
                    errread, errwrite, errpipe_read, errpipe_write,
                    close_fds, restore_signals, call_setsid,
+                   num_fds_to_keep, py_fds_to_keep,
                    preexec_fn, preexec_fn_args_tuple);
         _exit(255);
         return NULL;  /* Dead code to avoid a potential compiler warning. */
@@ -374,6 +402,45 @@
 Raises: Only on an error in the parent process.\n\
 ");
 
+PyDoc_STRVAR(subprocess_cloexec_pipe_doc,
+"cloexec_pipe() -> (read_end, write_end)\n\n\
+Create a pipe whose ends have the cloexec flag set.");
+
+static PyObject *
+subprocess_cloexec_pipe(PyObject *self, PyObject *noargs)
+{
+    int fds[2];
+    int res;
+#ifdef HAVE_PIPE2
+    Py_BEGIN_ALLOW_THREADS
+    res = pipe2(fds, O_CLOEXEC);
+    Py_END_ALLOW_THREADS
+#else
+    /* We hold the GIL which offers some protection from other code calling
+     * fork() before the CLOEXEC flags have been set but we can't guarantee
+     * anything without pipe2(). */
+    long oldflags;
+
+    res = pipe(fds);
+
+    if (res == 0) {
+        oldflags = fcntl(fds[0], F_GETFD, 0);
+        if (oldflags < 0) res = oldflags;
+    }
+    if (res == 0)
+        res = fcntl(fds[0], F_SETFD, oldflags | FD_CLOEXEC);
+
+    if (res == 0) {
+        oldflags = fcntl(fds[1], F_GETFD, 0);
+        if (oldflags < 0) res = oldflags;
+    }
+    if (res == 0)
+        res = fcntl(fds[1], F_SETFD, oldflags | FD_CLOEXEC);
+#endif
+    if (res != 0)
+        return PyErr_SetFromErrno(PyExc_OSError);
+    return Py_BuildValue("(ii)", fds[0], fds[1]);
+}
 
 /* module level code ********************************************************/
 
@@ -383,6 +450,7 @@
 
 static PyMethodDef module_methods[] = {
     {"fork_exec", subprocess_fork_exec, METH_VARARGS, subprocess_fork_exec_doc},
+    {"cloexec_pipe", subprocess_cloexec_pipe, METH_NOARGS, subprocess_cloexec_pipe_doc},
     {NULL, NULL}  /* sentinel */
 };
 

Modified: python/branches/py3k-cdecimal/Modules/_ssl.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_ssl.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_ssl.c	Sun Jan  2 13:18:37 2011
@@ -370,7 +370,7 @@
             sockstate = SOCKET_OPERATION_OK;
         }
         if (sockstate == SOCKET_HAS_TIMED_OUT) {
-            PyErr_SetString(PySSLErrorObject,
+            PyErr_SetString(PySocketModule.timeout_error,
                             ERRSTR("The handshake operation timed out"));
             goto error;
         } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
@@ -928,10 +928,10 @@
     char *cipher_protocol;
 
     if (self->ssl == NULL)
-        return Py_None;
+        Py_RETURN_NONE;
     current = SSL_get_current_cipher(self->ssl);
     if (current == NULL)
-        return Py_None;
+        Py_RETURN_NONE;
 
     retval = PyTuple_New(3);
     if (retval == NULL)
@@ -939,6 +939,7 @@
 
     cipher_name = (char *) SSL_CIPHER_get_name(current);
     if (cipher_name == NULL) {
+        Py_INCREF(Py_None);
         PyTuple_SET_ITEM(retval, 0, Py_None);
     } else {
         v = PyUnicode_FromString(cipher_name);
@@ -948,6 +949,7 @@
     }
     cipher_protocol = SSL_CIPHER_get_version(current);
     if (cipher_protocol == NULL) {
+        Py_INCREF(Py_None);
         PyTuple_SET_ITEM(retval, 1, Py_None);
     } else {
         v = PyUnicode_FromString(cipher_protocol);
@@ -1075,7 +1077,7 @@
 
     sockstate = check_socket_and_wait_for_timeout(sock, 1);
     if (sockstate == SOCKET_HAS_TIMED_OUT) {
-        PyErr_SetString(PySSLErrorObject,
+        PyErr_SetString(PySocketModule.timeout_error,
                         "The write operation timed out");
         goto error;
     } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
@@ -1104,7 +1106,7 @@
             sockstate = SOCKET_OPERATION_OK;
         }
         if (sockstate == SOCKET_HAS_TIMED_OUT) {
-            PyErr_SetString(PySSLErrorObject,
+            PyErr_SetString(PySocketModule.timeout_error,
                             "The write operation timed out");
             goto error;
         } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
@@ -1211,7 +1213,7 @@
     if (!count) {
         sockstate = check_socket_and_wait_for_timeout(sock, 0);
         if (sockstate == SOCKET_HAS_TIMED_OUT) {
-            PyErr_SetString(PySSLErrorObject,
+            PyErr_SetString(PySocketModule.timeout_error,
                             "The read operation timed out");
             goto error;
         } else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
@@ -1245,7 +1247,7 @@
             sockstate = SOCKET_OPERATION_OK;
         }
         if (sockstate == SOCKET_HAS_TIMED_OUT) {
-            PyErr_SetString(PySSLErrorObject,
+            PyErr_SetString(PySocketModule.timeout_error,
                             "The read operation timed out");
             goto error;
         } else if (sockstate == SOCKET_IS_NONBLOCKING) {
@@ -1340,10 +1342,10 @@
             break;
         if (sockstate == SOCKET_HAS_TIMED_OUT) {
             if (ssl_err == SSL_ERROR_WANT_READ)
-                PyErr_SetString(PySSLErrorObject,
+                PyErr_SetString(PySocketModule.timeout_error,
                                 "The read operation timed out");
             else
-                PyErr_SetString(PySSLErrorObject,
+                PyErr_SetString(PySocketModule.timeout_error,
                                 "The write operation timed out");
             goto error;
         }

Modified: python/branches/py3k-cdecimal/Modules/_struct.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_struct.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_struct.c	Sun Jan  2 13:18:37 2011
@@ -6,7 +6,6 @@
 #define PY_SSIZE_T_CLEAN
 
 #include "Python.h"
-#include "structseq.h"
 #include "structmember.h"
 #include <ctype.h>
 
@@ -463,14 +462,9 @@
 static int
 np_char(char *p, PyObject *v, const formatdef *f)
 {
-    if (PyUnicode_Check(v)) {
-        v = _PyUnicode_AsDefaultEncodedString(v, NULL);
-        if (v == NULL)
-            return -1;
-    }
     if (!PyBytes_Check(v) || PyBytes_Size(v) != 1) {
         PyErr_SetString(StructError,
-                        "char format requires bytes or string of length 1");
+                        "char format requires a bytes object of length 1");
         return -1;
     }
     *p = *PyBytes_AsString(v);
@@ -1346,7 +1340,7 @@
     if (!PyBytes_Check(o_format)) {
         Py_DECREF(o_format);
         PyErr_Format(PyExc_TypeError,
-                     "Struct() argument 1 must be bytes, not %.200s",
+                     "Struct() argument 1 must be a bytes object, not %.200s",
                      Py_TYPE(o_format)->tp_name);
         return -1;
     }
@@ -1424,7 +1418,7 @@
         return NULL;
     if (vbuf.len != soself->s_size) {
         PyErr_Format(StructError,
-                     "unpack requires a bytes argument of length %zd",
+                     "unpack requires a bytes object of length %zd",
                      soself->s_size);
         PyBuffer_Release(&vbuf);
         return NULL;
@@ -1504,15 +1498,10 @@
         if (e->format == 's') {
             int isstring;
             void *p;
-            if (PyUnicode_Check(v)) {
-                v = _PyUnicode_AsDefaultEncodedString(v, NULL);
-                if (v == NULL)
-                    return -1;
-            }
             isstring = PyBytes_Check(v);
             if (!isstring && !PyByteArray_Check(v)) {
                 PyErr_SetString(StructError,
-                                "argument for 's' must be a bytes or string");
+                                "argument for 's' must be a bytes object");
                 return -1;
             }
             if (isstring) {
@@ -1530,15 +1519,10 @@
         } else if (e->format == 'p') {
             int isstring;
             void *p;
-            if (PyUnicode_Check(v)) {
-                v = _PyUnicode_AsDefaultEncodedString(v, NULL);
-                if (v == NULL)
-                    return -1;
-            }
             isstring = PyBytes_Check(v);
             if (!isstring && !PyByteArray_Check(v)) {
                 PyErr_SetString(StructError,
-                                "argument for 'p' must be a bytes or string");
+                                "argument for 'p' must be a bytes object");
                 return -1;
             }
             if (isstring) {
@@ -1692,7 +1676,7 @@
     {NULL,       NULL}          /* sentinel */
 };
 
-PyDoc_STRVAR(s__doc__, 
+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"

Modified: python/branches/py3k-cdecimal/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_testcapimodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_testcapimodule.c	Sun Jan  2 13:18:37 2011
@@ -1398,7 +1398,7 @@
     if (buffer == NULL)
         return PyErr_NoMemory();
 
-    size = PyUnicode_AsWideChar((PyUnicodeObject*)unicode, buffer, buflen);
+    size = PyUnicode_AsWideChar(unicode, buffer, buflen);
     if (size == -1) {
         PyMem_Free(buffer);
         return NULL;
@@ -1741,15 +1741,16 @@
 {
     PyObject *result;
     char *msg;
+    static const Py_UNICODE one[] = {'1', 0};
 
-#define CHECK_1_FORMAT(FORMAT, TYPE)                    \
-    result = PyUnicode_FromFormat(FORMAT, (TYPE)1);     \
-    if (result == NULL)                                 \
-        return NULL;                                    \
-    if (strcmp(_PyUnicode_AsString(result), "1")) {     \
-        msg = FORMAT " failed at 1";                    \
-        goto Fail;                                      \
-    }                                                   \
+#define CHECK_1_FORMAT(FORMAT, TYPE)                                \
+    result = PyUnicode_FromFormat(FORMAT, (TYPE)1);                 \
+    if (result == NULL)                                             \
+        return NULL;                                                \
+    if (Py_UNICODE_strcmp(PyUnicode_AS_UNICODE(result), one)) {     \
+        msg = FORMAT " failed at 1";                                \
+        goto Fail;                                                  \
+    }                                                               \
     Py_DECREF(result)
 
     CHECK_1_FORMAT("%d", int);

Modified: python/branches/py3k-cdecimal/Modules/_threadmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/_threadmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/_threadmodule.c	Sun Jan  2 13:18:37 2011
@@ -40,6 +40,58 @@
     PyObject_Del(self);
 }
 
+/* Helper to acquire an interruptible lock with a timeout.  If the lock acquire
+ * is interrupted, signal handlers are run, and if they raise an exception,
+ * PY_LOCK_INTR is returned.  Otherwise, PY_LOCK_ACQUIRED or PY_LOCK_FAILURE
+ * are returned, depending on whether the lock can be acquired withing the
+ * timeout.
+ */
+static PyLockStatus
+acquire_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds)
+{
+    PyLockStatus r;
+    _PyTime_timeval curtime;
+    _PyTime_timeval endtime;
+
+    if (microseconds > 0) {
+        _PyTime_gettimeofday(&endtime);
+        endtime.tv_sec += microseconds / (1000 * 1000);
+        endtime.tv_usec += microseconds % (1000 * 1000);
+    }
+
+
+    do {
+        Py_BEGIN_ALLOW_THREADS
+        r = PyThread_acquire_lock_timed(lock, microseconds, 1);
+        Py_END_ALLOW_THREADS
+
+        if (r == PY_LOCK_INTR) {
+            /* Run signal handlers if we were interrupted.  Propagate
+             * exceptions from signal handlers, such as KeyboardInterrupt, by
+             * passing up PY_LOCK_INTR.  */
+            if (Py_MakePendingCalls() < 0) {
+                return PY_LOCK_INTR;
+            }
+
+            /* If we're using a timeout, recompute the timeout after processing
+             * signals, since those can take time.  */
+            if (microseconds >= 0) {
+                _PyTime_gettimeofday(&curtime);
+                microseconds = ((endtime.tv_sec - curtime.tv_sec) * 1000000 +
+                                (endtime.tv_usec - curtime.tv_usec));
+
+                /* Check for negative values, since those mean block forever.
+                 */
+                if (microseconds <= 0) {
+                    r = PY_LOCK_FAILURE;
+                }
+            }
+        }
+    } while (r == PY_LOCK_INTR);  /* Retry if we were interrupted. */
+
+    return r;
+}
+
 static PyObject *
 lock_PyThread_acquire_lock(lockobject *self, PyObject *args, PyObject *kwds)
 {
@@ -47,7 +99,7 @@
     int blocking = 1;
     double timeout = -1;
     PY_TIMEOUT_T microseconds;
-    int r;
+    PyLockStatus r;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "|id:acquire", kwlist,
                                      &blocking, &timeout))
@@ -77,11 +129,12 @@
         microseconds = (PY_TIMEOUT_T) timeout;
     }
 
-    Py_BEGIN_ALLOW_THREADS
-    r = PyThread_acquire_lock_timed(self->lock_lock, microseconds);
-    Py_END_ALLOW_THREADS
+    r = acquire_timed(self->lock_lock, microseconds);
+    if (r == PY_LOCK_INTR) {
+        return NULL;
+    }
 
-    return PyBool_FromLong(r);
+    return PyBool_FromLong(r == PY_LOCK_ACQUIRED);
 }
 
 PyDoc_STRVAR(acquire_doc,
@@ -93,7 +146,7 @@
 the lock, and return None once the lock is acquired.\n\
 With an argument, this will only block if the argument is true,\n\
 and the return value reflects whether the lock is acquired.\n\
-The blocking operation is not interruptible.");
+The blocking operation is interruptible.");
 
 static PyObject *
 lock_PyThread_release_lock(lockobject *self)
@@ -218,7 +271,7 @@
     double timeout = -1;
     PY_TIMEOUT_T microseconds;
     long tid;
-    int r = 1;
+    PyLockStatus r = PY_LOCK_ACQUIRED;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "|id:acquire", kwlist,
                                      &blocking, &timeout))
@@ -265,17 +318,18 @@
         if (microseconds == 0) {
             Py_RETURN_FALSE;
         }
-        Py_BEGIN_ALLOW_THREADS
-        r = PyThread_acquire_lock_timed(self->rlock_lock, microseconds);
-        Py_END_ALLOW_THREADS
+        r = acquire_timed(self->rlock_lock, microseconds);
     }
-    if (r) {
+    if (r == PY_LOCK_ACQUIRED) {
         assert(self->rlock_count == 0);
         self->rlock_owner = tid;
         self->rlock_count = 1;
     }
+    else if (r == PY_LOCK_INTR) {
+        return NULL;
+    }
 
-    return PyBool_FromLong(r);
+    return PyBool_FromLong(r == PY_LOCK_ACQUIRED);
 }
 
 PyDoc_STRVAR(rlock_acquire_doc,
@@ -287,7 +341,7 @@
 immediately.  If `blocking` is True and another thread holds\n\
 the lock, the method will wait for the lock to be released,\n\
 take it and then return True.\n\
-(note: the blocking operation is not interruptible.)\n\
+(note: the blocking operation is interruptible.)\n\
 \n\
 In all other cases, the method will return True immediately.\n\
 Precisely, if the current thread already holds the lock, its\n\

Modified: python/branches/py3k-cdecimal/Modules/arraymodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/arraymodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/arraymodule.c	Sun Jan  2 13:18:37 2011
@@ -674,11 +674,9 @@
 static PyObject *
 array_repeat(arrayobject *a, Py_ssize_t n)
 {
-    Py_ssize_t i;
     Py_ssize_t size;
     arrayobject *np;
-    char *p;
-    Py_ssize_t nbytes;
+    Py_ssize_t oldbytes, newbytes;
     if (n < 0)
         n = 0;
     if ((Py_SIZE(a) != 0) && (n > PY_SSIZE_T_MAX / Py_SIZE(a))) {
@@ -688,13 +686,23 @@
     np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr);
     if (np == NULL)
         return NULL;
-    p = np->ob_item;
-    nbytes = Py_SIZE(a) * a->ob_descr->itemsize;
-    for (i = 0; i < n; i++) {
-        memcpy(p, a->ob_item, nbytes);
-        p += nbytes;
+    if (n == 0)
+        return (PyObject *)np;
+    oldbytes = Py_SIZE(a) * a->ob_descr->itemsize;
+    newbytes = oldbytes * n;
+    /* this follows the code in unicode_repeat */
+    if (oldbytes == 1) {
+        memset(np->ob_item, a->ob_item[0], newbytes);
+    } else {
+        Py_ssize_t done = oldbytes;
+        Py_MEMCPY(np->ob_item, a->ob_item, oldbytes);
+        while (done < newbytes) {
+            Py_ssize_t ncopy = (done <= newbytes-done) ? done : newbytes-done;
+            Py_MEMCPY(np->ob_item+done, np->ob_item, ncopy);
+            done += ncopy;
+        }
     }
-    return (PyObject *) np;
+    return (PyObject *)np;
 }
 
 static int
@@ -1448,7 +1456,7 @@
 {
     Py_UNICODE *ustr;
     Py_ssize_t n;
-    char typecode;
+    Py_UNICODE typecode;
 
     if (!PyArg_ParseTuple(args, "u#:fromunicode", &ustr, &n))
         return NULL;
@@ -1483,7 +1491,7 @@
 static PyObject *
 array_tounicode(arrayobject *self, PyObject *unused)
 {
-    char typecode;
+    Py_UNICODE typecode;
     typecode = self->ob_descr->typecode;
     if ((typecode != 'u')) {
         PyErr_SetString(PyExc_ValueError,
@@ -2002,8 +2010,8 @@
 static PyObject *
 array_get_typecode(arrayobject *a, void *closure)
 {
-    char tc = a->ob_descr->typecode;
-    return PyUnicode_FromStringAndSize(&tc, 1);
+    Py_UNICODE tc = a->ob_descr->typecode;
+    return PyUnicode_FromUnicode(&tc, 1);
 }
 
 static PyObject *
@@ -2075,21 +2083,21 @@
 static PyObject *
 array_repr(arrayobject *a)
 {
-    char typecode;
+    Py_UNICODE typecode;
     PyObject *s, *v = NULL;
     Py_ssize_t len;
 
     len = Py_SIZE(a);
     typecode = a->ob_descr->typecode;
     if (len == 0) {
-        return PyUnicode_FromFormat("array('%c')", typecode);
+        return PyUnicode_FromFormat("array('%c')", (int)typecode);
     }
     if ((typecode == 'u'))
         v = array_tounicode(a, NULL);
     else
         v = array_tolist(a, NULL);
 
-    s = PyUnicode_FromFormat("array('%c', %R)", typecode, v);
+    s = PyUnicode_FromFormat("array('%c', %R)", (int)typecode, v);
     Py_DECREF(v);
     return s;
 }
@@ -2112,7 +2120,7 @@
         arrayobject* ar;
         int itemsize = self->ob_descr->itemsize;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
+        if (PySlice_GetIndicesEx(item, Py_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return NULL;
         }
@@ -2183,7 +2191,7 @@
             return (*self->ob_descr->setitem)(self, i, value);
     }
     else if (PySlice_Check(item)) {
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                                  Py_SIZE(self), &start, &stop,
                                  &step, &slicelength) < 0) {
             return -1;

Modified: python/branches/py3k-cdecimal/Modules/getpath.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/getpath.c	(original)
+++ python/branches/py3k-cdecimal/Modules/getpath.c	Sun Jan  2 13:18:37 2011
@@ -361,7 +361,7 @@
             decoded = PyUnicode_DecodeUTF8(buf, n, "surrogateescape");
             if (decoded != NULL) {
                 Py_ssize_t k;
-                k = PyUnicode_AsWideChar((PyUnicodeObject*)decoded,
+                k = PyUnicode_AsWideChar(decoded,
                                          rel_builddir_path, MAXPATHLEN);
                 Py_DECREF(decoded);
                 if (k >= 0) {

Modified: python/branches/py3k-cdecimal/Modules/grpmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/grpmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/grpmodule.c	Sun Jan  2 13:18:37 2011
@@ -2,7 +2,6 @@
 /* UNIX group file access module */
 
 #include "Python.h"
-#include "structseq.h"
 
 #include <sys/types.h>
 #include <grp.h>
@@ -160,7 +159,9 @@
 name is not valid, raise KeyError."},
     {"getgrall",        grp_getgrall,   METH_NOARGS,
      "getgrall() -> list of tuples\n\
-Return a list of all available group entries, in arbitrary order."},
+Return a list of all available group entries, in arbitrary order.\n\
+An entry whose name starts with '+' or '-' represents an instruction\n\
+to use YP/NIS and may not be accessible via getgrnam or getgrgid."},
     {NULL,              NULL}           /* sentinel */
 };
 

Modified: python/branches/py3k-cdecimal/Modules/itertoolsmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/itertoolsmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/itertoolsmodule.c	Sun Jan  2 13:18:37 2011
@@ -1215,6 +1215,7 @@
 {
     PyObject *item;
     PyObject *it = lz->it;
+    Py_ssize_t stop = lz->stop;
     Py_ssize_t oldnext;
     PyObject *(*iternext)(PyObject *);
 
@@ -1226,7 +1227,7 @@
         Py_DECREF(item);
         lz->cnt++;
     }
-    if (lz->stop != -1 && lz->cnt >= lz->stop)
+    if (stop != -1 && lz->cnt >= stop)
         return NULL;
     item = iternext(it);
     if (item == NULL)
@@ -1234,8 +1235,8 @@
     lz->cnt++;
     oldnext = lz->next;
     lz->next += lz->step;
-    if (lz->next < oldnext)     /* Check for overflow */
-        lz->next = lz->stop;
+    if (lz->next < oldnext || (stop != -1 && lz->next > stop))
+        lz->next = stop;
     return item;
 }
 
@@ -2583,6 +2584,138 @@
     PyObject_GC_Del,                    /* tp_free */
 };
 
+/* accumulate object ************************************************************/
+
+typedef struct {
+    PyObject_HEAD
+    PyObject *total;
+    PyObject *it;
+} accumulateobject;
+
+static PyTypeObject accumulate_type;
+
+static PyObject *
+accumulate_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    static char *kwargs[] = {"iterable", NULL};
+    PyObject *iterable;
+    PyObject *it;
+    accumulateobject *lz;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:accumulate", kwargs, &iterable))
+        return NULL;
+
+    /* Get iterator. */
+    it = PyObject_GetIter(iterable);
+    if (it == NULL)
+        return NULL;
+
+    /* create accumulateobject structure */
+    lz = (accumulateobject *)type->tp_alloc(type, 0);
+    if (lz == NULL) {
+        Py_DECREF(it);
+        return NULL;
+    }
+
+    lz->total = NULL;
+    lz->it = it;
+    return (PyObject *)lz;
+}
+
+static void
+accumulate_dealloc(accumulateobject *lz)
+{
+    PyObject_GC_UnTrack(lz);
+    Py_XDECREF(lz->total);
+    Py_XDECREF(lz->it);
+    Py_TYPE(lz)->tp_free(lz);
+}
+
+static int
+accumulate_traverse(accumulateobject *lz, visitproc visit, void *arg)
+{
+    Py_VISIT(lz->it);
+    Py_VISIT(lz->total);
+    return 0;
+}
+
+static PyObject *
+accumulate_next(accumulateobject *lz)
+{
+    PyObject *val, *oldtotal, *newtotal;
+    
+    val = PyIter_Next(lz->it);
+    if (val == NULL)
+        return NULL;
+ 
+    if (lz->total == NULL) {
+        Py_INCREF(val);
+        lz->total = val;
+        return lz->total;
+    }
+   
+    newtotal = PyNumber_Add(lz->total, val);
+    Py_DECREF(val);
+    if (newtotal == NULL)
+        return NULL;
+
+    oldtotal = lz->total;
+    lz->total = newtotal;
+    Py_DECREF(oldtotal);
+    
+    Py_INCREF(newtotal);
+    return newtotal;
+}
+
+PyDoc_STRVAR(accumulate_doc,
+"accumulate(iterable) --> accumulate object\n\
+\n\
+Return series of accumulated sums.");
+
+static PyTypeObject accumulate_type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "itertools.accumulate",             /* tp_name */
+    sizeof(accumulateobject),           /* tp_basicsize */
+    0,                                  /* tp_itemsize */
+    /* methods */
+    (destructor)accumulate_dealloc,     /* tp_dealloc */
+    0,                                  /* tp_print */
+    0,                                  /* tp_getattr */
+    0,                                  /* tp_setattr */
+    0,                                  /* tp_reserved */
+    0,                                  /* tp_repr */
+    0,                                  /* tp_as_number */
+    0,                                  /* tp_as_sequence */
+    0,                                  /* tp_as_mapping */
+    0,                                  /* tp_hash */
+    0,                                  /* tp_call */
+    0,                                  /* tp_str */
+    PyObject_GenericGetAttr,            /* tp_getattro */
+    0,                                  /* tp_setattro */
+    0,                                  /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
+        Py_TPFLAGS_BASETYPE,            /* tp_flags */
+    accumulate_doc,                     /* tp_doc */
+    (traverseproc)accumulate_traverse,  /* tp_traverse */
+    0,                                  /* tp_clear */
+    0,                                  /* tp_richcompare */
+    0,                                  /* tp_weaklistoffset */
+    PyObject_SelfIter,                  /* tp_iter */
+    (iternextfunc)accumulate_next,      /* tp_iternext */
+    0,                                  /* tp_methods */
+    0,                                  /* tp_members */
+    0,                                  /* tp_getset */
+    0,                                  /* tp_base */
+    0,                                  /* tp_dict */
+    0,                                  /* tp_descr_get */
+    0,                                  /* tp_descr_set */
+    0,                                  /* tp_dictoffset */
+    0,                                  /* tp_init */
+    0,                                  /* tp_alloc */
+    accumulate_new,                     /* tp_new */
+    PyObject_GC_Del,                    /* tp_free */
+};
+
 
 /* compress object ************************************************************/
 
@@ -3495,6 +3628,7 @@
 repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times\n\
 \n\
 Iterators terminating on the shortest input sequence:\n\
+accumulate(p, start=0) --> p0, p0+p1, p0+p1+p2\n\
 chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ... \n\
 compress(data, selectors) --> (d[0] if s[0]), (d[1] if s[1]), ...\n\
 dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails\n\
@@ -3540,6 +3674,7 @@
     PyObject *m;
     char *name;
     PyTypeObject *typelist[] = {
+        &accumulate_type,
         &combinations_type,
         &cwr_type,
         &cycle_type,

Modified: python/branches/py3k-cdecimal/Modules/main.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/main.c	(original)
+++ python/branches/py3k-cdecimal/Modules/main.c	Sun Jan  2 13:18:37 2011
@@ -2,7 +2,6 @@
 
 #include "Python.h"
 #include "osdefs.h"
-#include "import.h"
 
 #include <locale.h>
 
@@ -47,7 +46,7 @@
 static int  orig_argc;
 
 /* command line options */
-#define BASE_OPTS L"bBc:dEhiJm:OsStuvVW:xX:?"
+#define BASE_OPTS L"bBc:dEhiJm:OqsStuvVW:xX:?"
 
 #define PROGRAM_OPTS BASE_OPTS
 
@@ -72,6 +71,7 @@
 -m mod : run library module as a script (terminates option list)\n\
 -O     : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\
 -OO    : remove doc-strings in addition to the -O optimizations\n\
+-q     : don't print version and copyright messages on interactive startup\n\
 -s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
 -S     : don't imply 'import site' on initialization\n\
 ";
@@ -425,6 +425,10 @@
             PySys_AddXOption(_PyOS_optarg);
             break;
 
+        case 'q':
+            Py_QuietFlag++;
+            break;
+
         /* This space reserved for other options */
 
         default:
@@ -589,8 +593,9 @@
 #endif
     Py_Initialize();
 
-    if (Py_VerboseFlag ||
-        (command == NULL && filename == NULL && module == NULL && stdin_is_interactive)) {
+    if (!Py_QuietFlag && (Py_VerboseFlag ||
+                        (command == NULL && filename == NULL &&
+                         module == NULL && stdin_is_interactive))) {
         fprintf(stderr, "Python %s on %s\n",
             Py_GetVersion(), Py_GetPlatform());
         if (!Py_NoSiteFlag)

Modified: python/branches/py3k-cdecimal/Modules/mmapmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/mmapmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/mmapmodule.c	Sun Jan  2 13:18:37 2011
@@ -762,7 +762,7 @@
     else if (PySlice_Check(item)) {
         Py_ssize_t start, stop, step, slicelen;
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item, self->size,
+        if (PySlice_GetIndicesEx(item, self->size,
                          &start, &stop, &step, &slicelen) < 0) {
             return NULL;
         }
@@ -888,7 +888,7 @@
         Py_ssize_t start, stop, step, slicelen;
         Py_buffer vbuf;
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                                  self->size, &start, &stop,
                                  &step, &slicelen) < 0) {
             return -1;

Modified: python/branches/py3k-cdecimal/Modules/parsermodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/parsermodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/parsermodule.c	Sun Jan  2 13:18:37 2011
@@ -34,10 +34,8 @@
 #include "grammar.h"
 #include "parsetok.h"
                                         /* ISTERMINAL() / ISNONTERMINAL() */
-#include "compile.h"
 #undef Yield
 #include "ast.h"
-#include "pyarena.h"
 
 extern grammar _PyParser_Grammar; /* From graminit.c */
 
@@ -794,6 +792,11 @@
                 }
             }
             temp_str = _PyUnicode_AsStringAndSize(temp, &len);
+            if (temp_str == NULL) {
+                Py_DECREF(temp);
+                Py_XDECREF(elem);
+                return 0;
+            }
             strn = (char *)PyObject_MALLOC(len + 1);
             if (strn != NULL)
                 (void) memcpy(strn, temp_str, len + 1);
@@ -872,6 +875,8 @@
             encoding = PySequence_GetItem(tuple, 2);
             /* tuple isn't borrowed anymore here, need to DECREF */
             tuple = PySequence_GetSlice(tuple, 0, 2);
+            if (tuple == NULL)
+                return NULL;
         }
         res = PyNode_New(num);
         if (res != NULL) {
@@ -883,6 +888,12 @@
                 Py_ssize_t len;
                 const char *temp;
                 temp = _PyUnicode_AsStringAndSize(encoding, &len);
+                if (temp == NULL) {
+                    Py_DECREF(res);
+                    Py_DECREF(encoding);
+                    Py_DECREF(tuple);
+                    return NULL;
+                }
                 res->n_str = (char *)PyObject_MALLOC(len + 1);
                 if (res->n_str != NULL && temp != NULL)
                     (void) memcpy(res->n_str, temp, len + 1);

Modified: python/branches/py3k-cdecimal/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/posixmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/posixmodule.c	Sun Jan  2 13:18:37 2011
@@ -28,7 +28,6 @@
 #define PY_SSIZE_T_CLEAN
 
 #include "Python.h"
-#include "structseq.h"
 
 #if defined(__VMS)
 #    include <unixio.h>
@@ -278,6 +277,10 @@
 #include <windows.h>
 #include <shellapi.h>   /* for ShellExecute() */
 #include <lmcons.h>     /* for UNLEN */
+#ifdef SE_CREATE_SYMBOLIC_LINK_NAME /* Available starting with Vista */
+#define HAVE_SYMLINK
+static int win32_can_symlink = 0;
+#endif
 #endif /* _MSC_VER */
 
 #if defined(PYCC_VACPP) && defined(PYOS_OS2)
@@ -437,6 +440,98 @@
 #define _PyVerify_fd_dup2(A, B) (1)
 #endif
 
+#ifdef MS_WINDOWS
+/* The following structure was copied from
+   http://msdn.microsoft.com/en-us/library/ms791514.aspx as the required
+   include doesn't seem to be present in the Windows SDK (at least as included
+   with Visual Studio Express). */
+typedef struct _REPARSE_DATA_BUFFER {
+    ULONG ReparseTag;
+    USHORT ReparseDataLength;
+    USHORT Reserved;
+    union {
+        struct {
+            USHORT SubstituteNameOffset;
+            USHORT SubstituteNameLength;
+            USHORT PrintNameOffset;
+            USHORT PrintNameLength;
+            ULONG Flags;
+            WCHAR PathBuffer[1];
+        } SymbolicLinkReparseBuffer;
+
+        struct {
+            USHORT SubstituteNameOffset;
+            USHORT  SubstituteNameLength;
+            USHORT  PrintNameOffset;
+            USHORT  PrintNameLength;
+            WCHAR  PathBuffer[1];
+        } MountPointReparseBuffer;
+
+        struct {
+            UCHAR  DataBuffer[1];
+        } GenericReparseBuffer;
+    };
+} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
+
+#define REPARSE_DATA_BUFFER_HEADER_SIZE  FIELD_OFFSET(REPARSE_DATA_BUFFER,\
+                                                      GenericReparseBuffer)
+#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE  ( 16 * 1024 )
+
+static int
+win32_read_link(HANDLE reparse_point_handle, ULONG *reparse_tag, wchar_t **target_path)
+{
+    char target_buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
+    REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER *)target_buffer;
+    DWORD n_bytes_returned;
+    const wchar_t *ptr;
+    wchar_t *buf;
+    size_t len;
+
+    if (0 == DeviceIoControl(
+        reparse_point_handle,
+        FSCTL_GET_REPARSE_POINT,
+        NULL, 0, /* in buffer */
+        target_buffer, sizeof(target_buffer),
+        &n_bytes_returned,
+        NULL)) /* we're not using OVERLAPPED_IO */
+        return -1;
+
+    if (reparse_tag)
+        *reparse_tag = rdb->ReparseTag;
+
+    if (target_path) {
+        switch (rdb->ReparseTag) {
+        case IO_REPARSE_TAG_SYMLINK:
+            /* XXX: Maybe should use SubstituteName? */
+            ptr = rdb->SymbolicLinkReparseBuffer.PathBuffer +
+                  rdb->SymbolicLinkReparseBuffer.PrintNameOffset/sizeof(WCHAR);
+            len = rdb->SymbolicLinkReparseBuffer.PrintNameLength/sizeof(WCHAR);
+            break;
+        case IO_REPARSE_TAG_MOUNT_POINT:
+            ptr = rdb->MountPointReparseBuffer.PathBuffer +
+                  rdb->MountPointReparseBuffer.SubstituteNameOffset/sizeof(WCHAR);
+            len = rdb->MountPointReparseBuffer.SubstituteNameLength/sizeof(WCHAR);
+            break;
+        default:
+            SetLastError(ERROR_REPARSE_TAG_MISMATCH); /* XXX: Proper error code? */
+            return -1;
+        }
+        buf = (wchar_t *)malloc(sizeof(wchar_t)*(len+1));
+        if (!buf) {
+            SetLastError(ERROR_OUTOFMEMORY);
+            return -1;
+        }
+        wcsncpy(buf, ptr, len);
+        buf[len] = L'\0';
+        if (wcsncmp(buf, L"\\??\\", 4) == 0)
+            buf[1] = L'\\';
+        *target_path = buf;
+    }
+
+    return 0;
+}
+#endif /* MS_WINDOWS */
+
 /* Return a dictionary corresponding to the POSIX environment table */
 #ifdef WITH_NEXT_FRAMEWORK
 /* On Darwin/MacOSX a shared library or framework has no access to
@@ -934,7 +1029,7 @@
 }
 
 static int
-attribute_data_to_stat(WIN32_FILE_ATTRIBUTE_DATA *info, struct win32_stat *result)
+attribute_data_to_stat(BY_HANDLE_FILE_INFORMATION *info, ULONG reparse_tag, struct win32_stat *result)
 {
     memset(result, 0, sizeof(*result));
     result->st_mode = attributes_to_mode(info->dwFileAttributes);
@@ -942,12 +1037,20 @@
     FILE_TIME_to_time_t_nsec(&info->ftCreationTime, &result->st_ctime, &result->st_ctime_nsec);
     FILE_TIME_to_time_t_nsec(&info->ftLastWriteTime, &result->st_mtime, &result->st_mtime_nsec);
     FILE_TIME_to_time_t_nsec(&info->ftLastAccessTime, &result->st_atime, &result->st_atime_nsec);
+    result->st_nlink = info->nNumberOfLinks;
+    result->st_ino = (((__int64)info->nFileIndexHigh)<<32) + info->nFileIndexLow;
+    if (reparse_tag == IO_REPARSE_TAG_SYMLINK) {
+        /* first clear the S_IFMT bits */
+        result->st_mode ^= (result->st_mode & 0170000);
+        /* now set the bits that make this a symlink */
+        result->st_mode |= 0120000;
+    }
 
     return 0;
 }
 
 static BOOL
-attributes_from_dir(LPCSTR pszFile, LPWIN32_FILE_ATTRIBUTE_DATA pfad)
+attributes_from_dir(LPCSTR pszFile, BY_HANDLE_FILE_INFORMATION *info, ULONG *reparse_tag)
 {
     HANDLE hFindFile;
     WIN32_FIND_DATAA FileData;
@@ -955,17 +1058,22 @@
     if (hFindFile == INVALID_HANDLE_VALUE)
         return FALSE;
     FindClose(hFindFile);
-    pfad->dwFileAttributes = FileData.dwFileAttributes;
-    pfad->ftCreationTime   = FileData.ftCreationTime;
-    pfad->ftLastAccessTime = FileData.ftLastAccessTime;
-    pfad->ftLastWriteTime  = FileData.ftLastWriteTime;
-    pfad->nFileSizeHigh    = FileData.nFileSizeHigh;
-    pfad->nFileSizeLow     = FileData.nFileSizeLow;
+    memset(info, 0, sizeof(*info));
+    *reparse_tag = 0;
+    info->dwFileAttributes = FileData.dwFileAttributes;
+    info->ftCreationTime   = FileData.ftCreationTime;
+    info->ftLastAccessTime = FileData.ftLastAccessTime;
+    info->ftLastWriteTime  = FileData.ftLastWriteTime;
+    info->nFileSizeHigh    = FileData.nFileSizeHigh;
+    info->nFileSizeLow     = FileData.nFileSizeLow;
+/*  info->nNumberOfLinks   = 1; */
+    if (FileData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
+        *reparse_tag = FileData.dwReserved0;
     return TRUE;
 }
 
 static BOOL
-attributes_from_dir_w(LPCWSTR pszFile, LPWIN32_FILE_ATTRIBUTE_DATA pfad)
+attributes_from_dir_w(LPCWSTR pszFile, BY_HANDLE_FILE_INFORMATION *info, ULONG *reparse_tag)
 {
     HANDLE hFindFile;
     WIN32_FIND_DATAW FileData;
@@ -973,178 +1081,40 @@
     if (hFindFile == INVALID_HANDLE_VALUE)
         return FALSE;
     FindClose(hFindFile);
-    pfad->dwFileAttributes = FileData.dwFileAttributes;
-    pfad->ftCreationTime   = FileData.ftCreationTime;
-    pfad->ftLastAccessTime = FileData.ftLastAccessTime;
-    pfad->ftLastWriteTime  = FileData.ftLastWriteTime;
-    pfad->nFileSizeHigh    = FileData.nFileSizeHigh;
-    pfad->nFileSizeLow     = FileData.nFileSizeLow;
+    memset(info, 0, sizeof(*info));
+    *reparse_tag = 0;
+    info->dwFileAttributes = FileData.dwFileAttributes;
+    info->ftCreationTime   = FileData.ftCreationTime;
+    info->ftLastAccessTime = FileData.ftLastAccessTime;
+    info->ftLastWriteTime  = FileData.ftLastWriteTime;
+    info->nFileSizeHigh    = FileData.nFileSizeHigh;
+    info->nFileSizeLow     = FileData.nFileSizeLow;
+/*  info->nNumberOfLinks   = 1; */
+    if (FileData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
+        *reparse_tag = FileData.dwReserved0;
     return TRUE;
 }
 
-/* About the following functions: win32_lstat, win32_lstat_w, win32_stat,
-   win32_stat_w
-
-   In Posix, stat automatically traverses symlinks and returns the stat
-   structure for the target.  In Windows, the equivalent GetFileAttributes by
-   default does not traverse symlinks and instead returns attributes for
-   the symlink.
-
-   Therefore, win32_lstat will get the attributes traditionally, and
-   win32_stat will first explicitly resolve the symlink target and then will
-   call win32_lstat on that result.
-
-   The _w represent Unicode equivalents of the aformentioned ANSI functions. */
-
-static int 
-win32_lstat(const char* path, struct win32_stat *result)
-{
-    WIN32_FILE_ATTRIBUTE_DATA info;
-    int code;
-    char *dot;
-    WIN32_FIND_DATAA find_data;
-    HANDLE find_data_handle;
-    if (!GetFileAttributesExA(path, GetFileExInfoStandard, &info)) {
-        if (GetLastError() != ERROR_SHARING_VIOLATION) {
-            /* Protocol violation: we explicitly clear errno, instead of
-               setting it to a POSIX error. Callers should use GetLastError. */
-            errno = 0;
-            return -1;
-        } else {
-            /* Could not get attributes on open file. Fall back to
-               reading the directory. */
-            if (!attributes_from_dir(path, &info)) {
-                /* Very strange. This should not fail now */
-                errno = 0;
-                return -1;
-            }
-        }
-    }
-
-    code = attribute_data_to_stat(&info, result);
-    if (code != 0)
-        return code;
-
-    /* Get WIN32_FIND_DATA structure for the path to determine if
-       it is a symlink */
-    if(info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
-        find_data_handle = FindFirstFileA(path, &find_data);
-        if(find_data_handle != INVALID_HANDLE_VALUE) {
-            if(find_data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
-                /* first clear the S_IFMT bits */
-                result->st_mode ^= (result->st_mode & 0170000);
-                /* now set the bits that make this a symlink */
-                result->st_mode |= 0120000;
-            }
-            FindClose(find_data_handle);
-        }
-    }
-
-    /* Set S_IFEXEC if it is an .exe, .bat, ... */
-    dot = strrchr(path, '.');
-    if (dot) {
-        if (stricmp(dot, ".bat") == 0 || stricmp(dot, ".cmd") == 0 ||
-            stricmp(dot, ".exe") == 0 || stricmp(dot, ".com") == 0)
-            result->st_mode |= 0111;
-    }
-    return code;
-}
-
-static int
-win32_lstat_w(const wchar_t* path, struct win32_stat *result)
-{
-    int code;
-    const wchar_t *dot;
-    WIN32_FILE_ATTRIBUTE_DATA info;
-    WIN32_FIND_DATAW find_data;
-    HANDLE find_data_handle;
-    if (!GetFileAttributesExW(path, GetFileExInfoStandard, &info)) {
-        if (GetLastError() != ERROR_SHARING_VIOLATION) {
-            /* Protocol violation: we explicitly clear errno, instead of
-               setting it to a POSIX error. Callers should use GetLastError. */
-            errno = 0;
-            return -1;
-        } else {
-            /* Could not get attributes on open file. Fall back to reading
-            the directory. */
-            if (!attributes_from_dir_w(path, &info)) {
-                /* Very strange. This should not fail now */
-                errno = 0;
-                return -1;
-            }
-        }
-    }
-    code = attribute_data_to_stat(&info, result);
-    if (code < 0)
-        return code;
-
-    /* Get WIN32_FIND_DATA structure for the path to determine if
-       it is a symlink */
-    if(info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
-        find_data_handle = FindFirstFileW(path, &find_data);
-        if(find_data_handle != INVALID_HANDLE_VALUE) {
-            if(find_data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) {
-                /* first clear the S_IFMT bits */
-                result->st_mode ^= (result->st_mode & 0170000);
-                /* now set the bits that make this a symlink */
-                result->st_mode |= 0120000;
-            }
-            FindClose(find_data_handle);
-        }
-    }
-
-    /* Set IFEXEC if it is an .exe, .bat, ... */
-    dot = wcsrchr(path, '.');
-    if (dot) {
-        if (_wcsicmp(dot, L".bat") == 0 || _wcsicmp(dot, L".cmd") == 0 ||
-            _wcsicmp(dot, L".exe") == 0 || _wcsicmp(dot, L".com") == 0)
-            result->st_mode |= 0111;
-    }
-    return code;
-}
+#ifndef SYMLOOP_MAX
+#define SYMLOOP_MAX ( 88 )
+#endif
 
-/* Grab GetFinalPathNameByHandle dynamically from kernel32 */
-static int has_GetFinalPathNameByHandle = 0;
-static DWORD (CALLBACK *Py_GetFinalPathNameByHandleA)(HANDLE, LPSTR, DWORD,
-                                                      DWORD);
-static DWORD (CALLBACK *Py_GetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD,
-                                                      DWORD);
 static int
-check_GetFinalPathNameByHandle()
-{
-    HINSTANCE hKernel32;
-    /* only recheck */
-    if (!has_GetFinalPathNameByHandle)
-    {
-        hKernel32 = GetModuleHandle("KERNEL32");
-        *(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32,
-                                                "GetFinalPathNameByHandleA");
-        *(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32,
-                                                "GetFinalPathNameByHandleW");
-        has_GetFinalPathNameByHandle = Py_GetFinalPathNameByHandleA &&
-                                       Py_GetFinalPathNameByHandleW;
-    }
-    return has_GetFinalPathNameByHandle;
-}
+win32_xstat_impl_w(const wchar_t *path, struct win32_stat *result, BOOL traverse, int depth);
 
 static int
-win32_stat(const char* path, struct win32_stat *result)
+win32_xstat_impl(const char *path, struct win32_stat *result, BOOL traverse, int depth)
 {
-    /* Traverse the symlink to the target using
-    GetFinalPathNameByHandle()
-    */
     int code;
     HANDLE hFile;
-    int buf_size;
-    char *target_path;
-    int result_length;
-    WIN32_FILE_ATTRIBUTE_DATA info;
-    
-    if(!check_GetFinalPathNameByHandle()) {
-        /* if the OS doesn't have GetFinalPathNameByHandle, it doesn't
-           have symlinks, so just fall back to the traditional behavior
-           found in lstat. */
-        return win32_lstat(path, result);
+    BY_HANDLE_FILE_INFORMATION info;
+    ULONG reparse_tag = 0;
+    wchar_t *target_path;
+    const char *dot;
+
+    if (depth > SYMLOOP_MAX) {
+        SetLastError(ERROR_CANT_RESOLVE_FILENAME); /* XXX: ELOOP? */
+        return -1;
     }
 
     hFile = CreateFileA(
@@ -1154,75 +1124,70 @@
         NULL, /* security attributes */
         OPEN_EXISTING,
         /* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */
-        FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS,
+        FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OPEN_REPARSE_POINT,
         NULL);
-    
-    if(hFile == INVALID_HANDLE_VALUE) {
+
+    if (hFile == INVALID_HANDLE_VALUE) {
         /* Either the target doesn't exist, or we don't have access to
            get a handle to it. If the former, we need to return an error.
            If the latter, we can use attributes_from_dir. */
-        if (GetLastError() != ERROR_SHARING_VIOLATION) {
-            /* Protocol violation: we explicitly clear errno, instead of
-               setting it to a POSIX error. Callers should use GetLastError. */
-            errno = 0;
+        if (GetLastError() != ERROR_SHARING_VIOLATION)
             return -1;
-        } else {
-            /* Could not get attributes on open file. Fall back to
-               reading the directory. */
-            if (!attributes_from_dir(path, &info)) {
-                /* Very strange. This should not fail now */
-                errno = 0;
+        /* Could not get attributes on open file. Fall back to
+           reading the directory. */
+        if (!attributes_from_dir(path, &info, &reparse_tag))
+            /* Very strange. This should not fail now */
+            return -1;
+        if (info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+            if (traverse) {
+                /* Should traverse, but could not open reparse point handle */
+                SetLastError(ERROR_SHARING_VIOLATION);
                 return -1;
             }
         }
-        code = attribute_data_to_stat(&info, result);
+    } else {
+        if (!GetFileInformationByHandle(hFile, &info)) {
+            CloseHandle(hFile);
+            return -1;;
+        }
+        if (info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+            code = win32_read_link(hFile, &reparse_tag, traverse ? &target_path : NULL);
+            CloseHandle(hFile);
+            if (code < 0)
+                return code;
+            if (traverse) {
+                code = win32_xstat_impl_w(target_path, result, traverse, depth + 1);
+                free(target_path);
+                return code;
+            }
+        } else
+            CloseHandle(hFile);
     }
-    else {
-        /* We have a good handle to the target, use it to determine the target
-           path name (then we'll call lstat on it). */
-        buf_size = Py_GetFinalPathNameByHandleA(hFile, 0, 0, VOLUME_NAME_DOS);
-        if(!buf_size) return -1;
-        /* Due to a slight discrepancy between GetFinalPathNameByHandleA
-           and GetFinalPathNameByHandleW, we must allocate one more byte
-           than reported. */
-        target_path = (char *)malloc((buf_size+2)*sizeof(char));
-        result_length = Py_GetFinalPathNameByHandleA(hFile, target_path,
-                                                     buf_size+1, VOLUME_NAME_DOS);
+    attribute_data_to_stat(&info, reparse_tag, result);
 
-        if(!result_length) {
-            free(target_path);
-            return -1;
-        }
-
-        if(!CloseHandle(hFile)) {
-            free(target_path);
-            return -1;
-        }
-
-        target_path[result_length] = 0;
-        code = win32_lstat(target_path, result);
-        free(target_path);
+    /* Set S_IEXEC if it is an .exe, .bat, ... */
+    dot = strrchr(path, '.');
+    if (dot) {
+        if (stricmp(dot, ".bat") == 0 || stricmp(dot, ".cmd") == 0 ||
+            stricmp(dot, ".exe") == 0 || stricmp(dot, ".com") == 0)
+            result->st_mode |= 0111;
     }
-    
-    return code;
+    return 0;
 }
 
-static int 
-win32_stat_w(const wchar_t* path, struct win32_stat *result)
+static int
+win32_xstat_impl_w(const wchar_t *path, struct win32_stat *result, BOOL traverse, int depth)
 {
-    /* Traverse the symlink to the target using GetFinalPathNameByHandle() */
     int code;
     HANDLE hFile;
-    int buf_size;
-    wchar_t *target_path;
-    int result_length;
-    WIN32_FILE_ATTRIBUTE_DATA info;
-    
-    if(!check_GetFinalPathNameByHandle()) {
-        /* If the OS doesn't have GetFinalPathNameByHandle, it doesn't have
-           symlinks, so just fall back to the traditional behavior found
-           in lstat. */
-        return win32_lstat_w(path, result);
+    BY_HANDLE_FILE_INFORMATION info;
+    ULONG reparse_tag = 0;
+	wchar_t *target_path;
+    const wchar_t *dot;
+
+    if (depth > SYMLOOP_MAX) {
+        SetLastError(ERROR_CANT_RESOLVE_FILENAME); /* XXX: ELOOP? */
+        return -1;
     }
 
     hFile = CreateFileW(
@@ -1232,58 +1197,115 @@
         NULL, /* security attributes */
         OPEN_EXISTING,
         /* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */
-        FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS,
+        FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OPEN_REPARSE_POINT,
         NULL);
 
-    if(hFile == INVALID_HANDLE_VALUE) {
+    if (hFile == INVALID_HANDLE_VALUE) {
         /* Either the target doesn't exist, or we don't have access to
            get a handle to it. If the former, we need to return an error.
            If the latter, we can use attributes_from_dir. */
-        if (GetLastError() != ERROR_SHARING_VIOLATION) {
-            /* Protocol violation: we explicitly clear errno, instead of
-               setting it to a POSIX error. Callers should use GetLastError. */
-            errno = 0;
+        if (GetLastError() != ERROR_SHARING_VIOLATION)
             return -1;
-        } else {
-            /* Could not get attributes on open file. Fall back to
-               reading the directory. */
-            if (!attributes_from_dir_w(path, &info)) {
-                /* Very strange. This should not fail now */
-                errno = 0;
+        /* Could not get attributes on open file. Fall back to
+           reading the directory. */
+        if (!attributes_from_dir_w(path, &info, &reparse_tag))
+            /* Very strange. This should not fail now */
+            return -1;
+        if (info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+            if (traverse) {
+                /* Should traverse, but could not open reparse point handle */
+                SetLastError(ERROR_SHARING_VIOLATION);
                 return -1;
             }
         }
-        code = attribute_data_to_stat(&info, result);
+    } else {
+        if (!GetFileInformationByHandle(hFile, &info)) {
+            CloseHandle(hFile);
+            return -1;;
+        }
+        if (info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+            code = win32_read_link(hFile, &reparse_tag, traverse ? &target_path : NULL);
+            CloseHandle(hFile);
+            if (code < 0)
+                return code;
+            if (traverse) {
+                code = win32_xstat_impl_w(target_path, result, traverse, depth + 1);
+                free(target_path);
+                return code;
+            }
+        } else
+            CloseHandle(hFile);
     }
-    else {
-        /* We have a good handle to the target, use it to determine the target
-           path name (then we'll call lstat on it). */
-        buf_size = Py_GetFinalPathNameByHandleW(hFile, 0, 0, VOLUME_NAME_DOS);
-        if(!buf_size)
-            return -1;
+    attribute_data_to_stat(&info, reparse_tag, result);
 
-        target_path = (wchar_t *)malloc((buf_size+1)*sizeof(wchar_t));
-        result_length = Py_GetFinalPathNameByHandleW(hFile, target_path,
-                                                buf_size, VOLUME_NAME_DOS);
-        
-        if(!result_length) {
-            free(target_path);
-            return -1;
-        }
+    /* Set S_IEXEC if it is an .exe, .bat, ... */
+    dot = wcsrchr(path, '.');
+    if (dot) {
+        if (_wcsicmp(dot, L".bat") == 0 || _wcsicmp(dot, L".cmd") == 0 ||
+            _wcsicmp(dot, L".exe") == 0 || _wcsicmp(dot, L".com") == 0)
+            result->st_mode |= 0111;
+    }
+    return 0;
+}
 
-        if(!CloseHandle(hFile)) {
-            free(target_path);
-            return -1;
-        }
+static int
+win32_xstat(const char *path, struct win32_stat *result, BOOL traverse)
+{
+    /* Protocol violation: we explicitly clear errno, instead of
+       setting it to a POSIX error. Callers should use GetLastError. */
+    int code = win32_xstat_impl(path, result, traverse, 0);
+    errno = 0;
+    return code;
+}
 
-        target_path[result_length] = 0;
-        code = win32_lstat_w(target_path, result);
-        free(target_path);
-    }
-    
+static int
+win32_xstat_w(const wchar_t *path, struct win32_stat *result, BOOL traverse)
+{
+    /* Protocol violation: we explicitly clear errno, instead of
+       setting it to a POSIX error. Callers should use GetLastError. */
+    int code = win32_xstat_impl_w(path, result, traverse, 0);
+    errno = 0;
     return code;
 }
 
+/* About the following functions: win32_lstat, win32_lstat_w, win32_stat,
+   win32_stat_w
+
+   In Posix, stat automatically traverses symlinks and returns the stat
+   structure for the target.  In Windows, the equivalent GetFileAttributes by
+   default does not traverse symlinks and instead returns attributes for
+   the symlink.
+
+   Therefore, win32_lstat will get the attributes traditionally, and
+   win32_stat will first explicitly resolve the symlink target and then will
+   call win32_lstat on that result.
+
+   The _w represent Unicode equivalents of the aformentioned ANSI functions. */
+
+static int 
+win32_lstat(const char* path, struct win32_stat *result)
+{
+    return win32_xstat(path, result, FALSE);
+}
+
+static int
+win32_lstat_w(const wchar_t* path, struct win32_stat *result)
+{
+    return win32_xstat_w(path, result, FALSE);
+}
+
+static int
+win32_stat(const char* path, struct win32_stat *result)
+{
+    return win32_xstat(path, result, TRUE);
+}
+
+static int 
+win32_stat_w(const wchar_t* path, struct win32_stat *result)
+{
+    return win32_xstat_w(path, result, TRUE);
+}
+
 static int
 win32_fstat(int file_number, struct win32_stat *result)
 {
@@ -1309,7 +1331,7 @@
     if (type == FILE_TYPE_UNKNOWN) {
         DWORD error = GetLastError();
         if (error != 0) {
-        return -1;
+            return -1;
         }
         /* else: valid but unknown file */
     }
@@ -1326,17 +1348,8 @@
         return -1;
     }
 
-    /* similar to stat() */
-    result->st_mode = attributes_to_mode(info.dwFileAttributes);
-    result->st_size = (((__int64)info.nFileSizeHigh)<<32) + info.nFileSizeLow;
-    FILE_TIME_to_time_t_nsec(&info.ftCreationTime, &result->st_ctime,
-                             &result->st_ctime_nsec);
-    FILE_TIME_to_time_t_nsec(&info.ftLastWriteTime, &result->st_mtime,
-                             &result->st_mtime_nsec);
-    FILE_TIME_to_time_t_nsec(&info.ftLastAccessTime, &result->st_atime,
-                             &result->st_atime_nsec);
+    attribute_data_to_stat(&info, 0, result);
     /* specific to fstat() */
-    result->st_nlink = info.nNumberOfLinks;
     result->st_ino = (((__int64)info.nFileIndexHigh)<<32) + info.nFileIndexLow;
     return 0;
 }
@@ -2057,7 +2070,7 @@
 static PyObject *
 posix_fsync(PyObject *self, PyObject *fdobj)
 {
-       return posix_fildes(fdobj, fsync);
+    return posix_fildes(fdobj, fsync);
 }
 #endif /* HAVE_FSYNC */
 
@@ -2075,7 +2088,7 @@
 static PyObject *
 posix_fdatasync(PyObject *self, PyObject *fdobj)
 {
-       return posix_fildes(fdobj, fdatasync);
+    return posix_fildes(fdobj, fdatasync);
 }
 #endif /* HAVE_FDATASYNC */
 
@@ -2247,6 +2260,54 @@
 }
 #endif /* HAVE_LINK */
 
+#ifdef MS_WINDOWS
+PyDoc_STRVAR(win32_link__doc__,
+"link(src, dst)\n\n\
+Create a hard link to a file.");
+
+static PyObject *
+win32_link(PyObject *self, PyObject *args)
+{
+    PyObject *osrc, *odst;
+    char *src, *dst;
+    BOOL rslt;
+
+    PyUnicodeObject *usrc, *udst;
+    if (PyArg_ParseTuple(args, "UU:link", &usrc, &udst)) {
+        Py_BEGIN_ALLOW_THREADS
+        rslt = CreateHardLinkW(PyUnicode_AS_UNICODE(udst),
+                               PyUnicode_AS_UNICODE(usrc), NULL);
+        Py_END_ALLOW_THREADS
+
+        if (rslt == 0)
+            return win32_error("link", NULL);
+
+        Py_RETURN_NONE;
+    }
+
+    /* Narrow strings also valid. */
+    PyErr_Clear();
+
+    if (!PyArg_ParseTuple(args, "O&O&:link", PyUnicode_FSConverter, &osrc,
+                          PyUnicode_FSConverter, &odst))
+        return NULL;
+
+    src = PyBytes_AsString(osrc);
+    dst = PyBytes_AsString(odst);
+
+    Py_BEGIN_ALLOW_THREADS
+    rslt = CreateHardLinkA(dst, src, NULL);
+    Py_END_ALLOW_THREADS
+
+    Py_DECREF(osrc);
+    Py_DECREF(odst);
+    if (rslt == 0)
+        return win32_error("link", NULL);
+
+    Py_RETURN_NONE;
+}
+#endif /* MS_WINDOWS */
+
 
 PyDoc_STRVAR(posix_listdir__doc__,
 "listdir([path]) -> list_of_strings\n\n\
@@ -2371,6 +2432,7 @@
     }
     strcpy(namebuf, PyBytes_AsString(opath));
     len = PyObject_Size(opath);
+    Py_DECREF(opath);
     if (len > 0) {
         char ch = namebuf[len-1];
         if (ch != SEP && ch != ALTSEP && ch != ':')
@@ -2526,7 +2588,7 @@
     if (!PyArg_ParseTuple(args, "|O&:listdir", PyUnicode_FSConverter, &oname))
         return NULL;
     if (oname == NULL) { /* Default arg: "." */
-      oname = PyBytes_FromString(".");
+        oname = PyBytes_FromString(".");
     }
     name = PyBytes_AsString(oname);
     Py_BEGIN_ALLOW_THREADS
@@ -2644,6 +2706,30 @@
     return PyBytes_FromString(outbuf);
 } /* end of posix__getfullpathname */
 
+/* Grab GetFinalPathNameByHandle dynamically from kernel32 */
+static int has_GetFinalPathNameByHandle = 0;
+static DWORD (CALLBACK *Py_GetFinalPathNameByHandleA)(HANDLE, LPSTR, DWORD,
+                                                      DWORD);
+static DWORD (CALLBACK *Py_GetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD,
+                                                      DWORD);
+static int
+check_GetFinalPathNameByHandle()
+{
+    HINSTANCE hKernel32;
+    /* only recheck */
+    if (!has_GetFinalPathNameByHandle)
+    {
+        hKernel32 = GetModuleHandle("KERNEL32");
+        *(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32,
+                                                "GetFinalPathNameByHandleA");
+        *(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32,
+                                                "GetFinalPathNameByHandleW");
+        has_GetFinalPathNameByHandle = Py_GetFinalPathNameByHandleA &&
+                                       Py_GetFinalPathNameByHandleW;
+    }
+    return has_GetFinalPathNameByHandle;
+}
+
 /* A helper function for samepath on windows */
 static PyObject *
 posix__getfinalpathname(PyObject *self, PyObject *args)
@@ -2718,14 +2804,12 @@
     if (!PyArg_ParseTuple(args, "i:_getfileinformation", &fd))
         return NULL;
 
-    if (!_PyVerify_fd(fd)) {
-        PyErr_SetString(PyExc_ValueError, "received invalid file descriptor");
-        return NULL;
-    }
+    if (!_PyVerify_fd(fd))
+        return posix_error();
 
     hFile = (HANDLE)_get_osfhandle(fd);
     if (hFile == INVALID_HANDLE_VALUE)
-        return win32_error("_getfileinformation", NULL);
+        return posix_error();
 
     if (!GetFileInformationByHandle(hFile, &info))
         return win32_error("_getfileinformation", NULL);
@@ -3141,7 +3225,7 @@
             !SystemTimeToFileTime(&now, &atime)) {
             win32_error("utime", NULL);
             goto done;
-            }
+        }
     }
     else if (!PyTuple_Check(arg) || PyTuple_Size(arg) != 2) {
         PyErr_SetString(PyExc_TypeError,
@@ -4209,9 +4293,9 @@
         for (i = 0; i < n; ++i) {
             PyObject *o = PyLong_FromLong((long)alt_grouplist[i]);
             if (o == NULL) {
-            Py_DECREF(result);
-            result = NULL;
-            break;
+                Py_DECREF(result);
+                result = NULL;
+                break;
             }
             PyList_SET_ITEM(result, i, o);
         }
@@ -5026,7 +5110,7 @@
 #endif /* HAVE_READLINK */
 
 
-#ifdef HAVE_SYMLINK
+#if defined(HAVE_SYMLINK) && !defined(MS_WINDOWS)
 PyDoc_STRVAR(posix_symlink__doc__,
 "symlink(src, dst)\n\n\
 Create a symbolic link pointing to src named dst.");
@@ -5044,43 +5128,6 @@
 "readlink(path) -> path\n\n\
 Return a string representing the path to which the symbolic link points.");
 
-/* The following structure was copied from
-   http://msdn.microsoft.com/en-us/library/ms791514.aspx as the required
-   include doesn't seem to be present in the Windows SDK (at least as included
-   with Visual Studio Express). */
-typedef struct _REPARSE_DATA_BUFFER {
-    ULONG ReparseTag;
-    USHORT ReparseDataLength;
-    USHORT Reserved;
-    union {
-        struct {
-            USHORT SubstituteNameOffset;
-            USHORT SubstituteNameLength;
-            USHORT PrintNameOffset;
-            USHORT PrintNameLength;
-            ULONG Flags;
-            WCHAR PathBuffer[1];
-        } SymbolicLinkReparseBuffer;
-
-        struct {
-            USHORT SubstituteNameOffset;
-            USHORT  SubstituteNameLength;
-            USHORT  PrintNameOffset;
-            USHORT  PrintNameLength;
-            WCHAR  PathBuffer[1];
-        } MountPointReparseBuffer;
-
-        struct {
-            UCHAR  DataBuffer[1];
-        } GenericReparseBuffer;
-    };
-} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
-
-#define REPARSE_DATA_BUFFER_HEADER_SIZE  FIELD_OFFSET(REPARSE_DATA_BUFFER,\
-                                                      GenericReparseBuffer)
-
-#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE  ( 16 * 1024 )
-
 /* Windows readlink implementation */
 static PyObject *
 win_readlink(PyObject *self, PyObject *args)
@@ -5151,7 +5198,7 @@
 
 #endif /* !defined(HAVE_READLINK) && defined(MS_WINDOWS) */
 
-#if !defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
+#if defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
 
 /* Grab CreateSymbolicLinkW dynamically from kernel32 */
 static int has_CreateSymbolicLinkW = 0;
@@ -5197,6 +5244,10 @@
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i:symlink",
         kwlist, &src, &dest, &target_is_directory))
         return NULL;
+
+    if (win32_can_symlink == 0)
+        return PyErr_Format(PyExc_OSError, "symbolic link privilege not held");
+
     if (!convert_to_unicode(&src)) { return NULL; }
     if (!convert_to_unicode(&dest)) {
         Py_DECREF(src);
@@ -5229,7 +5280,7 @@
     Py_INCREF(Py_None);
     return Py_None;
 }
-#endif /* !defined(HAVE_SYMLINK) && defined(MS_WINDOWS) */
+#endif /* defined(HAVE_SYMLINK) && defined(MS_WINDOWS) */
 
 #ifdef HAVE_TIMES
 #if defined(PYCC_VACPP) && defined(PYOS_OS2)
@@ -5610,8 +5661,10 @@
     buffer = PyBytes_FromStringAndSize((char *)NULL, size);
     if (buffer == NULL)
         return NULL;
-    if (!_PyVerify_fd(fd))
+    if (!_PyVerify_fd(fd)) {
+        Py_DECREF(buffer);
         return posix_error();
+    }
     Py_BEGIN_ALLOW_THREADS
     n = read(fd, PyBytes_AS_STRING(buffer), size);
     Py_END_ALLOW_THREADS
@@ -5638,12 +5691,14 @@
 
     if (!PyArg_ParseTuple(args, "iy*:write", &fd, &pbuf))
         return NULL;
-    if (!_PyVerify_fd(fd))
+    if (!_PyVerify_fd(fd)) {
+        PyBuffer_Release(&pbuf);
         return posix_error();
+    }
     Py_BEGIN_ALLOW_THREADS
     size = write(fd, pbuf.buf, (size_t)pbuf.len);
     Py_END_ALLOW_THREADS
-        PyBuffer_Release(&pbuf);
+    PyBuffer_Release(&pbuf);
     if (size < 0)
         return posix_error();
     return PyLong_FromSsize_t(size);
@@ -6348,38 +6403,38 @@
               size_t tablesize)
 {
     if (PyLong_Check(arg)) {
-    *valuep = PyLong_AS_LONG(arg);
-    return 1;
+        *valuep = PyLong_AS_LONG(arg);
+        return 1;
     }
     else {
-    /* look up the value in the table using a binary search */
-    size_t lo = 0;
-    size_t mid;
-    size_t hi = tablesize;
-    int cmp;
-    const char *confname;
-    if (!PyUnicode_Check(arg)) {
-        PyErr_SetString(PyExc_TypeError,
-                        "configuration names must be strings or integers");
-        return 0;
-    }
-    confname = _PyUnicode_AsString(arg);
-    if (confname == NULL)
-        return 0;
-    while (lo < hi) {
-        mid = (lo + hi) / 2;
-        cmp = strcmp(confname, table[mid].name);
-        if (cmp < 0)
-        hi = mid;
-        else if (cmp > 0)
-        lo = mid + 1;
-        else {
-        *valuep = table[mid].value;
-        return 1;
+        /* look up the value in the table using a binary search */
+        size_t lo = 0;
+        size_t mid;
+        size_t hi = tablesize;
+        int cmp;
+        const char *confname;
+        if (!PyUnicode_Check(arg)) {
+            PyErr_SetString(PyExc_TypeError,
+                "configuration names must be strings or integers");
+            return 0;
         }
-    }
-    PyErr_SetString(PyExc_ValueError, "unrecognized configuration name");
-    return 0;
+        confname = _PyUnicode_AsString(arg);
+        if (confname == NULL)
+            return 0;
+        while (lo < hi) {
+            mid = (lo + hi) / 2;
+            cmp = strcmp(confname, table[mid].name);
+            if (cmp < 0)
+                hi = mid;
+            else if (cmp > 0)
+                lo = mid + 1;
+            else {
+                *valuep = table[mid].value;
+                return 1;
+            }
+        }
+        PyErr_SetString(PyExc_ValueError, "unrecognized configuration name");
+        return 0;
     }
 }
 
@@ -6495,14 +6550,14 @@
 
     if (PyArg_ParseTuple(args, "iO&:fpathconf", &fd,
                          conv_path_confname, &name)) {
-    long limit;
+        long limit;
 
-    errno = 0;
-    limit = fpathconf(fd, name);
-    if (limit == -1 && errno != 0)
-        posix_error();
-    else
-        result = PyLong_FromLong(limit);
+        errno = 0;
+        limit = fpathconf(fd, name);
+        if (limit == -1 && errno != 0)
+            posix_error();
+        else
+            result = PyLong_FromLong(limit);
     }
     return result;
 }
@@ -6530,10 +6585,10 @@
     limit = pathconf(path, name);
     if (limit == -1 && errno != 0) {
         if (errno == EINVAL)
-        /* could be a path or name problem */
-        posix_error();
+            /* could be a path or name problem */
+            posix_error();
         else
-        posix_error_with_filename(path);
+            posix_error_with_filename(path);
     }
     else
         result = PyLong_FromLong(limit);
@@ -6714,7 +6769,7 @@
     PyObject *result = NULL;
     int name;
     char buffer[255];
-        int len;
+    int len;
 
     if (!PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name))
         return NULL;
@@ -7329,21 +7384,21 @@
                              sizeof(posix_constants_pathconf)
                                / sizeof(struct constdef),
                              "pathconf_names", module))
-    return -1;
+        return -1;
 #endif
 #ifdef HAVE_CONFSTR
     if (setup_confname_table(posix_constants_confstr,
                              sizeof(posix_constants_confstr)
                                / sizeof(struct constdef),
                              "confstr_names", module))
-    return -1;
+        return -1;
 #endif
 #ifdef HAVE_SYSCONF
     if (setup_confname_table(posix_constants_sysconf,
                              sizeof(posix_constants_sysconf)
                                / sizeof(struct constdef),
                              "sysconf_names", module))
-    return -1;
+        return -1;
 #endif
     return 0;
 }
@@ -7456,10 +7511,10 @@
 {
     double loadavg[3];
     if (getloadavg(loadavg, 3)!=3) {
-    PyErr_SetString(PyExc_OSError, "Load averages are unobtainable");
-    return NULL;
+        PyErr_SetString(PyExc_OSError, "Load averages are unobtainable");
+        return NULL;
     } else
-    return Py_BuildValue("ddd", loadavg[0], loadavg[1], loadavg[2]);
+        return Py_BuildValue("ddd", loadavg[0], loadavg[1], loadavg[2]);
 }
 #endif
 
@@ -7747,13 +7802,13 @@
     {"rmdir",           posix_rmdir, METH_VARARGS, posix_rmdir__doc__},
     {"stat",            posix_stat, METH_VARARGS, posix_stat__doc__},
     {"stat_float_times", stat_float_times, METH_VARARGS, stat_float_times__doc__},
-#ifdef HAVE_SYMLINK
+#if defined(HAVE_SYMLINK) && !defined(MS_WINDOWS)
     {"symlink",         posix_symlink, METH_VARARGS, posix_symlink__doc__},
 #endif /* HAVE_SYMLINK */
-#if !defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
+#if defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
     {"symlink", (PyCFunction)win_symlink, METH_VARARGS | METH_KEYWORDS,
-                win_symlink__doc__},
-#endif /* !defined(HAVE_SYMLINK) && defined(MS_WINDOWS) */
+                 win_symlink__doc__},
+#endif /* defined(HAVE_SYMLINK) && defined(MS_WINDOWS) */
 #ifdef HAVE_SYSTEM
     {"system",          posix_system, METH_VARARGS, posix_system__doc__},
 #endif
@@ -7829,6 +7884,7 @@
 #ifdef MS_WINDOWS
     {"startfile",       win32_startfile, METH_VARARGS, win32_startfile__doc__},
     {"kill",    win32_kill, METH_VARARGS, win32_kill__doc__},
+    {"link",    win32_link, METH_VARARGS, win32_link__doc__},
 #endif
 #ifdef HAVE_SETUID
     {"setuid",          posix_setuid, METH_VARARGS, posix_setuid__doc__},
@@ -8066,6 +8122,35 @@
 }
 #endif
 
+#if defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
+static int
+enable_symlink()
+{
+    HANDLE tok;
+    TOKEN_PRIVILEGES tok_priv;
+    LUID luid;
+    int meth_idx = 0;
+
+    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &tok))
+        return 0;
+
+    if (!LookupPrivilegeValue(NULL, SE_CREATE_SYMBOLIC_LINK_NAME, &luid))
+        return 0;
+
+    tok_priv.PrivilegeCount = 1;
+    tok_priv.Privileges[0].Luid = luid;
+    tok_priv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+    if (!AdjustTokenPrivileges(tok, FALSE, &tok_priv,
+                               sizeof(TOKEN_PRIVILEGES),
+                               (PTOKEN_PRIVILEGES) NULL, (PDWORD) NULL))
+        return 0;
+
+    /* ERROR_NOT_ALL_ASSIGNED returned when the privilege can't be assigned. */
+    return GetLastError() == ERROR_NOT_ALL_ASSIGNED ? 0 : 1;
+}
+#endif /* defined(HAVE_SYMLINK) && defined(MS_WINDOWS) */
+
 static int
 all_ins(PyObject *d)
 {
@@ -8327,6 +8412,10 @@
 {
     PyObject *m, *v;
 
+#if defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
+    win32_can_symlink = enable_symlink();
+#endif
+
     m = PyModule_Create(&posixmodule);
     if (m == NULL)
         return NULL;

Modified: python/branches/py3k-cdecimal/Modules/pwdmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/pwdmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/pwdmodule.c	Sun Jan  2 13:18:37 2011
@@ -2,7 +2,6 @@
 /* UNIX password file access module */
 
 #include "Python.h"
-#include "structseq.h"
 
 #include <sys/types.h>
 #include <pwd.h>

Modified: python/branches/py3k-cdecimal/Modules/pyexpat.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/pyexpat.c	(original)
+++ python/branches/py3k-cdecimal/Modules/pyexpat.c	Sun Jan  2 13:18:37 2011
@@ -1215,11 +1215,12 @@
 }
 
 static int
-handlername2int(const char *name)
+handlername2int(PyObject *name)
 {
     int i;
     for (i = 0; handler_info[i].name != NULL; i++) {
-        if (strcmp(name, handler_info[i].name) == 0) {
+        if (PyUnicode_CompareWithASCIIString(
+                name, handler_info[i].name) == 0) {
             return i;
         }
     }
@@ -1237,13 +1238,13 @@
 static PyObject *
 xmlparse_getattro(xmlparseobject *self, PyObject *nameobj)
 {
-    char *name = "";
+    Py_UNICODE *name;
     int handlernum = -1;
 
-    if (PyUnicode_Check(nameobj))
-        name = _PyUnicode_AsString(nameobj);
+    if (!PyUnicode_Check(nameobj))
+        goto generic;
 
-    handlernum = handlername2int(name);
+    handlernum = handlername2int(nameobj);
 
     if (handlernum != -1) {
         PyObject *result = self->handlers[handlernum];
@@ -1252,46 +1253,48 @@
         Py_INCREF(result);
         return result;
     }
+
+    name = PyUnicode_AS_UNICODE(nameobj);
     if (name[0] == 'E') {
-        if (strcmp(name, "ErrorCode") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "ErrorCode") == 0)
             return PyLong_FromLong((long)
                                   XML_GetErrorCode(self->itself));
-        if (strcmp(name, "ErrorLineNumber") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "ErrorLineNumber") == 0)
             return PyLong_FromLong((long)
                                   XML_GetErrorLineNumber(self->itself));
-        if (strcmp(name, "ErrorColumnNumber") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "ErrorColumnNumber") == 0)
             return PyLong_FromLong((long)
                                   XML_GetErrorColumnNumber(self->itself));
-        if (strcmp(name, "ErrorByteIndex") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "ErrorByteIndex") == 0)
             return PyLong_FromLong((long)
                                   XML_GetErrorByteIndex(self->itself));
     }
     if (name[0] == 'C') {
-        if (strcmp(name, "CurrentLineNumber") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "CurrentLineNumber") == 0)
             return PyLong_FromLong((long)
                                   XML_GetCurrentLineNumber(self->itself));
-        if (strcmp(name, "CurrentColumnNumber") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "CurrentColumnNumber") == 0)
             return PyLong_FromLong((long)
                                   XML_GetCurrentColumnNumber(self->itself));
-        if (strcmp(name, "CurrentByteIndex") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "CurrentByteIndex") == 0)
             return PyLong_FromLong((long)
                                   XML_GetCurrentByteIndex(self->itself));
     }
     if (name[0] == 'b') {
-        if (strcmp(name, "buffer_size") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "buffer_size") == 0)
             return PyLong_FromLong((long) self->buffer_size);
-        if (strcmp(name, "buffer_text") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "buffer_text") == 0)
             return get_pybool(self->buffer != NULL);
-        if (strcmp(name, "buffer_used") == 0)
+        if (PyUnicode_CompareWithASCIIString(nameobj, "buffer_used") == 0)
             return PyLong_FromLong((long) self->buffer_used);
     }
-    if (strcmp(name, "namespace_prefixes") == 0)
+    if (PyUnicode_CompareWithASCIIString(nameobj, "namespace_prefixes") == 0)
         return get_pybool(self->ns_prefixes);
-    if (strcmp(name, "ordered_attributes") == 0)
+    if (PyUnicode_CompareWithASCIIString(nameobj, "ordered_attributes") == 0)
         return get_pybool(self->ordered_attributes);
-    if (strcmp(name, "specified_attributes") == 0)
+    if (PyUnicode_CompareWithASCIIString(nameobj, "specified_attributes") == 0)
         return get_pybool((long) self->specified_attributes);
-    if (strcmp(name, "intern") == 0) {
+    if (PyUnicode_CompareWithASCIIString(nameobj, "intern") == 0) {
         if (self->intern == NULL) {
             Py_INCREF(Py_None);
             return Py_None;
@@ -1301,7 +1304,7 @@
             return self->intern;
         }
     }
-
+  generic:
     return PyObject_GenericGetAttr((PyObject*)self, nameobj);
 }
 
@@ -1352,7 +1355,7 @@
 }
 
 static int
-sethandler(xmlparseobject *self, const char *name, PyObject* v)
+sethandler(xmlparseobject *self, PyObject *name, PyObject* v)
 {
     int handlernum = handlername2int(name);
     if (handlernum >= 0) {
@@ -1388,14 +1391,15 @@
 }
 
 static int
-xmlparse_setattr(xmlparseobject *self, char *name, PyObject *v)
+xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
 {
     /* Set attribute 'name' to value 'v'. v==NULL means delete */
     if (v == NULL) {
         PyErr_SetString(PyExc_RuntimeError, "Cannot delete attribute");
         return -1;
     }
-    if (strcmp(name, "buffer_text") == 0) {
+    assert(PyUnicode_Check(name));
+    if (PyUnicode_CompareWithASCIIString(name, "buffer_text") == 0) {
         if (PyObject_IsTrue(v)) {
             if (self->buffer == NULL) {
                 self->buffer = malloc(self->buffer_size);
@@ -1414,7 +1418,7 @@
         }
         return 0;
     }
-    if (strcmp(name, "namespace_prefixes") == 0) {
+    if (PyUnicode_CompareWithASCIIString(name, "namespace_prefixes") == 0) {
         if (PyObject_IsTrue(v))
             self->ns_prefixes = 1;
         else
@@ -1422,14 +1426,14 @@
         XML_SetReturnNSTriplet(self->itself, self->ns_prefixes);
         return 0;
     }
-    if (strcmp(name, "ordered_attributes") == 0) {
+    if (PyUnicode_CompareWithASCIIString(name, "ordered_attributes") == 0) {
         if (PyObject_IsTrue(v))
             self->ordered_attributes = 1;
         else
             self->ordered_attributes = 0;
         return 0;
     }
-    if (strcmp(name, "specified_attributes") == 0) {
+    if (PyUnicode_CompareWithASCIIString(name, "specified_attributes") == 0) {
         if (PyObject_IsTrue(v))
             self->specified_attributes = 1;
         else
@@ -1437,7 +1441,7 @@
         return 0;
     }
 
-    if (strcmp(name, "buffer_size") == 0) {
+    if (PyUnicode_CompareWithASCIIString(name, "buffer_size") == 0) {
       long new_buffer_size;
       if (!PyLong_Check(v)) {
         PyErr_SetString(PyExc_TypeError, "buffer_size must be an integer");
@@ -1480,7 +1484,7 @@
       return 0;
     }
 
-    if (strcmp(name, "CharacterDataHandler") == 0) {
+    if (PyUnicode_CompareWithASCIIString(name, "CharacterDataHandler") == 0) {
         /* If we're changing the character data handler, flush all
          * cached data with the old handler.  Not sure there's a
          * "right" thing to do, though, but this probably won't
@@ -1492,7 +1496,7 @@
     if (sethandler(self, name, v)) {
         return 0;
     }
-    PyErr_SetString(PyExc_AttributeError, name);
+    PyErr_SetObject(PyExc_AttributeError, name);
     return -1;
 }
 
@@ -1524,7 +1528,7 @@
         (destructor)xmlparse_dealloc,   /*tp_dealloc*/
         (printfunc)0,           /*tp_print*/
         0,                      /*tp_getattr*/
-        (setattrfunc)xmlparse_setattr,  /*tp_setattr*/
+        0,  /*tp_setattr*/
         0,                      /*tp_reserved*/
         (reprfunc)0,            /*tp_repr*/
         0,                      /*tp_as_number*/
@@ -1534,7 +1538,7 @@
         (ternaryfunc)0,         /*tp_call*/
         (reprfunc)0,            /*tp_str*/
         (getattrofunc)xmlparse_getattro, /* tp_getattro */
-        0,              /* tp_setattro */
+        (setattrofunc)xmlparse_setattro,              /* tp_setattro */
         0,              /* tp_as_buffer */
         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
         Xmlparsetype__doc__, /* tp_doc - Documentation string */

Modified: python/branches/py3k-cdecimal/Modules/readline.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/readline.c	(original)
+++ python/branches/py3k-cdecimal/Modules/readline.c	Sun Jan  2 13:18:37 2011
@@ -889,6 +889,14 @@
         Py_FatalError("not enough memory to save locale");
 #endif
 
+#ifdef __APPLE__
+    /* the libedit readline emulation resets key bindings etc 
+     * when calling rl_initialize.  So call it upfront
+     */
+    if (using_libedit_emulation)
+        rl_initialize();
+#endif /* __APPLE__ */
+
     using_history();
 
     rl_readline_name = "python";
@@ -920,8 +928,13 @@
      * XXX: A bug in the readline-2.2 library causes a memory leak
      * inside this function.  Nothing we can do about it.
      */
-    rl_initialize();
-
+#ifdef __APPLE__
+    if (using_libedit_emulation)
+	rl_read_init_file(NULL);
+    else
+#endif /* __APPLE__ */
+        rl_initialize();
+    
     RESTORE_LOCALE(saved_locale)
 }
 

Modified: python/branches/py3k-cdecimal/Modules/resource.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/resource.c	(original)
+++ python/branches/py3k-cdecimal/Modules/resource.c	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,5 @@
 
 #include "Python.h"
-#include "structseq.h"
 #include <sys/resource.h>
 #include <sys/time.h>
 #include <string.h>

Modified: python/branches/py3k-cdecimal/Modules/signalmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/signalmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/signalmodule.c	Sun Jan  2 13:18:37 2011
@@ -4,7 +4,6 @@
 /* XXX Signals should be recorded per thread, now we have thread state. */
 
 #include "Python.h"
-#include "intrcheck.h"
 
 #ifdef MS_WINDOWS
 #include <Windows.h>

Modified: python/branches/py3k-cdecimal/Modules/socketmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/socketmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/socketmodule.c	Sun Jan  2 13:18:37 2011
@@ -1406,9 +1406,9 @@
         {
             struct sockaddr_hci *addr = (struct sockaddr_hci *)addr_ret;
 #if defined(__NetBSD__) || defined(__DragonFly__)
-			char *straddr = PyBytes_AS_STRING(args);
+                        char *straddr = PyBytes_AS_STRING(args);
 
-			_BT_HCI_MEMB(addr, family) = AF_BLUETOOTH;
+                        _BT_HCI_MEMB(addr, family) = AF_BLUETOOTH;
             if (straddr == NULL) {
                 PyErr_SetString(socket_error, "getsockaddrarg: "
                     "wrong format");
@@ -4022,8 +4022,10 @@
         pptr = pbuf;
     } else if (PyUnicode_Check(pobj)) {
         pptr = _PyUnicode_AsString(pobj);
+        if (pptr == NULL)
+            goto err;
     } else if (PyBytes_Check(pobj)) {
-        pptr = PyBytes_AsString(pobj);
+        pptr = PyBytes_AS_STRING(pobj);
     } else if (pobj == Py_None) {
         pptr = (char *)NULL;
     } else {
@@ -4358,6 +4360,7 @@
 PySocketModule_APIObject PySocketModuleAPI =
 {
     &sock_type,
+    NULL,
     NULL
 };
 
@@ -4425,6 +4428,7 @@
                                         socket_error, NULL);
     if (socket_timeout == NULL)
         return NULL;
+    PySocketModuleAPI.timeout_error = socket_timeout;
     Py_INCREF(socket_timeout);
     PyModule_AddObject(m, "timeout", socket_timeout);
     Py_INCREF((PyObject *)&sock_type);

Modified: python/branches/py3k-cdecimal/Modules/socketmodule.h
==============================================================================
--- python/branches/py3k-cdecimal/Modules/socketmodule.h	(original)
+++ python/branches/py3k-cdecimal/Modules/socketmodule.h	Sun Jan  2 13:18:37 2011
@@ -196,6 +196,7 @@
 typedef struct {
     PyTypeObject *Sock_Type;
     PyObject *error;
+    PyObject *timeout_error;
 } PySocketModule_APIObject;
 
 #define PySocketModule_ImportModuleAndAPI() PyCapsule_Import(PySocket_CAPSULE_NAME, 1)

Modified: python/branches/py3k-cdecimal/Modules/spwdmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/spwdmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/spwdmodule.c	Sun Jan  2 13:18:37 2011
@@ -4,7 +4,6 @@
 /* For info also see http://www.unixpapa.com/incnote/passwd.html */
 
 #include "Python.h"
-#include "structseq.h"
 
 #include <sys/types.h>
 #ifdef HAVE_SHADOW_H

Modified: python/branches/py3k-cdecimal/Modules/symtablemodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/symtablemodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/symtablemodule.c	Sun Jan  2 13:18:37 2011
@@ -1,7 +1,6 @@
 #include "Python.h"
 
 #include "code.h"
-#include "compile.h"
 #include "Python-ast.h"
 #include "symtable.h"
 

Modified: python/branches/py3k-cdecimal/Modules/syslogmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/syslogmodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/syslogmodule.c	Sun Jan  2 13:18:37 2011
@@ -68,9 +68,9 @@
      * is optional.
      */
 
-    Py_ssize_t argv_len;
+    Py_ssize_t argv_len, scriptlen;
     PyObject *scriptobj;
-    char *atslash;
+    Py_UNICODE *atslash, *atstart;
     PyObject *argv = PySys_GetObject("argv");
 
     if (argv == NULL) {
@@ -90,13 +90,16 @@
     if (!PyUnicode_Check(scriptobj)) {
         return(NULL);
     }
-    if (PyUnicode_GET_SIZE(scriptobj) == 0) {
+    scriptlen = PyUnicode_GET_SIZE(scriptobj);
+    if (scriptlen == 0) {
         return(NULL);
     }
 
-    atslash = strrchr(_PyUnicode_AsString(scriptobj), SEP);
+    atstart = PyUnicode_AS_UNICODE(scriptobj);
+    atslash = Py_UNICODE_strrchr(atstart, SEP);
     if (atslash) {
-        return(PyUnicode_FromString(atslash + 1));
+        return(PyUnicode_FromUnicode(atslash + 1,
+                                     scriptlen - (atslash - atstart) - 1));
     } else {
         Py_INCREF(scriptobj);
         return(scriptobj);
@@ -113,6 +116,7 @@
     long facility = LOG_USER;
     PyObject *new_S_ident_o = NULL;
     static char *keywords[] = {"ident", "logoption", "facility", 0};
+    char *ident = NULL;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds,
                           "|Ull:openlog", keywords, &new_S_ident_o, &logopt, &facility))
@@ -120,12 +124,12 @@
 
     if (new_S_ident_o) {
         Py_INCREF(new_S_ident_o);
-        }
+    }
 
     /*  get sys.argv[0] or NULL if we can't for some reason  */
     if (!new_S_ident_o) {
         new_S_ident_o = syslog_get_argv();
-        }
+    }
 
     Py_XDECREF(S_ident_o);
     S_ident_o = new_S_ident_o;
@@ -134,8 +138,13 @@
      * make a copy, and syslog(3) later uses it.  We can't garbagecollect it
      * If NULL, just let openlog figure it out (probably using C argv[0]).
      */
+    if (S_ident_o) {
+        ident = _PyUnicode_AsString(S_ident_o);
+        if (ident == NULL)
+            return NULL;
+    }
 
-    openlog(S_ident_o ? _PyUnicode_AsString(S_ident_o) : NULL, logopt, facility);
+    openlog(ident, logopt, facility);
     S_log_open = 1;
 
     Py_INCREF(Py_None);

Modified: python/branches/py3k-cdecimal/Modules/timemodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/timemodule.c	(original)
+++ python/branches/py3k-cdecimal/Modules/timemodule.c	Sun Jan  2 13:18:37 2011
@@ -2,7 +2,6 @@
 /* Time module */
 
 #include "Python.h"
-#include "structseq.h"
 #include "_time.h"
 
 #define TZNAME_ENCODING "utf-8"
@@ -716,7 +715,7 @@
 }
 
 PyDoc_STRVAR(tzset_doc,
-"tzset(zone)\n\
+"tzset()\n\
 \n\
 Initialize, or reinitialize, the local timezone to the value stored in\n\
 os.environ['TZ']. The TZ environment variable should be specified in\n\

Modified: python/branches/py3k-cdecimal/Modules/unicodedata.c
==============================================================================
--- python/branches/py3k-cdecimal/Modules/unicodedata.c	(original)
+++ python/branches/py3k-cdecimal/Modules/unicodedata.c	Sun Jan  2 13:18:37 2011
@@ -684,10 +684,14 @@
       comb = 0;
       while (i1 < end) {
           int comb1 = _getrecord_ex(*i1)->combining;
-          if (comb && (comb1 == 0 || comb == comb1)) {
-              /* Character is blocked. */
-              i1++;
-              continue;
+          if (comb) {
+              if (comb1 == 0)
+                  break;
+              if (comb >= comb1) {
+                  /* Character is blocked. */
+                  i1++;
+                  continue;
+              }
           }
           l = find_nfc_index(self, nfc_last, *i1);
           /* *i1 cannot be combined with *i. If *i1
@@ -711,6 +715,7 @@
           /* Replace the original character. */
           *i = code;
           /* Mark the second character unused. */
+          assert(cskipped < 20);
           skipped[cskipped++] = i1;
           i1++;
           f = find_nfc_index(self, nfc_first, *i);

Modified: python/branches/py3k-cdecimal/Objects/bytearrayobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/bytearrayobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/bytearrayobject.c	Sun Jan  2 13:18:37 2011
@@ -389,7 +389,7 @@
     }
     else if (PySlice_Check(index)) {
         Py_ssize_t start, stop, step, slicelength, cur, i;
-        if (PySlice_GetIndicesEx((PySliceObject *)index,
+        if (PySlice_GetIndicesEx(index,
                                  PyByteArray_GET_SIZE(self),
                                  &start, &stop, &step, &slicelength) < 0) {
             return NULL;
@@ -573,7 +573,7 @@
         }
     }
     else if (PySlice_Check(index)) {
-        if (PySlice_GetIndicesEx((PySliceObject *)index,
+        if (PySlice_GetIndicesEx(index,
                                  PyByteArray_GET_SIZE(self),
                                  &start, &stop, &step, &slicelen) < 0) {
             return -1;
@@ -589,7 +589,7 @@
         needed = 0;
     }
     else if (values == (PyObject *)self || !PyByteArray_Check(values)) {
-        /* Make a copy an call this function recursively */
+        /* Make a copy and call this function recursively */
         int err;
         values = PyByteArray_FromObject(values);
         if (values == NULL)

Modified: python/branches/py3k-cdecimal/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/bytesobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/bytesobject.c	Sun Jan  2 13:18:37 2011
@@ -911,7 +911,7 @@
         char* result_buf;
         PyObject* result;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item,
+        if (PySlice_GetIndicesEx(item,
                          PyBytes_GET_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return NULL;

Modified: python/branches/py3k-cdecimal/Objects/complexobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/complexobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/complexobject.c	Sun Jan  2 13:18:37 2011
@@ -324,10 +324,11 @@
     op->ob_type->tp_free(op);
 }
 
-
 static PyObject *
-complex_format(PyComplexObject *v, int precision, char format_code)
+complex_repr(PyComplexObject *v)
 {
+    int precision = 0;
+    char format_code = 'r';
     PyObject *result = NULL;
     Py_ssize_t len;
 
@@ -344,6 +345,8 @@
     char *tail = "";
 
     if (v->cval.real == 0. && copysign(1.0, v->cval.real)==1.0) {
+        /* Real part is +0: just output the imaginary part and do not
+           include parens. */
         re = "";
         im = PyOS_double_to_string(v->cval.imag, format_code,
                                    precision, 0, NULL);
@@ -352,7 +355,8 @@
             goto done;
         }
     } else {
-        /* Format imaginary part with sign, real part without */
+        /* Format imaginary part with sign, real part without. Include
+           parens in the result. */
         pre = PyOS_double_to_string(v->cval.real, format_code,
                                     precision, 0, NULL);
         if (!pre) {
@@ -371,7 +375,7 @@
         tail = ")";
     }
     /* Alloc the final buffer. Add one for the "j" in the format string,
-       and one for the trailing zero. */
+       and one for the trailing zero byte. */
     len = strlen(lead) + strlen(re) + strlen(im) + strlen(tail) + 2;
     buf = PyMem_Malloc(len);
     if (!buf) {
@@ -388,12 +392,6 @@
     return result;
 }
 
-static PyObject *
-complex_repr(PyComplexObject *v)
-{
-    return complex_format(v, 0, 'r');
-}
-
 static Py_hash_t
 complex_hash(PyComplexObject *v)
 {
@@ -766,24 +764,30 @@
     char *end;
     double x=0.0, y=0.0, z;
     int got_bracket=0;
-    char *s_buffer = NULL;
+    PyObject *s_buffer = NULL;
     Py_ssize_t len;
 
     if (PyUnicode_Check(v)) {
-        s_buffer = (char *)PyMem_MALLOC(PyUnicode_GET_SIZE(v) + 1);
+        Py_ssize_t i, buflen = PyUnicode_GET_SIZE(v);
+        Py_UNICODE *bufptr;
+        s_buffer = PyUnicode_TransformDecimalToASCII(
+            PyUnicode_AS_UNICODE(v), buflen);
         if (s_buffer == NULL)
-            return PyErr_NoMemory();
-        if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v),
-                                    PyUnicode_GET_SIZE(v),
-                                    s_buffer,
-                                    NULL))
+            return NULL;
+        /* Replace non-ASCII whitespace with ' ' */
+        bufptr = PyUnicode_AS_UNICODE(s_buffer);
+        for (i = 0; i < buflen; i++) {
+            Py_UNICODE ch = bufptr[i];
+            if (ch > 127 && Py_UNICODE_ISSPACE(ch))
+                bufptr[i] = ' ';
+        }
+        s = _PyUnicode_AsStringAndSize(s_buffer, &len);
+        if (s == NULL)
             goto error;
-        s = s_buffer;
-        len = strlen(s);
     }
     else if (PyObject_AsCharBuffer(v, &s, &len)) {
         PyErr_SetString(PyExc_TypeError,
-                        "complex() arg is not a string");
+                        "complex() argument must be a string or a number");
         return NULL;
     }
 
@@ -894,16 +898,14 @@
     if (s-start != len)
         goto parse_error;
 
-    if (s_buffer)
-        PyMem_FREE(s_buffer);
+    Py_XDECREF(s_buffer);
     return complex_subtype_from_doubles(type, x, y);
 
   parse_error:
     PyErr_SetString(PyExc_ValueError,
                     "complex() arg is a malformed string");
   error:
-    if (s_buffer)
-        PyMem_FREE(s_buffer);
+    Py_XDECREF(s_buffer);
     return NULL;
 }
 

Modified: python/branches/py3k-cdecimal/Objects/descrobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/descrobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/descrobject.c	Sun Jan  2 13:18:37 2011
@@ -710,19 +710,19 @@
 static PyObject *
 proxy_keys(proxyobject *pp)
 {
-    return PyMapping_Keys(pp->dict);
+    return PyObject_CallMethod(pp->dict, "keys", NULL);
 }
 
 static PyObject *
 proxy_values(proxyobject *pp)
 {
-    return PyMapping_Values(pp->dict);
+    return PyObject_CallMethod(pp->dict, "values", NULL);
 }
 
 static PyObject *
 proxy_items(proxyobject *pp)
 {
-    return PyMapping_Items(pp->dict);
+    return PyObject_CallMethod(pp->dict, "items", NULL);
 }
 
 static PyObject *
@@ -766,6 +766,12 @@
     return PyObject_Str(pp->dict);
 }
 
+static PyObject *
+proxy_repr(proxyobject *pp)
+{
+    return PyUnicode_FromFormat("dict_proxy(%R)", pp->dict);
+}
+
 static int
 proxy_traverse(PyObject *self, visitproc visit, void *arg)
 {
@@ -791,7 +797,7 @@
     0,                                          /* tp_getattr */
     0,                                          /* tp_setattr */
     0,                                          /* tp_reserved */
-    0,                                          /* tp_repr */
+    (reprfunc)proxy_repr,                       /* tp_repr */
     0,                                          /* tp_as_number */
     &proxy_as_sequence,                         /* tp_as_sequence */
     &proxy_as_mapping,                          /* tp_as_mapping */
@@ -1190,7 +1196,7 @@
         PyErr_SetString(PyExc_AttributeError, "unreadable attribute");
         return NULL;
     }
-    return PyObject_CallFunction(gs->prop_get, "(O)", obj);
+    return PyObject_CallFunctionObjArgs(gs->prop_get, obj, NULL);
 }
 
 static int
@@ -1211,9 +1217,9 @@
         return -1;
     }
     if (value == NULL)
-        res = PyObject_CallFunction(func, "(O)", obj);
+        res = PyObject_CallFunctionObjArgs(func, obj, NULL);
     else
-        res = PyObject_CallFunction(func, "(OO)", obj, value);
+        res = PyObject_CallFunctionObjArgs(func, obj, value, NULL);
     if (res == NULL)
         return -1;
     Py_DECREF(res);

Modified: python/branches/py3k-cdecimal/Objects/floatobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/floatobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/floatobject.c	Sun Jan  2 13:18:37 2011
@@ -5,7 +5,6 @@
    for any kind of float exception without losing portability. */
 
 #include "Python.h"
-#include "structseq.h"
 
 #include <ctype.h>
 #include <float.h>
@@ -175,22 +174,30 @@
 {
     const char *s, *last, *end;
     double x;
-    char buffer[256]; /* for errors */
-    char *s_buffer = NULL;
+    PyObject *s_buffer = NULL;
     Py_ssize_t len;
     PyObject *result = NULL;
 
     if (PyUnicode_Check(v)) {
-        s_buffer = (char *)PyMem_MALLOC(PyUnicode_GET_SIZE(v)+1);
+        Py_ssize_t i, buflen = PyUnicode_GET_SIZE(v);
+        Py_UNICODE *bufptr;
+        s_buffer = PyUnicode_TransformDecimalToASCII(
+            PyUnicode_AS_UNICODE(v), buflen);
         if (s_buffer == NULL)
-            return PyErr_NoMemory();
-        if (PyUnicode_EncodeDecimal(PyUnicode_AS_UNICODE(v),
-                                    PyUnicode_GET_SIZE(v),
-                                    s_buffer,
-                                    NULL))
-            goto error;
-        s = s_buffer;
-        len = strlen(s);
+            return NULL;
+        /* Replace non-ASCII whitespace with ' ' */
+        bufptr = PyUnicode_AS_UNICODE(s_buffer);
+        for (i = 0; i < buflen; i++) {
+            Py_UNICODE ch = bufptr[i];
+            if (ch > 127 && Py_UNICODE_ISSPACE(ch))
+                bufptr[i] = ' ';
+        }
+        s = _PyUnicode_AsStringAndSize(s_buffer, &len);
+        if (s == NULL) {
+            Py_DECREF(s_buffer);
+            return NULL;
+        }
+        last = s + len;
     }
     else if (PyObject_AsCharBuffer(v, &s, &len)) {
         PyErr_SetString(PyExc_TypeError,
@@ -198,29 +205,27 @@
         return NULL;
     }
     last = s + len;
-
-    while (Py_ISSPACE(*s))
+    /* strip space */
+    while (s < last && Py_ISSPACE(*s))
         s++;
+    while (s < last - 1 && Py_ISSPACE(last[-1]))
+        last--;
     /* We don't care about overflow or underflow.  If the platform
      * supports them, infinities and signed zeroes (on underflow) are
      * fine. */
     x = PyOS_string_to_double(s, (char **)&end, NULL);
-    if (x == -1.0 && PyErr_Occurred())
-        goto error;
-    while (Py_ISSPACE(*end))
-        end++;
-    if (end == last)
-        result = PyFloat_FromDouble(x);
-    else {
-        PyOS_snprintf(buffer, sizeof(buffer),
-                      "invalid literal for float(): %.200s", s);
-        PyErr_SetString(PyExc_ValueError, buffer);
+    if (end != last) {
+        PyErr_Format(PyExc_ValueError,
+                     "could not convert string to float: "
+                     "%R", v);
         result = NULL;
     }
+    else if (x == -1.0 && PyErr_Occurred())
+        result = NULL;
+    else
+        result = PyFloat_FromDouble(x);
 
-  error:
-    if (s_buffer)
-        PyMem_FREE(s_buffer);
+    Py_XDECREF(s_buffer);
     return result;
 }
 
@@ -570,13 +575,11 @@
     double a,b;
     CONVERT_TO_DOUBLE(v, a);
     CONVERT_TO_DOUBLE(w, b);
-#ifdef Py_NAN
     if (b == 0.0) {
         PyErr_SetString(PyExc_ZeroDivisionError,
                         "float division by zero");
         return NULL;
     }
-#endif
     PyFPE_START_PROTECT("divide", return 0)
     a = a / b;
     PyFPE_END_PROTECT(a)
@@ -590,19 +593,24 @@
     double mod;
     CONVERT_TO_DOUBLE(v, vx);
     CONVERT_TO_DOUBLE(w, wx);
-#ifdef Py_NAN
     if (wx == 0.0) {
         PyErr_SetString(PyExc_ZeroDivisionError,
                         "float modulo");
         return NULL;
     }
-#endif
     PyFPE_START_PROTECT("modulo", return 0)
     mod = fmod(vx, wx);
-    /* note: checking mod*wx < 0 is incorrect -- underflows to
-       0 if wx < sqrt(smallest nonzero double) */
-    if (mod && ((wx < 0) != (mod < 0))) {
-        mod += wx;
+    if (mod) {
+        /* ensure the remainder has the same sign as the denominator */
+        if ((wx < 0) != (mod < 0)) {
+            mod += wx;
+        }
+    }
+    else {
+        /* the remainder is zero, and in the presence of signed zeroes
+           fmod returns different results across platforms; ensure
+           it has the same sign as the denominator. */
+        mod = copysign(0.0, wx);
     }
     PyFPE_END_PROTECT(mod)
     return PyFloat_FromDouble(mod);
@@ -638,11 +646,8 @@
     else {
         /* the remainder is zero, and in the presence of signed zeroes
            fmod returns different results across platforms; ensure
-           it has the same sign as the denominator; we'd like to do
-           "mod = wx * 0.0", but that may get optimized away */
-        mod *= mod;  /* hide "mod = +0" from optimizer */
-        if (wx < 0.0)
-            mod = -mod;
+           it has the same sign as the denominator. */
+        mod = copysign(0.0, wx);
     }
     /* snap quotient to nearest integral value */
     if (div) {
@@ -652,8 +657,7 @@
     }
     else {
         /* div is zero - get the same sign as the true quotient */
-        div *= div;             /* hide "div = +0" from optimizers */
-        floordiv = div * vx / wx; /* zero w/ sign of vx/wx */
+        floordiv = copysign(0.0, vx / wx); /* zero w/ sign of vx/wx */
     }
     PyFPE_END_PROTECT(floordiv)
     return Py_BuildValue("(dd)", floordiv, mod);
@@ -1487,13 +1491,11 @@
                       "Cannot pass infinity to float.as_integer_ratio.");
       return NULL;
     }
-#ifdef Py_NAN
     if (Py_IS_NAN(self)) {
       PyErr_SetString(PyExc_ValueError,
                       "Cannot pass NaN to float.as_integer_ratio.");
       return NULL;
     }
-#endif
 
     PyFPE_START_PROTECT("as_integer_ratio", goto error);
     float_part = frexp(self, &exponent);        /* self == float_part * 2**exponent exactly */

Modified: python/branches/py3k-cdecimal/Objects/funcobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/funcobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/funcobject.c	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,6 @@
 
 #include "Python.h"
 #include "code.h"
-#include "eval.h"
 #include "structmember.h"
 
 PyObject *
@@ -628,7 +627,7 @@
     }
 
     result = PyEval_EvalCodeEx(
-        (PyCodeObject *)PyFunction_GET_CODE(func),
+        PyFunction_GET_CODE(func),
         PyFunction_GET_GLOBALS(func), (PyObject *)NULL,
         &PyTuple_GET_ITEM(arg, 0), PyTuple_GET_SIZE(arg),
         k, nk, d, nd,

Modified: python/branches/py3k-cdecimal/Objects/genobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/genobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/genobject.c	Sun Jan  2 13:18:37 2011
@@ -2,8 +2,6 @@
 
 #include "Python.h"
 #include "frameobject.h"
-#include "genobject.h"
-#include "ceval.h"
 #include "structmember.h"
 #include "opcode.h"
 

Modified: python/branches/py3k-cdecimal/Objects/listobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/listobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/listobject.c	Sun Jan  2 13:18:37 2011
@@ -940,6 +940,71 @@
  * pieces to this algorithm; read listsort.txt for overviews and details.
  */
 
+/* A sortslice contains a pointer to an array of keys and a pointer to
+ * an array of corresponding values.  In other words, keys[i]
+ * corresponds with values[i].  If values == NULL, then the keys are
+ * also the values.
+ *
+ * Several convenience routines are provided here, so that keys and
+ * values are always moved in sync.
+ */
+
+typedef struct {
+    PyObject **keys;
+    PyObject **values;
+} sortslice;
+
+Py_LOCAL_INLINE(void)
+sortslice_copy(sortslice *s1, Py_ssize_t i, sortslice *s2, Py_ssize_t j)
+{
+    s1->keys[i] = s2->keys[j];
+    if (s1->values != NULL)
+        s1->values[i] = s2->values[j];
+}
+
+Py_LOCAL_INLINE(void)
+sortslice_copy_incr(sortslice *dst, sortslice *src)
+{
+    *dst->keys++ = *src->keys++;
+    if (dst->values != NULL)
+        *dst->values++ = *src->values++;
+}
+
+Py_LOCAL_INLINE(void)
+sortslice_copy_decr(sortslice *dst, sortslice *src)
+{
+    *dst->keys-- = *src->keys--;
+    if (dst->values != NULL)
+        *dst->values-- = *src->values--;
+}
+
+
+Py_LOCAL_INLINE(void)
+sortslice_memcpy(sortslice *s1, Py_ssize_t i, sortslice *s2, Py_ssize_t j,
+                 Py_ssize_t n)
+{
+    memcpy(&s1->keys[i], &s2->keys[j], sizeof(PyObject *) * n);
+    if (s1->values != NULL)
+        memcpy(&s1->values[i], &s2->values[j], sizeof(PyObject *) * n);
+}
+
+Py_LOCAL_INLINE(void)
+sortslice_memmove(sortslice *s1, Py_ssize_t i, sortslice *s2, Py_ssize_t j,
+                  Py_ssize_t n)
+{
+    memmove(&s1->keys[i], &s2->keys[j], sizeof(PyObject *) * n);
+    if (s1->values != NULL)
+        memmove(&s1->values[i], &s2->values[j], sizeof(PyObject *) * n);
+}
+
+Py_LOCAL_INLINE(void)
+sortslice_advance(sortslice *slice, Py_ssize_t n)
+{
+    slice->keys += n;
+    if (slice->values != NULL)
+        slice->values += n;
+}
+
 /* Comparison function: PyObject_RichCompareBool with Py_LT.
  * Returns -1 on error, 1 if x < y, 0 if x >= y.
  */
@@ -965,19 +1030,19 @@
    the input (nothing is lost or duplicated).
 */
 static int
-binarysort(PyObject **lo, PyObject **hi, PyObject **start)
+binarysort(sortslice lo, PyObject **hi, PyObject **start)
 {
     register Py_ssize_t k;
     register PyObject **l, **p, **r;
     register PyObject *pivot;
 
-    assert(lo <= start && start <= hi);
+    assert(lo.keys <= start && start <= hi);
     /* assert [lo, start) is sorted */
-    if (lo == start)
+    if (lo.keys == start)
         ++start;
     for (; start < hi; ++start) {
         /* set l to where *start belongs */
-        l = lo;
+        l = lo.keys;
         r = start;
         pivot = *r;
         /* Invariants:
@@ -1004,6 +1069,15 @@
         for (p = start; p > l; --p)
             *p = *(p-1);
         *l = pivot;
+        if (lo.values != NULL) {
+            Py_ssize_t offset = lo.values - lo.keys;
+            p = start + offset;
+            pivot = *p;
+            l += offset;
+            for (p = start + offset; p > l; --p)
+                *p = *(p-1);
+            *l = pivot;
+        }
     }
     return 0;
 
@@ -1272,7 +1346,7 @@
  * a convenient way to pass state around among the helper functions.
  */
 struct s_slice {
-    PyObject **base;
+    sortslice base;
     Py_ssize_t len;
 };
 
@@ -1286,7 +1360,7 @@
     /* 'a' is temp storage to help with merges.  It contains room for
      * alloced entries.
      */
-    PyObject **a;       /* may point to temparray below */
+    sortslice a;        /* may point to temparray below */
     Py_ssize_t alloced;
 
     /* A stack of n pending runs yet to be merged.  Run #i starts at
@@ -1307,11 +1381,29 @@
 
 /* Conceptually a MergeState's constructor. */
 static void
-merge_init(MergeState *ms)
+merge_init(MergeState *ms, int list_size, int has_keyfunc)
 {
     assert(ms != NULL);
-    ms->a = ms->temparray;
-    ms->alloced = MERGESTATE_TEMP_SIZE;
+    if (has_keyfunc) {
+        /* The temporary space for merging will need at most half the list
+         * size rounded up.  Use the minimum possible space so we can use the
+         * rest of temparray for other things.  In particular, if there is
+         * enough extra space, listsort() will use it to store the keys.
+         */
+        ms->alloced = (list_size + 1) / 2;
+
+        /* ms->alloced describes how many keys will be stored at
+           ms->temparray, but we also need to store the values.  Hence,
+           ms->alloced is capped at half of MERGESTATE_TEMP_SIZE. */
+        if (MERGESTATE_TEMP_SIZE / 2 < ms->alloced)
+            ms->alloced = MERGESTATE_TEMP_SIZE / 2;
+        ms->a.values = &ms->temparray[ms->alloced];
+    }
+    else {
+        ms->alloced = MERGESTATE_TEMP_SIZE;
+        ms->a.values = NULL;
+    }
+    ms->a.keys = ms->temparray;
     ms->n = 0;
     ms->min_gallop = MIN_GALLOP;
 }
@@ -1324,10 +1416,8 @@
 merge_freemem(MergeState *ms)
 {
     assert(ms != NULL);
-    if (ms->a != ms->temparray)
-        PyMem_Free(ms->a);
-    ms->a = ms->temparray;
-    ms->alloced = MERGESTATE_TEMP_SIZE;
+    if (ms->a.keys != ms->temparray)
+        PyMem_Free(ms->a.keys);
 }
 
 /* Ensure enough temp memory for 'need' array slots is available.
@@ -1336,52 +1426,60 @@
 static int
 merge_getmem(MergeState *ms, Py_ssize_t need)
 {
+    int multiplier;
+
     assert(ms != NULL);
     if (need <= ms->alloced)
         return 0;
+
+    multiplier = ms->a.values != NULL ? 2 : 1;
+
     /* Don't realloc!  That can cost cycles to copy the old data, but
      * we don't care what's in the block.
      */
     merge_freemem(ms);
-    if ((size_t)need > PY_SSIZE_T_MAX / sizeof(PyObject*)) {
+    if ((size_t)need > PY_SSIZE_T_MAX / sizeof(PyObject*) / multiplier) {
         PyErr_NoMemory();
         return -1;
     }
-    ms->a = (PyObject **)PyMem_Malloc(need * sizeof(PyObject*));
-    if (ms->a) {
+    ms->a.keys = (PyObject**)PyMem_Malloc(multiplier * need
+                                          * sizeof(PyObject *));
+    if (ms->a.keys != NULL) {
         ms->alloced = need;
+        if (ms->a.values != NULL)
+            ms->a.values = &ms->a.keys[need];
         return 0;
     }
     PyErr_NoMemory();
-    merge_freemem(ms);          /* reset to sane state */
     return -1;
 }
 #define MERGE_GETMEM(MS, NEED) ((NEED) <= (MS)->alloced ? 0 :   \
                                 merge_getmem(MS, NEED))
 
-/* Merge the na elements starting at pa with the nb elements starting at pb
- * in a stable way, in-place.  na and nb must be > 0, and pa + na == pb.
- * Must also have that *pb < *pa, that pa[na-1] belongs at the end of the
- * merge, and should have na <= nb.  See listsort.txt for more info.
- * Return 0 if successful, -1 if error.
+/* Merge the na elements starting at ssa with the nb elements starting at
+ * ssb.keys = ssa.keys + na in a stable way, in-place.  na and nb must be > 0.
+ * Must also have that ssa.keys[na-1] belongs at the end of the merge, and
+ * should have na <= nb.  See listsort.txt for more info.  Return 0 if
+ * successful, -1 if error.
  */
 static Py_ssize_t
-merge_lo(MergeState *ms, PyObject **pa, Py_ssize_t na,
-                         PyObject **pb, Py_ssize_t nb)
+merge_lo(MergeState *ms, sortslice ssa, Py_ssize_t na,
+         sortslice ssb, Py_ssize_t nb)
 {
     Py_ssize_t k;
-    PyObject **dest;
+    sortslice dest;
     int result = -1;            /* guilty until proved innocent */
     Py_ssize_t min_gallop;
 
-    assert(ms && pa && pb && na > 0 && nb > 0 && pa + na == pb);
+    assert(ms && ssa.keys && ssb.keys && na > 0 && nb > 0);
+    assert(ssa.keys + na == ssb.keys);
     if (MERGE_GETMEM(ms, na) < 0)
         return -1;
-    memcpy(ms->a, pa, na * sizeof(PyObject*));
-    dest = pa;
-    pa = ms->a;
+    sortslice_memcpy(&ms->a, 0, &ssa, 0, na);
+    dest = ssa;
+    ssa = ms->a;
 
-    *dest++ = *pb++;
+    sortslice_copy_incr(&dest, &ssb);
     --nb;
     if (nb == 0)
         goto Succeed;
@@ -1398,11 +1496,11 @@
          */
         for (;;) {
             assert(na > 1 && nb > 0);
-            k = ISLT(*pb, *pa);
+            k = ISLT(ssb.keys[0], ssa.keys[0]);
             if (k) {
                 if (k < 0)
                     goto Fail;
-                *dest++ = *pb++;
+                sortslice_copy_incr(&dest, &ssb);
                 ++bcount;
                 acount = 0;
                 --nb;
@@ -1412,7 +1510,7 @@
                     break;
             }
             else {
-                *dest++ = *pa++;
+                sortslice_copy_incr(&dest, &ssa);
                 ++acount;
                 bcount = 0;
                 --na;
@@ -1433,14 +1531,14 @@
             assert(na > 1 && nb > 0);
             min_gallop -= min_gallop > 1;
             ms->min_gallop = min_gallop;
-            k = gallop_right(*pb, pa, na, 0);
+            k = gallop_right(ssb.keys[0], ssa.keys, na, 0);
             acount = k;
             if (k) {
                 if (k < 0)
                     goto Fail;
-                memcpy(dest, pa, k * sizeof(PyObject *));
-                dest += k;
-                pa += k;
+                sortslice_memcpy(&dest, 0, &ssa, 0, k);
+                sortslice_advance(&dest, k);
+                sortslice_advance(&ssa, k);
                 na -= k;
                 if (na == 1)
                     goto CopyB;
@@ -1451,24 +1549,24 @@
                 if (na == 0)
                     goto Succeed;
             }
-            *dest++ = *pb++;
+            sortslice_copy_incr(&dest, &ssb);
             --nb;
             if (nb == 0)
                 goto Succeed;
 
-            k = gallop_left(*pa, pb, nb, 0);
+            k = gallop_left(ssa.keys[0], ssb.keys, nb, 0);
             bcount = k;
             if (k) {
                 if (k < 0)
                     goto Fail;
-                memmove(dest, pb, k * sizeof(PyObject *));
-                dest += k;
-                pb += k;
+                sortslice_memmove(&dest, 0, &ssb, 0, k);
+                sortslice_advance(&dest, k);
+                sortslice_advance(&ssb, k);
                 nb -= k;
                 if (nb == 0)
                     goto Succeed;
             }
-            *dest++ = *pa++;
+            sortslice_copy_incr(&dest, &ssa);
             --na;
             if (na == 1)
                 goto CopyB;
@@ -1480,43 +1578,46 @@
     result = 0;
 Fail:
     if (na)
-        memcpy(dest, pa, na * sizeof(PyObject*));
+        sortslice_memcpy(&dest, 0, &ssa, 0, na);
     return result;
 CopyB:
     assert(na == 1 && nb > 0);
-    /* The last element of pa belongs at the end of the merge. */
-    memmove(dest, pb, nb * sizeof(PyObject *));
-    dest[nb] = *pa;
+    /* The last element of ssa belongs at the end of the merge. */
+    sortslice_memmove(&dest, 0, &ssb, 0, nb);
+    sortslice_copy(&dest, nb, &ssa, 0);
     return 0;
 }
 
-/* Merge the na elements starting at pa with the nb elements starting at pb
- * in a stable way, in-place.  na and nb must be > 0, and pa + na == pb.
- * Must also have that *pb < *pa, that pa[na-1] belongs at the end of the
- * merge, and should have na >= nb.  See listsort.txt for more info.
- * Return 0 if successful, -1 if error.
+/* Merge the na elements starting at pa with the nb elements starting at
+ * ssb.keys = ssa.keys + na in a stable way, in-place.  na and nb must be > 0.
+ * Must also have that ssa.keys[na-1] belongs at the end of the merge, and
+ * should have na >= nb.  See listsort.txt for more info.  Return 0 if
+ * successful, -1 if error.
  */
 static Py_ssize_t
-merge_hi(MergeState *ms, PyObject **pa, Py_ssize_t na, PyObject **pb, Py_ssize_t nb)
+merge_hi(MergeState *ms, sortslice ssa, Py_ssize_t na,
+         sortslice ssb, Py_ssize_t nb)
 {
     Py_ssize_t k;
-    PyObject **dest;
+    sortslice dest, basea, baseb;
     int result = -1;            /* guilty until proved innocent */
-    PyObject **basea;
-    PyObject **baseb;
     Py_ssize_t min_gallop;
 
-    assert(ms && pa && pb && na > 0 && nb > 0 && pa + na == pb);
+    assert(ms && ssa.keys && ssb.keys && na > 0 && nb > 0);
+    assert(ssa.keys + na == ssb.keys);
     if (MERGE_GETMEM(ms, nb) < 0)
         return -1;
-    dest = pb + nb - 1;
-    memcpy(ms->a, pb, nb * sizeof(PyObject*));
-    basea = pa;
+    dest = ssb;
+    sortslice_advance(&dest, nb-1);
+    sortslice_memcpy(&ms->a, 0, &ssb, 0, nb);
+    basea = ssa;
     baseb = ms->a;
-    pb = ms->a + nb - 1;
-    pa += na - 1;
+    ssb.keys = ms->a.keys + nb - 1;
+    if (ssb.values != NULL)
+        ssb.values = ms->a.values + nb - 1;
+    sortslice_advance(&ssa, na - 1);
 
-    *dest-- = *pa--;
+    sortslice_copy_decr(&dest, &ssa);
     --na;
     if (na == 0)
         goto Succeed;
@@ -1533,11 +1634,11 @@
          */
         for (;;) {
             assert(na > 0 && nb > 1);
-            k = ISLT(*pb, *pa);
+            k = ISLT(ssb.keys[0], ssa.keys[0]);
             if (k) {
                 if (k < 0)
                     goto Fail;
-                *dest-- = *pa--;
+                sortslice_copy_decr(&dest, &ssa);
                 ++acount;
                 bcount = 0;
                 --na;
@@ -1547,7 +1648,7 @@
                     break;
             }
             else {
-                *dest-- = *pb--;
+                sortslice_copy_decr(&dest, &ssb);
                 ++bcount;
                 acount = 0;
                 --nb;
@@ -1568,33 +1669,33 @@
             assert(na > 0 && nb > 1);
             min_gallop -= min_gallop > 1;
             ms->min_gallop = min_gallop;
-            k = gallop_right(*pb, basea, na, na-1);
+            k = gallop_right(ssb.keys[0], basea.keys, na, na-1);
             if (k < 0)
                 goto Fail;
             k = na - k;
             acount = k;
             if (k) {
-                dest -= k;
-                pa -= k;
-                memmove(dest+1, pa+1, k * sizeof(PyObject *));
+                sortslice_advance(&dest, -k);
+                sortslice_advance(&ssa, -k);
+                sortslice_memmove(&dest, 1, &ssa, 1, k);
                 na -= k;
                 if (na == 0)
                     goto Succeed;
             }
-            *dest-- = *pb--;
+            sortslice_copy_decr(&dest, &ssb);
             --nb;
             if (nb == 1)
                 goto CopyA;
 
-            k = gallop_left(*pa, baseb, nb, nb-1);
+            k = gallop_left(ssa.keys[0], baseb.keys, nb, nb-1);
             if (k < 0)
                 goto Fail;
             k = nb - k;
             bcount = k;
             if (k) {
-                dest -= k;
-                pb -= k;
-                memcpy(dest+1, pb+1, k * sizeof(PyObject *));
+                sortslice_advance(&dest, -k);
+                sortslice_advance(&ssb, -k);
+                sortslice_memcpy(&dest, 1, &ssb, 1, k);
                 nb -= k;
                 if (nb == 1)
                     goto CopyA;
@@ -1605,7 +1706,7 @@
                 if (nb == 0)
                     goto Succeed;
             }
-            *dest-- = *pa--;
+            sortslice_copy_decr(&dest, &ssa);
             --na;
             if (na == 0)
                 goto Succeed;
@@ -1617,15 +1718,15 @@
     result = 0;
 Fail:
     if (nb)
-        memcpy(dest-(nb-1), baseb, nb * sizeof(PyObject*));
+        sortslice_memcpy(&dest, -(nb-1), &baseb, 0, nb);
     return result;
 CopyA:
     assert(nb == 1 && na > 0);
-    /* The first element of pb belongs at the front of the merge. */
-    dest -= na;
-    pa -= na;
-    memmove(dest+1, pa+1, na * sizeof(PyObject *));
-    *dest = *pb;
+    /* The first element of ssb belongs at the front of the merge. */
+    sortslice_memmove(&dest, 1-na, &ssa, 1-na, na);
+    sortslice_advance(&dest, -na);
+    sortslice_advance(&ssa, -na);
+    sortslice_copy(&dest, 0, &ssb, 0);
     return 0;
 }
 
@@ -1635,7 +1736,7 @@
 static Py_ssize_t
 merge_at(MergeState *ms, Py_ssize_t i)
 {
-    PyObject **pa, **pb;
+    sortslice ssa, ssb;
     Py_ssize_t na, nb;
     Py_ssize_t k;
 
@@ -1644,12 +1745,12 @@
     assert(i >= 0);
     assert(i == ms->n - 2 || i == ms->n - 3);
 
-    pa = ms->pending[i].base;
+    ssa = ms->pending[i].base;
     na = ms->pending[i].len;
-    pb = ms->pending[i+1].base;
+    ssb = ms->pending[i+1].base;
     nb = ms->pending[i+1].len;
     assert(na > 0 && nb > 0);
-    assert(pa + na == pb);
+    assert(ssa.keys + na == ssb.keys);
 
     /* Record the length of the combined runs; if i is the 3rd-last
      * run now, also slide over the last run (which isn't involved
@@ -1663,10 +1764,10 @@
     /* Where does b start in a?  Elements in a before that can be
      * ignored (already in place).
      */
-    k = gallop_right(*pb, pa, na, 0);
+    k = gallop_right(*ssb.keys, ssa.keys, na, 0);
     if (k < 0)
         return -1;
-    pa += k;
+    sortslice_advance(&ssa, k);
     na -= k;
     if (na == 0)
         return 0;
@@ -1674,7 +1775,7 @@
     /* Where does a end in b?  Elements in b after that can be
      * ignored (already in place).
      */
-    nb = gallop_left(pa[na-1], pb, nb, nb-1);
+    nb = gallop_left(ssa.keys[na-1], ssb.keys, nb, nb-1);
     if (nb <= 0)
         return nb;
 
@@ -1682,9 +1783,9 @@
      * min(na, nb) elements.
      */
     if (na <= nb)
-        return merge_lo(ms, pa, na, pb, nb);
+        return merge_lo(ms, ssa, na, ssb, nb);
     else
-        return merge_hi(ms, pa, na, pb, nb);
+        return merge_hi(ms, ssa, na, ssb, nb);
 }
 
 /* Examine the stack of runs waiting to be merged, merging adjacent runs
@@ -1765,103 +1866,12 @@
     return n + r;
 }
 
-/* Special wrapper to support stable sorting using the decorate-sort-undecorate
-   pattern.  Holds a key which is used for comparisons and the original record
-   which is returned during the undecorate phase.  By exposing only the key
-   during comparisons, the underlying sort stability characteristics are left
-   unchanged.  Also, the comparison function will only see the key instead of
-   a full record. */
-
-typedef struct {
-    PyObject_HEAD
-    PyObject *key;
-    PyObject *value;
-} sortwrapperobject;
-
-PyDoc_STRVAR(sortwrapper_doc, "Object wrapper with a custom sort key.");
-static PyObject *
-sortwrapper_richcompare(sortwrapperobject *, sortwrapperobject *, int);
-static void
-sortwrapper_dealloc(sortwrapperobject *);
-
-PyTypeObject PySortWrapper_Type = {
-    PyVarObject_HEAD_INIT(&PyType_Type, 0)
-    "sortwrapper",                              /* tp_name */
-    sizeof(sortwrapperobject),                  /* tp_basicsize */
-    0,                                          /* tp_itemsize */
-    /* methods */
-    (destructor)sortwrapper_dealloc,            /* tp_dealloc */
-    0,                                          /* tp_print */
-    0,                                          /* tp_getattr */
-    0,                                          /* tp_setattr */
-    0,                                          /* tp_reserved */
-    0,                                          /* tp_repr */
-    0,                                          /* tp_as_number */
-    0,                                          /* tp_as_sequence */
-    0,                                          /* tp_as_mapping */
-    0,                                          /* tp_hash */
-    0,                                          /* tp_call */
-    0,                                          /* tp_str */
-    PyObject_GenericGetAttr,                    /* tp_getattro */
-    0,                                          /* tp_setattro */
-    0,                                          /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,                         /* tp_flags */
-    sortwrapper_doc,                            /* tp_doc */
-    0,                                          /* tp_traverse */
-    0,                                          /* tp_clear */
-    (richcmpfunc)sortwrapper_richcompare,       /* tp_richcompare */
-};
-
-
-static PyObject *
-sortwrapper_richcompare(sortwrapperobject *a, sortwrapperobject *b, int op)
-{
-    if (!PyObject_TypeCheck(b, &PySortWrapper_Type)) {
-        PyErr_SetString(PyExc_TypeError,
-            "expected a sortwrapperobject");
-        return NULL;
-    }
-    return PyObject_RichCompare(a->key, b->key, op);
-}
-
 static void
-sortwrapper_dealloc(sortwrapperobject *so)
-{
-    Py_XDECREF(so->key);
-    Py_XDECREF(so->value);
-    PyObject_Del(so);
-}
-
-/* Returns a new reference to a sortwrapper.
-   Consumes the references to the two underlying objects. */
-
-static PyObject *
-build_sortwrapper(PyObject *key, PyObject *value)
-{
-    sortwrapperobject *so;
-
-    so = PyObject_New(sortwrapperobject, &PySortWrapper_Type);
-    if (so == NULL)
-        return NULL;
-    so->key = key;
-    so->value = value;
-    return (PyObject *)so;
-}
-
-/* Returns a new reference to the value underlying the wrapper. */
-static PyObject *
-sortwrapper_getvalue(PyObject *so)
+reverse_sortslice(sortslice *s, Py_ssize_t n)
 {
-    PyObject *value;
-
-    if (!PyObject_TypeCheck(so, &PySortWrapper_Type)) {
-        PyErr_SetString(PyExc_TypeError,
-            "expected a sortwrapperobject");
-        return NULL;
-    }
-    value = ((sortwrapperobject *)so)->value;
-    Py_INCREF(value);
-    return value;
+    reverse_slice(s->keys, &s->keys[n]);
+    if (s->values != NULL)
+        reverse_slice(s->values, &s->values[n]);
 }
 
 /* An adaptive, stable, natural mergesort.  See listsort.txt.
@@ -1873,9 +1883,9 @@
 listsort(PyListObject *self, PyObject *args, PyObject *kwds)
 {
     MergeState ms;
-    PyObject **lo, **hi;
     Py_ssize_t nremaining;
     Py_ssize_t minrun;
+    sortslice lo;
     Py_ssize_t saved_ob_size, saved_allocated;
     PyObject **saved_ob_item;
     PyObject **final_ob_item;
@@ -1883,8 +1893,8 @@
     int reverse = 0;
     PyObject *keyfunc = NULL;
     Py_ssize_t i;
-    PyObject *key, *value, *kvpair;
     static char *kwlist[] = {"key", "reverse", 0};
+    PyObject **keys;
 
     assert(self != NULL);
     assert (PyList_Check(self));
@@ -1913,28 +1923,36 @@
     self->ob_item = NULL;
     self->allocated = -1; /* any operation will reset it to >= 0 */
 
-    if (keyfunc != NULL) {
-        for (i=0 ; i < saved_ob_size ; i++) {
-            value = saved_ob_item[i];
-            key = PyObject_CallFunctionObjArgs(keyfunc, value,
-                                               NULL);
-            if (key == NULL) {
-                for (i=i-1 ; i>=0 ; i--) {
-                    kvpair = saved_ob_item[i];
-                    value = sortwrapper_getvalue(kvpair);
-                    saved_ob_item[i] = value;
-                    Py_DECREF(kvpair);
-                }
-                goto dsu_fail;
+    if (keyfunc == NULL) {
+        keys = NULL;
+        lo.keys = saved_ob_item;
+        lo.values = NULL;
+    }
+    else {
+        if (saved_ob_size < MERGESTATE_TEMP_SIZE/2)
+            /* Leverage stack space we allocated but won't otherwise use */
+            keys = &ms.temparray[saved_ob_size+1];
+        else {
+            keys = PyMem_MALLOC(sizeof(PyObject *) * saved_ob_size);
+            if (keys == NULL)
+                return NULL;
+        }
+
+        for (i = 0; i < saved_ob_size ; i++) {
+            keys[i] = PyObject_CallFunctionObjArgs(keyfunc, saved_ob_item[i],
+                                                   NULL);
+            if (keys[i] == NULL) {
+                for (i=i-1 ; i>=0 ; i--)
+                    Py_DECREF(keys[i]);
+                goto keyfunc_fail;
             }
-            kvpair = build_sortwrapper(key, value);
-            if (kvpair == NULL)
-                goto dsu_fail;
-            saved_ob_item[i] = kvpair;
         }
+
+        lo.keys = keys;
+        lo.values = saved_ob_item;
     }
 
-    merge_init(&ms);
+    merge_init(&ms, saved_ob_size, keys != NULL);
 
     nremaining = saved_ob_size;
     if (nremaining < 2)
@@ -1942,30 +1960,31 @@
 
     /* Reverse sort stability achieved by initially reversing the list,
     applying a stable forward sort, then reversing the final result. */
-    if (reverse)
-        reverse_slice(saved_ob_item, saved_ob_item + saved_ob_size);
+    if (reverse) {
+        if (keys != NULL)
+            reverse_slice(&keys[0], &keys[saved_ob_size]);
+        reverse_slice(&saved_ob_item[0], &saved_ob_item[saved_ob_size]);
+    }
 
     /* March over the array once, left to right, finding natural runs,
      * and extending short natural runs to minrun elements.
      */
-    lo = saved_ob_item;
-    hi = lo + nremaining;
     minrun = merge_compute_minrun(nremaining);
     do {
         int descending;
         Py_ssize_t n;
 
         /* Identify next run. */
-        n = count_run(lo, hi, &descending);
+        n = count_run(lo.keys, lo.keys + nremaining, &descending);
         if (n < 0)
             goto fail;
         if (descending)
-            reverse_slice(lo, lo + n);
+            reverse_sortslice(&lo, n);
         /* If short, extend to min(minrun, nremaining). */
         if (n < minrun) {
             const Py_ssize_t force = nremaining <= minrun ?
                               nremaining : minrun;
-            if (binarysort(lo, lo + force, lo + n) < 0)
+            if (binarysort(lo, lo.keys + force, lo.keys + n) < 0)
                 goto fail;
             n = force;
         }
@@ -1977,27 +1996,27 @@
         if (merge_collapse(&ms) < 0)
             goto fail;
         /* Advance to find next run. */
-        lo += n;
+        sortslice_advance(&lo, n);
         nremaining -= n;
     } while (nremaining);
-    assert(lo == hi);
 
     if (merge_force_collapse(&ms) < 0)
         goto fail;
     assert(ms.n == 1);
-    assert(ms.pending[0].base == saved_ob_item);
+    assert(keys == NULL
+           ? ms.pending[0].base.keys == saved_ob_item
+           : ms.pending[0].base.keys == &keys[0]);
     assert(ms.pending[0].len == saved_ob_size);
+    lo = ms.pending[0].base;
 
 succeed:
     result = Py_None;
 fail:
-    if (keyfunc != NULL) {
-        for (i=0 ; i < saved_ob_size ; i++) {
-            kvpair = saved_ob_item[i];
-            value = sortwrapper_getvalue(kvpair);
-            saved_ob_item[i] = value;
-            Py_DECREF(kvpair);
-        }
+    if (keys != NULL) {
+        for (i = 0; i < saved_ob_size; i++)
+            Py_DECREF(keys[i]);
+        if (keys != &ms.temparray[saved_ob_size+1])
+            PyMem_FREE(keys);
     }
 
     if (self->allocated != -1 && result != NULL) {
@@ -2013,7 +2032,7 @@
 
     merge_freemem(&ms);
 
-dsu_fail:
+keyfunc_fail:
     final_ob_item = self->ob_item;
     i = Py_SIZE(self);
     Py_SIZE(self) = saved_ob_size;
@@ -2378,7 +2397,7 @@
         PyObject* it;
         PyObject **src, **dest;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
+        if (PySlice_GetIndicesEx(item, Py_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return NULL;
         }
@@ -2427,7 +2446,7 @@
     else if (PySlice_Check(item)) {
         Py_ssize_t start, stop, step, slicelength;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
+        if (PySlice_GetIndicesEx(item, Py_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return -1;
         }
@@ -2862,4 +2881,3 @@
         len = 0;
     return PyLong_FromSsize_t(len);
 }
-

Modified: python/branches/py3k-cdecimal/Objects/longobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/longobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/longobject.c	Sun Jan  2 13:18:37 2011
@@ -4,7 +4,6 @@
 
 #include "Python.h"
 #include "longintrepr.h"
-#include "structseq.h"
 
 #include <float.h>
 #include <ctype.h>
@@ -2134,17 +2133,34 @@
 PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)
 {
     PyObject *result;
-    char *buffer = (char *)PyMem_MALLOC(length+1);
-
-    if (buffer == NULL)
-        return NULL;
-
-    if (PyUnicode_EncodeDecimal(u, length, buffer, NULL)) {
-        PyMem_FREE(buffer);
+    PyObject *asciidig;
+    char *buffer, *end;
+    Py_ssize_t i, buflen;
+    Py_UNICODE *ptr;
+
+    asciidig = PyUnicode_TransformDecimalToASCII(u, length);
+    if (asciidig == NULL)
+        return NULL;
+    /* Replace non-ASCII whitespace with ' ' */
+    ptr = PyUnicode_AS_UNICODE(asciidig);
+    for (i = 0; i < length; i++) {
+        Py_UNICODE ch = ptr[i];
+        if (ch > 127 && Py_UNICODE_ISSPACE(ch))
+            ptr[i] = ' ';
+    }
+    buffer = _PyUnicode_AsStringAndSize(asciidig, &buflen);
+    if (buffer == NULL) {
+        Py_DECREF(asciidig);
         return NULL;
     }
-    result = PyLong_FromString(buffer, NULL, base);
-    PyMem_FREE(buffer);
+    result = PyLong_FromString(buffer, &end, base);
+    if (result != NULL && end != buffer + buflen) {
+        PyErr_SetString(PyExc_ValueError,
+                        "null byte in argument for int()");
+        Py_DECREF(result);
+        result = NULL;
+    }
+    Py_DECREF(asciidig);
     return result;
 }
 

Modified: python/branches/py3k-cdecimal/Objects/memoryobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/memoryobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/memoryobject.c	Sun Jan  2 13:18:37 2011
@@ -599,7 +599,7 @@
     else if (PySlice_Check(key)) {
         Py_ssize_t start, stop, step, slicelength;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)key, get_shape0(view),
+        if (PySlice_GetIndicesEx(key, get_shape0(view),
                                  &start, &stop, &step, &slicelength) < 0) {
             return NULL;
         }
@@ -678,7 +678,7 @@
     else if (PySlice_Check(key)) {
         Py_ssize_t stop, step;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)key, get_shape0(view),
+        if (PySlice_GetIndicesEx(key, get_shape0(view),
                          &start, &stop, &step, &len) < 0) {
             return -1;
         }

Modified: python/branches/py3k-cdecimal/Objects/moduleobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/moduleobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/moduleobject.c	Sun Jan  2 13:18:37 2011
@@ -63,8 +63,9 @@
     PyMethodDef *ml;
     const char* name;
     PyModuleObject *m;
-    if (!Py_IsInitialized())
-        Py_FatalError("Interpreter not initialized (version mismatch?)");
+    PyInterpreterState *interp = PyThreadState_Get()->interp;
+    if (interp->modules == NULL)
+        Py_FatalError("Python import machinery not initialized");
     if (PyType_Ready(&moduledef_type) < 0)
         return NULL;
     if (module->m_base.m_index == 0) {
@@ -74,7 +75,7 @@
         module->m_base.m_index = max_module_number;
     }
     name = module->m_name;
-    if (module_api_version != PYTHON_API_VERSION) {
+    if (module_api_version != PYTHON_API_VERSION && module_api_version != PYTHON_ABI_VERSION) {
         int err;
         err = PyErr_WarnFormat(PyExc_RuntimeWarning, 1,
             "Python C API version mismatch for module %.100s: "

Modified: python/branches/py3k-cdecimal/Objects/object.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/object.c	(original)
+++ python/branches/py3k-cdecimal/Objects/object.c	Sun Jan  2 13:18:37 2011
@@ -2,7 +2,6 @@
 /* Generic object operations; and implementation of None (NoObject) */
 
 #include "Python.h"
-#include "sliceobject.h" /* For PyEllipsis_Type */
 #include "frameobject.h"
 
 #ifdef __cplusplus
@@ -1756,7 +1755,6 @@
 
 #endif
 
-
 /* Hack to force loading of pycapsule.o */
 PyTypeObject *_PyCapsule_hack = &PyCapsule_Type;
 
@@ -1901,6 +1899,19 @@
     }
 }
 
+#ifndef Py_TRACE_REFS
+/* For Py_LIMITED_API, we need an out-of-line version of _Py_Dealloc.
+   Define this here, so we can undefine the macro. */
+#undef _Py_Dealloc
+PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
+void
+_Py_Dealloc(PyObject *op)
+{
+    _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA
+    (*Py_TYPE(op)->tp_dealloc)(op);
+}
+#endif
+
 #ifdef __cplusplus
 }
 #endif

Modified: python/branches/py3k-cdecimal/Objects/obmalloc.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/obmalloc.c	(original)
+++ python/branches/py3k-cdecimal/Objects/obmalloc.c	Sun Jan  2 13:18:37 2011
@@ -249,7 +249,7 @@
 /* Pool for small blocks. */
 struct pool_header {
     union { block *_padding;
-        uint count; } ref;              /* number of allocated blocks    */
+            uint count; } ref;          /* number of allocated blocks    */
     block *freeblock;                   /* pool's free list head         */
     struct pool_header *nextpool;       /* next pool of this size class  */
     struct pool_header *prevpool;       /* previous pool       ""        */
@@ -404,7 +404,7 @@
 immediately follow a pool_header's first two members:
 
     union { block *_padding;
-        uint count; } ref;
+            uint count; } ref;
     block *freeblock;
 
 each of which consume sizeof(block *) bytes.  So what usedpools[i+i] really
@@ -709,7 +709,7 @@
 #undef Py_ADDRESS_IN_RANGE
 
 #if defined(__GNUC__) && ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) || \
-              (__GNUC__ >= 4))
+                          (__GNUC__ >= 4))
 #define Py_NO_INLINE __attribute__((__noinline__))
 #else
 #define Py_NO_INLINE
@@ -1514,7 +1514,7 @@
     if (nbytes > original_nbytes) {
         /* growing:  mark new extra memory clean */
         memset(q + original_nbytes, CLEANBYTE,
-            nbytes - original_nbytes);
+               nbytes - original_nbytes);
     }
 
     return q;
@@ -1641,11 +1641,11 @@
         fputs("FORBIDDENBYTE, as expected.\n", stderr);
     else {
         fprintf(stderr, "not all FORBIDDENBYTE (0x%02x):\n",
-            FORBIDDENBYTE);
+                FORBIDDENBYTE);
         for (i = 0; i < SST; ++i) {
             const uchar byte = tail[i];
             fprintf(stderr, "        at tail+%d: 0x%02x",
-                i, byte);
+                    i, byte);
             if (byte != FORBIDDENBYTE)
                 fputs(" *** OUCH", stderr);
             fputc('\n', stderr);
@@ -1751,7 +1751,7 @@
     char buf[128];
 
     fprintf(stderr, "Small block threshold = %d, in %u size classes.\n",
-        SMALL_REQUEST_THRESHOLD, numclasses);
+            SMALL_REQUEST_THRESHOLD, numclasses);
 
     for (i = 0; i < numclasses; ++i)
         numpools[i] = numblocks[i] = numfreeblocks[i] = 0;
@@ -1809,7 +1809,7 @@
     fputc('\n', stderr);
     fputs("class   size   num pools   blocks in use  avail blocks\n"
           "-----   ----   ---------   -------------  ------------\n",
-        stderr);
+          stderr);
 
     for (i = 0; i < numclasses; ++i) {
         size_t p = numpools[i];
@@ -1824,7 +1824,7 @@
                         "%11" PY_FORMAT_SIZE_T "u "
                         "%15" PY_FORMAT_SIZE_T "u "
                         "%13" PY_FORMAT_SIZE_T "u\n",
-            i, size, p, b, f);
+                i, size, p, b, f);
         allocated_bytes += b * size;
         available_bytes += f * size;
         pool_header_bytes += p * POOL_OVERHEAD;

Modified: python/branches/py3k-cdecimal/Objects/rangeobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/rangeobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/rangeobject.c	Sun Jan  2 13:18:37 2011
@@ -14,6 +14,7 @@
     PyObject *start;
     PyObject *stop;
     PyObject *step;
+    PyObject *length;
 } rangeobject;
 
 /* Helper function for validating step.  Always returns a new reference or
@@ -43,6 +44,31 @@
     return step;
 }
 
+static PyObject *
+compute_range_length(PyObject *start, PyObject *stop, PyObject *step);
+
+static rangeobject *
+make_range_object(PyTypeObject *type, PyObject *start,
+                  PyObject *stop, PyObject *step)
+{
+    rangeobject *obj = NULL;
+    PyObject *length;
+    length = compute_range_length(start, stop, step);
+    if (length == NULL) {
+        return NULL;
+    }
+    obj = PyObject_New(rangeobject, type);
+    if (obj == NULL) {
+        Py_DECREF(length);
+        return NULL;
+    }
+    obj->start = start;
+    obj->stop = stop;
+    obj->step = step;
+    obj->length = length;
+    return obj;
+}
+
 /* XXX(nnorwitz): should we error check if the user passes any empty ranges?
    range(-10)
    range(0, -5)
@@ -51,7 +77,7 @@
 static PyObject *
 range_new(PyTypeObject *type, PyObject *args, PyObject *kw)
 {
-    rangeobject *obj = NULL;
+    rangeobject *obj;
     PyObject *start = NULL, *stop = NULL, *step = NULL;
 
     if (!_PyArg_NoKeywords("range()", kw))
@@ -97,15 +123,11 @@
         }
     }
 
-    obj = PyObject_New(rangeobject, &PyRange_Type);
-    if (obj == NULL)
-        goto Fail;
-    obj->start = start;
-    obj->stop = stop;
-    obj->step = step;
-    return (PyObject *) obj;
+    obj = make_range_object(type, start, stop, step);
+    if (obj != NULL)
+        return (PyObject *) obj;
 
-Fail:
+    /* Failed to create object, release attributes */
     Py_XDECREF(start);
     Py_XDECREF(stop);
     Py_XDECREF(step);
@@ -115,7 +137,7 @@
 PyDoc_STRVAR(range_doc,
 "range([start,] stop[, step]) -> range object\n\
 \n\
-Returns an iterator that generates the numbers in the range on demand.");
+Returns a virtual sequence of numbers from start to stop by step.");
 
 static void
 range_dealloc(rangeobject *r)
@@ -123,6 +145,7 @@
     Py_DECREF(r->start);
     Py_DECREF(r->stop);
     Py_DECREF(r->step);
+    Py_DECREF(r->length);
     PyObject_Del(r);
 }
 
@@ -131,7 +154,7 @@
  * PyLong_Check().  Return NULL when there is an error.
  */
 static PyObject*
-range_length_obj(rangeobject *r)
+compute_range_length(PyObject *start, PyObject *stop, PyObject *step)
 {
     /* -------------------------------------------------------------
     Algorithm is equal to that of get_len_of_range(), but it operates
@@ -139,7 +162,6 @@
     ---------------------------------------------------------------*/
     int cmp_result;
     PyObject *lo, *hi;
-    PyObject *step = NULL;
     PyObject *diff = NULL;
     PyObject *one = NULL;
     PyObject *tmp1 = NULL, *tmp2 = NULL, *result;
@@ -148,20 +170,19 @@
     PyObject *zero = PyLong_FromLong(0);
     if (zero == NULL)
         return NULL;
-    cmp_result = PyObject_RichCompareBool(r->step, zero, Py_GT);
+    cmp_result = PyObject_RichCompareBool(step, zero, Py_GT);
     Py_DECREF(zero);
     if (cmp_result == -1)
         return NULL;
 
     if (cmp_result == 1) {
-        lo = r->start;
-        hi = r->stop;
-        step = r->step;
+        lo = start;
+        hi = stop;
         Py_INCREF(step);
     } else {
-        lo = r->stop;
-        hi = r->start;
-        step = PyNumber_Negative(r->step);
+        lo = stop;
+        hi = start;
+        step = PyNumber_Negative(step);
         if (!step)
             return NULL;
     }
@@ -206,32 +227,15 @@
 static Py_ssize_t
 range_length(rangeobject *r)
 {
-    PyObject *len = range_length_obj(r);
-    Py_ssize_t result = -1;
-    if (len) {
-        result = PyLong_AsSsize_t(len);
-        Py_DECREF(len);
-    }
-    return result;
+    return PyLong_AsSsize_t(r->length);
 }
 
 /* range(...)[x] is necessary for:  seq[:] = range(...) */
-
 static PyObject *
-range_item(rangeobject *r, Py_ssize_t i)
+compute_range_item(rangeobject *r, Py_ssize_t i)
 {
-    Py_ssize_t len = range_length(r);
     PyObject *rem, *incr, *result;
 
-    /* XXX(nnorwitz): should negative indices be supported? */
-    /* XXX(nnorwitz): should support range[x] where x > PY_SSIZE_T_MAX? */
-    if (i < 0 || i >= len) {
-        if (!PyErr_Occurred())
-            PyErr_SetString(PyExc_IndexError,
-                            "range object index out of range");
-        return NULL;
-    }
-
     /* XXX(nnorwitz): optimize for short ints. */
     rem = PyLong_FromSsize_t(i);
     if (!rem)
@@ -246,31 +250,22 @@
 }
 
 static PyObject *
-range_repr(rangeobject *r)
+range_item(rangeobject *r, Py_ssize_t i)
 {
-    Py_ssize_t istep;
-
-    /* Check for special case values for printing.  We don't always
-       need the step value.  We don't care about errors
-       (it means overflow), so clear the errors. */
-    istep = PyNumber_AsSsize_t(r->step, NULL);
-    if (istep != 1 || (istep == -1 && PyErr_Occurred())) {
-        PyErr_Clear();
-    }
+    /* XXX(nnorwitz): should we support range[x] where x > PY_SSIZE_T_MAX? */
+    Py_ssize_t len = range_length(r);
 
-    if (istep == 1)
-        return PyUnicode_FromFormat("range(%R, %R)", r->start, r->stop);
-    else
-        return PyUnicode_FromFormat("range(%R, %R, %R)",
-                                    r->start, r->stop, r->step);
-}
+    if (i < 0)
+        i += len;
 
-/* Pickling support */
-static PyObject *
-range_reduce(rangeobject *r, PyObject *args)
-{
-        return Py_BuildValue("(O(OOO))", Py_TYPE(r),
-                         r->start, r->stop, r->step);
+    if (i < 0 || i >= len) {
+        /* Also handles case where len < 0 due to (e.g) OverflowError */
+        if (!PyErr_Occurred())
+            PyErr_SetString(PyExc_IndexError,
+                            "range object index out of range");
+        return NULL;
+    }
+    return compute_range_item(r, i);
 }
 
 /* Assumes (PyLong_CheckExact(ob) || PyBool_Check(ob)) */
@@ -388,15 +383,110 @@
 
 static PySequenceMethods range_as_sequence = {
     (lenfunc)range_length,      /* sq_length */
-    0,                  /* sq_concat */
-    0,                  /* sq_repeat */
-    (ssizeargfunc)range_item, /* sq_item */
-    0,                  /* sq_slice */
-    0, /* sq_ass_item */
-    0, /* sq_ass_slice */
+    0,                          /* sq_concat */
+    0,                          /* sq_repeat */
+    (ssizeargfunc)range_item,   /* sq_item */
+    0,                          /* sq_slice */
+    0,                          /* sq_ass_item */
+    0,                          /* sq_ass_slice */
     (objobjproc)range_contains, /* sq_contains */
 };
 
+static PyObject *
+range_repr(rangeobject *r)
+{
+    Py_ssize_t istep;
+
+    /* Check for special case values for printing.  We don't always
+       need the step value.  We don't care about errors
+       (it means overflow), so clear the errors. */
+    istep = PyNumber_AsSsize_t(r->step, NULL);
+    if (istep != 1 || (istep == -1 && PyErr_Occurred())) {
+        PyErr_Clear();
+    }
+
+    if (istep == 1)
+        return PyUnicode_FromFormat("range(%R, %R)", r->start, r->stop);
+    else
+        return PyUnicode_FromFormat("range(%R, %R, %R)",
+                                    r->start, r->stop, r->step);
+}
+
+/* Pickling support */
+static PyObject *
+range_reduce(rangeobject *r, PyObject *args)
+{
+    return Py_BuildValue("(O(OOO))", Py_TYPE(r),
+                         r->start, r->stop, r->step);
+}
+
+static PyObject *
+range_subscript(rangeobject* self, PyObject* item)
+{
+    if (PyIndex_Check(item)) {
+        Py_ssize_t i;
+        i = PyNumber_AsSsize_t(item, PyExc_IndexError);
+        if (i == -1 && PyErr_Occurred())
+            return NULL;
+        return range_item(self, i);
+    }
+    if (PySlice_Check(item)) {
+        Py_ssize_t start, stop, step, len, rlen;
+        rangeobject *result;
+        PyObject *substart = NULL, *substep = NULL, *substop = NULL;
+
+        rlen = range_length(self);
+        if (rlen < 0) {
+            return NULL;
+        }
+
+        if (PySlice_GetIndicesEx(item, rlen,
+                                &start, &stop, &step, &len) < 0) {
+            return NULL;
+        }
+        if (step == 1) {
+            substep = self->step;
+            Py_INCREF(substep);
+        } else {
+            /* NB: slice step != Py_None here */
+            substep = PyNumber_Multiply(self->step, ((PySliceObject*)item)->step);
+            if (substep == NULL)
+                goto fail;
+        }
+        substart = compute_range_item(self, start);
+        if (substart == NULL)
+            goto fail;
+        if (len <= 0) {
+            substop = substart;
+            Py_INCREF(substop);
+        }
+        else {
+            substop = compute_range_item(self, stop);
+            if (substop == NULL)
+                goto fail;
+        }
+        result = make_range_object(Py_TYPE(self), substart, substop, substep);
+        if (result != NULL)
+            return (PyObject *) result;
+    fail:
+        Py_XDECREF(substart);
+        Py_XDECREF(substep);
+        Py_XDECREF(substop);
+        return NULL;
+    }
+    PyErr_Format(PyExc_TypeError,
+                 "range indices must be integers or slices, not %.200s",
+                 item->ob_type->tp_name);
+    return NULL;
+}
+
+
+static PyMappingMethods range_as_mapping = {
+        (lenfunc)range_length,       /* mp_length */
+        (binaryfunc)range_subscript, /* mp_subscript */
+        (objobjargproc)0,            /* mp_ass_subscript */
+};
+
 static PyObject * range_iter(PyObject *seq);
 static PyObject * range_reverse(PyObject *seq);
 
@@ -431,7 +521,7 @@
         (reprfunc)range_repr,   /* tp_repr */
         0,                      /* tp_as_number */
         &range_as_sequence,     /* tp_as_sequence */
-        0,                      /* tp_as_mapping */
+        &range_as_mapping,      /* tp_as_mapping */
         0,                      /* tp_hash */
         0,                      /* tp_call */
         0,                      /* tp_str */
@@ -491,22 +581,6 @@
     return PyLong_FromLong(r->len - r->index);
 }
 
-typedef struct {
-    PyObject_HEAD
-    PyObject *index;
-    PyObject *start;
-    PyObject *step;
-    PyObject *len;
-} longrangeiterobject;
-
-static PyObject *
-longrangeiter_len(longrangeiterobject *r, PyObject *no_args)
-{
-    return PyNumber_Subtract(r->len, r->index);
-}
-
-static PyObject *rangeiter_new(PyTypeObject *, PyObject *args, PyObject *kw);
-
 PyDoc_STRVAR(length_hint_doc,
              "Private method returning an estimate of len(list(it)).");
 
@@ -516,6 +590,8 @@
     {NULL,              NULL}           /* sentinel */
 };
 
+static PyObject *rangeiter_new(PyTypeObject *, PyObject *args, PyObject *kw);
+
 PyTypeObject PyRangeIter_Type = {
         PyVarObject_HEAD_INIT(&PyType_Type, 0)
         "range_iterator",                        /* tp_name */
@@ -590,7 +666,7 @@
    is not representable as a C long, OverflowError is raised. */
 
 static PyObject *
-int_range_iter(long start, long stop, long step)
+fast_range_iter(long start, long stop, long step)
 {
     rangeiterobject *it = PyObject_New(rangeiterobject, &PyRangeIter_Type);
     unsigned long ulen;
@@ -622,7 +698,21 @@
                           &start, &stop, &step))
         return NULL;
 
-    return int_range_iter(start, stop, step);
+    return fast_range_iter(start, stop, step);
+}
+
+typedef struct {
+    PyObject_HEAD
+    PyObject *index;
+    PyObject *start;
+    PyObject *step;
+    PyObject *len;
+} longrangeiterobject;
+
+static PyObject *
+longrangeiter_len(longrangeiterobject *r, PyObject *no_args)
+{
+    return PyNumber_Subtract(r->len, r->index);
 }
 
 static PyMethodDef longrangeiter_methods[] = {
@@ -736,7 +826,7 @@
         PyErr_Clear();
         goto long_range;
     }
-    int_it = int_range_iter(lstart, lstop, lstep);
+    int_it = fast_range_iter(lstart, lstop, lstep);
     if (int_it == NULL && PyErr_ExceptionMatches(PyExc_OverflowError)) {
         PyErr_Clear();
         goto long_range;
@@ -751,14 +841,11 @@
     /* Do all initialization here, so we can DECREF on failure. */
     it->start = r->start;
     it->step = r->step;
+    it->len = r->length;
     Py_INCREF(it->start);
     Py_INCREF(it->step);
+    Py_INCREF(it->len);
 
-    it->len = it->index = NULL;
-
-    it->len = range_length_obj(r);
-    if (!it->len)
-        goto create_failure;
     it->index = PyLong_FromLong(0);
     if (!it->index)
         goto create_failure;
@@ -775,7 +862,7 @@
 {
     rangeobject *range = (rangeobject*) seq;
     longrangeiterobject *it;
-    PyObject *one, *sum, *diff, *len = NULL, *product;
+    PyObject *one, *sum, *diff, *product;
     long lstart, lstop, lstep, new_start, new_stop;
     unsigned long ulen;
 
@@ -838,7 +925,7 @@
 
     new_stop = lstart - lstep;
     new_start = (long)(new_stop + ulen * lstep);
-    return int_range_iter(new_start, new_stop, -lstep);
+    return fast_range_iter(new_start, new_stop, -lstep);
 
 long_range:
     it = PyObject_New(longrangeiterobject, &PyLongRangeIter_Type);
@@ -846,18 +933,14 @@
         return NULL;
 
     /* start + (len - 1) * step */
-    len = range_length_obj(range);
-    if (!len)
-        goto create_failure;
-
-    /* Steal reference to len. */
-    it->len = len;
+    it->len = range->length;
+    Py_INCREF(it->len);
 
     one = PyLong_FromLong(1);
     if (!one)
         goto create_failure;
 
-    diff = PyNumber_Subtract(len, one);
+    diff = PyNumber_Subtract(it->len, one);
     Py_DECREF(one);
     if (!diff)
         goto create_failure;

Modified: python/branches/py3k-cdecimal/Objects/setobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/setobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/setobject.c	Sun Jan  2 13:18:37 2011
@@ -1525,6 +1525,20 @@
 "Remove all elements of another set from this set.");
 
 static PyObject *
+set_copy_and_difference(PySetObject *so, PyObject *other)
+{
+    PyObject *result;
+
+    result = set_copy(so);
+    if (result == NULL)
+        return NULL;
+    if (set_difference_update_internal((PySetObject *) result, other) != -1)
+        return result;
+    Py_DECREF(result);
+    return NULL;
+}
+
+static PyObject *
 set_difference(PySetObject *so, PyObject *other)
 {
     PyObject *result;
@@ -1532,13 +1546,13 @@
     Py_ssize_t pos = 0;
 
     if (!PyAnySet_Check(other)  && !PyDict_CheckExact(other)) {
-        result = set_copy(so);
-        if (result == NULL)
-            return NULL;
-        if (set_difference_update_internal((PySetObject *)result, other) != -1)
-            return result;
-        Py_DECREF(result);
-        return NULL;
+        return set_copy_and_difference(so, other);
+    }
+
+    /* If len(so) much more than len(other), it's more efficient to simply copy
+     * so and then iterate other looking for common elements. */
+    if ((PySet_GET_SIZE(so) >> 2) > PyObject_Size(other)) {
+        return set_copy_and_difference(so, other);
     }
 
     result = make_new_set_basetype(Py_TYPE(so), NULL);
@@ -1560,6 +1574,7 @@
         return result;
     }
 
+    /* Iterate over so, checking for common elements in other. */
     while (set_next(so, &pos, &entry)) {
         int rv = set_contains_entry((PySetObject *)other, entry);
         if (rv == -1) {

Modified: python/branches/py3k-cdecimal/Objects/sliceobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/sliceobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/sliceobject.c	Sun Jan  2 13:18:37 2011
@@ -99,9 +99,10 @@
 }
 
 int
-PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
+PySlice_GetIndices(PyObject *_r, Py_ssize_t length,
                    Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
 {
+    PySliceObject *r = (PySliceObject*)_r;
     /* XXX support long ints */
     if (r->step == Py_None) {
         *step = 1;
@@ -130,10 +131,11 @@
 }
 
 int
-PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
+PySlice_GetIndicesEx(PyObject *_r, Py_ssize_t length,
                      Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step,
                      Py_ssize_t *slicelength)
 {
+    PySliceObject *r = (PySliceObject*)_r;
     /* this is harder to get right than you might think */
 
     Py_ssize_t defstart, defstop;
@@ -256,7 +258,7 @@
         return NULL;
     }
 
-    if (PySlice_GetIndicesEx(self, ilen, &start, &stop,
+    if (PySlice_GetIndicesEx((PyObject*)self, ilen, &start, &stop,
                              &step, &slicelength) < 0) {
         return 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	Sun Jan  2 13:18:37 2011
@@ -941,13 +941,8 @@
        from a hard-code pseudo-locale */
     LocaleInfo locale;
 
-    /* Alternate is not allowed on floats. */
-    if (format->alternate) {
-        PyErr_SetString(PyExc_ValueError,
-                        "Alternate form (#) not allowed in float format "
-                        "specifier");
-        goto done;
-    }
+    if (format->alternate)
+        flags |= Py_DTSF_ALT;
 
     if (type == '\0') {
         /* Omitted type specifier.  Behaves in the same way as repr(x)
@@ -1104,15 +1099,7 @@
        from a hard-code pseudo-locale */
     LocaleInfo locale;
 
-    /* Alternate is not allowed on complex. */
-    if (format->alternate) {
-        PyErr_SetString(PyExc_ValueError,
-                        "Alternate form (#) not allowed in complex format "
-                        "specifier");
-        goto done;
-    }
-
-    /* Neither is zero pading. */
+    /* Zero padding is not allowed. */
     if (format->fill_char == '0') {
         PyErr_SetString(PyExc_ValueError,
                         "Zero padding is not allowed in complex format "
@@ -1135,6 +1122,9 @@
     if (im == -1.0 && PyErr_Occurred())
         goto done;
 
+    if (format->alternate)
+        flags |= Py_DTSF_ALT;
+
     if (type == '\0') {
         /* Omitted type specifier. Should be like str(self). */
         type = 'r';

Modified: python/branches/py3k-cdecimal/Objects/structseq.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/structseq.c	(original)
+++ python/branches/py3k-cdecimal/Objects/structseq.c	Sun Jan  2 13:18:37 2011
@@ -3,7 +3,6 @@
 
 #include "Python.h"
 #include "structmember.h"
-#include "structseq.h"
 
 static char visible_length_key[] = "n_sequence_fields";
 static char real_length_key[] = "n_fields";
@@ -44,6 +43,18 @@
     return (PyObject*)obj;
 }
 
+void
+PyStructSequence_SetItem(PyObject* op, Py_ssize_t i, PyObject* v)
+{
+    PyStructSequence_SET_ITEM(op, i, v);
+}
+
+PyObject*
+PyStructSequence_GetItem(PyObject* op, Py_ssize_t i)
+{
+    return PyStructSequence_GET_ITEM(op, i);
+}
+
 static void
 structseq_dealloc(PyStructSequence *obj)
 {
@@ -366,3 +377,11 @@
     SET_DICT_FROM_INT(real_length_key, n_members);
     SET_DICT_FROM_INT(unnamed_fields_key, n_unnamed_members);
 }
+
+PyTypeObject*
+PyStructSequence_NewType(PyStructSequence_Desc *desc)
+{
+    PyTypeObject *result = (PyTypeObject*)PyType_GenericAlloc(&PyType_Type, 0);
+    PyStructSequence_InitType(result, desc);
+    return result;
+}

Modified: python/branches/py3k-cdecimal/Objects/tupleobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/tupleobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/tupleobject.c	Sun Jan  2 13:18:37 2011
@@ -689,7 +689,7 @@
         PyObject* it;
         PyObject **src, **dest;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item,
+        if (PySlice_GetIndicesEx(item,
                          PyTuple_GET_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return NULL;

Modified: python/branches/py3k-cdecimal/Objects/typeobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/typeobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/typeobject.c	Sun Jan  2 13:18:37 2011
@@ -2304,6 +2304,44 @@
     return (PyObject *)type;
 }
 
+static short slotoffsets[] = {
+    -1, /* invalid slot */
+#include "typeslots.inc"
+};
+
+PyObject* PyType_FromSpec(PyType_Spec *spec)
+{
+    PyHeapTypeObject *res = (PyHeapTypeObject*)PyType_GenericAlloc(&PyType_Type, 0);
+    char *res_start = (char*)res;
+    PyType_Slot *slot;
+
+    res->ht_name = PyUnicode_FromString(spec->name);
+    if (!res->ht_name)
+	goto fail;
+    res->ht_type.tp_name = _PyUnicode_AsString(res->ht_name);
+    if (!res->ht_type.tp_name)
+	goto fail;
+
+    res->ht_type.tp_basicsize = spec->basicsize;
+    res->ht_type.tp_itemsize = spec->itemsize;
+    res->ht_type.tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
+    
+    for (slot = spec->slots; slot->slot; slot++) {
+	if (slot->slot >= sizeof(slotoffsets)/sizeof(slotoffsets[0])) {
+	    PyErr_SetString(PyExc_RuntimeError, "invalid slot offset");
+	    goto fail;
+	}
+	*(void**)(res_start + slotoffsets[slot->slot]) = slot->pfunc;
+    }
+
+    return (PyObject*)res;
+    
+ fail:
+    Py_DECREF(res);
+    return NULL;
+}
+
+
 /* Internal API to look for a name through the MRO.
    This returns a borrowed reference, and doesn't set an exception! */
 PyObject *

Modified: python/branches/py3k-cdecimal/Objects/unicodectype.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/unicodectype.c	(original)
+++ python/branches/py3k-cdecimal/Objects/unicodectype.c	Sun Jan  2 13:18:37 2011
@@ -9,7 +9,6 @@
 */
 
 #include "Python.h"
-#include "unicodeobject.h"
 
 #define ALPHA_MASK 0x01
 #define DECIMAL_MASK 0x02

Modified: python/branches/py3k-cdecimal/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k-cdecimal/Objects/unicodeobject.c	(original)
+++ python/branches/py3k-cdecimal/Objects/unicodeobject.c	Sun Jan  2 13:18:37 2011
@@ -41,9 +41,6 @@
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
-#include "bytes_methods.h"
-
-#include "unicodeobject.h"
 #include "ucnhash.h"
 
 #ifdef MS_WINDOWS
@@ -1264,7 +1261,7 @@
 }
 
 Py_ssize_t
-PyUnicode_AsWideChar(PyUnicodeObject *unicode,
+PyUnicode_AsWideChar(PyObject *unicode,
                      wchar_t *w,
                      Py_ssize_t size)
 {
@@ -1272,7 +1269,7 @@
         PyErr_BadInternalCall();
         return -1;
     }
-    return unicode_aswidechar(unicode, w, size);
+    return unicode_aswidechar((PyUnicodeObject*)unicode, w, size);
 }
 
 wchar_t*
@@ -6207,6 +6204,30 @@
     return NULL;
 }
 
+PyObject *
+PyUnicode_TransformDecimalToASCII(Py_UNICODE *s,
+                                  Py_ssize_t length)
+{
+    PyObject *result;
+    Py_UNICODE *p; /* write pointer into result */
+    Py_ssize_t i;
+    /* Copy to a new string */
+    result = (PyObject *)_PyUnicode_New(length);
+    Py_UNICODE_COPY(PyUnicode_AS_UNICODE(result), s, length);
+    if (result == NULL)
+        return result;
+    p = PyUnicode_AS_UNICODE(result);
+    /* Iterate over code points */
+    for (i = 0; i < length; i++) {
+        Py_UNICODE ch =s[i];
+        if (ch > 127) {
+            int decimal = Py_UNICODE_TODECIMAL(ch);
+            if (decimal >= 0)
+                p[i] = '0' + decimal;
+        }
+    }
+    return result;
+}
 /* --- Decimal Encoder ---------------------------------------------------- */
 
 int PyUnicode_EncodeDecimal(Py_UNICODE *s,
@@ -7425,26 +7446,11 @@
     static char *kwlist[] = {"encoding", "errors", 0};
     char *encoding = NULL;
     char *errors = NULL;
-    PyObject *v;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ss:encode",
                                      kwlist, &encoding, &errors))
         return NULL;
-    v = PyUnicode_AsEncodedString((PyObject *)self, encoding, errors);
-    if (v == NULL)
-        goto onError;
-    if (!PyBytes_Check(v)) {
-        PyErr_Format(PyExc_TypeError,
-                     "encoder did not return a bytes object "
-                     "(type=%.400s)",
-                     Py_TYPE(v)->tp_name);
-        Py_DECREF(v);
-        return NULL;
-    }
-    return v;
-
-  onError:
-    return NULL;
+    return PyUnicode_AsEncodedString((PyObject *)self, encoding, errors);
 }
 
 PyDoc_STRVAR(expandtabs__doc__,
@@ -8945,6 +8951,13 @@
 {
     return PyLong_FromLong(numfree);
 }
+
+static PyObject *
+unicode__decimal2ascii(PyObject *self)
+{
+    return PyUnicode_TransformDecimalToASCII(PyUnicode_AS_UNICODE(self),
+                                             PyUnicode_GET_SIZE(self));
+}
 #endif
 
 PyDoc_STRVAR(startswith__doc__,
@@ -9086,7 +9099,6 @@
     return Py_BuildValue("(u#)", v->str, v->length);
 }
 
-
 static PyMethodDef unicode_methods[] = {
 
     /* Order is according to common usage: often used methods should
@@ -9143,8 +9155,9 @@
 #endif
 
 #if 0
-    /* This one is just used for debugging the implementation. */
+    /* These methods are just used for debugging the implementation. */
     {"freelistsize", (PyCFunction) unicode_freelistsize, METH_NOARGS},
+    {"_decimal2ascii", (PyCFunction) unicode__decimal2ascii, METH_NOARGS},
 #endif
 
     {"__getnewargs__",  (PyCFunction)unicode_getnewargs, METH_NOARGS},
@@ -9195,7 +9208,7 @@
         Py_UNICODE* result_buf;
         PyObject* result;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item, PyUnicode_GET_SIZE(self),
+        if (PySlice_GetIndicesEx(item, PyUnicode_GET_SIZE(self),
                                  &start, &stop, &step, &slicelength) < 0) {
             return NULL;
         }

Modified: python/branches/py3k-cdecimal/PC/VC6/readme.txt
==============================================================================
--- python/branches/py3k-cdecimal/PC/VC6/readme.txt	(original)
+++ python/branches/py3k-cdecimal/PC/VC6/readme.txt	Sun Jan  2 13:18:37 2011
@@ -158,9 +158,17 @@
     You can (theoretically) use any version of OpenSSL you like - the
     build process will automatically select the latest version.
 
-    You must also install ActivePerl from
+    You can install the NASM assembler from
+        http://www.nasm.us/
+    for x86 builds.  Put nasmw.exe anywhere in your PATH.
+    Note: recent releases of nasm only have nasm.exe. Just rename it to 
+    nasmw.exe.
+
+    You can also install ActivePerl from
         http://www.activestate.com/activeperl/
-    as this is used by the OpenSSL build process.  Complain to them <wink>.
+    if you like to use the official sources instead of the files from 
+    python's subversion repository. The svn version contains pre-build
+    makefiles and assembly files.
 
     The MSVC project simply invokes PC/VC6/build_ssl.py to perform
     the build.  This Python script locates and builds your OpenSSL

Modified: python/branches/py3k-cdecimal/PC/getpathp.c
==============================================================================
--- python/branches/py3k-cdecimal/PC/getpathp.c	(original)
+++ python/branches/py3k-cdecimal/PC/getpathp.c	Sun Jan  2 13:18:37 2011
@@ -707,3 +707,38 @@
         calculate_path();
     return progpath;
 }
+
+/* Load python3.dll before loading any extension module that might refer 
+   to it. That way, we can be sure that always the python3.dll corresponding 
+   to this python DLL is loaded, not a python3.dll that might be on the path
+   by chance.
+   Return whether the DLL was found.
+*/
+static int python3_checked = 0;
+static HANDLE hPython3;
+int
+_Py_CheckPython3()
+{
+    wchar_t py3path[MAXPATHLEN+1];
+    wchar_t *s;
+    if (python3_checked)
+        return hPython3 != NULL;
+    python3_checked = 1;
+
+    /* If there is a python3.dll next to the python3y.dll,
+       assume this is a build tree; use that DLL */
+    wcscpy(py3path, dllpath);
+    s = wcsrchr(py3path, L'\\');
+    if (!s)
+        s = py3path;
+    wcscpy(s, L"\\python3.dll");
+    hPython3 = LoadLibraryExW(py3path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+    if (hPython3 != NULL)
+        return 1;
+
+    /* Check sys.prefix\DLLs\python3.dll */
+    wcscpy(py3path, Py_GetPrefix());
+    wcscat(py3path, L"\\DLLs\\python3.dll");
+    hPython3 = LoadLibraryExW(py3path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+    return hPython3 != NULL;
+}

Modified: python/branches/py3k-cdecimal/PC/pyconfig.h
==============================================================================
--- python/branches/py3k-cdecimal/PC/pyconfig.h	(original)
+++ python/branches/py3k-cdecimal/PC/pyconfig.h	Sun Jan  2 13:18:37 2011
@@ -318,8 +318,10 @@
 			/* So MSVC users need not specify the .lib file in
 			their Makefile (other compilers are generally
 			taken care of by distutils.) */
-#			ifdef _DEBUG
+#			if defined(_DEBUG)
 #				pragma comment(lib,"python32_d.lib")
+#			elif defined(Py_LIMITED_API)
+#				pragma comment(lib,"python3.lib")
 #			else
 #				pragma comment(lib,"python32.lib")
 #			endif /* _DEBUG */

Modified: python/branches/py3k-cdecimal/PC/python_nt.rc
==============================================================================
--- python/branches/py3k-cdecimal/PC/python_nt.rc	(original)
+++ python/branches/py3k-cdecimal/PC/python_nt.rc	Sun Jan  2 13:18:37 2011
@@ -61,7 +61,7 @@
             VALUE "FileDescription", "Python Core\0"
             VALUE "FileVersion", PYTHON_VERSION
             VALUE "InternalName", "Python DLL\0"
-            VALUE "LegalCopyright", "Copyright © 2001-2010 Python Software Foundation. Copyright © 2000 BeOpen.com. Copyright © 1995-2001 CNRI. Copyright © 1991-1995 SMC.\0"
+            VALUE "LegalCopyright", "Copyright © 2001-2011 Python Software Foundation. Copyright © 2000 BeOpen.com. Copyright © 1995-2001 CNRI. Copyright © 1991-1995 SMC.\0"
             VALUE "OriginalFilename", PYTHON_DLL_NAME "\0"
             VALUE "ProductName", "Python\0"
             VALUE "ProductVersion", PYTHON_VERSION

Modified: python/branches/py3k-cdecimal/PCbuild/build_tkinter.py
==============================================================================
--- python/branches/py3k-cdecimal/PCbuild/build_tkinter.py	(original)
+++ python/branches/py3k-cdecimal/PCbuild/build_tkinter.py	Sun Jan  2 13:18:37 2011
@@ -11,8 +11,8 @@
 here = os.path.abspath(os.path.dirname(__file__))
 par = os.path.pardir
 
-TCL = "tcl8.5.2"
-TK = "tk8.5.2"
+TCL = "tcl8.5.9"
+TK = "tk8.5.9"
 TIX = "tix-8.4.3.x"
 
 ROOT = os.path.abspath(os.path.join(here, par, par))

Modified: python/branches/py3k-cdecimal/PCbuild/make_buildinfo.c
==============================================================================
--- python/branches/py3k-cdecimal/PCbuild/make_buildinfo.c	(original)
+++ python/branches/py3k-cdecimal/PCbuild/make_buildinfo.c	Sun Jan  2 13:18:37 2011
@@ -52,9 +52,9 @@
     if (_stat(command+1, &st) < 0)
         /* subwcrev.exe not part of the release */
         return 0;
-    strcat_s(command, CMD_SIZE, "\" .. ..\\Modules\\getbuildinfo.c ");
-    strcat_s(command, CMD_SIZE, tmppath);
-    strcat_s(command, CMD_SIZE, "getbuildinfo2.c");
+    strcat_s(command, CMD_SIZE, "\" .. ..\\Modules\\getbuildinfo.c \"");
+    strcat_s(command, CMD_SIZE, tmppath); /* quoted tmppath */
+    strcat_s(command, CMD_SIZE, "getbuildinfo2.c\"");
     puts(command); fflush(stdout);
     if (system(command) < 0)
         return 0;
@@ -91,23 +91,36 @@
     if (argc > 2) {
         tmpdir = argv[2];
         strcat_s(tmppath, _countof(tmppath), tmpdir);
+        /* Hack fix for bad command line:  If the command is issued like this:
+         * $(SolutionDir)make_buildinfo.exe" Debug "$(IntDir)"
+         * we will get a trailing quote because IntDir ends with a backslash that then
+         * escapes the final ".  To simplify the life for developers, catch that problem
+         * here by cutting it off.
+         * The proper command line, btw is:
+         * $(SolutionDir)make_buildinfo.exe" Debug "$(IntDir)\"
+         * Hooray for command line parsing on windows.
+         */
+        if (strlen(tmppath) > 0 && tmppath[strlen(tmppath)-1] == '"')
+            tmppath[strlen(tmppath)-1] = '\0';
         strcat_s(tmppath, _countof(tmppath), "\\");
     }
 
     if ((do_unlink = make_buildinfo2(tmppath))) {
+        strcat_s(command, CMD_SIZE, "\"");
         strcat_s(command, CMD_SIZE, tmppath);
-        strcat_s(command, CMD_SIZE, "getbuildinfo2.c -DSUBWCREV ");
+        strcat_s(command, CMD_SIZE, "getbuildinfo2.c\" -DSUBWCREV ");
     } else
         strcat_s(command, CMD_SIZE, "..\\Modules\\getbuildinfo.c");
-    strcat_s(command, CMD_SIZE, " -Fo");
+    strcat_s(command, CMD_SIZE, " -Fo\"");
     strcat_s(command, CMD_SIZE, tmppath);
-    strcat_s(command, CMD_SIZE, "getbuildinfo.o -I..\\Include -I..\\PC");
+    strcat_s(command, CMD_SIZE, "getbuildinfo.o\" -I..\\Include -I..\\PC");
     puts(command); fflush(stdout);
     result = system(command);
     if (do_unlink) {
         command[0] = '\0';
+        strcat_s(command, CMD_SIZE, "\"");
         strcat_s(command, CMD_SIZE, tmppath);
-        strcat_s(command, CMD_SIZE, "getbuildinfo2.c");
+        strcat_s(command, CMD_SIZE, "getbuildinfo2.c\"");
         _unlink(command);
     }
     if (result < 0)

Modified: python/branches/py3k-cdecimal/PCbuild/pcbuild.sln
==============================================================================
--- python/branches/py3k-cdecimal/PCbuild/pcbuild.sln	(original)
+++ python/branches/py3k-cdecimal/PCbuild/pcbuild.sln	Sun Jan  2 13:18:37 2011
@@ -78,8 +78,8 @@
 	ProjectSection(ProjectDependencies) = postProject
 		{B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}
 		{86937F53-C189-40EF-8CE8-8759D8E7D480} = {86937F53-C189-40EF-8CE8-8759D8E7D480}
-		{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
 		{E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} = {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}
+		{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testcapi", "_testcapi.vcproj", "{6901D91C-6E48-4BB7-9FEC-700C8131DF1D}"
@@ -117,8 +117,8 @@
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_hashlib", "_hashlib.vcproj", "{447F05A8-F581-4CAC-A466-5AC7936E207E}"
 	ProjectSection(ProjectDependencies) = postProject
 		{B11D750F-CD1F-4A96-85CE-E69A5C5259F9} = {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}
-		{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
 		{E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0} = {E5B04CC0-EB4C-42AB-B4DC-18EF95F864B0}
+		{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite3", "sqlite3.vcproj", "{A1A295E5-463C-437F-81CA-1F32367685DA}"
@@ -138,6 +138,10 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kill_python", "kill_python.vcproj", "{6DE10744-E396-40A5-B4E2-1B69AA7C8D31}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python3dll", "python3dll.vcproj", "{885D4898-D08D-4091-9C40-C700CFE3FC5A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xxlimited", "xxlimited.vcproj", "{F749B822-B489-4CA5-A3AD-CE078F5F338A}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
@@ -574,6 +578,37 @@
 		{6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|Win32.Build.0 = Release|Win32
 		{6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|x64.ActiveCfg = Release|x64
 		{6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|x64.Build.0 = Release|x64
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Debug|Win32.ActiveCfg = PGInstrument|Win32
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Debug|x64.ActiveCfg = Debug|x64
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Debug|x64.Build.0 = Debug|x64
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGInstrument|Win32.Build.0 = PGInstrument|Win32
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGInstrument|x64.ActiveCfg = Release|x64
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGInstrument|x64.Build.0 = Release|x64
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGUpdate|Win32.Build.0 = PGUpdate|Win32
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGUpdate|x64.ActiveCfg = Release|x64
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGUpdate|x64.Build.0 = Release|x64
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|Win32.ActiveCfg = Release|Win32
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|Win32.Build.0 = Release|Win32
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|x64.ActiveCfg = Release|x64
+		{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|x64.Build.0 = Release|x64
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|Win32.ActiveCfg = Debug|Win32
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|Win32.Build.0 = Debug|Win32
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|x64.ActiveCfg = Debug|x64
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|x64.Build.0 = Debug|x64
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGInstrument|Win32.ActiveCfg = Release|Win32
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGInstrument|Win32.Build.0 = Release|Win32
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGInstrument|x64.ActiveCfg = Release|x64
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGInstrument|x64.Build.0 = Release|x64
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGUpdate|Win32.ActiveCfg = Release|Win32
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGUpdate|Win32.Build.0 = Release|Win32
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGUpdate|x64.ActiveCfg = Release|x64
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGUpdate|x64.Build.0 = Release|x64
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Release|Win32.ActiveCfg = Release|Win32
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Release|Win32.Build.0 = Release|Win32
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Release|x64.ActiveCfg = Release|x64
+		{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Release|x64.Build.0 = Release|x64
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

Modified: python/branches/py3k-cdecimal/PCbuild/pyproject.vsprops
==============================================================================
--- python/branches/py3k-cdecimal/PCbuild/pyproject.vsprops	(original)
+++ python/branches/py3k-cdecimal/PCbuild/pyproject.vsprops	Sun Jan  2 13:18:37 2011
@@ -50,7 +50,7 @@
 	/>
 	<UserMacro
 		Name="sqlite3Dir"
-		Value="$(externalsDir)\sqlite-3.6.21"
+		Value="$(externalsDir)\sqlite-3.7.4"
 	/>
 	<UserMacro
 		Name="bz2Dir"

Modified: python/branches/py3k-cdecimal/PCbuild/pythoncore.vcproj
==============================================================================
--- python/branches/py3k-cdecimal/PCbuild/pythoncore.vcproj	(original)
+++ python/branches/py3k-cdecimal/PCbuild/pythoncore.vcproj	Sun Jan  2 13:18:37 2011
@@ -59,11 +59,11 @@
 			<Tool
 				Name="VCPreLinkEventTool"
 				Description="Generate build information..."
-				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release $(IntDir)"
+				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release &quot;$(IntDir)\&quot;"
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="$(IntDir)\getbuildinfo.o"
+				AdditionalDependencies="&quot;$(IntDir)getbuildinfo.o&quot;"
 				OutputFile="$(OutDir)\$(PyDllName).dll"
 				IgnoreDefaultLibraryNames="libc"
 				ProgramDatabaseFile="$(OutDir)$(PyDllName).pdb"
@@ -134,11 +134,11 @@
 			<Tool
 				Name="VCPreLinkEventTool"
 				Description="Generate build information..."
-				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release $(IntDir)"
+				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release &quot;$(IntDir)\&quot;"
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="$(IntDir)\getbuildinfo.o"
+				AdditionalDependencies="&quot;$(IntDir)getbuildinfo.o&quot;"
 				OutputFile="$(OutDir)\$(PyDllName).dll"
 				IgnoreDefaultLibraryNames="libc"
 				ProgramDatabaseFile="$(OutDir)$(PyDllName).pdb"
@@ -212,11 +212,11 @@
 			<Tool
 				Name="VCPreLinkEventTool"
 				Description="Generate build information..."
-				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Debug $(IntDir)"
+				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Debug &quot;$(IntDir)\&quot;"
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="$(IntDir)\getbuildinfo.o"
+				AdditionalDependencies="&quot;$(IntDir)getbuildinfo.o&quot;"
 				OutputFile="$(OutDir)\$(PyDllName)_d.dll"
 				IgnoreDefaultLibraryNames="libc"
 				ProgramDatabaseFile="$(OutDir)$(PyDllName)_d.pdb"
@@ -290,11 +290,11 @@
 			<Tool
 				Name="VCPreLinkEventTool"
 				Description="Generate build information..."
-				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Debug $(IntDir)"
+				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Debug &quot;$(IntDir)\&quot;"
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="$(IntDir)\getbuildinfo.o"
+				AdditionalDependencies="&quot;$(IntDir)getbuildinfo.o&quot;"
 				OutputFile="$(OutDir)\$(PyDllName)_d.dll"
 				IgnoreDefaultLibraryNames="libc"
 				ProgramDatabaseFile="$(OutDir)$(PyDllName)_d.pdb"
@@ -364,11 +364,11 @@
 			<Tool
 				Name="VCPreLinkEventTool"
 				Description="Generate build information..."
-				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release $(IntDir)"
+				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release &quot;$(IntDir)\&quot;"
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="$(IntDir)\getbuildinfo.o"
+				AdditionalDependencies="&quot;$(IntDir)getbuildinfo.o&quot;"
 				OutputFile="$(OutDir)\$(PyDllName).dll"
 				IgnoreDefaultLibraryNames="libc"
 				ProgramDatabaseFile="$(OutDir)$(PyDllName).pdb"
@@ -439,11 +439,11 @@
 			<Tool
 				Name="VCPreLinkEventTool"
 				Description="Generate build information..."
-				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release $(IntDir)"
+				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release &quot;$(IntDir)\&quot;"
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="$(IntDir)\getbuildinfo.o"
+				AdditionalDependencies="&quot;$(IntDir)getbuildinfo.o&quot;"
 				OutputFile="$(OutDir)\$(PyDllName).dll"
 				IgnoreDefaultLibraryNames="libc"
 				ProgramDatabaseFile="$(OutDir)$(PyDllName).pdb"
@@ -514,11 +514,11 @@
 			<Tool
 				Name="VCPreLinkEventTool"
 				Description="Generate build information..."
-				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release ($IntDir)"
+				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release &quot;$(IntDir)\&quot;"
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="$(IntDir)\getbuildinfo.o"
+				AdditionalDependencies="&quot;$(IntDir)getbuildinfo.o&quot;"
 				OutputFile="$(OutDir)\$(PyDllName).dll"
 				IgnoreDefaultLibraryNames="libc"
 				ProgramDatabaseFile="$(OutDir)$(PyDllName).pdb"
@@ -589,11 +589,11 @@
 			<Tool
 				Name="VCPreLinkEventTool"
 				Description="Generate build information..."
-				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release $(IntDir)"
+				CommandLine="&quot;$(SolutionDir)make_buildinfo.exe&quot; Release &quot;$(IntDir)\&quot;"
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="$(IntDir)\getbuildinfo.o"
+				AdditionalDependencies="&quot;$(IntDir)getbuildinfo.o&quot;"
 				OutputFile="$(OutDir)\$(PyDllName).dll"
 				IgnoreDefaultLibraryNames="libc"
 				ProgramDatabaseFile="$(OutDir)$(PyDllName).pdb"

Modified: python/branches/py3k-cdecimal/PCbuild/readme.txt
==============================================================================
--- python/branches/py3k-cdecimal/PCbuild/readme.txt	(original)
+++ python/branches/py3k-cdecimal/PCbuild/readme.txt	Sun Jan  2 13:18:37 2011
@@ -104,7 +104,7 @@
 
 Python-controlled subprojects that wrap external projects:
 _sqlite3
-    Wraps SQLite 3.6.21, which is currently built by sqlite3.vcproj (see below).
+    Wraps SQLite 3.7.4, which is currently built by sqlite3.vcproj (see below).
 _tkinter
     Wraps the Tk windowing system.  Unlike _sqlite3, there's no
     corresponding tcltk.vcproj-type project that builds Tcl/Tk from vcproj's

Modified: python/branches/py3k-cdecimal/Parser/pgenmain.c
==============================================================================
--- python/branches/py3k-cdecimal/Parser/pgenmain.c	(original)
+++ python/branches/py3k-cdecimal/Parser/pgenmain.c	Sun Jan  2 13:18:37 2011
@@ -13,6 +13,8 @@
    - check for duplicate definitions of names (instead of fatal err)
 */
 
+#define PGEN
+
 #include "Python.h"
 #include "pgenheaders.h"
 #include "grammar.h"

Modified: python/branches/py3k-cdecimal/Parser/printgrammar.c
==============================================================================
--- python/branches/py3k-cdecimal/Parser/printgrammar.c	(original)
+++ python/branches/py3k-cdecimal/Parser/printgrammar.c	Sun Jan  2 13:18:37 2011
@@ -1,6 +1,8 @@
 
 /* Print a bunch of C initializers that represent a grammar */
 
+#define PGEN
+
 #include "pgenheaders.h"
 #include "grammar.h"
 

Modified: python/branches/py3k-cdecimal/Parser/tokenizer.c
==============================================================================
--- python/branches/py3k-cdecimal/Parser/tokenizer.c	(original)
+++ python/branches/py3k-cdecimal/Parser/tokenizer.c	Sun Jan  2 13:18:37 2011
@@ -545,6 +545,7 @@
 {
     char *line = NULL;
     int badchar = 0;
+    PyObject *filename;
     for (;;) {
         if (tok->decoding_state == STATE_NORMAL) {
             /* We already have a codec associated with
@@ -585,12 +586,16 @@
     if (badchar) {
         /* Need to add 1 to the line number, since this line
            has not been counted, yet.  */
-        PyErr_Format(PyExc_SyntaxError,
-            "Non-UTF-8 code starting with '\\x%.2x' "
-            "in file %.200s on line %i, "
-            "but no encoding declared; "
-            "see http://python.org/dev/peps/pep-0263/ for details",
-            badchar, tok->filename, tok->lineno + 1);
+        filename = PyUnicode_DecodeFSDefault(tok->filename);
+        if (filename != NULL) {
+            PyErr_Format(PyExc_SyntaxError,
+                    "Non-UTF-8 code starting with '\\x%.2x' "
+                    "in file %.200U on line %i, "
+                    "but no encoding declared; "
+                    "see http://python.org/dev/peps/pep-0263/ for details",
+                    badchar, filename, tok->lineno + 1);
+            Py_DECREF(filename);
+        }
         return error_ret(tok);
     }
 #endif

Modified: python/branches/py3k-cdecimal/Python/_warnings.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/_warnings.c	(original)
+++ python/branches/py3k-cdecimal/Python/_warnings.c	Sun Jan  2 13:18:37 2011
@@ -783,7 +783,7 @@
 {
     PyObject *res;
     PyObject *message = PyUnicode_FromString(text);
-    PyObject *filename = PyUnicode_FromString(filename_str);
+    PyObject *filename = PyUnicode_DecodeFSDefault(filename_str);
     PyObject *module = NULL;
     int ret = -1;
 

Modified: python/branches/py3k-cdecimal/Python/ast.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/ast.c	(original)
+++ python/branches/py3k-cdecimal/Python/ast.c	Sun Jan  2 13:18:37 2011
@@ -7,7 +7,6 @@
 #include "Python-ast.h"
 #include "grammar.h"
 #include "node.h"
-#include "pyarena.h"
 #include "ast.h"
 #include "token.h"
 #include "parsetok.h"

Modified: python/branches/py3k-cdecimal/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/bltinmodule.c	(original)
+++ python/branches/py3k-cdecimal/Python/bltinmodule.c	Sun Jan  2 13:18:37 2011
@@ -5,7 +5,6 @@
 
 #include "node.h"
 #include "code.h"
-#include "eval.h"
 
 #include <ctype.h>
 
@@ -311,6 +310,20 @@
 Return the binary representation of an integer or long integer.");
 
 
+static PyObject *
+builtin_callable(PyObject *self, PyObject *v)
+{
+    return PyBool_FromLong((long)PyCallable_Check(v));
+}
+
+PyDoc_STRVAR(callable_doc,
+"callable(object) -> bool\n\
+\n\
+Return whether the object is callable (i.e., some kind of function).\n\
+Note that classes are callable, as are instances of classes with a\n\
+__call__() method.");
+
+
 typedef struct {
     PyObject_HEAD
     PyObject *func;
@@ -530,19 +543,20 @@
     int mode = -1;
     int dont_inherit = 0;
     int supplied_flags = 0;
+    int optimize = -1;
     int is_ast;
     PyCompilerFlags cf;
     PyObject *cmd;
     static char *kwlist[] = {"source", "filename", "mode", "flags",
-                             "dont_inherit", NULL};
+                             "dont_inherit", "optimize", NULL};
     int start[] = {Py_file_input, Py_eval_input, Py_single_input};
     PyObject *result;
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&s|ii:compile",  kwlist,
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO&s|iii:compile",  kwlist,
                                      &cmd,
                                      PyUnicode_FSConverter, &filename_obj,
                                      &startstr, &supplied_flags,
-                                     &dont_inherit))
+                                     &dont_inherit, &optimize))
         return NULL;
 
     filename = PyBytes_AS_STRING(filename_obj);
@@ -557,6 +571,12 @@
     }
     /* XXX Warn if (supplied_flags & PyCF_MASK_OBSOLETE) != 0? */
 
+    if (optimize < -1 || optimize > 2) {
+        PyErr_SetString(PyExc_ValueError,
+                        "compile(): invalid optimize value");
+        goto error;
+    }
+
     if (!dont_inherit) {
         PyEval_MergeCompilerFlags(&cf);
     }
@@ -591,8 +611,8 @@
                 PyArena_Free(arena);
                 goto error;
             }
-            result = (PyObject*)PyAST_Compile(mod, filename,
-                                              &cf, arena);
+            result = (PyObject*)PyAST_CompileEx(mod, filename,
+                                                &cf, optimize, arena);
             PyArena_Free(arena);
         }
         goto finally;
@@ -602,7 +622,7 @@
     if (str == NULL)
         goto error;
 
-    result = Py_CompileStringFlags(str, filename, start[mode], &cf);
+    result = Py_CompileStringExFlags(str, filename, start[mode], &cf, optimize);
     goto finally;
 
 error:
@@ -714,7 +734,7 @@
         "code object passed to eval() may not contain free variables");
             return NULL;
         }
-        return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals);
+        return PyEval_EvalCode(cmd, globals, locals);
     }
 
     cf.cf_flags = PyCF_SOURCE_IS_UTF8;
@@ -790,7 +810,7 @@
                 "contain free variables");
             return NULL;
         }
-        v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals);
+        v = PyEval_EvalCode(prog, globals, locals);
     }
     else {
         char *str;
@@ -2242,6 +2262,7 @@
     {"any",             builtin_any,        METH_O, any_doc},
     {"ascii",           builtin_ascii,      METH_O, ascii_doc},
     {"bin",             builtin_bin,        METH_O, bin_doc},
+    {"callable",        builtin_callable,   METH_O, callable_doc},
     {"chr",             builtin_chr,        METH_VARARGS, chr_doc},
     {"compile",         (PyCFunction)builtin_compile,    METH_VARARGS | METH_KEYWORDS, compile_doc},
     {"delattr",         builtin_delattr,    METH_VARARGS, delattr_doc},

Modified: python/branches/py3k-cdecimal/Python/ceval.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/ceval.c	(original)
+++ python/branches/py3k-cdecimal/Python/ceval.c	Sun Jan  2 13:18:37 2011
@@ -13,7 +13,6 @@
 
 #include "code.h"
 #include "frameobject.h"
-#include "eval.h"
 #include "opcode.h"
 #include "structmember.h"
 
@@ -756,7 +755,7 @@
 
 
 PyObject *
-PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
+PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals)
 {
     return PyEval_EvalCodeEx(co,
                       globals, locals,
@@ -3060,10 +3059,11 @@
    the test in the if statements in Misc/gdbinit (pystack and pystackv). */
 
 PyObject *
-PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
+PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,
            PyObject **args, int argcount, PyObject **kws, int kwcount,
            PyObject **defs, int defcount, PyObject *kwdefs, PyObject *closure)
 {
+    PyCodeObject* co = (PyCodeObject*)_co;
     register PyFrameObject *f;
     register PyObject *retval = NULL;
     register PyObject **fastlocals, **freevars;
@@ -3969,7 +3969,7 @@
         d = &PyTuple_GET_ITEM(argdefs, 0);
         nd = Py_SIZE(argdefs);
     }
-    return PyEval_EvalCodeEx(co, globals,
+    return PyEval_EvalCodeEx((PyObject*)co, globals,
                              (PyObject *)NULL, (*pp_stack)-n, na,
                              (*pp_stack)-2*nk, nk, d, nd, kwdefs,
                              PyFunction_GET_CLOSURE(func));

Modified: python/branches/py3k-cdecimal/Python/compile.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/compile.c	(original)
+++ python/branches/py3k-cdecimal/Python/compile.c	Sun Jan  2 13:18:37 2011
@@ -25,10 +25,8 @@
 
 #include "Python-ast.h"
 #include "node.h"
-#include "pyarena.h"
 #include "ast.h"
 #include "code.h"
-#include "compile.h"
 #include "symtable.h"
 #include "opcode.h"
 
@@ -141,6 +139,7 @@
     PyFutureFeatures *c_future; /* pointer to module's __future__ */
     PyCompilerFlags *c_flags;
 
+    int c_optimize;              /* optimization level */
     int c_interactive;           /* true if in interactive mode */
     int c_nestlevel;
 
@@ -177,7 +176,7 @@
 static int compiler_in_loop(struct compiler *);
 
 static int inplace_binop(struct compiler *, operator_ty);
-static int expr_constant(expr_ty e);
+static int expr_constant(struct compiler *, expr_ty);
 
 static int compiler_with(struct compiler *, stmt_ty);
 static int compiler_call_helper(struct compiler *c, int n,
@@ -256,8 +255,8 @@
 }
 
 PyCodeObject *
-PyAST_Compile(mod_ty mod, const char *filename, PyCompilerFlags *flags,
-              PyArena *arena)
+PyAST_CompileEx(mod_ty mod, const char *filename, PyCompilerFlags *flags,
+                int optimize, PyArena *arena)
 {
     struct compiler c;
     PyCodeObject *co = NULL;
@@ -285,6 +284,7 @@
     c.c_future->ff_features = merged;
     flags->cf_flags = merged;
     c.c_flags = flags;
+    c.c_optimize = (optimize == -1) ? Py_OptimizeFlag : optimize;
     c.c_nestlevel = 0;
 
     c.c_st = PySymtable_Build(mod, filename, c.c_future);
@@ -1151,7 +1151,7 @@
     if (!asdl_seq_LEN(stmts))
         return 1;
     st = (stmt_ty)asdl_seq_GET(stmts, 0);
-    if (compiler_isdocstring(st) && Py_OptimizeFlag < 2) {
+    if (compiler_isdocstring(st) && c->c_optimize < 2) {
         /* don't generate docstrings if -OO */
         i = 1;
         VISIT(c, expr, st->v.Expr.value);
@@ -1465,7 +1465,7 @@
 
     st = (stmt_ty)asdl_seq_GET(s->v.FunctionDef.body, 0);
     docstring = compiler_isdocstring(st);
-    if (docstring && Py_OptimizeFlag < 2)
+    if (docstring && c->c_optimize < 2)
         first_const = st->v.Expr.value->v.Str.s;
     if (compiler_add_o(c, c->u->u_consts, first_const) < 0)      {
         compiler_exit_scope(c);
@@ -1699,7 +1699,7 @@
     if (end == NULL)
         return 0;
 
-    constant = expr_constant(s->v.If.test);
+    constant = expr_constant(c, s->v.If.test);
     /* constant = 0: "if 0"
      * constant = 1: "if 1", "if 2", ...
      * constant = -1: rest */
@@ -1761,7 +1761,7 @@
 compiler_while(struct compiler *c, stmt_ty s)
 {
     basicblock *loop, *orelse, *end, *anchor = NULL;
-    int constant = expr_constant(s->v.While.test);
+    int constant = expr_constant(c, s->v.While.test);
 
     if (constant == 0) {
         if (s->v.While.orelse)
@@ -2213,7 +2213,7 @@
     static PyObject *assertion_error = NULL;
     basicblock *end;
 
-    if (Py_OptimizeFlag)
+    if (c->c_optimize)
         return 1;
     if (assertion_error == NULL) {
         assertion_error = PyUnicode_InternFromString("AssertionError");
@@ -3013,7 +3013,7 @@
  */
 
 static int
-expr_constant(expr_ty e)
+expr_constant(struct compiler *c, expr_ty e)
 {
     char *id;
     switch (e->kind) {
@@ -3031,7 +3031,7 @@
         if (strcmp(id, "False") == 0) return 0;
         if (strcmp(id, "None") == 0) return 0;
         if (strcmp(id, "__debug__") == 0)
-            return ! Py_OptimizeFlag;
+            return ! c->c_optimize;
         /* fall through */
     default:
         return -1;
@@ -4082,3 +4082,13 @@
     assemble_free(&a);
     return co;
 }
+
+#undef PyAST_Compile
+PyAPI_FUNC(PyCodeObject *)
+PyAST_Compile(mod_ty mod, const char *filename, PyCompilerFlags *flags,
+              PyArena *arena)
+{
+    return PyAST_CompileEx(mod, filename, flags, -1, arena);
+}
+
+

Modified: python/branches/py3k-cdecimal/Python/dynload_shlib.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/dynload_shlib.c	(original)
+++ python/branches/py3k-cdecimal/Python/dynload_shlib.c	Sun Jan  2 13:18:37 2011
@@ -53,6 +53,8 @@
 #else  /* !__VMS */
     {"." SOABI ".so", "rb", C_EXTENSION},
     {"module." SOABI ".so", "rb", C_EXTENSION},
+    {".abi" PYTHON_ABI_STRING ".so", "rb", C_EXTENSION},
+    {"module.abi" PYTHON_ABI_STRING ".so", "rb", C_EXTENSION},
     {".so", "rb", C_EXTENSION},
     {"module.so", "rb", C_EXTENSION},
 #endif  /* __VMS */

Modified: python/branches/py3k-cdecimal/Python/dynload_win.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/dynload_win.c	(original)
+++ python/branches/py3k-cdecimal/Python/dynload_win.c	Sun Jan  2 13:18:37 2011
@@ -134,6 +134,15 @@
                 !strncmp(import_name,"python",6)) {
                 char *pch;
 
+#ifndef _DEBUG
+                /* In a release version, don't claim that python3.dll is
+                   a Python DLL. */
+                if (strcmp(import_name, "python3.dll") == 0) {
+                    import_data += 20;
+                    continue;
+                }
+#endif
+
                 /* Ensure python prefix is followed only
                    by numbers to the end of the basename */
                 pch = import_name + 6;
@@ -162,13 +171,16 @@
     return NULL;
 }
 
-
 dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
                                     const char *pathname, FILE *fp)
 {
     dl_funcptr p;
     char funcname[258], *import_python;
 
+#ifndef _DEBUG
+    _Py_CheckPython3();
+#endif
+
     PyOS_snprintf(funcname, sizeof(funcname), "PyInit_%.200s", shortname);
 
     {

Modified: python/branches/py3k-cdecimal/Python/errors.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/errors.c	(original)
+++ python/branches/py3k-cdecimal/Python/errors.c	Sun Jan  2 13:18:37 2011
@@ -515,7 +515,7 @@
     int ierr,
     const char *filename)
 {
-    PyObject *name = filename ? PyUnicode_FromString(filename) : NULL;
+    PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
     PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObject(exc,
                                                                  ierr,
                                                                  name);
@@ -552,7 +552,7 @@
     int ierr,
     const char *filename)
 {
-    PyObject *name = filename ? PyUnicode_FromString(filename) : NULL;
+    PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
     PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObject(
                                                   PyExc_WindowsError,
                                                   ierr, name);

Modified: python/branches/py3k-cdecimal/Python/future.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/future.c	(original)
+++ python/branches/py3k-cdecimal/Python/future.c	Sun Jan  2 13:18:37 2011
@@ -4,7 +4,6 @@
 #include "token.h"
 #include "graminit.h"
 #include "code.h"
-#include "compile.h"
 #include "symtable.h"
 
 #define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined"

Modified: python/branches/py3k-cdecimal/Python/getcopyright.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/getcopyright.c	(original)
+++ python/branches/py3k-cdecimal/Python/getcopyright.c	Sun Jan  2 13:18:37 2011
@@ -4,7 +4,7 @@
 
 static char cprt[] =
 "\
-Copyright (c) 2001-2010 Python Software Foundation.\n\
+Copyright (c) 2001-2011 Python Software Foundation.\n\
 All Rights Reserved.\n\
 \n\
 Copyright (c) 2000 BeOpen.com.\n\

Modified: python/branches/py3k-cdecimal/Python/import.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/import.c	(original)
+++ python/branches/py3k-cdecimal/Python/import.c	Sun Jan  2 13:18:37 2011
@@ -5,13 +5,9 @@
 
 #include "Python-ast.h"
 #undef Yield /* undefine macro conflicting with winbase.h */
-#include "pyarena.h"
-#include "pythonrun.h"
 #include "errcode.h"
 #include "marshal.h"
 #include "code.h"
-#include "compile.h"
-#include "eval.h"
 #include "osdefs.h"
 #include "importdl.h"
 
@@ -329,8 +325,17 @@
 {
     if (import_lock != NULL)
         import_lock = PyThread_allocate_lock();
-    import_lock_thread = -1;
-    import_lock_level = 0;
+    if (import_lock_level > 1) {
+        /* Forked as a side effect of import */
+        long me = PyThread_get_thread_ident();
+        PyThread_acquire_lock(import_lock, 0);
+	/* XXX: can the previous line fail? */
+        import_lock_thread = me;
+        import_lock_level--;
+    } else {
+        import_lock_thread = -1;
+        import_lock_level = 0;
+    }
 }
 
 #endif
@@ -801,7 +806,7 @@
         PyErr_Clear(); /* Not important enough to report */
     Py_DECREF(v);
 
-    v = PyEval_EvalCode((PyCodeObject *)co, d, d);
+    v = PyEval_EvalCode(co, d, d);
     if (v == NULL)
         goto error;
     Py_DECREF(v);
@@ -3201,14 +3206,14 @@
 static PyObject *
 imp_find_module(PyObject *self, PyObject *args)
 {
-    char *name;
+    PyObject *name;
     PyObject *ret, *path = NULL;
-    if (!PyArg_ParseTuple(args, "es|O:find_module",
-                          Py_FileSystemDefaultEncoding, &name,
+    if (!PyArg_ParseTuple(args, "O&|O:find_module",
+                          PyUnicode_FSConverter, &name,
                           &path))
         return NULL;
-    ret = call_find_module(name, path);
-    PyMem_Free(name);
+    ret = call_find_module(PyBytes_AS_STRING(name), path);
+    Py_DECREF(name);
     return ret;
 }
 
@@ -3326,23 +3331,23 @@
 imp_load_compiled(PyObject *self, PyObject *args)
 {
     char *name;
-    char *pathname;
+    PyObject *pathname;
     PyObject *fob = NULL;
     PyObject *m;
     FILE *fp;
-    if (!PyArg_ParseTuple(args, "ses|O:load_compiled",
+    if (!PyArg_ParseTuple(args, "sO&|O:load_compiled",
                           &name,
-                          Py_FileSystemDefaultEncoding, &pathname,
+                          PyUnicode_FSConverter, &pathname,
                           &fob))
         return NULL;
-    fp = get_file(pathname, fob, "rb");
+    fp = get_file(PyBytes_AS_STRING(pathname), fob, "rb");
     if (fp == NULL) {
-        PyMem_Free(pathname);
+        Py_DECREF(pathname);
         return NULL;
     }
-    m = load_compiled_module(name, pathname, fp);
+    m = load_compiled_module(name, PyBytes_AS_STRING(pathname), fp);
     fclose(fp);
-    PyMem_Free(pathname);
+    Py_DECREF(pathname);
     return m;
 }
 
@@ -3381,22 +3386,22 @@
 imp_load_source(PyObject *self, PyObject *args)
 {
     char *name;
-    char *pathname;
+    PyObject *pathname;
     PyObject *fob = NULL;
     PyObject *m;
     FILE *fp;
-    if (!PyArg_ParseTuple(args, "ses|O:load_source",
+    if (!PyArg_ParseTuple(args, "sO&|O:load_source",
                           &name,
-                          Py_FileSystemDefaultEncoding, &pathname,
+                          PyUnicode_FSConverter, &pathname,
                           &fob))
         return NULL;
-    fp = get_file(pathname, fob, "r");
+    fp = get_file(PyBytes_AS_STRING(pathname), fob, "r");
     if (fp == NULL) {
-        PyMem_Free(pathname);
+        Py_DECREF(pathname);
         return NULL;
     }
-    m = load_source_module(name, pathname, fp);
-    PyMem_Free(pathname);
+    m = load_source_module(name, PyBytes_AS_STRING(pathname), fp);
+    Py_DECREF(pathname);
     fclose(fp);
     return m;
 }
@@ -3450,13 +3455,13 @@
 imp_load_package(PyObject *self, PyObject *args)
 {
     char *name;
-    char *pathname;
+    PyObject *pathname;
     PyObject * ret;
-    if (!PyArg_ParseTuple(args, "ses:load_package",
-                          &name, Py_FileSystemDefaultEncoding, &pathname))
+    if (!PyArg_ParseTuple(args, "sO&:load_package",
+                          &name, PyUnicode_FSConverter, &pathname))
         return NULL;
-    ret = load_package(name, pathname);
-    PyMem_Free(pathname);
+    ret = load_package(name, PyBytes_AS_STRING(pathname));
+    Py_DECREF(pathname);
     return ret;
 }
 
@@ -3529,21 +3534,23 @@
 {
     static char *kwlist[] = {"path", NULL};
 
+    PyObject *pathname_obj;
     char *pathname;
     char buf[MAXPATHLEN+1];
 
     if (!PyArg_ParseTupleAndKeywords(
-                args, kws, "es", kwlist,
-                Py_FileSystemDefaultEncoding, &pathname))
+                args, kws, "O&", kwlist,
+                PyUnicode_FSConverter, &pathname_obj))
         return NULL;
 
+    pathname = PyBytes_AS_STRING(pathname_obj);
     if (make_source_pathname(pathname, buf) == NULL) {
         PyErr_Format(PyExc_ValueError, "Not a PEP 3147 pyc path: %s",
                      pathname);
-        PyMem_Free(pathname);
+        Py_DECREF(pathname_obj);
         return NULL;
     }
-    PyMem_Free(pathname);
+    Py_DECREF(pathname_obj);
     return PyUnicode_FromString(buf);
 }
 

Modified: python/branches/py3k-cdecimal/Python/peephole.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/peephole.c	(original)
+++ python/branches/py3k-cdecimal/Python/peephole.c	Sun Jan  2 13:18:37 2011
@@ -4,10 +4,8 @@
 
 #include "Python-ast.h"
 #include "node.h"
-#include "pyarena.h"
 #include "ast.h"
 #include "code.h"
-#include "compile.h"
 #include "symtable.h"
 #include "opcode.h"
 

Modified: python/branches/py3k-cdecimal/Python/pyarena.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/pyarena.c	(original)
+++ python/branches/py3k-cdecimal/Python/pyarena.c	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,4 @@
 #include "Python.h"
-#include "pyarena.h"
 
 /* A simple arena block structure.
 

Modified: python/branches/py3k-cdecimal/Python/pythonrun.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/pythonrun.c	(original)
+++ python/branches/py3k-cdecimal/Python/pythonrun.c	Sun Jan  2 13:18:37 2011
@@ -11,14 +11,10 @@
 #include "parsetok.h"
 #include "errcode.h"
 #include "code.h"
-#include "compile.h"
 #include "symtable.h"
-#include "pyarena.h"
 #include "ast.h"
-#include "eval.h"
 #include "marshal.h"
 #include "osdefs.h"
-#include "abstract.h"
 
 #ifdef HAVE_SIGNAL_H
 #include <signal.h>
@@ -82,6 +78,7 @@
 
 int Py_DebugFlag; /* Needed by parser.c */
 int Py_VerboseFlag; /* Needed by import.c */
+int Py_QuietFlag; /* Needed by sysmodule.c */
 int Py_InteractiveFlag; /* Needed by Py_FdIsInteractive() below */
 int Py_InspectFlag; /* Needed to determine whether to exit at SystemError */
 int Py_NoSiteFlag; /* Suppress 'import site' */
@@ -1759,7 +1756,7 @@
     co = PyAST_Compile(mod, filename, flags, arena);
     if (co == NULL)
         return NULL;
-    v = PyEval_EvalCode(co, globals, locals);
+    v = PyEval_EvalCode((PyObject*)co, globals, locals);
     Py_DECREF(co);
     return v;
 }
@@ -1789,7 +1786,7 @@
         return NULL;
     }
     co = (PyCodeObject *)v;
-    v = PyEval_EvalCode(co, globals, locals);
+    v = PyEval_EvalCode((PyObject*)co, globals, locals);
     if (v && flags)
         flags->cf_flags |= (co->co_flags & PyCF_MASK);
     Py_DECREF(co);
@@ -1797,8 +1794,8 @@
 }
 
 PyObject *
-Py_CompileStringFlags(const char *str, const char *filename, int start,
-                      PyCompilerFlags *flags)
+Py_CompileStringExFlags(const char *str, const char *filename, int start,
+                        PyCompilerFlags *flags, int optimize)
 {
     PyCodeObject *co;
     mod_ty mod;
@@ -1816,11 +1813,19 @@
         PyArena_Free(arena);
         return result;
     }
-    co = PyAST_Compile(mod, filename, flags, arena);
+    co = PyAST_CompileEx(mod, filename, flags, optimize, arena);
     PyArena_Free(arena);
     return (PyObject *)co;
 }
 
+/* For use in Py_LIMITED_API */
+#undef Py_CompileString
+PyObject *
+PyCompileString(const char *str, const char *filename, int start)
+{
+    return Py_CompileStringFlags(str, filename, start, NULL);
+}
+
 struct symtable *
 Py_SymtableString(const char *str, const char *filename, int start)
 {
@@ -2446,7 +2451,15 @@
 PyAPI_FUNC(PyObject *)
 Py_CompileString(const char *str, const char *p, int s)
 {
-    return Py_CompileStringFlags(str, p, s, NULL);
+    return Py_CompileStringExFlags(str, p, s, NULL, -1);
+}
+
+#undef Py_CompileStringFlags
+PyAPI_FUNC(PyObject *)
+Py_CompileStringFlags(const char *str, const char *p, int s,
+                      PyCompilerFlags *flags)
+{
+    return Py_CompileStringExFlags(str, p, s, flags, -1);
 }
 
 #undef PyRun_InteractiveOne

Modified: python/branches/py3k-cdecimal/Python/sysmodule.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/sysmodule.c	(original)
+++ python/branches/py3k-cdecimal/Python/sysmodule.c	Sun Jan  2 13:18:37 2011
@@ -15,10 +15,8 @@
 */
 
 #include "Python.h"
-#include "structseq.h"
 #include "code.h"
 #include "frameobject.h"
-#include "eval.h"
 
 #include "osdefs.h"
 
@@ -67,6 +65,68 @@
         return PyDict_SetItemString(sd, name, v);
 }
 
+/* Write repr(o) to sys.stdout using sys.stdout.encoding and 'backslashreplace'
+   error handler. If sys.stdout has a buffer attribute, use
+   sys.stdout.buffer.write(encoded), otherwise redecode the string and use
+   sys.stdout.write(redecoded).
+
+   Helper function for sys_displayhook(). */
+static int
+sys_displayhook_unencodable(PyObject *outf, PyObject *o)
+{
+    PyObject *stdout_encoding = NULL;
+    PyObject *encoded, *escaped_str, *repr_str, *buffer, *result;
+    char *stdout_encoding_str;
+    int ret;
+
+    stdout_encoding = PyObject_GetAttrString(outf, "encoding");
+    if (stdout_encoding == NULL)
+        goto error;
+    stdout_encoding_str = _PyUnicode_AsString(stdout_encoding);
+    if (stdout_encoding_str == NULL)
+        goto error;
+
+    repr_str = PyObject_Repr(o);
+    if (repr_str == NULL)
+        goto error;
+    encoded = PyUnicode_AsEncodedString(repr_str,
+                                        stdout_encoding_str,
+                                        "backslashreplace");
+    Py_DECREF(repr_str);
+    if (encoded == NULL)
+        goto error;
+
+    buffer = PyObject_GetAttrString(outf, "buffer");
+    if (buffer) {
+        result = PyObject_CallMethod(buffer, "write", "(O)", encoded);
+        Py_DECREF(buffer);
+        Py_DECREF(encoded);
+        if (result == NULL)
+            goto error;
+        Py_DECREF(result);
+    }
+    else {
+        PyErr_Clear();
+        escaped_str = PyUnicode_FromEncodedObject(encoded,
+                                                  stdout_encoding_str,
+                                                  "strict");
+        Py_DECREF(encoded);
+        if (PyFile_WriteObject(escaped_str, outf, Py_PRINT_RAW) != 0) {
+            Py_DECREF(escaped_str);
+            goto error;
+        }
+        Py_DECREF(escaped_str);
+    }
+    ret = 0;
+    goto finally;
+
+error:
+    ret = -1;
+finally:
+    Py_XDECREF(stdout_encoding);
+    return ret;
+}
+
 static PyObject *
 sys_displayhook(PyObject *self, PyObject *o)
 {
@@ -74,6 +134,7 @@
     PyInterpreterState *interp = PyThreadState_GET()->interp;
     PyObject *modules = interp->modules;
     PyObject *builtins = PyDict_GetItemString(modules, "builtins");
+    int err;
 
     if (builtins == NULL) {
         PyErr_SetString(PyExc_RuntimeError, "lost builtins module");
@@ -94,8 +155,19 @@
         PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
         return NULL;
     }
-    if (PyFile_WriteObject(o, outf, 0) != 0)
-        return NULL;
+    if (PyFile_WriteObject(o, outf, 0) != 0) {
+        if (PyErr_ExceptionMatches(PyExc_UnicodeEncodeError)) {
+            /* repr(o) is not encodable to sys.stdout.encoding with
+             * sys.stdout.errors error handler (which is probably 'strict') */
+            PyErr_Clear();
+            err = sys_displayhook_unencodable(outf, o);
+            if (err)
+                return NULL;
+        }
+        else {
+            return NULL;
+        }
+    }
     if (PyFile_WriteString("\n", outf) != 0)
         return NULL;
     if (PyObject_SetAttrString(builtins, "_", o) != 0)
@@ -1345,7 +1417,8 @@
 #endif
     /* {"unbuffered",                   "-u"}, */
     /* {"skip_first",                   "-x"}, */
-    {"bytes_warning", "-b"},
+    {"bytes_warning",           "-b"},
+    {"quiet",                   "-q"},
     {0}
 };
 
@@ -1389,6 +1462,7 @@
     /* SetFlag(saw_unbuffered_flag); */
     /* SetFlag(skipfirstline); */
     SetFlag(Py_BytesWarningFlag);
+    SetFlag(Py_QuietFlag);
 #undef SetFlag
 
     if (PyErr_Occurred()) {

Modified: python/branches/py3k-cdecimal/Python/thread_nt.h
==============================================================================
--- python/branches/py3k-cdecimal/Python/thread_nt.h	(original)
+++ python/branches/py3k-cdecimal/Python/thread_nt.h	Sun Jan  2 13:18:37 2011
@@ -238,10 +238,13 @@
  * and 0 if the lock was not acquired. This means a 0 is returned
  * if the lock has already been acquired by this thread!
  */
-int
-PyThread_acquire_lock_timed(PyThread_type_lock aLock, PY_TIMEOUT_T microseconds)
-{
-    int success ;
+PyLockStatus
+PyThread_acquire_lock_timed(PyThread_type_lock aLock,
+                            PY_TIMEOUT_T microseconds, int intr_flag)
+{
+    /* Fow now, intr_flag does nothing on Windows, and lock acquires are
+     * uninterruptible.  */
+    PyLockStatus success;
     PY_TIMEOUT_T milliseconds;
 
     if (microseconds >= 0) {
@@ -258,7 +261,13 @@
     dprintf(("%ld: PyThread_acquire_lock_timed(%p, %lld) called\n",
              PyThread_get_thread_ident(), aLock, microseconds));
 
-    success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (DWORD) milliseconds) == WAIT_OBJECT_0 ;
+    if (aLock && EnterNonRecursiveMutex((PNRMUTEX)aLock,
+                                        (DWORD)milliseconds) == WAIT_OBJECT_0) {
+        success = PY_LOCK_ACQUIRED;
+    }
+    else {
+        success = PY_LOCK_FAILURE;
+    }
 
     dprintf(("%ld: PyThread_acquire_lock(%p, %lld) -> %d\n",
              PyThread_get_thread_ident(), aLock, microseconds, success));
@@ -268,7 +277,7 @@
 int
 PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
 {
-    return PyThread_acquire_lock_timed(aLock, waitflag ? -1 : 0);
+    return PyThread_acquire_lock_timed(aLock, waitflag ? -1 : 0, 0);
 }
 
 void

Modified: python/branches/py3k-cdecimal/Python/thread_pthread.h
==============================================================================
--- python/branches/py3k-cdecimal/Python/thread_pthread.h	(original)
+++ python/branches/py3k-cdecimal/Python/thread_pthread.h	Sun Jan  2 13:18:37 2011
@@ -316,16 +316,17 @@
     return (status == -1) ? errno : status;
 }
 
-int
-PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds)
+PyLockStatus
+PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
+                            int intr_flag)
 {
-    int success;
+    PyLockStatus success;
     sem_t *thelock = (sem_t *)lock;
     int status, error = 0;
     struct timespec ts;
 
-    dprintf(("PyThread_acquire_lock_timed(%p, %lld) called\n",
-             lock, microseconds));
+    dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n",
+             lock, microseconds, intr_flag));
 
     if (microseconds > 0)
         MICROSECONDS_TO_TIMESPEC(microseconds, ts);
@@ -336,33 +337,38 @@
             status = fix_status(sem_trywait(thelock));
         else
             status = fix_status(sem_wait(thelock));
-    } while (status == EINTR); /* Retry if interrupted by a signal */
-
-    if (microseconds > 0) {
-        if (status != ETIMEDOUT)
-            CHECK_STATUS("sem_timedwait");
-    }
-    else if (microseconds == 0) {
-        if (status != EAGAIN)
-            CHECK_STATUS("sem_trywait");
-    }
-    else {
-        CHECK_STATUS("sem_wait");
+        /* Retry if interrupted by a signal, unless the caller wants to be
+           notified.  */
+    } while (!intr_flag && status == EINTR);
+
+    /* Don't check the status if we're stopping because of an interrupt.  */
+    if (!(intr_flag && status == EINTR)) {
+        if (microseconds > 0) {
+            if (status != ETIMEDOUT)
+                CHECK_STATUS("sem_timedwait");
+        }
+        else if (microseconds == 0) {
+            if (status != EAGAIN)
+                CHECK_STATUS("sem_trywait");
+        }
+        else {
+            CHECK_STATUS("sem_wait");
+        }
     }
 
-    success = (status == 0) ? 1 : 0;
+    if (status == 0) {
+        success = PY_LOCK_ACQUIRED;
+    } else if (intr_flag && status == EINTR) {
+        success = PY_LOCK_INTR;
+    } else {
+        success = PY_LOCK_FAILURE;
+    }
 
-    dprintf(("PyThread_acquire_lock_timed(%p, %lld) -> %d\n",
-             lock, microseconds, success));
+    dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n",
+             lock, microseconds, intr_flag, success));
     return success;
 }
 
-int
-PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
-{
-    return PyThread_acquire_lock_timed(lock, waitflag ? -1 : 0);
-}
-
 void
 PyThread_release_lock(PyThread_type_lock lock)
 {
@@ -436,21 +442,25 @@
     free((void *)thelock);
 }
 
-int
-PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds)
+PyLockStatus
+PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
+                            int intr_flag)
 {
-    int success;
+    PyLockStatus success;
     pthread_lock *thelock = (pthread_lock *)lock;
     int status, error = 0;
 
-    dprintf(("PyThread_acquire_lock_timed(%p, %lld) called\n",
-             lock, microseconds));
+    dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n",
+             lock, microseconds, intr_flag));
 
     status = pthread_mutex_lock( &thelock->mut );
     CHECK_STATUS("pthread_mutex_lock[1]");
-    success = thelock->locked == 0;
 
-    if (!success && microseconds != 0) {
+    if (thelock->locked == 0) {
+        success = PY_LOCK_ACQUIRED;
+    } else if (microseconds == 0) {
+        success = PY_LOCK_FAILURE;
+    } else {
         struct timespec ts;
         if (microseconds > 0)
             MICROSECONDS_TO_TIMESPEC(microseconds, ts);
@@ -458,7 +468,8 @@
 
         /* mut must be locked by me -- part of the condition
          * protocol */
-        while (thelock->locked) {
+        success = PY_LOCK_FAILURE;
+        while (success == PY_LOCK_FAILURE) {
             if (microseconds > 0) {
                 status = pthread_cond_timedwait(
                     &thelock->lock_released,
@@ -473,25 +484,30 @@
                     &thelock->mut);
                 CHECK_STATUS("pthread_cond_wait");
             }
+
+            if (intr_flag && status == 0 && thelock->locked) {
+                /* We were woken up, but didn't get the lock.  We probably received
+                 * a signal.  Return PY_LOCK_INTR to allow the caller to handle
+                 * it and retry.  */
+                success = PY_LOCK_INTR;
+                break;
+            } else if (status == 0 && !thelock->locked) {
+                success = PY_LOCK_ACQUIRED;
+            } else {
+                success = PY_LOCK_FAILURE;
+            }
         }
-        success = (status == 0);
     }
-    if (success) thelock->locked = 1;
+    if (success == PY_LOCK_ACQUIRED) thelock->locked = 1;
     status = pthread_mutex_unlock( &thelock->mut );
     CHECK_STATUS("pthread_mutex_unlock[1]");
 
-    if (error) success = 0;
-    dprintf(("PyThread_acquire_lock_timed(%p, %lld) -> %d\n",
-             lock, microseconds, success));
+    if (error) success = PY_LOCK_FAILURE;
+    dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n",
+             lock, microseconds, intr_flag, success));
     return success;
 }
 
-int
-PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
-{
-    return PyThread_acquire_lock_timed(lock, waitflag ? -1 : 0);
-}
-
 void
 PyThread_release_lock(PyThread_type_lock lock)
 {
@@ -515,6 +531,12 @@
 
 #endif /* USE_SEMAPHORES */
 
+int
+PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
+{
+    return PyThread_acquire_lock_timed(lock, waitflag ? -1 : 0, /*intr_flag=*/0);
+}
+
 /* set the thread stack size.
  * Return 0 if size is valid, -1 if size is invalid,
  * -2 if setting stack size is not supported.

Modified: python/branches/py3k-cdecimal/Python/traceback.c
==============================================================================
--- python/branches/py3k-cdecimal/Python/traceback.c	(original)
+++ python/branches/py3k-cdecimal/Python/traceback.c	Sun Jan  2 13:18:37 2011
@@ -7,7 +7,6 @@
 #include "frameobject.h"
 #include "structmember.h"
 #include "osdefs.h"
-#include "traceback.h"
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif

Modified: python/branches/py3k-cdecimal/README
==============================================================================
--- python/branches/py3k-cdecimal/README	(original)
+++ python/branches/py3k-cdecimal/README	Sun Jan  2 13:18:37 2011
@@ -1,7 +1,7 @@
-This is Python version 3.2 alpha 4
-==================================
+This is Python version 3.2 beta 2
+=================================
 
-Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 Python Software Foundation.
 All rights reserved.
 
@@ -97,10 +97,7 @@
 left by the previous test run).  The test set produces some output.  You can
 generally ignore the messages about skipped tests due to optional features which
 can't be imported.  If a message is printed about a failed test or a traceback
-or core dump is produced, something is wrong.  On some Linux systems (those that
-are not yet using glibc 6), test_strftime fails due to a non-standard
-implementation of strftime() in the C library. Please ignore this, or upgrade to
-glibc version 6.
+or core dump is produced, something is wrong.
 
 By default, tests are prevented from overusing resources like disk space and
 memory.  To enable these tests, run "make testall".
@@ -109,7 +106,7 @@
 include the output of "make test".  It is useless.  Run the failing test
 manually, as follows:
 
-        ./python Lib/test/regrtest.py -v test_whatever
+        ./python -m test -v test_whatever
 
 (substituting the top of the source tree for '.' if you built in a different
 directory).  This runs the test in verbose mode.

Modified: python/branches/py3k-cdecimal/Tools/README
==============================================================================
--- python/branches/py3k-cdecimal/Tools/README	(original)
+++ python/branches/py3k-cdecimal/Tools/README	Sun Jan  2 13:18:37 2011
@@ -5,7 +5,7 @@
 
 ccbench         A Python concurrency benchmark.
 
-framer          Generate boilerplate code for C extension types.
+demo            Several Python programming demos.
 
 freeze          Create a stand-alone executable from a Python program.
 
@@ -21,6 +21,8 @@
 
 msi             Support for packaging Python as an MSI package on Windows.
 
+parser          Un-parsing tool to generate code from an AST.
+
 pybench         Comprehensive Python benchmarking suite.
 
 pynche          A Tkinter-based color editor.
@@ -30,7 +32,7 @@
                 tabs and spaces, and 2to3, which converts Python 2 code
                 to Python 3 code.
 
-ssl             Currently, a tool to fetch server certificates.
+test2to3        A demonstration of how to use 2to3 transparently in setup.py.
 
 unicode         Tools used to generate unicode database files for
                 Python 2.0 (by Fredrik Lundh).

Modified: python/branches/py3k-cdecimal/Tools/buildbot/external-amd64.bat
==============================================================================
--- python/branches/py3k-cdecimal/Tools/buildbot/external-amd64.bat	(original)
+++ python/branches/py3k-cdecimal/Tools/buildbot/external-amd64.bat	Sun Jan  2 13:18:37 2011
@@ -5,17 +5,17 @@
 call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
 
 if not exist tcltk64\bin\tcl85g.dll (
-    cd tcl-8.5.2.1\win
+    cd tcl-8.5.9.0\win
     nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all
     nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 install
     cd ..\..
 )
 
 if not exist tcltk64\bin\tk85g.dll (
-    cd tk-8.5.2.0\win    
-    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.2.1 clean
-    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.2.1 all
-    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.2.1 install
+    cd tk-8.5.9.0\win    
+    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.9.0 clean
+    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.9.0 all
+    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.9.0 install
     cd ..\..
 )
 

Modified: python/branches/py3k-cdecimal/Tools/buildbot/external-common.bat
==============================================================================
--- python/branches/py3k-cdecimal/Tools/buildbot/external-common.bat	(original)
+++ python/branches/py3k-cdecimal/Tools/buildbot/external-common.bat	Sun Jan  2 13:18:37 2011
@@ -15,7 +15,7 @@
 @rem if exist tk-8.4.18.1 rd /s/q tk-8.4.18.1
 @rem if exist db-4.4.20 rd /s/q db-4.4.20
 @rem if exist openssl-1.0.0a rd /s/q openssl-1.0.0a
- at rem if exist sqlite-3.6.21 rd /s/q sqlite-3.6.21    
+ at rem if exist sqlite-3.7.4 rd /s/q sqlite-3.7.4    
 
 @rem bzip
 if not exist bzip2-1.0.5 (
@@ -30,14 +30,14 @@
 if not exist openssl-1.0.0a svn export http://svn.python.org/projects/external/openssl-1.0.0a
 
 @rem tcl/tk
-if not exist tcl-8.5.2.1 (
+if not exist tcl-8.5.9.0 (
    rd /s/q tcltk tcltk64
-   svn export http://svn.python.org/projects/external/tcl-8.5.2.1
+   svn export http://svn.python.org/projects/external/tcl-8.5.9.0
 )
-if not exist tk-8.5.2.0 svn export http://svn.python.org/projects/external/tk-8.5.2.0
+if not exist tk-8.5.9.0 svn export http://svn.python.org/projects/external/tk-8.5.9.0
 
 @rem sqlite3
-if not exist sqlite-3.6.21 (
-  rd /s/q sqlite-source-3.3.4
-  svn export http://svn.python.org/projects/external/sqlite-3.6.21
+if not exist sqlite-3.7.4 (
+  rd /s/q sqlite-source-3.6.21
+  svn export http://svn.python.org/projects/external/sqlite-3.7.4
 )

Modified: python/branches/py3k-cdecimal/Tools/buildbot/external.bat
==============================================================================
--- python/branches/py3k-cdecimal/Tools/buildbot/external.bat	(original)
+++ python/branches/py3k-cdecimal/Tools/buildbot/external.bat	Sun Jan  2 13:18:37 2011
@@ -6,16 +6,16 @@
 
 if not exist tcltk\bin\tcl85g.dll (
     @rem all and install need to be separate invocations, otherwise nmakehlp is not found on install
-    cd tcl-8.5.2.1\win
+    cd tcl-8.5.9.0\win
     nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 INSTALLDIR=..\..\tcltk clean all 
     nmake -f makefile.vc DEBUG=1 INSTALLDIR=..\..\tcltk install
     cd ..\..
 )
 
 if not exist tcltk\bin\tk85g.dll (
-    cd tk-8.5.2.0\win    
-    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.2.1 clean
-    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.2.1 all
-    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.2.1 install
+    cd tk-8.5.9.0\win    
+    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.9.0 clean
+    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.9.0 all
+    nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 INSTALLDIR=..\..\tcltk TCLDIR=..\..\tcl-8.5.9.0 install
     cd ..\..
 )

Modified: python/branches/py3k-cdecimal/Tools/buildbot/test.bat
==============================================================================
--- python/branches/py3k-cdecimal/Tools/buildbot/test.bat	(original)
+++ python/branches/py3k-cdecimal/Tools/buildbot/test.bat	Sun Jan  2 13:18:37 2011
@@ -1,4 +1,4 @@
 @rem Used by the buildbot "test" step.
 cd PCbuild
-call rt.bat -d -q -uall -rw -n
+call rt.bat -d -q -uall -rwW -n
 

Modified: python/branches/py3k-cdecimal/Tools/msi/msi.py
==============================================================================
--- python/branches/py3k-cdecimal/Tools/msi/msi.py	(original)
+++ python/branches/py3k-cdecimal/Tools/msi/msi.py	Sun Jan  2 13:18:37 2011
@@ -1035,6 +1035,8 @@
         if dir=='xmltestdata':
             lib.glob("*.xml")
             lib.add_file("test.xml.out")
+        if dir=='subprocessdata':
+            lib.glob("*.py")
         if dir=='output':
             lib.glob("test_*")
         if dir=='sndhdrdata':
@@ -1054,6 +1056,10 @@
         if dir=="macholib":
             lib.add_file("README.ctypes")
             lib.glob("fetch_macholib*")
+        if dir=='turtledemo':
+            lib.add_file("turtle.cfg")
+        if dir=="pydoc_data":
+            lib.add_file("_pydoc.css")
         if dir=="data" and parent.physical=="test" and parent.basedir.physical=="email":
             # This should contain all non-.svn files listed in subversion
             for f in os.listdir(lib.absolute):
@@ -1082,6 +1088,7 @@
             continue
         dlls.append(f)
         lib.add_file(f)
+    lib.add_file('python3.dll')
     # Add sqlite
     if msilib.msi_type=="Intel64;1033":
         sqlite_arch = "/ia64"
@@ -1118,6 +1125,7 @@
     for f in dlls:
         lib.add_file(f.replace('pyd','lib'))
     lib.add_file('python%s%s.lib' % (major, minor))
+    lib.add_file('python3.lib')
     # Add the mingw-format library
     if have_mingw:
         lib.add_file('libpython%s%s.a' % (major, minor))

Modified: python/branches/py3k-cdecimal/Tools/scripts/README
==============================================================================
--- python/branches/py3k-cdecimal/Tools/scripts/README	(original)
+++ python/branches/py3k-cdecimal/Tools/scripts/README	Sun Jan  2 13:18:37 2011
@@ -2,8 +2,6 @@
 useful while building, extending or managing Python.  Some (e.g., dutree or lll)
 are also generally useful UNIX tools.
 
-See also the Demo/scripts directory!
-
 2to3                    Main script for running the 2to3 conversion tool
 analyze_dxp.py          Analyzes the result of sys.getdxp()
 byext.py                Print lines/words/chars stats of files by extension

Deleted: python/branches/py3k-cdecimal/Tools/scripts/redemo.py
==============================================================================
--- python/branches/py3k-cdecimal/Tools/scripts/redemo.py	Sun Jan  2 13:18:37 2011
+++ (empty file)
@@ -1,171 +0,0 @@
-"""Basic regular expression demostration facility (Perl style syntax)."""
-
-from tkinter import *
-import re
-
-class ReDemo:
-
-    def __init__(self, master):
-        self.master = master
-
-        self.promptdisplay = Label(self.master, anchor=W,
-                text="Enter a Perl-style regular expression:")
-        self.promptdisplay.pack(side=TOP, fill=X)
-
-        self.regexdisplay = Entry(self.master)
-        self.regexdisplay.pack(fill=X)
-        self.regexdisplay.focus_set()
-
-        self.addoptions()
-
-        self.statusdisplay = Label(self.master, text="", anchor=W)
-        self.statusdisplay.pack(side=TOP, fill=X)
-
-        self.labeldisplay = Label(self.master, anchor=W,
-                text="Enter a string to search:")
-        self.labeldisplay.pack(fill=X)
-        self.labeldisplay.pack(fill=X)
-
-        self.showframe = Frame(master)
-        self.showframe.pack(fill=X, anchor=W)
-
-        self.showvar = StringVar(master)
-        self.showvar.set("first")
-
-        self.showfirstradio = Radiobutton(self.showframe,
-                                         text="Highlight first match",
-                                          variable=self.showvar,
-                                          value="first",
-                                          command=self.recompile)
-        self.showfirstradio.pack(side=LEFT)
-
-        self.showallradio = Radiobutton(self.showframe,
-                                        text="Highlight all matches",
-                                        variable=self.showvar,
-                                        value="all",
-                                        command=self.recompile)
-        self.showallradio.pack(side=LEFT)
-
-        self.stringdisplay = Text(self.master, width=60, height=4)
-        self.stringdisplay.pack(fill=BOTH, expand=1)
-        self.stringdisplay.tag_configure("hit", background="yellow")
-
-        self.grouplabel = Label(self.master, text="Groups:", anchor=W)
-        self.grouplabel.pack(fill=X)
-
-        self.grouplist = Listbox(self.master)
-        self.grouplist.pack(expand=1, fill=BOTH)
-
-        self.regexdisplay.bind('<Key>', self.recompile)
-        self.stringdisplay.bind('<Key>', self.reevaluate)
-
-        self.compiled = None
-        self.recompile()
-
-        btags = self.regexdisplay.bindtags()
-        self.regexdisplay.bindtags(btags[1:] + btags[:1])
-
-        btags = self.stringdisplay.bindtags()
-        self.stringdisplay.bindtags(btags[1:] + btags[:1])
-
-    def addoptions(self):
-        self.frames = []
-        self.boxes = []
-        self.vars = []
-        for name in ('IGNORECASE',
-                     'LOCALE',
-                     'MULTILINE',
-                     'DOTALL',
-                     'VERBOSE'):
-            if len(self.boxes) % 3 == 0:
-                frame = Frame(self.master)
-                frame.pack(fill=X)
-                self.frames.append(frame)
-            val = getattr(re, name)
-            var = IntVar()
-            box = Checkbutton(frame,
-                    variable=var, text=name,
-                    offvalue=0, onvalue=val,
-                    command=self.recompile)
-            box.pack(side=LEFT)
-            self.boxes.append(box)
-            self.vars.append(var)
-
-    def getflags(self):
-        flags = 0
-        for var in self.vars:
-            flags = flags | var.get()
-        flags = flags
-        return flags
-
-    def recompile(self, event=None):
-        try:
-            self.compiled = re.compile(self.regexdisplay.get(),
-                                       self.getflags())
-            bg = self.promptdisplay['background']
-            self.statusdisplay.config(text="", background=bg)
-        except re.error as msg:
-            self.compiled = None
-            self.statusdisplay.config(
-                    text="re.error: %s" % str(msg),
-                    background="red")
-        self.reevaluate()
-
-    def reevaluate(self, event=None):
-        try:
-            self.stringdisplay.tag_remove("hit", "1.0", END)
-        except TclError:
-            pass
-        try:
-            self.stringdisplay.tag_remove("hit0", "1.0", END)
-        except TclError:
-            pass
-        self.grouplist.delete(0, END)
-        if not self.compiled:
-            return
-        self.stringdisplay.tag_configure("hit", background="yellow")
-        self.stringdisplay.tag_configure("hit0", background="orange")
-        text = self.stringdisplay.get("1.0", END)
-        last = 0
-        nmatches = 0
-        while last <= len(text):
-            m = self.compiled.search(text, last)
-            if m is None:
-                break
-            first, last = m.span()
-            if last == first:
-                last = first+1
-                tag = "hit0"
-            else:
-                tag = "hit"
-            pfirst = "1.0 + %d chars" % first
-            plast = "1.0 + %d chars" % last
-            self.stringdisplay.tag_add(tag, pfirst, plast)
-            if nmatches == 0:
-                self.stringdisplay.yview_pickplace(pfirst)
-                groups = list(m.groups())
-                groups.insert(0, m.group())
-                for i in range(len(groups)):
-                    g = "%2d: %r" % (i, groups[i])
-                    self.grouplist.insert(END, g)
-            nmatches = nmatches + 1
-            if self.showvar.get() == "first":
-                break
-
-        if nmatches == 0:
-            self.statusdisplay.config(text="(no match)",
-                                      background="yellow")
-        else:
-            self.statusdisplay.config(text="")
-
-
-# Main function, run when invoked as a stand-alone Python program.
-
-def main():
-    root = Tk()
-    demo = ReDemo(root)
-    root.protocol('WM_DELETE_WINDOW', root.quit)
-    root.mainloop()
-
-if __name__ == '__main__':
-    main()

Modified: python/branches/py3k-cdecimal/Tools/scripts/untabify.py
==============================================================================
--- python/branches/py3k-cdecimal/Tools/scripts/untabify.py	(original)
+++ python/branches/py3k-cdecimal/Tools/scripts/untabify.py	Sun Jan  2 13:18:37 2011
@@ -5,7 +5,7 @@
 import os
 import sys
 import getopt
-
+import tokenize
 
 def main():
     tabsize = 8
@@ -27,8 +27,9 @@
 
 def process(filename, tabsize, verbose=True):
     try:
-        with open(filename) as f:
+        with tokenize.open(filename) as f:
             text = f.read()
+            encoding = f.encoding
     except IOError as msg:
         print("%r: I/O error: %s" % (filename, msg))
         return
@@ -44,7 +45,7 @@
         os.rename(filename, backup)
     except os.error:
         pass
-    with open(filename, "w") as f:
+    with open(filename, "w", encoding=encoding) as f:
         f.write(newtext)
     if verbose:
         print(filename)

Modified: python/branches/py3k-cdecimal/Tools/unicode/gencodec.py
==============================================================================
--- python/branches/py3k-cdecimal/Tools/unicode/gencodec.py	(original)
+++ python/branches/py3k-cdecimal/Tools/unicode/gencodec.py	Sun Jan  2 13:18:37 2011
@@ -34,6 +34,9 @@
 # Standard undefined Unicode code point
 UNI_UNDEFINED = chr(0xFFFE)
 
+# Placeholder for a missing codepoint
+MISSING_CODE = -1
+
 mapRE = re.compile('((?:0x[0-9a-fA-F]+\+?)+)'
                    '\s+'
                    '((?:(?:0x[0-9a-fA-Z]+|<[A-Za-z]+>)\+?)*)'
@@ -52,7 +55,7 @@
 
     """
     if not codes:
-        return None
+        return MISSING_CODE
     l = codes.split('+')
     if len(l) == 1:
         return int(l[0],16)
@@ -60,8 +63,8 @@
         try:
             l[i] = int(l[i],16)
         except ValueError:
-            l[i] = None
-    l = [x for x in l if x is not None]
+            l[i] = MISSING_CODE
+    l = [x for x in l if x != MISSING_CODE]
     if len(l) == 1:
         return l[0]
     else:
@@ -113,7 +116,7 @@
     # mappings to None for the rest
     if len(identity) >= len(unmapped):
         for enc in unmapped:
-            enc2uni[enc] = (None, "")
+            enc2uni[enc] = (MISSING_CODE, "")
         enc2uni['IDENTITY'] = 256
 
     return enc2uni
@@ -211,7 +214,7 @@
             (mapkey, mapcomment) = mapkey
         if isinstance(mapvalue, tuple):
             (mapvalue, mapcomment) = mapvalue
-        if mapkey is None:
+        if mapkey == MISSING_CODE:
             continue
         table[mapkey] = (mapvalue, mapcomment)
         if mapkey > maxkey:
@@ -223,11 +226,11 @@
     # Create table code
     for key in range(maxkey + 1):
         if key not in table:
-            mapvalue = None
+            mapvalue = MISSING_CODE
             mapcomment = 'UNDEFINED'
         else:
             mapvalue, mapcomment = table[key]
-        if mapvalue is None:
+        if mapvalue == MISSING_CODE:
             mapchar = UNI_UNDEFINED
         else:
             if isinstance(mapvalue, tuple):

Modified: python/branches/py3k-cdecimal/configure
==============================================================================
--- python/branches/py3k-cdecimal/configure	(original)
+++ python/branches/py3k-cdecimal/configure	Sun Jan  2 13:18:37 2011
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 86306 .
+# From configure.in Revision: 86687 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.67 for python 3.2.
 #
@@ -647,6 +647,7 @@
 RUNSHARED
 INSTSONAME
 LDLIBRARYDIR
+PY3LIBRARY
 BLDLIBRARY
 DLLLIBRARY
 LDLIBRARY
@@ -4710,13 +4711,14 @@
 
 
 
+
 LDLIBRARY="$LIBRARY"
 BLDLIBRARY='$(LDLIBRARY)'
 INSTSONAME='$(LDLIBRARY)'
 DLLLIBRARY=''
 LDLIBRARYDIR=''
 RUNSHARED=''
-LDVERSION="$(VERSION)"
+LDVERSION="$VERSION"
 
 # LINKCC is the command that links the python executable -- default is $(CC).
 # If CXX is set, and if it is needed to link a main function that was
@@ -4906,6 +4908,10 @@
 	  BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
 	  INSTSONAME="$LDLIBRARY".$SOVERSION
+	  if test $with_pydebug == no
+	  then
+	      PY3LIBRARY=libpython3.so
+	  fi
           ;;
     Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
 	  LDLIBRARY='libpython$(LDVERSION).so'
@@ -4917,6 +4923,11 @@
 		;;
 	  esac
 	  INSTSONAME="$LDLIBRARY".$SOVERSION
+	  PY3LIBRARY=libpython3.so
+	  if test $with_pydebug == no
+          then
+	      PY3LIBRARY=libpython3.so
+	  fi
 	  ;;
     hp*|HP*)
 	  case `uname -m` in
@@ -13776,6 +13787,12 @@
   OSF*) as_fn_error $? "OSF* systems are deprecated unless somebody volunteers. Check http://bugs.python.org/issue8606" "$LINENO" 5 ;;
 esac
 
+ac_fn_c_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2"
+if test "x$ac_cv_func_pipe2" = x""yes; then :
+
+$as_echo "#define HAVE_PIPE2 1" >>confdefs.h
+
+fi
 
 
 

Modified: python/branches/py3k-cdecimal/configure.in
==============================================================================
--- python/branches/py3k-cdecimal/configure.in	(original)
+++ python/branches/py3k-cdecimal/configure.in	Sun Jan  2 13:18:37 2011
@@ -608,6 +608,7 @@
 AC_SUBST(LDLIBRARY)
 AC_SUBST(DLLLIBRARY)
 AC_SUBST(BLDLIBRARY)
+AC_SUBST(PY3LIBRARY)
 AC_SUBST(LDLIBRARYDIR)
 AC_SUBST(INSTSONAME)
 AC_SUBST(RUNSHARED)
@@ -618,7 +619,7 @@
 DLLLIBRARY=''
 LDLIBRARYDIR=''
 RUNSHARED=''
-LDVERSION="$(VERSION)"
+LDVERSION="$VERSION"
 
 # LINKCC is the command that links the python executable -- default is $(CC).
 # If CXX is set, and if it is needed to link a main function that was
@@ -737,6 +738,10 @@
 	  BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
 	  RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
 	  INSTSONAME="$LDLIBRARY".$SOVERSION
+	  if test $with_pydebug == no
+	  then
+	      PY3LIBRARY=libpython3.so
+	  fi
           ;;
     Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
 	  LDLIBRARY='libpython$(LDVERSION).so'
@@ -748,6 +753,11 @@
 		;;
 	  esac
 	  INSTSONAME="$LDLIBRARY".$SOVERSION
+	  PY3LIBRARY=libpython3.so
+	  if test $with_pydebug == no
+          then
+	      PY3LIBRARY=libpython3.so
+	  fi
 	  ;;
     hp*|HP*)
 	  case `uname -m` in
@@ -4252,7 +4262,7 @@
   OSF*) AC_MSG_ERROR(OSF* systems are deprecated unless somebody volunteers. Check http://bugs.python.org/issue8606) ;;
 esac
 
-
+AC_CHECK_FUNC(pipe2, AC_DEFINE(HAVE_PIPE2, 1, [Define if the OS supports pipe2()]), )
 
 AC_SUBST(THREADHEADERS)
 

Modified: python/branches/py3k-cdecimal/pyconfig.h.in
==============================================================================
--- python/branches/py3k-cdecimal/pyconfig.h.in	(original)
+++ python/branches/py3k-cdecimal/pyconfig.h.in	Sun Jan  2 13:18:37 2011
@@ -503,6 +503,9 @@
 /* Define to 1 if you have the `pause' function. */
 #undef HAVE_PAUSE
 
+/* Define if the OS supports pipe2() */
+#undef HAVE_PIPE2
+
 /* Define to 1 if you have the `plock' function. */
 #undef HAVE_PLOCK
 

Deleted: python/branches/py3k-cdecimal/runtests.sh
==============================================================================
--- python/branches/py3k-cdecimal/runtests.sh	Sun Jan  2 13:18:37 2011
+++ (empty file)
@@ -1,93 +0,0 @@
-#!/bin/bash
-
-HELP="Usage: ./runtests.py [-h] [-x] [flags] [tests]
-
-Runs each unit test independently, with output directed to a file in
-OUT/<test>.out.  If no tests are given, all tests are run; otherwise,
-only the specified tests are run, unless -x is also given, in which
-case all tests *except* those given are run.
-
-Standard output shows the name of the tests run, with 'BAD' or
-'SKIPPED' added if the test didn't produce a positive result.  Also,
-three files are created, named 'BAD', 'GOOD' and 'SKIPPED', to which
-are written the names of the tests categorized by result.
-
-Flags (arguments starting with '-') are passed transparently to
-regrtest.py, except for -x, which is processed here."
-
-# Choose the Python binary.
-case `uname` in
-Darwin) PYTHON=./python.exe;;
-CYGWIN*) PYTHON=./python.exe;;
-*)      PYTHON=./python;;
-esac
-
-PYTHON="$PYTHON -bb"
-
-# Unset PYTHONPATH, just to be sure.
-unset PYTHONPATH
-
-# Create the output directory if necessary.
-mkdir -p OUT
-
-# Empty the summary files.
->GOOD
->BAD
->SKIPPED
-
-# Process flags (transparently pass these on to regrtest.py)
-FLAGS=""
-EXCEPT=""
-while :
-do
-    case $1 in
-    -h|--h|-help|--help) echo "$HELP"; exit;;
-    --) FLAGS="$FLAGS $1"; shift; break;;
-    -x) EXCEPT="$1"; shift;;
-    -*) FLAGS="$FLAGS $1"; shift;;
-    *)  break;;
-    esac
-done
-
-# Compute the list of tests to run.
-case "$#$EXCEPT" in
-0) 
-    TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//')`
-    ;;
-*-x)
-    PAT="^(`echo $@ | sed 's/\.py//g' | sed 's/ /|/g'`)$"
-    TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//' | egrep -v "$PAT")`
-    ;;
-*)
-    TESTS="$@"
-    ;;
-esac
-
-# Run the tests.
-for T in $TESTS
-do
-    echo -n $T
-    if   case $T in
-         *curses*)
-	     echo
-	     $PYTHON -E Lib/test/regrtest.py $FLAGS $T 2>OUT/$T.out
-	     ;;
-         *)  $PYTHON -E Lib/test/regrtest.py $FLAGS $T >OUT/$T.out 2>&1;;
-         esac
-    then
-        if grep -q "1 test skipped:" OUT/$T.out
-        then
-            echo " SKIPPED"
-            echo $T >>SKIPPED
-        else
-            echo
-            echo $T >>GOOD
-        fi
-    else
-        echo " BAD"
-        echo $T >>BAD
-    fi
-done
-
-# Summarize results
-wc -l BAD GOOD SKIPPED

Modified: python/branches/py3k-cdecimal/setup.py
==============================================================================
--- python/branches/py3k-cdecimal/setup.py	(original)
+++ python/branches/py3k-cdecimal/setup.py	Sun Jan  2 13:18:37 2011
@@ -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.command.build_scripts import build_scripts
 from distutils.spawn import find_executable
 
 # Were we compiled --with-pydebug or with #define Py_DEBUG?
@@ -27,11 +28,19 @@
 _BUILDDIR_COOKIE = "pybuilddir.txt"
 
 def add_dir_to_list(dirlist, dir):
-    """Add the directory 'dir' to the list 'dirlist' (at the front) if
+    """Add the directory 'dir' to the list 'dirlist' (after any relative
+    directories) if:
+
     1) 'dir' is not already in 'dirlist'
-    2) 'dir' actually exists, and is a directory."""
-    if dir is not None and os.path.isdir(dir) and dir not in dirlist:
-        dirlist.insert(0, dir)
+    2) 'dir' actually exists, and is a directory.
+    """
+    if dir is None or not os.path.isdir(dir) or dir in dirlist:
+        return
+    for i, path in enumerate(dirlist):
+        if not os.path.isabs(path):
+            dirlist.insert(i + 1, dir)
+            return
+    dirlist.insert(0, dir)
 
 def macosx_sdk_root():
     """
@@ -362,7 +371,9 @@
         return sys.platform
 
     def detect_modules(self):
-        # Ensure that /usr/local is always used
+        # Ensure that /usr/local is always used, but the local build
+        # directories (i.e. '.' and 'Include') must be first.  See issue
+        # 10520.
         add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
         add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
 
@@ -437,9 +448,10 @@
             # This should work on any unixy platform ;-)
             # If the user has bothered specifying additional -I and -L flags
             # in OPT and LDFLAGS we might as well use them here.
-            #   NOTE: using shlex.split would technically be more correct, but
-            # also gives a bootstrap problem. Let's hope nobody uses directories
-            # with whitespace in the name to store libraries.
+            #
+            # NOTE: using shlex.split would technically be more correct, but
+            # also gives a bootstrap problem. Let's hope nobody uses
+            # directories with whitespace in the name to store libraries.
             cflags, ldflags = sysconfig.get_config_vars(
                     'CFLAGS', 'LDFLAGS')
             for item in cflags.split():
@@ -1571,6 +1583,10 @@
 ##         # Uncomment these lines if you want to play with xxmodule.c
 ##         ext = Extension('xx', ['xxmodule.c'])
 ##         self.extensions.append(ext)
+        if 'd' not in sys.abiflags:
+            ext = Extension('xxlimited', ['xxlimited.c'],
+                            define_macros=[('Py_LIMITED_API', 1)])
+            self.extensions.append(ext)
 
         # XXX handle these, but how to detect?
         # *** Uncomment and edit for PIL (TkImaging) extension only:
@@ -1858,6 +1874,25 @@
     def is_chmod_supported(self):
         return hasattr(os, 'chmod')
 
+class PyBuildScripts(build_scripts):
+    def copy_scripts(self):
+        outfiles, updated_files = build_scripts.copy_scripts(self)
+        fullversion = '-{0[0]}.{0[1]}'.format(sys.version_info)
+        minoronly = '.{0[1]}'.format(sys.version_info)
+        newoutfiles = []
+        newupdated_files = []
+        for filename in outfiles:
+            if filename.endswith('2to3'):
+                newfilename = filename + fullversion
+            else:
+                newfilename = filename + minoronly
+            log.info('renaming {} to {}'.format(filename, newfilename))
+            os.rename(filename, newfilename)
+            newoutfiles.append(newfilename)
+            if filename in updated_files:
+                newupdated_files.append(newfilename)
+        return newoutfiles, newupdated_files
+
 SUMMARY = """
 Python is an interpreted, interactive, object-oriented programming
 language. It is often compared to Tcl, Perl, Scheme or Java.
@@ -1903,12 +1938,17 @@
           platforms = ["Many"],
 
           # Build info
-          cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall,
-                      'install_lib':PyBuildInstallLib},
+          cmdclass = {'build_ext': PyBuildExt,
+                      'build_scripts': PyBuildScripts,
+                      'install': PyBuildInstall,
+                      'install_lib': PyBuildInstallLib},
           # The struct module is defined here, because build_ext won't be
           # called unless there's at least one extension module defined.
           ext_modules=[Extension('_struct', ['_struct.c'])],
 
+          # If you change the scripts installed here, you also need to
+          # check the PyBuildScripts command above, and change the links
+          # created by the bininstall target in Makefile.pre.in
           scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
                      "Tools/scripts/2to3"]
         )


More information about the Python-checkins mailing list