[Python-checkins] r63244 - in python/branches/tlee-ast-optimize: .bzrignore .hgignore Doc/c-api/marshal.rst Doc/distutils/packageindex.rst Doc/distutils/uploading.rst Doc/library/_winreg.rst Doc/library/aepack.rst Doc/library/aetools.rst Doc/library/aetypes.rst Doc/library/autogil.rst Doc/library/basehttpserver.rst Doc/library/bastion.rst Doc/library/bdb.rst Doc/library/binhex.rst Doc/library/bsddb.rst Doc/library/carbon.rst Doc/library/cgi.rst Doc/library/collections.rst Doc/library/colorpicker.rst Doc/library/colorsys.rst Doc/library/compiler.rst Doc/library/copy.rst Doc/library/copy_reg.rst Doc/library/copyreg.rst Doc/library/dircache.rst Doc/library/dl.rst Doc/library/easydialogs.rst Doc/library/exceptions.rst Doc/library/fpformat.rst Doc/library/framework.rst Doc/library/ftplib.rst Doc/library/functions.rst Doc/library/httplib.rst Doc/library/ic.rst Doc/library/imageop.rst Doc/library/imp.rst Doc/library/imputil.rst Doc/library/logging.rst Doc/library/mac.rst Doc/library/macos.rst Doc/library/macostools.rst Doc/library/mailbox.rst Doc/library/math.rst Doc/library/mhlib.rst Doc/library/mutex.rst Doc/library/new.rst Doc/library/os.path.rst Doc/library/os.rst Doc/library/othergui.rst Doc/library/pdb.rst Doc/library/persistence.rst Doc/library/pickle.rst Doc/library/plistlib.rst Doc/library/pprint.rst Doc/library/queue.rst Doc/library/re.rst Doc/library/rexec.rst Doc/library/rlcompleter.rst Doc/library/simplexmlrpcserver.rst Doc/library/smtplib.rst Doc/library/socket.rst Doc/library/socketserver.rst Doc/library/stdtypes.rst Doc/library/string.rst Doc/library/telnetlib.rst Doc/library/tempfile.rst Doc/library/test.rst Doc/library/textwrap.rst Doc/library/threading.rst Doc/library/tk.rst Doc/library/undoc.rst Doc/library/urllib2.rst Doc/library/user.rst Doc/library/warnings.rst Doc/library/winsound.rst Doc/library/zipfile.rst Doc/library/zipimport.rst Doc/license.rst Doc/reference/datamodel.rst Doc/reference/executionmodel.rst Doc/reference/expressions.rst Doc/reference/simple_stmts.rst Doc/tutorial/modules.rst Doc/tutorial/stdlib2.rst Doc/whatsnew/2.6.rst Include/patchlevel.h Include/stringobject.h Lib/BaseHTTPServer.py Lib/Bastion.py Lib/Queue.py Lib/SimpleXMLRPCServer.py Lib/SocketServer.py Lib/bdb.py Lib/bsddb/__init__.py Lib/bsddb/dbshelve.py Lib/bsddb/test/test_1413192.py Lib/bsddb/test/test_all.py Lib/bsddb/test/test_associate.py Lib/bsddb/test/test_basics.py Lib/bsddb/test/test_compare.py Lib/bsddb/test/test_compat.py Lib/bsddb/test/test_cursor_pget_bug.py Lib/bsddb/test/test_dbobj.py Lib/bsddb/test/test_dbshelve.py Lib/bsddb/test/test_dbtables.py Lib/bsddb/test/test_distributed_transactions.py Lib/bsddb/test/test_early_close.py Lib/bsddb/test/test_env_close.py Lib/bsddb/test/test_get_none.py Lib/bsddb/test/test_join.py Lib/bsddb/test/test_lock.py Lib/bsddb/test/test_misc.py Lib/bsddb/test/test_pickle.py Lib/bsddb/test/test_queue.py Lib/bsddb/test/test_recno.py Lib/bsddb/test/test_replication.py Lib/bsddb/test/test_sequence.py Lib/bsddb/test/test_thread.py Lib/compiler/__init__.py Lib/copy.py Lib/copy_reg.py Lib/copyreg.py Lib/dircache.py Lib/distutils/__init__.py Lib/distutils/archive_util.py Lib/distutils/command/build_ext.py Lib/distutils/command/register.py Lib/distutils/command/upload.py Lib/distutils/config.py Lib/distutils/core.py Lib/distutils/dist.py Lib/distutils/tests/test_config.py Lib/distutils/tests/test_dist.py Lib/distutils/tests/test_upload.py Lib/doctest.py Lib/fpformat.py Lib/fractions.py Lib/idlelib/idlever.py Lib/idlelib/rpc.py Lib/idlelib/run.py Lib/ihooks.py Lib/imputil.py Lib/io.py Lib/json/encoder.py Lib/lib-old/Queue.py Lib/lib-old/SocketServer.py Lib/lib-tk/Canvas.py Lib/lib-tk/Tkinter.py Lib/logging/config.py Lib/macpath.py Lib/mhlib.py Lib/multifile.py Lib/mutex.py Lib/new.py Lib/ntpath.py Lib/os.py Lib/pdb.doc Lib/pdb.py Lib/pickle.py Lib/plat-irix5/AL.py Lib/plat-irix6/AL.py Lib/plat-mac/Audio_mac.py Lib/plat-mac/Carbon/__init__.py Lib/plat-mac/EasyDialogs.py Lib/plat-mac/FrameWork.py Lib/plat-mac/MiniAEFrame.py Lib/plat-mac/PixMapWrapper.py Lib/plat-mac/aepack.py Lib/plat-mac/aetools.py Lib/plat-mac/aetypes.py Lib/plat-mac/applesingle.py Lib/plat-mac/appletrawmain.py Lib/plat-mac/appletrunner.py Lib/plat-mac/argvemulator.py Lib/plat-mac/bgenlocations.py Lib/plat-mac/buildtools.py Lib/plat-mac/bundlebuilder.py Lib/plat-mac/cfmfile.py Lib/plat-mac/findertools.py Lib/plat-mac/gensuitemodule.py Lib/plat-mac/ic.py Lib/plat-mac/icopen.py Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py Lib/plat-mac/lib-scriptpackages/Finder/__init__.py Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py Lib/plat-mac/macerrors.py Lib/plat-mac/macostools.py Lib/plat-mac/macresource.py Lib/plat-mac/pimp.py Lib/plat-mac/terminalcommand.py Lib/plat-mac/videoreader.py Lib/platform.py Lib/plistlib.py Lib/posixpath.py Lib/pprint.py Lib/queue.py Lib/re.py Lib/rexec.py Lib/rlcompleter.py Lib/sched.py Lib/site.py Lib/socketserver.py Lib/stringold.py Lib/tempfile.py Lib/test/pickletester.py Lib/test/regrtest.py Lib/test/test___all__.py Lib/test/test_al.py Lib/test/test_bsddb185.py Lib/test/test_bsddb3.py Lib/test/test_builtin.py Lib/test/test_compiler.py Lib/test/test_copy.py Lib/test/test_copy_reg.py Lib/test/test_copyreg.py Lib/test/test_dircache.py Lib/test/test_dl.py Lib/test/test_dummy_thread.py Lib/test/test_enumerate.py Lib/test/test_eof.py Lib/test/test_fpformat.py Lib/test/test_imageop.py Lib/test/test_io.py Lib/test/test_json.py Lib/test/test_linuxaudiodev.py Lib/test/test_logging.py Lib/test/test_marshal.py Lib/test/test_math.py Lib/test/test_memoryio.py Lib/test/test_mhlib.py Lib/test/test_multifile.py Lib/test/test_mutex.py Lib/test/test_new.py Lib/test/test_pprint.py Lib/test/test_py3kwarn.py Lib/test/test_pyclbr.py Lib/test/test_queue.py Lib/test/test_repr.py Lib/test/test_site.py Lib/test/test_socket.py Lib/test/test_socketserver.py Lib/test/test_support.py Lib/test/test_sys.py Lib/test/test_textwrap.py Lib/test/test_types.py Lib/test/test_warnings.py Lib/test/test_wsgiref.py Lib/test/test_zipimport.py Lib/test/testall.py Lib/textwrap.py Lib/toaiff.py Lib/unittest.py Lib/urllib.py Lib/user.py Lib/warnings.py Mac/Modules/ColorPickermodule.c Mac/Modules/MacOS.c Mac/Modules/Nav.c Mac/Modules/OSATerminology.c Mac/Modules/autoGIL.c Mac/Modules/icgluemodule.c Makefile.pre.in Misc/ACKS Misc/NEWS Misc/RPM/python-2.6.spec Misc/TextMate/Python-Dev.tmbundle/Commands/2 to 3 - Module Deletion.tmCommand Misc/TextMate/Python-Dev.tmbundle/info.plist Misc/cheatsheet Modules/Setup.dist Modules/_bsddb.c Modules/_bytesio.c Modules/_fileio.c Modules/almodule.c Modules/bsddb.h Modules/bsddbmodule.c Modules/cPickle.c Modules/dlmodule.c Modules/imageop.c Modules/linuxaudiodev.c Modules/mathmodule.c Modules/parsermodule.c Modules/puremodule.c Modules/svmodule.c Modules/timingmodule.c Modules/zipimport.c Objects/bytesobject.c Objects/enumobject.c Objects/floatobject.c Objects/setobject.c Objects/stringlib/formatter.h Objects/stringlib/localeutil.h Objects/stringlib/stringdefs.h Objects/stringlib/unicodedefs.h Objects/stringobject.c Objects/typeobject.c Objects/unicodeobject.c PC/VS8.0/pythoncore.vcproj PC/config.c PC/winsound.c PCbuild/pythoncore.vcproj Python/_warnings.c Python/bltinmodule.c Python/marshal.c Python/pystrtod.c Python/pythonrun.c Python/sysmodule.c README Tools/buildbot/buildmsi.bat Tools/msi/msi.py Tools/msi/msisupport.c Tools/msi/msisupport.mak Tools/msi/uuids.py Tools/webchecker/wsgui.py setup.py

thomas.lee python-checkins at python.org
Thu May 15 00:25:18 CEST 2008


Author: thomas.lee
Date: Thu May 15 00:25:06 2008
New Revision: 63244

Log:
Merged revisions 62821-63222 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r62841 | christian.heimes | 2008-05-08 08:54:17 +1000 (Thu, 08 May 2008) | 1 line
  
  Replace more float hacks with correct math functions
........
  r62842 | benjamin.peterson | 2008-05-08 09:11:54 +1000 (Thu, 08 May 2008) | 2 lines
  
  Practice EAFP, and revert 62787
........
  r62848 | raymond.hettinger | 2008-05-08 14:35:20 +1000 (Thu, 08 May 2008) | 1 line
  
  Frozensets do not benefit from autoconversion.
........
  r62849 | raymond.hettinger | 2008-05-08 14:36:12 +1000 (Thu, 08 May 2008) | 1 line
  
  The __all__ variable forgot to expose the gcd() function.
........
  r62853 | raymond.hettinger | 2008-05-08 17:23:30 +1000 (Thu, 08 May 2008) | 1 line
  
  Fix-up the enumerate type example and move it to the end.
........
  r62854 | ronald.oussoren | 2008-05-08 20:34:39 +1000 (Thu, 08 May 2008) | 3 lines
  
  Fix for issue 1770190: platform.mac_ver() now returns the right
  version on OSX 10.4.10
........
  r62861 | barry.warsaw | 2008-05-08 23:16:19 +1000 (Thu, 08 May 2008) | 1 line
  
  Bump to 2.6a3
........
  r62865 | barry.warsaw | 2008-05-09 01:30:00 +1000 (Fri, 09 May 2008) | 1 line
  
  Post tag updates.
........
  r62873 | raymond.hettinger | 2008-05-09 03:18:13 +1000 (Fri, 09 May 2008) | 1 line
  
  Issue 2778.  Document the temporary frozenset swap in __contains__(), remove(), and discard().
........
  r62879 | brett.cannon | 2008-05-09 04:15:14 +1000 (Fri, 09 May 2008) | 2 lines
  
  Deprecate the imputil module for removal in 3.0.
........
  r62884 | brett.cannon | 2008-05-09 05:26:08 +1000 (Fri, 09 May 2008) | 2 lines
  
  The mutex module has been deprecated for removal in 3.0.
........
  r62887 | brett.cannon | 2008-05-09 05:50:51 +1000 (Fri, 09 May 2008) | 5 lines
  
  Make test.test_support.catch_warning() take an argument specifying if any
  triggered warnings should be captured. This allows the context manager to be
  used to just prevent the internal state of the 'warnings' framework and thus
  allow triggered warnings to be displayed.
........
  r62888 | brett.cannon | 2008-05-09 05:52:45 +1000 (Fri, 09 May 2008) | 2 lines
  
  Deprecate stringold for removal in 3.0.
........
  r62892 | brett.cannon | 2008-05-09 06:20:24 +1000 (Fri, 09 May 2008) | 4 lines
  
  Fix a bug introduced by the addition of the 'record' argument to
  test.test_support.catch_warning() where showwarning() was not being set
  properly.
........
  r62893 | brett.cannon | 2008-05-09 06:20:54 +1000 (Fri, 09 May 2008) | 2 lines
  
  Document the 'record' argument for test.test_support.catch_warning().
........
  r62894 | brett.cannon | 2008-05-09 06:23:06 +1000 (Fri, 09 May 2008) | 4 lines
  
  Fix sys.flags to properly expose bytes_warning.
  
  Closes issue #2790.
........
  r62895 | brett.cannon | 2008-05-09 06:23:54 +1000 (Fri, 09 May 2008) | 2 lines
  
  Add a missing entry on  the fix for issue #2790.
........
  r62896 | brett.cannon | 2008-05-09 06:24:43 +1000 (Fri, 09 May 2008) | 2 lines
  
  Add test.test_support.catch_warning()'s new argument.
........
  r62900 | brett.cannon | 2008-05-09 06:36:09 +1000 (Fri, 09 May 2008) | 2 lines
  
  Deprecate the user module for removal in 3.0.
........
  r62904 | benjamin.peterson | 2008-05-09 08:09:54 +1000 (Fri, 09 May 2008) | 2 lines
  
  Replace instances of os.path.walk with os.walk
........
  r62912 | benjamin.peterson | 2008-05-09 10:27:01 +1000 (Fri, 09 May 2008) | 2 lines
  
  Add Py3k warnings to os.path.walk
........
  r62914 | skip.montanaro | 2008-05-09 10:45:00 +1000 (Fri, 09 May 2008) | 4 lines
  
  Add an example about using NamedTemporaryFile() to replace mktemp().  I'm
  unclear whether the verbatim text should have been indented or by how much.
........
  r62915 | benjamin.peterson | 2008-05-09 10:50:40 +1000 (Fri, 09 May 2008) | 2 lines
  
  reindent example
........
  r62917 | brett.cannon | 2008-05-09 15:18:40 +1000 (Fri, 09 May 2008) | 2 lines
  
  Deprecate the new module for removal in 3.0.
........
  r62920 | brett.cannon | 2008-05-09 15:25:37 +1000 (Fri, 09 May 2008) | 2 lines
  
  Deprecate test.testall for removal in 3.0.
........
  r62923 | brett.cannon | 2008-05-09 15:32:42 +1000 (Fri, 09 May 2008) | 2 lines
  
  Deprecate the toaiff module for removal in 3.0.
........
  r62927 | georg.brandl | 2008-05-09 16:09:25 +1000 (Fri, 09 May 2008) | 2 lines
  
  #2788: add .hgignore file.
........
  r62928 | georg.brandl | 2008-05-09 16:10:43 +1000 (Fri, 09 May 2008) | 2 lines
  
  #2781: fix function name.
........
  r62929 | georg.brandl | 2008-05-09 16:18:27 +1000 (Fri, 09 May 2008) | 2 lines
  
  Add a sentence to basicConfig() that is in the docstring.
........
  r62930 | georg.brandl | 2008-05-09 16:26:54 +1000 (Fri, 09 May 2008) | 2 lines
  
  Add another link to colorsys docs.
........
  r62931 | georg.brandl | 2008-05-09 16:36:07 +1000 (Fri, 09 May 2008) | 2 lines
  
  Add Kodos as a re reference.
........
  r62932 | georg.brandl | 2008-05-09 16:39:58 +1000 (Fri, 09 May 2008) | 2 lines
  
  Add a note about using reload().
........
  r62933 | andrew.kuchling | 2008-05-09 21:46:05 +1000 (Fri, 09 May 2008) | 3 lines
  
  Update planned release date.
  Uncomment PEP 370 section.
  Add some module items
........
  r62934 | christian.heimes | 2008-05-09 22:19:09 +1000 (Fri, 09 May 2008) | 1 line
  
  Add --user option to build_ext
........
  r62943 | mark.dickinson | 2008-05-10 02:14:15 +1000 (Sat, 10 May 2008) | 5 lines
  
  Issue #2801: fix bug in float.is_integer where ValueError
  could be incorrectly raised.  This is a backport of the
  Py3k fix in r62939.  (Should really have been fixed
  in the trunk first and svnmerged into py3k.)
........
  r62946 | martin.v.loewis | 2008-05-10 03:11:07 +1000 (Sat, 10 May 2008) | 1 line
  
  Add 2.6b1 and 2.6b2 UUIDs.
........
  r62948 | mark.dickinson | 2008-05-10 03:54:23 +1000 (Sat, 10 May 2008) | 3 lines
  
  Issue #2487.  math.ldexp(x, n) raised OverflowError when n was large and 
  negative; fix to return an (appropriately signed) zero instead.
........
  r62949 | martin.v.loewis | 2008-05-10 04:21:55 +1000 (Sat, 10 May 2008) | 1 line
  
  Use the CHM file name that Sphinx assigns.
........
  r62954 | martin.v.loewis | 2008-05-10 06:11:37 +1000 (Sat, 10 May 2008) | 1 line
  
  Port to VS 2008. Drop W9x support.
........
  r62957 | benjamin.peterson | 2008-05-10 07:30:26 +1000 (Sat, 10 May 2008) | 2 lines
  
  In stdtypes.rst, move methods under class directives where applicable
........
  r62958 | brett.cannon | 2008-05-10 07:30:36 +1000 (Sat, 10 May 2008) | 2 lines
  
  Add a todo list to the module deletion command.
........
  r62960 | alexandre.vassalotti | 2008-05-10 07:49:43 +1000 (Sat, 10 May 2008) | 5 lines
  
  Backport fast alternate io.BytesIO implementation.
  Merged r62778, r62779, r62802, r62806, r62807, r62808, r62809, r62844,
  r62846, r62952, r62956.
........
  r62962 | brett.cannon | 2008-05-10 08:51:58 +1000 (Sat, 10 May 2008) | 2 lines
  
  Deprecate the pure module for 3.0.
........
  r62963 | brett.cannon | 2008-05-10 08:52:28 +1000 (Sat, 10 May 2008) | 2 lines
  
  Add support for extension modules in 3.0 deprection command.
........
  r62967 | brett.cannon | 2008-05-10 12:25:00 +1000 (Sat, 10 May 2008) | 2 lines
  
  Fix some errors in the deprecation warnings for new and user.
........
  r62968 | brett.cannon | 2008-05-10 12:27:04 +1000 (Sat, 10 May 2008) | 2 lines
  
  Deprecate Bastion and rexec for 3.0.
........
  r62971 | brett.cannon | 2008-05-10 12:47:54 +1000 (Sat, 10 May 2008) | 2 lines
  
  Deprecate the bsddb185 module for removal in 3.0.
........
  r62974 | brett.cannon | 2008-05-10 12:53:46 +1000 (Sat, 10 May 2008) | 2 lines
  
  Add an entry on the deprecation of Bastion and rexec.
........
  r62975 | brett.cannon | 2008-05-10 12:54:52 +1000 (Sat, 10 May 2008) | 3 lines
  
  Suppress deprecations for packages as well when using
  test.test_support.import_module().
........
  r62976 | brett.cannon | 2008-05-10 12:57:03 +1000 (Sat, 10 May 2008) | 2 lines
  
  Also ignore package deprecations.
........
  r62977 | brett.cannon | 2008-05-10 12:58:26 +1000 (Sat, 10 May 2008) | 2 lines
  
  Deprecate the compiler package for removal in 3.0.
........
  r62982 | benjamin.peterson | 2008-05-10 13:08:17 +1000 (Sat, 10 May 2008) | 2 lines
  
  Add the examples in the json module docstring as a doctest
........
  r62983 | brett.cannon | 2008-05-10 13:09:35 +1000 (Sat, 10 May 2008) | 2 lines
  
  Add a test for the deprecation of the compiler package.
........
  r62985 | brett.cannon | 2008-05-10 13:14:32 +1000 (Sat, 10 May 2008) | 2 lines
  
  The Canvas module has been deprecated for removal in 3.0.
........
  r62986 | brett.cannon | 2008-05-10 13:16:38 +1000 (Sat, 10 May 2008) | 3 lines
  
  Make sure warnings are not suppressed when testing for the raised
  DeprecationWarning.
........
  r62992 | martin.v.loewis | 2008-05-10 23:24:09 +1000 (Sat, 10 May 2008) | 2 lines
  
  Explicitly refer to current hhp file (2.6a3)
........
  r62993 | skip.montanaro | 2008-05-11 00:48:49 +1000 (Sun, 11 May 2008) | 2 lines
  
  Note the PyPI-edness of bsddb185 for people who might still need it.
........
  r62994 | andrew.kuchling | 2008-05-11 03:36:24 +1000 (Sun, 11 May 2008) | 1 line
  
  Docstring typo
........
  r62995 | andrew.kuchling | 2008-05-11 03:37:05 +1000 (Sun, 11 May 2008) | 1 line
  
  Document the 'line' argument
........
  r62996 | andrew.kuchling | 2008-05-11 03:48:45 +1000 (Sun, 11 May 2008) | 1 line
  
  #1625509: describe behaviour of import lock
........
  r62998 | andrew.kuchling | 2008-05-11 05:51:55 +1000 (Sun, 11 May 2008) | 7 lines
  
  #1858 from Tarek Ziade: 
  Allow multiple repositories in .pypirc; see http://wiki.python.org/moin/EnhancedPyPI
  for discussion.
  
  The patch is slightly revised from Tarek's last patch: I've simplified 
  the PyPIRCCommand.finalize_options() method to not look at sys.argv.  
  Tests still pass.
........
  r63000 | alexandre.vassalotti | 2008-05-11 05:59:16 +1000 (Sun, 11 May 2008) | 5 lines
  
  Cleaned up io._BytesIO.write().
  
  I am amazed that the old code, for inserting null-bytes, actually
  worked. Who wrote that thing? Oh, it is me... doh.
........
  r63002 | brett.cannon | 2008-05-11 06:52:01 +1000 (Sun, 11 May 2008) | 2 lines
  
  Revert r62998 as it broke the build (seems distutils.config is missing).
........
  r63004 | brett.cannon | 2008-05-11 07:12:57 +1000 (Sun, 11 May 2008) | 2 lines
  
  Deprecate the dircache module for 3.0.
........
  r63007 | brett.cannon | 2008-05-11 07:20:19 +1000 (Sun, 11 May 2008) | 2 lines
  
  Deprecate the dl module for removal in 3.0.
........
  r63008 | brett.cannon | 2008-05-11 07:22:43 +1000 (Sun, 11 May 2008) | 2 lines
  
  Add an entry for the deprecation of the dl module.
........
  r63013 | brett.cannon | 2008-05-11 08:11:45 +1000 (Sun, 11 May 2008) | 2 lines
  
  Deprecate the fpformat module for removal in 3.0.
........
  r63014 | andrew.kuchling | 2008-05-11 08:12:38 +1000 (Sun, 11 May 2008) | 1 line
  
  #1858: add distutils.config module
........
  r63018 | brett.cannon | 2008-05-11 08:45:07 +1000 (Sun, 11 May 2008) | 1 line
  
  Deprecate ihooks for removal in 3.0.
........
  r63021 | brett.cannon | 2008-05-11 10:50:51 +1000 (Sun, 11 May 2008) | 1 line
  
  The linuxaudidev module has been deprecated for removal in Python 3.0.
........
  r63025 | brett.cannon | 2008-05-11 11:06:54 +1000 (Sun, 11 May 2008) | 2 lines
  
  Fix up markup in the deprecation notice.
........
  r63027 | brett.cannon | 2008-05-11 11:09:32 +1000 (Sun, 11 May 2008) | 2 lines
  
  Flesh out the 3.0 deprecation to suggest using the ctypes module.
........
  r63028 | skip.montanaro | 2008-05-11 12:59:30 +1000 (Sun, 11 May 2008) | 4 lines
  
  Copied two versions of the example from the interactive session.  Delete
  one.
........
  r63030 | brett.cannon | 2008-05-11 13:01:47 +1000 (Sun, 11 May 2008) | 1 line
  
  Deprecated the mhlib module for removal in 3.0.
........
  r63037 | georg.brandl | 2008-05-11 17:02:17 +1000 (Sun, 11 May 2008) | 2 lines
  
  reload() takes the module itself.
........
  r63038 | alexandre.vassalotti | 2008-05-11 17:06:04 +1000 (Sun, 11 May 2008) | 4 lines
  
  Added test framework for handling module renames.
  Factored the import guard in test_py3kwarn.TestStdlibRemovals into
  a context manager, namely test_support.CleanImport.
........
  r63039 | georg.brandl | 2008-05-11 17:06:05 +1000 (Sun, 11 May 2008) | 2 lines
  
  #2742: ``''`` is not converted to NULL in getaddrinfo.
........
  r63040 | alexandre.vassalotti | 2008-05-11 17:08:12 +1000 (Sun, 11 May 2008) | 2 lines
  
  Fixed typo in a comment of test_support.CleanImport.
........
  r63041 | alexandre.vassalotti | 2008-05-11 17:10:25 +1000 (Sun, 11 May 2008) | 2 lines
  
  Removed a dead line of code.
........
  r63042 | alexandre.vassalotti | 2008-05-11 18:25:28 +1000 (Sun, 11 May 2008) | 5 lines
  
  Added module stub for copy_reg renaming in 3.0.
  Renamed copy_reg to copyreg in the standard library, to avoid
  spurious warnings and ease later merging to py3k branch. Public
  documentation remains intact.
........
  r63043 | georg.brandl | 2008-05-11 18:47:53 +1000 (Sun, 11 May 2008) | 2 lines
  
  #2812: document property.getter/setter/deleter.
........
  r63046 | alexandre.vassalotti | 2008-05-11 19:01:51 +1000 (Sun, 11 May 2008) | 3 lines
  
  Added test for copy_reg rename.
  Added note to documentation about copy_reg rename.
........
  r63049 | georg.brandl | 2008-05-11 19:06:30 +1000 (Sun, 11 May 2008) | 2 lines
  
  #1153769: document PEP 237 changes to string formatting.
........
  r63050 | georg.brandl | 2008-05-11 19:11:40 +1000 (Sun, 11 May 2008) | 2 lines
  
  #2809: elaborate str.split docstring a bit.
........
  r63051 | georg.brandl | 2008-05-11 20:13:59 +1000 (Sun, 11 May 2008) | 2 lines
  
  Fix typo.
........
  r63052 | georg.brandl | 2008-05-11 20:33:27 +1000 (Sun, 11 May 2008) | 2 lines
  
  #2709: clarification.
........
  r63053 | georg.brandl | 2008-05-11 20:42:28 +1000 (Sun, 11 May 2008) | 2 lines
  
  #2659: add ``break_on_hyphens`` to TextWrapper.
........
  r63055 | georg.brandl | 2008-05-11 20:55:59 +1000 (Sun, 11 May 2008) | 2 lines
  
  #2147: PEP 237 changes to overflow behavior.
........
  r63057 | georg.brandl | 2008-05-11 20:59:39 +1000 (Sun, 11 May 2008) | 2 lines
  
  #2741: clarification of value range for address_family.
........
  r63058 | georg.brandl | 2008-05-11 21:09:35 +1000 (Sun, 11 May 2008) | 2 lines
  
  #2452: timeout is used for all blocking operations.
........
  r63059 | andrew.kuchling | 2008-05-11 23:33:56 +1000 (Sun, 11 May 2008) | 2 lines
  
  #1792: Improve performance of marshal.dumps() on large objects by increasing
  the size of the buffer more quickly.
........
  r63060 | andrew.kuchling | 2008-05-12 00:00:00 +1000 (Mon, 12 May 2008) | 1 line
  
  #1858: re-apply patch for this, adding the missing files
........
  r63061 | benjamin.peterson | 2008-05-12 00:13:25 +1000 (Mon, 12 May 2008) | 2 lines
  
  Add the "until" command to pdb
........
  r63062 | georg.brandl | 2008-05-12 00:17:13 +1000 (Mon, 12 May 2008) | 2 lines
  
  Add some sentence endings.
........
  r63066 | georg.brandl | 2008-05-12 00:56:04 +1000 (Mon, 12 May 2008) | 2 lines
  
  #2709 followup: better description of Tk's pros and cons.
........
  r63067 | georg.brandl | 2008-05-12 01:05:13 +1000 (Mon, 12 May 2008) | 2 lines
  
  #1326: document and test zipimporter.archive and zipimporter.prefix.
........
  r63068 | georg.brandl | 2008-05-12 01:07:39 +1000 (Mon, 12 May 2008) | 2 lines
  
  #2816: clarify error messages for EOF while scanning strings.
........
  r63069 | georg.brandl | 2008-05-12 01:17:41 +1000 (Mon, 12 May 2008) | 3 lines
  
  #2787: Flush stdout after writing test name, helpful when running
  hanging or long-running tests. Patch by Adam Olsen.
........
  r63070 | georg.brandl | 2008-05-12 01:20:16 +1000 (Mon, 12 May 2008) | 3 lines
  
  #2803: fix wrong invocation of heappush in seldom-reached code.
  Thanks to Matt Harden.
........
  r63073 | benjamin.peterson | 2008-05-12 02:38:07 +1000 (Mon, 12 May 2008) | 2 lines
  
  broaden .bzrignore
........
  r63076 | andrew.kuchling | 2008-05-12 05:15:52 +1000 (Mon, 12 May 2008) | 1 line
  
  Add message to test assertion
........
  r63077 | alexandre.vassalotti | 2008-05-12 05:39:48 +1000 (Mon, 12 May 2008) | 3 lines
  
  Added stub for the Queue module to be renamed in 3.0.
  Use the 3.0 module name to avoid spurious warnings.
........
  r63078 | eric.smith | 2008-05-12 05:52:48 +1000 (Mon, 12 May 2008) | 14 lines
  
  Addresses issue 2802: 'n' formatting for integers.
  
  Adds 'n' as a format specifier for integers, to mirror the same
  specifier which is already available for floats.  'n' is the same as
  'd', but inserts the current locale-specific thousands grouping.
  
  I added this as a stringlib function, but it's only used by str type,
  not unicode.  This is because of an implementation detail in
  unicode.format(), which does its own str->unicode conversion.  But the
  unicode version will be needed in 3.0, and it may be needed by other
  code eventually in 2.6 (maybe decimal?), so I left it as a stringlib
  implementation.  As long as the unicode version isn't instantiated,
  there's no overhead for this.
........
  r63080 | alexandre.vassalotti | 2008-05-12 06:04:03 +1000 (Mon, 12 May 2008) | 3 lines
  
  Added test for Queue rename warning.
  Added note to documentation about Queue rename.
........
  r63083 | andrew.kuchling | 2008-05-12 06:08:33 +1000 (Mon, 12 May 2008) | 1 line
  
  Try setting HOME env.var to fix test on Win32
........
  r63086 | alexandre.vassalotti | 2008-05-12 06:30:43 +1000 (Mon, 12 May 2008) | 6 lines
  
  Added stub for the PixMapWrapper module to be renamed in 3.0.
  Modified TestStdlibRenames to support platform specific renames.
  Added test for PixMapWrapper rename warning.
  Added note to documentation about PixMapWrapper rename.
........
  r63092 | georg.brandl | 2008-05-12 06:53:55 +1000 (Mon, 12 May 2008) | 2 lines
  
  #2809 followup: even better split docstring.
........
  r63094 | georg.brandl | 2008-05-12 07:03:42 +1000 (Mon, 12 May 2008) | 4 lines
  
  - #2250: Exceptions raised during evaluation of names in rlcompleter's
    ``Completer.complete()`` method are now caught and ignored.
........
  r63095 | georg.brandl | 2008-05-12 07:16:37 +1000 (Mon, 12 May 2008) | 2 lines
  
  Clarify os.strerror()s exception behavior.
........
  r63097 | georg.brandl | 2008-05-12 07:34:10 +1000 (Mon, 12 May 2008) | 2 lines
  
  #2535: remove duplicated method.
........
  r63098 | georg.brandl | 2008-05-12 07:37:53 +1000 (Mon, 12 May 2008) | 2 lines
  
  Formally deprecate old classes in the cgi module.
........
  r63100 | georg.brandl | 2008-05-12 07:54:09 +1000 (Mon, 12 May 2008) | 2 lines
  
  Add a deprecation notice to mailbox' old classes' doc.
........
  r63104 | alexandre.vassalotti | 2008-05-12 09:04:27 +1000 (Mon, 12 May 2008) | 2 lines
  
  Moved the Queue module stub in lib-old.
........
  r63105 | alexandre.vassalotti | 2008-05-12 09:12:38 +1000 (Mon, 12 May 2008) | 2 lines
  
  Revert commit r63086.
........
  r63108 | brett.cannon | 2008-05-12 09:39:04 +1000 (Mon, 12 May 2008) | 2 lines
  
  Put Lib/lib-old back on to sys.path for module renames.
........
  r63114 | brett.cannon | 2008-05-12 10:08:34 +1000 (Mon, 12 May 2008) | 2 lines
  
  Depreate imageop for removal in 3.0.
........
  r63119 | benjamin.peterson | 2008-05-12 10:41:23 +1000 (Mon, 12 May 2008) | 2 lines
  
  #2196 hasattr now allows SystemExit and KeyboardInterrupt to propagate
........
  r63122 | benjamin.peterson | 2008-05-12 10:46:49 +1000 (Mon, 12 May 2008) | 2 lines
  
  make message slightly more informative, so there's no chance of misunderstanding it
........
  r63129 | alexandre.vassalotti | 2008-05-12 11:37:10 +1000 (Mon, 12 May 2008) | 3 lines
  
  Renamed SocketServer to 'socketserver'.
  Deprecated old name.
........
  r63132 | alexandre.vassalotti | 2008-05-12 12:11:22 +1000 (Mon, 12 May 2008) | 4 lines
  
  Updated all import statements to use the new socketserver module name.
  Renamed socketserver module in its own documentation. 
  Renamed documentation references.
........
  r63134 | alexandre.vassalotti | 2008-05-12 12:18:15 +1000 (Mon, 12 May 2008) | 3 lines
  
  Added stub entry in the documentation mentioning SocketServer
  was renamed.
........
  r63145 | brett.cannon | 2008-05-12 13:19:20 +1000 (Mon, 12 May 2008) | 1 line
  
  Deprecate the multifile module as per PEP 4.
........
  r63149 | brett.cannon | 2008-05-12 13:45:59 +1000 (Mon, 12 May 2008) | 2 lines
  
  Deprecate the sv module as per PEP 4.
........
  r63150 | brett.cannon | 2008-05-12 13:47:47 +1000 (Mon, 12 May 2008) | 1 line
  
  Deprecate the timing module for removal in Python 3.0.
........
  r63153 | georg.brandl | 2008-05-12 20:03:16 +1000 (Mon, 12 May 2008) | 2 lines
  
  Fix-up docs for socketserver and queue renaming.
........
  r63154 | georg.brandl | 2008-05-12 20:05:39 +1000 (Mon, 12 May 2008) | 2 lines
  
  Fix-up docs for the copyreg module renaming.
........
  r63158 | ronald.oussoren | 2008-05-12 21:24:33 +1000 (Mon, 12 May 2008) | 5 lines
  
  Remove references to platform 'mac'
  
  The 'mac' platform (that is, os.name == 'mac') was used for the MacOS 9 port,
  which is no longer supported (as of Python 2.4 IIRC).
........
  r63159 | ronald.oussoren | 2008-05-12 21:31:05 +1000 (Mon, 12 May 2008) | 8 lines
  
  MacOSX: remove dependency on Carbon package for urllib
  
  This patch removes the dependency on the Carbon package from urllib. 
  The mac-specific code for getting proxy configuration is now writting in
  Python using ctypes and uses the SystemConfiguration framework instead of
  InternetConfig. Also provides a mac-specific implementation of proxy_bypass.
........
  r63162 | eric.smith | 2008-05-13 00:00:01 +1000 (Tue, 13 May 2008) | 1 line
  
  Added 'n' presentation type for integers.
........
  r63164 | georg.brandl | 2008-05-13 02:26:52 +1000 (Tue, 13 May 2008) | 2 lines
  
  #1713041: fix pprint's handling of maximum depth.
........
  r63166 | georg.brandl | 2008-05-13 02:45:43 +1000 (Tue, 13 May 2008) | 2 lines
  
  #2836: backport new string formatting docs.
........
  r63170 | georg.brandl | 2008-05-13 02:53:42 +1000 (Tue, 13 May 2008) | 2 lines
  
  Fix parameter name for enumerate().
........
  r63173 | georg.brandl | 2008-05-13 03:01:58 +1000 (Tue, 13 May 2008) | 2 lines
  
  #2766: remove code without effect.
........
  r63174 | georg.brandl | 2008-05-13 03:04:10 +1000 (Tue, 13 May 2008) | 3 lines
  
  #2767: don't clear globs in run() call, since they could be needed in tearDown,
  which clears them at the end.
........
  r63175 | georg.brandl | 2008-05-13 03:14:51 +1000 (Tue, 13 May 2008) | 2 lines
  
  #1760: try-except-finally is one statement since PEP 341.
........
  r63177 | georg.brandl | 2008-05-13 03:43:13 +1000 (Tue, 13 May 2008) | 2 lines
  
  Fix markup.
........
  r63178 | georg.brandl | 2008-05-13 03:47:53 +1000 (Tue, 13 May 2008) | 2 lines
  
  Marshal is at version 2.
........
  r63179 | georg.brandl | 2008-05-13 03:48:56 +1000 (Tue, 13 May 2008) | 2 lines
  
  Mention version in which the new marshal version was introduced.
........
  r63180 | georg.brandl | 2008-05-13 03:52:13 +1000 (Tue, 13 May 2008) | 2 lines
  
  Win 95/98 is no longer supported.
........
  r63186 | amaury.forgeotdarc | 2008-05-13 07:30:24 +1000 (Tue, 13 May 2008) | 2 lines
  
  Sync code with documentation, and remove Win95 support in winsound module.
........
  r63187 | benjamin.peterson | 2008-05-13 07:42:13 +1000 (Tue, 13 May 2008) | 2 lines
  
  Add warnings to and deprecated all those Mac modules
........
  r63189 | amaury.forgeotdarc | 2008-05-13 08:21:39 +1000 (Tue, 13 May 2008) | 3 lines
  
  Adapt test_pyclbr to the new version of urllib.py:
  The new mac-specific functions must be ignored.
........
  r63191 | benjamin.peterson | 2008-05-13 08:26:05 +1000 (Tue, 13 May 2008) | 2 lines
  
  Make error messages more helpful
........
  r63195 | benjamin.peterson | 2008-05-13 10:09:46 +1000 (Tue, 13 May 2008) | 2 lines
  
  use .format and fix a bug
........
  r63207 | jesus.cea | 2008-05-14 04:45:46 +1000 (Wed, 14 May 2008) | 1 line
  
  bsddb module updated to version 4.6.4
........
  r63208 | georg.brandl | 2008-05-14 05:04:54 +1000 (Wed, 14 May 2008) | 2 lines
  
  #2831: add start argument to enumerate(). Patch by Scott Dial and me.
........
  r63209 | marc-andre.lemburg | 2008-05-14 05:10:45 +1000 (Wed, 14 May 2008) | 3 lines
  
  Remove leftovers from reverted setuptools checkin (they were added in r45525).
........
  r63210 | jesus.cea | 2008-05-14 06:57:59 +1000 (Wed, 14 May 2008) | 1 line
  
  Testsuite for bsddb module, version 4.6.4
........
  r63211 | georg.brandl | 2008-05-14 07:32:03 +1000 (Wed, 14 May 2008) | 2 lines
  
  Fix a refleak in the _warnings module.
........
  r63212 | andrew.kuchling | 2008-05-14 10:46:41 +1000 (Wed, 14 May 2008) | 1 line
  
  List all the removes and renamed modules
........
  r63213 | brett.cannon | 2008-05-14 11:08:21 +1000 (Wed, 14 May 2008) | 1 line
  
  Deprecate al/AL for removal in 3.0.
........
  r63214 | brett.cannon | 2008-05-14 11:09:40 +1000 (Wed, 14 May 2008) | 2 lines
  
  Rewrap some lines in test_py3kwarn.
........
  r63218 | gregory.p.smith | 2008-05-14 14:27:01 +1000 (Wed, 14 May 2008) | 2 lines
  
  Enable the updated Lib/bsddb/test suite to run.
........
  r63219 | georg.brandl | 2008-05-14 16:34:15 +1000 (Wed, 14 May 2008) | 2 lines
  
  Add NEWS entry for #2831.
........
  r63220 | neal.norwitz | 2008-05-14 16:47:56 +1000 (Wed, 14 May 2008) | 3 lines
  
  Fix "refleak" by restoring the tearDown method removed by accident (AFAICT)
  in r62788.
........
  r63221 | georg.brandl | 2008-05-14 17:18:22 +1000 (Wed, 14 May 2008) | 2 lines
  
  Fix another "refleak" by clearing the filters after test.
........
  r63222 | neal.norwitz | 2008-05-14 17:21:42 +1000 (Wed, 14 May 2008) | 5 lines
  
  Install the json package and tests as well as the lib2to3 tests
  so the tests work when run from an install directory.
  They are currently skipped on the daily runs (not from the buildbots)
  for checking refleaks, etc.
........


Added:
   python/branches/tlee-ast-optimize/.hgignore
      - copied unchanged from r63222, /python/trunk/.hgignore
   python/branches/tlee-ast-optimize/Doc/library/copyreg.rst
      - copied unchanged from r63222, /python/trunk/Doc/library/copyreg.rst
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_distributed_transactions.py
      - copied unchanged from r63222, /python/trunk/Lib/bsddb/test/test_distributed_transactions.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_early_close.py
      - copied unchanged from r63222, /python/trunk/Lib/bsddb/test/test_early_close.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_replication.py
      - copied unchanged from r63222, /python/trunk/Lib/bsddb/test/test_replication.py
   python/branches/tlee-ast-optimize/Lib/copyreg.py
      - copied unchanged from r63222, /python/trunk/Lib/copyreg.py
   python/branches/tlee-ast-optimize/Lib/distutils/config.py
      - copied unchanged from r63222, /python/trunk/Lib/distutils/config.py
   python/branches/tlee-ast-optimize/Lib/distutils/tests/test_config.py
      - copied unchanged from r63222, /python/trunk/Lib/distutils/tests/test_config.py
   python/branches/tlee-ast-optimize/Lib/distutils/tests/test_upload.py
      - copied unchanged from r63222, /python/trunk/Lib/distutils/tests/test_upload.py
   python/branches/tlee-ast-optimize/Lib/lib-old/Queue.py
      - copied unchanged from r63222, /python/trunk/Lib/lib-old/Queue.py
   python/branches/tlee-ast-optimize/Lib/lib-old/SocketServer.py
      - copied unchanged from r63222, /python/trunk/Lib/lib-old/SocketServer.py
   python/branches/tlee-ast-optimize/Lib/queue.py
      - copied unchanged from r63222, /python/trunk/Lib/queue.py
   python/branches/tlee-ast-optimize/Lib/socketserver.py
      - copied unchanged from r63222, /python/trunk/Lib/socketserver.py
   python/branches/tlee-ast-optimize/Lib/test/test_copyreg.py
      - copied unchanged from r63222, /python/trunk/Lib/test/test_copyreg.py
   python/branches/tlee-ast-optimize/Lib/test/test_memoryio.py
      - copied unchanged from r63222, /python/trunk/Lib/test/test_memoryio.py
   python/branches/tlee-ast-optimize/Modules/_bytesio.c
      - copied unchanged from r63222, /python/trunk/Modules/_bytesio.c
   python/branches/tlee-ast-optimize/Objects/stringlib/localeutil.h
      - copied unchanged from r63222, /python/trunk/Objects/stringlib/localeutil.h
Removed:
   python/branches/tlee-ast-optimize/Doc/library/copy_reg.rst
   python/branches/tlee-ast-optimize/Lib/Queue.py
   python/branches/tlee-ast-optimize/Lib/SocketServer.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_1413192.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_env_close.py
   python/branches/tlee-ast-optimize/Lib/test/test_copy_reg.py
Modified:
   python/branches/tlee-ast-optimize/   (props changed)
   python/branches/tlee-ast-optimize/.bzrignore
   python/branches/tlee-ast-optimize/Doc/c-api/marshal.rst
   python/branches/tlee-ast-optimize/Doc/distutils/packageindex.rst
   python/branches/tlee-ast-optimize/Doc/distutils/uploading.rst
   python/branches/tlee-ast-optimize/Doc/library/_winreg.rst
   python/branches/tlee-ast-optimize/Doc/library/aepack.rst
   python/branches/tlee-ast-optimize/Doc/library/aetools.rst
   python/branches/tlee-ast-optimize/Doc/library/aetypes.rst
   python/branches/tlee-ast-optimize/Doc/library/autogil.rst
   python/branches/tlee-ast-optimize/Doc/library/basehttpserver.rst
   python/branches/tlee-ast-optimize/Doc/library/bastion.rst
   python/branches/tlee-ast-optimize/Doc/library/bdb.rst
   python/branches/tlee-ast-optimize/Doc/library/binhex.rst
   python/branches/tlee-ast-optimize/Doc/library/bsddb.rst
   python/branches/tlee-ast-optimize/Doc/library/carbon.rst
   python/branches/tlee-ast-optimize/Doc/library/cgi.rst
   python/branches/tlee-ast-optimize/Doc/library/collections.rst
   python/branches/tlee-ast-optimize/Doc/library/colorpicker.rst
   python/branches/tlee-ast-optimize/Doc/library/colorsys.rst
   python/branches/tlee-ast-optimize/Doc/library/compiler.rst
   python/branches/tlee-ast-optimize/Doc/library/copy.rst
   python/branches/tlee-ast-optimize/Doc/library/dircache.rst
   python/branches/tlee-ast-optimize/Doc/library/dl.rst
   python/branches/tlee-ast-optimize/Doc/library/easydialogs.rst
   python/branches/tlee-ast-optimize/Doc/library/exceptions.rst
   python/branches/tlee-ast-optimize/Doc/library/fpformat.rst
   python/branches/tlee-ast-optimize/Doc/library/framework.rst
   python/branches/tlee-ast-optimize/Doc/library/ftplib.rst
   python/branches/tlee-ast-optimize/Doc/library/functions.rst
   python/branches/tlee-ast-optimize/Doc/library/httplib.rst
   python/branches/tlee-ast-optimize/Doc/library/ic.rst
   python/branches/tlee-ast-optimize/Doc/library/imageop.rst
   python/branches/tlee-ast-optimize/Doc/library/imp.rst
   python/branches/tlee-ast-optimize/Doc/library/imputil.rst
   python/branches/tlee-ast-optimize/Doc/library/logging.rst
   python/branches/tlee-ast-optimize/Doc/library/mac.rst
   python/branches/tlee-ast-optimize/Doc/library/macos.rst
   python/branches/tlee-ast-optimize/Doc/library/macostools.rst
   python/branches/tlee-ast-optimize/Doc/library/mailbox.rst
   python/branches/tlee-ast-optimize/Doc/library/math.rst
   python/branches/tlee-ast-optimize/Doc/library/mhlib.rst
   python/branches/tlee-ast-optimize/Doc/library/mutex.rst
   python/branches/tlee-ast-optimize/Doc/library/new.rst
   python/branches/tlee-ast-optimize/Doc/library/os.path.rst
   python/branches/tlee-ast-optimize/Doc/library/os.rst
   python/branches/tlee-ast-optimize/Doc/library/othergui.rst
   python/branches/tlee-ast-optimize/Doc/library/pdb.rst
   python/branches/tlee-ast-optimize/Doc/library/persistence.rst
   python/branches/tlee-ast-optimize/Doc/library/pickle.rst
   python/branches/tlee-ast-optimize/Doc/library/plistlib.rst
   python/branches/tlee-ast-optimize/Doc/library/pprint.rst
   python/branches/tlee-ast-optimize/Doc/library/queue.rst
   python/branches/tlee-ast-optimize/Doc/library/re.rst
   python/branches/tlee-ast-optimize/Doc/library/rexec.rst
   python/branches/tlee-ast-optimize/Doc/library/rlcompleter.rst
   python/branches/tlee-ast-optimize/Doc/library/simplexmlrpcserver.rst
   python/branches/tlee-ast-optimize/Doc/library/smtplib.rst
   python/branches/tlee-ast-optimize/Doc/library/socket.rst
   python/branches/tlee-ast-optimize/Doc/library/socketserver.rst
   python/branches/tlee-ast-optimize/Doc/library/stdtypes.rst
   python/branches/tlee-ast-optimize/Doc/library/string.rst
   python/branches/tlee-ast-optimize/Doc/library/telnetlib.rst
   python/branches/tlee-ast-optimize/Doc/library/tempfile.rst
   python/branches/tlee-ast-optimize/Doc/library/test.rst
   python/branches/tlee-ast-optimize/Doc/library/textwrap.rst
   python/branches/tlee-ast-optimize/Doc/library/threading.rst
   python/branches/tlee-ast-optimize/Doc/library/tk.rst
   python/branches/tlee-ast-optimize/Doc/library/undoc.rst
   python/branches/tlee-ast-optimize/Doc/library/urllib2.rst
   python/branches/tlee-ast-optimize/Doc/library/user.rst
   python/branches/tlee-ast-optimize/Doc/library/warnings.rst
   python/branches/tlee-ast-optimize/Doc/library/winsound.rst
   python/branches/tlee-ast-optimize/Doc/library/zipfile.rst
   python/branches/tlee-ast-optimize/Doc/library/zipimport.rst
   python/branches/tlee-ast-optimize/Doc/license.rst
   python/branches/tlee-ast-optimize/Doc/reference/datamodel.rst
   python/branches/tlee-ast-optimize/Doc/reference/executionmodel.rst
   python/branches/tlee-ast-optimize/Doc/reference/expressions.rst
   python/branches/tlee-ast-optimize/Doc/reference/simple_stmts.rst
   python/branches/tlee-ast-optimize/Doc/tutorial/modules.rst
   python/branches/tlee-ast-optimize/Doc/tutorial/stdlib2.rst
   python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst
   python/branches/tlee-ast-optimize/Include/patchlevel.h
   python/branches/tlee-ast-optimize/Include/stringobject.h
   python/branches/tlee-ast-optimize/Lib/BaseHTTPServer.py
   python/branches/tlee-ast-optimize/Lib/Bastion.py
   python/branches/tlee-ast-optimize/Lib/SimpleXMLRPCServer.py
   python/branches/tlee-ast-optimize/Lib/bdb.py
   python/branches/tlee-ast-optimize/Lib/bsddb/__init__.py
   python/branches/tlee-ast-optimize/Lib/bsddb/dbshelve.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_all.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_associate.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_basics.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_compare.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_compat.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_cursor_pget_bug.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbobj.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbshelve.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbtables.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_get_none.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_join.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_lock.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_misc.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_pickle.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_queue.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_recno.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_sequence.py
   python/branches/tlee-ast-optimize/Lib/bsddb/test/test_thread.py
   python/branches/tlee-ast-optimize/Lib/compiler/__init__.py
   python/branches/tlee-ast-optimize/Lib/copy.py
   python/branches/tlee-ast-optimize/Lib/copy_reg.py
   python/branches/tlee-ast-optimize/Lib/dircache.py
   python/branches/tlee-ast-optimize/Lib/distutils/__init__.py
   python/branches/tlee-ast-optimize/Lib/distutils/archive_util.py
   python/branches/tlee-ast-optimize/Lib/distutils/command/build_ext.py
   python/branches/tlee-ast-optimize/Lib/distutils/command/register.py
   python/branches/tlee-ast-optimize/Lib/distutils/command/upload.py
   python/branches/tlee-ast-optimize/Lib/distutils/core.py
   python/branches/tlee-ast-optimize/Lib/distutils/dist.py
   python/branches/tlee-ast-optimize/Lib/distutils/tests/test_dist.py
   python/branches/tlee-ast-optimize/Lib/doctest.py
   python/branches/tlee-ast-optimize/Lib/fpformat.py
   python/branches/tlee-ast-optimize/Lib/fractions.py
   python/branches/tlee-ast-optimize/Lib/idlelib/idlever.py
   python/branches/tlee-ast-optimize/Lib/idlelib/rpc.py
   python/branches/tlee-ast-optimize/Lib/idlelib/run.py
   python/branches/tlee-ast-optimize/Lib/ihooks.py
   python/branches/tlee-ast-optimize/Lib/imputil.py
   python/branches/tlee-ast-optimize/Lib/io.py
   python/branches/tlee-ast-optimize/Lib/json/encoder.py
   python/branches/tlee-ast-optimize/Lib/lib-tk/Canvas.py
   python/branches/tlee-ast-optimize/Lib/lib-tk/Tkinter.py
   python/branches/tlee-ast-optimize/Lib/logging/config.py
   python/branches/tlee-ast-optimize/Lib/macpath.py
   python/branches/tlee-ast-optimize/Lib/mhlib.py
   python/branches/tlee-ast-optimize/Lib/multifile.py
   python/branches/tlee-ast-optimize/Lib/mutex.py
   python/branches/tlee-ast-optimize/Lib/new.py
   python/branches/tlee-ast-optimize/Lib/ntpath.py
   python/branches/tlee-ast-optimize/Lib/os.py
   python/branches/tlee-ast-optimize/Lib/pdb.doc
   python/branches/tlee-ast-optimize/Lib/pdb.py
   python/branches/tlee-ast-optimize/Lib/pickle.py
   python/branches/tlee-ast-optimize/Lib/plat-irix5/AL.py
   python/branches/tlee-ast-optimize/Lib/plat-irix6/AL.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/Audio_mac.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/Carbon/__init__.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/EasyDialogs.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/FrameWork.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/MiniAEFrame.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/PixMapWrapper.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/aepack.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/aetools.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/aetypes.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/applesingle.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/appletrawmain.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/appletrunner.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/argvemulator.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/bgenlocations.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/buildtools.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/bundlebuilder.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/cfmfile.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/findertools.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/gensuitemodule.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/ic.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/icopen.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/macerrors.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/macostools.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/macresource.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/pimp.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/terminalcommand.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/videoreader.py
   python/branches/tlee-ast-optimize/Lib/platform.py
   python/branches/tlee-ast-optimize/Lib/plistlib.py
   python/branches/tlee-ast-optimize/Lib/posixpath.py
   python/branches/tlee-ast-optimize/Lib/pprint.py
   python/branches/tlee-ast-optimize/Lib/re.py
   python/branches/tlee-ast-optimize/Lib/rexec.py
   python/branches/tlee-ast-optimize/Lib/rlcompleter.py
   python/branches/tlee-ast-optimize/Lib/sched.py
   python/branches/tlee-ast-optimize/Lib/site.py
   python/branches/tlee-ast-optimize/Lib/stringold.py
   python/branches/tlee-ast-optimize/Lib/tempfile.py
   python/branches/tlee-ast-optimize/Lib/test/pickletester.py
   python/branches/tlee-ast-optimize/Lib/test/regrtest.py
   python/branches/tlee-ast-optimize/Lib/test/test___all__.py
   python/branches/tlee-ast-optimize/Lib/test/test_al.py
   python/branches/tlee-ast-optimize/Lib/test/test_bsddb185.py
   python/branches/tlee-ast-optimize/Lib/test/test_bsddb3.py
   python/branches/tlee-ast-optimize/Lib/test/test_builtin.py
   python/branches/tlee-ast-optimize/Lib/test/test_compiler.py
   python/branches/tlee-ast-optimize/Lib/test/test_copy.py
   python/branches/tlee-ast-optimize/Lib/test/test_dircache.py
   python/branches/tlee-ast-optimize/Lib/test/test_dl.py
   python/branches/tlee-ast-optimize/Lib/test/test_dummy_thread.py
   python/branches/tlee-ast-optimize/Lib/test/test_enumerate.py
   python/branches/tlee-ast-optimize/Lib/test/test_eof.py
   python/branches/tlee-ast-optimize/Lib/test/test_fpformat.py
   python/branches/tlee-ast-optimize/Lib/test/test_imageop.py
   python/branches/tlee-ast-optimize/Lib/test/test_io.py
   python/branches/tlee-ast-optimize/Lib/test/test_json.py
   python/branches/tlee-ast-optimize/Lib/test/test_linuxaudiodev.py
   python/branches/tlee-ast-optimize/Lib/test/test_logging.py
   python/branches/tlee-ast-optimize/Lib/test/test_marshal.py
   python/branches/tlee-ast-optimize/Lib/test/test_math.py
   python/branches/tlee-ast-optimize/Lib/test/test_mhlib.py
   python/branches/tlee-ast-optimize/Lib/test/test_multifile.py
   python/branches/tlee-ast-optimize/Lib/test/test_mutex.py
   python/branches/tlee-ast-optimize/Lib/test/test_new.py
   python/branches/tlee-ast-optimize/Lib/test/test_pprint.py
   python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py
   python/branches/tlee-ast-optimize/Lib/test/test_pyclbr.py
   python/branches/tlee-ast-optimize/Lib/test/test_queue.py
   python/branches/tlee-ast-optimize/Lib/test/test_repr.py
   python/branches/tlee-ast-optimize/Lib/test/test_site.py
   python/branches/tlee-ast-optimize/Lib/test/test_socket.py
   python/branches/tlee-ast-optimize/Lib/test/test_socketserver.py
   python/branches/tlee-ast-optimize/Lib/test/test_support.py
   python/branches/tlee-ast-optimize/Lib/test/test_sys.py
   python/branches/tlee-ast-optimize/Lib/test/test_textwrap.py
   python/branches/tlee-ast-optimize/Lib/test/test_types.py
   python/branches/tlee-ast-optimize/Lib/test/test_warnings.py
   python/branches/tlee-ast-optimize/Lib/test/test_wsgiref.py
   python/branches/tlee-ast-optimize/Lib/test/test_zipimport.py
   python/branches/tlee-ast-optimize/Lib/test/testall.py
   python/branches/tlee-ast-optimize/Lib/textwrap.py
   python/branches/tlee-ast-optimize/Lib/toaiff.py
   python/branches/tlee-ast-optimize/Lib/unittest.py
   python/branches/tlee-ast-optimize/Lib/urllib.py
   python/branches/tlee-ast-optimize/Lib/user.py
   python/branches/tlee-ast-optimize/Lib/warnings.py
   python/branches/tlee-ast-optimize/Mac/Modules/ColorPickermodule.c
   python/branches/tlee-ast-optimize/Mac/Modules/MacOS.c
   python/branches/tlee-ast-optimize/Mac/Modules/Nav.c
   python/branches/tlee-ast-optimize/Mac/Modules/OSATerminology.c
   python/branches/tlee-ast-optimize/Mac/Modules/autoGIL.c
   python/branches/tlee-ast-optimize/Mac/Modules/icgluemodule.c
   python/branches/tlee-ast-optimize/Makefile.pre.in
   python/branches/tlee-ast-optimize/Misc/ACKS
   python/branches/tlee-ast-optimize/Misc/NEWS
   python/branches/tlee-ast-optimize/Misc/RPM/python-2.6.spec
   python/branches/tlee-ast-optimize/Misc/TextMate/Python-Dev.tmbundle/Commands/2 to 3 - Module Deletion.tmCommand
   python/branches/tlee-ast-optimize/Misc/TextMate/Python-Dev.tmbundle/info.plist
   python/branches/tlee-ast-optimize/Misc/cheatsheet
   python/branches/tlee-ast-optimize/Modules/Setup.dist
   python/branches/tlee-ast-optimize/Modules/_bsddb.c
   python/branches/tlee-ast-optimize/Modules/_fileio.c
   python/branches/tlee-ast-optimize/Modules/almodule.c
   python/branches/tlee-ast-optimize/Modules/bsddb.h
   python/branches/tlee-ast-optimize/Modules/bsddbmodule.c
   python/branches/tlee-ast-optimize/Modules/cPickle.c
   python/branches/tlee-ast-optimize/Modules/dlmodule.c
   python/branches/tlee-ast-optimize/Modules/imageop.c
   python/branches/tlee-ast-optimize/Modules/linuxaudiodev.c
   python/branches/tlee-ast-optimize/Modules/mathmodule.c
   python/branches/tlee-ast-optimize/Modules/parsermodule.c
   python/branches/tlee-ast-optimize/Modules/puremodule.c
   python/branches/tlee-ast-optimize/Modules/svmodule.c
   python/branches/tlee-ast-optimize/Modules/timingmodule.c
   python/branches/tlee-ast-optimize/Modules/zipimport.c
   python/branches/tlee-ast-optimize/Objects/bytesobject.c
   python/branches/tlee-ast-optimize/Objects/enumobject.c
   python/branches/tlee-ast-optimize/Objects/floatobject.c
   python/branches/tlee-ast-optimize/Objects/setobject.c
   python/branches/tlee-ast-optimize/Objects/stringlib/formatter.h
   python/branches/tlee-ast-optimize/Objects/stringlib/stringdefs.h
   python/branches/tlee-ast-optimize/Objects/stringlib/unicodedefs.h
   python/branches/tlee-ast-optimize/Objects/stringobject.c
   python/branches/tlee-ast-optimize/Objects/typeobject.c
   python/branches/tlee-ast-optimize/Objects/unicodeobject.c
   python/branches/tlee-ast-optimize/PC/VS8.0/pythoncore.vcproj
   python/branches/tlee-ast-optimize/PC/config.c
   python/branches/tlee-ast-optimize/PC/winsound.c
   python/branches/tlee-ast-optimize/PCbuild/pythoncore.vcproj
   python/branches/tlee-ast-optimize/Python/_warnings.c
   python/branches/tlee-ast-optimize/Python/bltinmodule.c
   python/branches/tlee-ast-optimize/Python/marshal.c
   python/branches/tlee-ast-optimize/Python/pystrtod.c
   python/branches/tlee-ast-optimize/Python/pythonrun.c
   python/branches/tlee-ast-optimize/Python/sysmodule.c
   python/branches/tlee-ast-optimize/README
   python/branches/tlee-ast-optimize/Tools/buildbot/buildmsi.bat
   python/branches/tlee-ast-optimize/Tools/msi/msi.py
   python/branches/tlee-ast-optimize/Tools/msi/msisupport.c
   python/branches/tlee-ast-optimize/Tools/msi/msisupport.mak
   python/branches/tlee-ast-optimize/Tools/msi/uuids.py
   python/branches/tlee-ast-optimize/Tools/webchecker/wsgui.py
   python/branches/tlee-ast-optimize/setup.py

Modified: python/branches/tlee-ast-optimize/.bzrignore
==============================================================================
--- python/branches/tlee-ast-optimize/.bzrignore	(original)
+++ python/branches/tlee-ast-optimize/.bzrignore	Thu May 15 00:25:06 2008
@@ -41,7 +41,5 @@
 Modules/config.c
 Parser/pgen
 Lib/plat-mac/errors.rsrc.df.rsrc
-Lib/lib2to3/Grammar2.6.0.alpha.1.pickle
-Lib/lib2to3/Grammar2.6.0.alpha.2.pickle
-Lib/lib2to3/PatternGrammar2.6.0.alpha.1.pickle
-Lib/lib2to3/PatternGrammar2.6.0.alpha.2.pickle
+Lib/lib2to3/Grammar*.pickle
+Lib/lib2to3/PatternGrammar*.pickle

Modified: python/branches/tlee-ast-optimize/Doc/c-api/marshal.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/c-api/marshal.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/c-api/marshal.rst	Thu May 15 00:25:06 2008
@@ -14,8 +14,9 @@
 
 The module supports two versions of the data format: version 0 is the historical
 version, version 1 (new in Python 2.4) shares interned strings in the file, and
-upon unmarshalling. *Py_MARSHAL_VERSION* indicates the current file format
-(currently 1).
+upon unmarshalling.  Version 2 (new in Python 2.5) uses a binary format for
+floating point numbers.
+*Py_MARSHAL_VERSION* indicates the current file format (currently 2).
 
 
 .. cfunction:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version)

Modified: python/branches/tlee-ast-optimize/Doc/distutils/packageindex.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/distutils/packageindex.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/distutils/packageindex.rst	Thu May 15 00:25:06 2008
@@ -55,11 +55,40 @@
 
 The format of the :file:`.pypirc` file is as follows::
 
-   [server-login]
+   [distutils]
+   index-servers =
+     pypi
+
+   [pypi]
    repository: <repository-url>
    username: <username>
    password: <password>
 
 *repository* can be omitted and defaults to ``http://www.python.org/pypi``.
 
+If you want to define another server a new section can be created::
+
+   [distutils]
+   index-servers =
+     pypi
+     other
+ 
+   [pypi]
+   repository: <repository-url>
+   username: <username>
+   password: <password>
+
+   [other]
+   repository: http://example.com/pypi
+   username: <username>
+   password: <password>
+
+The command can then be called with the -r option::
+
+   python setup.py register -r http://example.com/pypi
+
+Or even with the section name::
+
+   python setup.py register -r other
 
+ 

Modified: python/branches/tlee-ast-optimize/Doc/distutils/uploading.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/distutils/uploading.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/distutils/uploading.rst	Thu May 15 00:25:06 2008
@@ -24,14 +24,20 @@
 from the :file:`$HOME/.pypirc` file (see section :ref:`pypirc` for more on this
 file).
 
+You can specify another PyPI server with the :option:`--repository=*url*` option::
+
+   python setup.py sdist bdist_wininst upload -r http://example.com/pypi
+
+See section :ref:`pypirc` for more on defining several servers.
+
 You can use the :option:`--sign` option to tell :command:`upload` to sign each
 uploaded file using GPG (GNU Privacy Guard).  The  :program:`gpg` program must
 be available for execution on the system :envvar:`PATH`.  You can also specify
 which key to use for signing using the :option:`--identity=*name*` option.
 
-Other :command:`upload` options include  :option:`--repository=*url*` (which
-lets you override the repository setting from :file:`$HOME/.pypirc`), and
+Other :command:`upload` options include  :option:`--repository=*url*` 
+or :option:`--repository=*section*` where `url` is the url of the server
+and `section` the name of the section in :file:`$HOME/.pypirc`, and
 :option:`--show-response` (which displays the full response text from the PyPI
 server for help in debugging upload problems).
 
-

Modified: python/branches/tlee-ast-optimize/Doc/library/_winreg.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/_winreg.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/_winreg.rst	Thu May 15 00:25:06 2008
@@ -150,7 +150,7 @@
    *key* is an already open key, or one of the predefined  :const:`HKEY_\*`
    constants.
 
-   It is not necessary to call RegFlushKey to change a key. Registry changes are
+   It is not necessary to call :func:`FlushKey` to change a key. Registry changes are
    flushed to disk by the registry using its lazy  flusher.  Registry changes are
    also flushed to disk at system  shutdown.  Unlike :func:`CloseKey`, the
    :func:`FlushKey` method  returns only when all the data has been written to the
@@ -163,7 +163,7 @@
       isn't.
 
 
-.. function:: RegLoadKey(key, sub_key, file_name)
+.. function:: LoadKey(key, sub_key, file_name)
 
    Creates a subkey under the specified key and stores registration  information
    from a specified file into that subkey.

Modified: python/branches/tlee-ast-optimize/Doc/library/aepack.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/aepack.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/aepack.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,7 @@
 .. module:: aepack
    :platform: Mac
    :synopsis: Conversion between Python variables and AppleEvent data containers.
+   :deprecated:
 .. sectionauthor:: Vincent Marchetti <vincem at en.com>
 .. moduleauthor:: Jack Jansen
 
@@ -13,6 +14,11 @@
 AppleEvent descriptor is handled by Python objects of built-in type
 :class:`AEDesc`, defined in module :mod:`Carbon.AE`.
 
+.. warning::
+
+   This module is removed in 3.0.
+
+
 The :mod:`aepack` module defines the following functions:
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/aetools.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/aetools.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/aetools.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,7 @@
 .. module:: aetools
    :platform: Mac
    :synopsis: Basic support for sending Apple Events
+   :deprecated:
 .. sectionauthor:: Jack Jansen <Jack.Jansen at cwi.nl>
 .. moduleauthor:: Jack Jansen
 
@@ -21,6 +22,11 @@
 manager, see section :ref:`osx-gui-scripts` for details. This restriction may be
 lifted in future releases.
 
+.. warning::
+
+   This module is removed in 3.0.
+
+
 The :mod:`aetools` module defines the following functions:
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/aetypes.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/aetypes.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/aetypes.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,7 @@
 .. module:: aetypes
    :platform: Mac
    :synopsis: Python representation of the Apple Event Object Model.
+   :deprecated:
 .. sectionauthor:: Vincent Marchetti <vincem at en.com>
 .. moduleauthor:: Jack Jansen
 
@@ -30,6 +31,12 @@
 contains object specifiers for a number of common OSA classes such as
 ``Document``, ``Window``, ``Character``, etc.
 
+.. warning::
+
+   This module is removed in 3.0.
+
+
+
 The :mod:`AEObjects` module defines the following classes to represent Apple
 Event descriptor data:
 

Modified: python/branches/tlee-ast-optimize/Doc/library/autogil.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/autogil.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/autogil.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,7 @@
 .. module:: autoGIL
    :platform: Mac
    :synopsis: Global Interpreter Lock handling in event loops.
+   :deprecated:
 .. moduleauthor:: Just van Rossum <just at letterror.com>
 
 
@@ -12,6 +13,10 @@
 automatically locks and unlocks Python's :term:`Global Interpreter Lock` when
 running an event loop.
 
+.. warning::
+
+   This module is removed in 3.0.
+
 
 .. exception:: AutoGILError
 

Modified: python/branches/tlee-ast-optimize/Doc/library/basehttpserver.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/basehttpserver.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/basehttpserver.rst	Thu May 15 00:25:06 2008
@@ -21,7 +21,7 @@
 functioning Web servers. See the :mod:`SimpleHTTPServer` and
 :mod:`CGIHTTPServer` modules.
 
-The first class, :class:`HTTPServer`, is a :class:`SocketServer.TCPServer`
+The first class, :class:`HTTPServer`, is a :class:`socketserver.TCPServer`
 subclass.  It creates and listens at the HTTP socket, dispatching the requests
 to a handler.  Code to create and run the server looks like this::
 

Modified: python/branches/tlee-ast-optimize/Doc/library/bastion.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/bastion.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/bastion.rst	Thu May 15 00:25:06 2008
@@ -4,6 +4,11 @@
 
 .. module:: Bastion
    :synopsis: Providing restricted access to objects.
+   :deprecated:
+   
+.. deprecated:: 2.6
+   The :mod:`Bastion` module has been removed in Python 3.0.
+   
 .. moduleauthor:: Barry Warsaw <bwarsaw at python.org>
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/bdb.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/bdb.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/bdb.rst	Thu May 15 00:25:06 2008
@@ -207,6 +207,11 @@
 
       Stop when returning from the given frame.
 
+   .. method:: set_until(frame)
+
+      Stop when the line with the line no greater than the current one is
+      reached or when returning from current frame
+
    .. method:: set_trace([frame])
 
       Start debugging from *frame*.  If *frame* is not specified, debugging

Modified: python/branches/tlee-ast-optimize/Doc/library/binhex.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/binhex.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/binhex.rst	Thu May 15 00:25:06 2008
@@ -11,6 +11,11 @@
 file and the finder information are encoded (or decoded), on other platforms
 only the data fork is handled.
 
+.. warning::
+
+   In 3.0, special Macintosh support is removed.
+
+
 The :mod:`binhex` module defines the following functions:
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/bsddb.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/bsddb.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/bsddb.rst	Thu May 15 00:25:06 2008
@@ -82,7 +82,8 @@
    Beginning in 2.3 some Unix versions of Python may have a :mod:`bsddb185` module.
    This is present *only* to allow backwards compatibility with systems which ship
    with the old Berkeley DB 1.85 database library.  The :mod:`bsddb185` module
-   should never be used directly in new code.
+   should never be used directly in new code. The module has been removed in
+   Python 3.0.  If you find you still need it look in PyPI.
 
 
 .. seealso::

Modified: python/branches/tlee-ast-optimize/Doc/library/carbon.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/carbon.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/carbon.rst	Thu May 15 00:25:06 2008
@@ -22,8 +22,9 @@
 
    from Carbon import AE
 
-**Warning!**  These modules are not yet documented.  If you wish to contribute
-documentation of any of these modules, please get in touch with docs at python.org.
+.. warning::
+
+   The Carbon modules are removed in 3.0.
 
 
 :mod:`Carbon.AE` --- Apple Events
@@ -32,6 +33,7 @@
 .. module:: Carbon.AE
    :platform: Mac
    :synopsis: Interface to the Apple Events toolbox.
+   :deprecated:
 
 
 
@@ -41,6 +43,7 @@
 .. module:: Carbon.AH
    :platform: Mac
    :synopsis: Interface to the Apple Help manager.
+   :deprecated:
 
 
 
@@ -50,6 +53,7 @@
 .. module:: Carbon.App
    :platform: Mac
    :synopsis: Interface to the Appearance Manager.
+   :deprecated:
 
 
 
@@ -59,6 +63,7 @@
 .. module:: Carbon.CF
    :platform: Mac
    :synopsis: Interface to the Core Foundation.
+   :deprecated:
 
 
 The ``CFBase``, ``CFArray``, ``CFData``, ``CFDictionary``, ``CFString`` and
@@ -71,6 +76,7 @@
 .. module:: Carbon.CG
    :platform: Mac
    :synopsis: Interface to Core Graphics.
+   :deprecated:
 
 
 
@@ -80,6 +86,7 @@
 .. module:: Carbon.CarbonEvt
    :platform: Mac
    :synopsis: Interface to the Carbon Event Manager.
+   :deprecated:
 
 
 
@@ -89,6 +96,7 @@
 .. module:: Carbon.Cm
    :platform: Mac
    :synopsis: Interface to the Component Manager.
+   :deprecated:
 
 
 
@@ -98,6 +106,7 @@
 .. module:: Carbon.Ctl
    :platform: Mac
    :synopsis: Interface to the Control Manager.
+   :deprecated:
 
 
 
@@ -107,6 +116,7 @@
 .. module:: Carbon.Dlg
    :platform: Mac
    :synopsis: Interface to the Dialog Manager.
+   :deprecated:
 
 
 
@@ -116,6 +126,7 @@
 .. module:: Carbon.Evt
    :platform: Mac
    :synopsis: Interface to the classic Event Manager.
+   :deprecated:
 
 
 
@@ -125,6 +136,7 @@
 .. module:: Carbon.Fm
    :platform: Mac
    :synopsis: Interface to the Font Manager.
+   :deprecated:
 
 
 
@@ -134,6 +146,7 @@
 .. module:: Carbon.Folder
    :platform: Mac
    :synopsis: Interface to the Folder Manager.
+   :deprecated:
 
 
 
@@ -143,6 +156,7 @@
 .. module:: Carbon.Help
    :platform: Mac
    :synopsis: Interface to the Carbon Help Manager.
+   :deprecated:
 
 
 
@@ -152,6 +166,7 @@
 .. module:: Carbon.List
    :platform: Mac
    :synopsis: Interface to the List Manager.
+   :deprecated:
 
 
 
@@ -161,6 +176,7 @@
 .. module:: Carbon.Menu
    :platform: Mac
    :synopsis: Interface to the Menu Manager.
+   :deprecated:
 
 
 
@@ -170,6 +186,7 @@
 .. module:: Carbon.Mlte
    :platform: Mac
    :synopsis: Interface to the MultiLingual Text Editor.
+   :deprecated:
 
 
 
@@ -179,6 +196,7 @@
 .. module:: Carbon.Qd
    :platform: Mac
    :synopsis: Interface to the QuickDraw toolbox.
+   :deprecated:
 
 
 
@@ -188,6 +206,7 @@
 .. module:: Carbon.Qdoffs
    :platform: Mac
    :synopsis: Interface to the QuickDraw Offscreen APIs.
+   :deprecated:
 
 
 
@@ -197,6 +216,7 @@
 .. module:: Carbon.Qt
    :platform: Mac
    :synopsis: Interface to the QuickTime toolbox.
+   :deprecated:
 
 
 
@@ -206,6 +226,7 @@
 .. module:: Carbon.Res
    :platform: Mac
    :synopsis: Interface to the Resource Manager and Handles.
+   :deprecated:
 
 
 
@@ -216,6 +237,7 @@
    :platform: Mac
    :synopsis: The Scrap Manager provides basic services for implementing cut & paste and
               clipboard operations.
+   :deprecated:
 
 
 This module is only fully available on MacOS9 and earlier under classic PPC
@@ -266,6 +288,7 @@
 .. module:: Carbon.Snd
    :platform: Mac
    :synopsis: Interface to the Sound Manager.
+   :deprecated:
 
 
 
@@ -275,6 +298,7 @@
 .. module:: Carbon.TE
    :platform: Mac
    :synopsis: Interface to TextEdit.
+   :deprecated:
 
 
 
@@ -284,5 +308,4 @@
 .. module:: Carbon.Win
    :platform: Mac
    :synopsis: Interface to the Window Manager.
-
-
+   :deprecated:

Modified: python/branches/tlee-ast-optimize/Doc/library/cgi.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/cgi.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/cgi.rst	Thu May 15 00:25:06 2008
@@ -250,9 +250,11 @@
 Old classes
 -----------
 
-These classes, present in earlier versions of the :mod:`cgi` module, are still
-supported for backward compatibility.  New applications should use the
-:class:`FieldStorage` class.
+.. deprecated:: 2.6
+
+   These classes, present in earlier versions of the :mod:`cgi` module, are
+   still supported for backward compatibility.  New applications should use the
+   :class:`FieldStorage` class.
 
 :class:`SvFormContentDict` stores single value form content as dictionary; it
 assumes each field name occurs in the form only once.

Modified: python/branches/tlee-ast-optimize/Doc/library/collections.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/collections.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/collections.rst	Thu May 15 00:25:06 2008
@@ -570,16 +570,6 @@
    for emp in map(EmployeeRecord._make, cursor.fetchall()):
        print emp.name, emp.title
 
-Named tuples can also be used to generate enumerated constants:
-
-.. testcode::
-
-   def enum(*names):
-       return namedtuple('Enum', ' '.join(names))(*range(len(names)))
-   
-   Status = enum('open', 'pending', 'closed')
-   assert (0, 1, 2) == (Status.open, Status.pending, Status.closed)
-
 In addition to the methods inherited from tuples, named tuples support
 three additional methods and one attribute.  To prevent conflicts with
 field names, the method and attribute names start with an underscore.
@@ -674,6 +664,15 @@
     >>> default_account = Account('<owner name>', 0.0, 0)
     >>> johns_account = default_account._replace(owner='John')
 
+Enumerated constants can be implemented with named tuples, but it is simpler
+and more efficient to use a simple class declaration:
+
+    >>> Status = namedtuple('Status', 'open pending closed')._make(range(3))
+    >>> Status.open, Status.pending, Status.closed
+    (0, 1, 2)
+    >>> class Status:
+    ...     open, pending, closed = range(3)
+
 .. rubric:: Footnotes
 
 .. [#] For information on the double-star-operator see

Modified: python/branches/tlee-ast-optimize/Doc/library/colorpicker.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/colorpicker.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/colorpicker.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,7 @@
 .. module:: ColorPicker
    :platform: Mac
    :synopsis: Interface to the standard color selection dialog.
+   :deprecated:
 .. moduleauthor:: Just van Rossum <just at letterror.com>
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake at acm.org>
 
@@ -12,6 +13,10 @@
 The :mod:`ColorPicker` module provides access to the standard color picker
 dialog.
 
+.. warning::
+
+   This module is removed in 3.0.
+
 
 .. function:: GetColor(prompt, rgb)
 

Modified: python/branches/tlee-ast-optimize/Doc/library/colorsys.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/colorsys.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/colorsys.rst	Thu May 15 00:25:06 2008
@@ -1,4 +1,3 @@
-
 :mod:`colorsys` --- Conversions between color systems
 =====================================================
 
@@ -15,8 +14,11 @@
 0 and 1, but the I and Q coordinates can be positive or negative.  In all other
 spaces, the coordinates are all between 0 and 1.
 
-More information about color spaces can be found at
-http://www.poynton.com/ColorFAQ.html.
+.. seealso::
+
+   More information about color spaces can be found at
+   http://www.poynton.com/ColorFAQ.html and
+   http://www.cambridgeincolour.com/tutorials/color-spaces.htm.
 
 The :mod:`colorsys` module defines the following functions:
 
@@ -57,4 +59,3 @@
    (0.25, 0.5, 0.4)
    >>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4)
    (0.3, 0.4, 0.2)
-

Modified: python/branches/tlee-ast-optimize/Doc/library/compiler.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/compiler.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/compiler.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,9 @@
 Python compiler package
 ***********************
 
+.. deprecated:: 2.6
+   The :mod:`compiler` package has been removed in Python 3.0.
+
 .. sectionauthor:: Jeremy Hylton <jeremy at zope.com>
 
 
@@ -34,6 +37,7 @@
 
 .. module:: compiler
    :synopsis: Python code compiler written in Python.
+   :deprecated:
 
 
 The top-level of the package defines four functions.  If you import

Modified: python/branches/tlee-ast-optimize/Doc/library/copy.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/copy.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/copy.rst	Thu May 15 00:25:06 2008
@@ -63,7 +63,7 @@
 
 Classes can use the same interfaces to control copying that they use to control
 pickling.  See the description of module :mod:`pickle` for information on these
-methods.  The :mod:`copy` module does not use the :mod:`copy_reg` registration
+methods.  The :mod:`copy` module does not use the :mod:`copyreg` registration
 module.
 
 .. index::

Deleted: python/branches/tlee-ast-optimize/Doc/library/copy_reg.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/copy_reg.rst	Thu May 15 00:25:06 2008
+++ (empty file)
@@ -1,42 +0,0 @@
-
-:mod:`copy_reg` --- Register :mod:`pickle` support functions
-============================================================
-
-.. module:: copy_reg
-   :synopsis: Register pickle support functions.
-
-
-.. index::
-   module: pickle
-   module: cPickle
-   module: copy
-
-The :mod:`copy_reg` module provides support for the :mod:`pickle` and
-:mod:`cPickle` modules.  The :mod:`copy` module is likely to use this in the
-future as well.  It provides configuration information about object constructors
-which are not classes.  Such constructors may be factory functions or class
-instances.
-
-
-.. function:: constructor(object)
-
-   Declares *object* to be a valid constructor.  If *object* is not callable (and
-   hence not valid as a constructor), raises :exc:`TypeError`.
-
-
-.. function:: pickle(type, function[, constructor])
-
-   Declares that *function* should be used as a "reduction" function for objects of
-   type *type*; *type* must not be a "classic" class object.  (Classic classes are
-   handled differently; see the documentation for the :mod:`pickle` module for
-   details.)  *function* should return either a string or a tuple containing two or
-   three elements.
-
-   The optional *constructor* parameter, if provided, is a callable object which
-   can be used to reconstruct the object when called with the tuple of arguments
-   returned by *function* at pickling time.  :exc:`TypeError` will be raised if
-   *object* is a class or *constructor* is not callable.
-
-   See the :mod:`pickle` module for more details on the interface expected of
-   *function* and *constructor*.
-

Modified: python/branches/tlee-ast-optimize/Doc/library/dircache.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/dircache.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/dircache.rst	Thu May 15 00:25:06 2008
@@ -4,6 +4,12 @@
 
 .. module:: dircache
    :synopsis: Return directory listing, with cache mechanism.
+   :deprecated:
+   
+.. deprecated:: 2.6
+   The :mod:`dircache` module has been removed in Python 3.0.
+   
+   
 .. sectionauthor:: Moshe Zadka <moshez at zadka.site.co.il>
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/dl.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/dl.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/dl.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,12 @@
 .. module:: dl
    :platform: Unix
    :synopsis: Call C functions in shared objects.
+   :deprecated:
+   
+.. deprecated:: 2.6
+    The :mod:`dl` module has been removed in Python 3.0. Use the :mod:`ctypes`
+    module instead.
+   
 .. sectionauthor:: Moshe Zadka <moshez at zadka.site.co.il>
 
 The :mod:`dl` module defines an interface to the :cfunc:`dlopen` function, which

Modified: python/branches/tlee-ast-optimize/Doc/library/easydialogs.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/easydialogs.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/easydialogs.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,7 @@
 .. module:: EasyDialogs
    :platform: Mac
    :synopsis: Basic Macintosh dialogs.
+   :deprecated:
 
 
 The :mod:`EasyDialogs` module contains some simple dialogs for the Macintosh.
@@ -13,6 +14,11 @@
 dialog items correspond (both type and item number) to those in the default
 :const:`DLOG` resource. See source code for details.
 
+.. warning::
+
+   This module is removed in 3.0.
+
+
 The :mod:`EasyDialogs` module defines the following functions:
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/exceptions.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/exceptions.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/exceptions.rst	Thu May 15 00:25:06 2008
@@ -254,11 +254,10 @@
 
    Raised when the result of an arithmetic operation is too large to be
    represented.  This cannot occur for long integers (which would rather raise
-   :exc:`MemoryError` than give up).  Because of the lack of standardization of
-   floating point exception handling in C, most floating point operations also
-   aren't checked.  For plain integers, all operations that can overflow are
-   checked except left shift, where typical applications prefer to drop bits than
-   raise an exception.
+   :exc:`MemoryError` than give up) and for most operations with plain integers,
+   which return a long integer instead.  Because of the lack of standardization
+   of floating point exception handling in C, most floating point operations
+   also aren't checked.
 
 
 .. exception:: ReferenceError

Modified: python/branches/tlee-ast-optimize/Doc/library/fpformat.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/fpformat.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/fpformat.rst	Thu May 15 00:25:06 2008
@@ -4,6 +4,11 @@
 
 .. module:: fpformat
    :synopsis: General floating point formatting functions.
+   :deprecated:
+   
+.. deprecated:: 2.6
+    The :mod:`fpformat` module has been removed in Python 3.0.
+   
 .. sectionauthor:: Moshe Zadka <moshez at zadka.site.co.il>
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/framework.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/framework.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/framework.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,7 @@
 .. module:: FrameWork
    :platform: Mac
    :synopsis: Interactive application framework.
+   :deprecated:
 
 
 The :mod:`FrameWork` module contains classes that together provide a framework
@@ -15,6 +16,10 @@
 dialog window in a non-standard way it is not necessary to override the complete
 event handling.
 
+.. warning::
+
+   This module is removed in 3.0.
+
 Work on the :mod:`FrameWork` has pretty much stopped, now that :mod:`PyObjC` is
 available for full Cocoa access from Python, and the documentation describes
 only the most important functionality, and not in the most logical manner at

Modified: python/branches/tlee-ast-optimize/Doc/library/ftplib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/ftplib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/ftplib.rst	Thu May 15 00:25:06 2008
@@ -40,11 +40,12 @@
 .. class:: FTP([host[, user[, passwd[, acct[, timeout]]]]])
 
    Return a new instance of the :class:`FTP` class.  When *host* is given, the
-   method call ``connect(host)`` is made.  When *user* is given, additionally the
-   method call ``login(user, passwd, acct)`` is made (where *passwd* and *acct*
-   default to the empty string when not given). The optional *timeout* parameter
-   specifies a timeout in seconds for the connection attempt (if is not specified,
-   or passed as None, the global default timeout setting will be used).
+   method call ``connect(host)`` is made.  When *user* is given, additionally
+   the method call ``login(user, passwd, acct)`` is made (where *passwd* and
+   *acct* default to the empty string when not given).  The optional *timeout*
+   parameter specifies a timeout in seconds for blocking operations like the
+   connection attempt (if is not specified, or passed as None, the global
+   default timeout setting will be used).
 
    .. versionchanged:: 2.6
       *timeout* was added.
@@ -125,9 +126,10 @@
    made.
 
    The optional *timeout* parameter specifies a timeout in seconds for the
-   connection attempt. If is not specified, or passed as None, the  object timeout
-   is used (the timeout that you passed when instantiating the class); if the
-   object timeout is also None, the global default timeout  setting will be used.
+   connection attempt. If is not specified, or passed as None, the object
+   timeout is used (the timeout that you passed when instantiating the class);
+   if the object timeout is also None, the global default timeout setting will
+   be used.
 
    .. versionchanged:: 2.6
       *timeout* was added.

Modified: python/branches/tlee-ast-optimize/Doc/library/functions.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/functions.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/functions.rst	Thu May 15 00:25:06 2008
@@ -335,12 +335,13 @@
       Using :func:`divmod` with complex numbers is deprecated.
 
 
-.. function:: enumerate(iterable)
+.. function:: enumerate(sequence[, start=0])
 
-   Return an enumerate object. *iterable* must be a sequence, an :term:`iterator`, or some
-   other object which supports iteration.  The :meth:`next` method of the iterator
-   returned by :func:`enumerate` returns a tuple containing a count (from zero) and
-   the corresponding value obtained from iterating over *iterable*.
+   Return an enumerate object. *sequence* must be a sequence, an
+   :term:`iterator`, or some other object which supports iteration.  The
+   :meth:`next` method of the iterator returned by :func:`enumerate` returns a
+   tuple containing a count (from *start* which defaults to 0) and the
+   corresponding value obtained from iterating over *iterable*.
    :func:`enumerate` is useful for obtaining an indexed series: ``(0, seq[0])``,
    ``(1, seq[1])``, ``(2, seq[2])``, .... For example:
 
@@ -352,6 +353,8 @@
       3 Winter
 
    .. versionadded:: 2.3
+   .. versionadded:: 2.6
+      The *start* parameter.
 
 
 .. function:: eval(expression[, globals[, locals]])
@@ -874,10 +877,15 @@
    use is to define a managed attribute x::
 
       class C(object):
-          def __init__(self): self._x = None
-          def getx(self): return self._x
-          def setx(self, value): self._x = value
-          def delx(self): del self._x
+          def __init__(self):
+              self._x = None
+
+          def getx(self):
+              return self._x
+          def setx(self, value):
+              self._x = value
+          def delx(self):
+              del self._x
           x = property(getx, setx, delx, "I'm the 'x' property.")
 
    If given, *doc* will be the docstring of the property attribute. Otherwise, the
@@ -893,14 +901,45 @@
               """Get the current voltage."""
               return self._voltage
 
-   turns the :meth:`voltage` method into a "getter" for a read-only attribute with
-   the same name.
+   turns the :meth:`voltage` method into a "getter" for a read-only attribute
+   with the same name.
+
+   A property object has :attr:`getter`, :attr:`setter`, and :attr:`deleter`
+   methods usable as decorators that create a copy of the property with the
+   corresponding accessor function set to the decorated function.  This is
+   best explained with an example::
+
+      class C(object):
+          def __init__(self): self._x = None
+
+          @property
+          def x(self):
+              """I'm the 'x' property."""
+              return self._x
+
+          @x.setter
+          def x(self, value):
+              self._x = value
+
+          @x.deleter
+          def x(self):
+              del self._x
+
+   This code is exactly equivalent to the first example.  Be sure to give the
+   additional functions the same name as the original property (``x`` in this
+   case.)
+
+   The returned property also has the attributes ``fget``, ``fset``, and
+   ``fdel`` corresponding to the constructor arguments.
 
    .. versionadded:: 2.2
 
    .. versionchanged:: 2.5
       Use *fget*'s docstring if no *doc* given.
 
+   .. versionchanged:: 2.6 
+      The ``getter``, ``setter``, and ``deleter`` attributes were added.
+
 
 .. function:: range([start,] stop[, step])
 

Modified: python/branches/tlee-ast-optimize/Doc/library/httplib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/httplib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/httplib.rst	Thu May 15 00:25:06 2008
@@ -33,14 +33,14 @@
 .. class:: HTTPConnection(host[, port[, strict[, timeout]]])
 
    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* 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, connection attempts will timeout after
-   that many seconds (if it is not given or ``None``, the global default  timeout
-   setting is used).
+   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* 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
+   operations (like connection attempts) will timeout after that many seconds
+   (if it is not given or ``None``, the global default timeout setting is used).
 
    For example, the following calls all create instances that connect to the server
    at the same host and port::

Modified: python/branches/tlee-ast-optimize/Doc/library/ic.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/ic.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/ic.rst	Thu May 15 00:25:06 2008
@@ -5,11 +5,17 @@
 .. module:: ic
    :platform: Mac
    :synopsis: Access to the Mac OS X Internet Config.
+   :deprecated:
 
 
 This module provides access to various internet-related preferences set through
 :program:`System Preferences` or the :program:`Finder`.
 
+.. warning::
+
+   This module is removed in 3.0.
+
+
 .. index:: module: icglue
 
 There is a low-level companion module :mod:`icglue` which provides the basic

Modified: python/branches/tlee-ast-optimize/Doc/library/imageop.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/imageop.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/imageop.rst	Thu May 15 00:25:06 2008
@@ -4,7 +4,10 @@
 
 .. module:: imageop
    :synopsis: Manipulate raw image data.
-
+   :deprecated:
+   
+.. deprecated:: 2.6
+    The :mod:`imageop` module has been removed in Python 3.0.
 
 The :mod:`imageop` module contains some useful operations on images. It operates
 on images consisting of 8 or 32 bit pixels stored in Python strings.  This is

Modified: python/branches/tlee-ast-optimize/Doc/library/imp.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/imp.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/imp.rst	Thu May 15 00:25:06 2008
@@ -114,10 +114,16 @@
 
 .. function:: acquire_lock()
 
-   Acquires the interpreter's import lock for the current thread.  This lock should
+   Acquire the interpreter's import lock for the current thread.  This lock should
    be used by import hooks to ensure thread-safety when importing modules. On
    platforms without threads, this function does nothing.
 
+   Once a thread has acquired the import lock, the same thread may acquire it
+   again without blocking; the thread must release it once for each time it has
+   acquired it.
+
+   On platforms without threads, this function does nothing.
+
    .. versionadded:: 2.3
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/imputil.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/imputil.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/imputil.rst	Thu May 15 00:25:06 2008
@@ -4,6 +4,10 @@
 
 .. module:: imputil
    :synopsis: Manage and augment the import process.
+   :deprecated:
+
+.. deprecated:: 2.6
+   The :mod:`imputil` module has been removed in Python 3.0.
 
 
 .. index:: statement: import

Modified: python/branches/tlee-ast-optimize/Doc/library/logging.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/logging.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/logging.rst	Thu May 15 00:25:06 2008
@@ -698,6 +698,8 @@
    :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.
+
    .. versionchanged:: 2.4
       Formerly, :func:`basicConfig` did not take any keyword arguments.
 
@@ -1297,17 +1299,17 @@
    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`
+At the receiving end, you can set up a receiver using the :mod:`socketserver`
 module. Here is a basic working example::
 
    import cPickle
    import logging
    import logging.handlers
-   import SocketServer
+   import socketserver
    import struct
 
 
-   class LogRecordStreamHandler(SocketServer.StreamRequestHandler):
+   class LogRecordStreamHandler(socketserver.StreamRequestHandler):
        """Handler for a streaming logging request.
 
        This basically logs the record using whatever logging policy is
@@ -1349,7 +1351,7 @@
            # cycles and network bandwidth!
            logger.handle(record)
 
-   class LogRecordSocketReceiver(SocketServer.ThreadingTCPServer):
+   class LogRecordSocketReceiver(socketserver.ThreadingTCPServer):
        """simple TCP socket-based logging receiver suitable for testing.
        """
 
@@ -1358,7 +1360,7 @@
        def __init__(self, host='localhost',
                     port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
                     handler=LogRecordStreamHandler):
-           SocketServer.ThreadingTCPServer.__init__(self, (host, port), handler)
+           socketserver.ThreadingTCPServer.__init__(self, (host, port), handler)
            self.abort = 0
            self.timeout = 1
            self.logname = None

Modified: python/branches/tlee-ast-optimize/Doc/library/mac.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/mac.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/mac.rst	Thu May 15 00:25:06 2008
@@ -10,6 +10,10 @@
 modules, and the HOWTO :ref:`using-on-mac` for a general introduction to
 Mac-specific Python programming.
 
+.. warning::
+
+   These modules are deprecated and are removed in 3.0
+
 
 .. toctree::
 

Modified: python/branches/tlee-ast-optimize/Doc/library/macos.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/macos.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/macos.rst	Thu May 15 00:25:06 2008
@@ -5,12 +5,17 @@
 .. module:: MacOS
    :platform: Mac
    :synopsis: Access to Mac OS-specific interpreter features.
+   :deprecated:
 
 
 This module provides access to MacOS specific functionality in the Python
 interpreter, such as how the interpreter eventloop functions and the like. Use
 with care.
 
+.. warning::
+
+   This module is removed in 3.0.
+
 Note the capitalization of the module name; this is a historical artifact.
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/macostools.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/macostools.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/macostools.rst	Thu May 15 00:25:06 2008
@@ -5,6 +5,7 @@
 .. module:: macostools
    :platform: Mac
    :synopsis: Convenience routines for file manipulation.
+   :deprecated:
 
 
 This module contains some convenience routines for file-manipulation on the
@@ -12,6 +13,10 @@
 :class:`FSSpec` objects.  This module expects a filesystem which supports forked
 files, so it should not be used on UFS partitions.
 
+.. warning::
+
+   This module is removed in 3.0.
+
 The :mod:`macostools` module defines the following functions:
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/mailbox.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/mailbox.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/mailbox.rst	Thu May 15 00:25:06 2008
@@ -1507,11 +1507,13 @@
 Deprecated classes and methods
 ------------------------------
 
+.. deprecated:: 2.6
+
 Older versions of the :mod:`mailbox` module do not support modification of
 mailboxes, such as adding or removing message, and do not provide classes to
 represent format-specific message properties. For backward compatibility, the
 older mailbox classes are still available, but the newer classes should be used
-in preference to them.
+in preference to them.  The old classes will be removed in Python 3.0.
 
 Older mailbox objects support only iteration and provide a single public method:
 

Modified: python/branches/tlee-ast-optimize/Doc/library/math.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/math.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/math.rst	Thu May 15 00:25:06 2008
@@ -300,7 +300,7 @@
    platform and libm implementation. It's usually :exc:`ValueError` for *EDOM*
    and :exc:`OverflowError` for errno *ERANGE*.
 
-   ..versionchanged:: 2.6
+   .. versionchanged:: 2.6
       In earlier versions of Python the outcome of an operation with NaN as
       input depended on platform and libm implementation.
 

Modified: python/branches/tlee-ast-optimize/Doc/library/mhlib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/mhlib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/mhlib.rst	Thu May 15 00:25:06 2008
@@ -3,6 +3,12 @@
 
 .. module:: mhlib
    :synopsis: Manipulate MH mailboxes from Python.
+   :deprecated:
+   
+.. deprecated:: 2.6
+    The :mod:`mhlib` module has been removed in Python 3.0. Use the
+    :mod:`mailbox` instead.
+
 .. sectionauthor:: Skip Montanaro <skip at pobox.com>
 
 The :mod:`mhlib` module provides a Python interface to MH folders and their

Modified: python/branches/tlee-ast-optimize/Doc/library/mutex.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/mutex.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/mutex.rst	Thu May 15 00:25:06 2008
@@ -4,6 +4,11 @@
 
 .. module:: mutex
    :synopsis: Lock and queue for mutual exclusion.
+   :deprecated:
+   
+.. deprecated::
+   The :mod:`mutex` module has been removed in Python 3.0.
+
 .. sectionauthor:: Moshe Zadka <moshez at zadka.site.co.il>
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/new.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/new.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/new.rst	Thu May 15 00:25:06 2008
@@ -4,6 +4,11 @@
 
 .. module:: new
    :synopsis: Interface to the creation of runtime implementation objects.
+   :deprecated:
+
+.. deprecated:: 2.6
+   The :mod:`new` module has been removed in Python 3.0.
+
 .. sectionauthor:: Moshe Zadka <moshez at zadka.site.co.il>
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/os.path.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/os.path.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/os.path.rst	Thu May 15 00:25:06 2008
@@ -303,10 +303,10 @@
       identify them with ``os.path.islink(file)`` and ``os.path.isdir(file)``, and
       invoke :func:`walk` as necessary.
 
-   .. note::
+   .. warning::
 
-      The newer :func:`os.walk` :term:`generator` supplies similar functionality
-      and can be easier to use.
+      This function is deprecated and is removed in 3.0 in favor of
+      :func:`os.walk`.
 
 
 .. data:: supports_unicode_filenames

Modified: python/branches/tlee-ast-optimize/Doc/library/os.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/os.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/os.rst	Thu May 15 00:25:06 2008
@@ -285,7 +285,8 @@
 .. function:: strerror(code)
 
    Return the error message corresponding to the error code in *code*.
-   Availability: Unix, Windows.
+   On platforms where :cfunc:`strerror` returns ``NULL`` when given an unknown
+   error number, :exc:`ValueError` is raised.  Availability: Unix, Windows.
 
 
 .. function:: umask(mask)

Modified: python/branches/tlee-ast-optimize/Doc/library/othergui.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/othergui.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/othergui.rst	Thu May 15 00:25:06 2008
@@ -69,10 +69,9 @@
       <http://www.amazon.com/exec/obidos/ASIN/1932394621>`_, by Noel Rappin and
       Robin Dunn.
 
-PyGTK, PyQt, and wxPython, all have a modern look and feel and far more
-widgets and better documentation than Tkinter. In addition,
-there are many other GUI toolkits for Python, both cross-platform, and
-platform-specific. See the `GUI Programming
+PyGTK, PyQt, and wxPython, all have a modern look and feel and more
+widgets than Tkinter. In addition, there are many other GUI toolkits for 
+Python, both cross-platform, and platform-specific. See the `GUI Programming
 <http://wiki.python.org/moin/GuiProgramming>`_ page in the Python Wiki for a
 much more complete list, and also for links to documents where the
 different GUI toolkits are compared.

Modified: python/branches/tlee-ast-optimize/Doc/library/pdb.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/pdb.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/pdb.rst	Thu May 15 00:25:06 2008
@@ -267,6 +267,12 @@
    inside a called function, while ``next`` executes called functions at (nearly)
    full speed, only stopping at the next line in the current function.)
 
+unt(il)
+   Continue execution until the line with the the line number greater than the
+   current one is reached or when returning from current frame.
+
+   .. versionadded:: 2.6
+
 r(eturn)
    Continue execution until the current function returns.
 

Modified: python/branches/tlee-ast-optimize/Doc/library/persistence.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/persistence.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/persistence.rst	Thu May 15 00:25:06 2008
@@ -19,7 +19,7 @@
 .. toctree::
 
    pickle.rst
-   copy_reg.rst
+   copyreg.rst
    shelve.rst
    marshal.rst
    anydbm.rst

Modified: python/branches/tlee-ast-optimize/Doc/library/pickle.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/pickle.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/pickle.rst	Thu May 15 00:25:06 2008
@@ -535,7 +535,7 @@
 and calls :meth:`__reduce__`.
 
 An alternative to implementing a :meth:`__reduce__` method on the object to be
-pickled, is to register the callable with the :mod:`copy_reg` module.  This
+pickled, is to register the callable with the :mod:`copyreg` module.  This
 module provides a way for programs to register "reduction functions" and
 constructors for user-defined types.   Reduction functions have the same
 semantics and interface as the :meth:`__reduce__` method described above, except
@@ -786,7 +786,7 @@
 
 .. seealso::
 
-   Module :mod:`copy_reg`
+   Module :mod:`copyreg`
       Pickle interface constructor registration for extension types.
 
    Module :mod:`shelve`

Modified: python/branches/tlee-ast-optimize/Doc/library/plistlib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/plistlib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/plistlib.rst	Thu May 15 00:25:06 2008
@@ -75,12 +75,22 @@
     Read a plist from the resource with type *restype* from the resource fork of
     *path*.  Availability: MacOS X.
 
+    .. warning::
+
+       In 3.0, this function is removed.
+
+
 
 .. function:: writePlistToResource(rootObject, path[, restype='plst'[, resid=0]])
 
     Write *rootObject* as a resource with type *restype* to the resource fork of
     *path*.  Availability: MacOS X.
 
+    .. warning::
+
+       In 3.0, this function is removed.
+
+
 
 The following class is available:
 

Modified: python/branches/tlee-ast-optimize/Doc/library/pprint.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/pprint.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/pprint.rst	Thu May 15 00:25:06 2008
@@ -66,8 +66,7 @@
       ... ('parrot', ('fresh fruit',))))))))
       >>> pp = pprint.PrettyPrinter(depth=6)
       >>> pp.pprint(tup)
-      ('spam',
-       ('eggs', ('lumberjack', ('knights', ('ni', ('dead', ('parrot', (...,))))))))
+      ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', (...)))))))
 
 The :class:`PrettyPrinter` class supports several derivative functions:
 
@@ -220,7 +219,7 @@
     ['cccccccccccccccccccc', 'dddddddddddddddddddd']]
    >>> pprint.pprint(stuff, depth=3)
    ['aaaaaaaaaa',
-    ('spam', ('eggs', ('lumberjack', (...)))),
+    ('spam', ('eggs', (...))),
     ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'],
     ['cccccccccccccccccccc', 'dddddddddddddddddddd']]
    >>> pprint.pprint(stuff, width=60)

Modified: python/branches/tlee-ast-optimize/Doc/library/queue.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/queue.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/queue.rst	Thu May 15 00:25:06 2008
@@ -1,12 +1,18 @@
-
-:mod:`Queue` --- A synchronized queue class
+:mod:`queue` --- A synchronized queue class
 ===========================================
 
 .. module:: Queue
+   :synopsis: Old name for the queue module.
+
+.. module:: queue
    :synopsis: A synchronized queue class.
 
+.. note::
+   The :mod:`Queue` module has been renamed to :mod:`queue` in Python 3.0.  It
+   is importable under both names in Python 2.6 and the rest of the 2.x series.
+
 
-The :mod:`Queue` module implements multi-producer, multi-consumer queues.
+The :mod:`queue` module implements multi-producer, multi-consumer queues.
 It is especially useful in threaded programming when information must be
 exchanged safely between multiple threads.  The :class:`Queue` class in this
 module implements all the required locking semantics.  It depends on the
@@ -20,7 +26,7 @@
 the entries are kept sorted (using the :mod:`heapq` module) and the
 lowest valued entry is retrieved first.
 
-The :mod:`Queue` module defines the following classes and exceptions:
+The :mod:`queue` module defines the following classes and exceptions:
 
 .. class:: Queue(maxsize)
 

Modified: python/branches/tlee-ast-optimize/Doc/library/re.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/re.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/re.rst	Thu May 15 00:25:06 2008
@@ -43,6 +43,9 @@
       second edition of the book no longer covers Python at all, but the first
       edition covered writing good regular expression patterns in great detail.
 
+   `Kodos <http://kodos.sf.net/>`_
+      is a graphical regular expression debugger written in Python.
+
 
 .. _re-syntax:
 

Modified: python/branches/tlee-ast-optimize/Doc/library/rexec.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/rexec.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/rexec.rst	Thu May 15 00:25:06 2008
@@ -4,7 +4,10 @@
 
 .. module:: rexec
    :synopsis: Basic restricted execution framework.
-
+   :deprecated:
+   
+.. deprecated:: 2.6
+   The :mod:`rexec` module has been removed in Python 3.0.
 
 .. versionchanged:: 2.3
    Disabled module.

Modified: python/branches/tlee-ast-optimize/Doc/library/rlcompleter.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/rlcompleter.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/rlcompleter.rst	Thu May 15 00:25:06 2008
@@ -61,5 +61,6 @@
    If called for a dotted name, it will try to evaluate anything without obvious
    side-effects (functions will not be evaluated, but it can generate calls to
    :meth:`__getattr__`) up to the last part, and find matches for the rest via the
-   :func:`dir` function.
+   :func:`dir` function.  Any exception raised during the evaluation of the 
+   expression is caught, silenced and :const:`None` is returned.
 

Modified: python/branches/tlee-ast-optimize/Doc/library/simplexmlrpcserver.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/simplexmlrpcserver.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/simplexmlrpcserver.rst	Thu May 15 00:25:06 2008
@@ -22,7 +22,7 @@
    functions that can be called by the XML-RPC protocol.  The *requestHandler*
    parameter should be a factory for request handler instances; it defaults to
    :class:`SimpleXMLRPCRequestHandler`.  The *addr* and *requestHandler* parameters
-   are passed to the :class:`SocketServer.TCPServer` constructor.  If *logRequests*
+   are passed to the :class:`socketserver.TCPServer` constructor.  If *logRequests*
    is true (the default), requests will be logged; setting this parameter to false
    will turn off logging.   The *allow_none* and *encoding* parameters are passed
    on to  :mod:`xmlrpclib` and control the XML-RPC responses that will be returned
@@ -63,7 +63,7 @@
 --------------------------
 
 The :class:`SimpleXMLRPCServer` class is based on
-:class:`SocketServer.TCPServer` and provides a means of creating simple, stand
+:class:`socketserver.TCPServer` and provides a means of creating simple, stand
 alone XML-RPC servers.
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/smtplib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/smtplib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/smtplib.rst	Thu May 15 00:25:06 2008
@@ -19,13 +19,14 @@
 
 .. class:: SMTP([host[, port[, local_hostname[, timeout]]]])
 
-   A :class:`SMTP` instance encapsulates an SMTP connection.  It has methods that
-   support a full repertoire of SMTP and ESMTP operations. If the optional host and
-   port parameters are given, the SMTP :meth:`connect` method is called with those
-   parameters during initialization.  An :exc:`SMTPConnectError` is raised if the
-   specified host doesn't respond correctly. The optional *timeout* parameter
-   specifies a timeout in seconds for the connection attempt (if not specified, or
-   passed as None, the global default timeout setting will be used).
+   A :class:`SMTP` instance encapsulates an SMTP connection.  It has methods
+   that support a full repertoire of SMTP and ESMTP operations. If the optional
+   host and port parameters are given, the SMTP :meth:`connect` method is called
+   with those parameters during initialization.  An :exc:`SMTPConnectError` is
+   raised if the specified host doesn't respond correctly. The optional
+   *timeout* parameter specifies a timeout in seconds for blocking operations
+   like the connection attempt (if not specified, or passed as None, the global
+   default timeout setting will be used).
 
    For normal use, you should only require the initialization/connect,
    :meth:`sendmail`, and :meth:`quit` methods.  An example is included below.
@@ -38,13 +39,14 @@
 
    A :class:`SMTP_SSL` instance behaves exactly the same as instances of
    :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is
-   required from  the beginning of the connection and using :meth:`starttls` is not
-   appropriate. If *host* is not specified, the local host is used. If *port* is
-   omitted, the standard SMTP-over-SSL port (465) is used. *keyfile* and *certfile*
-   are also optional, and can contain a PEM formatted private key and certificate
-   chain file for the SSL connection. The optional *timeout* parameter specifies a
-   timeout in seconds for the connection attempt (if not specified, or passed as
-   None, the global default timeout setting will be used).
+   required from the beginning of the connection and using :meth:`starttls` is
+   not appropriate. If *host* is not specified, the local host is used. If
+   *port* is omitted, the standard SMTP-over-SSL port (465) is used. *keyfile*
+   and *certfile* are also optional, and can contain a PEM formatted private key
+   and certificate chain file for the SSL connection. The optional *timeout*
+   parameter specifies a timeout in seconds for blocking operations like the
+   connection attempt (if not specified, or passed as None, the global default
+   timeout setting will be used).
 
    .. versionchanged:: 2.6
       *timeout* was added.

Modified: python/branches/tlee-ast-optimize/Doc/library/socket.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/socket.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/socket.rst	Thu May 15 00:25:06 2008
@@ -225,9 +225,9 @@
    service name (like ``'http'``), a numeric port number or ``None``.
 
    The rest of the arguments are optional and must be numeric if specified.  For
-   *host* and *port*, by passing either an empty string or ``None``, you can pass
-   ``NULL`` to the C API.  The :func:`getaddrinfo` function returns a list of
-   5-tuples with the following structure:
+   *host* and *port*, by passing ``None``, you can pass ``NULL`` to the C API.
+   The :func:`getaddrinfo` function returns a list of 5-tuples with the following
+   structure:
 
    ``(family, socktype, proto, canonname, sockaddr)``
 
@@ -481,7 +481,7 @@
 
 .. seealso::
 
-   Module :mod:`SocketServer`
+   Module :mod:`socketserver`
       Classes that simplify writing network servers.
 
 
@@ -846,7 +846,7 @@
    import socket
    import sys
 
-   HOST = ''                 # Symbolic name meaning all available interfaces
+   HOST = None               # Symbolic name meaning all available interfaces
    PORT = 50007              # Arbitrary non-privileged port
    s = None
    for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
@@ -908,7 +908,7 @@
 
    
 The last example shows how to write a very simple network sniffer with raw
-sockets on Windows. The example requires administrator priviliges to modify
+sockets on Windows. The example requires administrator privileges to modify
 the interface::
 
    import socket

Modified: python/branches/tlee-ast-optimize/Doc/library/socketserver.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/socketserver.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/socketserver.rst	Thu May 15 00:25:06 2008
@@ -1,12 +1,19 @@
-
-:mod:`SocketServer` --- A framework for network servers
+:mod:`socketserver` --- A framework for network servers
 =======================================================
 
 .. module:: SocketServer
+   :synopsis: Old name for the socketserver module.
+
+.. module:: socketserver
    :synopsis: A framework for network servers.
 
+.. note::
+   The :mod:`SocketServer` module has been renamed to :mod:`socketserver` in
+   Python 3.0.  It is importable under both names in Python 2.6 and the rest of
+   the 2.x series.
+
 
-The :mod:`SocketServer` module simplifies the task of writing network servers.
+The :mod:`socketserver` module simplifies the task of writing network servers.
 
 There are four basic server classes: :class:`TCPServer` uses the Internet TCP
 protocol, which provides for continuous streams of data between the client and
@@ -156,7 +163,7 @@
 .. data:: address_family
 
    The family of protocols to which the server's socket belongs.
-   :const:`socket.AF_INET` and :const:`socket.AF_UNIX` are two possible values.
+   Common examples are :const:`socket.AF_INET` and :const:`socket.AF_UNIX`.
 
 
 .. data:: RequestHandlerClass
@@ -200,7 +207,7 @@
 .. data:: socket_type
 
    The type of socket used by the server; :const:`socket.SOCK_STREAM` and
-   :const:`socket.SOCK_DGRAM` are two possible values.
+   :const:`socket.SOCK_DGRAM` are two common values.
 
 .. data:: timeout
 
@@ -213,7 +220,7 @@
 users of the server object.
 
 .. XXX should the default implementations of these be documented, or should
-   it be assumed that the user will look at SocketServer.py?
+   it be assumed that the user will look at socketserver.py?
 
 
 .. function:: finish_request()

Modified: python/branches/tlee-ast-optimize/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/stdtypes.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/stdtypes.rst	Thu May 15 00:25:06 2008
@@ -406,8 +406,7 @@
 operations and higher than the comparisons; the unary operation ``~`` has the
 same priority as the other unary numeric operations (``+`` and ``-``).
 
-This table lists the bit-string operations sorted in ascending priority
-(operations in the same box have the same priority):
+This table lists the bit-string operations sorted in ascending priority:
 
 +------------+--------------------------------+----------+
 | Operation  | Result                         | Notes    |
@@ -440,12 +439,11 @@
    Negative shift counts are illegal and cause a :exc:`ValueError` to be raised.
 
 (2)
-   A left shift by *n* bits is equivalent to multiplication by ``pow(2, n)``
-   without overflow check.
+   A left shift by *n* bits is equivalent to multiplication by ``pow(2, n)``.  A
+   long integer is returned if the result exceeds the range of plain integers.
 
 (3)
-   A right shift by *n* bits is equivalent to division by ``pow(2, n)`` without
-   overflow check.
+   A right shift by *n* bits is equivalent to division by ``pow(2, n)``.
 
 
 .. _typeiter:
@@ -785,6 +783,28 @@
    found.
 
 
+.. method:: str.format(format_string, *args, **kwargs)
+
+   Perform a string formatting operation.  The *format_string* argument can
+   contain literal text or replacement fields delimited by braces ``{}``.  Each
+   replacement field contains either the numeric index of a positional argument,
+   or the name of a keyword argument.  Returns a copy of *format_string* where
+   each replacement field is replaced with the string value of the corresponding
+   argument.
+
+      >>> "The sum of 1 + 2 is {0}".format(1+2)
+      'The sum of 1 + 2 is 3'
+
+   See :ref:`formatstrings` for a description of the various formatting options
+   that can be specified in format strings.
+
+   This method of string formatting is the new standard in Python 3.0, and
+   should be preferred to the ``%`` formatting described in
+   :ref:`string-formatting` in new code.
+
+   .. versionadded:: 2.6
+
+
 .. method:: str.index(sub[, start[, end]])
 
    Like :meth:`find`, but raise :exc:`ValueError` when the substring is not found.
@@ -1185,7 +1205,7 @@
 +---------+---------------------------------------------------------------------+
 
 A length modifier (``h``, ``l``, or ``L``) may be present, but is ignored as it
-is not necessary for Python.
+is not necessary for Python -- so e.g. ``%ld`` is identical to ``%d``.
 
 The conversion types are:
 
@@ -1196,13 +1216,13 @@
 +------------+-----------------------------------------------------+-------+
 | ``'i'``    | Signed integer decimal.                             |       |
 +------------+-----------------------------------------------------+-------+
-| ``'o'``    | Unsigned octal.                                     | \(1)  |
+| ``'o'``    | Signed octal value.                                 | \(1)  |
 +------------+-----------------------------------------------------+-------+
-| ``'u'``    | Unsigned decimal.                                   |       |
+| ``'u'``    | Obselete type -- it is identical to ``'d'``.        | \(7)  |
 +------------+-----------------------------------------------------+-------+
-| ``'x'``    | Unsigned hexadecimal (lowercase).                   | \(2)  |
+| ``'x'``    | Signed hexadecimal (lowercase).                     | \(2)  |
 +------------+-----------------------------------------------------+-------+
-| ``'X'``    | Unsigned hexadecimal (uppercase).                   | \(2)  |
+| ``'X'``    | Signed hexadecimal (uppercase).                     | \(2)  |
 +------------+-----------------------------------------------------+-------+
 | ``'e'``    | Floating point exponential format (lowercase).      | \(3)  |
 +------------+-----------------------------------------------------+-------+
@@ -1271,6 +1291,9 @@
 
    The precision determines the maximal number of characters used.
 
+(7)
+   See :pep:`237`.
+
 Since Python strings have an explicit length, ``%s`` conversions do not assume
 that ``'\0'`` is the end of the string.
 
@@ -1502,158 +1525,162 @@
    sets, the inner sets must be :class:`frozenset` objects.  If *iterable* is
    not specified, a new empty set is returned.
 
-Instances of :class:`set` and :class:`frozenset` provide the following
-operations:
+   Instances of :class:`set` and :class:`frozenset` provide the following
+   operations:
 
-.. describe:: len(s)
+   .. describe:: len(s)
 
-   Return the cardinality of set *s*.
+      Return the cardinality of set *s*.
 
-.. describe:: x in s
+   .. describe:: x in s
 
-   Test *x* for membership in *s*.
+      Test *x* for membership in *s*.
 
-.. describe:: x not in s
+   .. describe:: x not in s
 
-   Test *x* for non-membership in *s*.
+      Test *x* for non-membership in *s*.
 
-.. method:: set.isdisjoint(other)
+   .. method:: isdisjoint(other)
 
-   Return True if the set has no elements in common with *other*.
-   Sets are disjoint if and only if their interesection is the empty set.
+      Return True if the set has no elements in common with *other*.  Sets are
+      disjoint if and only if their interesection is the empty set.
 
-   .. versionadded:: 2.6
+      .. versionadded:: 2.6
 
-.. method:: set.issubset(other)
-            set <= other
+   .. method:: issubset(other)
+               set <= other
 
-   Test whether every element in the set is in *other*.
+      Test whether every element in the set is in *other*.
 
-.. method:: set < other
+   .. method:: set < other
 
-   Test whether the set is a true subset of *other*, that is,
-   ``set <= other and set != other``.
+      Test whether the set is a true subset of *other*, that is,
+      ``set <= other and set != other``.
 
-.. method:: set.issuperset(other)
-            set >= other
+   .. method:: issuperset(other)
+               set >= other
 
-   Test whether every element in *other* is in the set.
+      Test whether every element in *other* is in the set.
 
-.. method:: set > other
+   .. method:: set > other
 
-   Test whether the set is a true superset of *other*, that is,
-   ``set >= other and set != other``.
+      Test whether the set is a true superset of *other*, that is, ``set >=
+      other and set != other``.
 
-.. method:: set.union(other)
-            set | other
+   .. method:: union(other)
+               set | other
 
-   Return a new set with elements from both sets.
+      Return a new set with elements from both sets.
 
-.. method:: set.intersection(other)
-            set & other
+   .. method:: intersection(other)
+               set & other
 
-   Return a new set with elements common to both sets.
+      Return a new set with elements common to both sets.
 
-.. method:: set.difference(other)
-            set - other
+   .. method:: difference(other)
+               set - other
 
-   Return a new set with elements in the set that are not in *other*.
+      Return a new set with elements in the set that are not in *other*.
 
-.. method:: set.symmetric_difference(other)
-            set ^ other
+   .. method:: symmetric_difference(other)
+               set ^ other
 
-   Return a new set with elements in either the set or *other* but not both.
+      Return a new set with elements in either the set or *other* but not both.
 
-.. method:: set.copy()
+   .. method:: copy()
 
-   Return a new set with a shallow copy of *s*.
+      Return a new set with a shallow copy of *s*.
 
 
-Note, the non-operator versions of :meth:`union`, :meth:`intersection`,
-:meth:`difference`, and :meth:`symmetric_difference`, :meth:`issubset`, and
-:meth:`issuperset` methods will accept any iterable as an argument.  In
-contrast, their operator based counterparts require their arguments to be sets.
-This precludes error-prone constructions like ``set('abc') & 'cbs'`` in favor of
-the more readable ``set('abc').intersection('cbs')``.
+   Note, the non-operator versions of :meth:`union`, :meth:`intersection`,
+   :meth:`difference`, and :meth:`symmetric_difference`, :meth:`issubset`, and
+   :meth:`issuperset` methods will accept any iterable as an argument.  In
+   contrast, their operator based counterparts require their arguments to be
+   sets.  This precludes error-prone constructions like ``set('abc') & 'cbs'``
+   in favor of the more readable ``set('abc').intersection('cbs')``.
 
-Both :class:`set` and :class:`frozenset` support set to set comparisons. Two
-sets are equal if and only if every element of each set is contained in the
-other (each is a subset of the other). A set is less than another set if and
-only if the first set is a proper subset of the second set (is a subset, but is
-not equal). A set is greater than another set if and only if the first set is a
-proper superset of the second set (is a superset, but is not equal).
+   Both :class:`set` and :class:`frozenset` support set to set comparisons. Two
+   sets are equal if and only if every element of each set is contained in the
+   other (each is a subset of the other). A set is less than another set if and
+   only if the first set is a proper subset of the second set (is a subset, but
+   is not equal). A set is greater than another set if and only if the first set
+   is a proper superset of the second set (is a superset, but is not equal).
 
-Instances of :class:`set` are compared to instances of :class:`frozenset` based
-on their members.  For example, ``set('abc') == frozenset('abc')`` returns
-``True``.
+   Instances of :class:`set` are compared to instances of :class:`frozenset`
+   based on their members.  For example, ``set('abc') == frozenset('abc')``
+   returns ``True`` and so does ``set('abc') in set([frozenset('abc')])``.
 
-The subset and equality comparisons do not generalize to a complete ordering
-function.  For example, any two disjoint sets are not equal and are not subsets
-of each other, so *all* of the following return ``False``:  ``a<b``, ``a==b``,
-or ``a>b``. Accordingly, sets do not implement the :meth:`__cmp__` method.
+   The subset and equality comparisons do not generalize to a complete ordering
+   function.  For example, any two disjoint sets are not equal and are not
+   subsets of each other, so *all* of the following return ``False``: ``a<b``,
+   ``a==b``, or ``a>b``. Accordingly, sets do not implement the :meth:`__cmp__`
+   method.
 
-Since sets only define partial ordering (subset relationships), the output of
-the :meth:`list.sort` method is undefined for lists of sets.
+   Since sets only define partial ordering (subset relationships), the output of
+   the :meth:`list.sort` method is undefined for lists of sets.
 
-Set elements, like dictionary keys, must be :term:`hashable`.
+   Set elements, like dictionary keys, must be :term:`hashable`.
 
-Binary operations that mix :class:`set` instances with :class:`frozenset` return
-the type of the first operand.  For example: ``frozenset('ab') | set('bc')``
-returns an instance of :class:`frozenset`.
+   Binary operations that mix :class:`set` instances with :class:`frozenset`
+   return the type of the first operand.  For example: ``frozenset('ab') |
+   set('bc')`` returns an instance of :class:`frozenset`.
 
-The following table lists operations available for :class:`set` that do not
-apply to immutable instances of :class:`frozenset`:
+   The following table lists operations available for :class:`set` that do not
+   apply to immutable instances of :class:`frozenset`:
 
-.. method:: set.update(other)
-            set |= other
+   .. method:: update(other)
+               set |= other
 
-   Update the set, adding elements from *other*.
+      Update the set, adding elements from *other*.
 
-.. method:: set.intersection_update(other)
-            set &= other
+   .. method:: intersection_update(other)
+               set &= other
 
-   Update the set, keeping only elements found in it and *other*.
+      Update the set, keeping only elements found in it and *other*.
 
-.. method:: set.difference_update(other)
-            set -= other
+   .. method:: difference_update(other)
+               set -= other
 
-   Update the set, removing elements found in *other*.
+      Update the set, removing elements found in *other*.
 
-.. method:: set.symmetric_difference_update(other)
-            set ^= other
+   .. method:: symmetric_difference_update(other)
+               set ^= other
 
-   Update the set, keeping only elements found in either set, but not in both.
+      Update the set, keeping only elements found in either set, but not in both.
 
-.. method:: set.add(el)
+   .. method:: add(elem)
 
-   Add element *el* to the set.
+      Add element *elem* to the set.
 
-.. method:: set.remove(el)
+   .. method:: remove(elem)
 
-   Remove element *el* from the set.  Raises :exc:`KeyError` if *el* is not
-   contained in the set.
+      Remove element *elem* from the set.  Raises :exc:`KeyError` if *elem* is
+      not contained in the set.
 
-.. method:: set.discard(el)
+   .. method:: discard(elem)
 
-   Remove element *el* from the set if it is present.
+      Remove element *elem* from the set if it is present.
 
-.. method:: set.pop()
+   .. method:: pop()
 
-   Remove and return an arbitrary element from the set.  Raises :exc:`KeyError`
-   if the set is empty.
+      Remove and return an arbitrary element from the set.  Raises
+      :exc:`KeyError` if the set is empty.
 
-.. method:: set.clear()
+   .. method:: clear()
 
-   Remove all elements from the set.
+      Remove all elements from the set.
 
 
-Note, the non-operator versions of the :meth:`update`,
-:meth:`intersection_update`, :meth:`difference_update`, and
-:meth:`symmetric_difference_update` methods will accept any iterable as an
-argument.
+   Note, the non-operator versions of the :meth:`update`,
+   :meth:`intersection_update`, :meth:`difference_update`, and
+   :meth:`symmetric_difference_update` methods will accept any iterable as an
+   argument.
 
-The design of the set types was based on lessons learned from the Python
-implementation found in the :mod:`sets` module.
+   Note, the *elem* argument to the :meth:`__contains__`, :meth:`remove`, and
+   :meth:`discard` methods may be a set.  To support searching for an equivalent
+   frozenset, the *elem* set is temporarily mutated during the search and then
+   restored.  During the search, the *elem* set should not be read or mutated
+   since it does not have a meaningful value.
 
 
 .. seealso::
@@ -1730,159 +1757,162 @@
       Support for building a dictionary from keyword arguments added.
 
 
-These are the operations that dictionaries support (and therefore, custom mapping
-types should support too):
+   These are the operations that dictionaries support (and therefore, custom
+   mapping types should support too):
 
-.. describe:: len(d)
+   .. describe:: len(d)
 
-   Return the number of items in the dictionary *d*.
+      Return the number of items in the dictionary *d*.
 
-.. describe:: d[key]
+   .. describe:: d[key]
 
-   Return the item of *d* with key *key*.  Raises a :exc:`KeyError` if *key* is
-   not in the map.
-   
-   .. versionadded:: 2.5
-      If a subclass of dict defines a method :meth:`__missing__`, if the key
-      *key* is not present, the ``d[key]`` operation calls that method with the
-      key *key* as argument.  The ``d[key]`` operation then returns or raises
-      whatever is returned or raised by the ``__missing__(key)`` call if the key
-      is not present. No other operations or methods invoke
-      :meth:`__missing__`. If :meth:`__missing__` is not defined,
-      :exc:`KeyError` is raised.  :meth:`__missing__` must be a method; it
-      cannot be an instance variable. For an example, see
-      :class:`collections.defaultdict`.
+      Return the item of *d* with key *key*.  Raises a :exc:`KeyError` if *key*
+      is not in the map.
 
-.. describe:: d[key] = value
+      .. versionadded:: 2.5 
+         If a subclass of dict defines a method :meth:`__missing__`, if the key
+         *key* is not present, the ``d[key]`` operation calls that method with
+         the key *key* as argument.  The ``d[key]`` operation then returns or
+         raises whatever is returned or raised by the ``__missing__(key)`` call
+         if the key is not present. No other operations or methods invoke
+         :meth:`__missing__`. If :meth:`__missing__` is not defined,
+         :exc:`KeyError` is raised.  :meth:`__missing__` must be a method; it
+         cannot be an instance variable. For an example, see
+         :class:`collections.defaultdict`.
 
-   Set ``d[key]`` to *value*.
+   .. describe:: d[key] = value
 
-.. describe:: del d[key]
+      Set ``d[key]`` to *value*.
 
-   Remove ``d[key]`` from *d*.  Raises a :exc:`KeyError` if *key* is not in the
-   map.
+   .. describe:: del d[key]
 
-.. describe:: key in d
+      Remove ``d[key]`` from *d*.  Raises a :exc:`KeyError` if *key* is not in the
+      map.
 
-   Return ``True`` if *d* has a key *key*, else ``False``.
+   .. describe:: key in d
 
-   .. versionadded:: 2.2
+      Return ``True`` if *d* has a key *key*, else ``False``.
 
-.. describe:: key not in d
+      .. versionadded:: 2.2
 
-   Equivalent to ``not key in d``.
+   .. describe:: key not in d
 
-   .. versionadded:: 2.2
+      Equivalent to ``not key in d``.
 
-.. method:: dict.clear()
+      .. versionadded:: 2.2
 
-   Remove all items from the dictionary.
+   .. method:: clear()
 
-.. method:: dict.copy()
+      Remove all items from the dictionary.
 
-   Return a shallow copy of the dictionary.
+   .. method:: copy()
 
-.. method:: dict.fromkeys(seq[, value])
+      Return a shallow copy of the dictionary.
 
-   Create a new dictionary with keys from *seq* and values set to *value*.
+   .. method:: fromkeys(seq[, value])
 
-   :func:`fromkeys` is a class method that returns a new dictionary. *value*
-   defaults to ``None``.
+      Create a new dictionary with keys from *seq* and values set to *value*.
 
-   .. versionadded:: 2.3
+      :func:`fromkeys` is a class method that returns a new dictionary. *value*
+      defaults to ``None``.
 
-.. method:: dict.get(key[, default])
+      .. versionadded:: 2.3
 
-   Return the value for *key* if *key* is in the dictionary, else *default*.  If
-   *default* is not given, it defaults to ``None``, so that this method never
-   raises a :exc:`KeyError`.
+   .. method:: get(key[, default])
 
-.. method:: dict.has_key(key)
+      Return the value for *key* if *key* is in the dictionary, else *default*.
+      If *default* is not given, it defaults to ``None``, so that this method
+      never raises a :exc:`KeyError`.
 
-   ``d.has_key(key)`` is equivalent to ``key in d``, but deprecated.
+   .. method:: has_key(key)
 
-.. method:: dict.items()
+      ``dict.has_key(key)`` is equivalent to ``key in d``, but deprecated.
 
-   Return a copy of the dictionary's list of ``(key, value)`` pairs.
+   .. method:: items()
 
-   .. note::
+      Return a copy of the dictionary's list of ``(key, value)`` pairs.
 
-      Keys and values are listed in an arbitrary order which is non-random, varies
-      across Python implementations, and depends on the dictionary's history of
-      insertions and deletions. If :meth:`items`, :meth:`keys`, :meth:`values`,
-      :meth:`iteritems`, :meth:`iterkeys`, and :meth:`itervalues` are called with no
-      intervening modifications to the dictionary, the lists will directly correspond.
-      This allows the creation of ``(value, key)`` pairs using :func:`zip`: ``pairs =
-      zip(d.values(), d.keys())``.  The same relationship holds for the
-      :meth:`iterkeys` and :meth:`itervalues` methods: ``pairs = zip(d.itervalues(),
-      d.iterkeys())`` provides the same value for ``pairs``. Another way to create the
-      same list is ``pairs = [(v, k) for (k, v) in d.iteritems()]``.
+      .. note::
 
-.. method:: dict.iteritems()
+         Keys and values are listed in an arbitrary order which is non-random,
+         varies across Python implementations, and depends on the dictionary's
+         history of insertions and deletions. If :meth:`items`, :meth:`keys`,
+         :meth:`values`, :meth:`iteritems`, :meth:`iterkeys`, and
+         :meth:`itervalues` are called with no intervening modifications to the
+         dictionary, the lists will directly correspond.  This allows the
+         creation of ``(value, key)`` pairs using :func:`zip`: ``pairs =
+         zip(d.values(), d.keys())``.  The same relationship holds for the
+         :meth:`iterkeys` and :meth:`itervalues` methods: ``pairs =
+         zip(d.itervalues(), d.iterkeys())`` provides the same value for
+         ``pairs``. Another way to create the same list is ``pairs = [(v, k) for
+         (k, v) in d.iteritems()]``.
 
-   Return an iterator over the dictionary's ``(key, value)`` pairs.
-   See the note for :meth:`dict.items`.
+   .. method:: iteritems()
 
-   .. versionadded:: 2.2
+      Return an iterator over the dictionary's ``(key, value)`` pairs.  See the
+      note for :meth:`dict.items`.
 
-.. method:: dict.iterkeys()
+      .. versionadded:: 2.2
 
-   Return an iterator over the dictionary's keys.  See the note for
-   :meth:`dict.items`.
+   .. method:: iterkeys()
 
-   .. versionadded:: 2.2
+      Return an iterator over the dictionary's keys.  See the note for
+      :meth:`dict.items`.
 
-.. method:: dict.itervalues()
+      .. versionadded:: 2.2
 
-   Return an iterator over the dictionary's values.  See the note for
-   :meth:`dict.items`.
+   .. method:: itervalues()
 
-   .. versionadded:: 2.2
+      Return an iterator over the dictionary's values.  See the note for
+      :meth:`dict.items`.
 
-.. method:: dict.keys()
+      .. versionadded:: 2.2
 
-   Return a copy of the dictionary's list of keys.  See the note for
-   :meth:`dict.items`.
+   .. method:: keys()
 
-.. method:: dict.pop(key[, default])
+      Return a copy of the dictionary's list of keys.  See the note for
+      :meth:`dict.items`.
 
-   If *key* is in the dictionary, remove it and return its value, else return
-   *default*.  If *default* is not given and *key* is not in the dictionary, a
-   :exc:`KeyError` is raised.
+   .. method:: pop(key[, default])
 
-   .. versionadded:: 2.3
+      If *key* is in the dictionary, remove it and return its value, else return
+      *default*.  If *default* is not given and *key* is not in the dictionary,
+      a :exc:`KeyError` is raised.
 
-.. method:: dict.popitem()
+      .. versionadded:: 2.3
 
-   Remove and return an arbitrary ``(key, value)`` pair from the dictionary.
+   .. method:: popitem()
 
-   :func:`popitem` is useful to destructively iterate over a dictionary, as
-   often used in set algorithms.  If the dictionary is empty, calling
-   :func:`popitem` raises a :exc:`KeyError`.
+      Remove and return an arbitrary ``(key, value)`` pair from the dictionary.
 
-.. method:: dict.setdefault(key[, default])
+      :func:`popitem` is useful to destructively iterate over a dictionary, as
+      often used in set algorithms.  If the dictionary is empty, calling
+      :func:`popitem` raises a :exc:`KeyError`.
 
-   If *key* is in the dictionary, return its value.  If not, insert *key* with a
-   value of *default* and return *default*.  *default* defaults to ``None``.
+   .. method:: setdefault(key[, default])
 
-.. method:: dict.update([other])
+      If *key* is in the dictionary, return its value.  If not, insert *key*
+      with a value of *default* and return *default*.  *default* defaults to
+      ``None``.
 
-   Update the dictionary with the key/value pairs from *other*, overwriting existing
-   keys.  Return ``None``.
+   .. method:: update([other])
 
-   :func:`update` accepts either another dictionary object or an iterable of
-   key/value pairs (as a tuple or other iterable of length two).  If keyword
-   arguments are specified, the dictionary is then is updated with those
-   key/value pairs: ``d.update(red=1, blue=2)``.
+      Update the dictionary with the key/value pairs from *other*, overwriting
+      existing keys.  Return ``None``.
 
-   .. versionchanged:: 2.4
-      Allowed the argument to be an iterable of key/value pairs and allowed
-      keyword arguments.
+      :func:`update` accepts either another dictionary object or an iterable of
+      key/value pairs (as a tuple or other iterable of length two).  If keyword
+      arguments are specified, the dictionary is then is updated with those
+      key/value pairs: ``d.update(red=1, blue=2)``.
+
+      .. versionchanged:: 2.4
+          Allowed the argument to be an iterable of key/value pairs and allowed
+          keyword arguments.
 
-.. method:: dict.values()
+   .. method:: values()
 
-   Return a copy of the dictionary's list of values.  See the note for
-   :meth:`dict.items`.
+      Return a copy of the dictionary's list of values.  See the note for
+      :meth:`dict.items`.
 
 
 .. _bltin-file-objects:

Modified: python/branches/tlee-ast-optimize/Doc/library/string.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/string.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/string.rst	Thu May 15 00:25:06 2008
@@ -1,4 +1,3 @@
-
 :mod:`string` --- Common string operations
 ==========================================
 
@@ -104,6 +103,354 @@
    :func:`strip` and :func:`split` is undefined.
 
 
+.. _string-formatting:
+
+String Formatting
+-----------------
+
+Starting in Python 2.6, the built-in str and unicode classes provide the ability
+to do complex variable substitutions and value formatting via the :func:`format`
+method described in :pep:`3101`.  The :class:`Formatter` class in the
+:mod:`string` module allows you to create and customize your own string
+formatting behaviors using the same implementation as the built-in
+:meth:`format` method.
+
+.. class:: Formatter
+
+   The :class:`Formatter` class has the following public methods:
+
+   .. method:: format(format_string, *args, *kwargs)
+
+      :meth:`format` is the primary API method.  It takes a format template
+      string, and an arbitrary set of positional and keyword argument.
+      :meth:`format` is just a wrapper that calls :meth:`vformat`.
+
+   .. method:: vformat(format_string, args, kwargs)
+   
+      This function does the actual work of formatting.  It is exposed as a
+      separate function for cases where you want to pass in a predefined
+      dictionary of arguments, rather than unpacking and repacking the
+      dictionary as individual arguments using the ``*args`` and ``**kwds``
+      syntax.  :meth:`vformat` does the work of breaking up the format template
+      string into character data and replacement fields.  It calls the various
+      methods described below.
+
+   In addition, the :class:`Formatter` defines a number of methods that are
+   intended to be replaced by subclasses:
+
+   .. method:: parse(format_string)
+   
+      Loop over the format_string and return an iterable of tuples
+      (*literal_text*, *field_name*, *format_spec*, *conversion*).  This is used
+      by :meth:`vformat` to break the string in to either literal text, or
+      replacement fields.
+      
+      The values in the tuple conceptually represent a span of literal text
+      followed by a single replacement field.  If there is no literal text
+      (which can happen if two replacement fields occur consecutively), then
+      *literal_text* will be a zero-length string.  If there is no replacement
+      field, then the values of *field_name*, *format_spec* and *conversion*
+      will be ``None``.
+
+   .. method:: get_field(field_name, args, kwargs)
+
+      Given *field_name* as returned by :meth:`parse` (see above), convert it to
+      an object to be formatted.  Returns a tuple (obj, used_key).  The default
+      version takes strings of the form defined in :pep:`3101`, such as
+      "0[name]" or "label.title".  *args* and *kwargs* are as passed in to
+      :meth:`vformat`.  The return value *used_key* has the same meaning as the
+      *key* parameter to :meth:`get_value`.
+
+   .. method:: get_value(key, args, kwargs)
+   
+      Retrieve a given field value.  The *key* argument will be either an
+      integer or a string.  If it is an integer, it represents the index of the
+      positional argument in *args*; if it is a string, then it represents a
+      named argument in *kwargs*.
+
+      The *args* parameter is set to the list of positional arguments to
+      :meth:`vformat`, and the *kwargs* parameter is set to the dictionary of
+      keyword arguments.
+
+      For compound field names, these functions are only called for the first
+      component of the field name; Subsequent components are handled through
+      normal attribute and indexing operations.
+
+      So for example, the field expression '0.name' would cause
+      :meth:`get_value` to be called with a *key* argument of 0.  The ``name``
+      attribute will be looked up after :meth:`get_value` returns by calling the
+      built-in :func:`getattr` function.
+
+      If the index or keyword refers to an item that does not exist, then an
+      :exc:`IndexError` or :exc:`KeyError` should be raised.
+
+   .. method:: check_unused_args(used_args, args, kwargs)
+
+      Implement checking for unused arguments if desired.  The arguments to this
+      function is the set of all argument keys that were actually referred to in
+      the format string (integers for positional arguments, and strings for
+      named arguments), and a reference to the *args* and *kwargs* that was
+      passed to vformat.  The set of unused args can be calculated from these
+      parameters.  :meth:`check_unused_args` is assumed to throw an exception if
+      the check fails.
+
+   .. method:: format_field(value, format_spec)
+
+      :meth:`format_field` simply calls the global :func:`format` built-in.  The
+      method is provided so that subclasses can override it.
+
+   .. method:: convert_field(value, conversion)
+   
+      Converts the value (returned by :meth:`get_field`) given a conversion type
+      (as in the tuple returned by the :meth:`parse` method.)  The default
+      version understands 'r' (repr) and 's' (str) conversion types.
+
+
+.. _formatstrings:
+
+Format String Syntax
+--------------------
+
+The :meth:`str.format` method and the :class:`Formatter` class share the same
+syntax for format strings (although in the case of :class:`Formatter`,
+subclasses can define their own format string syntax.)
+
+Format strings contain "replacement fields" surrounded by curly braces ``{}``.
+Anything that is not contained in braces is considered literal text, which is
+copied unchanged to the output.  If you need to include a brace character in the
+literal text, it can be escaped by doubling: ``{{`` and ``}}``.
+
+The grammar for a replacement field is as follows:
+
+   .. productionlist:: sf
+      replacement_field: "{" `field_name` ["!" `conversion`] [":" `format_spec`] "}"
+      field_name: (`identifier` | `integer`) ("." `attribute_name` | "[" element_index "]")*
+      attribute_name: `identifier`
+      element_index: `integer`
+      conversion: "r" | "s"
+      format_spec: <described in the next section>
+      
+In less formal terms, the replacement field starts with a *field_name*, which
+can either be a number (for a positional argument), or an identifier (for
+keyword arguments).  Following this is an optional *conversion* field, which is
+preceded by an exclamation point ``'!'``, and a *format_spec*, which is preceded
+by a colon ``':'``.
+
+The *field_name* itself begins with either a number or a keyword.  If it's a
+number, it refers to a positional argument, and if it's a keyword it refers to a
+named keyword argument.  This can be followed by any number of index or
+attribute expressions. An expression of the form ``'.name'`` selects the named
+attribute using :func:`getattr`, while an expression of the form ``'[index]'``
+does an index lookup using :func:`__getitem__`.
+
+Some simple format string examples::
+
+   "First, thou shalt count to {0}" # References first positional argument
+   "My quest is {name}"             # References keyword argument 'name'
+   "Weight in tons {0.weight}"      # 'weight' attribute of first positional arg
+   "Units destroyed: {players[0]}"  # First element of keyword argument 'players'.
+   
+The *conversion* field causes a type coercion before formatting.  Normally, the
+job of formatting a value is done by the :meth:`__format__` method of the value
+itself.  However, in some cases it is desirable to force a type to be formatted
+as a string, overriding its own definition of formatting.  By converting the
+value to a string before calling :meth:`__format__`, the normal formatting logic
+is bypassed.
+
+Two conversion flags are currently supported: ``'!s'`` which calls :func:`str`
+on the value, and ``'!r'`` which calls :func:`repr`.
+
+Some examples::
+
+   "Harold's a clever {0!s}"        # Calls str() on the argument first
+   "Bring out the holy {name!r}"    # Calls repr() on the argument first
+
+The *format_spec* field contains a specification of how the value should be
+presented, including such details as field width, alignment, padding, decimal
+precision and so on.  Each value type can define it's own "formatting
+mini-language" or interpretation of the *format_spec*.
+
+Most built-in types support a common formatting mini-language, which is
+described in the next section.
+
+A *format_spec* field can also include nested replacement fields within it.
+These nested replacement fields can contain only a field name; conversion flags
+and format specifications are not allowed.  The replacement fields within the
+format_spec are substituted before the *format_spec* string is interpreted.
+This allows the formatting of a value to be dynamically specified.
+
+For example, suppose you wanted to have a replacement field whose field width is
+determined by another variable::
+
+   "A man with two {0:{1}}".format("noses", 10)
+
+This would first evaluate the inner replacement field, making the format string
+effectively::
+
+   "A man with two {0:10}"
+
+Then the outer replacement field would be evaluated, producing::
+
+   "noses     "
+   
+Which is subsitituted into the string, yielding::
+   
+   "A man with two noses     "
+   
+(The extra space is because we specified a field width of 10, and because left
+alignment is the default for strings.)
+
+
+.. _formatspec:
+
+Format Specification Mini-Language
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+"Format specifications" are used within replacement fields contained within a
+format string to define how individual values are presented (see
+:ref:`formatstrings`.)  They can also be passed directly to the builtin
+:func:`format` function.  Each formattable type may define how the format
+specification is to be interpreted.
+
+Most built-in types implement the following options for format specifications,
+although some of the formatting options are only supported by the numeric types.
+
+A general convention is that an empty format string (``""``) produces the same
+result as if you had called :func:`str` on the value.
+
+The general form of a *standard format specifier* is:
+
+.. productionlist:: sf
+   format_spec: [[`fill`]`align`][`sign`][0][`width`][.`precision`][`type`]
+   fill: <a character other than '}'>
+   align: "<" | ">" | "=" | "^"
+   sign: "+" | "-" | " "
+   width: `integer`
+   precision: `integer`
+   type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "x" | "X" | "%"
+   
+The *fill* character can be any character other than '}' (which signifies the
+end of the field).  The presence of a fill character is signaled by the *next*
+character, which must be one of the alignment options. If the second character
+of *format_spec* is not a valid alignment option, then it is assumed that both
+the fill character and the alignment option are absent.
+
+The meaning of the various alignment options is as follows:
+
+   +---------+----------------------------------------------------------+
+   | Option  | Meaning                                                  |
+   +=========+==========================================================+
+   | ``'<'`` | Forces the field to be left-aligned within the available |
+   |         | space (This is the default.)                             |
+   +---------+----------------------------------------------------------+
+   | ``'>'`` | Forces the field to be right-aligned within the          |
+   |         | available space.                                         |
+   +---------+----------------------------------------------------------+
+   | ``'='`` | Forces the padding to be placed after the sign (if any)  |
+   |         | but before the digits.  This is used for printing fields |
+   |         | in the form '+000000120'. This alignment option is only  |
+   |         | valid for numeric types.                                 |
+   +---------+----------------------------------------------------------+
+   | ``'^'`` | Forces the field to be centered within the available     |
+   |         | space.                                                   |
+   +---------+----------------------------------------------------------+
+
+Note that unless a minimum field width is defined, the field width will always
+be the same size as the data to fill it, so that the alignment option has no
+meaning in this case.
+
+The *sign* option is only valid for number types, and can be one of the
+following:
+
+   +---------+----------------------------------------------------------+
+   | Option  | Meaning                                                  |
+   +=========+==========================================================+
+   | ``'+'`` | indicates that a sign should be used for both            |
+   |         | positive as well as negative numbers.                    |
+   +---------+----------------------------------------------------------+
+   | ``'-'`` | indicates that a sign should be used only for negative   |
+   |         | numbers (this is the default behavior).                  |
+   +---------+----------------------------------------------------------+
+   | space   | indicates that a leading space should be used on         |
+   |         | positive numbers, and a minus sign on negative numbers.  |
+   +---------+----------------------------------------------------------+
+
+*width* is a decimal integer defining the minimum field width.  If not
+specified, then the field width will be determined by the content.
+
+If the *width* field is preceded by a zero (``'0'``) character, this enables
+zero-padding.  This is equivalent to an *alignment* type of ``'='`` and a *fill*
+character of ``'0'``.
+
+The *precision* is a decimal number indicating how many digits should be
+displayed after the decimal point for a floating point value.  For non-number
+types the field indicates the maximum field size - in other words, how many
+characters will be used from the field content. The *precision* is ignored for
+integer values.
+
+Finally, the *type* determines how the data should be presented.
+
+The available integer presentation types are:
+
+   +---------+----------------------------------------------------------+
+   | Type    | Meaning                                                  |
+   +=========+==========================================================+
+   | ``'b'`` | Binary. Outputs the number in base 2.                    |
+   +---------+----------------------------------------------------------+
+   | ``'c'`` | Character. Converts the integer to the corresponding     |
+   |         | unicode character before printing.                       |
+   +---------+----------------------------------------------------------+
+   | ``'d'`` | Decimal Integer. Outputs the number in base 10.          |
+   +---------+----------------------------------------------------------+
+   | ``'o'`` | Octal format. Outputs the number in base 8.              |
+   +---------+----------------------------------------------------------+
+   | ``'x'`` | Hex format. Outputs the number in base 16, using lower-  |
+   |         | case letters for the digits above 9.                     |
+   +---------+----------------------------------------------------------+
+   | ``'X'`` | Hex format. Outputs the number in base 16, using upper-  |
+   |         | case letters for the digits above 9.                     |
+   +---------+----------------------------------------------------------+
+   | ``'n'`` | Number. This is the same as ``'d'``, except that it uses |
+   |         | the current locale setting to insert the appropriate     |
+   |         | number separator characters.                             |
+   +---------+----------------------------------------------------------+
+   | None    | the same as ``'d'``                                      |
+   +---------+----------------------------------------------------------+
+                                                                         
+The available presentation types for floating point and decimal values are:
+                                                                         
+   +---------+----------------------------------------------------------+
+   | Type    | Meaning                                                  |
+   +=========+==========================================================+
+   | ``'e'`` | Exponent notation. Prints the number in scientific       |
+   |         | notation using the letter 'e' to indicate the exponent.  |
+   +---------+----------------------------------------------------------+
+   | ``'E'`` | Exponent notation. Same as ``'e'`` except it uses an     |
+   |         | upper case 'E' as the separator character.               |
+   +---------+----------------------------------------------------------+
+   | ``'f'`` | Fixed point. Displays the number as a fixed-point        |
+   |         | number.                                                  |
+   +---------+----------------------------------------------------------+
+   | ``'F'`` | Fixed point. Same as ``'f'``.                            |
+   +---------+----------------------------------------------------------+
+   | ``'g'`` | General format. This prints the number as a fixed-point  |
+   |         | number, unless the number is too large, in which case    |
+   |         | it switches to ``'e'`` exponent notation.                |
+   +---------+----------------------------------------------------------+
+   | ``'G'`` | General format. Same as ``'g'`` except switches to       |
+   |         | ``'E'`` if the number gets to large.                     |
+   +---------+----------------------------------------------------------+
+   | ``'n'`` | Number. This is the same as ``'g'``, except that it uses |
+   |         | the current locale setting to insert the appropriate     |
+   |         | number separator characters.                             |
+   +---------+----------------------------------------------------------+
+   | ``'%'`` | Percentage. Multiplies the number by 100 and displays    |
+   |         | in fixed (``'f'``) format, followed by a percent sign.   |
+   +---------+----------------------------------------------------------+
+   | None    | the same as ``'g'``                                      |
+   +---------+----------------------------------------------------------+
+
+
 Template strings
 ----------------
 

Modified: python/branches/tlee-ast-optimize/Doc/library/telnetlib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/telnetlib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/telnetlib.rst	Thu May 15 00:25:06 2008
@@ -27,11 +27,12 @@
 
    :class:`Telnet` represents a connection to a Telnet server. The instance is
    initially not connected by default; the :meth:`open` method must be used to
-   establish a connection.  Alternatively, the host name and optional port number
-   can be passed to the constructor, to, in which case the connection to the server
-   will be established before the constructor returns. The optional *timeout*
-   parameter specifies a timeout in seconds for the connection attempt (if not
-   specified, or passed as None, the global default timeout setting will be used).
+   establish a connection.  Alternatively, the host name and optional port
+   number can be passed to the constructor, to, in which case the connection to
+   the server will be established before the constructor returns. The optional
+   *timeout* parameter specifies a timeout in seconds for blocking operations
+   like the connection attempt (if not specified, or passed as None, the global
+   default timeout setting will be used).
 
    Do not reopen an already connected instance.
 
@@ -126,8 +127,9 @@
 
    Connect to a host. The optional second argument is the port number, which
    defaults to the standard Telnet port (23). The optional *timeout* parameter
-   specifies a timeout in seconds for the connection attempt (if not specified, or
-   passed as None, the global default timeout setting will be used).
+   specifies a timeout in seconds for blocking operations like the connection
+   attempt (if not specified, or passed as None, the global default timeout
+   setting will be used).
 
    Do not try to reopen an already connected instance.
 

Modified: python/branches/tlee-ast-optimize/Doc/library/tempfile.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/tempfile.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/tempfile.rst	Thu May 15 00:25:06 2008
@@ -167,6 +167,19 @@
       Use of this function may introduce a security hole in your program.
       By the time you get around to doing anything with the file name it
       returns, someone else may have beaten you to the punch.
+      :func:`mktemp` usage can be replaced easily with
+      :func:`NamedTemporaryFile`, passing it the  `delete=False` parameter::
+
+         >>> f = NamedTemporaryFile(delete=False)
+         >>> f
+         <open file '<fdopen>', mode 'w+b' at 0x384698>
+         >>> f.name
+         '/var/folders/5q/5qTPn6xq2RaWqk+1Ytw3-U+++TI/-Tmp-/tmpG7V1Y0'
+         >>> f.write("Hello World!\n")
+         >>> f.close()
+         >>> os.unlink(f.name)
+         >>> os.path.exists(f.name)
+         False
 
 The module uses two global variables that tell it how to construct a
 temporary name.  They are initialized at the first call to any of the

Modified: python/branches/tlee-ast-optimize/Doc/library/test.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/test.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/test.rst	Thu May 15 00:25:06 2008
@@ -283,13 +283,15 @@
    This will run all tests defined in the named module.
 
 
-.. function:: catch_warning()
+.. function:: catch_warning(record=True)
 
-   This is a context manager that guards the warnings filter from being
+   Return a context manager that guards the warnings filter from being
    permanently changed and records the data of the last warning that has been
-   issued.
+   issued. The ``record`` argument specifies whether any raised warnings are
+   captured by the object returned by :func:`warnings.catch_warning` or allowed
+   to propagate as normal.
 
-   Use like this::
+   The context manager is typically used like this::
 
       with catch_warning() as w:
           warnings.warn("foo")

Modified: python/branches/tlee-ast-optimize/Doc/library/textwrap.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/textwrap.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/textwrap.rst	Thu May 15 00:25:06 2008
@@ -41,6 +41,10 @@
 applications that wrap/fill many text strings, it will be more efficient for you
 to create your own :class:`TextWrapper` object.
 
+Text is preferably wrapped on whitespaces and right after the hyphens in
+hyphenated words; only then will long words be broken if necessary, unless
+:attr:`TextWrapper.break_long_words` is set to false.
+
 An additional utility function, :func:`dedent`, is provided to remove
 indentation from strings that have unwanted whitespace to the left of the text.
 
@@ -174,10 +178,22 @@
       than :attr:`width`.  (Long words will be put on a line by themselves, in
       order to minimize the amount by which :attr:`width` is exceeded.)
 
+
+   .. attribute:: break_on_hyphens
+
+      (default: ``True``) If true, wrapping will occur preferably on whitespaces
+      and right after hyphens in compound words, as it is customary in English.
+      If false, only whitespaces will be considered as potentially good places
+      for line breaks, but you need to set :attr:`break_long_words` to false if
+      you want truly insecable words.  Default behaviour in previous versions
+      was to always allow breaking hyphenated words.
+
+      .. versionadded:: 2.6
+
+
    :class:`TextWrapper` also provides two public methods, analogous to the
    module-level convenience functions:
 
-
    .. method:: wrap(text)
 
       Wraps the single paragraph in *text* (a string) so every line is at most

Modified: python/branches/tlee-ast-optimize/Doc/library/threading.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/threading.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/threading.rst	Thu May 15 00:25:06 2008
@@ -8,7 +8,7 @@
 
 This module constructs higher-level threading interfaces on top of the  lower
 level :mod:`thread` module.
-See also the :mod:`mutex` and :mod:`Queue` modules.
+See also the :mod:`mutex` and :mod:`queue` modules.
 
 The :mod:`dummy_threading` module is provided for situations where
 :mod:`threading` cannot be used because :mod:`thread` is missing.

Modified: python/branches/tlee-ast-optimize/Doc/library/tk.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/tk.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/tk.rst	Thu May 15 00:25:06 2008
@@ -22,10 +22,12 @@
 mechanism which allows Python and Tcl to interact.
 
 :mod:`Tkinter`'s chief virtues are that it is fast, and that it usually comes
-bundled with Python. Although it has been used to create some very good
-applications, including IDLE, it has weak documentation and an outdated look and
-feel. For more modern, better documented, and much more extensive GUI
-libraries, see the :ref:`other-gui-packages` section.
+bundled with Python. Although its standard documentation is weak, good 
+material is available, which includes: references, tutorials, a book and 
+others. :mod:`Tkinter` is also famous for having an outdated look and feel, 
+which has been vastly improved in Tk 8.5. Nevertheless, there are many other 
+GUI libraries that you could be interested in. For more information about 
+alternatives, see the :ref:`other-gui-packages` section.
 
 .. toctree::
    

Modified: python/branches/tlee-ast-optimize/Doc/library/undoc.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/undoc.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/undoc.rst	Thu May 15 00:25:06 2008
@@ -21,6 +21,8 @@
 
 :mod:`ihooks`
    --- Import hook support (for :mod:`rexec`; may become obsolete).
+   
+   .. warning:: The :mod:`ihooks` module has been removed in Python 3.0.
 
 
 Platform specific modules
@@ -52,6 +54,8 @@
 :mod:`linuxaudiodev`
    --- Play audio data on the Linux audio device.  Replaced in Python 2.3 by the
    :mod:`ossaudiodev` module.
+   
+   .. warning:: The :mod:`linuxaudiodev` module has been removed in Python 3.0.
 
 :mod:`sunaudio`
    --- Interpret Sun audio headers (may become obsolete or a tool/demo).
@@ -61,6 +65,9 @@
    or demo.  Requires the external program :program:`sox`.
 
 
+   .. warning:: The :mod:`toaiff` module has been removed in 3.0.
+
+
 .. _undoc-mac-modules:
 
 Undocumented Mac OS modules
@@ -73,7 +80,9 @@
 .. module:: applesingle
    :platform: Mac
    :synopsis: Rudimentary decoder for AppleSingle format files.
+   :deprecated:
 
+.. deprecated:: 2.6
 
 
 :mod:`buildtools` --- Helper module for BuildApplet and Friends
@@ -82,6 +91,7 @@
 .. module:: buildtools
    :platform: Mac
    :synopsis: Helper module for BuildApplet, BuildApplication and macfreeze.
+   :deprecated:
 
 
 .. deprecated:: 2.4
@@ -92,6 +102,7 @@
 .. module:: cfmfile
    :platform: Mac
    :synopsis: Code Fragment Resource module.
+   :deprecated:
 
 
 :mod:`cfmfile` is a module that understands Code Fragments and the accompanying
@@ -106,11 +117,14 @@
 .. module:: icopen
    :platform: Mac
    :synopsis: Internet Config replacement for open().
+   :deprecated:
 
 
 Importing :mod:`icopen` will replace the builtin :meth:`open` with a version
 that uses Internet Config to set file type and creator for new files.
 
+.. deprecated:: 2.6
+
 
 :mod:`macerrors` --- Mac OS Errors
 ----------------------------------
@@ -118,10 +132,13 @@
 .. module:: macerrors
    :platform: Mac
    :synopsis: Constant definitions for many Mac OS error codes.
+   :deprecated:
 
 
 :mod:`macerrors` contains constant definitions for many Mac OS error codes.
 
+.. deprecated:: 2.6
+
 
 :mod:`macresource` --- Locate script resources
 ----------------------------------------------
@@ -129,12 +146,15 @@
 .. module:: macresource
    :platform: Mac
    :synopsis: Locate script resources.
+   :deprecated:
 
 
 :mod:`macresource` helps scripts finding their resources, such as dialogs and
 menus, without requiring special case code for when the script is run under
 MacPython, as a MacPython applet or under OSX Python.
 
+.. deprecated:: 2.6
+
 
 :mod:`Nav` --- NavServices calls
 --------------------------------
@@ -142,10 +162,13 @@
 .. module:: Nav
    :platform: Mac
    :synopsis: Interface to Navigation Services.
+   :deprecated:
 
 
 A low-level interface to Navigation Services.
 
+.. deprecated:: 2.6
+
 
 :mod:`PixMapWrapper` --- Wrapper for PixMap objects
 ---------------------------------------------------
@@ -153,12 +176,15 @@
 .. module:: PixMapWrapper
    :platform: Mac
    :synopsis: Wrapper for PixMap objects.
+   :deprecated:
 
 
 :mod:`PixMapWrapper` wraps a PixMap object with a Python object that allows
 access to the fields by name. It also has methods to convert to and from
 :mod:`PIL` images.
 
+.. deprecated:: 2.6
+
 
 :mod:`videoreader` --- Read QuickTime movies
 --------------------------------------------
@@ -166,11 +192,14 @@
 .. module:: videoreader
    :platform: Mac
    :synopsis: Read QuickTime movies frame by frame for further processing.
+   :deprecated:
 
 
 :mod:`videoreader` reads and decodes QuickTime movies and passes a stream of
 images to your program. It also provides some support for audio tracks.
 
+.. deprecated:: 2.6
+
 
 :mod:`W` --- Widgets built on :mod:`FrameWork`
 ----------------------------------------------
@@ -178,10 +207,13 @@
 .. module:: W
    :platform: Mac
    :synopsis: Widgets for the Mac, built on top of FrameWork.
+   :deprecated:
 
 
 The :mod:`W` widgets are used extensively in the :program:`IDE`.
 
+.. deprecated:: 2.6
+
 
 .. _obsolete-modules:
 
@@ -206,6 +238,8 @@
 
 :mod:`timing`
    --- Measure time intervals to high resolution (use :func:`time.clock` instead).
+   
+   .. warning:: The :mod:`timing` module has been removed in Python 3.0.
 
 
 SGI-specific Extension modules
@@ -219,4 +253,6 @@
 
 :mod:`sv`
    --- Interface to the "simple video" board on SGI Indigo (obsolete hardware).
+   
+   .. warning:: The :mod:`sv` module has been removed in Python 3.0.
 

Modified: python/branches/tlee-ast-optimize/Doc/library/urllib2.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/urllib2.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/urllib2.rst	Thu May 15 00:25:06 2008
@@ -26,10 +26,10 @@
    :func:`urllib.urlencode` function takes a mapping or sequence of 2-tuples and
    returns a string in this format.
 
-   The optional *timeout* parameter specifies a timeout in seconds for the
-   connection attempt (if not specified, or passed as None, the global default
-   timeout setting will be used). This actually only work for HTTP, HTTPS, FTP and
-   FTPS connections.
+   The optional *timeout* parameter specifies a timeout in seconds for blocking
+   operations like the connection attempt (if not specified, or passed as
+   ``None``, the global default timeout setting will be used).  This actually
+   only works for HTTP, HTTPS, FTP and FTPS connections.
 
    This function returns a file-like object with two additional methods:
 
@@ -407,12 +407,13 @@
 .. method:: OpenerDirector.open(url[, data][, timeout])
 
    Open the given *url* (which can be a request object or a string), optionally
-   passing the given *data*. Arguments, return values and exceptions raised are the
-   same as those of :func:`urlopen` (which simply calls the :meth:`open` method on
-   the currently installed global :class:`OpenerDirector`).  The optional *timeout*
-   parameter specifies a timeout in seconds for the connection  attempt (if not
-   specified, or passed as None, the global default timeout  setting will be used;
-   this actually only work for HTTP, HTTPS, FTP and FTPS connections).
+   passing the given *data*. Arguments, return values and exceptions raised are
+   the same as those of :func:`urlopen` (which simply calls the :meth:`open`
+   method on the currently installed global :class:`OpenerDirector`).  The
+   optional *timeout* parameter specifies a timeout in seconds for blocking
+   operations like the connection attempt (if not specified, or passed as
+   ``None``, the global default timeout setting will be used; this actually only
+   works for HTTP, HTTPS, FTP and FTPS connections).
 
    .. versionchanged:: 2.6
       *timeout* was added.

Modified: python/branches/tlee-ast-optimize/Doc/library/user.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/user.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/user.rst	Thu May 15 00:25:06 2008
@@ -4,7 +4,10 @@
 
 .. module:: user
    :synopsis: A standard way to reference user-specific modules.
+   :deprecated:
 
+.. deprecated:: 2.6
+   The :mod:`user` module has been removed in Python 3.0.
 
 .. index::
    pair: .pythonrc.py; file

Modified: python/branches/tlee-ast-optimize/Doc/library/warnings.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/warnings.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/warnings.rst	Thu May 15 00:25:06 2008
@@ -218,6 +218,9 @@
    resulting string to *file*, which defaults to ``sys.stderr``.  You may replace
    this function with an alternative implementation by assigning to
    ``warnings.showwarning``.
+   *line* is a line of source code to be included in the warning
+   message; if *line* is not supplied, :func:`showwarning` will 
+   try to read the line specified by *filename* and *lineno*.
 
    .. versionchanged:: 2.6
       Added the *line* argument. Implementations that lack the new argument
@@ -227,7 +230,9 @@
 .. function:: formatwarning(message, category, filename, lineno[, line])
 
    Format a warning the standard way.  This returns a string  which may contain
-   embedded newlines and ends in a newline.
+   embedded newlines and ends in a newline.  *line* is 
+   a line of source code to be included in the warning message; if *line* is not supplied, 
+   :func:`formatwarning` will try to read the line specified by *filename* and *lineno*.
 
    .. versionchanged:: 2.6
       Added the *line* argument.

Modified: python/branches/tlee-ast-optimize/Doc/library/winsound.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/winsound.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/winsound.rst	Thu May 15 00:25:06 2008
@@ -22,13 +22,6 @@
    parameter specifies the number of milliseconds the sound should last.  If the
    system is not able to beep the speaker, :exc:`RuntimeError` is raised.
 
-   .. note::
-
-      Under Windows 95 and 98, the Windows :cfunc:`Beep` function exists but is
-      useless (it ignores its arguments).  In that case Python simulates it via direct
-      port manipulation (added in version 2.1).  It's unknown whether that will work
-      on all systems.
-
    .. versionadded:: 1.6
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/zipfile.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/zipfile.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/zipfile.rst	Thu May 15 00:25:06 2008
@@ -316,7 +316,7 @@
 
       string.pyc                                # Top level name 
       test/__init__.pyc                         # Package directory 
-      test/testall.pyc                          # Module test.testall
+      test/test_support.pyc                          # Module test.test_support
       test/bogus/__init__.pyc                   # Subpackage directory 
       test/bogus/myfile.pyc                     # Submodule test.bogus.myfile
 

Modified: python/branches/tlee-ast-optimize/Doc/library/zipimport.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/zipimport.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/zipimport.rst	Thu May 15 00:25:06 2008
@@ -65,17 +65,14 @@
 
 .. class:: zipimporter(archivepath)
 
-   Create a new zipimporter instance. *archivepath* must be a path to a ZIP file.
+   Create a new zipimporter instance. *archivepath* must be a path to a ZIP
+   file, or to a specific path within a ZIP file.  For example, an *archivepath*
+   of :file:`foo/bar.zip/lib` will look for modules in the :file:`lib` directory
+   inside the ZIP file :file:`foo/bar.zip` (provided that it exists).
+
    :exc:`ZipImportError` is raised if *archivepath* doesn't point to a valid ZIP
    archive.
 
-   *archivepath* can also contain a path within the ZIP file -- the importer
-   object will then look under that path instead of the ZIP file root.  For
-   example, an *archivepath* of :file:`foo/bar.zip/lib` will look for modules
-   in the :file:`lib` directory inside the ZIP file :file:`foo/bar.zip`
-   (provided that it exists).
-
-
    .. method:: find_module(fullname[, path])
 
       Search for a module specified by *fullname*. *fullname* must be the fully
@@ -120,13 +117,19 @@
 
    .. attribute:: archive
 
-      The file name of the importer's associated ZIP file.
+      The file name of the importer's associated ZIP file, without a possible
+      subpath.
 
 
    .. attribute:: prefix
 
-      The path within the ZIP file where modules are searched; see
-      :class:`zipimporter` for details.
+      The subpath within the ZIP file where modules are searched.  This is the
+      empty string for zipimporter objects which point to the root of the ZIP
+      file.
+
+   The :attr:`archive` and :attr:`prefix` attributes, when combined with a
+   slash, equal the original *archivepath* argument given to the
+   :class:`zipimporter` constructor.
 
 
 .. _zipimport-examples:

Modified: python/branches/tlee-ast-optimize/Doc/license.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/license.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/license.rst	Thu May 15 00:25:06 2008
@@ -88,6 +88,8 @@
 +----------------+--------------+-----------+------------+-----------------+
 | 2.5.1          | 2.5          | 2007      | PSF        | yes             |
 +----------------+--------------+-----------+------------+-----------------+
+| 2.6            | 2.5          | 2008      | PSF        | yes             |
++----------------+--------------+-----------+------------+-----------------+
 
 .. note::
 

Modified: python/branches/tlee-ast-optimize/Doc/reference/datamodel.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/reference/datamodel.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/reference/datamodel.rst	Thu May 15 00:25:06 2008
@@ -175,23 +175,24 @@
             object: plain integer
             single: OverflowError (built-in exception)
 
-         These represent numbers in the range -2147483648 through 2147483647. (The range
-         may be larger on machines with a larger natural word size, but not smaller.)
-         When the result of an operation would fall outside this range, the result is
-         normally returned as a long integer (in some cases, the exception
-         :exc:`OverflowError` is raised instead). For the purpose of shift and mask
-         operations, integers are assumed to have a binary, 2's complement notation using
-         32 or more bits, and hiding no bits from the user (i.e., all 4294967296
-         different bit patterns correspond to different values).
+         These represent numbers in the range -2147483648 through 2147483647.
+         (The range may be larger on machines with a larger natural word size,
+         but not smaller.)  When the result of an operation would fall outside
+         this range, the result is normally returned as a long integer (in some
+         cases, the exception :exc:`OverflowError` is raised instead).  For the
+         purpose of shift and mask operations, integers are assumed to have a
+         binary, 2's complement notation using 32 or more bits, and hiding no
+         bits from the user (i.e., all 4294967296 different bit patterns
+         correspond to different values).
 
       Long integers
          .. index:: object: long integer
 
-         These represent numbers in an unlimited range, subject to available (virtual)
-         memory only.  For the purpose of shift and mask operations, a binary
-         representation is assumed, and negative numbers are represented in a variant of
-         2's complement which gives the illusion of an infinite string of sign bits
-         extending to the left.
+         These represent numbers in an unlimited range, subject to available
+         (virtual) memory only.  For the purpose of shift and mask operations, a
+         binary representation is assumed, and negative numbers are represented
+         in a variant of 2's complement which gives the illusion of an infinite
+         string of sign bits extending to the left.
 
       Booleans
          .. index::
@@ -199,20 +200,22 @@
             single: False
             single: True
 
-         These represent the truth values False and True.  The two objects representing
-         the values False and True are the only Boolean objects. The Boolean type is a
-         subtype of plain integers, and Boolean values behave like the values 0 and 1,
-         respectively, in almost all contexts, the exception being that when converted to
-         a string, the strings ``"False"`` or ``"True"`` are returned, respectively.
+         These represent the truth values False and True.  The two objects
+         representing the values False and True are the only Boolean objects.
+         The Boolean type is a subtype of plain integers, and Boolean values
+         behave like the values 0 and 1, respectively, in almost all contexts,
+         the exception being that when converted to a string, the strings
+         ``"False"`` or ``"True"`` are returned, respectively.
 
       .. index:: pair: integer; representation
 
-      The rules for integer representation are intended to give the most meaningful
-      interpretation of shift and mask operations involving negative integers and the
-      least surprises when switching between the plain and long integer domains.  Any
-      operation except left shift, if it yields a result in the plain integer domain
-      without causing overflow, will yield the same result in the long integer domain
-      or when using mixed operands.
+      The rules for integer representation are intended to give the most
+      meaningful interpretation of shift and mask operations involving negative
+      integers and the least surprises when switching between the plain and long
+      integer domains.  Any operation, if it yields a result in the plain
+      integer domain, will yield the same result in the long integer domain or
+      when using mixed operands.  The switch between domains is transparent to
+      the programmer.
 
    :class:`numbers.Real` (:class:`float`)
       .. index::

Modified: python/branches/tlee-ast-optimize/Doc/reference/executionmodel.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/reference/executionmodel.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/reference/executionmodel.rst	Thu May 15 00:25:06 2008
@@ -203,10 +203,10 @@
 The Python interpreter raises an exception when it detects a run-time error
 (such as division by zero).  A Python program can also explicitly raise an
 exception with the :keyword:`raise` statement. Exception handlers are specified
-with the :keyword:`try` ... :keyword:`except` statement.  The :keyword:`try` ...
-:keyword:`finally` statement specifies cleanup code which does not handle the
-exception, but is executed whether an exception occurred or not in the preceding
-code.
+with the :keyword:`try` ... :keyword:`except` statement.  The :keyword:`finally`
+clause of such a statement can be used to specify cleanup code which does not
+handle the exception, but is executed whether an exception occurred or not in
+the preceding code.
 
 .. index:: single: termination model
 

Modified: python/branches/tlee-ast-optimize/Doc/reference/expressions.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/reference/expressions.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/reference/expressions.rst	Thu May 15 00:25:06 2008
@@ -944,11 +944,9 @@
 
 .. index:: exception: ValueError
 
-A right shift by *n* bits is defined as division by ``pow(2,n)``.  A left shift
-by *n* bits is defined as multiplication with ``pow(2,n)``; for plain integers
-there is no overflow check so in that case the operation drops bits and flips
-the sign if the result is not less than ``pow(2,31)`` in absolute value.
-Negative shift counts raise a :exc:`ValueError` exception.
+A right shift by *n* bits is defined as division by ``pow(2, n)``.  A left shift
+by *n* bits is defined as multiplication with ``pow(2, n)``.  Negative shift
+counts raise a :exc:`ValueError` exception.
 
 
 .. _bitwise:

Modified: python/branches/tlee-ast-optimize/Doc/reference/simple_stmts.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/reference/simple_stmts.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/reference/simple_stmts.rst	Thu May 15 00:25:06 2008
@@ -534,7 +534,7 @@
 If no expressions are present, :keyword:`raise` re-raises the last exception
 that was active in the current scope.  If no exception is active in the current
 scope, a :exc:`TypeError` exception is raised indicating that this is an error
-(if running under IDLE, a :exc:`Queue.Empty` exception is raised instead).
+(if running under IDLE, a :exc:`queue.Empty` exception is raised instead).
 
 Otherwise, :keyword:`raise` evaluates the expressions to get three objects,
 using ``None`` as the value of omitted expressions.  The first two objects are

Modified: python/branches/tlee-ast-optimize/Doc/tutorial/modules.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/modules.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/modules.rst	Thu May 15 00:25:06 2008
@@ -103,6 +103,13 @@
 
 This imports all names except those beginning with an underscore (``_``).
 
+.. note::
+
+   For efficiency reasons, each module is only imported once per interpreter
+   session.  Therefore, if you change your modules, you must restart the
+   interpreter -- or, if it's just one module you want to test interactively,
+   use :func:`reload`, e.g. ``reload(modulename)``.
+
 
 .. _tut-modulesasscripts:
 

Modified: python/branches/tlee-ast-optimize/Doc/tutorial/stdlib2.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/stdlib2.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/stdlib2.rst	Thu May 15 00:25:06 2008
@@ -198,7 +198,7 @@
 While those tools are powerful, minor design errors can result in problems that
 are difficult to reproduce.  So, the preferred approach to task coordination is
 to concentrate all access to a resource in a single thread and then use the
-:mod:`Queue` module to feed that thread with requests from other threads.
+:mod:`queue` module to feed that thread with requests from other threads.
 Applications using :class:`Queue` objects for inter-thread communication and
 coordination are easier to design, more readable, and more reliable.
 

Modified: python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst	Thu May 15 00:25:06 2008
@@ -40,25 +40,26 @@
    * Credit the author of a patch or bugfix.   Just the name is
    sufficient; the e-mail address isn't necessary.
    
-   * It's helpful to add the bug/patch number in an parenthetical
+   * It's helpful to add the bug/patch number in a parenthetical comment.
    
    XXX Describe the transmogrify() function added to the socket
    module.
    (Contributed by P.Y. Developer; :issue:`12345`.)
    
-   This saves the maintainer the effort of going through the SVN logs
+   This saves the maintainer some effort going through the SVN logs
    when researching a change.
 
-This article explains the new features in Python 2.6.  No release date for
-Python 2.6 has been set; it will probably be released in mid 2008.
+This article explains the new features in Python 2.6.  The release
+schedule is described in :pep:`361`; currently the final release is
+scheduled for September 3 2008.
 
 This article doesn't attempt to provide a complete specification of
 the new features, but instead provides a convenient overview.  For
 full details, you should refer to the documentation for Python 2.6. If
-you want to understand the complete implementation and design
-rationale, refer to the PEP for a particular new feature.  For smaller
-changes, this edition of "What's New in Python" links to the bug/patch
-item for each change whenever possible.
+you want to understand the rationale for the design and
+implementation, refer to the PEP for a particular new feature.
+Whenever possible, "What's New in Python" links to the bug/patch item
+for each change.
 
 .. Compare with previous release in 2 - 3 sentences here.
    add hyperlink when the documentation becomes available online.
@@ -481,24 +482,41 @@
 
 .. ======================================================================
 
-.. ::
+.. _pep-0370:
 
-    .. _pep-0370:
-
-    PEP 370: XXX
-    =====================================================
-
-    When you run Python, the module search page ``sys.modules`` usually
-    includes a directory whose path ends in ``"site-packages"``.  This
-    directory is intended to hold locally-installed packages available to
-    all users on a machine or using a particular site installation.
+PEP 370: Per-user ``site-packages`` Directory
+=====================================================
 
-    Python 2.6 introduces a convention for user-specific site directories.
+When you run Python, the module search path ``sys.modules`` usually
+includes a directory whose path ends in ``"site-packages"``.  This
+directory is intended to hold locally-installed packages available to
+all users on a machine or using a particular site installation.
+
+Python 2.6 introduces a convention for user-specific site directories.
+The directory varies depending on the platform:
+
+* Unix and MacOS: :file:`~/.local/`
+* Windows: :file:`%APPDATA%/Python`
+
+Within this directory, there will be version-specific subdirectories,
+such as :file:`lib/python2.6/site-packages` on Unix/MacOS and
+:file:`Python26/site-packages` on Windows.
+
+If you don't like the default directory, it can be overridden by an
+environment variable.  :envvar:`PYTHONUSERBASE` sets the root
+directory used for all Python versions supporting this feature.  On
+Windows, the directory for application-specific data can be changed by
+setting the :envvar:`APPDATA` environment variable.  You can also
+modify the :file:`site.py` file for your Python installation.
+
+The feature can be disabled entirely by running Python with the
+:option:`-s` option or setting the :envvar:`PYTHONNOUSERSITE`
+environment variable.
 
-    .. seealso::
+.. seealso::
 
-       :pep:`370` - XXX
-         PEP written by XXX; implemented by Christian Heimes.
+   :pep:`370` - Per-user ``site-packages`` Directory
+     PEP written and implemented by Christian Heimes.
 
   
 .. ======================================================================
@@ -594,8 +612,7 @@
     '3.750000e+00'
 
 A variety of presentation types are available.  Consult the 2.6
-documentation for a complete list (XXX add link, once it's in the 2.6
-docs), but here's a sample::
+documentation for a :ref:`complete list <formatstrings>`; here's a sample::
 
         'b' - Binary. Outputs the number in base 2.
         'c' - Character. Converts the integer to the corresponding
@@ -609,9 +626,9 @@
         'g' - General format. This prints the number as a fixed-point
               number, unless the number is too large, in which case
               it switches to 'e' exponent notation.
-        'n' - Number. This is the same as 'g', except that it uses the
-              current locale setting to insert the appropriate
-              number separator characters.
+        'n' - Number. This is the same as 'g' (for floats) or 'd' (for
+              integers), except that it uses the current locale setting to
+              insert the appropriate number separator characters.
         '%' - Percentage. Multiplies the number by 100 and displays
               in fixed ('f') format, followed by a percent sign.
 
@@ -1450,6 +1467,37 @@
 by module name. Consult the :file:`Misc/NEWS` file in the source tree for a more
 complete list of changes, or look through the CVS logs for all the details.
 
+* (3.0-warning mode) Python 3.0 will feature a reorganized standard 
+  library; many outdated modules are  being dropped,
+  and some modules are being renamed or moved into packages. 
+  Python 2.6 running in 3.0-warning mode will warn about these modules 
+  when they are improved.
+
+  The list of deprecated modules that are removed in Python 3.0 is:
+  :mod:`audiodev`, 
+  :mod:`Canvas`,
+  :mod:`compiler`,
+  :mod:`dircache`,
+  :mod:`dl`,
+  :mod:`fpformat`,
+  :mod:`ihooks`,
+  :mod:`imageop`,
+  :mod:`linuxaudiodev`,
+  :mod:`mhlib`,
+  :mod:`multifile`,
+  :mod:`new`
+  :mod:`popen2`,
+  :mod:`pure`,
+  :mod:`sv`,
+  :mod:`test.testall`,
+  :mod:`toaiff`.
+
+  The modules that have been renamed are:
+
+  * :mod:`copy_reg` has become :mod:`copyreg`.
+  * :mod:`SocketServer` has become :mod:`socketserver`.
+  * :mod:`Queue` has become :mod:`queue`.
+
 * The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
   available, instead of restricting itself to protocol 1.
   (Contributed by W. Barnes; :issue:`1551443`.)
@@ -1731,9 +1779,6 @@
   the forward search.
   (Contributed by John Lenton.)
 
-* (3.0-warning mode) The :mod:`new` module has been removed from
-  Python 3.0.  Importing it therefore triggers a warning message.
-
 * The :mod:`operator` module gained a 
   :func:`methodcaller` function that takes a name and an optional 
   set of arguments, returning a callable that will call 
@@ -2104,7 +2149,12 @@
 
   (Added by Facundo Batista.) 
 
-* The XML-RPC classes :class:`SimpleXMLRPCServer` and :class:`DocXMLRPCServer`
+* The :mod:`warnings` module's :func:`formatwarning` and :func:`showwarning` 
+  gained an optional *line* argument that can be used to supply the
+  line of source code.  (Added as part of :issue:`1631171`, which re-implemented
+  part of the :mod:`warnings` module in C code.)
+
+* The XML-RPC :class:`SimpleXMLRPCServer` and :class:`DocXMLRPCServer`
   classes can now be prevented from immediately opening and binding to
   their socket by passing True as the ``bind_and_activate``
   constructor parameter.  This can be used to modify the instance's
@@ -2144,6 +2194,9 @@
 
   (Contributed by Alan McIntyre; :issue:`467924`.)
 
+  Also, :mod:`zipfile` now supports using Unicode filenames
+  for archived files.  (Contributed by Alexey Borzenkov; :issue:`1734346`.)
+
 .. ======================================================================
 .. whole new modules get described in subsections here
 

Modified: python/branches/tlee-ast-optimize/Include/patchlevel.h
==============================================================================
--- python/branches/tlee-ast-optimize/Include/patchlevel.h	(original)
+++ python/branches/tlee-ast-optimize/Include/patchlevel.h	Thu May 15 00:25:06 2008
@@ -24,10 +24,10 @@
 #define PY_MINOR_VERSION	6
 #define PY_MICRO_VERSION	0
 #define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_ALPHA
-#define PY_RELEASE_SERIAL	2
+#define PY_RELEASE_SERIAL	3
 
 /* Version as a string */
-#define PY_VERSION      	"2.6a2+"
+#define PY_VERSION      	"2.6a3+"
 /*--end constants--*/
 
 /* Subversion Revision number of this file (not of the repository) */

Modified: python/branches/tlee-ast-optimize/Include/stringobject.h
==============================================================================
--- python/branches/tlee-ast-optimize/Include/stringobject.h	(original)
+++ python/branches/tlee-ast-optimize/Include/stringobject.h	Thu May 15 00:25:06 2008
@@ -176,7 +176,17 @@
 				   (only possible for 0-terminated
 				   strings) */
     );
-    
+
+/* Using the current locale, insert the thousands grouping
+   into the string pointed to by buffer.  For the argument descriptions,
+   see Objects/stringlib/localeutil.h */
+
+PyAPI_FUNC(int) _PyString_InsertThousandsGrouping(char *buffer,
+						  Py_ssize_t len,
+						  char *plast,
+						  Py_ssize_t buf_size,
+						  Py_ssize_t *count,
+						  int append_zero_char);
 
 #ifdef __cplusplus
 }

Modified: python/branches/tlee-ast-optimize/Lib/BaseHTTPServer.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/BaseHTTPServer.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/BaseHTTPServer.py	Thu May 15 00:25:06 2008
@@ -74,7 +74,7 @@
 import time
 import socket # For gethostbyaddr()
 import mimetools
-import SocketServer
+import socketserver
 
 # Default error message template
 DEFAULT_ERROR_MESSAGE = """\
@@ -94,19 +94,19 @@
 def _quote_html(html):
     return html.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
 
-class HTTPServer(SocketServer.TCPServer):
+class HTTPServer(socketserver.TCPServer):
 
     allow_reuse_address = 1    # Seems to make sense in testing environment
 
     def server_bind(self):
         """Override server_bind to store the server name."""
-        SocketServer.TCPServer.server_bind(self)
+        socketserver.TCPServer.server_bind(self)
         host, port = self.socket.getsockname()[:2]
         self.server_name = socket.getfqdn(host)
         self.server_port = port
 
 
-class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
+class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
 
     """HTTP request handler base class.
 

Modified: python/branches/tlee-ast-optimize/Lib/Bastion.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/Bastion.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/Bastion.py	Thu May 15 00:25:06 2008
@@ -25,6 +25,9 @@
 bastion is created.
 
 """
+from warnings import warnpy3k
+warnpy3k("the Bastion module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 __all__ = ["BastionClass", "Bastion"]
 

Deleted: python/branches/tlee-ast-optimize/Lib/Queue.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/Queue.py	Thu May 15 00:25:06 2008
+++ (empty file)
@@ -1,244 +0,0 @@
-"""A multi-producer, multi-consumer queue."""
-
-from time import time as _time
-from collections import deque
-import heapq
-
-__all__ = ['Empty', 'Full', 'Queue', 'PriorityQueue', 'LifoQueue']
-
-class Empty(Exception):
-    "Exception raised by Queue.get(block=0)/get_nowait()."
-    pass
-
-class Full(Exception):
-    "Exception raised by Queue.put(block=0)/put_nowait()."
-    pass
-
-class Queue:
-    """Create a queue object with a given maximum size.
-
-    If maxsize is <= 0, the queue size is infinite.
-    """
-    def __init__(self, maxsize=0):
-        try:
-            import threading
-        except ImportError:
-            import dummy_threading as threading
-        self.maxsize = maxsize
-        self._init(maxsize)
-        # mutex must be held whenever the queue is mutating.  All methods
-        # that acquire mutex must release it before returning.  mutex
-        # is shared between the three conditions, so acquiring and
-        # releasing the conditions also acquires and releases mutex.
-        self.mutex = threading.Lock()
-        # Notify not_empty whenever an item is added to the queue; a
-        # thread waiting to get is notified then.
-        self.not_empty = threading.Condition(self.mutex)
-        # Notify not_full whenever an item is removed from the queue;
-        # a thread waiting to put is notified then.
-        self.not_full = threading.Condition(self.mutex)
-        # Notify all_tasks_done whenever the number of unfinished tasks
-        # drops to zero; thread waiting to join() is notified to resume
-        self.all_tasks_done = threading.Condition(self.mutex)
-        self.unfinished_tasks = 0
-
-    def task_done(self):
-        """Indicate that a formerly enqueued task is complete.
-
-        Used by Queue consumer threads.  For each get() used to fetch a task,
-        a subsequent call to task_done() tells the queue that the processing
-        on the task is complete.
-
-        If a join() is currently blocking, it will resume when all items
-        have been processed (meaning that a task_done() call was received
-        for every item that had been put() into the queue).
-
-        Raises a ValueError if called more times than there were items
-        placed in the queue.
-        """
-        self.all_tasks_done.acquire()
-        try:
-            unfinished = self.unfinished_tasks - 1
-            if unfinished <= 0:
-                if unfinished < 0:
-                    raise ValueError('task_done() called too many times')
-                self.all_tasks_done.notifyAll()
-            self.unfinished_tasks = unfinished
-        finally:
-            self.all_tasks_done.release()
-
-    def join(self):
-        """Blocks until all items in the Queue have been gotten and processed.
-
-        The count of unfinished tasks goes up whenever an item is added to the
-        queue. The count goes down whenever a consumer thread calls task_done()
-        to indicate the item was retrieved and all work on it is complete.
-
-        When the count of unfinished tasks drops to zero, join() unblocks.
-        """
-        self.all_tasks_done.acquire()
-        try:
-            while self.unfinished_tasks:
-                self.all_tasks_done.wait()
-        finally:
-            self.all_tasks_done.release()
-
-    def qsize(self):
-        """Return the approximate size of the queue (not reliable!)."""
-        self.mutex.acquire()
-        n = self._qsize()
-        self.mutex.release()
-        return n
-
-    def empty(self):
-        """Return True if the queue is empty, False otherwise (not reliable!)."""
-        self.mutex.acquire()
-        n = not self._qsize()
-        self.mutex.release()
-        return n
-
-    def full(self):
-        """Return True if the queue is full, False otherwise (not reliable!)."""
-        self.mutex.acquire()
-        n = 0 < self.maxsize == self._qsize()
-        self.mutex.release()
-        return n
-
-    def put(self, item, block=True, timeout=None):
-        """Put an item into the queue.
-
-        If optional args 'block' is true and 'timeout' is None (the default),
-        block if necessary until a free slot is available. If 'timeout' is
-        a positive number, it blocks at most 'timeout' seconds and raises
-        the Full exception if no free slot was available within that time.
-        Otherwise ('block' is false), put an item on the queue if a free slot
-        is immediately available, else raise the Full exception ('timeout'
-        is ignored in that case).
-        """
-        self.not_full.acquire()
-        try:
-            if self.maxsize > 0:
-                if not block:
-                    if self._qsize() == self.maxsize:
-                        raise Full
-                elif timeout is None:
-                    while self._qsize() == self.maxsize:
-                        self.not_full.wait()
-                elif timeout < 0:
-                    raise ValueError("'timeout' must be a positive number")
-                else:
-                    endtime = _time() + timeout
-                    while self._qsize() == self.maxsize:
-                        remaining = endtime - _time()
-                        if remaining <= 0.0:
-                            raise Full
-                        self.not_full.wait(remaining)
-            self._put(item)
-            self.unfinished_tasks += 1
-            self.not_empty.notify()
-        finally:
-            self.not_full.release()
-
-    def put_nowait(self, item):
-        """Put an item into the queue without blocking.
-
-        Only enqueue the item if a free slot is immediately available.
-        Otherwise raise the Full exception.
-        """
-        return self.put(item, False)
-
-    def get(self, block=True, timeout=None):
-        """Remove and return an item from the queue.
-
-        If optional args 'block' is true and 'timeout' is None (the default),
-        block if necessary until an item is available. If 'timeout' is
-        a positive number, it blocks at most 'timeout' seconds and raises
-        the Empty exception if no item was available within that time.
-        Otherwise ('block' is false), return an item if one is immediately
-        available, else raise the Empty exception ('timeout' is ignored
-        in that case).
-        """
-        self.not_empty.acquire()
-        try:
-            if not block:
-                if not self._qsize():
-                    raise Empty
-            elif timeout is None:
-                while not self._qsize():
-                    self.not_empty.wait()
-            elif timeout < 0:
-                raise ValueError("'timeout' must be a positive number")
-            else:
-                endtime = _time() + timeout
-                while not self._qsize():
-                    remaining = endtime - _time()
-                    if remaining <= 0.0:
-                        raise Empty
-                    self.not_empty.wait(remaining)
-            item = self._get()
-            self.not_full.notify()
-            return item
-        finally:
-            self.not_empty.release()
-
-    def get_nowait(self):
-        """Remove and return an item from the queue without blocking.
-
-        Only get an item if one is immediately available. Otherwise
-        raise the Empty exception.
-        """
-        return self.get(False)
-
-    # Override these methods to implement other queue organizations
-    # (e.g. stack or priority queue).
-    # These will only be called with appropriate locks held
-
-    # Initialize the queue representation
-    def _init(self, maxsize):
-        self.queue = deque()
-
-    def _qsize(self, len=len):
-        return len(self.queue)
-
-    # Put a new item in the queue
-    def _put(self, item):
-        self.queue.append(item)
-
-    # Get an item from the queue
-    def _get(self):
-        return self.queue.popleft()
-
-
-class PriorityQueue(Queue):
-    '''Variant of Queue that retrieves open entries in priority order (lowest first).
-
-    Entries are typically tuples of the form:  (priority number, data).
-    '''
-
-    def _init(self, maxsize):
-        self.queue = []
-
-    def _qsize(self, len=len):
-        return len(self.queue)
-
-    def _put(self, item, heappush=heapq.heappush):
-        heappush(self.queue, item)
-
-    def _get(self, heappop=heapq.heappop):
-        return heappop(self.queue)
-
-
-class LifoQueue(Queue):
-    '''Variant of Queue that retrieves most recently added entries first.'''
-
-    def _init(self, maxsize):
-        self.queue = []
-
-    def _qsize(self, len=len):
-        return len(self.queue)
-
-    def _put(self, item):
-        self.queue.append(item)
-
-    def _get(self):
-        return self.queue.pop()

Modified: python/branches/tlee-ast-optimize/Lib/SimpleXMLRPCServer.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/SimpleXMLRPCServer.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/SimpleXMLRPCServer.py	Thu May 15 00:25:06 2008
@@ -101,7 +101,7 @@
 
 import xmlrpclib
 from xmlrpclib import Fault
-import SocketServer
+import socketserver
 import BaseHTTPServer
 import sys
 import os
@@ -512,7 +512,7 @@
         if self.server.logRequests:
             BaseHTTPServer.BaseHTTPRequestHandler.log_request(self, code, size)
 
-class SimpleXMLRPCServer(SocketServer.TCPServer,
+class SimpleXMLRPCServer(socketserver.TCPServer,
                          SimpleXMLRPCDispatcher):
     """Simple XML-RPC server.
 
@@ -536,7 +536,7 @@
         self.logRequests = logRequests
 
         SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
-        SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
+        socketserver.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
 
         # [Bug #1222790] If possible, set close-on-exec flag; if a
         # method spawns a subprocess, the subprocess shouldn't have

Deleted: python/branches/tlee-ast-optimize/Lib/SocketServer.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/SocketServer.py	Thu May 15 00:25:06 2008
+++ (empty file)
@@ -1,681 +0,0 @@
-"""Generic socket server classes.
-
-This module tries to capture the various aspects of defining a server:
-
-For socket-based servers:
-
-- address family:
-        - AF_INET{,6}: IP (Internet Protocol) sockets (default)
-        - AF_UNIX: Unix domain sockets
-        - others, e.g. AF_DECNET are conceivable (see <socket.h>
-- socket type:
-        - SOCK_STREAM (reliable stream, e.g. TCP)
-        - SOCK_DGRAM (datagrams, e.g. UDP)
-
-For request-based servers (including socket-based):
-
-- client address verification before further looking at the request
-        (This is actually a hook for any processing that needs to look
-         at the request before anything else, e.g. logging)
-- how to handle multiple requests:
-        - synchronous (one request is handled at a time)
-        - forking (each request is handled by a new process)
-        - threading (each request is handled by a new thread)
-
-The classes in this module favor the server type that is simplest to
-write: a synchronous TCP/IP server.  This is bad class design, but
-save some typing.  (There's also the issue that a deep class hierarchy
-slows down method lookups.)
-
-There are five classes in an inheritance diagram, four of which represent
-synchronous servers of four types:
-
-        +------------+
-        | BaseServer |
-        +------------+
-              |
-              v
-        +-----------+        +------------------+
-        | TCPServer |------->| UnixStreamServer |
-        +-----------+        +------------------+
-              |
-              v
-        +-----------+        +--------------------+
-        | UDPServer |------->| UnixDatagramServer |
-        +-----------+        +--------------------+
-
-Note that UnixDatagramServer derives from UDPServer, not from
-UnixStreamServer -- the only difference between an IP and a Unix
-stream server is the address family, which is simply repeated in both
-unix server classes.
-
-Forking and threading versions of each type of server can be created
-using the ForkingMixIn and ThreadingMixIn mix-in classes.  For
-instance, a threading UDP server class is created as follows:
-
-        class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
-
-The Mix-in class must come first, since it overrides a method defined
-in UDPServer! Setting the various member variables also changes
-the behavior of the underlying server mechanism.
-
-To implement a service, you must derive a class from
-BaseRequestHandler and redefine its handle() method.  You can then run
-various versions of the service by combining one of the server classes
-with your request handler class.
-
-The request handler class must be different for datagram or stream
-services.  This can be hidden by using the request handler
-subclasses StreamRequestHandler or DatagramRequestHandler.
-
-Of course, you still have to use your head!
-
-For instance, it makes no sense to use a forking server if the service
-contains state in memory that can be modified by requests (since the
-modifications in the child process would never reach the initial state
-kept in the parent process and passed to each child).  In this case,
-you can use a threading server, but you will probably have to use
-locks to avoid two requests that come in nearly simultaneous to apply
-conflicting changes to the server state.
-
-On the other hand, if you are building e.g. an HTTP server, where all
-data is stored externally (e.g. in the file system), a synchronous
-class will essentially render the service "deaf" while one request is
-being handled -- which may be for a very long time if a client is slow
-to reqd all the data it has requested.  Here a threading or forking
-server is appropriate.
-
-In some cases, it may be appropriate to process part of a request
-synchronously, but to finish processing in a forked child depending on
-the request data.  This can be implemented by using a synchronous
-server and doing an explicit fork in the request handler class
-handle() method.
-
-Another approach to handling multiple simultaneous requests in an
-environment that supports neither threads nor fork (or where these are
-too expensive or inappropriate for the service) is to maintain an
-explicit table of partially finished requests and to use select() to
-decide which request to work on next (or whether to handle a new
-incoming request).  This is particularly important for stream services
-where each client can potentially be connected for a long time (if
-threads or subprocesses cannot be used).
-
-Future work:
-- Standard classes for Sun RPC (which uses either UDP or TCP)
-- Standard mix-in classes to implement various authentication
-  and encryption schemes
-- Standard framework for select-based multiplexing
-
-XXX Open problems:
-- What to do with out-of-band data?
-
-BaseServer:
-- split generic "request" functionality out into BaseServer class.
-  Copyright (C) 2000  Luke Kenneth Casson Leighton <lkcl at samba.org>
-
-  example: read entries from a SQL database (requires overriding
-  get_request() to return a table entry from the database).
-  entry is processed by a RequestHandlerClass.
-
-"""
-
-# Author of the BaseServer patch: Luke Kenneth Casson Leighton
-
-# XXX Warning!
-# There is a test suite for this module, but it cannot be run by the
-# standard regression test.
-# To run it manually, run Lib/test/test_socketserver.py.
-
-__version__ = "0.4"
-
-
-import socket
-import select
-import sys
-import os
-try:
-    import threading
-except ImportError:
-    import dummy_threading as threading
-
-__all__ = ["TCPServer","UDPServer","ForkingUDPServer","ForkingTCPServer",
-           "ThreadingUDPServer","ThreadingTCPServer","BaseRequestHandler",
-           "StreamRequestHandler","DatagramRequestHandler",
-           "ThreadingMixIn", "ForkingMixIn"]
-if hasattr(socket, "AF_UNIX"):
-    __all__.extend(["UnixStreamServer","UnixDatagramServer",
-                    "ThreadingUnixStreamServer",
-                    "ThreadingUnixDatagramServer"])
-
-class BaseServer:
-
-    """Base class for server classes.
-
-    Methods for the caller:
-
-    - __init__(server_address, RequestHandlerClass)
-    - serve_forever(poll_interval=0.5)
-    - shutdown()
-    - handle_request()  # if you do not use serve_forever()
-    - fileno() -> int   # for select()
-
-    Methods that may be overridden:
-
-    - server_bind()
-    - server_activate()
-    - get_request() -> request, client_address
-    - handle_timeout()
-    - verify_request(request, client_address)
-    - server_close()
-    - process_request(request, client_address)
-    - close_request(request)
-    - handle_error()
-
-    Methods for derived classes:
-
-    - finish_request(request, client_address)
-
-    Class variables that may be overridden by derived classes or
-    instances:
-
-    - timeout
-    - address_family
-    - socket_type
-    - allow_reuse_address
-
-    Instance variables:
-
-    - RequestHandlerClass
-    - socket
-
-    """
-
-    timeout = None
-
-    def __init__(self, server_address, RequestHandlerClass):
-        """Constructor.  May be extended, do not override."""
-        self.server_address = server_address
-        self.RequestHandlerClass = RequestHandlerClass
-        self.__is_shut_down = threading.Event()
-        self.__serving = False
-
-    def server_activate(self):
-        """Called by constructor to activate the server.
-
-        May be overridden.
-
-        """
-        pass
-
-    def serve_forever(self, poll_interval=0.5):
-        """Handle one request at a time until shutdown.
-
-        Polls for shutdown every poll_interval seconds. Ignores
-        self.timeout. If you need to do periodic tasks, do them in
-        another thread.
-        """
-        self.__serving = True
-        self.__is_shut_down.clear()
-        while self.__serving:
-            # XXX: Consider using another file descriptor or
-            # connecting to the socket to wake this up instead of
-            # polling. Polling reduces our responsiveness to a
-            # shutdown request and wastes cpu at all other times.
-            r, w, e = select.select([self], [], [], poll_interval)
-            if r:
-                self._handle_request_noblock()
-        self.__is_shut_down.set()
-
-    def shutdown(self):
-        """Stops the serve_forever loop.
-
-        Blocks until the loop has finished. This must be called while
-        serve_forever() is running in another thread, or it will
-        deadlock.
-        """
-        self.__serving = False
-        self.__is_shut_down.wait()
-
-    # The distinction between handling, getting, processing and
-    # finishing a request is fairly arbitrary.  Remember:
-    #
-    # - handle_request() is the top-level call.  It calls
-    #   select, get_request(), verify_request() and process_request()
-    # - get_request() is different for stream or datagram sockets
-    # - process_request() is the place that may fork a new process
-    #   or create a new thread to finish the request
-    # - finish_request() instantiates the request handler class;
-    #   this constructor will handle the request all by itself
-
-    def handle_request(self):
-        """Handle one request, possibly blocking.
-
-        Respects self.timeout.
-        """
-        # Support people who used socket.settimeout() to escape
-        # handle_request before self.timeout was available.
-        timeout = self.socket.gettimeout()
-        if timeout is None:
-            timeout = self.timeout
-        elif self.timeout is not None:
-            timeout = min(timeout, self.timeout)
-        fd_sets = select.select([self], [], [], timeout)
-        if not fd_sets[0]:
-            self.handle_timeout()
-            return
-        self._handle_request_noblock()
-
-    def _handle_request_noblock(self):
-        """Handle one request, without blocking.
-
-        I assume that select.select has returned that the socket is
-        readable before this function was called, so there should be
-        no risk of blocking in get_request().
-        """
-        try:
-            request, client_address = self.get_request()
-        except socket.error:
-            return
-        if self.verify_request(request, client_address):
-            try:
-                self.process_request(request, client_address)
-            except:
-                self.handle_error(request, client_address)
-                self.close_request(request)
-
-    def handle_timeout(self):
-        """Called if no new request arrives within self.timeout.
-
-        Overridden by ForkingMixIn.
-        """
-        pass
-
-    def verify_request(self, request, client_address):
-        """Verify the request.  May be overridden.
-
-        Return True if we should proceed with this request.
-
-        """
-        return True
-
-    def process_request(self, request, client_address):
-        """Call finish_request.
-
-        Overridden by ForkingMixIn and ThreadingMixIn.
-
-        """
-        self.finish_request(request, client_address)
-        self.close_request(request)
-
-    def server_close(self):
-        """Called to clean-up the server.
-
-        May be overridden.
-
-        """
-        pass
-
-    def finish_request(self, request, client_address):
-        """Finish one request by instantiating RequestHandlerClass."""
-        self.RequestHandlerClass(request, client_address, self)
-
-    def close_request(self, request):
-        """Called to clean up an individual request."""
-        pass
-
-    def handle_error(self, request, client_address):
-        """Handle an error gracefully.  May be overridden.
-
-        The default is to print a traceback and continue.
-
-        """
-        print '-'*40
-        print 'Exception happened during processing of request from',
-        print client_address
-        import traceback
-        traceback.print_exc() # XXX But this goes to stderr!
-        print '-'*40
-
-
-class TCPServer(BaseServer):
-
-    """Base class for various socket-based server classes.
-
-    Defaults to synchronous IP stream (i.e., TCP).
-
-    Methods for the caller:
-
-    - __init__(server_address, RequestHandlerClass, bind_and_activate=True)
-    - serve_forever(poll_interval=0.5)
-    - shutdown()
-    - handle_request()  # if you don't use serve_forever()
-    - fileno() -> int   # for select()
-
-    Methods that may be overridden:
-
-    - server_bind()
-    - server_activate()
-    - get_request() -> request, client_address
-    - handle_timeout()
-    - verify_request(request, client_address)
-    - process_request(request, client_address)
-    - close_request(request)
-    - handle_error()
-
-    Methods for derived classes:
-
-    - finish_request(request, client_address)
-
-    Class variables that may be overridden by derived classes or
-    instances:
-
-    - timeout
-    - address_family
-    - socket_type
-    - request_queue_size (only for stream sockets)
-    - allow_reuse_address
-
-    Instance variables:
-
-    - server_address
-    - RequestHandlerClass
-    - socket
-
-    """
-
-    address_family = socket.AF_INET
-
-    socket_type = socket.SOCK_STREAM
-
-    request_queue_size = 5
-
-    allow_reuse_address = False
-
-    def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
-        """Constructor.  May be extended, do not override."""
-        BaseServer.__init__(self, server_address, RequestHandlerClass)
-        self.socket = socket.socket(self.address_family,
-                                    self.socket_type)
-        if bind_and_activate:
-            self.server_bind()
-            self.server_activate()
-
-    def server_bind(self):
-        """Called by constructor to bind the socket.
-
-        May be overridden.
-
-        """
-        if self.allow_reuse_address:
-            self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-        self.socket.bind(self.server_address)
-        self.server_address = self.socket.getsockname()
-
-    def server_activate(self):
-        """Called by constructor to activate the server.
-
-        May be overridden.
-
-        """
-        self.socket.listen(self.request_queue_size)
-
-    def server_close(self):
-        """Called to clean-up the server.
-
-        May be overridden.
-
-        """
-        self.socket.close()
-
-    def fileno(self):
-        """Return socket file number.
-
-        Interface required by select().
-
-        """
-        return self.socket.fileno()
-
-    def get_request(self):
-        """Get the request and client address from the socket.
-
-        May be overridden.
-
-        """
-        return self.socket.accept()
-
-    def close_request(self, request):
-        """Called to clean up an individual request."""
-        request.close()
-
-
-class UDPServer(TCPServer):
-
-    """UDP server class."""
-
-    allow_reuse_address = False
-
-    socket_type = socket.SOCK_DGRAM
-
-    max_packet_size = 8192
-
-    def get_request(self):
-        data, client_addr = self.socket.recvfrom(self.max_packet_size)
-        return (data, self.socket), client_addr
-
-    def server_activate(self):
-        # No need to call listen() for UDP.
-        pass
-
-    def close_request(self, request):
-        # No need to close anything.
-        pass
-
-class ForkingMixIn:
-
-    """Mix-in class to handle each request in a new process."""
-
-    timeout = 300
-    active_children = None
-    max_children = 40
-
-    def collect_children(self):
-        """Internal routine to wait for children that have exited."""
-        if self.active_children is None: return
-        while len(self.active_children) >= self.max_children:
-            # XXX: This will wait for any child process, not just ones
-            # spawned by this library. This could confuse other
-            # libraries that expect to be able to wait for their own
-            # children.
-            try:
-                pid, status = os.waitpid(0, options=0)
-            except os.error:
-                pid = None
-            if pid not in self.active_children: continue
-            self.active_children.remove(pid)
-
-        # XXX: This loop runs more system calls than it ought
-        # to. There should be a way to put the active_children into a
-        # process group and then use os.waitpid(-pgid) to wait for any
-        # of that set, but I couldn't find a way to allocate pgids
-        # that couldn't collide.
-        for child in self.active_children:
-            try:
-                pid, status = os.waitpid(child, os.WNOHANG)
-            except os.error:
-                pid = None
-            if not pid: continue
-            try:
-                self.active_children.remove(pid)
-            except ValueError, e:
-                raise ValueError('%s. x=%d and list=%r' % (e.message, pid,
-                                                           self.active_children))
-
-    def handle_timeout(self):
-        """Wait for zombies after self.timeout seconds of inactivity.
-
-        May be extended, do not override.
-        """
-        self.collect_children()
-
-    def process_request(self, request, client_address):
-        """Fork a new subprocess to process the request."""
-        self.collect_children()
-        pid = os.fork()
-        if pid:
-            # Parent process
-            if self.active_children is None:
-                self.active_children = []
-            self.active_children.append(pid)
-            self.close_request(request)
-            return
-        else:
-            # Child process.
-            # This must never return, hence os._exit()!
-            try:
-                self.finish_request(request, client_address)
-                os._exit(0)
-            except:
-                try:
-                    self.handle_error(request, client_address)
-                finally:
-                    os._exit(1)
-
-
-class ThreadingMixIn:
-    """Mix-in class to handle each request in a new thread."""
-
-    # Decides how threads will act upon termination of the
-    # main process
-    daemon_threads = False
-
-    def process_request_thread(self, request, client_address):
-        """Same as in BaseServer but as a thread.
-
-        In addition, exception handling is done here.
-
-        """
-        try:
-            self.finish_request(request, client_address)
-            self.close_request(request)
-        except:
-            self.handle_error(request, client_address)
-            self.close_request(request)
-
-    def process_request(self, request, client_address):
-        """Start a new thread to process the request."""
-        t = threading.Thread(target = self.process_request_thread,
-                             args = (request, client_address))
-        if self.daemon_threads:
-            t.setDaemon (1)
-        t.start()
-
-
-class ForkingUDPServer(ForkingMixIn, UDPServer): pass
-class ForkingTCPServer(ForkingMixIn, TCPServer): pass
-
-class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
-class ThreadingTCPServer(ThreadingMixIn, TCPServer): pass
-
-if hasattr(socket, 'AF_UNIX'):
-
-    class UnixStreamServer(TCPServer):
-        address_family = socket.AF_UNIX
-
-    class UnixDatagramServer(UDPServer):
-        address_family = socket.AF_UNIX
-
-    class ThreadingUnixStreamServer(ThreadingMixIn, UnixStreamServer): pass
-
-    class ThreadingUnixDatagramServer(ThreadingMixIn, UnixDatagramServer): pass
-
-class BaseRequestHandler:
-
-    """Base class for request handler classes.
-
-    This class is instantiated for each request to be handled.  The
-    constructor sets the instance variables request, client_address
-    and server, and then calls the handle() method.  To implement a
-    specific service, all you need to do is to derive a class which
-    defines a handle() method.
-
-    The handle() method can find the request as self.request, the
-    client address as self.client_address, and the server (in case it
-    needs access to per-server information) as self.server.  Since a
-    separate instance is created for each request, the handle() method
-    can define arbitrary other instance variariables.
-
-    """
-
-    def __init__(self, request, client_address, server):
-        self.request = request
-        self.client_address = client_address
-        self.server = server
-        try:
-            self.setup()
-            self.handle()
-            self.finish()
-        finally:
-            sys.exc_traceback = None    # Help garbage collection
-
-    def setup(self):
-        pass
-
-    def handle(self):
-        pass
-
-    def finish(self):
-        pass
-
-
-# The following two classes make it possible to use the same service
-# class for stream or datagram servers.
-# Each class sets up these instance variables:
-# - rfile: a file object from which receives the request is read
-# - wfile: a file object to which the reply is written
-# When the handle() method returns, wfile is flushed properly
-
-
-class StreamRequestHandler(BaseRequestHandler):
-
-    """Define self.rfile and self.wfile for stream sockets."""
-
-    # Default buffer sizes for rfile, wfile.
-    # We default rfile to buffered because otherwise it could be
-    # really slow for large data (a getc() call per byte); we make
-    # wfile unbuffered because (a) often after a write() we want to
-    # read and we need to flush the line; (b) big writes to unbuffered
-    # files are typically optimized by stdio even when big reads
-    # aren't.
-    rbufsize = -1
-    wbufsize = 0
-
-    def setup(self):
-        self.connection = self.request
-        self.rfile = self.connection.makefile('rb', self.rbufsize)
-        self.wfile = self.connection.makefile('wb', self.wbufsize)
-
-    def finish(self):
-        if not self.wfile.closed:
-            self.wfile.flush()
-        self.wfile.close()
-        self.rfile.close()
-
-
-class DatagramRequestHandler(BaseRequestHandler):
-
-    # XXX Regrettably, I cannot get this working on Linux;
-    # s.recvfrom() doesn't return a meaningful client address.
-
-    """Define self.rfile and self.wfile for datagram sockets."""
-
-    def setup(self):
-        try:
-            from cStringIO import StringIO
-        except ImportError:
-            from StringIO import StringIO
-        self.packet, self.socket = self.request
-        self.rfile = StringIO(self.packet)
-        self.wfile = StringIO()
-
-    def finish(self):
-        self.socket.sendto(self.wfile.getvalue(), self.client_address)

Modified: python/branches/tlee-ast-optimize/Lib/bdb.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bdb.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bdb.py	Thu May 15 00:25:06 2008
@@ -37,9 +37,7 @@
         import linecache
         linecache.checkcache()
         self.botframe = None
-        self.stopframe = None
-        self.returnframe = None
-        self.quitting = 0
+        self._set_stopinfo(None, None)
 
     def trace_dispatch(self, frame, event, arg):
         if self.quitting:
@@ -100,7 +98,7 @@
         # (CT) stopframe may now also be None, see dispatch_call.
         # (CT) the former test for None is therefore removed from here.
         if frame is self.stopframe:
-            return True
+            return frame.f_lineno >= self.stoplineno
         while frame is not None and frame is not self.stopframe:
             if frame is self.botframe:
                 return True
@@ -157,26 +155,31 @@
         but only if we are to stop at or just below this level."""
         pass
 
+    def _set_stopinfo(self, stopframe, returnframe, stoplineno=-1):
+        self.stopframe = stopframe
+        self.returnframe = returnframe
+        self.quitting = 0
+        self.stoplineno = stoplineno
+
     # Derived classes and clients can call the following methods
     # to affect the stepping state.
 
+    def set_until(self, frame): #the name "until" is borrowed from gdb
+        """Stop when the line with the line no greater than the current one is
+        reached or when returning from current frame"""
+        self._set_stopinfo(frame, frame, frame.f_lineno+1)
+
     def set_step(self):
         """Stop after one line of code."""
-        self.stopframe = None
-        self.returnframe = None
-        self.quitting = 0
+        self._set_stopinfo(None,None)
 
     def set_next(self, frame):
         """Stop on the next line in or below the given frame."""
-        self.stopframe = frame
-        self.returnframe = None
-        self.quitting = 0
+        self._set_stopinfo(frame, None)
 
     def set_return(self, frame):
         """Stop when returning from the given frame."""
-        self.stopframe = frame.f_back
-        self.returnframe = frame
-        self.quitting = 0
+        self._set_stopinfo(frame.f_back, frame)
 
     def set_trace(self, frame=None):
         """Start debugging from `frame`.
@@ -195,9 +198,7 @@
 
     def set_continue(self):
         # Don't stop except at breakpoints or when finished
-        self.stopframe = self.botframe
-        self.returnframe = None
-        self.quitting = 0
+        self._set_stopinfo(self.botframe, None)
         if not self.breaks:
             # no breakpoints; run without debugger overhead
             sys.settrace(None)

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/__init__.py	Thu May 15 00:25:06 2008
@@ -33,10 +33,10 @@
 #----------------------------------------------------------------------
 
 
-"""Support for BerkeleyDB 3.3 through 4.4 with a simple interface.
+"""Support for Berkeley DB 3.3 through 4.6 with a simple interface.
 
 For the full featured object oriented interface use the bsddb.db module
-instead.  It mirrors the Sleepycat BerkeleyDB C API.
+instead.  It mirrors the Oracle Berkeley DB C API.
 """
 
 try:
@@ -188,7 +188,7 @@
                 self.saved_dbc_key = None
 
     # This method is needed for all non-cursor DB calls to avoid
-    # BerkeleyDB deadlocks (due to being opened with DB_INIT_LOCK
+    # Berkeley DB deadlocks (due to being opened with DB_INIT_LOCK
     # and DB_THREAD to be thread safe) when intermixing database
     # operations that use the cursor internally with those that don't.
     def _closeCursors(self, save=1):
@@ -372,7 +372,7 @@
     elif flag == 'n':
         flags = db.DB_CREATE
         #flags = db.DB_CREATE | db.DB_TRUNCATE
-        # we used db.DB_TRUNCATE flag for this before but BerkeleyDB
+        # we used db.DB_TRUNCATE flag for this before but Berkeley DB
         # 4.2.52 changed to disallowed truncate with txn environments.
         if file is not None and os.path.isfile(file):
             os.unlink(file)
@@ -385,10 +385,10 @@
 
 # This is a silly little hack that allows apps to continue to use the
 # DB_THREAD flag even on systems without threads without freaking out
-# BerkeleyDB.
+# Berkeley DB.
 #
 # This assumes that if Python was built with thread support then
-# BerkeleyDB was too.
+# Berkeley DB was too.
 
 try:
     import thread

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/dbshelve.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/dbshelve.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/dbshelve.py	Thu May 15 00:25:06 2008
@@ -37,9 +37,18 @@
 #DictMixin was added
 if sys.version_info[:3] >= (2, 3, 0):
     HIGHEST_PROTOCOL = cPickle.HIGHEST_PROTOCOL
-    def _dumps(object, protocol):
-        return cPickle.dumps(object, protocol=protocol)
+# In python 2.3.*, "cPickle.dumps" accepts no
+# named parameters. "pickle.dumps" accepts them,
+# so this seems a bug.
+    if sys.version_info[:3] < (2, 4, 0):
+        def _dumps(object, protocol):
+            return cPickle.dumps(object, protocol)
+    else :
+        def _dumps(object, protocol):
+            return cPickle.dumps(object, protocol=protocol)
+
     from UserDict import DictMixin
+
 else:
     HIGHEST_PROTOCOL = None
     def _dumps(object, protocol):
@@ -133,7 +142,7 @@
 
 
     def keys(self, txn=None):
-        if txn is not None:
+        if txn != None:
             return self.db.keys(txn)
         else:
             return self.db.keys()
@@ -157,7 +166,7 @@
 
 
     def items(self, txn=None):
-        if txn is not None:
+        if txn != None:
             items = self.db.items(txn)
         else:
             items = self.db.items()
@@ -168,7 +177,7 @@
         return newitems
 
     def values(self, txn=None):
-        if txn is not None:
+        if txn != None:
             values = self.db.values(txn)
         else:
             values = self.db.values()

Deleted: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_1413192.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_1413192.py	Thu May 15 00:25:06 2008
+++ (empty file)
@@ -1,48 +0,0 @@
-# http://bugs.python.org/issue1413192
-#
-# See the bug report for details.
-# The problem was that the env was deallocated prior to the txn.
-
-import shutil
-import tempfile
-from test.test_support import catch_warning
-import warnings
-
-try:
-    # For Pythons w/distutils and add-on pybsddb
-    from bsddb3 import db
-except ImportError:
-    # For Python >= 2.3 builtin bsddb distribution
-    from bsddb import db
-
-env_name = tempfile.mkdtemp()
-
-# Wrap test operation in a class so we can control destruction rather than
-# waiting for the controlling Python executable to exit
-
-class Context:
-
-    def __init__(self):
-        self.env = db.DBEnv()
-        self.env.open(env_name,
-                      db.DB_CREATE | db.DB_INIT_TXN | db.DB_INIT_MPOOL)
-        self.the_txn = self.env.txn_begin()
-
-        self.map = db.DB(self.env)
-        self.map.open('xxx.db', "p",
-                      db.DB_HASH, db.DB_CREATE, 0666, txn=self.the_txn)
-        del self.env
-        del self.the_txn
-
-
-with catch_warning():
-    warnings.filterwarnings('ignore', 'DBTxn aborted in destructor')
-    context = Context()
-    del context
-
-
-# try not to leave a turd
-try:
-    shutil.rmtree(env_name)
-except EnvironmentError:
-    pass

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_all.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_all.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_all.py	Thu May 15 00:25:06 2008
@@ -11,6 +11,11 @@
     # For Python 2.3
     from bsddb import db
 
+try:
+    from bsddb3 import test_support
+except ImportError:
+    from test import test_support
+
 verbose = 0
 if 'verbose' in sys.argv:
     verbose = 1
@@ -33,6 +38,53 @@
     print '-=' * 38
 
 
+def get_new_path(name) :
+    get_new_path.mutex.acquire()
+    try :
+        import os
+        path=os.path.join(get_new_path.prefix,
+                name+"_"+str(os.getpid())+"_"+str(get_new_path.num))
+        get_new_path.num+=1
+    finally :
+        get_new_path.mutex.release()
+    return path
+
+def get_new_environment_path() :
+    path=get_new_path("environment")
+    import os
+    try:
+        os.makedirs(path,mode=0700)
+    except os.error:
+        test_support.rmtree(path)
+        os.makedirs(path)
+    return path
+
+def get_new_database_path() :
+    path=get_new_path("database")
+    import os
+    if os.path.exists(path) :
+        os.remove(path)
+    return path
+
+
+get_new_path.prefix="/tmp/z-Berkeley_DB"
+get_new_path.num=0
+
+try :
+    import threading
+    get_new_path.mutex=threading.Lock()
+    del threading
+except ImportError:
+    class Lock(object) :
+        def acquire(self) :
+            pass
+        def release(self) :
+            pass
+    get_new_path.mutex=Lock()
+    del Lock
+
+
+
 class PrintInfoFakeTest(unittest.TestCase):
     def testPrintVersions(self):
         print_versions()
@@ -60,7 +112,9 @@
         'test_dbobj',
         'test_dbshelve',
         'test_dbtables',
-        'test_env_close',
+        'test_early_close',
+        'test_distributed_transactions',
+        'test_replication',
         'test_get_none',
         'test_join',
         'test_lock',

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_associate.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_associate.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_associate.py	Thu May 15 00:25:06 2008
@@ -3,7 +3,6 @@
 """
 
 import sys, os, string
-import tempfile
 import time
 from pprint import pprint
 
@@ -14,7 +13,7 @@
     have_threads = 0
 
 import unittest
-from test_all import verbose
+from test_all import verbose, get_new_environment_path
 
 try:
     # For Pythons w/distutils pybsddb
@@ -96,17 +95,9 @@
 class AssociateErrorTestCase(unittest.TestCase):
     def setUp(self):
         self.filename = self.__class__.__name__ + '.db'
-        homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        self.homeDir = homeDir
-        try:
-            os.mkdir(homeDir)
-        except os.error:
-            import glob
-            files = glob.glob(os.path.join(self.homeDir, '*'))
-            for file in files:
-                os.remove(file)
+        self.homeDir = get_new_environment_path()
         self.env = db.DBEnv()
-        self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
 
     def tearDown(self):
         self.env.close()
@@ -127,7 +118,7 @@
         secDB.open(self.filename, "secondary", db.DB_BTREE, db.DB_CREATE)
 
         # dupDB has been configured to allow duplicates, it can't
-        # associate with a secondary.  BerkeleyDB will return an error.
+        # associate with a secondary.  Berkeley DB will return an error.
         try:
             def f(a,b): return a+b
             dupDB.associate(secDB, f)
@@ -152,27 +143,16 @@
 
     def setUp(self):
         self.filename = self.__class__.__name__ + '.db'
-        homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        self.homeDir = homeDir
-        try:
-            os.mkdir(homeDir)
-        except os.error:
-            import glob
-            files = glob.glob(os.path.join(self.homeDir, '*'))
-            for file in files:
-                os.remove(file)
+        self.homeDir = get_new_environment_path()
         self.env = db.DBEnv()
-        self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
                                db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags)
 
     def tearDown(self):
         self.closeDB()
         self.env.close()
         self.env = None
-        import glob
-        files = glob.glob(os.path.join(self.homeDir, '*'))
-        for file in files:
-            os.remove(file)
+        test_support.rmtree(self.homeDir)
 
     def addDataToDB(self, d, txn=None):
         for key, value in musicdata.items():
@@ -249,10 +229,10 @@
     def finish_test(self, secDB, txn=None):
         # 'Blues' should not be in the secondary database
         vals = secDB.pget('Blues', txn=txn)
-        assert vals == None, vals
+        self.assertEqual(vals, None, vals)
 
         vals = secDB.pget('Unknown', txn=txn)
-        assert vals[0] == 99 or vals[0] == '99', vals
+        self.assert_(vals[0] == 99 or vals[0] == '99', vals)
         vals[1].index('Unknown')
         vals[1].index('Unnamed')
         vals[1].index('unknown')
@@ -264,14 +244,14 @@
         rec = self.cur.first()
         while rec is not None:
             if type(self.keytype) == type(''):
-                assert string.atoi(rec[0])  # for primary db, key is a number
+                self.assert_(string.atoi(rec[0]))  # for primary db, key is a number
             else:
-                assert rec[0] and type(rec[0]) == type(0)
+                self.assert_(rec[0] and type(rec[0]) == type(0))
             count = count + 1
             if verbose:
                 print rec
             rec = self.cur.next()
-        assert count == len(musicdata) # all items accounted for
+        self.assertEqual(count, len(musicdata))  # all items accounted for
 
 
         if verbose:
@@ -281,29 +261,29 @@
 
         # test cursor pget
         vals = self.cur.pget('Unknown', flags=db.DB_LAST)
-        assert vals[1] == 99 or vals[1] == '99', vals
-        assert vals[0] == 'Unknown'
+        self.assert_(vals[1] == 99 or vals[1] == '99', vals)
+        self.assertEqual(vals[0], 'Unknown')
         vals[2].index('Unknown')
         vals[2].index('Unnamed')
         vals[2].index('unknown')
 
         vals = self.cur.pget('Unknown', data='wrong value', flags=db.DB_GET_BOTH)
-        assert vals == None, vals
+        self.assertEqual(vals, None, vals)
 
         rec = self.cur.first()
-        assert rec[0] == "Jazz"
+        self.assertEqual(rec[0], "Jazz")
         while rec is not None:
             count = count + 1
             if verbose:
                 print rec
             rec = self.cur.next()
         # all items accounted for EXCEPT for 1 with "Blues" genre
-        assert count == len(musicdata)-1
+        self.assertEqual(count, len(musicdata)-1)
 
         self.cur = None
 
     def getGenre(self, priKey, priData):
-        assert type(priData) == type("")
+        self.assertEqual(type(priData), type(""))
         if verbose:
             print 'getGenre key: %r data: %r' % (priKey, priData)
         genre = string.split(priData, '|')[2]
@@ -388,7 +368,7 @@
 
 
     def getGenre(self, priKey, priData):
-        assert type(priData) == type(())
+        self.assertEqual(type(priData), type(()))
         if verbose:
             print 'getGenre key: %r data: %r' % (priKey, priData)
         genre = priData[2]
@@ -419,6 +399,8 @@
         t2 = Thread(target = self.writer2,
                     args = (d, ))
 
+        t1.setDaemon(True)
+        t2.setDaemon(True)
         t1.start()
         t2.start()
         t1.join()

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_basics.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_basics.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_basics.py	Thu May 15 00:25:06 2008
@@ -6,7 +6,6 @@
 import os
 import errno
 import string
-import tempfile
 from pprint import pprint
 import unittest
 import time
@@ -23,7 +22,7 @@
 except ImportError:
     from test import test_support
 
-from test_all import verbose
+from test_all import verbose, get_new_environment_path, get_new_database_path
 
 DASH = '-'
 
@@ -38,8 +37,8 @@
             print 'bsddb.db.version(): %s' % (info, )
             print db.DB_VERSION_STRING
             print '-=' * 20
-        assert info == (db.DB_VERSION_MAJOR, db.DB_VERSION_MINOR,
-                        db.DB_VERSION_PATCH)
+        self.assertEqual(info, (db.DB_VERSION_MAJOR, db.DB_VERSION_MINOR,
+                        db.DB_VERSION_PATCH))
 
 #----------------------------------------------------------------------
 
@@ -57,27 +56,22 @@
 
     def setUp(self):
         if self.useEnv:
-            homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-            self.homeDir = homeDir
-            test_support.rmtree(homeDir)
-            os.mkdir(homeDir)
+            self.homeDir=get_new_environment_path()
             try:
                 self.env = db.DBEnv()
                 self.env.set_lg_max(1024*1024)
                 self.env.set_tx_max(30)
                 self.env.set_tx_timestamp(int(time.time()))
                 self.env.set_flags(self.envsetflags, 1)
-                self.env.open(homeDir, self.envflags | db.DB_CREATE)
-                tempfile.tempdir = homeDir
-                self.filename = os.path.split(tempfile.mktemp())[1]
-                tempfile.tempdir = None
+                self.env.open(self.homeDir, self.envflags | db.DB_CREATE)
+                self.filename = "test"
             # Yes, a bare except is intended, since we're re-raising the exc.
             except:
-                test_support.rmtree(homeDir)
+                test_support.rmtree(self.homeDir)
                 raise
         else:
             self.env = None
-            self.filename = tempfile.mktemp()
+            self.filename = get_new_database_path()
 
         # create and open the DB
         self.d = db.DB(self.env)
@@ -99,13 +93,6 @@
         if self.env is not None:
             self.env.close()
             test_support.rmtree(self.homeDir)
-            ## XXX(nnorwitz): is this comment stil valid?
-            ## Make a new DBEnv to remove the env files from the home dir.
-            ## (It can't be done while the env is open, nor after it has been
-            ## closed, so we make a new one to do it.)
-            #e = db.DBEnv()
-            #e.remove(self.homeDir)
-            #os.remove(os.path.join(self.homeDir, self.filename))
         else:
             os.remove(self.filename)
 
@@ -153,44 +140,44 @@
             if verbose:
                 print data
 
-        assert d.get('0321') == '0321-0321-0321-0321-0321'
+        self.assertEqual(d.get('0321'), '0321-0321-0321-0321-0321')
 
         # By default non-existant keys return None...
-        assert d.get('abcd') == None
+        self.assertEqual(d.get('abcd'), None)
 
         # ...but they raise exceptions in other situations.  Call
         # set_get_returns_none() to change it.
         try:
             d.delete('abcd')
         except db.DBNotFoundError, val:
-            assert val[0] == db.DB_NOTFOUND
+            self.assertEqual(val[0], db.DB_NOTFOUND)
             if verbose: print val
         else:
             self.fail("expected exception")
 
 
         d.put('abcd', 'a new record')
-        assert d.get('abcd') == 'a new record'
+        self.assertEqual(d.get('abcd'), 'a new record')
 
         d.put('abcd', 'same key')
         if self.dbsetflags & db.DB_DUP:
-            assert d.get('abcd') == 'a new record'
+            self.assertEqual(d.get('abcd'), 'a new record')
         else:
-            assert d.get('abcd') == 'same key'
+            self.assertEqual(d.get('abcd'), 'same key')
 
 
         try:
             d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE)
         except db.DBKeyExistError, val:
-            assert val[0] == db.DB_KEYEXIST
+            self.assertEqual(val[0], db.DB_KEYEXIST)
             if verbose: print val
         else:
             self.fail("expected exception")
 
         if self.dbsetflags & db.DB_DUP:
-            assert d.get('abcd') == 'a new record'
+            self.assertEqual(d.get('abcd'), 'a new record')
         else:
-            assert d.get('abcd') == 'same key'
+            self.assertEqual(d.get('abcd'), 'same key')
 
 
         d.sync()
@@ -204,28 +191,28 @@
             self.d.open(self.filename)
         d = self.d
 
-        assert d.get('0321') == '0321-0321-0321-0321-0321'
+        self.assertEqual(d.get('0321'), '0321-0321-0321-0321-0321')
         if self.dbsetflags & db.DB_DUP:
-            assert d.get('abcd') == 'a new record'
+            self.assertEqual(d.get('abcd'), 'a new record')
         else:
-            assert d.get('abcd') == 'same key'
+            self.assertEqual(d.get('abcd'), 'same key')
 
         rec = d.get_both('0555', '0555-0555-0555-0555-0555')
         if verbose:
             print rec
 
-        assert d.get_both('0555', 'bad data') == None
+        self.assertEqual(d.get_both('0555', 'bad data'), None)
 
         # test default value
         data = d.get('bad key', 'bad data')
-        assert data == 'bad data'
+        self.assertEqual(data, 'bad data')
 
         # any object can pass through
         data = d.get('bad key', self)
-        assert data == self
+        self.assertEqual(data, self)
 
         s = d.stat()
-        assert type(s) == type({})
+        self.assertEqual(type(s), type({}))
         if verbose:
             print 'd.stat() returned this dictionary:'
             pprint(s)
@@ -243,47 +230,47 @@
 
         for key in ['0002', '0101', '0401', '0701', '0998']:
             data = d[key]
-            assert data == self.makeData(key)
+            self.assertEqual(data, self.makeData(key))
             if verbose:
                 print data
 
-        assert len(d) == self._numKeys
+        self.assertEqual(len(d), self._numKeys)
         keys = d.keys()
-        assert len(keys) == self._numKeys
-        assert type(keys) == type([])
+        self.assertEqual(len(keys), self._numKeys)
+        self.assertEqual(type(keys), type([]))
 
         d['new record'] = 'a new record'
-        assert len(d) == self._numKeys+1
+        self.assertEqual(len(d), self._numKeys+1)
         keys = d.keys()
-        assert len(keys) == self._numKeys+1
+        self.assertEqual(len(keys), self._numKeys+1)
 
         d['new record'] = 'a replacement record'
-        assert len(d) == self._numKeys+1
+        self.assertEqual(len(d), self._numKeys+1)
         keys = d.keys()
-        assert len(keys) == self._numKeys+1
+        self.assertEqual(len(keys), self._numKeys+1)
 
         if verbose:
             print "the first 10 keys are:"
             pprint(keys[:10])
 
-        assert d['new record'] == 'a replacement record'
+        self.assertEqual(d['new record'], 'a replacement record')
 
-        assert d.has_key('0001') == 1
-        assert d.has_key('spam') == 0
+        self.assertEqual(d.has_key('0001'), 1)
+        self.assertEqual(d.has_key('spam'), 0)
 
         items = d.items()
-        assert len(items) == self._numKeys+1
-        assert type(items) == type([])
-        assert type(items[0]) == type(())
-        assert len(items[0]) == 2
+        self.assertEqual(len(items), self._numKeys+1)
+        self.assertEqual(type(items), type([]))
+        self.assertEqual(type(items[0]), type(()))
+        self.assertEqual(len(items[0]), 2)
 
         if verbose:
             print "the first 10 items are:"
             pprint(items[:10])
 
         values = d.values()
-        assert len(values) == self._numKeys+1
-        assert type(values) == type([])
+        self.assertEqual(len(values), self._numKeys+1)
+        self.assertEqual(type(values), type([]))
 
         if verbose:
             print "the first 10 values are:"
@@ -315,14 +302,15 @@
                 rec = c.next()
             except db.DBNotFoundError, val:
                 if get_raises_error:
-                    assert val[0] == db.DB_NOTFOUND
+                    self.assertEqual(val[0], db.DB_NOTFOUND)
                     if verbose: print val
                     rec = None
                 else:
                     self.fail("unexpected DBNotFoundError")
-            assert c.get_current_size() == len(c.current()[1]), "%s != len(%r)" % (c.get_current_size(), c.current()[1])
+            self.assertEqual(c.get_current_size(), len(c.current()[1]),
+                    "%s != len(%r)" % (c.get_current_size(), c.current()[1]))
 
-        assert count == self._numKeys
+        self.assertEqual(count, self._numKeys)
 
 
         rec = c.last()
@@ -335,49 +323,49 @@
                 rec = c.prev()
             except db.DBNotFoundError, val:
                 if get_raises_error:
-                    assert val[0] == db.DB_NOTFOUND
+                    self.assertEqual(val[0], db.DB_NOTFOUND)
                     if verbose: print val
                     rec = None
                 else:
                     self.fail("unexpected DBNotFoundError")
 
-        assert count == self._numKeys
+        self.assertEqual(count, self._numKeys)
 
         rec = c.set('0505')
         rec2 = c.current()
-        assert rec == rec2
-        assert rec[0] == '0505'
-        assert rec[1] == self.makeData('0505')
-        assert c.get_current_size() == len(rec[1])
+        self.assertEqual(rec, rec2)
+        self.assertEqual(rec[0], '0505')
+        self.assertEqual(rec[1], self.makeData('0505'))
+        self.assertEqual(c.get_current_size(), len(rec[1]))
 
         # make sure we get empty values properly
         rec = c.set('empty value')
-        assert rec[1] == ''
-        assert c.get_current_size() == 0
+        self.assertEqual(rec[1], '')
+        self.assertEqual(c.get_current_size(), 0)
 
         try:
             n = c.set('bad key')
         except db.DBNotFoundError, val:
-            assert val[0] == db.DB_NOTFOUND
+            self.assertEqual(val[0], db.DB_NOTFOUND)
             if verbose: print val
         else:
             if set_raises_error:
                 self.fail("expected exception")
-            if n is not None:
+            if n != None:
                 self.fail("expected None: %r" % (n,))
 
         rec = c.get_both('0404', self.makeData('0404'))
-        assert rec == ('0404', self.makeData('0404'))
+        self.assertEqual(rec, ('0404', self.makeData('0404')))
 
         try:
             n = c.get_both('0404', 'bad data')
         except db.DBNotFoundError, val:
-            assert val[0] == db.DB_NOTFOUND
+            self.assertEqual(val[0], db.DB_NOTFOUND)
             if verbose: print val
         else:
             if get_raises_error:
                 self.fail("expected exception")
-            if n is not None:
+            if n != None:
                 self.fail("expected None: %r" % (n,))
 
         if self.d.get_type() == db.DB_BTREE:
@@ -401,7 +389,7 @@
             rec = c.current()
         except db.DBKeyEmptyError, val:
             if get_raises_error:
-                assert val[0] == db.DB_KEYEMPTY
+                self.assertEqual(val[0], db.DB_KEYEMPTY)
                 if verbose: print val
             else:
                 self.fail("unexpected DBKeyEmptyError")
@@ -411,14 +399,14 @@
 
         c.next()
         c2 = c.dup(db.DB_POSITION)
-        assert c.current() == c2.current()
+        self.assertEqual(c.current(), c2.current())
 
         c2.put('', 'a new value', db.DB_CURRENT)
-        assert c.current() == c2.current()
-        assert c.current()[1] == 'a new value'
+        self.assertEqual(c.current(), c2.current())
+        self.assertEqual(c.current()[1], 'a new value')
 
         c2.put('', 'er', db.DB_CURRENT, dlen=0, doff=5)
-        assert c2.current()[1] == 'a newer value'
+        self.assertEqual(c2.current()[1], 'a newer value')
 
         c.close()
         c2.close()
@@ -446,7 +434,7 @@
                 # a bug may cause a NULL pointer dereference...
                 apply(getattr(c, method), args)
             except db.DBError, val:
-                assert val[0] == 0
+                self.assertEqual(val[0], 0)
                 if verbose: print val
             else:
                 self.fail("no exception raised when using a buggy cursor's"
@@ -471,7 +459,7 @@
                   self.__class__.__name__
 
         old = self.d.set_get_returns_none(0)
-        assert old == 2
+        self.assertEqual(old, 2)
         self.test03_SimpleCursorStuff(get_raises_error=1, set_raises_error=1)
 
     def test03b_SimpleCursorWithGetReturnsNone1(self):
@@ -493,9 +481,9 @@
                   self.__class__.__name__
 
         old = self.d.set_get_returns_none(1)
-        assert old == 2
+        self.assertEqual(old, 2)
         old = self.d.set_get_returns_none(2)
-        assert old == 1
+        self.assertEqual(old, 1)
         self.test03_SimpleCursorStuff(get_raises_error=0, set_raises_error=0)
 
     #----------------------------------------
@@ -510,23 +498,24 @@
         key = "partialTest"
         data = "1" * 1000 + "2" * 1000
         d.put(key, data)
-        assert d.get(key) == data
-        assert d.get(key, dlen=20, doff=990) == ("1" * 10) + ("2" * 10)
+        self.assertEqual(d.get(key), data)
+        self.assertEqual(d.get(key, dlen=20, doff=990),
+                ("1" * 10) + ("2" * 10))
 
         d.put("partialtest2", ("1" * 30000) + "robin" )
-        assert d.get("partialtest2", dlen=5, doff=30000) == "robin"
+        self.assertEqual(d.get("partialtest2", dlen=5, doff=30000), "robin")
 
         # There seems to be a bug in DB here...  Commented out the test for
         # now.
-        ##assert d.get("partialtest2", dlen=5, doff=30010) == ""
+        ##self.assertEqual(d.get("partialtest2", dlen=5, doff=30010), "")
 
         if self.dbsetflags != db.DB_DUP:
             # Partial put with duplicate records requires a cursor
             d.put(key, "0000", dlen=2000, doff=0)
-            assert d.get(key) == "0000"
+            self.assertEqual(d.get(key), "0000")
 
             d.put(key, "1111", dlen=1, doff=2)
-            assert d.get(key) == "0011110"
+            self.assertEqual(d.get(key), "0011110")
 
     #----------------------------------------
 
@@ -541,14 +530,14 @@
             #print "before ", i,
             d.put(key, "1" * i)
             #print "after",
-            assert d.get_size(key) == i
+            self.assertEqual(d.get_size(key), i)
             #print "done"
 
     #----------------------------------------
 
     def test06_Truncate(self):
         if db.version() < (3,3):
-            # truncate is a feature of BerkeleyDB 3.3 and above
+            # truncate is a feature of Berkeley DB 3.3 and above
             return
 
         d = self.d
@@ -558,9 +547,10 @@
 
         d.put("abcde", "ABCDE");
         num = d.truncate()
-        assert num >= 1, "truncate returned <= 0 on non-empty database"
+        self.assert_(num >= 1, "truncate returned <= 0 on non-empty database")
         num = d.truncate()
-        assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
+        self.assertEqual(num, 0,
+                "truncate on empty DB returned nonzero (%r)" % (num,))
 
     #----------------------------------------
 
@@ -625,6 +615,11 @@
 #----------------------------------------------------------------------
 
 class BasicTransactionTestCase(BasicTestCase):
+    import sys
+    if sys.version_info[:3] < (2, 4, 0):
+        def assertTrue(self, expr, msg=None):
+            self.failUnless(expr,msg=msg)
+
     dbopenflags = db.DB_THREAD | db.DB_AUTO_COMMIT
     useEnv = 1
     envflags = (db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK |
@@ -650,19 +645,21 @@
             print '\n', '-=' * 30
             print "Running %s.test06_Transactions..." % self.__class__.__name__
 
-        assert d.get('new rec', txn=self.txn) == None
+        self.assertEqual(d.get('new rec', txn=self.txn), None)
         d.put('new rec', 'this is a new record', self.txn)
-        assert d.get('new rec', txn=self.txn) == 'this is a new record'
+        self.assertEqual(d.get('new rec', txn=self.txn),
+                'this is a new record')
         self.txn.abort()
-        assert d.get('new rec') == None
+        self.assertEqual(d.get('new rec'), None)
 
         self.txn = self.env.txn_begin()
 
-        assert d.get('new rec', txn=self.txn) == None
+        self.assertEqual(d.get('new rec', txn=self.txn), None)
         d.put('new rec', 'this is a new record', self.txn)
-        assert d.get('new rec', txn=self.txn) == 'this is a new record'
+        self.assertEqual(d.get('new rec', txn=self.txn),
+                'this is a new record')
         self.txn.commit()
-        assert d.get('new rec') == 'this is a new record'
+        self.assertEqual(d.get('new rec'), 'this is a new record')
 
         self.txn = self.env.txn_begin()
         c = d.cursor(self.txn)
@@ -673,7 +670,7 @@
             if verbose and count % 100 == 0:
                 print rec
             rec = c.next()
-        assert count == self._numKeys+1
+        self.assertEqual(count, self._numKeys+1)
 
         c.close()                # Cursors *MUST* be closed before commit!
         self.txn.commit()
@@ -686,20 +683,20 @@
 
         if db.version() >= (4,0):
             statDict = self.env.log_stat(0);
-            assert statDict.has_key('magic')
-            assert statDict.has_key('version')
-            assert statDict.has_key('cur_file')
-            assert statDict.has_key('region_nowait')
+            self.assert_(statDict.has_key('magic'))
+            self.assert_(statDict.has_key('version'))
+            self.assert_(statDict.has_key('cur_file'))
+            self.assert_(statDict.has_key('region_nowait'))
 
         # must have at least one log file present:
         logs = self.env.log_archive(db.DB_ARCH_ABS | db.DB_ARCH_LOG)
-        assert logs != None
+        self.assertNotEqual(logs, None)
         for log in logs:
             if verbose:
                 print 'log file: ' + log
         if db.version() >= (4,2):
             logs = self.env.log_archive(db.DB_ARCH_REMOVE)
-            assert not logs
+            self.assertTrue(not logs)
 
         self.txn = self.env.txn_begin()
 
@@ -707,7 +704,7 @@
 
     def test07_TxnTruncate(self):
         if db.version() < (3,3):
-            # truncate is a feature of BerkeleyDB 3.3 and above
+            # truncate is a feature of Berkeley DB 3.3 and above
             return
 
         d = self.d
@@ -718,9 +715,10 @@
         d.put("abcde", "ABCDE");
         txn = self.env.txn_begin()
         num = d.truncate(txn)
-        assert num >= 1, "truncate returned <= 0 on non-empty database"
+        self.assert_(num >= 1, "truncate returned <= 0 on non-empty database")
         num = d.truncate(txn)
-        assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
+        self.assertEqual(num, 0,
+                "truncate on empty DB returned nonzero (%r)" % (num,))
         txn.commit()
 
     #----------------------------------------
@@ -766,20 +764,20 @@
             print "Running %s.test07_RecnoInBTree..." % self.__class__.__name__
 
         rec = d.get(200)
-        assert type(rec) == type(())
-        assert len(rec) == 2
+        self.assertEqual(type(rec), type(()))
+        self.assertEqual(len(rec), 2)
         if verbose:
             print "Record #200 is ", rec
 
         c = d.cursor()
         c.set('0200')
         num = c.get_recno()
-        assert type(num) == type(1)
+        self.assertEqual(type(num), type(1))
         if verbose:
             print "recno of d['0200'] is ", num
 
         rec = c.current()
-        assert c.set_recno(num) == rec
+        self.assertEqual(c.set_recno(num), rec)
 
         c.close()
 
@@ -806,23 +804,23 @@
         d.put("dup2", "after")
 
         data = d.get("dup1")
-        assert data == "The"
+        self.assertEqual(data, "The")
         if verbose:
             print data
 
         c = d.cursor()
         rec = c.set("dup1")
-        assert rec == ('dup1', 'The')
+        self.assertEqual(rec, ('dup1', 'The'))
 
         next = c.next()
-        assert next == ('dup1', 'quick')
+        self.assertEqual(next, ('dup1', 'quick'))
 
         rec = c.set("dup1")
         count = c.count()
-        assert count == 9
+        self.assertEqual(count, 9)
 
         next_dup = c.next_dup()
-        assert next_dup == ('dup1', 'quick')
+        self.assertEqual(next_dup, ('dup1', 'quick'))
 
         rec = c.set('dup1')
         while rec is not None:
@@ -832,7 +830,7 @@
 
         c.set('dup1')
         rec = c.next_nodup()
-        assert rec[0] != 'dup1'
+        self.assertNotEqual(rec[0], 'dup1')
         if verbose:
             print rec
 
@@ -912,7 +910,7 @@
             if verbose and (count % 50) == 0:
                 print rec
             rec = c1.next()
-        assert count == self._numKeys
+        self.assertEqual(count, self._numKeys)
 
         count = 0
         rec = c2.first()
@@ -921,7 +919,7 @@
             if verbose:
                 print rec
             rec = c2.next()
-        assert count == 9
+        self.assertEqual(count, 9)
 
         count = 0
         rec = c3.first()
@@ -930,7 +928,7 @@
             if verbose:
                 print rec
             rec = c3.next()
-        assert count == 52
+        self.assertEqual(count, 52)
 
 
         c1.close()

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_compare.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_compare.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_compare.py	Thu May 15 00:25:06 2008
@@ -4,7 +4,6 @@
 
 import sys, os, re
 import test_all
-import tempfile
 from cStringIO import StringIO
 
 import unittest
@@ -15,6 +14,8 @@
     # For Python 2.3
     from bsddb import db, dbshelve
 
+from test_all import get_new_environment_path, get_new_database_path
+
 try:
     from bsddb3 import test_support
 except ImportError:
@@ -57,23 +58,17 @@
 
     def setUp (self):
         self.filename = self.__class__.__name__ + '.db'
-        homeDir = os.path.join (tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        self.homeDir = homeDir
-        try:
-            os.mkdir (homeDir)
-        except os.error:
-            pass
-
-        env = db.DBEnv ()
-        env.open (homeDir,
+        self.homeDir = get_new_environment_path()
+        env = db.DBEnv()
+        env.open (self.homeDir,
                   db.DB_CREATE | db.DB_INIT_MPOOL
                   | db.DB_INIT_LOCK | db.DB_THREAD)
         self.env = env
 
     def tearDown (self):
-        self.closeDB ()
+        self.closeDB()
         if self.env is not None:
-            self.env.close ()
+            self.env.close()
             self.env = None
         test_support.rmtree(self.homeDir)
 
@@ -236,7 +231,7 @@
         self.createDB (my_compare)
         try:
             self.db.set_bt_compare (my_compare)
-            assert False, "this set should fail"
+            self.assert_(0, "this set should fail")
 
         except RuntimeError, msg:
             pass

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_compat.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_compat.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_compat.py	Thu May 15 00:25:06 2008
@@ -5,9 +5,9 @@
 
 import os, string
 import unittest
-import tempfile
 
-from test_all import verbose
+from test_all import verbose, get_new_database_path
+
 
 try:
     # For Pythons w/distutils pybsddb
@@ -16,10 +16,9 @@
     # For Python 2.3
     from bsddb import db, hashopen, btopen, rnopen
 
-
 class CompatibilityTestCase(unittest.TestCase):
     def setUp(self):
-        self.filename = tempfile.mktemp()
+        self.filename = get_new_database_path()
 
     def tearDown(self):
         try:
@@ -47,7 +46,7 @@
         if verbose:
             print '%s %s %s' % getTest
 
-        assert getTest[1] == 'quick', 'data mismatch!'
+        self.assertEqual(getTest[1], 'quick', 'data mismatch!')
 
         rv = f.set_location(3)
         if rv != (3, 'brown'):
@@ -120,13 +119,13 @@
             try:
                 rec = f.next()
             except KeyError:
-                assert rec == f.last(), 'Error, last <> last!'
+                self.assertEqual(rec, f.last(), 'Error, last <> last!')
                 f.previous()
                 break
             if verbose:
                 print rec
 
-        assert f.has_key('f'), 'Error, missing key!'
+        self.assert_(f.has_key('f'), 'Error, missing key!')
 
         # test that set_location() returns the next nearest key, value
         # on btree databases and raises KeyError on others.

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_cursor_pget_bug.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_cursor_pget_bug.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_cursor_pget_bug.py	Thu May 15 00:25:06 2008
@@ -1,5 +1,4 @@
 import unittest
-import tempfile
 import os, glob
 
 try:
@@ -9,12 +8,13 @@
     # For Python 2.3
     from bsddb import db
 
+from test_all import get_new_environment_path, get_new_database_path
+
 try:
     from bsddb3 import test_support
 except ImportError:
     from test import test_support
 
-
 #----------------------------------------------------------------------
 
 class pget_bugTestCase(unittest.TestCase):
@@ -22,11 +22,7 @@
     db_name = 'test-cursor_pget.db'
 
     def setUp(self):
-        self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        try:
-            os.mkdir(self.homeDir)
-        except os.error:
-            pass
+        self.homeDir = get_new_environment_path()
         self.env = db.DBEnv()
         self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
         self.primary_db = db.DB(self.env)

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbobj.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbobj.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbobj.py	Thu May 15 00:25:06 2008
@@ -1,7 +1,6 @@
 
 import os, string
 import unittest
-import tempfile
 
 try:
     # For Pythons w/distutils pybsddb
@@ -10,24 +9,21 @@
     # For Python 2.3
     from bsddb import db, dbobj
 
+from test_all import get_new_environment_path, get_new_database_path
+
 try:
     from bsddb3 import test_support
 except ImportError:
     from test import test_support
 
-
 #----------------------------------------------------------------------
 
 class dbobjTestCase(unittest.TestCase):
     """Verify that dbobj.DB and dbobj.DBEnv work properly"""
-    db_home = 'db_home'
     db_name = 'test-dbobj.db'
 
     def setUp(self):
-        homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        self.homeDir = homeDir
-        try: os.mkdir(homeDir)
-        except os.error: pass
+        self.homeDir = get_new_environment_path()
 
     def tearDown(self):
         if hasattr(self, 'db'):
@@ -48,10 +44,10 @@
         self.db = TestDB(self.env)
         self.db.open(self.db_name, db.DB_HASH, db.DB_CREATE)
         self.db.put('spam', 'eggs')
-        assert self.db.get('spam') == None, \
-               "overridden dbobj.DB.put() method failed [1]"
-        assert self.db.get('SPAM') == 'eggs', \
-               "overridden dbobj.DB.put() method failed [2]"
+        self.assertEqual(self.db.get('spam'), None,
+               "overridden dbobj.DB.put() method failed [1]")
+        self.assertEqual(self.db.get('SPAM'), 'eggs',
+               "overridden dbobj.DB.put() method failed [2]")
         self.db.close()
         self.env.close()
 
@@ -63,12 +59,12 @@
         # __setitem__
         self.db['spam'] = 'eggs'
         # __len__
-        assert len(self.db) == 1
+        self.assertEqual(len(self.db), 1)
         # __getitem__
-        assert self.db['spam'] == 'eggs'
+        self.assertEqual(self.db['spam'], 'eggs')
         # __del__
         del self.db['spam']
-        assert self.db.get('spam') == None, "dbobj __del__ failed"
+        self.assertEqual(self.db.get('spam'), None, "dbobj __del__ failed")
         self.db.close()
         self.env.close()
 

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbshelve.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbshelve.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbshelve.py	Thu May 15 00:25:06 2008
@@ -3,7 +3,7 @@
 """
 
 import os, string
-import tempfile, random
+import random
 from types import *
 import unittest
 
@@ -19,7 +19,8 @@
 except ImportError:
     from test import test_support
 
-from test_all import verbose
+from test_all import verbose, get_new_environment_path, get_new_database_path
+
 
 
 #----------------------------------------------------------------------
@@ -35,7 +36,7 @@
 
 class DBShelveTestCase(unittest.TestCase):
     def setUp(self):
-        self.filename = tempfile.mktemp()
+        self.filename = get_new_database_path()
         self.do_open()
 
     def tearDown(self):
@@ -91,15 +92,15 @@
             print "keys:", k
             print "stats:", s
 
-        assert 0 == d.has_key(self.mk('bad key'))
-        assert 1 == d.has_key(self.mk('IA'))
-        assert 1 == d.has_key(self.mk('OA'))
+        self.assertEqual(0, d.has_key(self.mk('bad key')))
+        self.assertEqual(1, d.has_key(self.mk('IA')))
+        self.assertEqual(1, d.has_key(self.mk('OA')))
 
         d.delete(self.mk('IA'))
         del d[self.mk('OA')]
-        assert 0 == d.has_key(self.mk('IA'))
-        assert 0 == d.has_key(self.mk('OA'))
-        assert len(d) == l-2
+        self.assertEqual(0, d.has_key(self.mk('IA')))
+        self.assertEqual(0, d.has_key(self.mk('OA')))
+        self.assertEqual(len(d), l-2)
 
         values = []
         for key in d.keys():
@@ -110,29 +111,29 @@
             self.checkrec(key, value)
 
         dbvalues = d.values()
-        assert len(dbvalues) == len(d.keys())
+        self.assertEqual(len(dbvalues), len(d.keys()))
         values.sort()
         dbvalues.sort()
-        assert values == dbvalues
+        self.assertEqual(values, dbvalues)
 
         items = d.items()
-        assert len(items) == len(values)
+        self.assertEqual(len(items), len(values))
 
         for key, value in items:
             self.checkrec(key, value)
 
-        assert d.get(self.mk('bad key')) == None
-        assert d.get(self.mk('bad key'), None) == None
-        assert d.get(self.mk('bad key'), 'a string') == 'a string'
-        assert d.get(self.mk('bad key'), [1, 2, 3]) == [1, 2, 3]
+        self.assertEqual(d.get(self.mk('bad key')), None)
+        self.assertEqual(d.get(self.mk('bad key'), None), None)
+        self.assertEqual(d.get(self.mk('bad key'), 'a string'), 'a string')
+        self.assertEqual(d.get(self.mk('bad key'), [1, 2, 3]), [1, 2, 3])
 
         d.set_get_returns_none(0)
         self.assertRaises(db.DBNotFoundError, d.get, self.mk('bad key'))
         d.set_get_returns_none(1)
 
         d.put(self.mk('new key'), 'new data')
-        assert d.get(self.mk('new key')) == 'new data'
-        assert d[self.mk('new key')] == 'new data'
+        self.assertEqual(d.get(self.mk('new key')), 'new data')
+        self.assertEqual(d[self.mk('new key')], 'new data')
 
 
 
@@ -156,7 +157,7 @@
             rec = c.next()
         del c
 
-        assert count == len(d)
+        self.assertEqual(count, len(d))
 
         count = 0
         c = d.cursor()
@@ -169,7 +170,7 @@
             self.checkrec(key, value)
             rec = c.prev()
 
-        assert count == len(d)
+        self.assertEqual(count, len(d))
 
         c.set(self.mk('SS'))
         key, value = c.current()
@@ -191,25 +192,25 @@
         # override this in a subclass if the key type is different
         x = key[1]
         if key[0] == 'S':
-            assert type(value) == StringType
-            assert value == 10 * x
+            self.assertEqual(type(value), StringType)
+            self.assertEqual(value, 10 * x)
 
         elif key[0] == 'I':
-            assert type(value) == IntType
-            assert value == ord(x)
+            self.assertEqual(type(value), IntType)
+            self.assertEqual(value, ord(x))
 
         elif key[0] == 'L':
-            assert type(value) == ListType
-            assert value == [x] * 10
+            self.assertEqual(type(value), ListType)
+            self.assertEqual(value, [x] * 10)
 
         elif key[0] == 'O':
-            assert type(value) == InstanceType
-            assert value.S == 10 * x
-            assert value.I == ord(x)
-            assert value.L == [x] * 10
+            self.assertEqual(type(value), InstanceType)
+            self.assertEqual(value.S, 10 * x)
+            self.assertEqual(value.I, ord(x))
+            self.assertEqual(value.L, [x] * 10)
 
         else:
-            raise AssertionError, 'Unknown key type, fix the test'
+            self.assert_(0, 'Unknown key type, fix the test')
 
 #----------------------------------------------------------------------
 
@@ -246,12 +247,9 @@
 
 class BasicEnvShelveTestCase(DBShelveTestCase):
     def do_open(self):
-        self.homeDir = homeDir = os.path.join(
-            tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        try: os.mkdir(homeDir)
-        except os.error: pass
         self.env = db.DBEnv()
-        self.env.open(homeDir, self.envflags | db.DB_INIT_MPOOL | db.DB_CREATE)
+        self.env.open(self.homeDir,
+                self.envflags | db.DB_INIT_MPOOL | db.DB_CREATE)
 
         self.filename = os.path.split(self.filename)[1]
         self.d = dbshelve.DBShelf(self.env)
@@ -263,6 +261,10 @@
         self.env.close()
 
 
+    def setUp(self) :
+        self.homeDir = get_new_environment_path()
+        DBShelveTestCase.setUp(self)
+
     def tearDown(self):
         self.do_close()
         test_support.rmtree(self.homeDir)

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbtables.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbtables.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_dbtables.py	Thu May 15 00:25:06 2008
@@ -21,16 +21,14 @@
 # $Id$
 
 import os, re
-import tempfile
 try:
     import cPickle
     pickle = cPickle
 except ImportError:
     import pickle
-import tempfile
 
 import unittest
-from test_all import verbose
+from test_all import verbose, get_new_environment_path, get_new_database_path
 
 try:
     # For Pythons w/distutils pybsddb
@@ -48,16 +46,12 @@
 #----------------------------------------------------------------------
 
 class TableDBTestCase(unittest.TestCase):
-    db_home = 'db_home'
     db_name = 'test-table.db'
 
     def setUp(self):
-        homeDir = tempfile.mkdtemp()
-        self.testHomeDir = homeDir
-        try: os.mkdir(homeDir)
-        except os.error: pass
+        self.testHomeDir = get_new_environment_path()
         self.tdb = dbtables.bsdTableDB(
-            filename='tabletest.db', dbhome=homeDir, create=1)
+            filename='tabletest.db', dbhome=self.testHomeDir, create=1)
 
     def tearDown(self):
         self.tdb.close()
@@ -323,7 +317,7 @@
         self.tdb.Insert(tabname, {'Type': 'Unknown', 'Access': '0'})
 
         def set_type(type):
-            if type is None:
+            if type == None:
                 return 'MP3'
             return type
 

Deleted: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_env_close.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_env_close.py	Thu May 15 00:25:06 2008
+++ (empty file)
@@ -1,107 +0,0 @@
-"""TestCases for checking that it does not segfault when a DBEnv object
-is closed before its DB objects.
-"""
-
-import os
-import tempfile
-import unittest
-
-try:
-    # For Pythons w/distutils pybsddb
-    from bsddb3 import db
-except ImportError:
-    # For Python 2.3
-    from bsddb import db
-
-try:
-    from bsddb3 import test_support
-except ImportError:
-    from test import test_support
-
-from test_all import verbose
-
-# We're going to get warnings in this module about trying to close the db when
-# its env is already closed.  Let's just ignore those.
-try:
-    import warnings
-except ImportError:
-    pass
-else:
-    warnings.filterwarnings('ignore',
-                            message='DB could not be closed in',
-                            category=RuntimeWarning)
-
-
-#----------------------------------------------------------------------
-
-class DBEnvClosedEarlyCrash(unittest.TestCase):
-    def setUp(self):
-        self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        try: os.mkdir(self.homeDir)
-        except os.error: pass
-        tempfile.tempdir = self.homeDir
-        self.filename = os.path.split(tempfile.mktemp())[1]
-        tempfile.tempdir = None
-
-    def tearDown(self):
-        test_support.rmtree(self.homeDir)
-
-    def test01_close_dbenv_before_db(self):
-        dbenv = db.DBEnv()
-        dbenv.open(self.homeDir,
-                   db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
-                   0666)
-
-        d = db.DB(dbenv)
-        d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
-
-        try:
-            dbenv.close()
-        except db.DBError:
-            try:
-                d.close()
-            except db.DBError:
-                return
-            assert 0, \
-                   "DB close did not raise an exception about its "\
-                   "DBEnv being trashed"
-
-        # XXX This may fail when using older versions of BerkeleyDB.
-        # E.g. 3.2.9 never raised the exception.
-        assert 0, "dbenv did not raise an exception about its DB being open"
-
-
-    def test02_close_dbenv_delete_db_success(self):
-        dbenv = db.DBEnv()
-        dbenv.open(self.homeDir,
-                   db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
-                   0666)
-
-        d = db.DB(dbenv)
-        d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
-
-        try:
-            dbenv.close()
-        except db.DBError:
-            pass  # good, it should raise an exception
-
-        del d
-        try:
-            import gc
-        except ImportError:
-            gc = None
-        if gc:
-            # force d.__del__ [DB_dealloc] to be called
-            gc.collect()
-
-
-#----------------------------------------------------------------------
-
-def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(DBEnvClosedEarlyCrash))
-    return suite
-
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_get_none.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_get_none.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_get_none.py	Thu May 15 00:25:06 2008
@@ -3,7 +3,6 @@
 """
 
 import os, string
-import tempfile
 import unittest
 
 try:
@@ -13,14 +12,14 @@
     # For Python 2.3
     from bsddb import db
 
-from test_all import verbose
+from test_all import verbose, get_new_database_path
 
 
 #----------------------------------------------------------------------
 
 class GetReturnsNoneTestCase(unittest.TestCase):
     def setUp(self):
-        self.filename = tempfile.mktemp()
+        self.filename = get_new_database_path()
 
     def tearDown(self):
         try:
@@ -38,10 +37,10 @@
             d.put(x, x * 40)
 
         data = d.get('bad key')
-        assert data == None
+        self.assertEqual(data, None)
 
         data = d.get('a')
-        assert data == 'a'*40
+        self.assertEqual(data, 'a'*40)
 
         count = 0
         c = d.cursor()
@@ -50,8 +49,8 @@
             count = count + 1
             rec = c.next()
 
-        assert rec == None
-        assert count == 52
+        self.assertEqual(rec, None)
+        self.assertEqual(count, 52)
 
         c.close()
         d.close()
@@ -69,7 +68,7 @@
         self.assertRaises(KeyError, d.get, 'bad key')
 
         data = d.get('a')
-        assert data == 'a'*40
+        self.assertEqual(data, 'a'*40)
 
         count = 0
         exceptionHappened = 0
@@ -83,9 +82,9 @@
                 exceptionHappened = 1
                 break
 
-        assert rec != None
-        assert exceptionHappened
-        assert count == 52
+        self.assertNotEqual(rec, None)
+        self.assert_(exceptionHappened)
+        self.assertEqual(count, 52)
 
         c.close()
         d.close()

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_join.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_join.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_join.py	Thu May 15 00:25:06 2008
@@ -2,13 +2,6 @@
 """
 
 import os
-import tempfile
-
-try:
-    from threading import Thread, currentThread
-    have_threads = 1
-except ImportError:
-    have_threads = 0
 
 import unittest
 from test_all import verbose
@@ -20,11 +13,14 @@
     # For Python 2.3
     from bsddb import db, dbshelve
 
+from test_all import get_new_environment_path, get_new_database_path
+
 try:
     from bsddb3 import test_support
 except ImportError:
     from test import test_support
 
+
 #----------------------------------------------------------------------
 
 ProductIndex = [
@@ -51,12 +47,9 @@
 
     def setUp(self):
         self.filename = self.__class__.__name__ + '.db'
-        homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        self.homeDir = homeDir
-        try: os.mkdir(homeDir)
-        except os.error: pass
+        self.homeDir = get_new_environment_path()
         self.env = db.DBEnv()
-        self.env.open(homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK )
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK )
 
     def tearDown(self):
         self.env.close()
@@ -87,7 +80,7 @@
             # Don't do the .set() in an assert, or you can get a bogus failure
             # when running python -O
             tmp = sCursor.set('red')
-            assert tmp
+            self.assert_(tmp)
 
             # FIXME: jCursor doesn't properly hold a reference to its
             # cursors, if they are closed before jcursor is used it

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_lock.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_lock.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_lock.py	Thu May 15 00:25:06 2008
@@ -2,7 +2,6 @@
 TestCases for testing the locking sub-system.
 """
 
-import tempfile
 import time
 
 try:
@@ -13,7 +12,7 @@
 
 
 import unittest
-from test_all import verbose
+from test_all import verbose, get_new_environment_path, get_new_database_path
 
 try:
     # For Pythons w/distutils pybsddb
@@ -31,9 +30,14 @@
 #----------------------------------------------------------------------
 
 class LockingTestCase(unittest.TestCase):
+    import sys
+    if sys.version_info[:3] < (2, 4, 0):
+        def assertTrue(self, expr, msg=None):
+            self.failUnless(expr,msg=msg)
+
 
     def setUp(self):
-        self.homeDir = tempfile.mkdtemp('.test_lock')
+        self.homeDir = get_new_environment_path()
         self.env = db.DBEnv()
         self.env.open(self.homeDir, db.DB_THREAD | db.DB_INIT_MPOOL |
                                     db.DB_INIT_LOCK | db.DB_CREATE)
@@ -55,7 +59,6 @@
         lock = self.env.lock_get(anID, "some locked thing", db.DB_LOCK_WRITE)
         if verbose:
             print "Aquired lock: %s" % lock
-        time.sleep(1)
         self.env.lock_put(lock)
         if verbose:
             print "Released lock: %s" % lock
@@ -70,38 +73,73 @@
 
         threads = []
         threads.append(Thread(target = self.theThread,
-                              args=(5, db.DB_LOCK_WRITE)))
+                              args=(db.DB_LOCK_WRITE,)))
         threads.append(Thread(target = self.theThread,
-                              args=(1, db.DB_LOCK_READ)))
+                              args=(db.DB_LOCK_READ,)))
         threads.append(Thread(target = self.theThread,
-                              args=(1, db.DB_LOCK_READ)))
+                              args=(db.DB_LOCK_READ,)))
         threads.append(Thread(target = self.theThread,
-                              args=(1, db.DB_LOCK_WRITE)))
+                              args=(db.DB_LOCK_WRITE,)))
         threads.append(Thread(target = self.theThread,
-                              args=(1, db.DB_LOCK_READ)))
+                              args=(db.DB_LOCK_READ,)))
         threads.append(Thread(target = self.theThread,
-                              args=(1, db.DB_LOCK_READ)))
+                              args=(db.DB_LOCK_READ,)))
         threads.append(Thread(target = self.theThread,
-                              args=(1, db.DB_LOCK_WRITE)))
+                              args=(db.DB_LOCK_WRITE,)))
         threads.append(Thread(target = self.theThread,
-                              args=(1, db.DB_LOCK_WRITE)))
+                              args=(db.DB_LOCK_WRITE,)))
         threads.append(Thread(target = self.theThread,
-                              args=(1, db.DB_LOCK_WRITE)))
+                              args=(db.DB_LOCK_WRITE,)))
 
         for t in threads:
+            t.setDaemon(True)
             t.start()
         for t in threads:
             t.join()
 
-    def test03_set_timeout(self):
-        # test that the set_timeout call works
-        if hasattr(self.env, 'set_timeout'):
-            self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
-            self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
-            self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
-            self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)
+    def test03_lock_timeout(self):
+        self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
+        self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
+        self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
+        self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)
+
+        def deadlock_detection() :
+            while not deadlock_detection.end :
+                deadlock_detection.count = \
+                    self.env.lock_detect(db.DB_LOCK_EXPIRE)
+                if deadlock_detection.count :
+                    while not deadlock_detection.end :
+                        pass
+                    break
+                time.sleep(0.01)
+
+        deadlock_detection.end=False
+        deadlock_detection.count=0
+        t=Thread(target=deadlock_detection)
+        t.setDaemon(True)
+        t.start()
+        self.env.set_timeout(100000, db.DB_SET_LOCK_TIMEOUT)
+        anID = self.env.lock_id()
+        anID2 = self.env.lock_id()
+        self.assertNotEqual(anID, anID2)
+        lock = self.env.lock_get(anID, "shared lock", db.DB_LOCK_WRITE)
+        start_time=time.time()
+        self.assertRaises(db.DBLockNotGrantedError,
+                self.env.lock_get,anID2, "shared lock", db.DB_LOCK_READ)
+        end_time=time.time()
+        deadlock_detection.end=True
+        self.assertTrue((end_time-start_time) >= 0.1)
+        self.env.lock_put(lock)
+        t.join()
+
+        if db.version() >= (4,0):
+            self.env.lock_id_free(anID)
+            self.env.lock_id_free(anID2)
 
-    def theThread(self, sleepTime, lockType):
+        if db.version() >= (4,6):
+            self.assertTrue(deadlock_detection.count>0)
+
+    def theThread(self, lockType):
         name = currentThread().getName()
         if lockType ==  db.DB_LOCK_WRITE:
             lt = "write"
@@ -112,15 +150,15 @@
         if verbose:
             print "%s: locker ID: %s" % (name, anID)
 
-        lock = self.env.lock_get(anID, "some locked thing", lockType)
-        if verbose:
-            print "%s: Aquired %s lock: %s" % (name, lt, lock)
-
-        time.sleep(sleepTime)
+        for i in xrange(1000) :
+            lock = self.env.lock_get(anID, "some locked thing", lockType)
+            if verbose:
+                print "%s: Aquired %s lock: %s" % (name, lt, lock)
+
+            self.env.lock_put(lock)
+            if verbose:
+                print "%s: Released %s lock: %s" % (name, lt, lock)
 
-        self.env.lock_put(lock)
-        if verbose:
-            print "%s: Released %s lock: %s" % (name, lt, lock)
         if db.version() >= (4,0):
             self.env.lock_id_free(anID)
 

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_misc.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_misc.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_misc.py	Thu May 15 00:25:06 2008
@@ -3,7 +3,6 @@
 
 import os
 import unittest
-import tempfile
 
 try:
     # For Pythons w/distutils pybsddb
@@ -12,6 +11,8 @@
     # For Python 2.3
     from bsddb import db, dbshelve, hashopen
 
+from test_all import get_new_environment_path, get_new_database_path
+
 try:
     from bsddb3 import test_support
 except ImportError:
@@ -22,12 +23,7 @@
 class MiscTestCase(unittest.TestCase):
     def setUp(self):
         self.filename = self.__class__.__name__ + '.db'
-        homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        self.homeDir = homeDir
-        try:
-            os.mkdir(homeDir)
-        except OSError:
-            pass
+        self.homeDir = get_new_environment_path()
 
     def tearDown(self):
         test_support.unlink(self.filename)
@@ -41,9 +37,9 @@
     def test02_db_home(self):
         env = db.DBEnv()
         # check for crash fixed when db_home is used before open()
-        assert env.db_home is None
+        self.assert_(env.db_home is None)
         env.open(self.homeDir, db.DB_CREATE)
-        assert self.homeDir == env.db_home
+        self.assertEqual(self.homeDir, env.db_home)
 
     def test03_repr_closed_db(self):
         db = hashopen(self.filename)
@@ -93,7 +89,7 @@
     def test_DB_set_flags_persists(self):
         if db.version() < (4,2):
             # The get_flags API required for this to work is only available
-            # in BerkeleyDB >= 4.2
+            # in Berkeley DB >= 4.2
             return
         try:
             db1 = db.DB()

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_pickle.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_pickle.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_pickle.py	Thu May 15 00:25:06 2008
@@ -6,7 +6,6 @@
 except ImportError:
     cPickle = None
 import unittest
-import tempfile
 
 try:
     # For Pythons w/distutils pybsddb
@@ -15,6 +14,8 @@
     # For Python 2.3
     from bsddb import db
 
+from test_all import get_new_environment_path, get_new_database_path
+
 try:
     from bsddb3 import test_support
 except ImportError:
@@ -25,14 +26,10 @@
 
 class pickleTestCase(unittest.TestCase):
     """Verify that DBError can be pickled and unpickled"""
-    db_home = 'db_home'
     db_name = 'test-dbobj.db'
 
     def setUp(self):
-        homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        self.homeDir = homeDir
-        try: os.mkdir(homeDir)
-        except os.error: pass
+        self.homeDir = get_new_environment_path()
 
     def tearDown(self):
         if hasattr(self, 'db'):
@@ -47,7 +44,7 @@
         self.db = db.DB(self.env)
         self.db.open(self.db_name, db.DB_HASH, db.DB_CREATE)
         self.db.put('spam', 'eggs')
-        assert self.db['spam'] == 'eggs'
+        self.assertEqual(self.db['spam'], 'eggs')
         try:
             self.db.put('spam', 'ham', flags=db.DB_NOOVERWRITE)
         except db.DBError, egg:

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_queue.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_queue.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_queue.py	Thu May 15 00:25:06 2008
@@ -3,7 +3,6 @@
 """
 
 import os, string
-import tempfile
 from pprint import pprint
 import unittest
 
@@ -14,14 +13,14 @@
     # For Python 2.3
     from bsddb import db
 
-from test_all import verbose
+from test_all import verbose, get_new_database_path
 
 
 #----------------------------------------------------------------------
 
 class SimpleQueueTestCase(unittest.TestCase):
     def setUp(self):
-        self.filename = tempfile.mktemp()
+        self.filename = get_new_database_path()
 
     def tearDown(self):
         try:
@@ -48,14 +47,14 @@
         for x in string.letters:
             d.append(x * 40)
 
-        assert len(d) == 52
+        self.assertEqual(len(d), 52)
 
         d.put(100, "some more data")
         d.put(101, "and some more ")
         d.put(75,  "out of order")
         d.put(1,   "replacement data")
 
-        assert len(d) == 55
+        self.assertEqual(len(d), 55)
 
         if verbose:
             print "before close" + '-' * 30
@@ -88,9 +87,9 @@
             print "after consume loop" + '-' * 30
             pprint(d.stat())
 
-        assert len(d) == 0, \
+        self.assertEqual(len(d), 0, \
                "if you see this message then you need to rebuild " \
-               "BerkeleyDB 3.1.17 with the patch in patches/qam_stat.diff"
+               "Berkeley DB 3.1.17 with the patch in patches/qam_stat.diff")
 
         d.close()
 
@@ -120,14 +119,14 @@
         for x in string.letters:
             d.append(x * 40)
 
-        assert len(d) == 52
+        self.assertEqual(len(d), 52)
 
         d.put(100, "some more data")
         d.put(101, "and some more ")
         d.put(75,  "out of order")
         d.put(1,   "replacement data")
 
-        assert len(d) == 55
+        self.assertEqual(len(d), 55)
 
         if verbose:
             print "before close" + '-' * 30

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_recno.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_recno.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_recno.py	Thu May 15 00:25:06 2008
@@ -3,11 +3,10 @@
 
 import os
 import errno
-import tempfile
 from pprint import pprint
 import unittest
 
-from test_all import verbose
+from test_all import verbose, get_new_environment_path, get_new_database_path
 
 try:
     # For Pythons w/distutils pybsddb
@@ -27,8 +26,13 @@
 #----------------------------------------------------------------------
 
 class SimpleRecnoTestCase(unittest.TestCase):
+    import sys
+    if sys.version_info[:3] < (2, 4, 0):
+        def assertFalse(self, expr, msg=None):
+            self.failIf(expr,msg=msg)
+
     def setUp(self):
-        self.filename = tempfile.mktemp()
+        self.filename = get_new_database_path()
         self.homeDir = None
 
     def tearDown(self):
@@ -46,8 +50,8 @@
 
         for x in letters:
             recno = d.append(x * 60)
-            assert type(recno) == type(0)
-            assert recno >= 1
+            self.assertEqual(type(recno), type(0))
+            self.assert_(recno >= 1)
             if verbose:
                 print recno,
 
@@ -62,13 +66,13 @@
             if verbose:
                 print data
 
-            assert type(data) == type("")
-            assert data == d.get(recno)
+            self.assertEqual(type(data), type(""))
+            self.assertEqual(data, d.get(recno))
 
         try:
             data = d[0]  # This should raise a KeyError!?!?!
         except db.DBInvalidArgError, val:
-            assert val[0] == db.EINVAL
+            self.assertEqual(val[0], db.EINVAL)
             if verbose: print val
         else:
             self.fail("expected exception")
@@ -94,35 +98,35 @@
             if get_returns_none:
                 self.fail("unexpected exception")
         else:
-            assert data == None
+            self.assertEqual(data, None)
 
         keys = d.keys()
         if verbose:
             print keys
-        assert type(keys) == type([])
-        assert type(keys[0]) == type(123)
-        assert len(keys) == len(d)
+        self.assertEqual(type(keys), type([]))
+        self.assertEqual(type(keys[0]), type(123))
+        self.assertEqual(len(keys), len(d))
 
         items = d.items()
         if verbose:
             pprint(items)
-        assert type(items) == type([])
-        assert type(items[0]) == type(())
-        assert len(items[0]) == 2
-        assert type(items[0][0]) == type(123)
-        assert type(items[0][1]) == type("")
-        assert len(items) == len(d)
+        self.assertEqual(type(items), type([]))
+        self.assertEqual(type(items[0]), type(()))
+        self.assertEqual(len(items[0]), 2)
+        self.assertEqual(type(items[0][0]), type(123))
+        self.assertEqual(type(items[0][1]), type(""))
+        self.assertEqual(len(items), len(d))
 
-        assert d.has_key(25)
+        self.assert_(d.has_key(25))
 
         del d[25]
-        assert not d.has_key(25)
+        self.assertFalse(d.has_key(25))
 
         d.delete(13)
-        assert not d.has_key(13)
+        self.assertFalse(d.has_key(13))
 
         data = d.get_both(26, "z" * 60)
-        assert data == "z" * 60, 'was %r' % data
+        self.assertEqual(data, "z" * 60, 'was %r' % data)
         if verbose:
             print data
 
@@ -146,7 +150,7 @@
 
         c.set(50)
         rec = c.current()
-        assert rec == (50, "a replacement record")
+        self.assertEqual(rec, (50, "a replacement record"))
         if verbose:
             print rec
 
@@ -157,7 +161,7 @@
         # test that non-existant key lookups work (and that
         # DBC_set_range doesn't have a memleak under valgrind)
         rec = c.set_range(999999)
-        assert rec == None
+        self.assertEqual(rec, None)
         if verbose:
             print rec
 
@@ -170,7 +174,7 @@
 
         # put a record beyond the consecutive end of the recno's
         d[100] = "way out there"
-        assert d[100] == "way out there"
+        self.assertEqual(d[100], "way out there")
 
         try:
             data = d[99]
@@ -185,7 +189,7 @@
             if get_returns_none:
                 self.fail("unexpected DBKeyEmptyError exception")
             else:
-                assert val[0] == db.DB_KEYEMPTY
+                self.assertEqual(val[0], db.DB_KEYEMPTY)
                 if verbose: print val
         else:
             if not get_returns_none:
@@ -207,7 +211,7 @@
         just a line in the file, but you can set a different record delimiter
         if needed.
         """
-        homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
+        homeDir = get_new_environment_path()
         self.homeDir = homeDir
         source = os.path.join(homeDir, 'test_recno.txt')
         if not os.path.isdir(homeDir):
@@ -236,7 +240,7 @@
             print data
             print text.split('\n')
 
-        assert text.split('\n') == data
+        self.assertEqual(text.split('\n'), data)
 
         # open as a DB again
         d = db.DB()
@@ -255,8 +259,8 @@
             print text
             print text.split('\n')
 
-        assert text.split('\n') == \
-             "The quick reddish-brown fox jumped over the comatose dog".split()
+        self.assertEqual(text.split('\n'),
+           "The quick reddish-brown fox jumped over the comatose dog".split())
 
     def test03_FixedLength(self):
         d = db.DB()
@@ -273,7 +277,7 @@
         try:                    # this one will fail
             d.append('bad' * 20)
         except db.DBInvalidArgError, val:
-            assert val[0] == db.EINVAL
+            self.assertEqual(val[0], db.EINVAL)
             if verbose: print val
         else:
             self.fail("expected exception")

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_sequence.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_sequence.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_sequence.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,5 @@
 import unittest
 import os
-import tempfile
 
 try:
     # For Pythons w/distutils pybsddb
@@ -13,18 +12,19 @@
 except ImportError:
     from test import test_support
 
+from test_all import get_new_environment_path, get_new_database_path
+
 
 class DBSequenceTest(unittest.TestCase):
+    import sys
+    if sys.version_info[:3] < (2, 4, 0):
+        def assertTrue(self, expr, msg=None):
+            self.failUnless(expr,msg=msg)
+
     def setUp(self):
         self.int_32_max = 0x100000000
-        self.homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        try:
-            os.mkdir(self.homeDir)
-        except os.error:
-            pass
-        tempfile.tempdir = self.homeDir
-        self.filename = os.path.split(tempfile.mktemp())[1]
-        tempfile.tempdir = None
+        self.homeDir = get_new_environment_path()
+        self.filename = "test"
 
         self.dbenv = db.DBEnv()
         self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0666)
@@ -100,6 +100,52 @@
                       'flags', 'cache_size', 'last_value', 'wait'):
             self.assertTrue(param in stat, "parameter %s isn't in stat info" % param)
 
+    if db.version() >= (4,7) :
+        # This code checks a crash solved in Berkeley DB 4.7
+        def test_stat_crash(self) :
+            d=db.DB()
+            d.open(None,dbtype=db.DB_HASH,flags=db.DB_CREATE)  # In RAM
+            seq = db.DBSequence(d, flags=0)
+
+            self.assertRaises(db.DBNotFoundError, seq.open,
+                    key='id', txn=None, flags=0)
+
+            self.assertRaises(db.DBNotFoundError, seq.stat)
+
+            d.close()
+
+    def test_64bits(self) :
+        value_plus=(1L<<63)-1
+        self.assertEquals(9223372036854775807L,value_plus)
+        value_minus=-1L<<63  # Two complement
+        self.assertEquals(-9223372036854775808L,value_minus)
+        if db.version() < (4,4):
+            # We don't use both extremes because it is
+            # problematic in Berkeley DB 4.3.
+            value_plus-=1
+            value_minus+=1
+        self.seq = db.DBSequence(self.d, flags=0)
+        self.assertEquals(None, self.seq.init_value(value_plus-1))
+        self.assertEquals(None, self.seq.open(key='id', txn=None,
+            flags=db.DB_CREATE))
+        self.assertEquals(value_plus-1, self.seq.get(1))
+        self.assertEquals(value_plus, self.seq.get(1))
+
+        self.seq.remove(txn=None, flags=0)
+
+        self.seq = db.DBSequence(self.d, flags=0)
+        self.assertEquals(None, self.seq.init_value(value_minus))
+        self.assertEquals(None, self.seq.open(key='id', txn=None,
+            flags=db.DB_CREATE))
+        self.assertEquals(value_minus, self.seq.get(1))
+        self.assertEquals(value_minus+1, self.seq.get(1))
+
+    def test_multiple_close(self):
+        self.seq = db.DBSequence(self.d)
+        self.seq.close()  # You can close a Sequence multiple times
+        self.seq.close()
+        self.seq.close()
+
 def test_suite():
     suite = unittest.TestSuite()
     if db.version() >= (4,3):

Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_thread.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_thread.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_thread.py	Thu May 15 00:25:06 2008
@@ -5,7 +5,6 @@
 import sys
 import time
 import errno
-import tempfile
 from random import random
 
 try:
@@ -29,7 +28,8 @@
         pass
 
 import unittest
-from test_all import verbose
+from test_all import verbose, get_new_environment_path, get_new_database_path
+
 
 try:
     # For Pythons w/distutils pybsddb
@@ -52,19 +52,19 @@
     dbsetflags   = 0
     envflags     = 0
 
+    import sys
+    if sys.version_info[:3] < (2, 4, 0):
+        def assertTrue(self, expr, msg=None):
+            self.failUnless(expr,msg=msg)
+
     def setUp(self):
         if verbose:
             dbutils._deadlock_VerboseFile = sys.stdout
 
-        homeDir = os.path.join(tempfile.gettempdir(), 'db_home%d'%os.getpid())
-        self.homeDir = homeDir
-        try:
-            os.mkdir(homeDir)
-        except OSError, e:
-            if e.errno != errno.EEXIST: raise
+        self.homeDir = get_new_environment_path()
         self.env = db.DBEnv()
         self.setEnvOpts()
-        self.env.open(homeDir, self.envflags | db.DB_CREATE)
+        self.env.open(self.homeDir, self.envflags | db.DB_CREATE)
 
         self.filename = self.__class__.__name__ + '.db'
         self.d = db.DB(self.env)
@@ -100,63 +100,73 @@
             print "Running %s.test01_1WriterMultiReaders..." % \
                   self.__class__.__name__
 
-        threads = []
-        for x in range(self.writers):
-            wt = Thread(target = self.writerThread,
-                        args = (self.d, self.records, x),
-                        name = 'writer %d' % x,
-                        )#verbose = verbose)
-            threads.append(wt)
+        keys=range(self.records)
+        import random
+        random.shuffle(keys)
+        records_per_writer=self.records/self.writers
+        readers_per_writer=self.readers/self.writers
+        self.assertEqual(self.records,self.writers*records_per_writer)
+        self.assertEqual(self.readers,self.writers*readers_per_writer)
+        self.assertTrue((records_per_writer%readers_per_writer)==0)
+        readers = []
 
-        for x in range(self.readers):
+        for x in xrange(self.readers):
             rt = Thread(target = self.readerThread,
                         args = (self.d, x),
                         name = 'reader %d' % x,
                         )#verbose = verbose)
-            threads.append(rt)
+            rt.setDaemon(True)
+            readers.append(rt)
+
+        writers=[]
+        for x in xrange(self.writers):
+            a=keys[records_per_writer*x:records_per_writer*(x+1)]
+            a.sort()  # Generate conflicts
+            b=readers[readers_per_writer*x:readers_per_writer*(x+1)]
+            wt = Thread(target = self.writerThread,
+                        args = (self.d, a, b),
+                        name = 'writer %d' % x,
+                        )#verbose = verbose)
+            writers.append(wt)
 
-        for t in threads:
+        for t in writers:
+            t.setDaemon(True)
             t.start()
-        for t in threads:
+
+        for t in writers:
+            t.join()
+        for t in readers:
             t.join()
 
-    def writerThread(self, d, howMany, writerNum):
-        #time.sleep(0.01 * writerNum + 0.01)
+    def writerThread(self, d, keys, readers):
         name = currentThread().getName()
-        start = howMany * writerNum
-        stop = howMany * (writerNum + 1) - 1
         if verbose:
             print "%s: creating records %d - %d" % (name, start, stop)
 
-        for x in range(start, stop):
+        count=len(keys)/len(readers)
+        count2=count
+        for x in keys :
             key = '%04d' % x
             dbutils.DeadlockWrap(d.put, key, self.makeData(key),
                                  max_retries=12)
             if verbose and x % 100 == 0:
                 print "%s: records %d - %d finished" % (name, start, x)
 
+            count2-=1
+            if not count2 :
+                readers.pop().start()
+                count2=count
+
         if verbose:
             print "%s: finished creating records" % name
 
-##         # Each write-cursor will be exclusive, the only one that can update the DB...
-##         if verbose: print "%s: deleting a few records" % name
-##         c = d.cursor(flags = db.DB_WRITECURSOR)
-##         for x in range(10):
-##             key = int(random() * howMany) + start
-##             key = '%04d' % key
-##             if d.has_key(key):
-##                 c.set(key)
-##                 c.delete()
-
-##         c.close()
         if verbose:
             print "%s: thread finished" % name
 
     def readerThread(self, d, readerNum):
-        time.sleep(0.01 * readerNum)
         name = currentThread().getName()
 
-        for loop in range(5):
+        for i in xrange(5) :
             c = d.cursor()
             count = 0
             rec = c.first()
@@ -168,7 +178,6 @@
             if verbose:
                 print "%s: found %d records" % (name, count)
             c.close()
-            time.sleep(0.05)
 
         if verbose:
             print "%s: thread finished" % name
@@ -193,8 +202,8 @@
 class SimpleThreadedBase(BaseThreadedTestCase):
     dbopenflags = db.DB_THREAD
     envflags    = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
-    readers = 5
-    writers = 3
+    readers = 10
+    writers = 2
     records = 1000
 
     def setEnvOpts(self):
@@ -205,34 +214,53 @@
             print '\n', '-=' * 30
             print "Running %s.test02_SimpleLocks..." % self.__class__.__name__
 
-        threads = []
-        for x in range(self.writers):
-            wt = Thread(target = self.writerThread,
-                        args = (self.d, self.records, x),
-                        name = 'writer %d' % x,
-                        )#verbose = verbose)
-            threads.append(wt)
-        for x in range(self.readers):
+
+        keys=range(self.records)
+        import random
+        random.shuffle(keys)
+        records_per_writer=self.records/self.writers
+        readers_per_writer=self.readers/self.writers
+        self.assertEqual(self.records,self.writers*records_per_writer)
+        self.assertEqual(self.readers,self.writers*readers_per_writer)
+        self.assertTrue((records_per_writer%readers_per_writer)==0)
+
+        readers = []
+        for x in xrange(self.readers):
             rt = Thread(target = self.readerThread,
                         args = (self.d, x),
                         name = 'reader %d' % x,
                         )#verbose = verbose)
-            threads.append(rt)
+            rt.setDaemon(True)
+            readers.append(rt)
 
-        for t in threads:
+        writers = []
+        for x in xrange(self.writers):
+            a=keys[records_per_writer*x:records_per_writer*(x+1)]
+            a.sort()  # Generate conflicts
+            b=readers[readers_per_writer*x:readers_per_writer*(x+1)]
+            wt = Thread(target = self.writerThread,
+                        args = (self.d, a, b),
+                        name = 'writer %d' % x,
+                        )#verbose = verbose)
+            writers.append(wt)
+
+        for t in writers:
+            t.setDaemon(True)
             t.start()
-        for t in threads:
+
+        for t in writers:
+            t.join()
+        for t in readers:
             t.join()
 
-    def writerThread(self, d, howMany, writerNum):
+    def writerThread(self, d, keys, readers):
         name = currentThread().getName()
-        start = howMany * writerNum
-        stop = howMany * (writerNum + 1) - 1
         if verbose:
             print "%s: creating records %d - %d" % (name, start, stop)
 
-        # create a bunch of records
-        for x in xrange(start, stop):
+        count=len(keys)/len(readers)
+        count2=count
+        for x in keys :
             key = '%04d' % x
             dbutils.DeadlockWrap(d.put, key, self.makeData(key),
                                  max_retries=12)
@@ -240,52 +268,28 @@
             if verbose and x % 100 == 0:
                 print "%s: records %d - %d finished" % (name, start, x)
 
-            # do a bit or reading too
-            if random() <= 0.05:
-                for y in xrange(start, x):
-                    key = '%04d' % x
-                    data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
-                    self.assertEqual(data, self.makeData(key))
-
-        # flush them
-        try:
-            dbutils.DeadlockWrap(d.sync, max_retries=12)
-        except db.DBIncompleteError, val:
-            if verbose:
-                print "could not complete sync()..."
-
-        # read them back, deleting a few
-        for x in xrange(start, stop):
-            key = '%04d' % x
-            data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
-            if verbose and x % 100 == 0:
-                print "%s: fetched record (%s, %s)" % (name, key, data)
-            self.assertEqual(data, self.makeData(key))
-            if random() <= 0.10:
-                dbutils.DeadlockWrap(d.delete, key, max_retries=12)
-                if verbose:
-                    print "%s: deleted record %s" % (name, key)
+            count2-=1
+            if not count2 :
+                readers.pop().start()
+                count2=count
 
         if verbose:
             print "%s: thread finished" % name
 
     def readerThread(self, d, readerNum):
-        time.sleep(0.01 * readerNum)
         name = currentThread().getName()
 
-        for loop in range(5):
-            c = d.cursor()
-            count = 0
-            rec = dbutils.DeadlockWrap(c.first, max_retries=10)
-            while rec:
-                count += 1
-                key, data = rec
-                self.assertEqual(self.makeData(key), data)
-                rec = dbutils.DeadlockWrap(c.next, max_retries=10)
-            if verbose:
-                print "%s: found %d records" % (name, count)
-            c.close()
-            time.sleep(0.05)
+        c = d.cursor()
+        count = 0
+        rec = dbutils.DeadlockWrap(c.first, max_retries=10)
+        while rec:
+            count += 1
+            key, data = rec
+            self.assertEqual(self.makeData(key), data)
+            rec = dbutils.DeadlockWrap(c.next, max_retries=10)
+        if verbose:
+            print "%s: found %d records" % (name, count)
+        c.close()
 
         if verbose:
             print "%s: thread finished" % name
@@ -325,120 +329,97 @@
             print "Running %s.test03_ThreadedTransactions..." % \
                   self.__class__.__name__
 
-        threads = []
-        for x in range(self.writers):
-            wt = Thread(target = self.writerThread,
-                        args = (self.d, self.records, x),
-                        name = 'writer %d' % x,
-                        )#verbose = verbose)
-            threads.append(wt)
+        keys=range(self.records)
+        import random
+        random.shuffle(keys)
+        records_per_writer=self.records/self.writers
+        readers_per_writer=self.readers/self.writers
+        self.assertEqual(self.records,self.writers*records_per_writer)
+        self.assertEqual(self.readers,self.writers*readers_per_writer)
+        self.assertTrue((records_per_writer%readers_per_writer)==0)
 
-        for x in range(self.readers):
+        readers=[]
+        for x in xrange(self.readers):
             rt = Thread(target = self.readerThread,
                         args = (self.d, x),
                         name = 'reader %d' % x,
                         )#verbose = verbose)
-            threads.append(rt)
+            rt.setDaemon(True)
+            readers.append(rt)
+
+        writers = []
+        for x in xrange(self.writers):
+            a=keys[records_per_writer*x:records_per_writer*(x+1)]
+            b=readers[readers_per_writer*x:readers_per_writer*(x+1)]
+            wt = Thread(target = self.writerThread,
+                        args = (self.d, a, b),
+                        name = 'writer %d' % x,
+                        )#verbose = verbose)
+            writers.append(wt)
 
         dt = Thread(target = self.deadlockThread)
+        dt.setDaemon(True)
         dt.start()
 
-        for t in threads:
+        for t in writers:
+            t.setDaemon(True)
             t.start()
-        for t in threads:
+
+        for t in writers:
+            t.join()
+        for t in readers:
             t.join()
 
         self.doLockDetect = False
         dt.join()
 
-    def doWrite(self, d, name, start, stop):
-        finished = False
-        while not finished:
+    def writerThread(self, d, keys, readers):
+        name = currentThread().getName()
+        count=len(keys)/len(readers)
+        while len(keys):
             try:
                 txn = self.env.txn_begin(None, self.txnFlag)
-                for x in range(start, stop):
+                keys2=keys[:count]
+                for x in keys2 :
                     key = '%04d' % x
                     d.put(key, self.makeData(key), txn)
                     if verbose and x % 100 == 0:
                         print "%s: records %d - %d finished" % (name, start, x)
                 txn.commit()
-                finished = True
+                keys=keys[count:]
+                readers.pop().start()
             except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
                 if verbose:
                     print "%s: Aborting transaction (%s)" % (name, val[1])
                 txn.abort()
-                time.sleep(0.05)
 
-    def writerThread(self, d, howMany, writerNum):
-        name = currentThread().getName()
-        start = howMany * writerNum
-        stop = howMany * (writerNum + 1) - 1
         if verbose:
-            print "%s: creating records %d - %d" % (name, start, stop)
-
-        step = 100
-        for x in range(start, stop, step):
-            self.doWrite(d, name, x, min(stop, x+step))
+            print "%s: thread finished" % name
 
-        if verbose:
-            print "%s: finished creating records" % name
-        if verbose:
-            print "%s: deleting a few records" % name
+    def readerThread(self, d, readerNum):
+        name = currentThread().getName()
 
         finished = False
         while not finished:
             try:
-                recs = []
                 txn = self.env.txn_begin(None, self.txnFlag)
-                for x in range(10):
-                    key = int(random() * howMany) + start
-                    key = '%04d' % key
-                    data = d.get(key, None, txn, db.DB_RMW)
-                    if data is not None:
-                        d.delete(key, txn)
-                        recs.append(key)
+                c = d.cursor(txn)
+                count = 0
+                rec = c.first()
+                while rec:
+                    count += 1
+                    key, data = rec
+                    self.assertEqual(self.makeData(key), data)
+                    rec = c.next()
+                if verbose: print "%s: found %d records" % (name, count)
+                c.close()
                 txn.commit()
                 finished = True
-                if verbose:
-                    print "%s: deleted records %s" % (name, recs)
             except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
                 if verbose:
                     print "%s: Aborting transaction (%s)" % (name, val[1])
+                c.close()
                 txn.abort()
-                time.sleep(0.05)
-
-        if verbose:
-            print "%s: thread finished" % name
-
-    def readerThread(self, d, readerNum):
-        time.sleep(0.01 * readerNum + 0.05)
-        name = currentThread().getName()
-
-        for loop in range(5):
-            finished = False
-            while not finished:
-                try:
-                    txn = self.env.txn_begin(None, self.txnFlag)
-                    c = d.cursor(txn)
-                    count = 0
-                    rec = c.first()
-                    while rec:
-                        count += 1
-                        key, data = rec
-                        self.assertEqual(self.makeData(key), data)
-                        rec = c.next()
-                    if verbose: print "%s: found %d records" % (name, count)
-                    c.close()
-                    txn.commit()
-                    finished = True
-                except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
-                    if verbose:
-                        print "%s: Aborting transaction (%s)" % (name, val[1])
-                    c.close()
-                    txn.abort()
-                    time.sleep(0.05)
-
-            time.sleep(0.05)
 
         if verbose:
             print "%s: thread finished" % name
@@ -446,7 +427,7 @@
     def deadlockThread(self):
         self.doLockDetect = True
         while self.doLockDetect:
-            time.sleep(0.5)
+            time.sleep(0.05)
             try:
                 aborted = self.env.lock_detect(
                     db.DB_LOCK_RANDOM, db.DB_LOCK_CONFLICT)
@@ -459,28 +440,28 @@
 
 class BTreeThreadedTransactions(ThreadedTransactionsBase):
     dbtype = db.DB_BTREE
-    writers = 3
-    readers = 5
-    records = 2000
+    writers = 2
+    readers = 10
+    records = 1000
 
 class HashThreadedTransactions(ThreadedTransactionsBase):
     dbtype = db.DB_HASH
-    writers = 1
-    readers = 5
-    records = 2000
+    writers = 2
+    readers = 10
+    records = 1000
 
 class BTreeThreadedNoWaitTransactions(ThreadedTransactionsBase):
     dbtype = db.DB_BTREE
-    writers = 3
-    readers = 5
-    records = 2000
+    writers = 2
+    readers = 10
+    records = 1000
     txnFlag = db.DB_TXN_NOWAIT
 
 class HashThreadedNoWaitTransactions(ThreadedTransactionsBase):
     dbtype = db.DB_HASH
-    writers = 1
-    readers = 5
-    records = 2000
+    writers = 2
+    readers = 10
+    records = 1000
     txnFlag = db.DB_TXN_NOWAIT
 
 

Modified: python/branches/tlee-ast-optimize/Lib/compiler/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/compiler/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/compiler/__init__.py	Thu May 15 00:25:06 2008
@@ -20,6 +20,9 @@
 compileFile(filename)
     Generates a .pyc file by compiling filename.
 """
+from warnings import warnpy3k
+warnpy3k("the compiler package has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 from compiler.transformer import parse, parseFile
 from compiler.visitor import walk

Modified: python/branches/tlee-ast-optimize/Lib/copy.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/copy.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/copy.py	Thu May 15 00:25:06 2008
@@ -49,7 +49,7 @@
 """
 
 import types
-from copy_reg import dispatch_table
+from copyreg import dispatch_table
 
 class Error(Exception):
     pass

Modified: python/branches/tlee-ast-optimize/Lib/copy_reg.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/copy_reg.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/copy_reg.py	Thu May 15 00:25:06 2008
@@ -1,201 +1,8 @@
-"""Helper to provide extensibility for pickle/cPickle.
+import sys
+from warnings import warnpy3k
 
-This is only useful to add pickle support for extension types defined in
-C, not for instances of user-defined classes.
-"""
+warnpy3k("the copy_reg module has been renamed "
+         "to 'copyreg' in Python 3.0", stacklevel=2)
 
-from types import ClassType as _ClassType
-
-__all__ = ["pickle", "constructor",
-           "add_extension", "remove_extension", "clear_extension_cache"]
-
-dispatch_table = {}
-
-def pickle(ob_type, pickle_function, constructor_ob=None):
-    if type(ob_type) is _ClassType:
-        raise TypeError("copy_reg is not intended for use with classes")
-
-    if not hasattr(pickle_function, '__call__'):
-        raise TypeError("reduction functions must be callable")
-    dispatch_table[ob_type] = pickle_function
-
-    # The constructor_ob function is a vestige of safe for unpickling.
-    # There is no reason for the caller to pass it anymore.
-    if constructor_ob is not None:
-        constructor(constructor_ob)
-
-def constructor(object):
-    if not hasattr(object, '__call__'):
-        raise TypeError("constructors must be callable")
-
-# Example: provide pickling support for complex numbers.
-
-try:
-    complex
-except NameError:
-    pass
-else:
-
-    def pickle_complex(c):
-        return complex, (c.real, c.imag)
-
-    pickle(complex, pickle_complex, complex)
-
-# Support for pickling new-style objects
-
-def _reconstructor(cls, base, state):
-    if base is object:
-        obj = object.__new__(cls)
-    else:
-        obj = base.__new__(cls, state)
-        if base.__init__ != object.__init__:
-            base.__init__(obj, state)
-    return obj
-
-_HEAPTYPE = 1<<9
-
-# Python code for object.__reduce_ex__ for protocols 0 and 1
-
-def _reduce_ex(self, proto):
-    assert proto < 2
-    for base in self.__class__.__mro__:
-        if hasattr(base, '__flags__') and not base.__flags__ & _HEAPTYPE:
-            break
-    else:
-        base = object # not really reachable
-    if base is object:
-        state = None
-    else:
-        if base is self.__class__:
-            raise TypeError, "can't pickle %s objects" % base.__name__
-        state = base(self)
-    args = (self.__class__, base, state)
-    try:
-        getstate = self.__getstate__
-    except AttributeError:
-        if getattr(self, "__slots__", None):
-            raise TypeError("a class that defines __slots__ without "
-                            "defining __getstate__ cannot be pickled")
-        try:
-            dict = self.__dict__
-        except AttributeError:
-            dict = None
-    else:
-        dict = getstate()
-    if dict:
-        return _reconstructor, args, dict
-    else:
-        return _reconstructor, args
-
-# Helper for __reduce_ex__ protocol 2
-
-def __newobj__(cls, *args):
-    return cls.__new__(cls, *args)
-
-def _slotnames(cls):
-    """Return a list of slot names for a given class.
-
-    This needs to find slots defined by the class and its bases, so we
-    can't simply return the __slots__ attribute.  We must walk down
-    the Method Resolution Order and concatenate the __slots__ of each
-    class found there.  (This assumes classes don't modify their
-    __slots__ attribute to misrepresent their slots after the class is
-    defined.)
-    """
-
-    # Get the value from a cache in the class if possible
-    names = cls.__dict__.get("__slotnames__")
-    if names is not None:
-        return names
-
-    # Not cached -- calculate the value
-    names = []
-    if not hasattr(cls, "__slots__"):
-        # This class has no slots
-        pass
-    else:
-        # Slots found -- gather slot names from all base classes
-        for c in cls.__mro__:
-            if "__slots__" in c.__dict__:
-                slots = c.__dict__['__slots__']
-                # if class has a single slot, it can be given as a string
-                if isinstance(slots, basestring):
-                    slots = (slots,)
-                for name in slots:
-                    # special descriptors
-                    if name in ("__dict__", "__weakref__"):
-                        continue
-                    # mangled names
-                    elif name.startswith('__') and not name.endswith('__'):
-                        names.append('_%s%s' % (c.__name__, name))
-                    else:
-                        names.append(name)
-
-    # Cache the outcome in the class if at all possible
-    try:
-        cls.__slotnames__ = names
-    except:
-        pass # But don't die if we can't
-
-    return names
-
-# A registry of extension codes.  This is an ad-hoc compression
-# mechanism.  Whenever a global reference to <module>, <name> is about
-# to be pickled, the (<module>, <name>) tuple is looked up here to see
-# if it is a registered extension code for it.  Extension codes are
-# universal, so that the meaning of a pickle does not depend on
-# context.  (There are also some codes reserved for local use that
-# don't have this restriction.)  Codes are positive ints; 0 is
-# reserved.
-
-_extension_registry = {}                # key -> code
-_inverted_registry = {}                 # code -> key
-_extension_cache = {}                   # code -> object
-# Don't ever rebind those names:  cPickle grabs a reference to them when
-# it's initialized, and won't see a rebinding.
-
-def add_extension(module, name, code):
-    """Register an extension code."""
-    code = int(code)
-    if not 1 <= code <= 0x7fffffff:
-        raise ValueError, "code out of range"
-    key = (module, name)
-    if (_extension_registry.get(key) == code and
-        _inverted_registry.get(code) == key):
-        return # Redundant registrations are benign
-    if key in _extension_registry:
-        raise ValueError("key %s is already registered with code %s" %
-                         (key, _extension_registry[key]))
-    if code in _inverted_registry:
-        raise ValueError("code %s is already in use for key %s" %
-                         (code, _inverted_registry[code]))
-    _extension_registry[key] = code
-    _inverted_registry[code] = key
-
-def remove_extension(module, name, code):
-    """Unregister an extension code.  For testing only."""
-    key = (module, name)
-    if (_extension_registry.get(key) != code or
-        _inverted_registry.get(code) != key):
-        raise ValueError("key %s is not registered with code %s" %
-                         (key, code))
-    del _extension_registry[key]
-    del _inverted_registry[code]
-    if code in _extension_cache:
-        del _extension_cache[code]
-
-def clear_extension_cache():
-    _extension_cache.clear()
-
-# Standard extension code assignments
-
-# Reserved ranges
-
-# First  Last Count  Purpose
-#     1   127   127  Reserved for Python standard library
-#   128   191    64  Reserved for Zope
-#   192   239    48  Reserved for 3rd parties
-#   240   255    16  Reserved for private use (will never be assigned)
-#   256   Inf   Inf  Reserved for future assignment
-
-# Extension codes are assigned by the Python Software Foundation.
+import copyreg
+sys.modules[__name__] = copyreg

Modified: python/branches/tlee-ast-optimize/Lib/dircache.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/dircache.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/dircache.py	Thu May 15 00:25:06 2008
@@ -3,6 +3,9 @@
 The listdir() routine returns a sorted list of the files in a directory,
 using a cache to avoid reading the directory more often than necessary.
 The annotate() routine appends slashes to directories."""
+from warnings import warnpy3k
+warnpy3k("the dircache module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 import os
 

Modified: python/branches/tlee-ast-optimize/Lib/distutils/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/__init__.py	Thu May 15 00:25:06 2008
@@ -22,5 +22,5 @@
 #
 
 #--start constants--
-__version__ = "2.6a2"
+__version__ = "2.6a3"
 #--end constants--

Modified: python/branches/tlee-ast-optimize/Lib/distutils/archive_util.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/archive_util.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/archive_util.py	Thu May 15 00:25:06 2008
@@ -95,18 +95,16 @@
         log.info("creating '%s' and adding '%s' to it",
                  zip_filename, base_dir)
 
-        def visit (z, dirname, names):
-            for name in names:
-                path = os.path.normpath(os.path.join(dirname, name))
-                if os.path.isfile(path):
-                    z.write(path, path)
-                    log.info("adding '%s'" % path)
-
         if not dry_run:
             z = zipfile.ZipFile(zip_filename, "w",
                                 compression=zipfile.ZIP_DEFLATED)
 
-            os.path.walk(base_dir, visit, z)
+            for dirpath, dirnames, filenames in os.walk(base_dir):
+                for name in filenames:
+                    path = os.path.normpath(os.path.join(dirpath, name))
+                    if os.path.isfile(path):
+                        z.write(path, path)
+                        log.info("adding '%s'" % path)
             z.close()
 
     return zip_filename

Modified: python/branches/tlee-ast-optimize/Lib/distutils/command/build_ext.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/command/build_ext.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/command/build_ext.py	Thu May 15 00:25:06 2008
@@ -10,6 +10,7 @@
 
 import sys, os, string, re
 from types import *
+from site import USER_BASE, USER_SITE
 from distutils.core import Command
 from distutils.errors import *
 from distutils.sysconfig import customize_compiler, get_python_version
@@ -93,9 +94,11 @@
          "list of SWIG command line options"),
         ('swig=', None,
          "path to the SWIG executable"),
+        ('user', None,
+         "add user include, library and rpath"),
         ]
 
-    boolean_options = ['inplace', 'debug', 'force', 'swig-cpp']
+    boolean_options = ['inplace', 'debug', 'force', 'swig-cpp', 'user']
 
     help_options = [
         ('help-compiler', None,
@@ -123,6 +126,7 @@
         self.swig = None
         self.swig_cpp = None
         self.swig_opts = None
+        self.user = None
 
     def finalize_options (self):
         from distutils import sysconfig
@@ -257,6 +261,16 @@
         else:
             self.swig_opts = self.swig_opts.split(' ')
 
+        # Finally add the user include and library directories if requested
+        if self.user:
+            user_include = os.path.join(USER_BASE, "include")
+            user_lib = os.path.join(USER_BASE, "lib")
+            if os.path.isdir(user_include):
+                self.include_dirs.append(user_include)
+            if os.path.isdir(user_lib):
+                self.library_dirs.append(user_lib)
+                self.rpath.append(user_lib)
+
     # finalize_options ()
 
 

Modified: python/branches/tlee-ast-optimize/Lib/distutils/command/register.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/command/register.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/command/register.py	Thu May 15 00:25:06 2008
@@ -8,37 +8,29 @@
 __revision__ = "$Id$"
 
 import os, string, urllib2, getpass, urlparse
-import StringIO, ConfigParser
+import StringIO
 
-from distutils.core import Command
+from distutils.core import PyPIRCCommand
 from distutils.errors import *
+from distutils import log
 
-class register(Command):
+class register(PyPIRCCommand):
 
     description = ("register the distribution with the Python package index")
-
-    DEFAULT_REPOSITORY = 'http://pypi.python.org/pypi'
-
-    user_options = [
-        ('repository=', 'r',
-         "url of repository [default: %s]"%DEFAULT_REPOSITORY),
+    user_options = PyPIRCCommand.user_options + [
         ('list-classifiers', None,
          'list the valid Trove classifiers'),
-        ('show-response', None,
-         'display full response text from server'),
         ]
-    boolean_options = ['verify', 'show-response', 'list-classifiers']
+    boolean_options = PyPIRCCommand.boolean_options + [
+        'verify', 'list-classifiers']
 
     def initialize_options(self):
-        self.repository = None
-        self.show_response = 0
+        PyPIRCCommand.initialize_options(self)
         self.list_classifiers = 0
 
-    def finalize_options(self):
-        if self.repository is None:
-            self.repository = self.DEFAULT_REPOSITORY
-
     def run(self):
+        self.finalize_options()
+        self._set_config()
         self.check_metadata()
         if self.dry_run:
             self.verify_metadata()
@@ -77,6 +69,23 @@
                       "or (maintainer and maintainer_email) " +
                       "must be supplied")
 
+    def _set_config(self):
+        ''' Reads the configuration file and set attributes.
+        '''
+        config = self._read_pypirc()
+        if config != {}:
+            self.username = config['username']
+            self.password = config['password']
+            self.repository = config['repository']
+            self.realm = config['realm']
+            self.has_config = True
+        else:
+            if self.repository not in ('pypi', self.DEFAULT_REPOSITORY):
+                raise ValueError('%s not found in .pypirc' % self.repository)
+            if self.repository == 'pypi':
+                self.repository = self.DEFAULT_REPOSITORY
+            self.has_config = False
+
     def classifiers(self):
         ''' Fetch the list of classifiers from the server.
         '''
@@ -90,6 +99,7 @@
         (code, result) = self.post_to_server(self.build_post_data('verify'))
         print 'Server response (%s): %s'%(code, result)
 
+
     def send_metadata(self):
         ''' Send the metadata to the package index server.
 
@@ -99,10 +109,14 @@
 
             First we try to read the username/password from $HOME/.pypirc,
             which is a ConfigParser-formatted file with a section
-            [server-login] containing username and password entries (both
+            [distutils] containing username and password entries (both
             in clear text). Eg:
 
-                [server-login]
+                [distutils]
+                index-servers =
+                    pypi
+
+                [pypi]
                 username: fred
                 password: sekrit
 
@@ -114,21 +128,15 @@
              3. set the password to a random string and email the user.
 
         '''
-        choice = 'x'
-        username = password = ''
-
         # see if we can short-cut and get the username/password from the
         # config
-        config = None
-        if 'HOME' in os.environ:
-            rc = os.path.join(os.environ['HOME'], '.pypirc')
-            if os.path.exists(rc):
-                print 'Using PyPI login from %s'%rc
-                config = ConfigParser.ConfigParser()
-                config.read(rc)
-                username = config.get('server-login', 'username')
-                password = config.get('server-login', 'password')
-                choice = '1'
+        if self.has_config:
+            choice = '1'
+            username = self.username
+            password = self.password
+        else:
+            choice = 'x'
+            username = password = ''
 
         # get the user's login info
         choices = '1 2 3 4'.split()
@@ -155,32 +163,24 @@
             # set up the authentication
             auth = urllib2.HTTPPasswordMgr()
             host = urlparse.urlparse(self.repository)[1]
-            auth.add_password('pypi', host, username, password)
-
+            auth.add_password(self.realm, host, username, password)
             # send the info to the server and report the result
             code, result = self.post_to_server(self.build_post_data('submit'),
                 auth)
-            print 'Server response (%s): %s'%(code, result)
+            print 'Server response (%s): %s' % (code, result)
 
             # possibly save the login
-            if 'HOME' in os.environ and config is None and code == 200:
-                rc = os.path.join(os.environ['HOME'], '.pypirc')
+            if not self.has_config and code == 200:
                 print 'I can store your PyPI login so future submissions will be faster.'
-                print '(the login will be stored in %s)'%rc
+                print '(the login will be stored in %s)' % self._get_rc_file()
                 choice = 'X'
                 while choice.lower() not in 'yn':
                     choice = raw_input('Save your login (y/N)?')
                     if not choice:
                         choice = 'n'
                 if choice.lower() == 'y':
-                    f = open(rc, 'w')
-                    f.write('[server-login]\nusername:%s\npassword:%s\n'%(
-                        username, password))
-                    f.close()
-                    try:
-                        os.chmod(rc, 0600)
-                    except:
-                        pass
+                    self._store_pypirc(username, password)
+
         elif choice == '2':
             data = {':action': 'user'}
             data['name'] = data['password'] = data['email'] = ''
@@ -243,7 +243,8 @@
     def post_to_server(self, data, auth=None):
         ''' Post a query to the server, and return a string response.
         '''
-
+        self.announce('Registering %s to %s' % (data['name'],
+                                                self.repository), log.INFO)
         # Build up the MIME payload for the urllib2 POST data
         boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
         sep_boundary = '\n--' + boundary

Modified: python/branches/tlee-ast-optimize/Lib/distutils/command/upload.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/command/upload.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/command/upload.py	Thu May 15 00:25:06 2008
@@ -3,7 +3,7 @@
 Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
 
 from distutils.errors import *
-from distutils.core import Command
+from distutils.core import PyPIRCCommand
 from distutils.spawn import spawn
 from distutils import log
 from hashlib import md5
@@ -16,53 +16,38 @@
 import urlparse
 import cStringIO as StringIO
 
-class upload(Command):
+class upload(PyPIRCCommand):
 
     description = "upload binary package to PyPI"
 
-    DEFAULT_REPOSITORY = 'http://pypi.python.org/pypi'
-
-    user_options = [
-        ('repository=', 'r',
-         "url of repository [default: %s]" % DEFAULT_REPOSITORY),
-        ('show-response', None,
-         'display full response text from server'),
+    user_options = PyPIRCCommand.user_options + [
         ('sign', 's',
          'sign files to upload using gpg'),
         ('identity=', 'i', 'GPG identity used to sign files'),
         ]
-    boolean_options = ['show-response', 'sign']
+
+    boolean_options = PyPIRCCommand.boolean_options + ['sign']
 
     def initialize_options(self):
+        PyPIRCCommand.initialize_options(self)
         self.username = ''
         self.password = ''
-        self.repository = ''
         self.show_response = 0
         self.sign = False
         self.identity = None
 
     def finalize_options(self):
+        PyPIRCCommand.finalize_options(self)
         if self.identity and not self.sign:
             raise DistutilsOptionError(
                 "Must use --sign for --identity to have meaning"
             )
-        if 'HOME' in os.environ:
-            rc = os.path.join(os.environ['HOME'], '.pypirc')
-            if os.path.exists(rc):
-                self.announce('Using PyPI login from %s' % rc)
-                config = ConfigParser.ConfigParser({
-                        'username':'',
-                        'password':'',
-                        'repository':''})
-                config.read(rc)
-                if not self.repository:
-                    self.repository = config.get('server-login', 'repository')
-                if not self.username:
-                    self.username = config.get('server-login', 'username')
-                if not self.password:
-                    self.password = config.get('server-login', 'password')
-        if not self.repository:
-            self.repository = self.DEFAULT_REPOSITORY
+        config = self._read_pypirc()
+        if config != {}:
+            self.username = config['username']
+            self.password = config['password']
+            self.repository = config['repository']
+            self.realm = config['realm']
 
     def run(self):
         if not self.distribution.dist_files:

Modified: python/branches/tlee-ast-optimize/Lib/distutils/core.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/core.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/core.py	Thu May 15 00:25:06 2008
@@ -20,6 +20,7 @@
 # Mainly import these so setup scripts can "from distutils.core import" them.
 from distutils.dist import Distribution
 from distutils.cmd import Command
+from distutils.config import PyPIRCCommand
 from distutils.extension import Extension
 
 # This is a barebones help message generated displayed when the user

Modified: python/branches/tlee-ast-optimize/Lib/distutils/dist.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/dist.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/dist.py	Thu May 15 00:25:06 2008
@@ -343,10 +343,9 @@
             user_filename = "pydistutils.cfg"
 
         # And look for the user config file
-        if 'HOME' in os.environ:
-            user_file = os.path.join(os.environ.get('HOME'), user_filename)
-            if os.path.isfile(user_file):
-                files.append(user_file)
+        user_file = os.path.join(os.path.expanduser('~'), user_filename)
+        if os.path.isfile(user_file):
+            files.append(user_file)
 
         # All platforms support local setup.cfg
         local_file = "setup.cfg"

Modified: python/branches/tlee-ast-optimize/Lib/distutils/tests/test_dist.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/tests/test_dist.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/tests/test_dist.py	Thu May 15 00:25:06 2008
@@ -55,6 +55,7 @@
         self.assertEqual(d.get_command_packages(), ["distutils.command"])
 
     def test_command_packages_cmdline(self):
+        from distutils.tests.test_dist import test_dist
         sys.argv.extend(["--command-packages",
                          "foo.bar,distutils.tests",
                          "test_dist",
@@ -179,9 +180,55 @@
         dist.metadata.write_pkg_file(sio)
         return sio.getvalue()
 
+    def test_custom_pydistutils(self):
+        # fixes #2166
+        # make sure pydistutils.cfg is found
+        old = {}
+        for env in ('HOME', 'HOMEPATH', 'HOMEDRIVE'):
+            value = os.environ.get(env)
+            old[env] = value
+            if value is not None:
+                del os.environ[env]
+
+        if os.name == 'posix':
+            user_filename = ".pydistutils.cfg"
+        else:
+            user_filename = "pydistutils.cfg"
+
+        curdir = os.path.dirname(__file__)
+        user_filename = os.path.join(curdir, user_filename)
+        f = open(user_filename, 'w')
+        f.write('.')
+        f.close()
+
+        try:
+            dist = distutils.dist.Distribution()
+
+            # linux-style
+            if sys.platform in ('linux', 'darwin'):
+                os.environ['HOME'] = curdir
+                files = dist.find_config_files()
+                self.assert_(user_filename in files)
+
+            # win32-style
+            if sys.platform == 'win32':
+                # home drive should be found
+                os.environ['HOME'] = curdir
+                files = dist.find_config_files()
+                self.assert_(user_filename in files,
+                             '%r not found in %r' % (user_filename, files))
+        finally:
+            for key, value in old.items():
+                if value is None:
+                    continue
+                os.environ[key] = value
+            os.remove(user_filename)
 
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(DistributionTestCase))
     suite.addTest(unittest.makeSuite(MetadataTestCase))
     return suite
+
+if __name__ == "__main__":
+    unittest.main(defaultTest="test_suite")

Modified: python/branches/tlee-ast-optimize/Lib/doctest.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/doctest.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/doctest.py	Thu May 15 00:25:06 2008
@@ -2211,7 +2211,7 @@
         self.setUp()
         runner = DebugRunner(optionflags=self._dt_optionflags,
                              checker=self._dt_checker, verbose=False)
-        runner.run(self._dt_test)
+        runner.run(self._dt_test, clear_globs=False)
         self.tearDown()
 
     def id(self):
@@ -2268,8 +2268,6 @@
 
     module = _normalize_module(module)
     tests = test_finder.find(module, globs=globs, extraglobs=extraglobs)
-    if globs is None:
-        globs = module.__dict__
     if not tests:
         # Why do we want to do this? Because it reveals a bug that might
         # otherwise be hidden.

Modified: python/branches/tlee-ast-optimize/Lib/fpformat.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/fpformat.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/fpformat.py	Thu May 15 00:25:06 2008
@@ -10,6 +10,9 @@
 x:             number to be formatted; or a string resembling a number
 digits_behind: number of digits behind the decimal point
 """
+from warnings import warnpy3k
+warnpy3k("the fpformat module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 import re
 

Modified: python/branches/tlee-ast-optimize/Lib/fractions.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/fractions.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/fractions.py	Thu May 15 00:25:06 2008
@@ -9,7 +9,7 @@
 import operator
 import re
 
-__all__ = ["Fraction"]
+__all__ = ['Fraction', 'gcd']
 
 Rational = numbers.Rational
 

Modified: python/branches/tlee-ast-optimize/Lib/idlelib/idlever.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/idlelib/idlever.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/idlelib/idlever.py	Thu May 15 00:25:06 2008
@@ -1 +1 @@
-IDLE_VERSION = "2.6a2"
+IDLE_VERSION = "2.6a3"

Modified: python/branches/tlee-ast-optimize/Lib/idlelib/rpc.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/idlelib/rpc.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/idlelib/rpc.py	Thu May 15 00:25:06 2008
@@ -5,7 +5,7 @@
 has only one client per server, this was not a limitation.
 
    +---------------------------------+ +-------------+
-   | SocketServer.BaseRequestHandler | | SocketIO    |
+   | socketserver.BaseRequestHandler | | SocketIO    |
    +---------------------------------+ +-------------+
                    ^                   | register()  |
                    |                   | unregister()|
@@ -31,13 +31,13 @@
 import os
 import socket
 import select
-import SocketServer
+import socketserver
 import struct
 import cPickle as pickle
 import threading
-import Queue
+import queue
 import traceback
-import copy_reg
+import copyreg
 import types
 import marshal
 
@@ -60,18 +60,18 @@
 #      assert isinstance(fn, type.FunctionType)
 #      return repr(fn)
 
-copy_reg.pickle(types.CodeType, pickle_code, unpickle_code)
-# copy_reg.pickle(types.FunctionType, pickle_function, unpickle_function)
+copyreg.pickle(types.CodeType, pickle_code, unpickle_code)
+# copyreg.pickle(types.FunctionType, pickle_function, unpickle_function)
 
 BUFSIZE = 8*1024
 LOCALHOST = '127.0.0.1'
 
-class RPCServer(SocketServer.TCPServer):
+class RPCServer(socketserver.TCPServer):
 
     def __init__(self, addr, handlerclass=None):
         if handlerclass is None:
             handlerclass = RPCHandler
-        SocketServer.TCPServer.__init__(self, addr, handlerclass)
+        socketserver.TCPServer.__init__(self, addr, handlerclass)
 
     def server_bind(self):
         "Override TCPServer method, no bind() phase for connecting entity"
@@ -117,8 +117,8 @@
 #----------------- end class RPCServer --------------------
 
 objecttable = {}
-request_queue = Queue.Queue(0)
-response_queue = Queue.Queue(0)
+request_queue = queue.Queue(0)
+response_queue = queue.Queue(0)
 
 
 class SocketIO(object):
@@ -413,7 +413,7 @@
             # send queued response if there is one available
             try:
                 qmsg = response_queue.get(0)
-            except Queue.Empty:
+            except queue.Empty:
                 pass
             else:
                 seq, response = qmsg
@@ -492,7 +492,7 @@
     def __init__(self, oid):
         self.oid = oid
 
-class RPCHandler(SocketServer.BaseRequestHandler, SocketIO):
+class RPCHandler(socketserver.BaseRequestHandler, SocketIO):
 
     debugging = False
     location = "#S"  # Server
@@ -500,10 +500,10 @@
     def __init__(self, sock, addr, svr):
         svr.current_handler = self ## cgt xxx
         SocketIO.__init__(self, sock)
-        SocketServer.BaseRequestHandler.__init__(self, sock, addr, svr)
+        socketserver.BaseRequestHandler.__init__(self, sock, addr, svr)
 
     def handle(self):
-        "handle() method required by SocketServer"
+        "handle() method required by socketserver"
         self.mainloop()
 
     def get_remote_proxy(self, oid):

Modified: python/branches/tlee-ast-optimize/Lib/idlelib/run.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/idlelib/run.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/idlelib/run.py	Thu May 15 00:25:06 2008
@@ -5,7 +5,7 @@
 import traceback
 import thread
 import threading
-import Queue
+import queue
 
 import CallTips
 import AutoComplete
@@ -85,7 +85,7 @@
                     continue
             try:
                 seq, request = rpc.request_queue.get(block=True, timeout=0.05)
-            except Queue.Empty:
+            except queue.Empty:
                 continue
             method, args, kwargs = request
             ret = method(*args, **kwargs)

Modified: python/branches/tlee-ast-optimize/Lib/ihooks.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/ihooks.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/ihooks.py	Thu May 15 00:25:06 2008
@@ -49,7 +49,9 @@
 would also do wise to install a different version of reload().
 
 """
-
+from warnings import warnpy3k
+warnpy3k("the ihooks module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 import __builtin__
 import imp

Modified: python/branches/tlee-ast-optimize/Lib/imputil.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/imputil.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/imputil.py	Thu May 15 00:25:06 2008
@@ -9,6 +9,9 @@
 
     DynLoadSuffixImporter
 """
+from warnings import warnpy3k
+warnpy3k("the imputil module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 # note: avoid importing non-builtin modules
 import imp                      ### not available in JPython?

Modified: python/branches/tlee-ast-optimize/Lib/io.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/io.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/io.py	Thu May 15 00:25:06 2008
@@ -494,6 +494,7 @@
         files, the newlines argument to open can be used to select the line
         terminator(s) recognized.
         """
+        self._checkClosed()
         if hasattr(self, "peek"):
             def nreadahead():
                 readahead = self.peek(1)
@@ -508,6 +509,8 @@
                 return 1
         if limit is None:
             limit = -1
+        if not isinstance(limit, (int, long)):
+            raise TypeError("limit must be an integer")
         res = bytearray()
         while limit < 0 or len(res) < limit:
             b = self.read(nreadahead())
@@ -536,6 +539,10 @@
         lines so far exceeds hint.
         """
         if hint is None:
+            hint = -1
+        if not isinstance(hint, (int, long)):
+            raise TypeError("hint must be an integer")
+        if hint <= 0:
             return list(self)
         n = 0
         lines = []
@@ -686,7 +693,7 @@
             import array
             if not isinstance(b, array.array):
                 raise err
-            b[:n] = array.array('b', data)
+            b[:n] = array.array(b'b', data)
         return n
 
     def write(self, b):
@@ -729,6 +736,8 @@
 
         if pos is None:
             pos = self.tell()
+        # XXX: Should seek() be used, instead of passing the position
+        # XXX  directly to truncate?
         return self.raw.truncate(pos)
 
     ### Flush and close ###
@@ -768,7 +777,7 @@
         return self.raw.isatty()
 
 
-class BytesIO(BufferedIOBase):
+class _BytesIO(BufferedIOBase):
 
     """Buffered I/O implementation using an in-memory bytes buffer."""
 
@@ -777,20 +786,28 @@
     def __init__(self, initial_bytes=None):
         buf = bytearray()
         if initial_bytes is not None:
-            buf += initial_bytes
+            buf += bytearray(initial_bytes)
         self._buffer = buf
         self._pos = 0
 
     def getvalue(self):
         """Return the bytes value (contents) of the buffer
         """
+        if self.closed:
+            raise ValueError("getvalue on closed file")
         return bytes(self._buffer)
 
     def read(self, n=None):
+        if self.closed:
+            raise ValueError("read from closed file")
         if n is None:
             n = -1
+        if not isinstance(n, (int, long)):
+            raise TypeError("argument must be an integer")
         if n < 0:
             n = len(self._buffer)
+        if len(self._buffer) <= self._pos:
+            return b""
         newpos = min(len(self._buffer), self._pos + n)
         b = self._buffer[self._pos : newpos]
         self._pos = newpos
@@ -807,39 +824,51 @@
         if isinstance(b, unicode):
             raise TypeError("can't write unicode to binary stream")
         n = len(b)
-        newpos = self._pos + n
-        if newpos > len(self._buffer):
+        if n == 0:
+            return 0
+        pos = self._pos
+        if pos > len(self._buffer):
             # Inserts null bytes between the current end of the file
             # and the new write position.
-            padding = b'\x00' * (newpos - len(self._buffer) - n)
-            self._buffer[self._pos:newpos - n] = padding
-        self._buffer[self._pos:newpos] = b
-        self._pos = newpos
+            padding = b'\x00' * (pos - len(self._buffer))
+            self._buffer += padding
+        self._buffer[pos:pos + n] = b
+        self._pos += n
         return n
 
     def seek(self, pos, whence=0):
+        if self.closed:
+            raise ValueError("seek on closed file")
         try:
             pos = pos.__index__()
         except AttributeError as err:
             raise TypeError("an integer is required") # from err
         if whence == 0:
-            self._pos = max(0, pos)
+            if pos < 0:
+                raise ValueError("negative seek position %r" % (pos,))
+            self._pos = pos
         elif whence == 1:
             self._pos = max(0, self._pos + pos)
         elif whence == 2:
             self._pos = max(0, len(self._buffer) + pos)
         else:
-            raise IOError("invalid whence value")
+            raise ValueError("invalid whence value")
         return self._pos
 
     def tell(self):
+        if self.closed:
+            raise ValueError("tell on closed file")
         return self._pos
 
     def truncate(self, pos=None):
+        if self.closed:
+            raise ValueError("truncate on closed file")
         if pos is None:
             pos = self._pos
+        elif pos < 0:
+            raise ValueError("negative truncate position %r" % (pos,))
         del self._buffer[pos:]
-        return pos
+        return self.seek(pos)
 
     def readable(self):
         return True
@@ -850,6 +879,16 @@
     def seekable(self):
         return True
 
+# Use the faster implementation of BytesIO if available
+try:
+    import _bytesio
+
+    class BytesIO(_bytesio._BytesIO, BufferedIOBase):
+        __doc__ = _bytesio._BytesIO.__doc__
+
+except ImportError:
+    BytesIO = _BytesIO
+
 
 class BufferedReader(_BufferedIOMixin):
 
@@ -983,6 +1022,12 @@
                     raise BlockingIOError(e.errno, e.strerror, overage)
         return written
 
+    def truncate(self, pos=None):
+        self.flush()
+        if pos is None:
+            pos = self.raw.tell()
+        return self.raw.truncate(pos)
+
     def flush(self):
         if self.closed:
             raise ValueError("flush of closed file")
@@ -1102,6 +1147,13 @@
         else:
             return self.raw.tell() - len(self._read_buf)
 
+    def truncate(self, pos=None):
+        if pos is None:
+            pos = self.tell()
+        # Use seek to flush the read buffer.
+        self.seek(pos)
+        return BufferedWriter.truncate(self)
+
     def read(self, n=None):
         if n is None:
             n = -1
@@ -1150,11 +1202,7 @@
 
     def truncate(self, pos = None):
         """Truncate size to pos."""
-        self.flush()
-        if pos is None:
-            pos = self.tell()
-        self.seek(pos)
-        return self.buffer.truncate()
+        self._unsupported("truncate")
 
     def readline(self):
         """Read until newline or EOF.
@@ -1351,6 +1399,12 @@
     def seekable(self):
         return self._seekable
 
+    def readable(self):
+        return self.buffer.readable()
+
+    def writable(self):
+        return self.buffer.writable()
+
     def flush(self):
         self.buffer.flush()
         self._telling = self._seekable
@@ -1542,7 +1596,16 @@
         finally:
             decoder.setstate(saved_state)
 
+    def truncate(self, pos=None):
+        self.flush()
+        if pos is None:
+            pos = self.tell()
+        self.seek(pos)
+        return self.buffer.truncate()
+
     def seek(self, cookie, whence=0):
+        if self.closed:
+            raise ValueError("tell on closed file")
         if not self._seekable:
             raise IOError("underlying stream is not seekable")
         if whence == 1: # seek relative to current position
@@ -1629,8 +1692,12 @@
         return line
 
     def readline(self, limit=None):
+        if self.closed:
+            raise ValueError("read from closed file")
         if limit is None:
             limit = -1
+        if not isinstance(limit, (int, long)):
+            raise TypeError("limit must be an integer")
 
         # Grab all the decoded text (we will rewind any extra bits later).
         line = self._get_decoded_chars()

Modified: python/branches/tlee-ast-optimize/Lib/json/encoder.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/json/encoder.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/json/encoder.py	Thu May 15 00:25:06 2008
@@ -2,6 +2,7 @@
 """
 
 import re
+import math
 
 try:
     from _json import encode_basestring_ascii as c_encode_basestring_ascii
@@ -25,20 +26,19 @@
 for i in range(0x20):
     ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i))
 
-# Assume this produces an infinity on all machines (probably not guaranteed)
-INFINITY = float('1e66666')
 FLOAT_REPR = repr
 
 def floatstr(o, allow_nan=True):
     # Check for specials.  Note that this type of test is processor- and/or
     # platform-specific, so do tests which don't depend on the internals.
 
-    if o != o:
+    if math.isnan(o):
         text = 'NaN'
-    elif o == INFINITY:
-        text = 'Infinity'
-    elif o == -INFINITY:
-        text = '-Infinity'
+    elif math.isinf(o):
+        if math.copysign(1., o) == 1.:
+            text = 'Infinity'
+        else:
+            text = '-Infinity'
     else:
         return FLOAT_REPR(o)
 

Modified: python/branches/tlee-ast-optimize/Lib/lib-tk/Canvas.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib-tk/Canvas.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/lib-tk/Canvas.py	Thu May 15 00:25:06 2008
@@ -3,6 +3,10 @@
 # NOTE: This module was an experiment and is now obsolete.
 # It's best to use the Tkinter.Canvas class directly.
 
+from warnings import warnpy3k
+warnpy3k("the Canvas module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
+
 from Tkinter import Canvas, _cnfmerge, _flatten
 
 

Modified: python/branches/tlee-ast-optimize/Lib/lib-tk/Tkinter.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib-tk/Tkinter.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/lib-tk/Tkinter.py	Thu May 15 00:25:06 2008
@@ -590,9 +590,6 @@
         status = self.tk.call('grab', 'status', self._w)
         if status == 'none': status = None
         return status
-    def lower(self, belowThis=None):
-        """Lower this widget in the stacking order."""
-        self.tk.call('lower', self._w, belowThis)
     def option_add(self, pattern, value, priority = None):
         """Set a VALUE (second parameter) for an option
         PATTERN (first parameter).

Modified: python/branches/tlee-ast-optimize/Lib/logging/config.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/logging/config.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/logging/config.py	Thu May 15 00:25:06 2008
@@ -35,7 +35,7 @@
 except ImportError:
     thread = None
 
-from SocketServer import ThreadingTCPServer, StreamRequestHandler
+from socketserver import ThreadingTCPServer, StreamRequestHandler
 
 
 DEFAULT_LOGGING_CONFIG_PORT = 9030

Modified: python/branches/tlee-ast-optimize/Lib/macpath.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/macpath.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/macpath.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,7 @@
 """Pathname and path-related operations for the Macintosh."""
 
 import os
+import warnings
 from stat import *
 import genericpath
 from genericpath import *
@@ -169,7 +170,7 @@
     beyond that arg is always passed to func.  It can be used, e.g., to pass
     a filename pattern, or a mutable object designed to accumulate
     statistics.  Passing None for arg is common."""
-
+    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.")
     try:
         names = os.listdir(top)
     except os.error:

Modified: python/branches/tlee-ast-optimize/Lib/mhlib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/mhlib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/mhlib.py	Thu May 15 00:25:06 2008
@@ -52,6 +52,10 @@
 s = m.getbodytext()     # text of message's body, decoded
 s = m.getbodytext(0)    # text of message's body, not decoded
 """
+from warnings import warnpy3k
+warnpy3k("the mhlib module has been removed in Python 3.0; use the mailbox "
+            "module instead", stacklevel=2)
+del warnpy3k
 
 # XXX To do, functionality:
 # - annotate messages

Modified: python/branches/tlee-ast-optimize/Lib/multifile.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/multifile.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/multifile.py	Thu May 15 00:25:06 2008
@@ -26,6 +26,10 @@
 current file part.  This may be useful when using MultiFile with a non-
 seekable stream object.
 """
+from warnings import warn
+warn("the multifile module has been deprecated since Python 2.5",
+        DeprecationWarning, stacklevel=2)
+del warn
 
 __all__ = ["MultiFile","Error"]
 

Modified: python/branches/tlee-ast-optimize/Lib/mutex.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/mutex.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/mutex.py	Thu May 15 00:25:06 2008
@@ -11,6 +11,9 @@
 Of course, no multi-threading is implied -- hence the funny interface
 for lock, where a function is called once the lock is aquired.
 """
+from warnings import warnpy3k
+warnpy3k("the mutex module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 from collections import deque
 

Modified: python/branches/tlee-ast-optimize/Lib/new.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/new.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/new.py	Thu May 15 00:25:06 2008
@@ -3,9 +3,10 @@
 This module is no longer required except for backward compatibility.
 Objects of most types can now be created by calling the type object.
 """
-from warnings import warnpy3k as _warnpy3k
-_warnpy3k("The 'new' module is not supported in 3.x, use the 'types' module "
-    "instead.", stacklevel=2)
+from warnings import warnpy3k
+warnpy3k("The 'new' module has been removed in Python 3.0; use the 'types' "
+            "module instead.", stacklevel=2)
+del warnpy3k
 
 from types import ClassType as classobj
 from types import FunctionType as function

Modified: python/branches/tlee-ast-optimize/Lib/ntpath.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/ntpath.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/ntpath.py	Thu May 15 00:25:06 2008
@@ -9,6 +9,8 @@
 import sys
 import stat
 import genericpath
+import warnings
+
 from genericpath import *
 
 __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
@@ -248,7 +250,7 @@
     beyond that arg is always passed to func.  It can be used, e.g., to pass
     a filename pattern, or a mutable object designed to accumulate
     statistics.  Passing None for arg is common."""
-
+    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.")
     try:
         names = os.listdir(top)
     except os.error:

Modified: python/branches/tlee-ast-optimize/Lib/os.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/os.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/os.py	Thu May 15 00:25:06 2008
@@ -1,9 +1,9 @@
 r"""OS routines for Mac, NT, or Posix depending on what system we're on.
 
 This exports:
-  - all functions from posix, nt, os2, mac, or ce, e.g. unlink, stat, etc.
-  - os.path is one of the modules posixpath, ntpath, or macpath
-  - os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos'
+  - all functions from posix, nt, os2, or ce, e.g. unlink, stat, etc.
+  - os.path is one of the modules posixpath, or ntpath
+  - os.name is 'posix', 'nt', 'os2', 'ce' or 'riscos'
   - os.curdir is a string representing the current directory ('.' or ':')
   - os.pardir is a string representing the parent directory ('..' or '::')
   - os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
@@ -84,20 +84,6 @@
     __all__.extend(_get_exports_list(os2))
     del os2
 
-elif 'mac' in _names:
-    name = 'mac'
-    linesep = '\r'
-    from mac import *
-    try:
-        from mac import _exit
-    except ImportError:
-        pass
-    import macpath as path
-
-    import mac
-    __all__.extend(_get_exports_list(mac))
-    del mac
-
 elif 'ce' in _names:
     name = 'ce'
     linesep = '\r\n'
@@ -729,7 +715,7 @@
             return p.stdin, p.stdout
         __all__.append("popen4")
 
-import copy_reg as _copy_reg
+import copyreg as _copy_reg
 
 def _make_stat_result(tup, dict):
     return stat_result(tup, dict)

Modified: python/branches/tlee-ast-optimize/Lib/pdb.doc
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/pdb.doc	(original)
+++ python/branches/tlee-ast-optimize/Lib/pdb.doc	Thu May 15 00:25:06 2008
@@ -128,6 +128,10 @@
         Continue execution until the next line in the current function
         is reached or it returns.
 
+unt(il)
+        Continue execution until the line with a number greater than the 
+        current one is reached or until the current frame returns.
+
 r(eturn)
         Continue execution until the current function returns.
 

Modified: python/branches/tlee-ast-optimize/Lib/pdb.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/pdb.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/pdb.py	Thu May 15 00:25:06 2008
@@ -612,6 +612,11 @@
             self.lineno = None
     do_d = do_down
 
+    def do_until(self, arg):
+        self.set_until(self.curframe)
+        return 1
+    do_unt = do_until
+
     def do_step(self, arg):
         self.set_step()
         return 1
@@ -962,6 +967,14 @@
 Execute the current line, stop at the first possible occasion
 (either in a function that is called or in the current function)."""
 
+    def help_until(self):
+        self.help_unt()
+
+    def help_unt(self):
+        print """unt(il)
+Continue execution until the line with a number greater than the current
+one is reached or until the current frame returns"""
+
     def help_next(self):
         self.help_n()
 

Modified: python/branches/tlee-ast-optimize/Lib/pickle.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/pickle.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/pickle.py	Thu May 15 00:25:06 2008
@@ -27,8 +27,8 @@
 __version__ = "$Revision$"       # Code version
 
 from types import *
-from copy_reg import dispatch_table
-from copy_reg import _extension_registry, _inverted_registry, _extension_cache
+from copyreg import dispatch_table
+from copyreg import _extension_registry, _inverted_registry, _extension_cache
 import marshal
 import sys
 import struct
@@ -295,7 +295,7 @@
             self.save_global(obj)
             return
 
-        # Check copy_reg.dispatch_table
+        # Check copyreg.dispatch_table
         reduce = dispatch_table.get(t)
         if reduce:
             rv = reduce(obj)

Modified: python/branches/tlee-ast-optimize/Lib/plat-irix5/AL.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-irix5/AL.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-irix5/AL.py	Thu May 15 00:25:06 2008
@@ -1,3 +1,7 @@
+from warnings import warnpy3k
+warnpy3k("the AL module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
+
 RATE_48000      = 48000
 RATE_44100      = 44100
 RATE_32000      = 32000

Modified: python/branches/tlee-ast-optimize/Lib/plat-irix6/AL.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-irix6/AL.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-irix6/AL.py	Thu May 15 00:25:06 2008
@@ -1,3 +1,7 @@
+from warnings import warnpy3k
+warnpy3k("the AL module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
+
 RATE_48000      = 48000
 RATE_44100      = 44100
 RATE_32000      = 32000

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/Audio_mac.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/Audio_mac.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/Audio_mac.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,9 @@
 QSIZE = 100000
 error='Audio_mac.error'
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the Play_Audio_mac module is removed.")
+
 class Play_Audio_mac:
 
     def __init__(self, qsize=QSIZE):

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/Carbon/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/Carbon/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/Carbon/__init__.py	Thu May 15 00:25:06 2008
@@ -2,3 +2,6 @@
 import warnings
 warnings.filterwarnings("ignore", "", FutureWarning, ".*Controls")
 warnings.filterwarnings("ignore", "", FutureWarning, ".*MacTextEditor")
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, Carbon is removed.")

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/EasyDialogs.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/EasyDialogs.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/EasyDialogs.py	Thu May 15 00:25:06 2008
@@ -18,6 +18,9 @@
 Based upon STDWIN dialogs with the same names and functions.
 """
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the EasyDialogs module is removed.")
+
 from Carbon.Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog
 from Carbon import Qd
 from Carbon import QuickDraw

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/FrameWork.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/FrameWork.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/FrameWork.py	Thu May 15 00:25:06 2008
@@ -2,6 +2,9 @@
 
 DEBUG=0
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the FrameWork module is removed.")
+
 import MacOS
 import traceback
 

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/MiniAEFrame.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/MiniAEFrame.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/MiniAEFrame.py	Thu May 15 00:25:06 2008
@@ -6,6 +6,9 @@
         only suitable for the simplest of AppleEvent servers.
 """
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the MiniAEFrame module is removed.")
+
 import traceback
 import MacOS
 from Carbon import AE

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/PixMapWrapper.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/PixMapWrapper.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/PixMapWrapper.py	Thu May 15 00:25:06 2008
@@ -5,6 +5,10 @@
 
 J. Strout <joe at strout.net>  February 1999"""
 
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the PixMapWrapper module is removed.")
+
 from Carbon import Qd
 from Carbon import QuickDraw
 import struct

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/aepack.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/aepack.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/aepack.py	Thu May 15 00:25:06 2008
@@ -12,6 +12,9 @@
 # Apple Event Registry, chapter 9.
 #
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the aepack module is removed.")
+
 import struct
 import types
 from types import *

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/aetools.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/aetools.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/aetools.py	Thu May 15 00:25:06 2008
@@ -21,6 +21,9 @@
 """
 
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the aetools module is removed.")
+
 from types import *
 from Carbon import AE
 from Carbon import Evt

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/aetypes.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/aetypes.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/aetypes.py	Thu May 15 00:25:06 2008
@@ -1,5 +1,8 @@
 """aetypes - Python objects representing various AE types."""
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the aetypes module is removed.")
+
 from Carbon.AppleEvents import *
 import struct
 from types import *

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/applesingle.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/applesingle.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/applesingle.py	Thu May 15 00:25:06 2008
@@ -1,5 +1,9 @@
 r"""Routines to decode AppleSingle files
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the applesingle module is removed.")
+
 import struct
 import sys
 try:

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/appletrawmain.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/appletrawmain.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/appletrawmain.py	Thu May 15 00:25:06 2008
@@ -4,6 +4,10 @@
 # This script is put into __rawmain__.pyc for applets that need argv
 # emulation, by BuildApplet and friends.
 #
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the appletrawmain module is removed.")
+
 import argvemulator
 import os
 import sys

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/appletrunner.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/appletrunner.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/appletrunner.py	Thu May 15 00:25:06 2008
@@ -3,6 +3,9 @@
 # BuildApplet will use it as the main executable in the .app bundle if
 # we are not running in a framework build.
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, appletrunner is removed.")
+
 import os
 import sys
 for name in ["__rawmain__.py", "__rawmain__.pyc", "__main__.py", "__main__.pyc"]:

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/argvemulator.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/argvemulator.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/argvemulator.py	Thu May 15 00:25:06 2008
@@ -2,6 +2,9 @@
 want unix-style arguments.
 """
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the argvemulator module is removed.")
+
 import sys
 import traceback
 from Carbon import AE

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/bgenlocations.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/bgenlocations.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/bgenlocations.py	Thu May 15 00:25:06 2008
@@ -7,6 +7,9 @@
 
 import os
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the bgenlocations module is removed.")
+
 Error = "bgenlocations.Error"
 #
 # Where bgen is. For unix-Python bgen isn't installed, so you have to refer to

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/buildtools.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/buildtools.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/buildtools.py	Thu May 15 00:25:06 2008
@@ -1,5 +1,9 @@
 """tools for BuildApplet and BuildApplication"""
 
+import warnings
+warnings.warn("the buildtools module is deprecated and is removed in 3.0",
+              DeprecationWarning, 2)
+
 import sys
 import os
 import string
@@ -14,9 +18,6 @@
 import EasyDialogs
 import shutil
 
-import warnings
-warnings.warn("the buildtools module is deprecated", DeprecationWarning, 2)
-
 
 BuildError = "BuildError"
 

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/bundlebuilder.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/bundlebuilder.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/bundlebuilder.py	Thu May 15 00:25:06 2008
@@ -28,6 +28,9 @@
 __all__ = ["BundleBuilder", "BundleBuilderError", "AppBuilder", "buildapp"]
 
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the bundlebuilder module is removed.")
+
 import sys
 import os, errno, shutil
 import imp, marshal

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/cfmfile.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/cfmfile.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/cfmfile.py	Thu May 15 00:25:06 2008
@@ -5,15 +5,16 @@
 __version__ = "0.8b3"
 __author__ = "jvr"
 
+import warnings
+warnings.warn("the cfmfile module is deprecated and is removed in 3,0",
+              DeprecationWarning, 2)
+
 import Carbon.File
 import struct
 from Carbon import Res
 import os
 import sys
 
-import warnings
-warnings.warn("the cfmfile module is deprecated", DeprecationWarning, 2)
-
 DEBUG = 0
 
 error = "cfm.error"

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/findertools.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/findertools.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/findertools.py	Thu May 15 00:25:06 2008
@@ -14,6 +14,10 @@
 
 Mostly written by erik at letterror.com
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the findertools module is removed.")
+
 import Finder
 from Carbon import AppleEvents
 import aetools

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/gensuitemodule.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/gensuitemodule.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/gensuitemodule.py	Thu May 15 00:25:06 2008
@@ -6,6 +6,9 @@
 Reading and understanding this code is left as an exercise to the reader.
 """
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the gensuitemodule module is removed.")
+
 import MacOS
 import EasyDialogs
 import os

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/ic.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/ic.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/ic.py	Thu May 15 00:25:06 2008
@@ -1,5 +1,8 @@
 """IC wrapper module, based on Internet Config 1.3"""
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the ic module is removed.")
+
 import icglue
 import string
 import sys

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/icopen.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/icopen.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/icopen.py	Thu May 15 00:25:06 2008
@@ -37,6 +37,9 @@
 effect.
 """
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the icopen module is removed.")
+
 import __builtin__
 
 _builtin_open = globals().get('_builtin_open', __builtin__.open)

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,10 @@
 """
 Package generated from /Volumes/Sap/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/CodeWarrior IDE 4.2.5
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the CodeWarrior package is removed.")
+
 import aetools
 Error = aetools.Error
 import CodeWarrior_suite

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,10 @@
 """
 Package generated from /Applications/Internet Explorer.app
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the Explorer module is removed.")
+
 import aetools
 Error = aetools.Error
 import Standard_Suite

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,10 @@
 """
 Package generated from /System/Library/CoreServices/Finder.app
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the Finder package is removed.")
+
 import aetools
 Error = aetools.Error
 import Standard_Suite

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,10 @@
 """
 Package generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicator\xe2\x84\xa2 Folder/Netscape Communicator\xe2\x84\xa2
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the Netscape package is removed.")
+
 import aetools
 Error = aetools.Error
 import Standard_Suite

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py	Thu May 15 00:25:06 2008
@@ -2,6 +2,10 @@
 Package generated from /Volumes/Sap/System Folder/Extensions/AppleScript
 Resource aeut resid 0 Standard Event Suites for English
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the StdSuites package is removed.")
+
 import aetools
 Error = aetools.Error
 import Text_Suite

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,10 @@
 """
 Package generated from /System/Library/CoreServices/System Events.app
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the SystemEvents package is removed.")
+
 import aetools
 Error = aetools.Error
 import Standard_Suite

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,10 @@
 """
 Package generated from /Applications/Utilities/Terminal.app
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the Terminal module is removed.")
+
 import aetools
 Error = aetools.Error
 import Standard_Suite

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py	Thu May 15 00:25:06 2008
@@ -4,6 +4,10 @@
 in the Required suite according to the Apple docs, but they often seem to be
 in the Standard suite.
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the _builtinSuites module is removed.")
+
 import aetools
 import builtin_Suite
 

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/macerrors.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/macerrors.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/macerrors.py	Thu May 15 00:25:06 2008
@@ -1,4 +1,8 @@
 # -coding=latin1-
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the macerrors module is removed.")
+
 svTempDisable   =   -32768  #svTempDisable
 svDisabled  =   -32640  #Reserve range -32640 to -32768 for Apple temp disables.
 fontNotOutlineErr   =   -32615  #bitmap font passed to routine that does outlines only

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/macostools.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/macostools.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/macostools.py	Thu May 15 00:25:06 2008
@@ -4,6 +4,9 @@
 copy(src, dst) - Full copy of 'src' to 'dst'
 """
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the macostools module is removed.")
+
 from Carbon import Res
 from Carbon import File, Files
 import os

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/macresource.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/macresource.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/macresource.py	Thu May 15 00:25:06 2008
@@ -1,5 +1,8 @@
 """macresource - Locate and open the resources needed for a script."""
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the macresource module is removed.")
+
 from Carbon import Res
 import os
 import sys

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/pimp.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/pimp.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/pimp.py	Thu May 15 00:25:06 2008
@@ -12,6 +12,10 @@
 There is a minimal main program that works as a command line tool, but the
 intention is that the end user will use this through a GUI.
 """
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the pimp module is removed.")
+
 import sys
 import os
 import subprocess

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/terminalcommand.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/terminalcommand.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/terminalcommand.py	Thu May 15 00:25:06 2008
@@ -14,6 +14,9 @@
 # Mac/OSX/PythonLauncher/doscript.m.
 #
 
+from warnings import warnpy3k
+warnpy3k("In 3.x, the terminalcommand module is removed.")
+
 import time
 import os
 from Carbon import AE

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/videoreader.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/videoreader.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/videoreader.py	Thu May 15 00:25:06 2008
@@ -5,6 +5,11 @@
 #
 # Jack Jansen, August 2000
 #
+
+from warnings import warnpy3k
+warnpy3k("In 3.x, the videoreader module is removed.")
+
+
 import sys
 from Carbon import Qt
 from Carbon import QuickTime

Modified: python/branches/tlee-ast-optimize/Lib/platform.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/platform.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/platform.py	Thu May 15 00:25:06 2008
@@ -722,7 +722,17 @@
         major = (sysv & 0xFF00) >> 8
         minor = (sysv & 0x00F0) >> 4
         patch = (sysv & 0x000F)
-        release = '%s.%i.%i' % (_bcd2str(major),minor,patch)
+
+        if (major, minor) >= (10, 4):
+            # the 'sysv' gestald cannot return patchlevels
+            # higher than 9. Apple introduced 3 new
+            # gestalt codes in 10.4 to deal with this
+            # issue (needed because patch levels can
+            # run higher than 9, such as 10.4.11)
+            major,minor,patch = _mac_ver_lookup(('sys1','sys2','sys3'))
+            release = '%i.%i.%i' %(major, minor, patch)
+        else:
+            release = '%s.%i.%i' % (_bcd2str(major),minor,patch)
     if sysu:
         major =  int((sysu & 0xFF000000L) >> 24)
         minor =  (sysu & 0x00F00000) >> 20

Modified: python/branches/tlee-ast-optimize/Lib/plistlib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plistlib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plistlib.py	Thu May 15 00:25:06 2008
@@ -62,6 +62,7 @@
 import datetime
 from cStringIO import StringIO
 import re
+import warnings
 
 
 def readPlist(pathOrFile):
@@ -113,6 +114,7 @@
 def readPlistFromResource(path, restype='plst', resid=0):
     """Read plst resource from the resource fork of path.
     """
+    warnings.warnpy3k("In 3.x, readPlistFromResource is removed.")
     from Carbon.File import FSRef, FSGetResourceForkName
     from Carbon.Files import fsRdPerm
     from Carbon import Res
@@ -127,6 +129,7 @@
 def writePlistToResource(rootObject, path, restype='plst', resid=0):
     """Write 'rootObject' as a plst resource to the resource fork of path.
     """
+    warnings.warnpy3k("In 3.x, writePlistToResource is removed.")
     from Carbon.File import FSRef, FSGetResourceForkName
     from Carbon.Files import fsRdWrPerm
     from Carbon import Res

Modified: python/branches/tlee-ast-optimize/Lib/posixpath.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/posixpath.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/posixpath.py	Thu May 15 00:25:06 2008
@@ -13,6 +13,7 @@
 import os
 import stat
 import genericpath
+import warnings
 from genericpath import *
 
 __all__ = ["normcase","isabs","join","splitdrive","split","splitext",
@@ -215,7 +216,7 @@
     beyond that arg is always passed to func.  It can be used, e.g., to pass
     a filename pattern, or a mutable object designed to accumulate
     statistics.  Passing None for arg is common."""
-
+    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.")
     try:
         names = os.listdir(top)
     except os.error:

Modified: python/branches/tlee-ast-optimize/Lib/pprint.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/pprint.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/pprint.py	Thu May 15 00:25:06 2008
@@ -131,6 +131,10 @@
         sepLines = _len(rep) > (self._width - 1 - indent - allowance)
         write = stream.write
 
+        if self._depth and level > self._depth:
+            write(rep)
+            return
+
         r = getattr(typ, "__repr__", None)
         if issubclass(typ, dict) and r is dict.__repr__:
             write('{')
@@ -211,8 +215,8 @@
                 write(',')
             write(endchar)
             return
-        write(rep)
 
+        write(rep)
 
     def _repr(self, object, context, level):
         repr, readable, recursive = self.format(object, context.copy(),
@@ -259,7 +263,7 @@
         if not object:
             return "{}", True, False
         objid = _id(object)
-        if maxlevels and level > maxlevels:
+        if maxlevels and level >= maxlevels:
             return "{...}", False, objid in context
         if objid in context:
             return _recursion(object), False, True
@@ -293,7 +297,7 @@
                 return "()", True, False
             format = "(%s)"
         objid = _id(object)
-        if maxlevels and level > maxlevels:
+        if maxlevels and level >= maxlevels:
             return format % "...", False, objid in context
         if objid in context:
             return _recursion(object), False, True

Modified: python/branches/tlee-ast-optimize/Lib/re.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/re.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/re.py	Thu May 15 00:25:06 2008
@@ -278,12 +278,12 @@
 
 # register myself for pickling
 
-import copy_reg
+import copyreg
 
 def _pickle(p):
     return _compile, (p.pattern, p.flags)
 
-copy_reg.pickle(_pattern_type, _pickle, _compile)
+copyreg.pickle(_pattern_type, _pickle, _compile)
 
 # --------------------------------------------------------------------
 # experimental stuff (see python-dev discussions for details)

Modified: python/branches/tlee-ast-optimize/Lib/rexec.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/rexec.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/rexec.py	Thu May 15 00:25:06 2008
@@ -16,6 +16,9 @@
 - r_exec etc. with explicit globals/locals? (Use rexec("exec ... in ...")?)
 
 """
+from warnings import warnpy3k
+warnpy3k("the rexec module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 
 import sys

Modified: python/branches/tlee-ast-optimize/Lib/rlcompleter.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/rlcompleter.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/rlcompleter.py	Thu May 15 00:25:06 2008
@@ -127,7 +127,10 @@
         if not m:
             return []
         expr, attr = m.group(1, 3)
-        object = eval(expr, self.namespace)
+        try:
+            object = eval(expr, self.namespace)
+        except Exception:
+            return []
         words = dir(object)
         if hasattr(object,'__class__'):
             words.append('__class__')

Modified: python/branches/tlee-ast-optimize/Lib/sched.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/sched.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/sched.py	Thu May 15 00:25:06 2008
@@ -117,7 +117,7 @@
                     action(*argument)
                     delayfunc(0)   # Let other threads run
                 else:
-                    heapq.heappush(event)
+                    heapq.heappush(q, event)
 
     @property
     def queue(self):

Modified: python/branches/tlee-ast-optimize/Lib/site.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/site.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/site.py	Thu May 15 00:25:06 2008
@@ -191,7 +191,7 @@
 def check_enableusersite():
     """Check if user site directory is safe for inclusion
 
-    The functions tests for the command line flag (including environment var),
+    The function tests for the command line flag (including environment var),
     process uid/gid equal to effective uid/gid.
 
     None: Disabled for security reasons
@@ -522,7 +522,7 @@
 
     Exit codes with --user-base or --user-site:
       0 - user site directory is enabled
-      1 - user site diretory is disabled by user
+      1 - user site directory is disabled by user
       2 - uses site directory is disabled by super user
           or for security reasons
      >2 - unknown error

Modified: python/branches/tlee-ast-optimize/Lib/stringold.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/stringold.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/stringold.py	Thu May 15 00:25:06 2008
@@ -18,6 +18,9 @@
 octdigits -- a string containing all characters considered octal digits
 
 """
+from warnings import warnpy3k
+warnpy3k("the stringold module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 # Some strings for ctype-style character classification
 whitespace = ' \t\n\r\v\f'

Modified: python/branches/tlee-ast-optimize/Lib/tempfile.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/tempfile.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/tempfile.py	Thu May 15 00:25:06 2008
@@ -33,10 +33,6 @@
 import errno as _errno
 from random import Random as _Random
 
-if _os.name == 'mac':
-    import Carbon.Folder as _Folder
-    import Carbon.Folders as _Folders
-
 try:
     from cStringIO import StringIO as _StringIO
 except ImportError:
@@ -153,15 +149,7 @@
         if dirname: dirlist.append(dirname)
 
     # Failing that, try OS-specific locations.
-    if _os.name == 'mac':
-        try:
-            fsr = _Folder.FSFindFolder(_Folders.kOnSystemDisk,
-                                              _Folders.kTemporaryFolderType, 1)
-            dirname = fsr.as_pathname()
-            dirlist.append(dirname)
-        except _Folder.error:
-            pass
-    elif _os.name == 'riscos':
+    if _os.name == 'riscos':
         dirname = _os.getenv('Wimp$ScrapDir')
         if dirname: dirlist.append(dirname)
     elif _os.name == 'nt':

Modified: python/branches/tlee-ast-optimize/Lib/test/pickletester.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/pickletester.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/pickletester.py	Thu May 15 00:25:06 2008
@@ -2,7 +2,7 @@
 import pickle
 import cPickle
 import pickletools
-import copy_reg
+import copyreg
 
 from test.test_support import TestFailed, have_unicode, TESTFN, \
                               run_with_locale
@@ -44,21 +44,21 @@
     # there is one).
     def __init__(self, code):
         self.code = code
-        if code in copy_reg._inverted_registry:
-            self.pair = copy_reg._inverted_registry[code]
-            copy_reg.remove_extension(self.pair[0], self.pair[1], code)
+        if code in copyreg._inverted_registry:
+            self.pair = copyreg._inverted_registry[code]
+            copyreg.remove_extension(self.pair[0], self.pair[1], code)
         else:
             self.pair = None
 
     # Restore previous registration for code.
     def restore(self):
         code = self.code
-        curpair = copy_reg._inverted_registry.get(code)
+        curpair = copyreg._inverted_registry.get(code)
         if curpair is not None:
-            copy_reg.remove_extension(curpair[0], curpair[1], code)
+            copyreg.remove_extension(curpair[0], curpair[1], code)
         pair = self.pair
         if pair is not None:
-            copy_reg.add_extension(pair[0], pair[1], code)
+            copyreg.add_extension(pair[0], pair[1], code)
 
 class C:
     def __cmp__(self, other):
@@ -690,14 +690,14 @@
                 self.assertEqual(B(x), B(y), detail)
                 self.assertEqual(x.__dict__, y.__dict__, detail)
 
-    # Register a type with copy_reg, with extension code extcode.  Pickle
+    # Register a type with copyreg, with extension code extcode.  Pickle
     # an object of that type.  Check that the resulting pickle uses opcode
     # (EXT[124]) under proto 2, and not in proto 1.
 
     def produce_global_ext(self, extcode, opcode):
         e = ExtensionSaver(extcode)
         try:
-            copy_reg.add_extension(__name__, "MyList", extcode)
+            copyreg.add_extension(__name__, "MyList", extcode)
             x = MyList([1, 2, 3])
             x.foo = 42
             x.bar = "hello"

Modified: python/branches/tlee-ast-optimize/Lib/test/regrtest.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/regrtest.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/regrtest.py	Thu May 15 00:25:06 2008
@@ -629,7 +629,7 @@
 
 def dash_R(the_module, test, indirect_test, huntrleaks):
     # This code is hackish and inelegant, but it seems to do the job.
-    import copy_reg, _abcoll, io
+    import copyreg, _abcoll, io
 
     if not hasattr(sys, 'gettotalrefcount'):
         raise Exception("Tracking reference leaks requires a debug build "
@@ -637,7 +637,7 @@
 
     # Save current values for dash_R_cleanup() to restore.
     fs = warnings.filters[:]
-    ps = copy_reg.dispatch_table.copy()
+    ps = copyreg.dispatch_table.copy()
     pic = sys.path_importer_cache.copy()
     abcs = {}
     modules = _abcoll, io
@@ -677,8 +677,9 @@
         refrep.close()
 
 def dash_R_cleanup(fs, ps, pic, abcs):
-    import gc, copy_reg
-    import _strptime, linecache, dircache
+    import gc, copyreg
+    import _strptime, linecache
+    dircache = test_support.import_module('dircache', deprecated=True)
     import urlparse, urllib, urllib2, mimetypes, doctest
     import struct, filecmp
     from distutils.dir_util import _path_created
@@ -690,8 +691,8 @@
 
     # Restore some original values.
     warnings.filters[:] = fs
-    copy_reg.dispatch_table.clear()
-    copy_reg.dispatch_table.update(ps)
+    copyreg.dispatch_table.clear()
+    copyreg.dispatch_table.update(ps)
     sys.path_importer_cache.clear()
     sys.path_importer_cache.update(pic)
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test___all__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test___all__.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test___all__.py	Thu May 15 00:25:06 2008
@@ -10,7 +10,8 @@
     def check_all(self, modname):
         names = {}
         with catch_warning():
-            warnings.filterwarnings("ignore", ".* module", DeprecationWarning)
+            warnings.filterwarnings("ignore", ".* (module|package)",
+                                    DeprecationWarning)
             try:
                 exec "import %s" % modname in names
             except ImportError:
@@ -41,7 +42,7 @@
         self.check_all("MimeWriter")
         self.check_all("Queue")
         self.check_all("SimpleHTTPServer")
-        self.check_all("SocketServer")
+        self.check_all("socketserver")
         self.check_all("StringIO")
         self.check_all("UserString")
         self.check_all("aifc")
@@ -60,7 +61,7 @@
         self.check_all("commands")
         self.check_all("compileall")
         self.check_all("copy")
-        self.check_all("copy_reg")
+        self.check_all("copyreg")
         self.check_all("csv")
         self.check_all("dbhash")
         self.check_all("decimal")

Modified: python/branches/tlee-ast-optimize/Lib/test/test_al.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_al.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_al.py	Thu May 15 00:25:06 2008
@@ -2,8 +2,8 @@
 """Whimpy test script for the al module
    Roger E. Masse
 """
-import al
-from test.test_support import verbose
+from test.test_support import verbose, import_module
+al = import_module('al', deprecated=True)
 
 alattrs = ['__doc__', '__name__', 'getdefault', 'getminmax', 'getname', 'getparams',
            'newconfig', 'openport', 'queryparams', 'setparams']

Modified: python/branches/tlee-ast-optimize/Lib/test/test_bsddb185.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_bsddb185.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_bsddb185.py	Thu May 15 00:25:06 2008
@@ -4,9 +4,9 @@
 testing suite.
 
 """
-from test.test_support import run_unittest, findfile
+from test.test_support import run_unittest, findfile, import_module
 import unittest
-import bsddb185
+bsddb185 = import_module('bsddb185', deprecated=True)
 import anydbm
 import whichdb
 import os

Modified: python/branches/tlee-ast-optimize/Lib/test/test_bsddb3.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_bsddb3.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_bsddb3.py	Thu May 15 00:25:06 2008
@@ -49,30 +49,27 @@
 
 
 def suite():
-    try:
-        # this is special, it used to segfault the interpreter
-        import bsddb.test.test_1413192
-    except:
-        for f in ['__db.001', '__db.002', '__db.003', 'log.0000000001']:
-            unlink(f)
-
     test_modules = [
         'test_associate',
         'test_basics',
+        'test_compare',
         'test_compat',
+        'test_cursor_pget_bug',
         'test_dbobj',
         'test_dbshelve',
         'test_dbtables',
-        'test_env_close',
+        'test_distributed_transactions',
+        'test_early_close',
         'test_get_none',
         'test_join',
         'test_lock',
         'test_misc',
+        'test_pickle',
         'test_queue',
         'test_recno',
-        'test_thread',
+        'test_replication',
         'test_sequence',
-        'test_cursor_pget_bug',
+        'test_thread',
         ]
 
     alltests = unittest.TestSuite()

Modified: python/branches/tlee-ast-optimize/Lib/test/test_builtin.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_builtin.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_builtin.py	Thu May 15 00:25:06 2008
@@ -590,6 +590,16 @@
         if have_unicode:
             self.assertRaises(UnicodeError, hasattr, sys, unichr(sys.maxunicode))
 
+        # Check that hasattr allows SystemExit and KeyboardInterrupts by
+        class A:
+            def __getattr__(self, what):
+                raise KeyboardInterrupt
+        self.assertRaises(KeyboardInterrupt, hasattr, A(), "b")
+        class B:
+            def __getattr__(self, what):
+                raise SystemExit
+        self.assertRaises(SystemExit, hasattr, B(), "b")
+
     def test_hash(self):
         hash(None)
         self.assertEqual(hash(1), hash(1L))

Modified: python/branches/tlee-ast-optimize/Lib/test/test_compiler.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_compiler.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_compiler.py	Thu May 15 00:25:06 2008
@@ -1,7 +1,7 @@
-import compiler
+import test.test_support
+compiler = test.test_support.import_module('compiler', deprecated=True)
 from compiler.ast import flatten
 import os, sys, time, unittest
-import test.test_support
 from random import random
 from StringIO import StringIO
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_copy.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_copy.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_copy.py	Thu May 15 00:25:06 2008
@@ -1,7 +1,7 @@
 """Unit tests for the copy module."""
 
 import copy
-import copy_reg
+import copyreg
 
 import unittest
 from test import test_support
@@ -42,7 +42,7 @@
             return (C, (obj.foo,))
         x = C(42)
         self.assertRaises(TypeError, copy.copy, x)
-        copy_reg.pickle(C, pickle_C, C)
+        copyreg.pickle(C, pickle_C, C)
         y = copy.copy(x)
 
     def test_copy_reduce_ex(self):
@@ -215,7 +215,7 @@
             return (C, (obj.foo,))
         x = C(42)
         self.assertRaises(TypeError, copy.deepcopy, x)
-        copy_reg.pickle(C, pickle_C, C)
+        copyreg.pickle(C, pickle_C, C)
         y = copy.deepcopy(x)
 
     def test_deepcopy_reduce_ex(self):

Deleted: python/branches/tlee-ast-optimize/Lib/test/test_copy_reg.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_copy_reg.py	Thu May 15 00:25:06 2008
+++ (empty file)
@@ -1,121 +0,0 @@
-import copy_reg
-import unittest
-
-from test import test_support
-from test.pickletester import ExtensionSaver
-
-class C:
-    pass
-
-
-class WithoutSlots(object):
-    pass
-
-class WithWeakref(object):
-    __slots__ = ('__weakref__',)
-
-class WithPrivate(object):
-    __slots__ = ('__spam',)
-
-class WithSingleString(object):
-    __slots__ = 'spam'
-
-class WithInherited(WithSingleString):
-    __slots__ = ('eggs',)
-
-
-class CopyRegTestCase(unittest.TestCase):
-
-    def test_class(self):
-        self.assertRaises(TypeError, copy_reg.pickle,
-                          C, None, None)
-
-    def test_noncallable_reduce(self):
-        self.assertRaises(TypeError, copy_reg.pickle,
-                          type(1), "not a callable")
-
-    def test_noncallable_constructor(self):
-        self.assertRaises(TypeError, copy_reg.pickle,
-                          type(1), int, "not a callable")
-
-    def test_bool(self):
-        import copy
-        self.assertEquals(True, copy.copy(True))
-
-    def test_extension_registry(self):
-        mod, func, code = 'junk1 ', ' junk2', 0xabcd
-        e = ExtensionSaver(code)
-        try:
-            # Shouldn't be in registry now.
-            self.assertRaises(ValueError, copy_reg.remove_extension,
-                              mod, func, code)
-            copy_reg.add_extension(mod, func, code)
-            # Should be in the registry.
-            self.assert_(copy_reg._extension_registry[mod, func] == code)
-            self.assert_(copy_reg._inverted_registry[code] == (mod, func))
-            # Shouldn't be in the cache.
-            self.assert_(code not in copy_reg._extension_cache)
-            # Redundant registration should be OK.
-            copy_reg.add_extension(mod, func, code)  # shouldn't blow up
-            # Conflicting code.
-            self.assertRaises(ValueError, copy_reg.add_extension,
-                              mod, func, code + 1)
-            self.assertRaises(ValueError, copy_reg.remove_extension,
-                              mod, func, code + 1)
-            # Conflicting module name.
-            self.assertRaises(ValueError, copy_reg.add_extension,
-                              mod[1:], func, code )
-            self.assertRaises(ValueError, copy_reg.remove_extension,
-                              mod[1:], func, code )
-            # Conflicting function name.
-            self.assertRaises(ValueError, copy_reg.add_extension,
-                              mod, func[1:], code)
-            self.assertRaises(ValueError, copy_reg.remove_extension,
-                              mod, func[1:], code)
-            # Can't remove one that isn't registered at all.
-            if code + 1 not in copy_reg._inverted_registry:
-                self.assertRaises(ValueError, copy_reg.remove_extension,
-                                  mod[1:], func[1:], code + 1)
-
-        finally:
-            e.restore()
-
-        # Shouldn't be there anymore.
-        self.assert_((mod, func) not in copy_reg._extension_registry)
-        # The code *may* be in copy_reg._extension_registry, though, if
-        # we happened to pick on a registered code.  So don't check for
-        # that.
-
-        # Check valid codes at the limits.
-        for code in 1, 0x7fffffff:
-            e = ExtensionSaver(code)
-            try:
-                copy_reg.add_extension(mod, func, code)
-                copy_reg.remove_extension(mod, func, code)
-            finally:
-                e.restore()
-
-        # Ensure invalid codes blow up.
-        for code in -1, 0, 0x80000000L:
-            self.assertRaises(ValueError, copy_reg.add_extension,
-                              mod, func, code)
-
-    def test_slotnames(self):
-        self.assertEquals(copy_reg._slotnames(WithoutSlots), [])
-        self.assertEquals(copy_reg._slotnames(WithWeakref), [])
-        expected = ['_WithPrivate__spam']
-        self.assertEquals(copy_reg._slotnames(WithPrivate), expected)
-        self.assertEquals(copy_reg._slotnames(WithSingleString), ['spam'])
-        expected = ['eggs', 'spam']
-        expected.sort()
-        result = copy_reg._slotnames(WithInherited)
-        result.sort()
-        self.assertEquals(result, expected)
-
-
-def test_main():
-    test_support.run_unittest(CopyRegTestCase)
-
-
-if __name__ == "__main__":
-    test_main()

Modified: python/branches/tlee-ast-optimize/Lib/test/test_dircache.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_dircache.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_dircache.py	Thu May 15 00:25:06 2008
@@ -4,8 +4,9 @@
 """
 
 import unittest
-from test.test_support import run_unittest, TESTFN
-import dircache, os, time, sys, tempfile
+from test.test_support import run_unittest, TESTFN, import_module
+dircache = import_module('dircache', deprecated=True)
+import os, time, sys, tempfile
 
 
 class DircacheTests(unittest.TestCase):
@@ -66,7 +67,10 @@
 
 
 def test_main():
-    run_unittest(DircacheTests)
+    try:
+        run_unittest(DircacheTests)
+    finally:
+        dircache.reset()
 
 
 if __name__ == "__main__":

Modified: python/branches/tlee-ast-optimize/Lib/test/test_dl.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_dl.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_dl.py	Thu May 15 00:25:06 2008
@@ -2,9 +2,8 @@
 """Test dlmodule.c
    Roger E. Masse  revised strategy by Barry Warsaw
 """
-
-import dl
-from test.test_support import verbose,TestSkipped
+from test.test_support import verbose,TestSkipped, import_module
+dl = import_module('dl', deprecated=True)
 
 sharedlibs = [
     ('/usr/lib/libc.so', 'getpid'),

Modified: python/branches/tlee-ast-optimize/Lib/test/test_dummy_thread.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_dummy_thread.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_dummy_thread.py	Thu May 15 00:25:06 2008
@@ -7,7 +7,7 @@
 """
 import dummy_thread as _thread
 import time
-import Queue
+import queue
 import random
 import unittest
 from test import test_support
@@ -124,7 +124,7 @@
             """Use to test _thread.start_new_thread() passes args properly."""
             queue.put((arg1, arg2))
 
-        testing_queue = Queue.Queue(1)
+        testing_queue = queue.Queue(1)
         _thread.start_new_thread(arg_tester, (testing_queue, True, True))
         result = testing_queue.get()
         self.failUnless(result[0] and result[1],
@@ -148,7 +148,7 @@
             queue.put(_thread.get_ident())
 
         thread_count = 5
-        testing_queue = Queue.Queue(thread_count)
+        testing_queue = queue.Queue(thread_count)
         if test_support.verbose:
             print
             print "*** Testing multiple thread creation "\

Modified: python/branches/tlee-ast-optimize/Lib/test/test_enumerate.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_enumerate.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_enumerate.py	Thu May 15 00:25:06 2008
@@ -100,7 +100,8 @@
     def test_argumentcheck(self):
         self.assertRaises(TypeError, self.enum) # no arguments
         self.assertRaises(TypeError, self.enum, 1) # wrong type (not iterable)
-        self.assertRaises(TypeError, self.enum, 'abc', 2) # too many arguments
+        self.assertRaises(TypeError, self.enum, 'abc', 'a') # wrong type
+        self.assertRaises(TypeError, self.enum, 'abc', 2, 3) # too many arguments
 
     def test_tuple_reuse(self):
         # Tests an implementation detail where tuple is reused
@@ -196,6 +197,19 @@
         self.assertEqual(rc, sys.getrefcount(r))
 
 
+class TestStart(EnumerateTestCase):
+
+    enum = lambda i: enumerate(i, start=11)
+    seq, res = 'abc', [(1, 'a'), (2, 'b'), (3, 'c')]
+
+
+class TestLongStart(EnumerateTestCase):
+
+    enum = lambda i: enumerate(i, start=sys.maxint+1)
+    seq, res = 'abc', [(sys.maxint+1,'a'), (sys.maxint+2,'b'),
+                       (sys.maxint+3,'c')]
+
+
 def test_main(verbose=None):
     testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig,
                    TestReversed)

Modified: python/branches/tlee-ast-optimize/Lib/test/test_eof.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_eof.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_eof.py	Thu May 15 00:25:06 2008
@@ -6,7 +6,7 @@
 
 class EOFTestCase(unittest.TestCase):
     def test_EOFC(self):
-        expect = "EOL while scanning single-quoted string (<string>, line 1)"
+        expect = "EOL while scanning string literal (<string>, line 1)"
         try:
             eval("""'this is a test\
             """)
@@ -16,7 +16,8 @@
             raise test_support.TestFailed
 
     def test_EOFS(self):
-        expect = "EOF while scanning triple-quoted string (<string>, line 1)"
+        expect = ("EOF while scanning triple-quoted string literal "
+                  "(<string>, line 1)")
         try:
             eval("""'''this is a test""")
         except SyntaxError, msg:

Modified: python/branches/tlee-ast-optimize/Lib/test/test_fpformat.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_fpformat.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_fpformat.py	Thu May 15 00:25:06 2008
@@ -2,9 +2,10 @@
    Tests for fpformat module
    Nick Mathewson
 '''
-from test.test_support import run_unittest
+from test.test_support import run_unittest, import_module
 import unittest
-from fpformat import fix, sci, NotANumber
+fpformat = import_module('fpformat', deprecated=True)
+fix, sci, NotANumber = fpformat.fix, fpformat.sci, fpformat.NotANumber
 
 StringType = type('')
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_imageop.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_imageop.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_imageop.py	Thu May 15 00:25:06 2008
@@ -5,11 +5,10 @@
    Roger E. Masse
 """
 
-from test.test_support import verbose, unlink
+from test.test_support import verbose, unlink, import_module
 
-import imageop, uu, os, imgfile
-
-import warnings
+imageop = import_module('imageop', deprecated=True)
+import uu, os, imgfile
 
 def test_main():
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_io.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_io.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_io.py	Thu May 15 00:25:06 2008
@@ -97,7 +97,7 @@
         self.assertEqual(f.seek(-1, 2), 13)
         self.assertEqual(f.tell(), 13)
         self.assertEqual(f.truncate(12), 12)
-        self.assertEqual(f.tell(), 13)
+        self.assertEqual(f.tell(), 12)
         self.assertRaises(TypeError, f.seek, 0.0)
 
     def read_ops(self, f, buffered=False):
@@ -142,7 +142,7 @@
         self.assertEqual(f.tell(), self.LARGE + 2)
         self.assertEqual(f.seek(0, 2), self.LARGE + 2)
         self.assertEqual(f.truncate(self.LARGE + 1), self.LARGE + 1)
-        self.assertEqual(f.tell(), self.LARGE + 2)
+        self.assertEqual(f.tell(), self.LARGE + 1)
         self.assertEqual(f.seek(0, 2), self.LARGE + 1)
         self.assertEqual(f.seek(-1, 2), self.LARGE)
         self.assertEqual(f.read(2), b"x")
@@ -726,6 +726,7 @@
             txt.write("BB\nCCC\n")
             txt.write("X\rY\r\nZ")
             txt.flush()
+            self.assertEquals(buf.closed, False)
             self.assertEquals(buf.getvalue(), expected)
 
     def testNewlines(self):
@@ -806,7 +807,8 @@
                 txt = io.TextIOWrapper(buf, encoding="ascii", newline=newline)
                 txt.write(data)
                 txt.close()
-                self.assertEquals(buf.getvalue(), expected)
+                self.assertEquals(buf.closed, True)
+                self.assertRaises(ValueError, buf.getvalue)
         finally:
             os.linesep = save_linesep
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_json.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_json.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_json.py	Thu May 15 00:25:06 2008
@@ -11,6 +11,7 @@
 
 def test_main():
     test.test_support.run_unittest(json.tests.test_suite())
+    test.test_support.run_doctest(json)
 
 
 if __name__ == "__main__":

Modified: python/branches/tlee-ast-optimize/Lib/test/test_linuxaudiodev.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_linuxaudiodev.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_linuxaudiodev.py	Thu May 15 00:25:06 2008
@@ -4,7 +4,7 @@
 from test.test_support import findfile, TestSkipped, run_unittest
 
 import errno
-import linuxaudiodev
+linuxaudiodev = test_support.import_module('linuxaudiodev', deprecated=True)
 import sys
 import sunaudio
 import audioop

Modified: python/branches/tlee-ast-optimize/Lib/test/test_logging.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_logging.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_logging.py	Thu May 15 00:25:06 2008
@@ -33,7 +33,7 @@
 import re
 import select
 import socket
-from SocketServer import ThreadingTCPServer, StreamRequestHandler
+from socketserver import ThreadingTCPServer, StreamRequestHandler
 import string
 import struct
 import sys

Modified: python/branches/tlee-ast-optimize/Lib/test/test_marshal.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_marshal.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_marshal.py	Thu May 15 00:25:06 2008
@@ -255,6 +255,14 @@
             subtyp = type('subtyp', (typ,), {})
             self.assertRaises(ValueError, marshal.dumps, subtyp())
 
+    # Issue #1792 introduced a change in how marshal increases the size of its
+    # internal buffer; this test ensures that the new code is exercised.
+    def test_large_marshal(self):
+        size = int(1e6)
+        testString = 'abc' * size
+        marshal.dumps(testString)
+
+
 def test_main():
     test_support.run_unittest(IntTestCase,
                               FloatTestCase,

Modified: python/branches/tlee-ast-optimize/Lib/test/test_math.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_math.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_math.py	Thu May 15 00:25:06 2008
@@ -374,6 +374,24 @@
         self.assertEquals(math.ldexp(NINF, -213), NINF)
         self.assert_(math.isnan(math.ldexp(NAN, 0)))
 
+        # large second argument
+        for n in [10**5, 10L**5, 10**10, 10L**10, 10**20, 10**40]:
+            self.assertEquals(math.ldexp(INF, -n), INF)
+            self.assertEquals(math.ldexp(NINF, -n), NINF)
+            self.assertEquals(math.ldexp(1., -n), 0.)
+            self.assertEquals(math.ldexp(-1., -n), -0.)
+            self.assertEquals(math.ldexp(0., -n), 0.)
+            self.assertEquals(math.ldexp(-0., -n), -0.)
+            self.assert_(math.isnan(math.ldexp(NAN, -n)))
+
+            self.assertRaises(OverflowError, math.ldexp, 1., n)
+            self.assertRaises(OverflowError, math.ldexp, -1., n)
+            self.assertEquals(math.ldexp(0., n), 0.)
+            self.assertEquals(math.ldexp(-0., n), -0.)
+            self.assertEquals(math.ldexp(INF, n), INF)
+            self.assertEquals(math.ldexp(NINF, n), NINF)
+            self.assert_(math.isnan(math.ldexp(NAN, n)))
+
     def testLog(self):
         self.assertRaises(TypeError, math.log)
         self.ftest('log(1/e)', math.log(1/math.e), -1)

Modified: python/branches/tlee-ast-optimize/Lib/test/test_mhlib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_mhlib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_mhlib.py	Thu May 15 00:25:06 2008
@@ -7,10 +7,10 @@
 ###      mhlib.  It should.
 
 import unittest
-from test.test_support import run_unittest, TESTFN, TestSkipped
+from test.test_support import run_unittest, TESTFN, TestSkipped, import_module
 import os, StringIO
 import sys
-import mhlib
+mhlib = import_module('mhlib', deprecated=True)
 
 if (sys.platform.startswith("win") or sys.platform=="riscos" or
       sys.platform.startswith("atheos")):

Modified: python/branches/tlee-ast-optimize/Lib/test/test_multifile.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_multifile.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_multifile.py	Thu May 15 00:25:06 2008
@@ -1,5 +1,6 @@
+from test import test_support
 import mimetools
-import multifile
+multifile = test_support.import_module('multifile', deprecated=True)
 import cStringIO
 
 msg = """Mime-Version: 1.0

Modified: python/branches/tlee-ast-optimize/Lib/test/test_mutex.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_mutex.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_mutex.py	Thu May 15 00:25:06 2008
@@ -1,8 +1,8 @@
-import mutex
-
 import unittest
 import test.test_support
 
+mutex = test.test_support.import_module("mutex", deprecated=True)
+
 class MutexTest(unittest.TestCase):
 
     def setUp(self):

Modified: python/branches/tlee-ast-optimize/Lib/test/test_new.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_new.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_new.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,7 @@
 import unittest
 from test import test_support
-import sys, new
+import sys
+new = test_support.import_module('new', deprecated=True)
 
 class NewTest(unittest.TestCase):
     def test_spam(self):

Modified: python/branches/tlee-ast-optimize/Lib/test/test_pprint.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_pprint.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_pprint.py	Thu May 15 00:25:06 2008
@@ -387,6 +387,21 @@
         cubo = test.test_set.linegraph(cube)
         self.assertEqual(pprint.pformat(cubo), cubo_repr_tgt)
 
+    def test_depth(self):
+        nested_tuple = (1, (2, (3, (4, (5, 6)))))
+        nested_dict = {1: {2: {3: {4: {5: {6: 6}}}}}}
+        nested_list = [1, [2, [3, [4, [5, [6, []]]]]]]
+        self.assertEqual(pprint.pformat(nested_tuple), repr(nested_tuple))
+        self.assertEqual(pprint.pformat(nested_dict), repr(nested_dict))
+        self.assertEqual(pprint.pformat(nested_list), repr(nested_list))
+
+        lv1_tuple = '(1, (...))'
+        lv1_dict = '{1: {...}}'
+        lv1_list = '[1, [...]]'
+        self.assertEqual(pprint.pformat(nested_tuple, depth=1), lv1_tuple)
+        self.assertEqual(pprint.pformat(nested_dict, depth=1), lv1_dict)
+        self.assertEqual(pprint.pformat(nested_list, depth=1), lv1_list)
+
 
 class DottedPrettyPrinter(pprint.PrettyPrinter):
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py	Thu May 15 00:25:06 2008
@@ -1,7 +1,7 @@
 import unittest
 import sys
-from test.test_support import (catch_warning, TestSkipped, run_unittest,
-                                TestSkipped)
+from test.test_support import (catch_warning, CleanImport,
+                               TestSkipped, run_unittest)
 import warnings
 
 if not sys.py3kwarning:
@@ -126,30 +126,50 @@
 
 class TestStdlibRemovals(unittest.TestCase):
 
-    all_platforms = ('audiodev',)
+    # test.testall not tested as it executes all unit tests as an
+    # import side-effect.
+    all_platforms = ('audiodev', 'imputil', 'mutex', 'user', 'new', 'rexec',
+                        'Bastion', 'compiler', 'dircache', 'fpformat',
+                        'ihooks', 'mhlib')
+    inclusive_platforms = {'irix' : ('pure', 'AL', 'al'),
+                          'darwin' : ('autoGIL', 'Carbon', 'OSATerminology',
+                                      'icglue', 'Nav', 'MacOS', 'aepack',
+                                      'aetools', 'aetypes', 'applesingle',
+                                      'appletrawmain', 'appletrunner',
+                                      'argvemulator', 'bgenlocations',
+                                      'EasyDialogs', 'macerrors', 'macostools',
+                                      'findertools', 'FrameWork', 'ic',
+                                      'gensuitemodule', 'icopen', 'macresource',
+                                      'MiniAEFrame', 'pimp', 'PixMapWrapper',
+                                      'terminalcommand', 'videoreader',
+                                      '_builtinSuites', 'CodeWarrior',
+                                      'Explorer', 'Finder', 'Netscape',
+                                      'StdSuites', 'SystemEvents', 'Terminal',
+                                      'cfmfile', 'bundlebuilder', 'buildtools',
+                                      'ColorPicker')}
+    optional_modules = ('bsddb185', 'Canvas', 'dl', 'linuxaudiodev', 'imageop',
+                        'sv')
 
-    def check_removal(self, module_name):
+    def check_removal(self, module_name, optional=False):
         """Make sure the specified module, when imported, raises a
         DeprecationWarning and specifies itself in the message."""
-        original_module = None
-        if module_name in sys.modules:
-            original_module = sys.modules[module_name]
-            del sys.modules[module_name]
-        try:
-            with catch_warning() as w:
+        with CleanImport(module_name):
+            with catch_warning(record=False) as w:
                 warnings.filterwarnings("error", ".+ removed",
                                         DeprecationWarning)
                 try:
                     __import__(module_name, level=0)
                 except DeprecationWarning as exc:
-                    self.assert_(module_name in exc.args[0])
+                    self.assert_(module_name in exc.args[0],
+                                 "%s warning didn't contain module name"
+                                 % module_name)
+                except ImportError:
+                    if not optional:
+                        self.fail("Non-optional module {0} raised an "
+                                  "ImportError.".format(module_name))
                 else:
-                    self.fail("DeprecationWarning not raised for %s" %
-                                module_name)
-        finally:
-            if original_module:
-                sys.modules[module_name] = original_module
-
+                    self.fail("DeprecationWarning not raised for {0}"
+                                .format(module_name))
 
     def test_platform_independent_removals(self):
         # Make sure that the modules that are available on all platforms raise
@@ -157,9 +177,71 @@
         for module_name in self.all_platforms:
             self.check_removal(module_name)
 
+    def test_platform_specific_removals(self):
+        # Test the removal of platform-specific modules.
+        for module_name in self.inclusive_platforms.get(sys.platform, []):
+            self.check_removal(module_name, optional=True)
+
+    def test_optional_module_removals(self):
+        # Test the removal of modules that may or may not be built.
+        for module_name in self.optional_modules:
+            self.check_removal(module_name, optional=True)
+
+    def test_os_path_walk(self):
+        msg = "In 3.x, os.path.walk is removed in favor of os.walk."
+        def dumbo(where, names, args): pass
+        for path_mod in ("ntpath", "macpath", "os2emxpath", "posixpath"):
+            mod = __import__(path_mod)
+            with catch_warning() as w:
+                # Since os3exmpath just imports it from ntpath
+                warnings.simplefilter("always")
+                mod.walk(".", dumbo, None)
+            self.assertEquals(str(w.message), msg)
+
+
+class TestStdlibRenames(unittest.TestCase):
+
+    renames = {'copy_reg': 'copyreg', 'Queue': 'queue',
+               'SocketServer': 'socketserver'}
+
+    def check_rename(self, module_name, new_module_name):
+        """Make sure that:
+        - A DeprecationWarning is raised when importing using the
+          old 2.x module name.
+        - The module can be imported using the new 3.x name.
+        - The warning message specify both names.
+        """
+        with CleanImport(module_name):
+            with catch_warning(record=False) as w:
+                warnings.filterwarnings("error", ".+ renamed to",
+                                        DeprecationWarning)
+                try:
+                    __import__(module_name, level=0)
+                except DeprecationWarning as exc:
+                    self.assert_(module_name in exc.args[0])
+                    self.assert_(new_module_name in exc.args[0])
+                else:
+                    self.fail("DeprecationWarning not raised for %s" %
+                              module_name)
+        with CleanImport(new_module_name):
+            try:
+                __import__(new_module_name, level=0)
+            except ImportError:
+                self.fail("cannot import %s with its 3.x name, %s" %
+                          module_name, new_module_name)
+            except DeprecationWarning:
+                self.fail("unexpected DeprecationWarning raised for %s" %
+                          module_name)
+
+    def test_module_renames(self):
+        for module_name, new_module_name in self.renames.items():
+            self.check_rename(module_name, new_module_name)
+
 
 def test_main():
-    run_unittest(TestPy3KWarnings, TestStdlibRemovals)
+    run_unittest(TestPy3KWarnings,
+                 TestStdlibRemovals,
+                 TestStdlibRenames)
 
 if __name__ == '__main__':
     test_main()

Modified: python/branches/tlee-ast-optimize/Lib/test/test_pyclbr.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_pyclbr.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_pyclbr.py	Thu May 15 00:25:06 2008
@@ -164,10 +164,13 @@
         # These were once about the 10 longest modules
         cm('random', ignore=('Random',))  # from _random import Random as CoreGenerator
         cm('cgi', ignore=('log',))      # set with = in module
-        cm('mhlib')
-        cm('urllib', ignore=('getproxies_registry',
+        cm('urllib', ignore=('_CFNumberToInt32',
+                             '_CStringFromCFString',
+                             'getproxies_registry',
                              'proxy_bypass_registry',
+                             'proxy_bypass_macosx_sysconf',
                              'open_https',
+                             'getproxies_macosx_sysconf',
                              'getproxies_internetconfig',)) # not on all platforms
         cm('pickle')
         cm('aifc', ignore=('openfp',))  # set with = in module

Modified: python/branches/tlee-ast-optimize/Lib/test/test_queue.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_queue.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_queue.py	Thu May 15 00:25:06 2008
@@ -1,6 +1,6 @@
-# Some simple Queue module tests, plus some failure conditions
+# Some simple queue module tests, plus some failure conditions
 # to ensure the Queue locks remain stable.
-import Queue
+import queue
 import sys
 import threading
 import time
@@ -107,12 +107,12 @@
         try:
             q.put("full", block=0)
             self.fail("Didn't appear to block with a full queue")
-        except Queue.Full:
+        except queue.Full:
             pass
         try:
             q.put("full", timeout=0.01)
             self.fail("Didn't appear to time-out with a full queue")
-        except Queue.Full:
+        except queue.Full:
             pass
         # Test a blocking put
         self.do_blocking_test(q.put, ("full",), q.get, ())
@@ -124,12 +124,12 @@
         try:
             q.get(block=0)
             self.fail("Didn't appear to block with an empty queue")
-        except Queue.Empty:
+        except queue.Empty:
             pass
         try:
             q.get(timeout=0.01)
             self.fail("Didn't appear to time-out with an empty queue")
-        except Queue.Empty:
+        except queue.Empty:
             pass
         # Test a blocking get
         self.do_blocking_test(q.get, (), q.put, ('empty',))
@@ -191,13 +191,13 @@
 
 
 class QueueTest(BaseQueueTest):
-    type2test = Queue.Queue
+    type2test = queue.Queue
 
 class LifoQueueTest(BaseQueueTest):
-    type2test = Queue.LifoQueue
+    type2test = queue.LifoQueue
 
 class PriorityQueueTest(BaseQueueTest):
-    type2test = Queue.PriorityQueue
+    type2test = queue.PriorityQueue
 
 
 
@@ -205,21 +205,21 @@
 class FailingQueueException(Exception):
     pass
 
-class FailingQueue(Queue.Queue):
+class FailingQueue(queue.Queue):
     def __init__(self, *args):
         self.fail_next_put = False
         self.fail_next_get = False
-        Queue.Queue.__init__(self, *args)
+        queue.Queue.__init__(self, *args)
     def _put(self, item):
         if self.fail_next_put:
             self.fail_next_put = False
             raise FailingQueueException, "You Lose"
-        return Queue.Queue._put(self, item)
+        return queue.Queue._put(self, item)
     def _get(self):
         if self.fail_next_get:
             self.fail_next_get = False
             raise FailingQueueException, "You Lose"
-        return Queue.Queue._get(self)
+        return queue.Queue._get(self)
 
 class FailingQueueTest(unittest.TestCase, BlockingTestMixin):
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_repr.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_repr.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_repr.py	Thu May 15 00:25:06 2008
@@ -211,10 +211,6 @@
     fp.write(text)
     fp.close()
 
-def zap(actions, dirname, names):
-    for name in names:
-        actions.append(os.path.join(dirname, name))
-
 class LongReprTest(unittest.TestCase):
     def setUp(self):
         longname = 'areallylongpackageandmodulenametotestreprtruncation'
@@ -233,7 +229,9 @@
 
     def tearDown(self):
         actions = []
-        os.path.walk(self.pkgname, zap, actions)
+        for dirpath, dirnames, filenames in os.walk(self.pkgname):
+            for name in dirnames + filenames:
+                actions.append(os.path.join(dirpath, name))
         actions.append(self.pkgname)
         actions.sort()
         actions.reverse()

Modified: python/branches/tlee-ast-optimize/Lib/test/test_site.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_site.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_site.py	Thu May 15 00:25:06 2008
@@ -36,7 +36,7 @@
         """Save a copy of sys.path"""
         self.sys_path = sys.path[:]
 
-
+    def tearDown(self):
         """Restore sys.path"""
         sys.path = self.sys_path
 
@@ -256,13 +256,8 @@
             else:
                 self.fail("sitecustomize not imported automatically")
 
-
-
-
 def test_main():
     run_unittest(HelperFunctionsTests, ImportSideEffectTests)
 
-
-
 if __name__ == "__main__":
     test_main()

Modified: python/branches/tlee-ast-optimize/Lib/test/test_socket.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_socket.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_socket.py	Thu May 15 00:25:06 2008
@@ -9,7 +9,7 @@
 import thread, threading
 import time
 import traceback
-import Queue
+import queue
 import sys
 import os
 import array
@@ -96,7 +96,7 @@
         self.server_ready = threading.Event()
         self.client_ready = threading.Event()
         self.done = threading.Event()
-        self.queue = Queue.Queue(1)
+        self.queue = queue.Queue(1)
 
         # Do some munging to start the client test.
         methodname = self.id()

Modified: python/branches/tlee-ast-optimize/Lib/test/test_socketserver.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_socketserver.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_socketserver.py	Thu May 15 00:25:06 2008
@@ -1,5 +1,5 @@
 """
-Test suite for SocketServer.py.
+Test suite for socketserver.
 """
 
 import contextlib
@@ -13,7 +13,7 @@
 import threading
 import time
 import unittest
-import SocketServer
+import socketserver
 
 import test.test_support
 from test.test_support import reap_children, verbose, TestSkipped
@@ -40,12 +40,12 @@
         raise RuntimeError, "timed out on %r" % (sock,)
 
 if HAVE_UNIX_SOCKETS:
-    class ForkingUnixStreamServer(SocketServer.ForkingMixIn,
-                                  SocketServer.UnixStreamServer):
+    class ForkingUnixStreamServer(socketserver.ForkingMixIn,
+                                  socketserver.UnixStreamServer):
         pass
 
-    class ForkingUnixDatagramServer(SocketServer.ForkingMixIn,
-                                    SocketServer.UnixDatagramServer):
+    class ForkingUnixDatagramServer(socketserver.ForkingMixIn,
+                                    socketserver.UnixDatagramServer):
         pass
 
 
@@ -172,55 +172,55 @@
         s.close()
 
     def test_TCPServer(self):
-        self.run_server(SocketServer.TCPServer,
-                        SocketServer.StreamRequestHandler,
+        self.run_server(socketserver.TCPServer,
+                        socketserver.StreamRequestHandler,
                         self.stream_examine)
 
     def test_ThreadingTCPServer(self):
-        self.run_server(SocketServer.ThreadingTCPServer,
-                        SocketServer.StreamRequestHandler,
+        self.run_server(socketserver.ThreadingTCPServer,
+                        socketserver.StreamRequestHandler,
                         self.stream_examine)
 
     if HAVE_FORKING:
         def test_ForkingTCPServer(self):
             with simple_subprocess(self):
-                self.run_server(SocketServer.ForkingTCPServer,
-                                SocketServer.StreamRequestHandler,
+                self.run_server(socketserver.ForkingTCPServer,
+                                socketserver.StreamRequestHandler,
                                 self.stream_examine)
 
     if HAVE_UNIX_SOCKETS:
         def test_UnixStreamServer(self):
-            self.run_server(SocketServer.UnixStreamServer,
-                            SocketServer.StreamRequestHandler,
+            self.run_server(socketserver.UnixStreamServer,
+                            socketserver.StreamRequestHandler,
                             self.stream_examine)
 
         def test_ThreadingUnixStreamServer(self):
-            self.run_server(SocketServer.ThreadingUnixStreamServer,
-                            SocketServer.StreamRequestHandler,
+            self.run_server(socketserver.ThreadingUnixStreamServer,
+                            socketserver.StreamRequestHandler,
                             self.stream_examine)
 
         if HAVE_FORKING:
             def test_ForkingUnixStreamServer(self):
                 with simple_subprocess(self):
                     self.run_server(ForkingUnixStreamServer,
-                                    SocketServer.StreamRequestHandler,
+                                    socketserver.StreamRequestHandler,
                                     self.stream_examine)
 
     def test_UDPServer(self):
-        self.run_server(SocketServer.UDPServer,
-                        SocketServer.DatagramRequestHandler,
+        self.run_server(socketserver.UDPServer,
+                        socketserver.DatagramRequestHandler,
                         self.dgram_examine)
 
     def test_ThreadingUDPServer(self):
-        self.run_server(SocketServer.ThreadingUDPServer,
-                        SocketServer.DatagramRequestHandler,
+        self.run_server(socketserver.ThreadingUDPServer,
+                        socketserver.DatagramRequestHandler,
                         self.dgram_examine)
 
     if HAVE_FORKING:
         def test_ForkingUDPServer(self):
             with simple_subprocess(self):
-                self.run_server(SocketServer.ForkingUDPServer,
-                                SocketServer.DatagramRequestHandler,
+                self.run_server(socketserver.ForkingUDPServer,
+                                socketserver.DatagramRequestHandler,
                                 self.dgram_examine)
 
     # Alas, on Linux (at least) recvfrom() doesn't return a meaningful
@@ -228,19 +228,19 @@
 
     # if HAVE_UNIX_SOCKETS:
     #     def test_UnixDatagramServer(self):
-    #         self.run_server(SocketServer.UnixDatagramServer,
-    #                         SocketServer.DatagramRequestHandler,
+    #         self.run_server(socketserver.UnixDatagramServer,
+    #                         socketserver.DatagramRequestHandler,
     #                         self.dgram_examine)
     #
     #     def test_ThreadingUnixDatagramServer(self):
-    #         self.run_server(SocketServer.ThreadingUnixDatagramServer,
-    #                         SocketServer.DatagramRequestHandler,
+    #         self.run_server(socketserver.ThreadingUnixDatagramServer,
+    #                         socketserver.DatagramRequestHandler,
     #                         self.dgram_examine)
     #
     #     if HAVE_FORKING:
     #         def test_ForkingUnixDatagramServer(self):
-    #             self.run_server(SocketServer.ForkingUnixDatagramServer,
-    #                             SocketServer.DatagramRequestHandler,
+    #             self.run_server(socketserver.ForkingUnixDatagramServer,
+    #                             socketserver.DatagramRequestHandler,
     #                             self.dgram_examine)
 
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_support.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_support.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_support.py	Thu May 15 00:25:06 2008
@@ -37,6 +37,20 @@
     and unexpected skips.
     """
 
+def import_module(name, deprecated=False):
+    """Import the module to be tested, raising TestSkipped if it is not
+    available."""
+    with catch_warning(record=False):
+        if deprecated:
+            warnings.filterwarnings("ignore", ".+ (module|package)",
+                                    DeprecationWarning)
+        try:
+            module = __import__(name, level=0)
+        except ImportError:
+            raise TestSkipped("No module named " + name)
+        else:
+            return module
+
 verbose = 1              # Flag set to 0 by regrtest.py
 use_resources = None     # Flag set to [] by regrtest.py
 max_memuse = 0           # Disable bigmem tests (they will still be run with
@@ -382,7 +396,7 @@
 
 
 @contextlib.contextmanager
-def catch_warning(module=warnings):
+def catch_warning(module=warnings, record=True):
     """
     Guard the warnings filter from being permanently changed and record the
     data of the last warning that has been issued.
@@ -393,16 +407,50 @@
             warnings.warn("foo")
             assert str(w.message) == "foo"
     """
-    warning_obj = WarningMessage()
     original_filters = module.filters[:]
     original_showwarning = module.showwarning
-    module.showwarning = warning_obj._showwarning
+    if record:
+        warning_obj = WarningMessage()
+        module.showwarning = warning_obj._showwarning
     try:
-        yield warning_obj
+        yield warning_obj if record else None
     finally:
         module.showwarning = original_showwarning
         module.filters = original_filters
 
+
+class CleanImport(object):
+    """Context manager to force import to return a new module reference.
+
+    This is useful for testing module-level behaviours, such as
+    the emission of a DepreciationWarning on import.
+
+    Use like this:
+
+        with CleanImport("foo"):
+            __import__("foo") # new reference
+    """
+
+    def __init__(self, *module_names):
+        self.original_modules = sys.modules.copy()
+        for module_name in module_names:
+            if module_name in sys.modules:
+                module = sys.modules[module_name]
+                # It is possible that module_name is just an alias for
+                # another module (e.g. stub for modules renamed in 3.x).
+                # In that case, we also need delete the real module to clear
+                # the import cache.
+                if module.__name__ != module_name:
+                    del sys.modules[module.__name__]
+                del sys.modules[module_name]
+
+    def __enter__(self):
+        return self
+
+    def __exit__(self, *ignore_exc):
+        sys.modules.update(self.original_modules)
+
+
 class EnvironmentVarGuard(object):
 
     """Class to help protect the environment variable properly.  Can be used as

Modified: python/branches/tlee-ast-optimize/Lib/test/test_sys.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_sys.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_sys.py	Thu May 15 00:25:06 2008
@@ -357,7 +357,7 @@
         attrs = ("debug", "py3k_warning", "division_warning", "division_new",
                  "inspect", "interactive", "optimize", "dont_write_bytecode",
                  "no_site", "ignore_environment", "tabcheck", "verbose",
-                 "unicode")
+                 "unicode", "bytes_warning")
         for attr in attrs:
             self.assert_(hasattr(sys.flags, attr), attr)
             self.assertEqual(type(getattr(sys.flags, attr)), int, attr)

Modified: python/branches/tlee-ast-optimize/Lib/test/test_textwrap.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_textwrap.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_textwrap.py	Thu May 15 00:25:06 2008
@@ -364,6 +364,14 @@
              ["Hello", " ", "there", " ", "--", " ", "you", " ", "goof-",
               "ball,", " ", "use", " ", "the", " ", "-b", " ",  "option!"])
 
+    def test_break_on_hyphens(self):
+        # Ensure that the break_on_hyphens attributes work
+        text = "yaba daba-doo"
+        self.check_wrap(text, 10, ["yaba daba-", "doo"],
+                        break_on_hyphens=True)
+        self.check_wrap(text, 10, ["yaba", "daba-doo"],
+                        break_on_hyphens=False)
+
     def test_bad_width(self):
         # Ensure that width <= 0 is caught.
         text = "Whatever, it doesn't matter."

Modified: python/branches/tlee-ast-optimize/Lib/test/test_types.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_types.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_types.py	Thu May 15 00:25:06 2008
@@ -377,7 +377,7 @@
 
         # ensure that float type specifiers work; format converts
         #  the int to a float
-        for format_spec in 'eEfFgGn%':
+        for format_spec in 'eEfFgG%':
             for value in [0, 1, -1, 100, -100, 1234567890, -1234567890]:
                 self.assertEqual(value.__format__(format_spec),
                                  float(value).__format__(format_spec))
@@ -472,7 +472,7 @@
 
         # ensure that float type specifiers work; format converts
         #  the long to a float
-        for format_spec in 'eEfFgGn%':
+        for format_spec in 'eEfFgG%':
             for value in [0L, 1L, -1L, 100L, -100L, 1234567890L, -1234567890L]:
                 self.assertEqual(value.__format__(format_spec),
                                  float(value).__format__(format_spec))
@@ -486,6 +486,17 @@
             self.assertEqual(locale.format('%g', x, grouping=True), format(x, 'n'))
             self.assertEqual(locale.format('%.10g', x, grouping=True), format(x, '.10n'))
 
+    @run_with_locale('LC_NUMERIC', 'en_US.UTF8')
+    def test_int__format__locale(self):
+        # test locale support for __format__ code 'n' for integers
+
+        x = 123456789012345678901234567890
+        for i in range(0, 30):
+            self.assertEqual(locale.format('%d', x, grouping=True), format(x, 'n'))
+
+            # move to the next integer to test
+            x = x // 10
+
     def test_float__format__(self):
         # these should be rewritten to use both format(x, spec) and
         # x.__format__(spec)

Modified: python/branches/tlee-ast-optimize/Lib/test/test_warnings.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_warnings.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_warnings.py	Thu May 15 00:25:06 2008
@@ -396,6 +396,7 @@
             self.assertRaises(TypeError, self.module.warn, "Warning!")
         finally:
             self.module.showwarning = old_showwarning
+            self.module.resetwarnings()
 
     def test_show_warning_output(self):
         # With showarning() missing, make sure that output is okay.

Modified: python/branches/tlee-ast-optimize/Lib/test/test_wsgiref.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_wsgiref.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_wsgiref.py	Thu May 15 00:25:06 2008
@@ -8,7 +8,7 @@
 from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, demo_app
 from wsgiref.simple_server import make_server
 from StringIO import StringIO
-from SocketServer import BaseServer
+from socketserver import BaseServer
 import re, sys
 
 from test import test_support

Modified: python/branches/tlee-ast-optimize/Lib/test/test_zipimport.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_zipimport.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_zipimport.py	Thu May 15 00:25:06 2008
@@ -212,6 +212,7 @@
             z.close()
 
             zi = zipimport.zipimporter(TEMP_ZIP)
+            self.assertEquals(zi.archive, TEMP_ZIP)
             self.assertEquals(zi.is_package(TESTPACK), True)
             zi.load_module(TESTPACK)
 
@@ -232,6 +233,37 @@
             z.close()
             os.remove(TEMP_ZIP)
 
+    def testZipImporterMethodsInSubDirectory(self):
+        packdir = TESTPACK + os.sep
+        packdir2 = packdir + TESTPACK2 + os.sep
+        files = {packdir2 + "__init__" + pyc_ext: (NOW, test_pyc),
+                 packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)}
+
+        z = ZipFile(TEMP_ZIP, "w")
+        try:
+            for name, (mtime, data) in files.items():
+                zinfo = ZipInfo(name, time.localtime(mtime))
+                zinfo.compress_type = self.compression
+                z.writestr(zinfo, data)
+            z.close()
+
+            zi = zipimport.zipimporter(TEMP_ZIP + os.sep + packdir)
+            self.assertEquals(zi.archive, TEMP_ZIP)
+            self.assertEquals(zi.prefix, packdir)
+            self.assertEquals(zi.is_package(TESTPACK2), True)
+            zi.load_module(TESTPACK2)
+
+            self.assertEquals(zi.is_package(TESTPACK2 + os.sep + '__init__'), False)
+            self.assertEquals(zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)
+
+            mod_name = TESTPACK2 + os.sep + TESTMOD
+            mod = __import__(module_path_to_dotted_name(mod_name))
+            self.assertEquals(zi.get_source(TESTPACK2), None)
+            self.assertEquals(zi.get_source(mod_name), None)
+        finally:
+            z.close()
+            os.remove(TEMP_ZIP)
+
     def testGetData(self):
         z = ZipFile(TEMP_ZIP, "w")
         z.compression = self.compression

Modified: python/branches/tlee-ast-optimize/Lib/test/testall.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/testall.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/testall.py	Thu May 15 00:25:06 2008
@@ -1,4 +1,10 @@
 # Backward compatibility -- you should use regrtest instead of this module.
+from warnings import warnpy3k
+warnpy3k("the test.testall module has been removed in Python 3.0",
+            stacklevel=2)
+del warnpy3k
+
+
 import sys, regrtest
 sys.argv[1:] = ["-vv"]
 regrtest.main()

Modified: python/branches/tlee-ast-optimize/Lib/textwrap.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/textwrap.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/textwrap.py	Thu May 15 00:25:06 2008
@@ -63,6 +63,10 @@
       break_long_words (default: true)
         Break words longer than 'width'.  If false, those words will not
         be broken, and some lines might be longer than 'width'.
+      break_on_hyphens (default: true)
+        Allow breaking hyphenated words. If true, wrapping will occur
+        preferably on whitespaces and right after hyphens part of
+        compound words.
       drop_whitespace (default: true)
         Drop leading and trailing whitespace from lines.
     """
@@ -85,6 +89,12 @@
         r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|'   # hyphenated words
         r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))')   # em-dash
 
+    # This less funky little regex just split on recognized spaces. E.g.
+    #   "Hello there -- you goof-ball, use the -b option!"
+    # splits into
+    #   Hello/ /there/ /--/ /you/ /goof-ball,/ /use/ /the/ /-b/ /option!/
+    wordsep_simple_re = re.compile(r'(\s+)')
+
     # XXX this is not locale- or charset-aware -- string.lowercase
     # is US-ASCII only (and therefore English-only)
     sentence_end_re = re.compile(r'[%s]'              # lowercase letter
@@ -102,7 +112,8 @@
                  replace_whitespace=True,
                  fix_sentence_endings=False,
                  break_long_words=True,
-                 drop_whitespace=True):
+                 drop_whitespace=True,
+                 break_on_hyphens=True):
         self.width = width
         self.initial_indent = initial_indent
         self.subsequent_indent = subsequent_indent
@@ -111,6 +122,7 @@
         self.fix_sentence_endings = fix_sentence_endings
         self.break_long_words = break_long_words
         self.drop_whitespace = drop_whitespace
+        self.break_on_hyphens = break_on_hyphens
 
 
     # -- Private methods -----------------------------------------------
@@ -143,8 +155,15 @@
         breaks into the following chunks:
           'Look,', ' ', 'goof-', 'ball', ' ', '--', ' ',
           'use', ' ', 'the', ' ', '-b', ' ', 'option!'
+        if break_on_hyphens is True, or in:
+          'Look,', ' ', 'goof-ball', ' ', '--', ' ',
+          'use', ' ', 'the', ' ', '-b', ' ', option!'
+        otherwise.
         """
-        chunks = self.wordsep_re.split(text)
+        if self.break_on_hyphens is True:
+            chunks = self.wordsep_re.split(text)
+        else:
+            chunks = self.wordsep_simple_re.split(text)
         chunks = filter(None, chunks)  # remove empty chunks
         return chunks
 

Modified: python/branches/tlee-ast-optimize/Lib/toaiff.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/toaiff.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/toaiff.py	Thu May 15 00:25:06 2008
@@ -7,6 +7,9 @@
 in the latter case the caller must ensure that it is removed.
 Other temporary files used are removed by the function.
 """
+from warnings import warnpy3k
+warnpy3k("the toaiff module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 import os
 import tempfile

Modified: python/branches/tlee-ast-optimize/Lib/unittest.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/unittest.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/unittest.py	Thu May 15 00:25:06 2008
@@ -682,6 +682,7 @@
         if self.showAll:
             self.stream.write(self.getDescription(test))
             self.stream.write(" ... ")
+            self.stream.flush()
 
     def addSuccess(self, test):
         TestResult.addSuccess(self, test)
@@ -689,6 +690,7 @@
             self.stream.writeln("ok")
         elif self.dots:
             self.stream.write('.')
+            self.stream.flush()
 
     def addError(self, test, err):
         TestResult.addError(self, test, err)
@@ -696,6 +698,7 @@
             self.stream.writeln("ERROR")
         elif self.dots:
             self.stream.write('E')
+            self.stream.flush()
 
     def addFailure(self, test, err):
         TestResult.addFailure(self, test, err)
@@ -703,6 +706,7 @@
             self.stream.writeln("FAIL")
         elif self.dots:
             self.stream.write('F')
+            self.stream.flush()
 
     def printErrors(self):
         if self.dots or self.showAll:

Modified: python/branches/tlee-ast-optimize/Lib/urllib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/urllib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/urllib.py	Thu May 15 00:25:06 2008
@@ -1321,44 +1321,214 @@
 
 
 if sys.platform == 'darwin':
-    def getproxies_internetconfig():
-        """Return a dictionary of scheme -> proxy server URL mappings.
+    def _CStringFromCFString(sc, value):
+        from ctypes import create_string_buffer
+        length = sc.CFStringGetLength(value) + 1
+        buff = create_string_buffer(length)
+        sc.CFStringGetCString(value, buff, length, 0)
+        return buff.value
+
+    def _CFNumberToInt32(sc, cfnum):
+        from ctypes import byref, c_int
+        val = c_int()
+        kCFNumberSInt32Type = 3
+        sc.CFNumberGetValue(cfnum, kCFNumberSInt32Type, byref(val))
+        return val.value
 
-        By convention the mac uses Internet Config to store
-        proxies.  An HTTP proxy, for instance, is stored under
-        the HttpProxy key.
 
+    def proxy_bypass_macosx_sysconf(host):
         """
-        try:
-            import ic
-        except ImportError:
-            return {}
+        Return True iff this host shouldn't be accessed using a proxy
+
+        This function uses the MacOSX framework SystemConfiguration
+        to fetch the proxy information.
+        """
+        from ctypes import cdll
+        from ctypes.util import find_library
+        import re
+        import socket
+        from fnmatch import fnmatch
+
+        def ip2num(ipAddr):
+            parts = ipAddr.split('.')
+            parts = map(int, parts)
+            if len(parts) != 4:
+                parts = (parts + [0, 0, 0, 0])[:4]
+            return (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8) | parts[3]
+
+        sc = cdll.LoadLibrary(find_library("SystemConfiguration"))
+
+        hostIP = None
+
+        if not sc:
+            return False
+
+        kSCPropNetProxiesExceptionsList = sc.CFStringCreateWithCString(0, "ExceptionsList", 0)
+        kSCPropNetProxiesExcludeSimpleHostnames = sc.CFStringCreateWithCString(0,
+                "ExcludeSimpleHostnames", 0)
+
+
+        proxyDict = sc.SCDynamicStoreCopyProxies(None)
 
         try:
-            config = ic.IC()
-        except ic.error:
+            # Check for simple host names:
+            if '.' not in host:
+                exclude_simple = sc.CFDictionaryGetValue(proxyDict,
+                        kSCPropNetProxiesExcludeSimpleHostnames)
+                if exclude_simple and _CFNumberToInt32(sc, exclude_simple):
+                    return True
+
+
+            # Check the exceptions list:
+            exceptions = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesExceptionsList)
+            if exceptions:
+                # Items in the list are strings like these: *.local, 169.254/16
+                for index in xrange(sc.CFArrayGetCount(exceptions)):
+                    value = sc.CFArrayGetValueAtIndex(exceptions, index)
+                    if not value: continue
+                    value = _CStringFromCFString(sc, value)
+
+                    m = re.match(r"(\d+(?:\.\d+)*)(/\d+)?", value)
+                    if m is not None:
+                        if hostIP is None:
+                            hostIP = socket.gethostbyname(host)
+                            hostIP = ip2num(hostIP)
+
+                        base = ip2num(m.group(1))
+                        mask = int(m.group(2)[1:])
+                        mask = 32 - mask
+
+                        if (hostIP >> mask) == (base >> mask):
+                            return True
+
+                    elif fnmatch(host, value):
+                        return True
+
+            return False
+
+        finally:
+            sc.CFRelease(kSCPropNetProxiesExceptionsList)
+            sc.CFRelease(kSCPropNetProxiesExcludeSimpleHostnames)
+
+
+
+    def getproxies_macosx_sysconf():
+        """Return a dictionary of scheme -> proxy server URL mappings.
+
+        This function uses the MacOSX framework SystemConfiguration
+        to fetch the proxy information.
+        """
+        from ctypes import cdll
+        from ctypes.util import find_library
+
+        sc = cdll.LoadLibrary(find_library("SystemConfiguration"))
+
+        if not sc:
             return {}
+
+
+        kSCPropNetProxiesHTTPEnable = sc.CFStringCreateWithCString(0, "HTTPEnable", 0)
+        kSCPropNetProxiesHTTPProxy = sc.CFStringCreateWithCString(0, "HTTPProxy", 0)
+        kSCPropNetProxiesHTTPPort = sc.CFStringCreateWithCString(0, "HTTPPort", 0)
+
+        kSCPropNetProxiesHTTPSEnable = sc.CFStringCreateWithCString(0, "HTTPSEnable", 0)
+        kSCPropNetProxiesHTTPSProxy = sc.CFStringCreateWithCString(0, "HTTPSProxy", 0)
+        kSCPropNetProxiesHTTPSPort = sc.CFStringCreateWithCString(0, "HTTPSPort", 0)
+
+        kSCPropNetProxiesFTPEnable = sc.CFStringCreateWithCString(0, "FTPEnable", 0)
+        kSCPropNetProxiesFTPPassive = sc.CFStringCreateWithCString(0, "FTPPassive", 0)
+        kSCPropNetProxiesFTPPort = sc.CFStringCreateWithCString(0, "FTPPort", 0)
+        kSCPropNetProxiesFTPProxy = sc.CFStringCreateWithCString(0, "FTPProxy", 0)
+
+        kSCPropNetProxiesGopherEnable = sc.CFStringCreateWithCString(0, "GopherEnable", 0)
+        kSCPropNetProxiesGopherPort = sc.CFStringCreateWithCString(0, "GopherPort", 0)
+        kSCPropNetProxiesGopherProxy = sc.CFStringCreateWithCString(0, "GopherProxy", 0)
+
         proxies = {}
-        # HTTP:
-        if 'UseHTTPProxy' in config and config['UseHTTPProxy']:
-            try:
-                value = config['HTTPProxyHost']
-            except ic.error:
-                pass
-            else:
-                proxies['http'] = 'http://%s' % value
-        # FTP: XXX To be done.
-        # Gopher: XXX To be done.
+        proxyDict = sc.SCDynamicStoreCopyProxies(None)
+
+        try:
+            # HTTP:
+            enabled = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesHTTPEnable)
+            if enabled and _CFNumberToInt32(sc, enabled):
+                proxy = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesHTTPProxy)
+                port = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesHTTPPort)
+
+                if proxy:
+                    proxy = _CStringFromCFString(sc, proxy)
+                    if port:
+                        port = _CFNumberToInt32(sc, port)
+                        proxies["http"] = "http://%s:%i" % (proxy, port)
+                    else:
+                        proxies["http"] = "http://%s" % (proxy, )
+
+            # HTTPS:
+            enabled = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesHTTPSEnable)
+            if enabled and _CFNumberToInt32(sc, enabled):
+                proxy = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesHTTPSProxy)
+                port = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesHTTPSPort)
+
+                if proxy:
+                    proxy = _CStringFromCFString(sc, proxy)
+                    if port:
+                        port = _CFNumberToInt32(sc, port)
+                        proxies["https"] = "http://%s:%i" % (proxy, port)
+                    else:
+                        proxies["https"] = "http://%s" % (proxy, )
+
+            # FTP:
+            enabled = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesFTPEnable)
+            if enabled and _CFNumberToInt32(sc, enabled):
+                proxy = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesFTPProxy)
+                port = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesFTPPort)
+
+                if proxy:
+                    proxy = _CStringFromCFString(sc, proxy)
+                    if port:
+                        port = _CFNumberToInt32(sc, port)
+                        proxies["ftp"] = "http://%s:%i" % (proxy, port)
+                    else:
+                        proxies["ftp"] = "http://%s" % (proxy, )
+
+            # Gopher:
+            enabled = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesGopherEnable)
+            if enabled and _CFNumberToInt32(sc, enabled):
+                proxy = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesGopherProxy)
+                port = sc.CFDictionaryGetValue(proxyDict, kSCPropNetProxiesGopherPort)
+
+                if proxy:
+                    proxy = _CStringFromCFString(sc, proxy)
+                    if port:
+                        port = _CFNumberToInt32(sc, port)
+                        proxies["gopher"] = "http://%s:%i" % (proxy, port)
+                    else:
+                        proxies["gopher"] = "http://%s" % (proxy, )
+        finally:
+            sc.CFRelease(proxyDict)
+
+        sc.CFRelease(kSCPropNetProxiesHTTPEnable)
+        sc.CFRelease(kSCPropNetProxiesHTTPProxy)
+        sc.CFRelease(kSCPropNetProxiesHTTPPort)
+        sc.CFRelease(kSCPropNetProxiesFTPEnable)
+        sc.CFRelease(kSCPropNetProxiesFTPPassive)
+        sc.CFRelease(kSCPropNetProxiesFTPPort)
+        sc.CFRelease(kSCPropNetProxiesFTPProxy)
+        sc.CFRelease(kSCPropNetProxiesGopherEnable)
+        sc.CFRelease(kSCPropNetProxiesGopherPort)
+        sc.CFRelease(kSCPropNetProxiesGopherProxy)
+
         return proxies
 
+
+
     def proxy_bypass(host):
         if getproxies_environment():
             return proxy_bypass_environment(host)
         else:
-            return 0
+            return proxy_bypass_macosx_sysconf(host)
 
     def getproxies():
-        return getproxies_environment() or getproxies_internetconfig()
+        return getproxies_environment() or getproxies_macosx_sysconf()
 
 elif os.name == 'nt':
     def getproxies_registry():

Modified: python/branches/tlee-ast-optimize/Lib/user.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/user.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/user.py	Thu May 15 00:25:06 2008
@@ -20,6 +20,9 @@
 wishes to do different things depending on the Python version.
 
 """
+from warnings import warnpy3k
+warnpy3k("the user module has been removed in Python 3.0", stacklevel=2)
+del warnpy3k
 
 import os
 

Modified: python/branches/tlee-ast-optimize/Lib/warnings.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/warnings.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/warnings.py	Thu May 15 00:25:06 2008
@@ -278,9 +278,6 @@
                 _show_warning(message, category, filename, lineno)
             else:
                 warn(showwarning_msg, DeprecationWarning)
-    if not callable(showwarning):
-        raise TypeError("warnings.showwarning() must be set to a "
-                        "function or method")
     # Print message and context
     showwarning(message, category, filename, lineno)
 

Modified: python/branches/tlee-ast-optimize/Mac/Modules/ColorPickermodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Modules/ColorPickermodule.c	(original)
+++ python/branches/tlee-ast-optimize/Mac/Modules/ColorPickermodule.c	Thu May 15 00:25:06 2008
@@ -64,6 +64,9 @@
 void initColorPicker(void)
 {
 	PyObject *m;
+	
+	if (PyErr_WarnPy3k("In 3.x, ColorPicker is removed.", 1) < 0)
+		return;
 
 	/* Create the module and add the functions */
 	m = Py_InitModule4("ColorPicker", cp_methods,

Modified: python/branches/tlee-ast-optimize/Mac/Modules/MacOS.c
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Modules/MacOS.c	(original)
+++ python/branches/tlee-ast-optimize/Mac/Modules/MacOS.c	Thu May 15 00:25:06 2008
@@ -603,6 +603,9 @@
 {
 	PyObject *m, *d;
 	
+	if (PyErr_WarnPy3k("In 3.x, MacOS is removed.", 1))
+		return;
+	
 	m = Py_InitModule("MacOS", MacOS_Methods);
 	d = PyModule_GetDict(m);
 	

Modified: python/branches/tlee-ast-optimize/Mac/Modules/Nav.c
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Modules/Nav.c	(original)
+++ python/branches/tlee-ast-optimize/Mac/Modules/Nav.c	Thu May 15 00:25:06 2008
@@ -916,6 +916,9 @@
 initNav(void)
 {
 	PyObject *m, *d;
+	
+	if (PyErr_WarnPy3k("In 3.x, Nav is removed.", 1))
+		return;
 
 	/* Test that we have NavServices */
 	if ( !NavServicesAvailable() ) {

Modified: python/branches/tlee-ast-optimize/Mac/Modules/OSATerminology.c
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Modules/OSATerminology.c	(original)
+++ python/branches/tlee-ast-optimize/Mac/Modules/OSATerminology.c	Thu May 15 00:25:06 2008
@@ -89,5 +89,7 @@
 void
 initOSATerminology(void)
 {
+	if (PyErr_WarnPy3k("In 3.x, OSATerminology is removed.", 1) < 0)
+		return;
 	Py_InitModule("OSATerminology", OSATerminology_methods);
 }
\ No newline at end of file

Modified: python/branches/tlee-ast-optimize/Mac/Modules/autoGIL.c
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Modules/autoGIL.c	(original)
+++ python/branches/tlee-ast-optimize/Mac/Modules/autoGIL.c	Thu May 15 00:25:06 2008
@@ -134,6 +134,9 @@
 {
 	PyObject *mod;
 
+	if (PyErr_WarnPy3k("In 3.x, the autoGIL module is removed.", 1) < 0)
+		return;
+
 	mod = Py_InitModule4("autoGIL", autoGIL_methods, autoGIL_docs,
 			     NULL, PYTHON_API_VERSION);
 	if (mod == NULL)

Modified: python/branches/tlee-ast-optimize/Mac/Modules/icgluemodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Modules/icgluemodule.c	(original)
+++ python/branches/tlee-ast-optimize/Mac/Modules/icgluemodule.c	Thu May 15 00:25:06 2008
@@ -453,6 +453,9 @@
 initicglue(void)
 {
 	PyObject *m, *d;
+	
+	if (PyErr_WarnPy3k("In 3.x, icglue is removed.", 1))
+		return;
 
 	/* Create the module and add the functions */
 	m = Py_InitModule4("icglue", ic_methods,

Modified: python/branches/tlee-ast-optimize/Makefile.pre.in
==============================================================================
--- python/branches/tlee-ast-optimize/Makefile.pre.in	(original)
+++ python/branches/tlee-ast-optimize/Makefile.pre.in	Thu May 15 00:25:06 2008
@@ -478,7 +478,7 @@
 		echo "Modules/Setup.dist is newer than Modules/Setup;"; \
 		echo "check to make sure you have all the updates you"; \
 		echo "need in your Modules/Setup file."; \
-		echo "Usually, copying Setup.dist to Setup will work."; \
+		echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
 		echo "-----------------------------------------------"; \
 	fi
 
@@ -550,7 +550,8 @@
 		$(srcdir)/Objects/stringlib/stringdefs.h \
 		$(srcdir)/Objects/stringlib/string_format.h \
 		$(srcdir)/Objects/stringlib/transmogrify.h \
-		$(srcdir)/Objects/stringlib/unicodedefs.h
+		$(srcdir)/Objects/stringlib/unicodedefs.h \
+		$(srcdir)/Objects/stringlib/localeutil.h
 
 Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
 				$(STRINGLIB_HEADERS)
@@ -809,12 +810,13 @@
 		test/decimaltestdata \
 		encodings compiler hotshot \
 		email email/mime email/test email/test/data \
+		json json/tests \
 		sqlite3 sqlite3/test \
 		logging bsddb bsddb/test csv wsgiref \
-		lib2to3 lib2to3/fixes lib2to3/pgen2 \
+		lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
 		ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
 		distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
-		setuptools setuptools/command setuptools/tests setuptools.egg-info \
+		lib-old \
 		curses $(MACHDEPS)
 libinstall:	build_all $(srcdir)/Lib/$(PLATDIR)
 	@for i in $(SCRIPTDIR) $(LIBDEST); \

Modified: python/branches/tlee-ast-optimize/Misc/ACKS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/ACKS	(original)
+++ python/branches/tlee-ast-optimize/Misc/ACKS	Thu May 15 00:25:06 2008
@@ -589,6 +589,7 @@
 Hajime Saitou
 Rich Salz
 Kevin Samborn
+Ilya Sandler
 Ty Sarna
 Ben Sayer
 Michael Scharf
@@ -758,3 +759,4 @@
 Uwe Zessin
 Amaury Forgeot d'Arc
 Peter Åstrand
+Tarek ZiadŽ

Modified: python/branches/tlee-ast-optimize/Misc/NEWS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/NEWS	(original)
+++ python/branches/tlee-ast-optimize/Misc/NEWS	Thu May 15 00:25:06 2008
@@ -4,10 +4,112 @@
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
+What's New in Python 2.6 beta 1?
+================================
+
+*Release date: XX-June-2008*
+
+Core and Builtins
+-----------------
+
+- Issue #2831: enumerate() now has a ``start`` argument.
+
+- Issue #2801: fix bug in the float.is_integer method where a ValueError
+  was sometimes incorrectly raised.
+
+- Issue #2790: sys.flags was not properly exposing its bytes_warning attribute.
+
+- Issue #2196: hasattr now lets exceptions which do not inherit Exception
+  (KeyboardInterrupt, and SystemExit) propagate instead of ignoring them
+
+Extension Modules
+-----------------
+
+- Support for Windows9x has been removed from the winsound module.
+
+- bsddb module updated to version 4.6.4.
+
+Library
+-------
+
+- The al and AL modules for IRIX have been deprecated for removal in
+  Python 3.0.
+
+- #1713041: fix pprint's handling of maximum depth.
+
+- The timing module has been deprecated for removal in Python 3.0.
+
+- The sv module has been deprecated for removal in Python 3.0.
+
+- The multifile module has been deprecated as per PEP 4.
+
+- The SocketServer module has been renamed 'socketserver'.  The old
+  name is now deprecated.
+
+- The imageop module has been deprecated for removal in Python 3.0.
+
+- #2250: Exceptions raised during evaluation of names in rlcompleter's
+  ``Completer.complete()`` method are now caught and ignored.
+
+- #2659: Added ``break_on_hyphens`` option to textwrap TextWrapper class.
+
+- The mhlib module has been deprecated for removal in Python 3.0.
+
+- The linuxaudiodev module has been deprecated for removal in Python 3.0.
+
+- The ihooks module has been deprecated for removal in Python 3.0.
+
+- The fpformat module has been deprecated for removal in Python 3.0.
+
+- The dl module has been deprecated for removal in Python 3.0.
+
+- The Canvas module has been deprecated for removal in Python 3.0.
+
+- The compiler package has been deprecated for removal in Python 3.0.
+
+- The Bastion and rexec modules have been deprecated for removal in Python 3.0.
+
+- The bsddb185 module has been deprecated for removal in Python 3.0.
+
+- The pure module has been deprecated for removal in Python 3.0.
+
+- Issue #2487: change the semantics of math.ldexp(x, n) when n is too
+  large to fit in a C long.  ldexp(x, n) now returns a zero (with
+  suitable sign) if n is large and negative; previously, it raised
+  OverflowError.
+
+- The toaiff module has been deprecated for removal in Python 3.0.
+
+- The test.testall module has been deprecated for removal in Python 3.0.
+
+- The new module has been deprecated for removal in Python 3.0.
+
+- The user module has been deprecated for removal in Python 3.0.
+
+- The stringold module has been deprecated for removal in Python 3.0.
+
+- The mutex module has been deprecated for removal in Python 3.0.
+
+- The imputil module has been deprecated for removal in Python 3.0.
+
+- test.test_support.catch_warning() gained a 'record' argument.
+
+- os.path.walk is deprecated in favor of os.walk.
+
+- pdb gained the "until" command.
+
+- The Mac Modules (including Carbon) have been deprecated for removal in
+  3.0.
+
+Build
+-----
+
+- ``Lib/lib-old`` is now added to sys.path.
+
 What's New in Python 2.6 alpha 3?
 =================================
 
-*Release date: XX-XXX-2008*
+*Release date: 08-May-2008*
 
 Core and builtins
 -----------------
@@ -314,6 +416,11 @@
   platforms when x is too large to fit into an IEEE 754 float; previously
   it only raised OverflowError on non IEEE 754 platforms.
 
+- Issues #2166, #1741 and #1531505: now distutils deals with HOME
+  correctly under win32
+
+- #1858: distutils: added multiple server support in .pypirc
+
 - Issue #1106316: pdb.post_mortem()'s parameter, "traceback", is now
   optional: it defaults to the traceback of the exception that is currently
   being handled (is mandatory to be in the middle of an exception, otherwise

Modified: python/branches/tlee-ast-optimize/Misc/RPM/python-2.6.spec
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/RPM/python-2.6.spec	(original)
+++ python/branches/tlee-ast-optimize/Misc/RPM/python-2.6.spec	Thu May 15 00:25:06 2008
@@ -34,7 +34,7 @@
 
 %define name python
 #--start constants--
-%define version 2.6a2
+%define version 2.6a3
 %define libver 2.6
 #--end constants--
 %define release 1pydotorg

Modified: python/branches/tlee-ast-optimize/Misc/TextMate/Python-Dev.tmbundle/Commands/2 to 3 - Module Deletion.tmCommand
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/TextMate/Python-Dev.tmbundle/Commands/2 to 3 - Module Deletion.tmCommand	(original)
+++ python/branches/tlee-ast-optimize/Misc/TextMate/Python-Dev.tmbundle/Commands/2 to 3 - Module Deletion.tmCommand	Thu May 15 00:25:06 2008
@@ -6,24 +6,50 @@
 	<string>nop</string>
 	<key>command</key>
 	<string>#!/usr/bin/python
+"""Generate code to warn about a module's removal in Python 3.0.
 
-template = """from warnings import warnpy3k
+XXX Not supported:
+- Module's in a package do not have their full name generated.
+- Package's __init__ module; should detect and use the package's name instead.
+
+"""
+py_template = """from warnings import warnpy3k
 warnpy3k("the ${1:%s} module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-$0"""
+del warnpy3k$0"""
+
+c_template = """
+if (PyErr_WarnPy3k("the ${1:%s} module has been removed in "
+                   "Python 3.0", 2) &lt; 0)
+    return;$0"""
+
 
 import imp
 import os
 
 file_name = os.path.split(os.environ['TM_FILEPATH'])[1]
-for suffix in (tuple_[0] for tuple_ in imp.get_suffixes()):
-    if not file_name.endswith(suffix):
+
+py_suffixes = reversed(sorted((suffix[0] for suffix in imp.get_suffixes() if suffix[2] == imp.PY_SOURCE), key=len))
+c_suffixes = reversed(sorted((os.path.splitext(suffix[0])[0] + '.c'
+                                for suffix in imp.get_suffixes() if suffix[2] == imp.C_EXTENSION), key=len))
+
+pairings = ((py_suffixes, py_template), (c_suffixes, c_template))
+
+def create_template(suffixes, template):
+    for suffix in suffixes:
+        if not file_name.endswith(suffix):
+            continue
+        module_name = file_name[:-len(suffix)]
+        return template % module_name
+    else:
+        return None
+
+for template in (create_template(*pair) for pair in pairings):
+    if not template:
         continue
-    module_name = file_name[:-len(suffix)]
-    print (template % module_name),
+    print template,
     break
 else:
-    print (template % "XXX"),</string>
+    print 'XXX Could not generate code.'</string>
 	<key>input</key>
 	<string>none</string>
 	<key>name</key>

Modified: python/branches/tlee-ast-optimize/Misc/TextMate/Python-Dev.tmbundle/info.plist
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/TextMate/Python-Dev.tmbundle/info.plist	(original)
+++ python/branches/tlee-ast-optimize/Misc/TextMate/Python-Dev.tmbundle/info.plist	Thu May 15 00:25:06 2008
@@ -22,10 +22,12 @@
 	<string>Python-Dev</string>
 	<key>ordering</key>
 	<array>
+		<string>9519C22B-6AB8-41A1-94F6-079E0B45C147</string>
 		<string>B545BB1B-A8E1-426C-B50A-426E78B96D38</string>
 		<string>6EF151E5-7149-4F82-8796-0CC40FE589FA</string>
 		<string>FD25A8DC-22DC-4ED4-B222-B943C8A9117D</string>
 		<string>BF336FFF-E14D-4BF1-A156-71CF768AC034</string>
+		<string>EDBB037F-AAE3-4512-863F-D9AA82C9E51E</string>
 	</array>
 	<key>uuid</key>
 	<string>A932ECD1-D43A-4F57-B7FB-A1CEC3B65D20</string>

Modified: python/branches/tlee-ast-optimize/Misc/cheatsheet
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/cheatsheet	(original)
+++ python/branches/tlee-ast-optimize/Misc/cheatsheet	Thu May 15 00:25:06 2008
@@ -1973,7 +1973,7 @@
                  sys.path.
 smtplib          SMTP Client class (RFC 821)
 sndhdr           Several routines that help recognizing sound.
-SocketServer     Generic socket server classes.
+socketserver     Generic socket server classes.
 stat             Constants and functions for interpreting stat/lstat struct.
 statcache        Maintain a cache of file stats.
 statvfs          Constants for interpreting statvfs struct as returned by
@@ -2271,5 +2271,3 @@
 after editing, any remembered breakpoints are likely to be wrong.
 
 Always single-steps through top-most stack frame. That is, "c" acts like "n".
-
-

Modified: python/branches/tlee-ast-optimize/Modules/Setup.dist
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/Setup.dist	(original)
+++ python/branches/tlee-ast-optimize/Modules/Setup.dist	Thu May 15 00:25:06 2008
@@ -98,7 +98,10 @@
 # The TKPATH variable is always enabled, to save you the effort.
 TKPATH=:lib-tk
 
-COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH)
+# Path component for old modules.
+OLDPATH=:lib-old
+
+COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH)$(OLDPATH)
 PYTHONPATH=$(COREPYTHONPATH)
 
 

Modified: python/branches/tlee-ast-optimize/Modules/_bsddb.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_bsddb.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/_bsddb.c	Thu May 15 00:25:06 2008
@@ -36,7 +36,7 @@
 /*
  * Handwritten code to wrap version 3.x of the Berkeley DB library,
  * written to replace a SWIG-generated file.  It has since been updated
- * to compile with BerkeleyDB versions 3.2 through 4.2.
+ * to compile with Berkeley DB versions 3.2 through 4.2.
  *
  * This module was started by Andrew Kuchling to remove the dependency
  * on SWIG in a package by Gregory P. Smith who based his work on a
@@ -48,7 +48,10 @@
  * the DB 3.x API and to build a solid unit test suite.  Robin has
  * since gone onto other projects (wxPython).
  *
- * Gregory P. Smith <greg at krypto.org> is once again the maintainer.
+ * Gregory P. Smith <greg at krypto.org> was once again the maintainer.
+ *
+ * Since January 2008, new maintainer is Jesus Cea <jcea at argo.es>.
+ * Jesus Cea licenses this code to PSF under a Contributor Agreement.
  *
  * Use the pybsddb-users at lists.sf.net mailing list for all questions.
  * Things can change faster than the header of this file is updated.  This
@@ -183,6 +186,10 @@
 static PyObject* DBNoSuchFileError;     /* ENOENT */
 static PyObject* DBPermissionsError;    /* EPERM  */
 
+#if (DBVER >= 42)
+static PyObject* DBRepHandleDeadError;  /* DB_REP_HANDLE_DEAD */
+#endif
+
 #if (DBVER < 43)
 #define	DB_BUFFER_SMALL		ENOMEM
 #endif
@@ -202,6 +209,9 @@
 
 
 staticforward PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type;
+#if (DBVER >= 43)
+staticforward PyTypeObject DBSequence_Type;
+#endif
 
 #ifndef Py_TYPE
 /* for compatibility with Python 2.5 and earlier */
@@ -217,10 +227,77 @@
 #define DBSequenceObject_Check(v)   (Py_TYPE(v) == &DBSequence_Type)
 #endif
 
+#if (DBVER < 46)
+  #define _DBC_close(dbc)           dbc->c_close(dbc)
+  #define _DBC_count(dbc,a,b)       dbc->c_count(dbc,a,b)
+  #define _DBC_del(dbc,a)           dbc->c_del(dbc,a)
+  #define _DBC_dup(dbc,a,b)         dbc->c_dup(dbc,a,b)
+  #define _DBC_get(dbc,a,b,c)       dbc->c_get(dbc,a,b,c)
+  #define _DBC_pget(dbc,a,b,c,d)    dbc->c_pget(dbc,a,b,c,d)
+  #define _DBC_put(dbc,a,b,c)       dbc->c_put(dbc,a,b,c)
+#else
+  #define _DBC_close(dbc)           dbc->close(dbc)
+  #define _DBC_count(dbc,a,b)       dbc->count(dbc,a,b)
+  #define _DBC_del(dbc,a)           dbc->del(dbc,a)
+  #define _DBC_dup(dbc,a,b)         dbc->dup(dbc,a,b)
+  #define _DBC_get(dbc,a,b,c)       dbc->get(dbc,a,b,c)
+  #define _DBC_pget(dbc,a,b,c,d)    dbc->pget(dbc,a,b,c,d)
+  #define _DBC_put(dbc,a,b,c)       dbc->put(dbc,a,b,c)
+#endif
+
 
 /* --------------------------------------------------------------------- */
 /* Utility macros and functions */
 
+#define INSERT_IN_DOUBLE_LINKED_LIST(backlink,object)                   \
+    {                                                                   \
+        object->sibling_next=backlink;                                  \
+        object->sibling_prev_p=&(backlink);                             \
+        backlink=object;                                                \
+        if (object->sibling_next) {                                     \
+          object->sibling_next->sibling_prev_p=&(object->sibling_next); \
+        }                                                               \
+    }
+
+#define EXTRACT_FROM_DOUBLE_LINKED_LIST(object)                          \
+    {                                                                    \
+        if (object->sibling_next) {                                      \
+            object->sibling_next->sibling_prev_p=object->sibling_prev_p; \
+        }                                                                \
+        *(object->sibling_prev_p)=object->sibling_next;                  \
+    }
+
+#define EXTRACT_FROM_DOUBLE_LINKED_LIST_MAYBE_NULL(object)               \
+    {                                                                    \
+        if (object->sibling_next) {                                      \
+            object->sibling_next->sibling_prev_p=object->sibling_prev_p; \
+        }                                                                \
+        if (object->sibling_prev_p) {                                    \
+            *(object->sibling_prev_p)=object->sibling_next;              \
+        }                                                                \
+    }
+
+#define INSERT_IN_DOUBLE_LINKED_LIST_TXN(backlink,object)  \
+    {                                                      \
+        object->sibling_next_txn=backlink;                 \
+        object->sibling_prev_p_txn=&(backlink);            \
+        backlink=object;                                   \
+        if (object->sibling_next_txn) {                    \
+            object->sibling_next_txn->sibling_prev_p_txn=  \
+                &(object->sibling_next_txn);               \
+        }                                                  \
+    }
+
+#define EXTRACT_FROM_DOUBLE_LINKED_LIST_TXN(object)             \
+    {                                                           \
+        if (object->sibling_next_txn) {                         \
+            object->sibling_next_txn->sibling_prev_p_txn=       \
+                object->sibling_prev_p_txn;                     \
+        }                                                       \
+        *(object->sibling_prev_p_txn)=object->sibling_next_txn; \
+    }
+
+
 #define RETURN_IF_ERR()          \
     if (makeDBError(err)) {      \
         return NULL;             \
@@ -443,6 +520,66 @@
 }
 
 
+/*
+** We need these functions because some results
+** are undefined if pointer is NULL. Some other
+** give None instead of "".
+**
+** This functions are static and will be
+** -I hope- inlined.
+*/
+static const char *DummyString = "This string is a simple placeholder";
+static PyObject *Build_PyString(const char *p,int s)
+{
+  if (!p) {
+    p=DummyString;
+    assert(s==0);
+  }
+  return PyString_FromStringAndSize(p,s);
+}
+
+static PyObject *BuildValue_S(const void *p,int s)
+{
+  if (!p) {
+    p=DummyString;
+    assert(s==0);
+  }
+  return Py_BuildValue("s#",p,s);
+}
+
+static PyObject *BuildValue_SS(const void *p1,int s1,const void *p2,int s2)
+{
+  if (!p1) {
+    p1=DummyString;
+    assert(s1==0);
+  }
+  if (!p2) {
+    p2=DummyString;
+    assert(s2==0);
+  }
+  return Py_BuildValue("s#s#",p1,s1,p2,s2);
+}
+
+static PyObject *BuildValue_IS(int i,const void *p,int s)
+{
+  if (!p) {
+    p=DummyString;
+    assert(s==0);
+  }
+  return Py_BuildValue("is#",i,p,s);
+}
+
+static PyObject *BuildValue_LS(long i,const void *p,int s)
+{
+  if (!p) {
+    p=DummyString;
+    assert(s==0);
+  }
+  return Py_BuildValue("ls#",i,p,s);
+}
+
+
+
 /* make a nice exception object to raise for errors. */
 static int makeDBError(int err)
 {
@@ -505,6 +642,10 @@
         case ENOENT:  errObj = DBNoSuchFileError;   break;
         case EPERM :  errObj = DBPermissionsError;  break;
 
+#if (DBVER >= 42)
+        case DB_REP_HANDLE_DEAD : errObj = DBRepHandleDeadError; break;
+#endif
+
         default:      errObj = DBError;             break;
     }
 
@@ -608,16 +749,11 @@
     flags |= extra_flags;
     CLEAR_DBT(key);
     CLEAR_DBT(data);
-    if (CHECK_DBFLAG(self->mydb, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
-        data.flags = DB_DBT_MALLOC;
-        key.flags = DB_DBT_MALLOC;
-    }
     if (!add_partial_dbt(&data, dlen, doff))
         return NULL;
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_get(self->dbc, &key, &data, flags);
+    err = _DBC_get(self->dbc, &key, &data, flags);
     MYDB_END_ALLOW_THREADS;
 
     if ((err == DB_NOTFOUND || err == DB_KEYEMPTY)
@@ -638,21 +774,15 @@
 
         case DB_RECNO:
         case DB_QUEUE:
-            retval = Py_BuildValue("is#", *((db_recno_t*)key.data),
-                                   data.data, data.size);
+            retval = BuildValue_IS(*((db_recno_t*)key.data), data.data, data.size);
             break;
         case DB_HASH:
         case DB_BTREE:
         default:
-            retval = Py_BuildValue("s#s#", key.data, key.size,
-                                   data.data, data.size);
+            retval = BuildValue_SS(key.data, key.size, data.data, data.size);
             break;
         }
     }
-    if (!err) {
-        FREE_DBT(key);
-        FREE_DBT(data);
-    }
     return retval;
 }
 
@@ -672,7 +802,7 @@
 {
     PyObject* v;
 	/* if the value fits in regular int, use that. */
-#ifdef HAVE_LONG_LONG
+#ifdef PY_LONG_LONG
 	if (sizeof(time_t) > sizeof(long))
 		v = PyLong_FromLongLong((PY_LONG_LONG) value);
 	else
@@ -696,7 +826,16 @@
 }
 #endif
 
+#if (DBVER >= 40)
+static void _addDB_lsnToDict(PyObject* dict, char *name, DB_LSN value)
+{
+    PyObject *v = Py_BuildValue("(ll)",value.file,value.offset);
+    if (!v || PyDict_SetItemString(dict, name, v))
+        PyErr_Clear();
 
+    Py_XDECREF(v);
+}
+#endif
 
 /* --------------------------------------------------------------------- */
 /* Allocators and deallocators */
@@ -716,6 +855,10 @@
     self->flags = 0;
     self->setflags = 0;
     self->myenvobj = NULL;
+    self->children_cursors = NULL;
+#if (DBVER >=43)
+    self->children_sequences = NULL;
+#endif
 #if (DBVER >= 33)
     self->associateCallback = NULL;
     self->btCompareCallback = NULL;
@@ -728,7 +871,14 @@
         Py_INCREF(arg);
         self->myenvobj = arg;
         db_env = arg->db_env;
+        INSERT_IN_DOUBLE_LINKED_LIST(self->myenvobj->children_dbs,self);
+    } else {
+      self->sibling_prev_p=NULL;
+      self->sibling_next=NULL;
     }
+    self->txn=NULL;
+    self->sibling_prev_p_txn=NULL;
+    self->sibling_next_txn=NULL;
 
     if (self->myenvobj)
         self->moduleFlags = self->myenvobj->moduleFlags;
@@ -760,23 +910,17 @@
 }
 
 
+/* Forward declaration */
+static PyObject *DB_close_internal(DBObject* self, int flags);
+
 static void
 DB_dealloc(DBObject* self)
 {
+  PyObject *dummy;
+
     if (self->db != NULL) {
-        /* avoid closing a DB when its DBEnv has been closed out from under
-         * it */
-        if (!self->myenvobj ||
-            (self->myenvobj && self->myenvobj->db_env))
-        {
-            MYDB_BEGIN_ALLOW_THREADS;
-            self->db->close(self->db, 0);
-            MYDB_END_ALLOW_THREADS;
-        } else {
-            PyErr_Warn(PyExc_RuntimeWarning,
-                "DB could not be closed in destructor: DBEnv already closed");
-        }
-        self->db = NULL;
+      dummy=DB_close_internal(self,0);
+      Py_XDECREF(dummy);
     }
     if (self->in_weakreflist != NULL) {
         PyObject_ClearWeakRefs((PyObject *) self);
@@ -798,9 +942,8 @@
     PyObject_Del(self);
 }
 
-
 static DBCursorObject*
-newDBCursorObject(DBC* dbc, DBObject* db)
+newDBCursorObject(DBC* dbc, DBTxnObject *txn, DBObject* db)
 {
     DBCursorObject* self = PyObject_New(DBCursorObject, &DBCursor_Type);
     if (self == NULL)
@@ -808,40 +951,37 @@
 
     self->dbc = dbc;
     self->mydb = db;
+
+    INSERT_IN_DOUBLE_LINKED_LIST(self->mydb->children_cursors,self);
+    if (txn && ((PyObject *)txn!=Py_None)) {
+	    INSERT_IN_DOUBLE_LINKED_LIST_TXN(txn->children_cursors,self);
+	    self->txn=txn;
+    } else {
+	    self->txn=NULL;
+    }
+
     self->in_weakreflist = NULL;
     Py_INCREF(self->mydb);
     return self;
 }
 
 
+/* Forward declaration */
+static PyObject *DBC_close_internal(DBCursorObject* self);
+
 static void
 DBCursor_dealloc(DBCursorObject* self)
 {
-    int err;
+    PyObject *dummy;
 
+    if (self->dbc != NULL) {
+      dummy=DBC_close_internal(self);
+      Py_XDECREF(dummy);
+    }
     if (self->in_weakreflist != NULL) {
         PyObject_ClearWeakRefs((PyObject *) self);
     }
-
-    if (self->dbc != NULL) {
-	/* If the underlying database has been closed, we don't
-	   need to do anything. If the environment has been closed
-	   we need to leak, as BerkeleyDB will crash trying to access
-	   the environment. There was an exception when the 
-	   user closed the environment even though there still was
-	   a database open. */
-	if (self->mydb->db && self->mydb->myenvobj &&
-	    !self->mydb->myenvobj->closed)
-        /* test for: open db + no environment or non-closed environment */
-	if (self->mydb->db && (!self->mydb->myenvobj || (self->mydb->myenvobj &&
-	    !self->mydb->myenvobj->closed))) {
-            MYDB_BEGIN_ALLOW_THREADS;
-            err = self->dbc->c_close(self->dbc);
-            MYDB_END_ALLOW_THREADS;
-        }
-        self->dbc = NULL;
-    }
-    Py_XDECREF( self->mydb );
+    Py_DECREF(self->mydb);
     PyObject_Del(self);
 }
 
@@ -858,8 +998,14 @@
     self->flags = flags;
     self->moduleFlags.getReturnsNone = DEFAULT_GET_RETURNS_NONE;
     self->moduleFlags.cursorSetReturnsNone = DEFAULT_CURSOR_SET_RETURNS_NONE;
+    self->children_dbs = NULL;
+    self->children_txns = NULL;
     self->in_weakreflist = NULL;
 
+#if (DBVER >= 40)
+    self->event_notifyCallback = NULL;
+#endif
+
     MYDB_BEGIN_ALLOW_THREADS;
     err = db_env_create(&self->db_env, flags);
     MYDB_END_ALLOW_THREADS;
@@ -869,75 +1015,119 @@
     }
     else {
         self->db_env->set_errcall(self->db_env, _db_errorCallback);
+        self->db_env->app_private=self;
     }
     return self;
 }
 
+/* Forward declaration */
+static PyObject *DBEnv_close_internal(DBEnvObject* self, int flags);
 
 static void
 DBEnv_dealloc(DBEnvObject* self)
 {
+  PyObject *dummy;
+
+    if (self->db_env && !self->closed) {
+      dummy=DBEnv_close_internal(self,0);
+      Py_XDECREF(dummy);
+    }
+
+#if (DBVER >= 40)
+    Py_XDECREF(self->event_notifyCallback);
+    self->event_notifyCallback = NULL;
+#endif
+
     if (self->in_weakreflist != NULL) {
         PyObject_ClearWeakRefs((PyObject *) self);
     }
 
-    if (self->db_env && !self->closed) {
-        MYDB_BEGIN_ALLOW_THREADS;
-        self->db_env->close(self->db_env, 0);
-        MYDB_END_ALLOW_THREADS;
-    }
     PyObject_Del(self);
 }
 
 
 static DBTxnObject*
-newDBTxnObject(DBEnvObject* myenv, DB_TXN *parent, int flags)
+newDBTxnObject(DBEnvObject* myenv, DBTxnObject *parent, DB_TXN *txn, int flags)
 {
     int err;
+    DB_TXN *parent_txn=NULL;
+
     DBTxnObject* self = PyObject_New(DBTxnObject, &DBTxn_Type);
     if (self == NULL)
         return NULL;
-    Py_INCREF(myenv);
-    self->env = (PyObject*)myenv;
+
     self->in_weakreflist = NULL;
 
-    MYDB_BEGIN_ALLOW_THREADS;
+    if (parent && ((PyObject *)parent!=Py_None)) {
+        parent_txn=parent->txn;
+    }
+
+    if (txn) {
+        self->txn=txn;
+    } else {
+        MYDB_BEGIN_ALLOW_THREADS;
 #if (DBVER >= 40)
-    err = myenv->db_env->txn_begin(myenv->db_env, parent, &(self->txn), flags);
+        err = myenv->db_env->txn_begin(myenv->db_env, parent_txn, &(self->txn), flags);
 #else
-    err = txn_begin(myenv->db_env, parent, &(self->txn), flags);
+        err = txn_begin(myenv->db_env, parent->txn, &(self_txn), flags);
 #endif
-    MYDB_END_ALLOW_THREADS;
-    if (makeDBError(err)) {
-        Py_DECREF(self->env);
-        PyObject_Del(self);
-        self = NULL;
+        MYDB_END_ALLOW_THREADS;
+
+        if (makeDBError(err)) {
+            PyObject_Del(self);
+            return NULL;
+        }
     }
+
+    if (parent_txn) { /* Can't use 'parent' because could be 'parent==Py_None' */
+        self->parent_txn=parent;
+        Py_INCREF(parent);
+        self->env = NULL;
+        INSERT_IN_DOUBLE_LINKED_LIST(parent->children_txns,self);
+    } else {
+        self->parent_txn=NULL;
+        Py_INCREF(myenv);
+        self->env = myenv;
+        INSERT_IN_DOUBLE_LINKED_LIST(myenv->children_txns,self);
+    }
+
+    self->children_txns=NULL;
+    self->children_dbs=NULL;
+    self->children_cursors=NULL;
+    self->children_sequences=NULL;
+    self->flag_prepare=0;
+
     return self;
 }
 
+/* Forward declaration */
+static PyObject *
+DBTxn_abort_discard_internal(DBTxnObject* self, int discard);
 
 static void
 DBTxn_dealloc(DBTxnObject* self)
 {
+  PyObject *dummy;
+
+    if (self->txn) {
+        int flag_prepare = self->flag_prepare;
+        dummy=DBTxn_abort_discard_internal(self,0);
+        Py_XDECREF(dummy);
+        if (!flag_prepare) {
+            PyErr_Warn(PyExc_RuntimeWarning,
+              "DBTxn aborted in destructor.  No prior commit() or abort().");
+        }
+    }
+
     if (self->in_weakreflist != NULL) {
         PyObject_ClearWeakRefs((PyObject *) self);
     }
 
-    if (self->txn) {
-        /* it hasn't been finalized, abort it! */
-        MYDB_BEGIN_ALLOW_THREADS;
-#if (DBVER >= 40)
-        self->txn->abort(self->txn);
-#else
-        txn_abort(self->txn);
-#endif
-        MYDB_END_ALLOW_THREADS;
-        PyErr_Warn(PyExc_RuntimeWarning,
-            "DBTxn aborted in destructor.  No prior commit() or abort().");
+    if (self->env) {
+        Py_DECREF(self->env);
+    } else {
+        Py_DECREF(self->parent_txn);
     }
-
-    Py_DECREF(self->env);
     PyObject_Del(self);
 }
 
@@ -991,8 +1181,11 @@
         return NULL;
     Py_INCREF(mydb);
     self->mydb = mydb;
-    self->in_weakreflist = NULL;
 
+    INSERT_IN_DOUBLE_LINKED_LIST(self->mydb->children_sequences,self);
+    self->txn=NULL;
+
+    self->in_weakreflist = NULL;
 
     MYDB_BEGIN_ALLOW_THREADS;
     err = db_sequence_create(&self->sequence, self->mydb->db, flags);
@@ -1006,10 +1199,20 @@
     return self;
 }
 
+/* Forward declaration */
+static PyObject
+*DBSequence_close_internal(DBSequenceObject* self, int flags, int do_not_close);
 
 static void
 DBSequence_dealloc(DBSequenceObject* self)
 {
+    PyObject *dummy;
+
+    if (self->sequence != NULL) {
+        dummy=DBSequence_close_internal(self,0,0);
+        Py_XDECREF(dummy);
+    }
+
     if (self->in_weakreflist != NULL) {
         PyObject_ClearWeakRefs((PyObject *) self);
     }
@@ -1072,11 +1275,9 @@
         MYDB_BEGIN_BLOCK_THREADS;
 
         if (type == DB_RECNO || type == DB_QUEUE)
-            args = Py_BuildValue("(ls#)", *((db_recno_t*)priKey->data),
-                                 priData->data, priData->size);
+            args = BuildValue_LS(*((db_recno_t*)priKey->data), priData->data, priData->size);
         else
-            args = Py_BuildValue("(s#s#)", priKey->data, priKey->size,
-                                 priData->data, priData->size);
+            args = BuildValue_SS(priKey->data, priKey->size, priData->data, priData->size);
         if (args != NULL) {
                 result = PyEval_CallObject(callback, args);
         }
@@ -1217,21 +1418,49 @@
 
 
 static PyObject*
-DB_close(DBObject* self, PyObject* args)
+DB_close_internal(DBObject* self, int flags)
 {
-    int err, flags=0;
-    if (!PyArg_ParseTuple(args,"|i:close", &flags))
-        return NULL;
+    PyObject *dummy;
+    int err;
+
     if (self->db != NULL) {
-        if (self->myenvobj)
-            CHECK_ENV_NOT_CLOSED(self->myenvobj);
+        /* Can be NULL if db is not in an environment */
+        EXTRACT_FROM_DOUBLE_LINKED_LIST_MAYBE_NULL(self);
+        if (self->txn) {
+            EXTRACT_FROM_DOUBLE_LINKED_LIST_TXN(self);
+            self->txn=NULL;
+        }
+
+        while(self->children_cursors) {
+          dummy=DBC_close_internal(self->children_cursors);
+          Py_XDECREF(dummy);
+        }
+
+#if (DBVER >= 43)
+        while(self->children_sequences) {
+            dummy=DBSequence_close_internal(self->children_sequences,0,0);
+            Py_XDECREF(dummy);
+        }
+#endif
+
+        MYDB_BEGIN_ALLOW_THREADS;
         err = self->db->close(self->db, flags);
+        MYDB_END_ALLOW_THREADS;
         self->db = NULL;
         RETURN_IF_ERR();
     }
     RETURN_NONE();
 }
 
+static PyObject*
+DB_close(DBObject* self, PyObject* args)
+{
+    int flags=0;
+    if (!PyArg_ParseTuple(args,"|i:close", &flags))
+        return NULL;
+    return DB_close_internal(self,flags);
+}
+
 
 static PyObject*
 _DB_consume(DBObject* self, PyObject* args, PyObject* kwargs, int consume_flag)
@@ -1262,7 +1491,7 @@
     CLEAR_DBT(key);
     CLEAR_DBT(data);
     if (CHECK_DBFLAG(self, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
+        /* Tell Berkeley DB to malloc the return value (thread safe) */
         data.flags = DB_DBT_MALLOC;
         key.flags = DB_DBT_MALLOC;
     }
@@ -1278,8 +1507,7 @@
         retval = Py_None;
     }
     else if (!err) {
-        retval = Py_BuildValue("s#s#", key.data, key.size, data.data,
-                               data.size);
+        retval = BuildValue_SS(key.data, key.size, data.data, data.size);
         FREE_DBT(key);
         FREE_DBT(data);
     }
@@ -1322,7 +1550,7 @@
     err = self->db->cursor(self->db, txn, &dbc, flags);
     MYDB_END_ALLOW_THREADS;
     RETURN_IF_ERR();
-    return (PyObject*) newDBCursorObject(dbc, self);
+    return (PyObject*) newDBCursorObject(dbc, (DBTxnObject *)txnobj, self);
 }
 
 
@@ -1404,7 +1632,7 @@
 
     CLEAR_DBT(data);
     if (CHECK_DBFLAG(self, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
+        /* Tell Berkeley DB to malloc the return value (thread safe) */
         data.flags = DB_DBT_MALLOC;
     }
     if (!add_partial_dbt(&data, dlen, doff)) {
@@ -1429,10 +1657,9 @@
     }
     else if (!err) {
         if (flags & DB_SET_RECNO) /* return both key and data */
-            retval = Py_BuildValue("s#s#", key.data, key.size, data.data,
-                                   data.size);
+            retval = BuildValue_SS(key.data, key.size, data.data, data.size);
         else /* return just the data */
-            retval = PyString_FromStringAndSize((char*)data.data, data.size);
+            retval = Build_PyString(data.data, data.size);
         FREE_DBT(data);
     }
     FREE_DBT(key);
@@ -1472,7 +1699,7 @@
 
     CLEAR_DBT(data);
     if (CHECK_DBFLAG(self, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
+        /* Tell Berkeley DB to malloc the return value (thread safe) */
         data.flags = DB_DBT_MALLOC;
     }
     if (!add_partial_dbt(&data, dlen, doff)) {
@@ -1501,13 +1728,13 @@
     else if (!err) {
         PyObject *pkeyObj;
         PyObject *dataObj;
-        dataObj = PyString_FromStringAndSize(data.data, data.size);
+        dataObj = Build_PyString(data.data, data.size);
 
         if (self->primaryDBType == DB_RECNO ||
             self->primaryDBType == DB_QUEUE)
             pkeyObj = PyInt_FromLong(*(int *)pkey.data);
         else
-            pkeyObj = PyString_FromStringAndSize(pkey.data, pkey.size);
+            pkeyObj = Build_PyString(pkey.data, pkey.size);
 
         if (flags & DB_SET_RECNO) /* return key , pkey and data */
         {
@@ -1516,7 +1743,7 @@
             if (type == DB_RECNO || type == DB_QUEUE)
                 keyObj = PyInt_FromLong(*(int *)key.data);
             else
-                keyObj = PyString_FromStringAndSize(key.data, key.size);
+                keyObj = Build_PyString(key.data, key.size);
 #if (PY_VERSION_HEX >= 0x02040000)
             retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj);
 #else
@@ -1620,7 +1847,7 @@
     orig_data = data.data;
 
     if (CHECK_DBFLAG(self, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
+        /* Tell Berkeley DB to malloc the return value (thread safe) */
         /* XXX(nnorwitz): At least 4.4.20 and 4.5.20 require this flag. */
         data.flags = DB_DBT_MALLOC;
     }
@@ -1637,7 +1864,7 @@
     }
     else if (!err) {
         /* XXX(nnorwitz): can we do: retval = dataobj; Py_INCREF(retval); */
-        retval = PyString_FromStringAndSize((char*)data.data, data.size);
+        retval = Build_PyString(data.data, data.size);
 
         /* Even though the flags require DB_DBT_MALLOC, data is not always
            allocated.  4.4: allocated, 4.5: *not* allocated. :-( */
@@ -1748,7 +1975,7 @@
        but does not hold python references to them or prevent
        them from being closed prematurely.  This can cause
        python to crash when things are done in the wrong order. */
-    return (PyObject*) newDBCursorObject(dbc, self);
+    return (PyObject*) newDBCursorObject(dbc, NULL, self);
 }
 
 
@@ -1845,6 +2072,17 @@
         return NULL;
     }
 
+#if (DBVER >= 41)
+    if (txn) {  /* Can't use 'txnobj' because could be 'txnobj==Py_None' */
+        INSERT_IN_DOUBLE_LINKED_LIST_TXN(((DBTxnObject *)txnobj)->children_dbs,self);
+        self->txn=(DBTxnObject *)txnobj;
+    } else {
+        self->txn=NULL;
+    }
+#else
+    self->txn=NULL;
+#endif
+
     MYDB_BEGIN_ALLOW_THREADS;
 #if (DBVER >= 41)
     err = self->db->open(self->db, txn, filename, dbname, type, flags, mode);
@@ -1853,8 +2091,10 @@
 #endif
     MYDB_END_ALLOW_THREADS;
     if (makeDBError(err)) {
-        self->db->close(self->db, 0);
-        self->db = NULL;
+        PyObject *dummy;
+
+        dummy=DB_close_internal(self,0);
+        Py_XDECREF(dummy);
         return NULL;
     }
 
@@ -1863,6 +2103,7 @@
 #endif
 
     self->flags = flags;
+
     RETURN_NONE();
 }
 
@@ -1993,7 +2234,7 @@
 }
 
 static int
-_db_compareCallback(DB* db, 
+_db_compareCallback(DB* db,
 		    const DBT *leftKey,
 		    const DBT *rightKey)
 {
@@ -2015,8 +2256,7 @@
     } else {
 	MYDB_BEGIN_BLOCK_THREADS;
 
-	args = Py_BuildValue("s#s#", leftKey->data, leftKey->size,
-			     rightKey->data, rightKey->size);
+	args = BuildValue_SS(leftKey->data, leftKey->size, rightKey->data, rightKey->size);
 	if (args != NULL) {
 		/* XXX(twouters) I highly doubt this INCREF is correct */
 		Py_INCREF(self);
@@ -2369,6 +2609,9 @@
         MAKE_HASH_ENTRY(version);
         MAKE_HASH_ENTRY(nkeys);
         MAKE_HASH_ENTRY(ndata);
+#if (DBVER >= 46)
+        MAKE_HASH_ENTRY(pagecnt);
+#endif
         MAKE_HASH_ENTRY(pagesize);
 #if (DBVER < 41)
         MAKE_HASH_ENTRY(nelem);
@@ -2391,6 +2634,9 @@
         MAKE_BT_ENTRY(version);
         MAKE_BT_ENTRY(nkeys);
         MAKE_BT_ENTRY(ndata);
+#if (DBVER >= 46)
+        MAKE_BT_ENTRY(pagecnt);
+#endif
         MAKE_BT_ENTRY(pagesize);
         MAKE_BT_ENTRY(minkey);
         MAKE_BT_ENTRY(re_len);
@@ -2400,6 +2646,9 @@
         MAKE_BT_ENTRY(leaf_pg);
         MAKE_BT_ENTRY(dup_pg);
         MAKE_BT_ENTRY(over_pg);
+#if (DBVER >= 43)
+        MAKE_BT_ENTRY(empty_pg);
+#endif
         MAKE_BT_ENTRY(free);
         MAKE_BT_ENTRY(int_pgfree);
         MAKE_BT_ENTRY(leaf_pgfree);
@@ -2413,6 +2662,9 @@
         MAKE_QUEUE_ENTRY(nkeys);
         MAKE_QUEUE_ENTRY(ndata);
         MAKE_QUEUE_ENTRY(pagesize);
+#if (DBVER > 40)
+        MAKE_QUEUE_ENTRY(extentsize);
+#endif
         MAKE_QUEUE_ENTRY(pages);
         MAKE_QUEUE_ENTRY(re_len);
         MAKE_QUEUE_ENTRY(re_pad);
@@ -2527,15 +2779,14 @@
     if (outFile)
         fclose(outFile);
 
-    /* DB.verify acts as a DB handle destructor (like close); this was
-     * documented in BerkeleyDB 4.2 but had the undocumented effect
-     * of not being safe in prior versions while still requiring an explicit
-     * DB.close call afterwards.  Lets call close for the user to emulate
-     * the safe 4.2 behaviour. */
-#if (DBVER <= 41)
-    self->db->close(self->db, 0);
-#endif
-    self->db = NULL;
+    {  /* DB.verify acts as a DB handle destructor (like close) */
+        PyObject *error;
+
+        error=DB_close_internal(self,0);
+        if (error ) {
+          return error;
+        }
+     }
 
     RETURN_IF_ERR();
     RETURN_NONE();
@@ -2622,7 +2873,7 @@
        so we can use any of them for the type cast */
     size = ((DB_BTREE_STAT*)sp)->bt_ndata;
 
-    /* A size of 0 could mean that BerkeleyDB no longer had the stat values cached.
+    /* A size of 0 could mean that Berkeley DB no longer had the stat values cached.
      * redo a full stat to make sure.
      *   Fixes SF python bug 1493322, pybsddb bug 1184012
      */
@@ -2658,7 +2909,7 @@
 
     CLEAR_DBT(data);
     if (CHECK_DBFLAG(self, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
+        /* Tell Berkeley DB to malloc the return value (thread safe) */
         data.flags = DB_DBT_MALLOC;
     }
     MYDB_BEGIN_ALLOW_THREADS;
@@ -2672,7 +2923,7 @@
         retval = NULL;
     }
     else {
-        retval = PyString_FromStringAndSize((char*)data.data, data.size);
+        retval = Build_PyString(data.data, data.size);
         FREE_DBT(data);
     }
 
@@ -2802,14 +3053,9 @@
         return NULL;
     }
 
-    if (CHECK_DBFLAG(self, DB_THREAD)) {
-        key.flags = DB_DBT_REALLOC;
-        data.flags = DB_DBT_REALLOC;
-    }
-
     while (1) { /* use the cursor to traverse the DB, collecting items */
         MYDB_BEGIN_ALLOW_THREADS;
-        err = cursor->c_get(cursor, &key, &data, DB_NEXT);
+        err = _DBC_get(cursor, &key, &data, DB_NEXT);
         MYDB_END_ALLOW_THREADS;
 
         if (err) {
@@ -2823,7 +3069,7 @@
             case DB_BTREE:
             case DB_HASH:
             default:
-                item = PyString_FromStringAndSize((char*)key.data, key.size);
+                item = Build_PyString(key.data, key.size);
                 break;
             case DB_RECNO:
             case DB_QUEUE:
@@ -2833,7 +3079,7 @@
             break;
 
         case _VALUES_LIST:
-            item = PyString_FromStringAndSize((char*)data.data, data.size);
+            item = Build_PyString(data.data, data.size);
             break;
 
         case _ITEMS_LIST:
@@ -2841,13 +3087,11 @@
             case DB_BTREE:
             case DB_HASH:
             default:
-                item = Py_BuildValue("s#s#", key.data, key.size, data.data,
-                                     data.size);
+                item = BuildValue_SS(key.data, key.size, data.data, data.size);
                 break;
             case DB_RECNO:
             case DB_QUEUE:
-                item = Py_BuildValue("is#", *((db_recno_t*)key.data),
-                                     data.data, data.size);
+                item = BuildValue_IS(*((db_recno_t*)key.data), data.data, data.size);
                 break;
             }
             break;
@@ -2872,10 +3116,8 @@
     }
 
  done:
-    FREE_DBT(key);
-    FREE_DBT(data);
     MYDB_BEGIN_ALLOW_THREADS;
-    cursor->c_close(cursor);
+    _DBC_close(cursor);
     MYDB_END_ALLOW_THREADS;
     return list;
 }
@@ -2927,23 +3169,35 @@
 
 
 static PyObject*
-DBC_close(DBCursorObject* self, PyObject* args)
+DBC_close_internal(DBCursorObject* self)
 {
     int err = 0;
 
-    if (!PyArg_ParseTuple(args, ":close"))
-        return NULL;
-
     if (self->dbc != NULL) {
+        EXTRACT_FROM_DOUBLE_LINKED_LIST(self);
+        if (self->txn) {
+            EXTRACT_FROM_DOUBLE_LINKED_LIST_TXN(self);
+            self->txn=NULL;
+        }
+
         MYDB_BEGIN_ALLOW_THREADS;
-        err = self->dbc->c_close(self->dbc);
-        self->dbc = NULL;
+        err = _DBC_close(self->dbc);
         MYDB_END_ALLOW_THREADS;
+        self->dbc = NULL;
     }
     RETURN_IF_ERR();
     RETURN_NONE();
 }
 
+static PyObject*
+DBC_close(DBCursorObject* self, PyObject* args)
+{
+    if (!PyArg_ParseTuple(args, ":close"))
+        return NULL;
+
+    return DBC_close_internal(self);
+}
+
 
 static PyObject*
 DBC_count(DBCursorObject* self, PyObject* args)
@@ -2958,7 +3212,7 @@
     CHECK_CURSOR_NOT_CLOSED(self);
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_count(self->dbc, &count, flags);
+    err = _DBC_count(self->dbc, &count, flags);
     MYDB_END_ALLOW_THREADS;
     RETURN_IF_ERR();
 
@@ -2984,7 +3238,7 @@
     CHECK_CURSOR_NOT_CLOSED(self);
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_del(self->dbc, flags);
+    err = _DBC_del(self->dbc, flags);
     MYDB_END_ALLOW_THREADS;
     RETURN_IF_ERR();
 
@@ -3005,11 +3259,11 @@
     CHECK_CURSOR_NOT_CLOSED(self);
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_dup(self->dbc, &dbc, flags);
+    err = _DBC_dup(self->dbc, &dbc, flags);
     MYDB_END_ALLOW_THREADS;
     RETURN_IF_ERR();
 
-    return (PyObject*) newDBCursorObject(dbc, self->mydb);
+    return (PyObject*) newDBCursorObject(dbc, self->txn, self->mydb);
 }
 
 static PyObject*
@@ -3059,19 +3313,12 @@
     if ( (dataobj && !make_dbt(dataobj, &data)) ||
          (!add_partial_dbt(&data, dlen, doff)) )
     {
-        FREE_DBT(key);
+        FREE_DBT(key); /* 'make_key_dbt' could do a 'malloc' */
         return NULL;
     }
 
-    if (CHECK_DBFLAG(self->mydb, DB_THREAD)) {
-        data.flags = DB_DBT_MALLOC;
-        if (!(key.flags & DB_DBT_REALLOC)) {
-            key.flags |= DB_DBT_MALLOC;
-        }
-    }
-
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_get(self->dbc, &key, &data, flags);
+    err = _DBC_get(self->dbc, &key, &data, flags);
     MYDB_END_ALLOW_THREADS;
 
     if ((err == DB_NOTFOUND || err == DB_KEYEMPTY)
@@ -3090,18 +3337,15 @@
         case DB_BTREE:
         case DB_HASH:
         default:
-            retval = Py_BuildValue("s#s#", key.data, key.size,
-                                   data.data, data.size);
+            retval = BuildValue_SS(key.data, key.size, data.data, data.size);
             break;
         case DB_RECNO:
         case DB_QUEUE:
-            retval = Py_BuildValue("is#", *((db_recno_t*)key.data),
-                                   data.data, data.size);
+            retval = BuildValue_IS(*((db_recno_t*)key.data), data.data, data.size);
             break;
         }
-        FREE_DBT(data);
     }
-    FREE_DBT(key);
+    FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
     return retval;
 }
 
@@ -3145,22 +3389,15 @@
         return NULL;
     if ( (dataobj && !make_dbt(dataobj, &data)) ||
          (!add_partial_dbt(&data, dlen, doff)) ) {
-        FREE_DBT(key);
+        FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
         return NULL;
     }
 
-    if (CHECK_DBFLAG(self->mydb, DB_THREAD)) {
-        data.flags = DB_DBT_MALLOC;
-        if (!(key.flags & DB_DBT_REALLOC)) {
-            key.flags |= DB_DBT_MALLOC;
-        }
-    }
-
     CLEAR_DBT(pkey);
     pkey.flags = DB_DBT_MALLOC;
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_pget(self->dbc, &key, &pkey, &data, flags);
+    err = _DBC_pget(self->dbc, &key, &pkey, &data, flags);
     MYDB_END_ALLOW_THREADS;
 
     if ((err == DB_NOTFOUND || err == DB_KEYEMPTY)
@@ -3174,13 +3411,13 @@
     else {
         PyObject *pkeyObj;
         PyObject *dataObj;
-        dataObj = PyString_FromStringAndSize(data.data, data.size);
+        dataObj = Build_PyString(data.data, data.size);
 
         if (self->mydb->primaryDBType == DB_RECNO ||
             self->mydb->primaryDBType == DB_QUEUE)
             pkeyObj = PyInt_FromLong(*(int *)pkey.data);
         else
-            pkeyObj = PyString_FromStringAndSize(pkey.data, pkey.size);
+            pkeyObj = Build_PyString(pkey.data, pkey.size);
 
         if (key.data && key.size) /* return key, pkey and data */
         {
@@ -3189,14 +3426,14 @@
             if (type == DB_RECNO || type == DB_QUEUE)
                 keyObj = PyInt_FromLong(*(int *)key.data);
             else
-                keyObj = PyString_FromStringAndSize(key.data, key.size);
+                keyObj = Build_PyString(key.data, key.size);
 #if (PY_VERSION_HEX >= 0x02040000)
             retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj);
 #else
             retval = Py_BuildValue("OOO", keyObj, pkeyObj, dataObj);
 #endif
             Py_DECREF(keyObj);
-            FREE_DBT(key);
+            FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
         }
         else /* return just the pkey and data */
         {
@@ -3209,11 +3446,10 @@
         Py_DECREF(dataObj);
         Py_DECREF(pkeyObj);
         FREE_DBT(pkey);
-        FREE_DBT(data);
     }
     /* the only time REALLOC should be set is if we used an integer
      * key that make_key_dbt malloc'd for us.  always free these. */
-    if (key.flags & DB_DBT_REALLOC) {
+    if (key.flags & DB_DBT_REALLOC) {  /* 'make_key_dbt' could do a 'malloc' */
         FREE_DBT(key);
     }
     return retval;
@@ -3236,20 +3472,13 @@
 
     CLEAR_DBT(key);
     CLEAR_DBT(data);
-    if (CHECK_DBFLAG(self->mydb, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
-        data.flags = DB_DBT_MALLOC;
-        key.flags = DB_DBT_MALLOC;
-    }
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_get(self->dbc, &key, &data, DB_GET_RECNO);
+    err = _DBC_get(self->dbc, &key, &data, DB_GET_RECNO);
     MYDB_END_ALLOW_THREADS;
     RETURN_IF_ERR();
 
     recno = *((db_recno_t*)data.data);
-    FREE_DBT(key);
-    FREE_DBT(data);
     return PyInt_FromLong(recno);
 }
 
@@ -3297,14 +3526,14 @@
     if (!make_dbt(dataobj, &data) ||
         !add_partial_dbt(&data, dlen, doff) )
     {
-        FREE_DBT(key);
+        FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
         return NULL;
     }
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_put(self->dbc, &key, &data, flags);
+    err = _DBC_put(self->dbc, &key, &data, flags);
     MYDB_END_ALLOW_THREADS;
-    FREE_DBT(key);
+    FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
     RETURN_IF_ERR();
     self->mydb->haveStat = 0;
     RETURN_NONE();
@@ -3331,17 +3560,13 @@
         return NULL;
 
     CLEAR_DBT(data);
-    if (CHECK_DBFLAG(self->mydb, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
-        data.flags = DB_DBT_MALLOC;
-    }
     if (!add_partial_dbt(&data, dlen, doff)) {
-        FREE_DBT(key);
+        FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
         return NULL;
     }
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_get(self->dbc, &key, &data, flags|DB_SET);
+    err = _DBC_get(self->dbc, &key, &data, flags|DB_SET);
     MYDB_END_ALLOW_THREADS;
     if ((err == DB_NOTFOUND || err == DB_KEYEMPTY)
 	    && self->mydb->moduleFlags.cursorSetReturnsNone) {
@@ -3359,22 +3584,19 @@
         case DB_BTREE:
         case DB_HASH:
         default:
-            retval = Py_BuildValue("s#s#", key.data, key.size,
-                                   data.data, data.size);
+            retval = BuildValue_SS(key.data, key.size, data.data, data.size);
             break;
         case DB_RECNO:
         case DB_QUEUE:
-            retval = Py_BuildValue("is#", *((db_recno_t*)key.data),
-                                   data.data, data.size);
+            retval = BuildValue_IS(*((db_recno_t*)key.data), data.data, data.size);
             break;
         }
-        FREE_DBT(data);
-        FREE_DBT(key);
+        FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
     }
     /* the only time REALLOC should be set is if we used an integer
      * key that make_key_dbt malloc'd for us.  always free these. */
     if (key.flags & DB_DBT_REALLOC) {
-        FREE_DBT(key);
+        FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
     }
 
     return retval;
@@ -3402,19 +3624,11 @@
 
     CLEAR_DBT(data);
     if (!add_partial_dbt(&data, dlen, doff)) {
-        FREE_DBT(key);
+        FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
         return NULL;
     }
-    if (CHECK_DBFLAG(self->mydb, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
-        data.flags |= DB_DBT_MALLOC;
-        /* only BTREE databases will return anything in the key */
-        if (!(key.flags & DB_DBT_REALLOC) && _DB_get_type(self->mydb) == DB_BTREE) {
-            key.flags |= DB_DBT_MALLOC;
-        }
-    }
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_get(self->dbc, &key, &data, flags|DB_SET_RANGE);
+    err = _DBC_get(self->dbc, &key, &data, flags|DB_SET_RANGE);
     MYDB_END_ALLOW_THREADS;
     if ((err == DB_NOTFOUND || err == DB_KEYEMPTY)
 	    && self->mydb->moduleFlags.cursorSetReturnsNone) {
@@ -3432,22 +3646,19 @@
         case DB_BTREE:
         case DB_HASH:
         default:
-            retval = Py_BuildValue("s#s#", key.data, key.size,
-                                   data.data, data.size);
+            retval = BuildValue_SS(key.data, key.size, data.data, data.size);
             break;
         case DB_RECNO:
         case DB_QUEUE:
-            retval = Py_BuildValue("is#", *((db_recno_t*)key.data),
-                                   data.data, data.size);
+            retval = BuildValue_IS(*((db_recno_t*)key.data), data.data, data.size);
             break;
         }
-        FREE_DBT(key);
-        FREE_DBT(data);
+        FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
     }
     /* the only time REALLOC should be set is if we used an integer
      * key that make_key_dbt malloc'd for us.  always free these. */
     if (key.flags & DB_DBT_REALLOC) {
-        FREE_DBT(key);
+        FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
     }
 
     return retval;
@@ -3465,12 +3676,12 @@
     if (!make_key_dbt(self->mydb, keyobj, &key, NULL))
         return NULL;
     if (!make_dbt(dataobj, &data)) {
-        FREE_DBT(key);
+        FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
         return NULL;
     }
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_get(self->dbc, &key, &data, flags|DB_GET_BOTH);
+    err = _DBC_get(self->dbc, &key, &data, flags|DB_GET_BOTH);
     MYDB_END_ALLOW_THREADS;
     if ((err == DB_NOTFOUND || err == DB_KEYEMPTY) && returnsNone) {
         Py_INCREF(Py_None);
@@ -3487,18 +3698,16 @@
         case DB_BTREE:
         case DB_HASH:
         default:
-            retval = Py_BuildValue("s#s#", key.data, key.size,
-                                   data.data, data.size);
+            retval = BuildValue_SS(key.data, key.size, data.data, data.size);
             break;
         case DB_RECNO:
         case DB_QUEUE:
-            retval = Py_BuildValue("is#", *((db_recno_t*)key.data),
-                                   data.data, data.size);
+            retval = BuildValue_IS(*((db_recno_t*)key.data), data.data, data.size);
             break;
         }
     }
 
-    FREE_DBT(key);
+    FREE_DBT(key);  /* 'make_key_dbt' could do a 'malloc' */
     return retval;
 }
 
@@ -3537,7 +3746,7 @@
     data.flags = DB_DBT_USERMEM;
     data.ulen = 0;
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_get(self->dbc, &key, &data, flags);
+    err = _DBC_get(self->dbc, &key, &data, flags);
     MYDB_END_ALLOW_THREADS;
     if (err == DB_BUFFER_SMALL || !err) {
         /* DB_BUFFER_SMALL means positive size, !err means zero length value */
@@ -3545,8 +3754,6 @@
         err = 0;
     }
 
-    FREE_DBT(key);
-    FREE_DBT(data);
     RETURN_IF_ERR();
     return retval;
 }
@@ -3600,17 +3807,13 @@
     key.flags = DB_DBT_REALLOC;
 
     CLEAR_DBT(data);
-    if (CHECK_DBFLAG(self->mydb, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
-        data.flags = DB_DBT_MALLOC;
-    }
     if (!add_partial_dbt(&data, dlen, doff)) {
         FREE_DBT(key);
         return NULL;
     }
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_get(self->dbc, &key, &data, flags|DB_SET_RECNO);
+    err = _DBC_get(self->dbc, &key, &data, flags|DB_SET_RECNO);
     MYDB_END_ALLOW_THREADS;
     if ((err == DB_NOTFOUND || err == DB_KEYEMPTY)
 	    && self->mydb->moduleFlags.cursorSetReturnsNone) {
@@ -3621,9 +3824,7 @@
         retval = NULL;
     }
     else {  /* Can only be used for BTrees, so no need to return int key */
-        retval = Py_BuildValue("s#s#", key.data, key.size,
-                               data.data, data.size);
-        FREE_DBT(data);
+        retval = BuildValue_SS(key.data, key.size, data.data, data.size);
     }
     FREE_DBT(key);
 
@@ -3673,13 +3874,9 @@
 
     CLEAR_DBT(key);
     CLEAR_DBT(data);
-    if (CHECK_DBFLAG(self->mydb, DB_THREAD)) {
-        /* Tell BerkeleyDB to malloc the return value (thread safe) */
-        key.flags = DB_DBT_MALLOC;
-    }
 
     MYDB_BEGIN_ALLOW_THREADS;
-    err = self->dbc->c_get(self->dbc, &key, &data, flags | DB_JOIN_ITEM);
+    err = _DBC_get(self->dbc, &key, &data, flags | DB_JOIN_ITEM);
     MYDB_END_ALLOW_THREADS;
     if ((err == DB_NOTFOUND || err == DB_KEYEMPTY)
 	    && self->mydb->moduleFlags.getReturnsNone) {
@@ -3690,8 +3887,7 @@
         retval = NULL;
     }
     else {
-        retval = Py_BuildValue("s#", key.data, key.size);
-        FREE_DBT(key);
+        retval = BuildValue_S(key.data, key.size);
     }
 
     return retval;
@@ -3704,18 +3900,26 @@
 
 
 static PyObject*
-DBEnv_close(DBEnvObject* self, PyObject* args)
+DBEnv_close_internal(DBEnvObject* self, int flags)
 {
-    int err, flags = 0;
+    PyObject *dummy;
+    int err;
 
-    if (!PyArg_ParseTuple(args, "|i:close", &flags))
-        return NULL;
     if (!self->closed) {      /* Don't close more than once */
+        while(self->children_txns) {
+          dummy=DBTxn_abort_discard_internal(self->children_txns,0);
+          Py_XDECREF(dummy);
+        }
+        while(self->children_dbs) {
+          dummy=DB_close_internal(self->children_dbs,0);
+          Py_XDECREF(dummy);
+        }
+
         MYDB_BEGIN_ALLOW_THREADS;
         err = self->db_env->close(self->db_env, flags);
         MYDB_END_ALLOW_THREADS;
         /* after calling DBEnv->close, regardless of error, this DBEnv
-         * may not be accessed again (BerkeleyDB docs). */
+         * may not be accessed again (Berkeley DB docs). */
         self->closed = 1;
         self->db_env = NULL;
         RETURN_IF_ERR();
@@ -3723,6 +3927,16 @@
     RETURN_NONE();
 }
 
+static PyObject*
+DBEnv_close(DBEnvObject* self, PyObject* args)
+{
+    int flags = 0;
+
+    if (!PyArg_ParseTuple(args, "|i:close", &flags))
+        return NULL;
+    return DBEnv_close_internal(self,flags);
+}
+
 
 static PyObject*
 DBEnv_open(DBEnvObject* self, PyObject* args)
@@ -3982,8 +4196,27 @@
     RETURN_NONE();
 }
 
-
-#if (DBVER >= 33)
+#if (DBVER >= 42)
+static PyObject*
+DBEnv_get_lg_max(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    u_int32_t lg_max;
+
+    if (!PyArg_ParseTuple(args, ":get_lg_max"))
+        return NULL;
+    CHECK_ENV_NOT_CLOSED(self);
+
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->get_lg_max(self->db_env, &lg_max);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    return PyInt_FromLong(lg_max);
+}
+#endif
+
+
+#if (DBVER >= 33)
 static PyObject*
 DBEnv_set_lg_regionmax(DBEnvObject* self, PyObject* args)
 {
@@ -4125,6 +4358,84 @@
 }
 
 
+#if (DBVER >= 40)
+static PyObject*
+DBEnv_txn_recover(DBEnvObject* self, PyObject* args)
+{
+    int flags = DB_FIRST;
+    int err, i;
+    PyObject *list, *tuple, *gid;
+    DBTxnObject *txn;
+#define PREPLIST_LEN 16
+    DB_PREPLIST preplist[PREPLIST_LEN];
+    long retp;
+
+    if (!PyArg_ParseTuple(args, ":txn_recover"))
+        return NULL;
+
+    CHECK_ENV_NOT_CLOSED(self);
+
+    list=PyList_New(0);
+    if (!list)
+        return NULL;
+    while (!0) {
+        MYDB_BEGIN_ALLOW_THREADS
+        err=self->db_env->txn_recover(self->db_env,
+                        preplist, PREPLIST_LEN, &retp, flags);
+#undef PREPLIST_LEN
+        MYDB_END_ALLOW_THREADS
+        if (err) {
+            Py_DECREF(list);
+            RETURN_IF_ERR();
+        }
+        if (!retp) break;
+        flags=DB_NEXT;  /* Prepare for next loop pass */
+        for (i=0; i<retp; i++) {
+            gid=PyString_FromStringAndSize((char *)(preplist[i].gid),
+                                DB_XIDDATASIZE);
+            if (!gid) {
+                Py_DECREF(list);
+                return NULL;
+            }
+            txn=newDBTxnObject(self, NULL, preplist[i].txn, flags);
+            if (!txn) {
+                Py_DECREF(list);
+                Py_DECREF(gid);
+                return NULL;
+            }
+            txn->flag_prepare=1;  /* Recover state */
+            tuple=PyTuple_New(2);
+            if (!tuple) {
+                Py_DECREF(list);
+                Py_DECREF(gid);
+                Py_DECREF(txn);
+                return NULL;
+            }
+            if (PyTuple_SetItem(tuple, 0, gid)) {
+                Py_DECREF(list);
+                Py_DECREF(gid);
+                Py_DECREF(txn);
+                Py_DECREF(tuple);
+                return NULL;
+            }
+            if (PyTuple_SetItem(tuple, 1, (PyObject *)txn)) {
+                Py_DECREF(list);
+                Py_DECREF(txn);
+                Py_DECREF(tuple); /* This delete the "gid" also */
+                return NULL;
+            }
+            if (PyList_Append(list, tuple)) {
+                Py_DECREF(list);
+                Py_DECREF(tuple);/* This delete the "gid" and the "txn" also */
+                return NULL;
+            }
+            Py_DECREF(tuple);
+        }
+    }
+    return list;
+}
+#endif
+
 static PyObject*
 DBEnv_txn_begin(DBEnvObject* self, PyObject* args, PyObject* kwargs)
 {
@@ -4141,7 +4452,7 @@
         return NULL;
     CHECK_ENV_NOT_CLOSED(self);
 
-    return (PyObject*)newDBTxnObject(self, txn, flags);
+    return (PyObject*)newDBTxnObject(self, (DBTxnObject *)txnobj, NULL, flags);
 }
 
 
@@ -4426,6 +4737,10 @@
 #if (DBVER < 41)
     MAKE_ENTRY(lastid);
 #endif
+#if (DBVER >=41)
+    MAKE_ENTRY(id);
+    MAKE_ENTRY(cur_maxid);
+#endif
     MAKE_ENTRY(nmodes);
     MAKE_ENTRY(maxlocks);
     MAKE_ENTRY(maxlockers);
@@ -4438,6 +4753,10 @@
     MAKE_ENTRY(maxnobjects);
     MAKE_ENTRY(nrequests);
     MAKE_ENTRY(nreleases);
+#if (DBVER >= 44)
+    MAKE_ENTRY(nupgrade);
+    MAKE_ENTRY(ndowngrade);
+#endif
 #if (DBVER < 44)
     MAKE_ENTRY(nnowaits);       /* these were renamed in 4.4 */
     MAKE_ENTRY(nconflicts);
@@ -4446,6 +4765,23 @@
     MAKE_ENTRY(lock_wait);
 #endif
     MAKE_ENTRY(ndeadlocks);
+#if (DBVER >= 41)
+    MAKE_ENTRY(locktimeout);
+    MAKE_ENTRY(txntimeout);
+#endif
+#if (DBVER >= 40)
+    MAKE_ENTRY(nlocktimeouts);
+    MAKE_ENTRY(ntxntimeouts);
+#endif
+#if (DBVER >= 46)
+    MAKE_ENTRY(objs_wait);
+    MAKE_ENTRY(objs_nowait);
+    MAKE_ENTRY(lockers_wait);
+    MAKE_ENTRY(lockers_nowait);
+    MAKE_ENTRY(locks_wait);
+    MAKE_ENTRY(locks_nowait);
+    MAKE_ENTRY(hash_len);
+#endif
     MAKE_ENTRY(regsize);
     MAKE_ENTRY(region_wait);
     MAKE_ENTRY(region_nowait);
@@ -4455,130 +4791,653 @@
     return d;
 }
 
+#if (DBVER >= 40)
+static PyObject*
+DBEnv_log_flush(DBEnvObject* self, PyObject* args)
+{
+    int err;
+
+    if (!PyArg_ParseTuple(args, ":log_flush"))
+        return NULL;
+    CHECK_ENV_NOT_CLOSED(self);
+
+    MYDB_BEGIN_ALLOW_THREADS
+    err = self->db_env->log_flush(self->db_env, NULL);
+    MYDB_END_ALLOW_THREADS
+
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
+#endif
 
 static PyObject*
 DBEnv_log_archive(DBEnvObject* self, PyObject* args)
 {
-    int flags=0;
+    int flags=0;
+    int err;
+    char **log_list = NULL;
+    PyObject* list;
+    PyObject* item = NULL;
+
+    if (!PyArg_ParseTuple(args, "|i:log_archive", &flags))
+        return NULL;
+
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+#if (DBVER >= 40)
+    err = self->db_env->log_archive(self->db_env, &log_list, flags);
+#elif (DBVER == 33)
+    err = log_archive(self->db_env, &log_list, flags);
+#else
+    err = log_archive(self->db_env, &log_list, flags, NULL);
+#endif
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+
+    list = PyList_New(0);
+    if (list == NULL) {
+        if (log_list)
+            free(log_list);
+        return NULL;
+    }
+
+    if (log_list) {
+        char **log_list_start;
+        for (log_list_start = log_list; *log_list != NULL; ++log_list) {
+            item = PyString_FromString (*log_list);
+            if (item == NULL) {
+                Py_DECREF(list);
+                list = NULL;
+                break;
+            }
+            PyList_Append(list, item);
+            Py_DECREF(item);
+        }
+        free(log_list_start);
+    }
+    return list;
+}
+
+
+static PyObject*
+DBEnv_txn_stat(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    DB_TXN_STAT* sp;
+    PyObject* d = NULL;
+    u_int32_t flags=0;
+
+    if (!PyArg_ParseTuple(args, "|i:txn_stat", &flags))
+        return NULL;
+    CHECK_ENV_NOT_CLOSED(self);
+
+    MYDB_BEGIN_ALLOW_THREADS;
+#if (DBVER >= 40)
+    err = self->db_env->txn_stat(self->db_env, &sp, flags);
+#elif (DBVER == 33)
+    err = txn_stat(self->db_env, &sp);
+#else
+    err = txn_stat(self->db_env, &sp, NULL);
+#endif
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+
+    /* Turn the stat structure into a dictionary */
+    d = PyDict_New();
+    if (d == NULL) {
+        free(sp);
+        return NULL;
+    }
+
+#define MAKE_ENTRY(name)        _addIntToDict(d, #name, sp->st_##name)
+#define MAKE_TIME_T_ENTRY(name) _addTimeTToDict(d, #name, sp->st_##name)
+#define MAKE_DB_LSN_ENTRY(name) _addDB_lsnToDict(d, #name, sp->st_##name)
+
+#if (DBVER >= 40)
+    MAKE_DB_LSN_ENTRY(last_ckp);
+#endif
+    MAKE_TIME_T_ENTRY(time_ckp);
+    MAKE_ENTRY(last_txnid);
+    MAKE_ENTRY(maxtxns);
+    MAKE_ENTRY(nactive);
+    MAKE_ENTRY(maxnactive);
+#if (DBVER >= 45)
+    MAKE_ENTRY(nsnapshot);
+    MAKE_ENTRY(maxnsnapshot);
+#endif
+    MAKE_ENTRY(nbegins);
+    MAKE_ENTRY(naborts);
+    MAKE_ENTRY(ncommits);
+#if (DBVER >= 40)
+    MAKE_ENTRY(nrestores);
+#endif
+    MAKE_ENTRY(regsize);
+    MAKE_ENTRY(region_wait);
+    MAKE_ENTRY(region_nowait);
+
+#undef MAKE_DB_LSN_ENTRY
+#undef MAKE_ENTRY
+#undef MAKE_TIME_T_ENTRY
+    free(sp);
+    return d;
+}
+
+
+static PyObject*
+DBEnv_set_get_returns_none(DBEnvObject* self, PyObject* args)
+{
+    int flags=0;
+    int oldValue=0;
+
+    if (!PyArg_ParseTuple(args,"i:set_get_returns_none", &flags))
+        return NULL;
+    CHECK_ENV_NOT_CLOSED(self);
+
+    if (self->moduleFlags.getReturnsNone)
+        ++oldValue;
+    if (self->moduleFlags.cursorSetReturnsNone)
+        ++oldValue;
+    self->moduleFlags.getReturnsNone = (flags >= 1);
+    self->moduleFlags.cursorSetReturnsNone = (flags >= 2);
+    return PyInt_FromLong(oldValue);
+}
+
+#if (DBVER >= 40)
+static PyObject*
+DBEnv_set_verbose(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int which, onoff;
+
+    if (!PyArg_ParseTuple(args, "ii:set_verbose", &which, &onoff)) {
+        return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->set_verbose(self->db_env, which, onoff);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
+
+#if (DBVER >= 42)
+static PyObject*
+DBEnv_get_verbose(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int which;
+    int verbose;
+
+    if (!PyArg_ParseTuple(args, "i:get_verbose", &which)) {
+        return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->get_verbose(self->db_env, which, &verbose);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    return PyBool_FromLong(verbose);
+}
+#endif
+#endif
+
+#if (DBVER >= 45)
+static void
+_dbenv_event_notifyCallback(DB_ENV* db_env, u_int32_t event, void *event_info)
+{
+    DBEnvObject *dbenv;
+    PyObject* callback;
+    PyObject* args;
+    PyObject* result = NULL;
+
+    MYDB_BEGIN_BLOCK_THREADS;
+    dbenv = (DBEnvObject *)db_env->app_private;
+    callback = dbenv->event_notifyCallback;
+    if (callback) {
+        if (event == DB_EVENT_REP_NEWMASTER) {
+            args = Py_BuildValue("(Oii)", dbenv, event, *((int *)event_info));
+        } else {
+            args = Py_BuildValue("(OiO)", dbenv, event, Py_None);
+        }
+        if (args) {
+            result = PyEval_CallObject(callback, args);
+        }
+        if ((!args) || (!result)) {
+            PyErr_Print();
+        }
+        Py_XDECREF(args);
+        Py_XDECREF(result);
+    }
+    MYDB_END_BLOCK_THREADS;
+}
+#endif
+
+#if (DBVER >= 45)
+static PyObject*
+DBEnv_set_event_notify(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    PyObject *notifyFunc;
+
+    if (!PyArg_ParseTuple(args, "O:set_event_notify", &notifyFunc)) {
+	    return NULL;
+    }
+
+    CHECK_ENV_NOT_CLOSED(self);
+
+    if (!PyCallable_Check(notifyFunc)) {
+	    makeTypeError("Callable", notifyFunc);
+	    return NULL;
+    }
+
+    Py_XDECREF(self->event_notifyCallback);
+    Py_INCREF(notifyFunc);
+    self->event_notifyCallback = notifyFunc;
+
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->set_event_notify(self->db_env, _dbenv_event_notifyCallback);
+    MYDB_END_ALLOW_THREADS;
+
+    if (err) {
+	    Py_DECREF(notifyFunc);
+	    self->event_notifyCallback = NULL;
+    }
+
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
+#endif
+
+
+/* --------------------------------------------------------------------- */
+/* REPLICATION METHODS: Base Replication */
+
+#if (DBVER >= 45)
+static PyObject*
+DBEnv_rep_set_nsites(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int nsites;
+
+    if (!PyArg_ParseTuple(args, "i:rep_set_nsites", &nsites)) {
+        return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->rep_set_nsites(self->db_env, nsites);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
+
+static PyObject*
+DBEnv_rep_get_nsites(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int nsites;
+
+    if (!PyArg_ParseTuple(args, ":rep_get_nsites")) {
+        return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->rep_get_nsites(self->db_env, &nsites);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    return PyInt_FromLong(nsites);
+}
+
+static PyObject*
+DBEnv_rep_set_priority(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int priority;
+
+    if (!PyArg_ParseTuple(args, "i:rep_set_priority", &priority)) {
+        return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->rep_set_priority(self->db_env, priority);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
+
+static PyObject*
+DBEnv_rep_get_priority(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int priority;
+
+    if (!PyArg_ParseTuple(args, ":rep_get_priority")) {
+        return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->rep_get_priority(self->db_env, &priority);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    return PyInt_FromLong(priority);
+}
+
+static PyObject*
+DBEnv_rep_set_timeout(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int which, timeout;
+
+    if (!PyArg_ParseTuple(args, "ii:rep_set_timeout", &which, &timeout)) {
+        return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->rep_set_timeout(self->db_env, which, timeout);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
+
+static PyObject*
+DBEnv_rep_get_timeout(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int which;
+    u_int32_t timeout;
+
+    if (!PyArg_ParseTuple(args, "i:rep_get_timeout", &which)) {
+        return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->rep_get_timeout(self->db_env, which, &timeout);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    return PyInt_FromLong(timeout);
+}
+#endif
+
+/* --------------------------------------------------------------------- */
+/* REPLICATION METHODS: Replication Manager */
+
+#if (DBVER >= 45)
+static PyObject*
+DBEnv_repmgr_start(DBEnvObject* self, PyObject* args, PyObject*
+        kwargs)
+{
+    int err;
+    int nthreads, flags;
+    static char* kwnames[] = {"nthreads","flags", NULL};
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                "ii:repmgr_start", kwnames, &nthreads, &flags))
+    {
+	    return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->repmgr_start(self->db_env, nthreads, flags);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
+
+static PyObject*
+DBEnv_repmgr_set_local_site(DBEnvObject* self, PyObject* args, PyObject*
+        kwargs)
+{
+    int err;
+    char *host;
+    int port;
+    int flags = 0;
+    static char* kwnames[] = {"host", "port", "flags", NULL};
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                "si|i:repmgr_set_local_site", kwnames, &host, &port, &flags))
+    {
+	    return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->repmgr_set_local_site(self->db_env, host, port, flags);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
+
+static PyObject*
+DBEnv_repmgr_add_remote_site(DBEnvObject* self, PyObject* args, PyObject*
+        kwargs)
+{
+    int err;
+    char *host;
+    int port;
+    int flags = 0;
+    int eidp;
+    static char* kwnames[] = {"host", "port", "flags", NULL};
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                "si|i:repmgr_add_remote_site", kwnames, &host, &port, &flags))
+    {
+	    return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->repmgr_add_remote_site(self->db_env, host, port, &eidp, flags);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    return PyInt_FromLong(eidp);
+}
+
+static PyObject*
+DBEnv_repmgr_set_ack_policy(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int ack_policy;
+
+    if (!PyArg_ParseTuple(args, "i:repmgr_set_ack_policy", &ack_policy))
+    {
+	    return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->repmgr_set_ack_policy(self->db_env, ack_policy);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
+
+static PyObject*
+DBEnv_repmgr_get_ack_policy(DBEnvObject* self, PyObject* args)
+{
+    int err;
+    int ack_policy;
+
+    if (!PyArg_ParseTuple(args, ":repmgr_get_ack_policy"))
+    {
+	    return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->repmgr_get_ack_policy(self->db_env, &ack_policy);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    return PyInt_FromLong(ack_policy);
+}
+
+static PyObject*
+DBEnv_repmgr_site_list(DBEnvObject* self, PyObject* args)
+{
     int err;
-    char **log_list = NULL;
-    PyObject* list;
-    PyObject* item = NULL;
+    unsigned int countp;
+    DB_REPMGR_SITE *listp;
+    PyObject *stats, *key, *tuple;
 
-    if (!PyArg_ParseTuple(args, "|i:log_archive", &flags))
+    if (!PyArg_ParseTuple(args, ":repmgr_site_list"))
+    {
         return NULL;
-
+    }
     CHECK_ENV_NOT_CLOSED(self);
     MYDB_BEGIN_ALLOW_THREADS;
-#if (DBVER >= 40)
-    err = self->db_env->log_archive(self->db_env, &log_list, flags);
-#elif (DBVER == 33)
-    err = log_archive(self->db_env, &log_list, flags);
-#else
-    err = log_archive(self->db_env, &log_list, flags, NULL);
-#endif
+    err = self->db_env->repmgr_site_list(self->db_env, &countp, &listp);
     MYDB_END_ALLOW_THREADS;
     RETURN_IF_ERR();
 
-    list = PyList_New(0);
-    if (list == NULL) {
-        if (log_list)
-            free(log_list);
+    stats=PyDict_New();
+    if (stats == NULL) {
+        free(listp);
         return NULL;
     }
 
-    if (log_list) {
-        char **log_list_start;
-        for (log_list_start = log_list; *log_list != NULL; ++log_list) {
-            item = PyString_FromString (*log_list);
-            if (item == NULL) {
-                Py_DECREF(list);
-                list = NULL;
-                break;
-            }
-            PyList_Append(list, item);
-            Py_DECREF(item);
+    for(;countp--;) {
+        key=PyInt_FromLong(listp[countp].eid);
+        if(!key) {
+            Py_DECREF(stats);
+            free(listp);
+            return NULL;
+        }
+#if (PY_VERSION_HEX >= 0x02040000)
+        tuple=Py_BuildValue("(sII)", listp[countp].host,
+                listp[countp].port, listp[countp].status);
+#else
+        tuple=Py_BuildValue("(sii)", listp[countp].host,
+                listp[countp].port, listp[countp].status);
+#endif
+        if(!tuple) {
+            Py_DECREF(key);
+            Py_DECREF(stats);
+            free(listp);
+            return NULL;
+        }
+        if(PyDict_SetItem(stats, key, tuple)) {
+            Py_DECREF(key);
+            Py_DECREF(tuple);
+            Py_DECREF(stats);
+            free(listp);
+            return NULL;
         }
-        free(log_list_start);
     }
-    return list;
+    free(listp);
+    return stats;
 }
+#endif
 
-
+#if (DBVER >= 46)
 static PyObject*
-DBEnv_txn_stat(DBEnvObject* self, PyObject* args)
+DBEnv_repmgr_stat_print(DBEnvObject* self, PyObject* args, PyObject *kwargs)
 {
     int err;
-    DB_TXN_STAT* sp;
-    PyObject* d = NULL;
-    u_int32_t flags=0;
+    int flags=0;
+    static char* kwnames[] = { "flags", NULL };
 
-    if (!PyArg_ParseTuple(args, "|i:txn_stat", &flags))
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:repmgr_stat_print",
+                kwnames, &flags))
+    {
         return NULL;
+    }
     CHECK_ENV_NOT_CLOSED(self);
+    MYDB_BEGIN_ALLOW_THREADS;
+    err = self->db_env->repmgr_stat_print(self->db_env, flags);
+    MYDB_END_ALLOW_THREADS;
+    RETURN_IF_ERR();
+    RETURN_NONE();
+}
 
+static PyObject*
+DBEnv_repmgr_stat(DBEnvObject* self, PyObject* args, PyObject *kwargs)
+{
+    int err;
+    int flags=0;
+    DB_REPMGR_STAT *statp;
+    PyObject *stats;
+    static char* kwnames[] = { "flags", NULL };
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:repmgr_stat",
+                kwnames, &flags))
+    {
+        return NULL;
+    }
+    CHECK_ENV_NOT_CLOSED(self);
     MYDB_BEGIN_ALLOW_THREADS;
-#if (DBVER >= 40)
-    err = self->db_env->txn_stat(self->db_env, &sp, flags);
-#elif (DBVER == 33)
-    err = txn_stat(self->db_env, &sp);
-#else
-    err = txn_stat(self->db_env, &sp, NULL);
-#endif
+    err = self->db_env->repmgr_stat(self->db_env, &statp, flags);
     MYDB_END_ALLOW_THREADS;
     RETURN_IF_ERR();
 
-    /* Turn the stat structure into a dictionary */
-    d = PyDict_New();
-    if (d == NULL) {
-        free(sp);
+    stats=PyDict_New();
+    if (stats == NULL) {
+        free(statp);
         return NULL;
     }
 
-#define MAKE_ENTRY(name)  _addIntToDict(d, #name, sp->st_##name)
-#define MAKE_TIME_T_ENTRY(name)_addTimeTToDict(d, #name, sp->st_##name)
+#define MAKE_ENTRY(name)  _addIntToDict(stats, #name, statp->st_##name)
 
-    MAKE_TIME_T_ENTRY(time_ckp);
-    MAKE_ENTRY(last_txnid);
-    MAKE_ENTRY(maxtxns);
-    MAKE_ENTRY(nactive);
-    MAKE_ENTRY(maxnactive);
-    MAKE_ENTRY(nbegins);
-    MAKE_ENTRY(naborts);
-    MAKE_ENTRY(ncommits);
-    MAKE_ENTRY(regsize);
-    MAKE_ENTRY(region_wait);
-    MAKE_ENTRY(region_nowait);
+    MAKE_ENTRY(perm_failed);
+    MAKE_ENTRY(msgs_queued);
+    MAKE_ENTRY(msgs_dropped);
+    MAKE_ENTRY(connection_drop);
+    MAKE_ENTRY(connect_fail);
 
 #undef MAKE_ENTRY
-#undef MAKE_TIME_T_ENTRY
-    free(sp);
-    return d;
+
+    free(statp);
+    return stats;
 }
+#endif
 
 
-static PyObject*
-DBEnv_set_get_returns_none(DBEnvObject* self, PyObject* args)
-{
-    int flags=0;
-    int oldValue=0;
+/* --------------------------------------------------------------------- */
+/* DBTxn methods */
 
-    if (!PyArg_ParseTuple(args,"i:set_get_returns_none", &flags))
-        return NULL;
-    CHECK_ENV_NOT_CLOSED(self);
 
-    if (self->moduleFlags.getReturnsNone)
-        ++oldValue;
-    if (self->moduleFlags.cursorSetReturnsNone)
-        ++oldValue;
-    self->moduleFlags.getReturnsNone = (flags >= 1);
-    self->moduleFlags.cursorSetReturnsNone = (flags >= 2);
-    return PyInt_FromLong(oldValue);
+static void _close_transaction_cursors(DBTxnObject* txn)
+{
+    PyObject *dummy;
+
+    while(txn->children_cursors) {
+        PyErr_Warn(PyExc_RuntimeWarning,
+            "Must close cursors before resolving a transaction.");
+        dummy=DBC_close_internal(txn->children_cursors);
+        Py_XDECREF(dummy);
+    }
 }
 
+static void _promote_transaction_dbs_and_sequences(DBTxnObject *txn)
+{
+    DBObject *db;
+#if (DBVER >= 43)
+    DBSequenceObject *dbs;
+#endif
 
-/* --------------------------------------------------------------------- */
-/* DBTxn methods */
+    while (txn->children_dbs) {
+        db=txn->children_dbs;
+        EXTRACT_FROM_DOUBLE_LINKED_LIST_TXN(db);
+        if (txn->parent_txn) {
+            INSERT_IN_DOUBLE_LINKED_LIST_TXN(txn->parent_txn->children_dbs,db);
+            db->txn=txn->parent_txn;
+        } else {
+            /* The db is already linked to its environment,
+            ** so nothing to do.
+            */
+            db->txn=NULL; 
+        }
+    }
+
+#if (DBVER >= 43)
+    while (txn->children_sequences) {
+        dbs=txn->children_sequences;
+        EXTRACT_FROM_DOUBLE_LINKED_LIST_TXN(dbs);
+        if (txn->parent_txn) {
+            INSERT_IN_DOUBLE_LINKED_LIST_TXN(txn->parent_txn->children_sequences,dbs);
+            dbs->txn=txn->parent_txn;
+        } else {
+            /* The sequence is already linked to its
+            ** parent db. Nothing to do.
+            */
+            dbs->txn=NULL;
+        }
+    }
+#endif
+}
 
 
 static PyObject*
@@ -4590,15 +5449,22 @@
     if (!PyArg_ParseTuple(args, "|i:commit", &flags))
         return NULL;
 
+    _close_transaction_cursors(self);
+
     if (!self->txn) {
         PyObject *t =  Py_BuildValue("(is)", 0, "DBTxn must not be used "
-                                     "after txn_commit or txn_abort");
+                                     "after txn_commit, txn_abort "
+                                     "or txn_discard");
         PyErr_SetObject(DBError, t);
         Py_DECREF(t);
         return NULL;
     }
+    self->flag_prepare=0;
     txn = self->txn;
     self->txn = NULL;   /* this DB_TXN is no longer valid after this call */
+
+    EXTRACT_FROM_DOUBLE_LINKED_LIST(self);
+
     MYDB_BEGIN_ALLOW_THREADS;
 #if (DBVER >= 40)
     err = txn->commit(txn, flags);
@@ -4606,6 +5472,9 @@
     err = txn_commit(txn, flags);
 #endif
     MYDB_END_ALLOW_THREADS;
+
+    _promote_transaction_dbs_and_sequences(self);
+
     RETURN_IF_ERR();
     RETURN_NONE();
 }
@@ -4629,11 +5498,13 @@
 
     if (!self->txn) {
         PyObject *t = Py_BuildValue("(is)", 0,"DBTxn must not be used "
-                                    "after txn_commit or txn_abort");
+                                    "after txn_commit, txn_abort "
+                                    "or txn_discard");
         PyErr_SetObject(DBError, t);
         Py_DECREF(t);
         return NULL;
     }
+    self->flag_prepare=1;  /* Prepare state */
     MYDB_BEGIN_ALLOW_THREADS;
 #if (DBVER >= 40)
     err = self->txn->prepare(self->txn, (u_int8_t*)gid);
@@ -4651,7 +5522,8 @@
 
     if (!self->txn) {
         PyObject *t = Py_BuildValue("(is)", 0, "DBTxn must not be used "
-                                    "after txn_commit or txn_abort");
+                                    "after txn_commit, txn_abort "
+                                    "or txn_discard");
         PyErr_SetObject(DBError, t);
         Py_DECREF(t);
         return NULL;
@@ -4666,34 +5538,87 @@
 
 
 static PyObject*
-DBTxn_abort(DBTxnObject* self, PyObject* args)
+DBTxn_abort_discard_internal(DBTxnObject* self, int discard)
 {
-    int err;
+    PyObject *dummy;
+    int err=0;
     DB_TXN *txn;
 
-    if (!PyArg_ParseTuple(args, ":abort"))
-        return NULL;
-
     if (!self->txn) {
         PyObject *t = Py_BuildValue("(is)", 0, "DBTxn must not be used "
-                                    "after txn_commit or txn_abort");
+                                    "after txn_commit, txn_abort "
+                                    "or txn_discard");
         PyErr_SetObject(DBError, t);
         Py_DECREF(t);
         return NULL;
     }
     txn = self->txn;
     self->txn = NULL;   /* this DB_TXN is no longer valid after this call */
+
+    _close_transaction_cursors(self);
+#if (DBVER >= 43)
+    while (self->children_sequences) {
+        dummy=DBSequence_close_internal(self->children_sequences,0,0);
+        Py_XDECREF(dummy);
+    }
+#endif
+    while (self->children_dbs) {
+        dummy=DB_close_internal(self->children_dbs,0);
+        Py_XDECREF(dummy);
+    }
+
+    EXTRACT_FROM_DOUBLE_LINKED_LIST(self);
+
     MYDB_BEGIN_ALLOW_THREADS;
+    if (discard) {
+        assert(!self->flag_prepare);
+#if (DBVER >= 40)
+        err = txn->discard(txn,0);
+#else
+        err = txn_discard(txn);
+#endif
+    } else {
+        /*
+        ** If the transaction is in the "prepare" or "recover" state,
+        ** we better do not implicitly abort it.
+        */
+        if (!self->flag_prepare) {
 #if (DBVER >= 40)
-    err = txn->abort(txn);
+            err = txn->abort(txn);
 #else
-    err = txn_abort(txn);
+            err = txn_abort(txn);
 #endif
+        }
+    }
     MYDB_END_ALLOW_THREADS;
     RETURN_IF_ERR();
     RETURN_NONE();
 }
 
+static PyObject*
+DBTxn_abort(DBTxnObject* self, PyObject* args)
+{
+    if (!PyArg_ParseTuple(args, ":abort"))
+        return NULL;
+
+    self->flag_prepare=0;
+    _close_transaction_cursors(self);
+
+    return DBTxn_abort_discard_internal(self,0);
+}
+
+static PyObject*
+DBTxn_discard(DBTxnObject* self, PyObject* args)
+{
+    if (!PyArg_ParseTuple(args, ":discard"))
+        return NULL;
+
+    self->flag_prepare=0;
+    _close_transaction_cursors(self);
+
+    return DBTxn_abort_discard_internal(self,1);
+}
+
 
 static PyObject*
 DBTxn_id(DBTxnObject* self, PyObject* args)
@@ -4705,7 +5630,8 @@
 
     if (!self->txn) {
         PyObject *t = Py_BuildValue("(is)", 0, "DBTxn must not be used "
-                                    "after txn_commit or txn_abort");
+                                    "after txn_commit, txn_abort "
+                                    "or txn_discard");
         PyErr_SetObject(DBError, t);
         Py_DECREF(t);
         return NULL;
@@ -4726,24 +5652,41 @@
 
 
 static PyObject*
-DBSequence_close(DBSequenceObject* self, PyObject* args)
+DBSequence_close_internal(DBSequenceObject* self, int flags, int do_not_close)
 {
-    int err, flags=0;
-    if (!PyArg_ParseTuple(args,"|i:close", &flags))
-        return NULL;
-    CHECK_SEQUENCE_NOT_CLOSED(self)
+    int err=0;
 
-    MYDB_BEGIN_ALLOW_THREADS
-    err = self->sequence->close(self->sequence, flags);
-    self->sequence = NULL;
-    MYDB_END_ALLOW_THREADS
+    if (self->sequence!=NULL) {
+        EXTRACT_FROM_DOUBLE_LINKED_LIST(self);
+        if (self->txn) {
+            EXTRACT_FROM_DOUBLE_LINKED_LIST_TXN(self);
+            self->txn=NULL;
+        }
 
-    RETURN_IF_ERR();
+        if (!do_not_close) {
+            MYDB_BEGIN_ALLOW_THREADS
+            err = self->sequence->close(self->sequence, flags);
+            MYDB_END_ALLOW_THREADS
+        }
+        self->sequence = NULL;
+
+        RETURN_IF_ERR();
+    }
 
     RETURN_NONE();
 }
 
 static PyObject*
+DBSequence_close(DBSequenceObject* self, PyObject* args)
+{
+    int flags=0;
+    if (!PyArg_ParseTuple(args,"|i:close", &flags))
+        return NULL;
+
+    return DBSequence_close_internal(self,flags,0);
+}
+
+static PyObject*
 DBSequence_get(DBSequenceObject* self, PyObject* args, PyObject* kwargs)
 {
     int err, flags = 0;
@@ -4765,7 +5708,6 @@
 
     RETURN_IF_ERR();
     return PyLong_FromLongLong(value);
-
 }
 
 static PyObject*
@@ -4784,6 +5726,10 @@
     int err;
     DBT key;
     PyObject *retval = NULL;
+
+    if (!PyArg_ParseTuple(args,":get_key"))
+        return NULL;
+
     key.flags = DB_DBT_MALLOC;
     CHECK_SEQUENCE_NOT_CLOSED(self)
     MYDB_BEGIN_ALLOW_THREADS
@@ -4791,7 +5737,7 @@
     MYDB_END_ALLOW_THREADS
 
     if (!err)
-        retval = PyString_FromStringAndSize(key.data, key.size); 
+        retval = Build_PyString(key.data, key.size); 
 
     FREE_DBT(key);
     RETURN_IF_ERR();
@@ -4803,13 +5749,15 @@
 DBSequence_init_value(DBSequenceObject* self, PyObject* args)
 {
     int err;
-    db_seq_t value;
+    PY_LONG_LONG value;
+    db_seq_t value2;
     if (!PyArg_ParseTuple(args,"L:init_value", &value))
         return NULL;
     CHECK_SEQUENCE_NOT_CLOSED(self)
 
+    value2=value; /* If truncation, compiler should show a warning */
     MYDB_BEGIN_ALLOW_THREADS
-    err = self->sequence->initial_value(self->sequence, value);
+    err = self->sequence->initial_value(self->sequence, value2);
     MYDB_END_ALLOW_THREADS
 
     RETURN_IF_ERR();
@@ -4843,12 +5791,18 @@
     CLEAR_DBT(key);
     RETURN_IF_ERR();
 
+    if (txn) {
+        INSERT_IN_DOUBLE_LINKED_LIST_TXN(((DBTxnObject *)txnobj)->children_sequences,self);
+        self->txn=(DBTxnObject *)txnobj;
+    }
+
     RETURN_NONE();
 }
 
 static PyObject*
 DBSequence_remove(DBSequenceObject* self, PyObject* args, PyObject* kwargs)
 {
+    PyObject *dummy;
     int err, flags = 0;
     PyObject *txnobj = NULL;
     DB_TXN *txn = NULL;
@@ -4866,6 +5820,9 @@
     err = self->sequence->remove(self->sequence, txn, flags);
     MYDB_END_ALLOW_THREADS
 
+    dummy=DBSequence_close_internal(self,flags,1);
+    Py_XDECREF(dummy);
+
     RETURN_IF_ERR();
     RETURN_NONE();
 }
@@ -4916,7 +5873,6 @@
 
     RETURN_IF_ERR();
     RETURN_NONE();
-
 }
 
 static PyObject*
@@ -4940,13 +5896,16 @@
 DBSequence_set_range(DBSequenceObject* self, PyObject* args)
 {
     int err;
-    db_seq_t min, max;
+    PY_LONG_LONG min, max;
+    db_seq_t min2, max2;
     if (!PyArg_ParseTuple(args,"(LL):set_range", &min, &max))
         return NULL;
     CHECK_SEQUENCE_NOT_CLOSED(self)
 
+    min2=min;  /* If truncation, compiler should show a warning */
+    max2=max;
     MYDB_BEGIN_ALLOW_THREADS
-    err = self->sequence->set_range(self->sequence, min, max);
+    err = self->sequence->set_range(self->sequence, min2, max2);
     MYDB_END_ALLOW_THREADS
 
     RETURN_IF_ERR();
@@ -4957,16 +5916,19 @@
 DBSequence_get_range(DBSequenceObject* self, PyObject* args)
 {
     int err;
-    db_seq_t min, max;
+    PY_LONG_LONG min, max;
+    db_seq_t min2, max2;
     if (!PyArg_ParseTuple(args,":get_range"))
         return NULL;
     CHECK_SEQUENCE_NOT_CLOSED(self)
 
     MYDB_BEGIN_ALLOW_THREADS
-    err = self->sequence->get_range(self->sequence, &min, &max);
+    err = self->sequence->get_range(self->sequence, &min2, &max2);
     MYDB_END_ALLOW_THREADS
 
     RETURN_IF_ERR();
+    min=min2;  /* If truncation, compiler should show a warning */
+    max=max2;
     return Py_BuildValue("(LL)", min, max);
 }
 
@@ -5134,6 +6096,9 @@
     {"set_lg_bsize",    (PyCFunction)DBEnv_set_lg_bsize,     METH_VARARGS},
     {"set_lg_dir",      (PyCFunction)DBEnv_set_lg_dir,       METH_VARARGS},
     {"set_lg_max",      (PyCFunction)DBEnv_set_lg_max,       METH_VARARGS},
+#if (DBVER >= 42)
+    {"get_lg_max",      (PyCFunction)DBEnv_get_lg_max,       METH_VARARGS},
+#endif
 #if (DBVER >= 33)
     {"set_lg_regionmax",(PyCFunction)DBEnv_set_lg_regionmax, METH_VARARGS},
 #endif
@@ -5161,12 +6126,55 @@
     {"lock_stat",       (PyCFunction)DBEnv_lock_stat,        METH_VARARGS},
     {"log_archive",     (PyCFunction)DBEnv_log_archive,      METH_VARARGS},
 #if (DBVER >= 40)
+    {"log_flush",       (PyCFunction)DBEnv_log_flush,       METH_VARARGS},
+#endif
+#if (DBVER >= 40)
     {"log_stat",        (PyCFunction)DBEnv_log_stat,         METH_VARARGS},
 #endif
 #if (DBVER >= 44)
     {"lsn_reset",       (PyCFunction)DBEnv_lsn_reset,        METH_VARARGS|METH_KEYWORDS},
 #endif
     {"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS},
+#if (DBVER >= 40)
+    {"txn_recover",     (PyCFunction)DBEnv_txn_recover,       METH_VARARGS},
+#endif
+#if (DBVER >= 40)
+    {"set_verbose",     (PyCFunction)DBEnv_set_verbose,       METH_VARARGS},
+#if (DBVER >= 42)
+    {"get_verbose",     (PyCFunction)DBEnv_get_verbose,       METH_VARARGS},
+#endif
+#endif
+#if (DBVER >= 45)
+    {"set_event_notify", (PyCFunction)DBEnv_set_event_notify, METH_VARARGS},
+#endif
+#if (DBVER >= 45)
+    {"rep_set_nsites", (PyCFunction)DBEnv_rep_set_nsites, METH_VARARGS},
+    {"rep_get_nsites", (PyCFunction)DBEnv_rep_get_nsites, METH_VARARGS},
+    {"rep_set_priority", (PyCFunction)DBEnv_rep_set_priority, METH_VARARGS},
+    {"rep_get_priority", (PyCFunction)DBEnv_rep_get_priority, METH_VARARGS},
+    {"rep_set_timeout", (PyCFunction)DBEnv_rep_set_timeout, METH_VARARGS},
+    {"rep_get_timeout", (PyCFunction)DBEnv_rep_get_timeout, METH_VARARGS},
+#endif
+#if (DBVER >= 45)
+    {"repmgr_start", (PyCFunction)DBEnv_repmgr_start,
+        METH_VARARGS|METH_KEYWORDS},
+    {"repmgr_set_local_site", (PyCFunction)DBEnv_repmgr_set_local_site,
+        METH_VARARGS|METH_KEYWORDS},
+    {"repmgr_add_remote_site", (PyCFunction)DBEnv_repmgr_add_remote_site,
+        METH_VARARGS|METH_KEYWORDS},
+    {"repmgr_set_ack_policy", (PyCFunction)DBEnv_repmgr_set_ack_policy,
+        METH_VARARGS},
+    {"repmgr_get_ack_policy", (PyCFunction)DBEnv_repmgr_get_ack_policy,
+        METH_VARARGS},
+    {"repmgr_site_list", (PyCFunction)DBEnv_repmgr_site_list,
+        METH_VARARGS},
+#endif
+#if (DBVER >= 46)
+    {"repmgr_stat", (PyCFunction)DBEnv_repmgr_stat,
+        METH_VARARGS|METH_KEYWORDS},
+    {"repmgr_stat_print", (PyCFunction)DBEnv_repmgr_stat_print,
+        METH_VARARGS|METH_KEYWORDS},
+#endif
     {NULL,      NULL}       /* sentinel */
 };
 
@@ -5174,6 +6182,7 @@
 static PyMethodDef DBTxn_methods[] = {
     {"commit",          (PyCFunction)DBTxn_commit,      METH_VARARGS},
     {"prepare",         (PyCFunction)DBTxn_prepare,     METH_VARARGS},
+    {"discard",         (PyCFunction)DBTxn_discard,     METH_VARARGS},
     {"abort",           (PyCFunction)DBTxn_abort,       METH_VARARGS},
     {"id",              (PyCFunction)DBTxn_id,          METH_VARARGS},
     {NULL,      NULL}       /* sentinel */
@@ -5212,11 +6221,17 @@
 DBEnv_getattr(DBEnvObject* self, char *name)
 {
     if (!strcmp(name, "db_home")) {
-        CHECK_ENV_NOT_CLOSED(self);
-        if (self->db_env->db_home == NULL) {
-            RETURN_NONE();
-        }
-        return PyString_FromString(self->db_env->db_home);
+      const char *home = NULL;
+      CHECK_ENV_NOT_CLOSED(self);
+#if (DBVER >= 42)
+      self->db_env->get_home(self->db_env, &home);
+#else
+      home=self->db_env->db_home;
+#endif
+      if (home == NULL) {
+          RETURN_NONE();
+      }
+      return PyString_FromString(home);
     }
 
     return Py_FindMethod(DBEnv_methods, (PyObject* )self, name);
@@ -5582,7 +6597,7 @@
     ADD_INT(d, DB_RPCCLIENT);
 #else
     ADD_INT(d, DB_CLIENT);
-    /* allow apps to be written using DB_RPCCLIENT on older BerkeleyDB */
+    /* allow apps to be written using DB_RPCCLIENT on older Berkeley DB */
     _addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT);
 #endif
     ADD_INT(d, DB_XA_CREATE);
@@ -5590,6 +6605,9 @@
     ADD_INT(d, DB_CREATE);
     ADD_INT(d, DB_NOMMAP);
     ADD_INT(d, DB_THREAD);
+#if (DBVER >= 45)
+    ADD_INT(d, DB_MULTIVERSION);
+#endif
 
     ADD_INT(d, DB_FORCE);
     ADD_INT(d, DB_INIT_CDB);
@@ -5599,6 +6617,10 @@
     ADD_INT(d, DB_INIT_TXN);
     ADD_INT(d, DB_JOINENV);
 
+#if (DBVER >= 40)
+    ADD_INT(d, DB_XIDDATASIZE);
+#endif
+
     ADD_INT(d, DB_RECOVER);
     ADD_INT(d, DB_RECOVER_FATAL);
     ADD_INT(d, DB_TXN_NOSYNC);
@@ -5645,6 +6667,13 @@
     ADD_INT(d, DB_LOCK_MINWRITE);
 #endif
 
+#if (DBVER >= 40)
+    ADD_INT(d, DB_LOCK_EXPIRE);
+#endif
+#if (DBVER >= 43)
+    ADD_INT(d, DB_LOCK_MAXWRITE);
+#endif
+
 
 #if (DBVER >= 33)
     /* docs say to use zero instead */
@@ -5816,6 +6845,10 @@
     ADD_INT(d, DB_NOPANIC);
 #endif
 
+#if (DBVER >= 41)
+    ADD_INT(d, DB_OVERWRITE);
+#endif
+
 #ifdef DB_REGISTER
     ADD_INT(d, DB_REGISTER);
 #endif
@@ -5832,7 +6865,76 @@
     ADD_INT(d, DB_CHKSUM);
 #endif
 
+#if (DBVER >= 44)
+    ADD_INT(d, DB_DSYNC_DB);
+#endif
+
+#if (DBVER >= 45)
+    ADD_INT(d, DB_TXN_SNAPSHOT);
+#endif
+
+#if (DBVER >= 40)
+    ADD_INT(d, DB_VERB_DEADLOCK);
+#if (DBVER >= 46)
+    ADD_INT(d, DB_VERB_FILEOPS);
+    ADD_INT(d, DB_VERB_FILEOPS_ALL);
+#endif
+    ADD_INT(d, DB_VERB_RECOVERY);
+#if (DBVER >= 44)
+    ADD_INT(d, DB_VERB_REGISTER);
+#endif
+    ADD_INT(d, DB_VERB_REPLICATION);
+    ADD_INT(d, DB_VERB_WAITSFOR);
+#endif
+
+#if (DBVER >= 45)
+    ADD_INT(d, DB_EVENT_PANIC);
+    ADD_INT(d, DB_EVENT_REP_CLIENT);
+#if (DBVER >= 46)
+    ADD_INT(d, DB_EVENT_REP_ELECTED);
+#endif
+    ADD_INT(d, DB_EVENT_REP_MASTER);
+    ADD_INT(d, DB_EVENT_REP_NEWMASTER);
+#if (DBVER >= 46)
+    ADD_INT(d, DB_EVENT_REP_PERM_FAILED);
+#endif
+    ADD_INT(d, DB_EVENT_REP_STARTUPDONE);
+    ADD_INT(d, DB_EVENT_WRITE_FAILED);
+#endif
+
+#if (DBVER >= 40)
+    ADD_INT(d, DB_REP_MASTER);
+    ADD_INT(d, DB_REP_CLIENT);
+#if (DBVER >= 45)
+    ADD_INT(d, DB_REP_ELECTION);
+
+    ADD_INT(d, DB_REP_ACK_TIMEOUT);
+    ADD_INT(d, DB_REP_CONNECTION_RETRY);
+    ADD_INT(d, DB_REP_ELECTION_TIMEOUT);
+    ADD_INT(d, DB_REP_ELECTION_RETRY);
+#endif
+#if (DBVER >= 46)
+    ADD_INT(d, DB_REP_CHECKPOINT_DELAY);
+    ADD_INT(d, DB_REP_FULL_ELECTION_TIMEOUT);
+#endif
+#endif
+
+#if (DBVER >= 45)
+    ADD_INT(d, DB_REPMGR_PEER);
+    ADD_INT(d, DB_REPMGR_ACKS_ALL);
+    ADD_INT(d, DB_REPMGR_ACKS_ALL_PEERS);
+    ADD_INT(d, DB_REPMGR_ACKS_NONE);
+    ADD_INT(d, DB_REPMGR_ACKS_ONE);
+    ADD_INT(d, DB_REPMGR_ACKS_ONE_PEER);
+    ADD_INT(d, DB_REPMGR_ACKS_QUORUM);
+    ADD_INT(d, DB_REPMGR_CONNECTED);
+    ADD_INT(d, DB_REPMGR_DISCONNECTED);
+    ADD_INT(d, DB_STAT_CLEAR);
+    ADD_INT(d, DB_STAT_ALL);
+#endif
+
 #if (DBVER >= 43)
+    ADD_INT(d, DB_DSYNC_LOG);
     ADD_INT(d, DB_LOG_INMEMORY);
     ADD_INT(d, DB_BUFFER_SMALL);
     ADD_INT(d, DB_SEQ_DEC);
@@ -5844,7 +6946,7 @@
     ADD_INT(d, DB_ENCRYPT_AES);
     ADD_INT(d, DB_AUTO_COMMIT);
 #else
-    /* allow berkeleydb 4.1 aware apps to run on older versions */
+    /* allow Berkeley DB 4.1 aware apps to run on older versions */
     _addIntToDict(d, "DB_AUTO_COMMIT", 0);
 #endif
 
@@ -5920,6 +7022,10 @@
     MAKE_EX(DBNoSuchFileError);
     MAKE_EX(DBPermissionsError);
 
+#if (DBVER >= 42)
+    MAKE_EX(DBRepHandleDeadError);
+#endif
+
 #undef MAKE_EX
 
     /* Initiliase the C API structure and add it to the module */

Modified: python/branches/tlee-ast-optimize/Modules/_fileio.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_fileio.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/_fileio.c	Thu May 15 00:25:06 2008
@@ -552,11 +552,10 @@
 			PyErr_SetString(PyExc_TypeError, "an integer is required");
 			return NULL;
 		}
-#if !defined(HAVE_LARGEFILE_SUPPORT)
-		pos = PyLong_AsLong(posobj);
+#if defined(HAVE_LARGEFILE_SUPPORT)
+		pos = PyLong_AsLongLong(posobj);
 #else
-		pos = PyLong_Check(posobj) ?
-			PyLong_AsLongLong(posobj) : PyLong_AsLong(posobj);
+		pos = PyLong_AsLong(posobj);
 #endif
 		if (PyErr_Occurred())
 			return NULL;
@@ -572,10 +571,10 @@
 	if (res < 0)
 		return PyErr_SetFromErrno(PyExc_IOError);
 
-#if !defined(HAVE_LARGEFILE_SUPPORT)
-	return PyLong_FromLong(res);
-#else
+#if defined(HAVE_LARGEFILE_SUPPORT)
 	return PyLong_FromLongLong(res);
+#else
+	return PyLong_FromLong(res);
 #endif
 }
 
@@ -622,48 +621,29 @@
 		return NULL;
 
 	if (posobj == Py_None || posobj == NULL) {
+		/* Get the current position. */
                 posobj = portable_lseek(fd, NULL, 1);
                 if (posobj == NULL)
-                  return NULL;
+			return NULL;
         }
         else {
-		Py_INCREF(posobj);
+		/* Move to the position to be truncated. */
+                posobj = portable_lseek(fd, posobj, 0);
         }
 
-#if !defined(HAVE_LARGEFILE_SUPPORT)
-	pos = PyLong_AsLong(posobj);
+#if defined(HAVE_LARGEFILE_SUPPORT)
+	pos = PyLong_AsLongLong(posobj);
 #else
-	pos = PyLong_Check(posobj) ?
-		PyLong_AsLongLong(posobj) : PyLong_AsLong(posobj);
+	pos = PyLong_AsLong(posobj);
 #endif
-	if (PyErr_Occurred()) {
-		Py_DECREF(posobj);
+	if (PyErr_Occurred())
 		return NULL;
-	}
 
 #ifdef MS_WINDOWS
 	/* MS _chsize doesn't work if newsize doesn't fit in 32 bits,
 	   so don't even try using it. */
 	{
 		HANDLE hFile;
-		PyObject *pos2, *oldposobj;
-
-		/* store the current position */
-		oldposobj = portable_lseek(self->fd, NULL, 1);
-		if (oldposobj == NULL) {
-			Py_DECREF(posobj);
-			return NULL;
-		}
-
-		/* Have to move current pos to desired endpoint on Windows. */
-		errno = 0;
-		pos2 = portable_lseek(fd, posobj, SEEK_SET);
-		if (pos2 == NULL) {
-			Py_DECREF(posobj);
-			Py_DECREF(oldposobj);
-			return NULL;
-		}
-		Py_DECREF(pos2);
 
 		/* Truncate.  Note that this may grow the file! */
 		Py_BEGIN_ALLOW_THREADS
@@ -676,18 +656,6 @@
 				errno = EACCES;
 		}
 		Py_END_ALLOW_THREADS
-
-		if (ret == 0) {
-			/* Move to the previous position in the file */
-			pos2 = portable_lseek(fd, oldposobj, SEEK_SET);
-			if (pos2 == NULL) {
-				Py_DECREF(posobj);
-				Py_DECREF(oldposobj);
-				return NULL;
-			}
-		}
-		Py_DECREF(pos2);
-		Py_DECREF(oldposobj);
 	}
 #else
 	Py_BEGIN_ALLOW_THREADS
@@ -697,7 +665,6 @@
 #endif /* !MS_WINDOWS */
 
 	if (ret != 0) {
-		Py_DECREF(posobj);
 		PyErr_SetFromErrno(PyExc_IOError);
 		return NULL;
 	}
@@ -791,7 +758,8 @@
 PyDoc_STRVAR(truncate_doc,
 "truncate([size: int]) -> None.	 Truncate the file to at most size bytes.\n"
 "\n"
-"Size defaults to the current file position, as returned by tell().");
+"Size defaults to the current file position, as returned by tell()."
+"The current file position is changed to the value of size.");
 #endif
 
 PyDoc_STRVAR(tell_doc,

Modified: python/branches/tlee-ast-optimize/Modules/almodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/almodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/almodule.c	Thu May 15 00:25:06 2008
@@ -1994,6 +1994,10 @@
 {
 	PyObject *m, *d, *x;
 
+	if (PyErr_WarnPy3k("the al module has been removed in "
+	                   "Python 3.0", 2) < 0)
+	    return;	
+
 	/* Create the module and add the functions */
 	m = Py_InitModule4("al", al_methods,
 		al_module_documentation,

Modified: python/branches/tlee-ast-optimize/Modules/bsddb.h
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/bsddb.h	(original)
+++ python/branches/tlee-ast-optimize/Modules/bsddb.h	Thu May 15 00:25:06 2008
@@ -36,7 +36,7 @@
 /*
  * Handwritten code to wrap version 3.x of the Berkeley DB library,
  * written to replace a SWIG-generated file.  It has since been updated
- * to compile with BerkeleyDB versions 3.2 through 4.2.
+ * to compile with Berkeley DB versions 3.2 through 4.2.
  *
  * This module was started by Andrew Kuchling to remove the dependency
  * on SWIG in a package by Gregory P. Smith who based his work on a
@@ -105,7 +105,7 @@
 #error "eek! DBVER can't handle minor versions > 9"
 #endif
 
-#define PY_BSDDB_VERSION "4.6.0"
+#define PY_BSDDB_VERSION "4.6.5devel2"
 
 /* Python object definitions */
 
@@ -119,17 +119,27 @@
 };
 
 
+
+struct DBObject;          /* Forward declaration */
+struct DBCursorObject;    /* Forward declaration */
+struct DBTxnObject;       /* Forward declaration */
+struct DBSequenceObject;  /* Forward declaration */
+
 typedef struct {
     PyObject_HEAD
     DB_ENV*     db_env;
     u_int32_t   flags;             /* saved flags from open() */
     int         closed;
     struct behaviourFlags moduleFlags;
+#if (DBVER >= 40)
+    PyObject*       event_notifyCallback;
+#endif
+    struct DBObject *children_dbs;
+    struct DBTxnObject *children_txns;
     PyObject        *in_weakreflist; /* List of weak references */
 } DBEnvObject;
 
-
-typedef struct {
+typedef struct DBObject {
     PyObject_HEAD
     DB*             db;
     DBEnvObject*    myenvobj;  /* PyObject containing the DB_ENV */
@@ -137,6 +147,15 @@
     u_int32_t       setflags;  /* saved flags from set_flags() */
     int             haveStat;
     struct behaviourFlags moduleFlags;
+    struct DBTxnObject *txn;
+    struct DBCursorObject *children_cursors;
+#if (DBVER >=43)
+    struct DBSequenceObject *children_sequences;
+#endif
+    struct DBObject **sibling_prev_p;
+    struct DBObject *sibling_next;
+    struct DBObject **sibling_prev_p_txn;
+    struct DBObject *sibling_next_txn;
 #if (DBVER >= 33)
     PyObject*       associateCallback;
     PyObject*       btCompareCallback;
@@ -146,18 +165,31 @@
 } DBObject;
 
 
-typedef struct {
+typedef struct DBCursorObject {
     PyObject_HEAD
     DBC*            dbc;
+    struct DBCursorObject **sibling_prev_p;
+    struct DBCursorObject *sibling_next;
+    struct DBCursorObject **sibling_prev_p_txn;
+    struct DBCursorObject *sibling_next_txn;
     DBObject*       mydb;
+    struct DBTxnObject *txn;
     PyObject        *in_weakreflist; /* List of weak references */
 } DBCursorObject;
 
 
-typedef struct {
+typedef struct DBTxnObject {
     PyObject_HEAD
     DB_TXN*         txn;
-    PyObject        *env;
+    DBEnvObject*    env;
+    int             flag_prepare;
+    struct DBTxnObject *parent_txn;
+    struct DBTxnObject **sibling_prev_p;
+    struct DBTxnObject *sibling_next;
+    struct DBTxnObject *children_txns;
+    struct DBObject *children_dbs;
+    struct DBSequenceObject *children_sequences;
+    struct DBCursorObject *children_cursors;
     PyObject        *in_weakreflist; /* List of weak references */
 } DBTxnObject;
 
@@ -170,13 +202,17 @@
 
 
 #if (DBVER >= 43)
-typedef struct {
+typedef struct DBSequenceObject {
     PyObject_HEAD
     DB_SEQUENCE*     sequence;
     DBObject*        mydb;
+    struct DBTxnObject *txn;
+    struct DBSequenceObject **sibling_prev_p;
+    struct DBSequenceObject *sibling_next;
+    struct DBSequenceObject **sibling_prev_p_txn;
+    struct DBSequenceObject *sibling_next_txn;
     PyObject        *in_weakreflist; /* List of weak references */
 } DBSequenceObject;
-staticforward PyTypeObject DBSequence_Type;
 #endif
 
 

Modified: python/branches/tlee-ast-optimize/Modules/bsddbmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/bsddbmodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/bsddbmodule.c	Thu May 15 00:25:06 2008
@@ -847,6 +847,10 @@
 initbsddb185(void) {
 	PyObject *m, *d;
 
+    if (PyErr_WarnPy3k("the bsddb185 module has been removed in "
+                       "Python 3.0", 2) < 0)
+        return;    
+
 	Bsddbtype.ob_type = &PyType_Type;
 	m = Py_InitModule("bsddb185", bsddbmodule_methods);
 	if (m == NULL)

Modified: python/branches/tlee-ast-optimize/Modules/cPickle.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/cPickle.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/cPickle.c	Thu May 15 00:25:06 2008
@@ -105,18 +105,18 @@
 /* As the name says, an empty tuple. */
 static PyObject *empty_tuple;
 
-/* copy_reg.dispatch_table, {type_object: pickling_function} */
+/* copyreg.dispatch_table, {type_object: pickling_function} */
 static PyObject *dispatch_table;
 
 /* For EXT[124] opcodes. */
-/* copy_reg._extension_registry, {(module_name, function_name): code} */
+/* copyreg._extension_registry, {(module_name, function_name): code} */
 static PyObject *extension_registry;
-/* copy_reg._inverted_registry, {code: (module_name, function_name)} */
+/* copyreg._inverted_registry, {code: (module_name, function_name)} */
 static PyObject *inverted_registry;
-/* copy_reg._extension_cache, {code: object} */
+/* copyreg._extension_cache, {code: object} */
 static PyObject *extension_cache;
 
-/* For looking up name pairs in copy_reg._extension_registry. */
+/* For looking up name pairs in copyreg._extension_registry. */
 static PyObject *two_tuple;
 
 static PyObject *__class___str, *__getinitargs___str, *__dict___str,
@@ -124,7 +124,7 @@
   *__reduce_ex___str,
   *write_str, *append_str,
   *read_str, *readline_str, *__main___str, 
-  *copy_reg_str, *dispatch_table_str;
+  *copyreg_str, *dispatch_table_str;
 
 /*************************************************************************
  Internal Data type for pickle data.                                     */
@@ -2477,7 +2477,7 @@
 	}
 
 	/* Get a reduction callable, and call it.  This may come from
-	 * copy_reg.dispatch_table, the object's __reduce_ex__ method,
+	 * copyreg.dispatch_table, the object's __reduce_ex__ method,
 	 * or the object's __reduce__ method.
 	 */
 	__reduce__ = PyDict_GetItem(dispatch_table, (PyObject *)type);
@@ -2856,7 +2856,7 @@
 
 	if (PyEval_GetRestricted()) {
 		/* Restricted execution, get private tables */
-		PyObject *m = PyImport_Import(copy_reg_str);
+		PyObject *m = PyImport_Import(copyreg_str);
 
 		if (m == NULL)
 			goto err;
@@ -5566,7 +5566,7 @@
 static int
 init_stuff(PyObject *module_dict)
 {
-	PyObject *copy_reg, *t, *r;
+	PyObject *copyreg, *t, *r;
 
 #define INIT_STR(S) if (!( S ## _str=PyString_InternFromString(#S)))  return -1;
 
@@ -5588,30 +5588,30 @@
 	INIT_STR(append);
 	INIT_STR(read);
 	INIT_STR(readline);
-	INIT_STR(copy_reg);
+	INIT_STR(copyreg);
 	INIT_STR(dispatch_table);
 
-	if (!( copy_reg = PyImport_ImportModule("copy_reg")))
+	if (!( copyreg = PyImport_ImportModule("copyreg")))
 		return -1;
 
 	/* This is special because we want to use a different
 	   one in restricted mode. */
-	dispatch_table = PyObject_GetAttr(copy_reg, dispatch_table_str);
+	dispatch_table = PyObject_GetAttr(copyreg, dispatch_table_str);
 	if (!dispatch_table) return -1;
 
-	extension_registry = PyObject_GetAttrString(copy_reg,
+	extension_registry = PyObject_GetAttrString(copyreg,
 				"_extension_registry");
 	if (!extension_registry) return -1;
 
-	inverted_registry = PyObject_GetAttrString(copy_reg,
+	inverted_registry = PyObject_GetAttrString(copyreg,
 				"_inverted_registry");
 	if (!inverted_registry) return -1;
 
-	extension_cache = PyObject_GetAttrString(copy_reg,
+	extension_cache = PyObject_GetAttrString(copyreg,
 				"_extension_cache");
 	if (!extension_cache) return -1;
 
-	Py_DECREF(copy_reg);
+	Py_DECREF(copyreg);
 
 	if (!(empty_tuple = PyTuple_New(0)))
 		return -1;

Modified: python/branches/tlee-ast-optimize/Modules/dlmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/dlmodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/dlmodule.c	Thu May 15 00:25:06 2008
@@ -235,6 +235,10 @@
 {
 	PyObject *m, *d, *x;
 
+    if (PyErr_WarnPy3k("the dl module has been removed in "
+                        "Python 3.0; use the ctypes module instead", 2) < 0)
+        return;    
+
 	/* Initialize object type */
 	Py_TYPE(&Dltype) = &PyType_Type;
 

Modified: python/branches/tlee-ast-optimize/Modules/imageop.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/imageop.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/imageop.c	Thu May 15 00:25:06 2008
@@ -775,6 +775,11 @@
 initimageop(void)
 {
 	PyObject *m;
+	
+	if (PyErr_WarnPy3k("the imageop module has been removed in "
+	                   "Python 3.0", 2) < 0)
+	    return;
+	
 	m = Py_InitModule("imageop", imageop_methods);
 	if (m == NULL)
 		return;

Modified: python/branches/tlee-ast-optimize/Modules/linuxaudiodev.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/linuxaudiodev.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/linuxaudiodev.c	Thu May 15 00:25:06 2008
@@ -469,6 +469,10 @@
 initlinuxaudiodev(void)
 {
     PyObject *m;
+    
+    if (PyErr_WarnPy3k("the linuxaudiodev module has been removed in "
+                    "Python 3.0; use the ossaudiodev module instead", 2) < 0)
+        return;
   
     m = Py_InitModule("linuxaudiodev", linuxaudiodev_methods);
     if (m == NULL)

Modified: python/branches/tlee-ast-optimize/Modules/mathmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/mathmodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/mathmodule.c	Thu May 15 00:25:06 2008
@@ -349,23 +349,65 @@
 math_ldexp(PyObject *self, PyObject *args)
 {
 	double x, r;
-	int exp;
-	if (! PyArg_ParseTuple(args, "di:ldexp", &x, &exp))
+	PyObject *oexp;
+	long exp;
+	if (! PyArg_ParseTuple(args, "dO:ldexp", &x, &oexp))
+		return NULL;
+
+	if (PyLong_Check(oexp)) {
+		/* on overflow, replace exponent with either LONG_MAX
+		   or LONG_MIN, depending on the sign. */
+		exp = PyLong_AsLong(oexp);
+		if (exp == -1 && PyErr_Occurred()) {
+			if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
+				if (Py_SIZE(oexp) < 0) {
+					exp = LONG_MIN;
+				}
+				else {
+					exp = LONG_MAX;
+				}
+				PyErr_Clear();
+			}
+			else {
+				/* propagate any unexpected exception */
+				return NULL;
+			}
+		}
+	}
+	else if (PyInt_Check(oexp)) {
+		exp = PyInt_AS_LONG(oexp);
+	}
+	else {
+		PyErr_SetString(PyExc_TypeError,
+				"Expected an int or long as second argument "
+				"to ldexp.");
 		return NULL;
-	errno = 0;
-	PyFPE_START_PROTECT("in math_ldexp", return 0)
-	r = ldexp(x, exp);
-	PyFPE_END_PROTECT(r)
-	if (Py_IS_FINITE(x) && Py_IS_INFINITY(r))
+	}
+
+	if (x == 0. || !Py_IS_FINITE(x)) {
+		/* NaNs, zeros and infinities are returned unchanged */
+		r = x;
+		errno = 0;
+	} else if (exp > INT_MAX) {
+		/* overflow */
+		r = copysign(Py_HUGE_VAL, x);
 		errno = ERANGE;
-	/* Windows MSVC8 sets errno = EDOM on ldexp(NaN, i);
-	   we unset it to avoid raising a ValueError here. */
-	if (errno == EDOM)
+	} else if (exp < INT_MIN) {
+		/* underflow to +-0 */
+		r = copysign(0., x);
+		errno = 0;
+	} else {
 		errno = 0;
+		PyFPE_START_PROTECT("in math_ldexp", return 0);
+		r = ldexp(x, (int)exp);
+		PyFPE_END_PROTECT(r);
+		if (Py_IS_INFINITY(r))
+			errno = ERANGE;
+	}
+
 	if (errno && is_error(r))
 		return NULL;
-	else
-		return PyFloat_FromDouble(r);
+	return PyFloat_FromDouble(r);
 }
 
 PyDoc_STRVAR(math_ldexp_doc,

Modified: python/branches/tlee-ast-optimize/Modules/parsermodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/parsermodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/parsermodule.c	Thu May 15 00:25:06 2008
@@ -3284,7 +3284,7 @@
      * If this fails, the import of this module will fail because an
      * exception will be raised here; should we clear the exception?
      */
-    copyreg = PyImport_ImportModuleNoBlock("copy_reg");
+    copyreg = PyImport_ImportModuleNoBlock("copyreg");
     if (copyreg != NULL) {
         PyObject *func, *pickler;
 

Modified: python/branches/tlee-ast-optimize/Modules/puremodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/puremodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/puremodule.c	Thu May 15 00:25:06 2008
@@ -951,6 +951,10 @@
 {
 	PyObject *m, *d;
 
+	if (PyErr_WarnPy3k("the pure module has been removed in "
+	                   "Python 3.0", 2) < 0)
+	    return;	
+
 	m = Py_InitModule("pure", pure_methods);
 	if (m == NULL)
     		return;

Modified: python/branches/tlee-ast-optimize/Modules/svmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/svmodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/svmodule.c	Thu May 15 00:25:06 2008
@@ -954,6 +954,10 @@
 initsv(void)
 {
 	PyObject *m, *d;
+	
+	if (PyErr_WarnPy3k("the sv module has been removed in "
+	                   "Python 3.0", 2) < 0)
+	    return;
 
 	m = Py_InitModule("sv", sv_methods);
 	if (m == NULL)

Modified: python/branches/tlee-ast-optimize/Modules/timingmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/timingmodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/timingmodule.c	Thu May 15 00:25:06 2008
@@ -54,5 +54,9 @@
 
 PyMODINIT_FUNC inittiming(void)
 {
+    if (PyErr_WarnPy3k("the timing module has been removed in "
+                        "Python 3.0; use time.clock() instead", 2) < 0)
+        return;
+    
 	(void)Py_InitModule("timing", timing_methods);
 }

Modified: python/branches/tlee-ast-optimize/Modules/zipimport.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/zipimport.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/zipimport.c	Thu May 15 00:25:06 2008
@@ -555,8 +555,15 @@
 "zipimporter(archivepath) -> zipimporter object\n\
 \n\
 Create a new zipimporter instance. 'archivepath' must be a path to\n\
-a zipfile. ZipImportError is raised if 'archivepath' doesn't point to\n\
-a valid Zip archive.");
+a zipfile, or to a specific path inside a zipfile. For example, it can be\n\
+'/tmp/myimport.zip', or '/tmp/myimport.zip/mydirectory', if mydirectory is a\n\
+valid directory inside the archive.\n\
+\n\
+'ZipImportError is raised if 'archivepath' doesn't point to a valid Zip\n\
+archive.\n\
+\n\
+The 'archive' attribute of zipimporter objects contains the name of the\n\
+zipfile targeted.");
 
 #define DEFERRED_ADDRESS(ADDR) 0
 

Modified: python/branches/tlee-ast-optimize/Objects/bytesobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/bytesobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/bytesobject.c	Thu May 15 00:25:06 2008
@@ -315,8 +315,8 @@
     Py_buffer vo;
 
     if (_getbuffer(other, &vo) < 0) {
-        PyErr_Format(PyExc_TypeError, "can't concat bytes to %.100s",
-                     Py_TYPE(self)->tp_name);
+        PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s",
+                     Py_TYPE(other)->tp_name, Py_TYPE(self)->tp_name);
         return NULL;
     }
 

Modified: python/branches/tlee-ast-optimize/Objects/enumobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/enumobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/enumobject.c	Thu May 15 00:25:06 2008
@@ -15,18 +15,36 @@
 {
 	enumobject *en;
 	PyObject *seq = NULL;
-	static char *kwlist[] = {"sequence", 0};
+	PyObject *start = NULL;
+	static char *kwlist[] = {"sequence", "start", 0};
 
-	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:enumerate", kwlist,
-					 &seq))
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:enumerate", kwlist,
+					 &seq, &start))
 		return NULL;
 
 	en = (enumobject *)type->tp_alloc(type, 0);
 	if (en == NULL)
 		return NULL;
-	en->en_index = 0;
+	if (start) {
+		start = PyNumber_Index(start);
+		if (start == NULL) {
+			Py_DECREF(en);
+			return NULL;
+		}
+		if (PyLong_Check(start)) {
+			en->en_index = LONG_MAX;
+			en->en_longindex = start;
+		} else {
+			assert(PyInt_Check(start));
+			en->en_index = PyInt_AsLong(start);
+			en->en_longindex = NULL;
+			Py_DECREF(start);
+		}
+	} else {
+		en->en_index = 0;
+		en->en_longindex = NULL;
+	}
 	en->en_sit = PyObject_GetIter(seq);
-	en->en_longindex = NULL;
 	if (en->en_sit == NULL) {
 		Py_DECREF(en);
 		return NULL;

Modified: python/branches/tlee-ast-optimize/Objects/floatobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/floatobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/floatobject.c	Thu May 15 00:25:06 2008
@@ -1031,6 +1031,7 @@
 		return NULL;
 	if (!Py_IS_FINITE(x))
 		Py_RETURN_FALSE;
+	errno = 0;
 	PyFPE_START_PROTECT("is_integer", return NULL)
 	o = (floor(x) == x) ? Py_True : Py_False;
 	PyFPE_END_PROTECT(x)

Modified: python/branches/tlee-ast-optimize/Objects/setobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/setobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/setobject.c	Thu May 15 00:25:06 2008
@@ -1755,7 +1755,7 @@
 
 	rv = set_contains_key(so, key);
 	if (rv == -1) {
-		if (!PyAnySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
+		if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
 			return -1;
 		PyErr_Clear();
 		tmpkey = make_new_set(&PyFrozenSet_Type, NULL);
@@ -1790,7 +1790,7 @@
 
 	rv = set_discard_key(so, key);
 	if (rv == -1) {
-		if (!PyAnySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
+		if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
 			return NULL;
 		PyErr_Clear();
 		tmpkey = make_new_set(&PyFrozenSet_Type, NULL);
@@ -1821,7 +1821,7 @@
 
 	rv = set_discard_key(so, key);
 	if (rv == -1) {
-		if (!PyAnySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
+		if (!PySet_Check(key) || !PyErr_ExceptionMatches(PyExc_TypeError))
 			return NULL;
 		PyErr_Clear();
 		tmpkey = make_new_set(&PyFrozenSet_Type, NULL);

Modified: python/branches/tlee-ast-optimize/Objects/stringlib/formatter.h
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/stringlib/formatter.h	(original)
+++ python/branches/tlee-ast-optimize/Objects/stringlib/formatter.h	Thu May 15 00:25:06 2008
@@ -453,6 +453,9 @@
     Py_ssize_t n_digits;       /* count of digits need from the computed
                                   string */
     Py_ssize_t n_leading_chars;
+    Py_ssize_t n_grouping_chars = 0; /* Count of additional chars to
+					allocate, used for 'n'
+					formatting. */
     NumberFieldWidths spec;
     long x;
 
@@ -523,6 +526,7 @@
             break;
         default:  /* shouldn't be needed, but stops a compiler warning */
         case 'd':
+        case 'n':
             base = 10;
             leading_chars_to_skip = 0;
             break;
@@ -555,8 +559,15 @@
     /* Calculate the widths of the various leading and trailing parts */
     calc_number_widths(&spec, sign, n_digits, format);
 
+    if (format->type == 'n')
+	    /* Compute how many additional chars we need to allocate
+	       to hold the thousands grouping. */
+	    STRINGLIB_GROUPING(pnumeric_chars, n_digits,
+			       pnumeric_chars+n_digits,
+			       0, &n_grouping_chars, 0);
+
     /* Allocate a new string to hold the result */
-    result = STRINGLIB_NEW(NULL, spec.n_total);
+    result = STRINGLIB_NEW(NULL, spec.n_total + n_grouping_chars);
     if (!result)
 	goto done;
     p = STRINGLIB_STR(result);
@@ -567,13 +578,26 @@
 	    pnumeric_chars,
 	    n_digits * sizeof(STRINGLIB_CHAR));
 
-    /* if X, convert to uppercase */
+    /* If type is 'X', convert to uppercase */
     if (format->type == 'X') {
 	Py_ssize_t t;
 	for (t = 0; t < n_digits; ++t)
 	    p[t + n_leading_chars] = STRINGLIB_TOUPPER(p[t + n_leading_chars]);
     }
 
+    /* Insert the grouping, if any, after the uppercasing of 'X', so we can
+       ensure that grouping chars won't be affeted. */
+    if (n_grouping_chars && format->type == 'n') {
+	    /* We know this can't fail, since we've already
+	       reserved enough space. */
+	    STRINGLIB_CHAR *pstart = p + n_leading_chars;
+	    int r = STRINGLIB_GROUPING(pstart, n_digits,
+				       pstart + n_digits,
+				       spec.n_total+n_grouping_chars-n_leading_chars,
+				       NULL, 0);
+	    assert(r);
+    }
+
     /* Fill in the non-digit parts */
     fill_number(p, &spec, n_digits,
                 format->fill_char == '\0' ? ' ' : format->fill_char);
@@ -841,6 +865,7 @@
     case 'o':
     case 'x':
     case 'X':
+    case 'n':
         /* no type conversion needed, already an int (or long).  do
 	   the formatting */
 	    result = format_int_or_long_internal(value, &format, tostring);
@@ -852,7 +877,6 @@
     case 'F':
     case 'g':
     case 'G':
-    case 'n':
     case '%':
         /* convert to float */
         tmp = PyNumber_Float(value);

Modified: python/branches/tlee-ast-optimize/Objects/stringlib/stringdefs.h
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/stringlib/stringdefs.h	(original)
+++ python/branches/tlee-ast-optimize/Objects/stringlib/stringdefs.h	Thu May 15 00:25:06 2008
@@ -23,5 +23,6 @@
 #define STRINGLIB_CHECK          PyString_Check
 #define STRINGLIB_CMP            memcmp
 #define STRINGLIB_TOSTR          PyObject_Str
+#define STRINGLIB_GROUPING       _PyString_InsertThousandsGrouping
 
 #endif /* !STRINGLIB_STRINGDEFS_H */

Modified: python/branches/tlee-ast-optimize/Objects/stringlib/unicodedefs.h
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/stringlib/unicodedefs.h	(original)
+++ python/branches/tlee-ast-optimize/Objects/stringlib/unicodedefs.h	Thu May 15 00:25:06 2008
@@ -21,6 +21,7 @@
 #define STRINGLIB_NEW            PyUnicode_FromUnicode
 #define STRINGLIB_RESIZE         PyUnicode_Resize
 #define STRINGLIB_CHECK          PyUnicode_Check
+#define STRINGLIB_GROUPING       _PyUnicode_InsertThousandsGrouping
 
 #if PY_VERSION_HEX < 0x03000000
 #define STRINGLIB_TOSTR          PyObject_Unicode

Modified: python/branches/tlee-ast-optimize/Objects/stringobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/stringobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/stringobject.c	Thu May 15 00:25:06 2008
@@ -784,6 +784,10 @@
 #include "stringlib/find.h"
 #include "stringlib/partition.h"
 
+#define _Py_InsertThousandsGrouping _PyString_InsertThousandsGrouping
+#include "stringlib/localeutil.h"
+
+
 
 static int
 string_print(PyStringObject *op, FILE *fp, int flags)
@@ -1498,7 +1502,8 @@
 Return a list of the words in the string S, using sep as the\n\
 delimiter string.  If maxsplit is given, at most maxsplit\n\
 splits are done. If sep is not specified or is None, any\n\
-whitespace string is a separator.");
+whitespace string is a separator and empty strings are removed\n\
+from the result.");
 
 static PyObject *
 string_split(PyStringObject *self, PyObject *args)

Modified: python/branches/tlee-ast-optimize/Objects/typeobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/typeobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/typeobject.c	Thu May 15 00:25:06 2008
@@ -3058,31 +3058,31 @@
 
 
 /* Stuff to implement __reduce_ex__ for pickle protocols >= 2.
-   We fall back to helpers in copy_reg for:
+   We fall back to helpers in copyreg for:
    - pickle protocols < 2
    - calculating the list of slot names (done only once per class)
    - the __newobj__ function (which is used as a token but never called)
 */
 
 static PyObject *
-import_copy_reg(void)
+import_copyreg(void)
 {
-	static PyObject *copy_reg_str;
+	static PyObject *copyreg_str;
 
-	if (!copy_reg_str) {
-		copy_reg_str = PyString_InternFromString("copy_reg");
-		if (copy_reg_str == NULL)
+	if (!copyreg_str) {
+		copyreg_str = PyString_InternFromString("copyreg");
+		if (copyreg_str == NULL)
 			return NULL;
 	}
 
-	return PyImport_Import(copy_reg_str);
+	return PyImport_Import(copyreg_str);
 }
 
 static PyObject *
 slotnames(PyObject *cls)
 {
 	PyObject *clsdict;
-	PyObject *copy_reg;
+	PyObject *copyreg;
 	PyObject *slotnames;
 
 	if (!PyType_Check(cls)) {
@@ -3097,12 +3097,12 @@
 		return slotnames;
 	}
 
-	copy_reg = import_copy_reg();
-	if (copy_reg == NULL)
+	copyreg = import_copyreg();
+	if (copyreg == NULL)
 		return NULL;
 
-	slotnames = PyObject_CallMethod(copy_reg, "_slotnames", "O", cls);
-	Py_DECREF(copy_reg);
+	slotnames = PyObject_CallMethod(copyreg, "_slotnames", "O", cls);
+	Py_DECREF(copyreg);
 	if (slotnames != NULL &&
 	    slotnames != Py_None &&
 	    !PyList_Check(slotnames))
@@ -3123,7 +3123,7 @@
 	PyObject *args = NULL, *args2 = NULL;
 	PyObject *getstate = NULL, *state = NULL, *names = NULL;
 	PyObject *slots = NULL, *listitems = NULL, *dictitems = NULL;
-	PyObject *copy_reg = NULL, *newobj = NULL, *res = NULL;
+	PyObject *copyreg = NULL, *newobj = NULL, *res = NULL;
 	Py_ssize_t i, n;
 
 	cls = PyObject_GetAttrString(obj, "__class__");
@@ -3218,10 +3218,10 @@
 			goto end;
 	}
 
-	copy_reg = import_copy_reg();
-	if (copy_reg == NULL)
+	copyreg = import_copyreg();
+	if (copyreg == NULL)
 		goto end;
-	newobj = PyObject_GetAttrString(copy_reg, "__newobj__");
+	newobj = PyObject_GetAttrString(copyreg, "__newobj__");
 	if (newobj == NULL)
 		goto end;
 
@@ -3248,7 +3248,7 @@
 	Py_XDECREF(names);
 	Py_XDECREF(listitems);
 	Py_XDECREF(dictitems);
-	Py_XDECREF(copy_reg);
+	Py_XDECREF(copyreg);
 	Py_XDECREF(newobj);
 	return res;
 }
@@ -3271,17 +3271,17 @@
 static PyObject *
 _common_reduce(PyObject *self, int proto)
 {
-	PyObject *copy_reg, *res;
+	PyObject *copyreg, *res;
 
 	if (proto >= 2)
 		return reduce_2(self);
 
-	copy_reg = import_copy_reg();
-	if (!copy_reg)
+	copyreg = import_copyreg();
+	if (!copyreg)
 		return NULL;
 
-	res = PyEval_CallMethod(copy_reg, "_reduce_ex", "(Oi)", self, proto);
-	Py_DECREF(copy_reg);
+	res = PyEval_CallMethod(copyreg, "_reduce_ex", "(Oi)", self, proto);
+	Py_DECREF(copyreg);
 
 	return res;
 }

Modified: python/branches/tlee-ast-optimize/Objects/unicodeobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/unicodeobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/unicodeobject.c	Thu May 15 00:25:06 2008
@@ -7494,8 +7494,9 @@
 \n\
 Return a list of the words in S, using sep as the\n\
 delimiter string.  If maxsplit is given, at most maxsplit\n\
-splits are done. If sep is not specified or is None,\n\
-any whitespace string is a separator.");
+splits are done. If sep is not specified or is None, any\n\
+whitespace string is a separator and empty strings are\n\
+removed from the result.");
 
 static PyObject*
 unicode_split(PyUnicodeObject *self, PyObject *args)

Modified: python/branches/tlee-ast-optimize/PC/VS8.0/pythoncore.vcproj
==============================================================================
--- python/branches/tlee-ast-optimize/PC/VS8.0/pythoncore.vcproj	(original)
+++ python/branches/tlee-ast-optimize/PC/VS8.0/pythoncore.vcproj	Thu May 15 00:25:06 2008
@@ -991,6 +991,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\Modules\_bytesio.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\Modules\_functoolsmodule.c"
 				>
 			</File>

Modified: python/branches/tlee-ast-optimize/PC/config.c
==============================================================================
--- python/branches/tlee-ast-optimize/PC/config.c	(original)
+++ python/branches/tlee-ast-optimize/PC/config.c	Thu May 15 00:25:06 2008
@@ -53,6 +53,7 @@
 extern void init_struct(void);
 extern void initdatetime(void);
 extern void init_fileio(void);
+extern void init_bytesio(void);
 extern void init_functools(void);
 extern void init_json(void);
 extern void initzlib(void);
@@ -132,6 +133,7 @@
 	{"_struct", init_struct},
 	{"datetime", initdatetime},
 	{"_fileio", init_fileio},
+	{"_bytesio", init_bytesio},
 	{"_functools", init_functools},
 	{"_json", init_json},
 

Modified: python/branches/tlee-ast-optimize/PC/winsound.c
==============================================================================
--- python/branches/tlee-ast-optimize/PC/winsound.c	(original)
+++ python/branches/tlee-ast-optimize/PC/winsound.c	Thu May 15 00:25:06 2008
@@ -38,9 +38,6 @@
 #include <Python.h>
 #include <windows.h>
 #include <mmsystem.h>
-#ifdef HAVE_CONIO_H
-#include <conio.h>	/* port functions on Win9x */
-#endif
 
 PyDoc_STRVAR(sound_playsound_doc,
 "PlaySound(sound, flags) - a wrapper around the Windows PlaySound API\n"
@@ -53,10 +50,7 @@
 "\n"
 "The frequency argument specifies frequency, in hertz, of the sound.\n"
 "This parameter must be in the range 37 through 32,767.\n"
-"The duration argument specifies the number of milliseconds.\n"
-"On WinNT and 2000, the platform Beep API is used directly.  Else funky\n"
-"code doing direct port manipulation is used; it's unknown whether that\n"
-"will work on all systems.");
+"The duration argument specifies the number of milliseconds.\n");
 
 PyDoc_STRVAR(sound_msgbeep_doc,
 "MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK.");
@@ -107,14 +101,12 @@
     return Py_None;
 }
 
-enum OSType {Win9X, WinNT2000};
-static enum OSType whichOS;	/* set by module init */
-
 static PyObject *
 sound_beep(PyObject *self, PyObject *args)
 {
 	int freq;
 	int dur;
+	BOOL ok;
 
 	if (!PyArg_ParseTuple(args, "ii:Beep", &freq,  &dur))
 		return NULL;
@@ -125,57 +117,14 @@
 		return NULL;
 	}
 
-	/* On NT and 2000, the SDK Beep() function does the whole job.
-	 * But while Beep() exists before NT, it ignores its arguments and
-	 * plays the system default sound.  Sheesh ...
-	 * The Win9X code is mondo bizarre.  I (Tim) pieced it together from
-	 * crap all over the web.  The original IBM PC used some particular
-	 * pieces of hardware (Intel 8255 and 8254 chips) hardwired to
-	 * particular port addresses and running at particular clock speeds,
-	 * and the poor sound card folks have been forced to emulate that in
-	 * all particulars ever since.  But NT and 2000 don't support port
-	 * manipulation.  Don't know about WinME; guessing it's like 98.
-	 */
-
-	if (whichOS == WinNT2000) {
-		BOOL ok;
-		Py_BEGIN_ALLOW_THREADS
-		ok = Beep(freq, dur);
-		Py_END_ALLOW_THREADS
-		if (!ok) {
-			PyErr_SetString(PyExc_RuntimeError,"Failed to beep");
-			return NULL;
-		}
-	}
-#if defined(_M_IX86) && defined(HAVE_CONIO_H)
-	else if (whichOS == Win9X) {
-		int speaker_state;
-		/* Force timer into oscillator mode via timer control port. */
-		_outp(0x43, 0xb6);
-		/* Compute ratio of ancient hardcoded timer frequency to
-		 * frequency we want.  Then feed that ratio (lowest byte
-		 * first) into timer data port.
-		 */
-		freq = 1193180 / freq;
-		_outp(0x42, freq & 0xff);
-		_outp(0x42, (freq >> 8) & 0xff);
-		/* Get speaker control state. */
-		speaker_state = _inp(0x61);
-		/* Turn the speaker on (bit 1)
-		 * and drive speaker from timer (bit 0).
-		 */
-		_outp(0x61, speaker_state | 0x3);
-		/* Let it blast in peace for the duration. */
-		Py_BEGIN_ALLOW_THREADS
-		Sleep(dur);
-		Py_END_ALLOW_THREADS
-		/* Restore speaker control to original state. */
-		_outp(0x61, speaker_state);
-	}
-#endif /* _M_IX86 && HAVE_CONIO_H */
-	else {
-		assert(!"winsound's whichOS has insane value");
+	Py_BEGIN_ALLOW_THREADS
+	ok = Beep(freq, dur);
+	Py_END_ALLOW_THREADS
+	if (!ok) {
+		PyErr_SetString(PyExc_RuntimeError,"Failed to beep");
+		return NULL;
 	}
+
 	Py_INCREF(Py_None);
 	return Py_None;
 }
@@ -217,8 +166,6 @@
 PyMODINIT_FUNC
 initwinsound(void)
 {
-	OSVERSIONINFO version;
-
 	PyObject *dict;
 	PyObject *module = Py_InitModule3("winsound",
 					  sound_methods,
@@ -243,11 +190,4 @@
 	ADD_DEFINE(MB_ICONEXCLAMATION);
 	ADD_DEFINE(MB_ICONHAND);
 	ADD_DEFINE(MB_ICONQUESTION);
-
-	version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-	GetVersionEx(&version);
-	whichOS = Win9X;
-	if (version.dwPlatformId != VER_PLATFORM_WIN32s &&
-	    version.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
-		whichOS = WinNT2000;
 }

Modified: python/branches/tlee-ast-optimize/PCbuild/pythoncore.vcproj
==============================================================================
--- python/branches/tlee-ast-optimize/PCbuild/pythoncore.vcproj	(original)
+++ python/branches/tlee-ast-optimize/PCbuild/pythoncore.vcproj	Thu May 15 00:25:06 2008
@@ -995,6 +995,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\Modules\_bytesio.c"
+				>
+			</File>
+			<File
 				RelativePath="..\Modules\_functoolsmodule.c"
 				>
 			</File>

Modified: python/branches/tlee-ast-optimize/Python/_warnings.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/_warnings.c	(original)
+++ python/branches/tlee-ast-optimize/Python/_warnings.c	Thu May 15 00:25:06 2008
@@ -408,8 +408,10 @@
                 /* A proper implementation of warnings.showwarning() should
                     have at least two default arguments. */
                 if ((defaults == NULL) || (PyTuple_Size(defaults) < 2)) {
-                    if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1) < 0)
+                    if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1) < 0) {
+                        Py_DECREF(show_fxn);
                         goto cleanup;
+                    }
                 }
                 res = PyObject_CallFunctionObjArgs(show_fxn, message, category,
                                                     filename, lineno_obj,

Modified: python/branches/tlee-ast-optimize/Python/bltinmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/bltinmodule.c	(original)
+++ python/branches/tlee-ast-optimize/Python/bltinmodule.c	Thu May 15 00:25:06 2008
@@ -887,9 +887,13 @@
 	}
 	v = PyObject_GetAttr(v, name);
 	if (v == NULL) {
-		PyErr_Clear();
-		Py_INCREF(Py_False);
-		return Py_False;
+		if (!PyErr_ExceptionMatches(PyExc_Exception))
+			return NULL;
+		else {
+			PyErr_Clear();
+			Py_INCREF(Py_False);
+			return Py_False;
+		}
 	}
 	Py_DECREF(v);
 	Py_INCREF(Py_True);

Modified: python/branches/tlee-ast-optimize/Python/marshal.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/marshal.c	(original)
+++ python/branches/tlee-ast-optimize/Python/marshal.c	Thu May 15 00:25:06 2008
@@ -65,7 +65,10 @@
 	if (p->str == NULL)
 		return; /* An error already occurred */
 	size = PyString_Size(p->str);
-	newsize = size + 1024;
+	newsize = size + size + 1024;
+	if (newsize > 32*1024*1024) {
+		newsize = size + 1024*1024;
+	}
 	if (_PyString_Resize(&p->str, newsize) != 0) {
 		p->ptr = p->end = NULL;
 	}

Modified: python/branches/tlee-ast-optimize/Python/pystrtod.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/pystrtod.c	(original)
+++ python/branches/tlee-ast-optimize/Python/pystrtod.c	Thu May 15 00:25:06 2008
@@ -343,14 +343,9 @@
 Py_LOCAL_INLINE(int)
 add_thousands_grouping(char* buffer, size_t buf_size)
 {
+	Py_ssize_t len = strlen(buffer);
 	struct lconv *locale_data = localeconv();
-	const char *grouping = locale_data->grouping;
-	const char *thousands_sep = locale_data->thousands_sep;
-	size_t thousands_sep_len = strlen(thousands_sep);
 	const char *decimal_point = locale_data->decimal_point;
-	char *pend = buffer + strlen(buffer); /* current end of buffer */
-	char *pmax = buffer + buf_size;       /* max of buffer */
-	char current_grouping;
 
 	/* Find the decimal point, if any.  We're only concerned
 	   about the characters to the left of the decimal when
@@ -364,49 +359,13 @@
 		if (!p)
 			/* No exponent and no decimal.  Use the entire
 			   string. */
-			p = pend;
+			p = buffer + len;
 	}
 	/* At this point, p points just past the right-most character we
 	   want to format.  We need to add the grouping string for the
 	   characters between buffer and p. */
-
-	/* Starting at p and working right-to-left, keep track of
-	   what grouping needs to be added and insert that. */
-	current_grouping = *grouping++;
-
-	/* If the first character is 0, perform no grouping at all. */
-	if (current_grouping == 0)
-		return 1;
-
-	while (p - buffer > current_grouping) {
-		/* Always leave buffer and pend valid at the end of this
-		   loop, since we might leave with a return statement. */
-
-		/* Is there room to insert thousands_sep_len chars?. */
-		if (pmax - pend <= thousands_sep_len)
-			/* No room. */
-			return 0;
-
-		/* Move the rest of the string down. */
-		p -= current_grouping;
-		memmove(p + thousands_sep_len,
-			p,
-			pend - p + 1);
-		/* Adjust end pointer. */
-		pend += thousands_sep_len;
-		/* Copy the thousands_sep chars into the buffer. */
-		memcpy(p, thousands_sep, thousands_sep_len);
-
-		/* Move to the next grouping character, unless we're
-		   repeating (which is designated by a grouping of 0). */
-		if (*grouping != 0) {
-			current_grouping = *grouping++;
-			if (current_grouping == CHAR_MAX)
-				/* We're done. */
-				return 1;
-		}
-	}
-	return 1;
+	return _PyString_InsertThousandsGrouping(buffer, len, p,
+						 buf_size, NULL, 1);
 }
 
 /* see FORMATBUFLEN in unicodeobject.c */

Modified: python/branches/tlee-ast-optimize/Python/pythonrun.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/pythonrun.c	(original)
+++ python/branches/tlee-ast-optimize/Python/pythonrun.c	Thu May 15 00:25:06 2008
@@ -1508,10 +1508,10 @@
 		msg = "invalid token";
 		break;
 	case E_EOFS:
-		msg = "EOF while scanning triple-quoted string";
+		msg = "EOF while scanning triple-quoted string literal";
 		break;
 	case E_EOLS:
-		msg = "EOL while scanning single-quoted string";
+		msg = "EOL while scanning string literal";
 		break;
 	case E_INTR:
 		if (!PyErr_Occurred())

Modified: python/branches/tlee-ast-optimize/Python/sysmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/sysmodule.c	(original)
+++ python/branches/tlee-ast-optimize/Python/sysmodule.c	Thu May 15 00:25:06 2008
@@ -1178,9 +1178,9 @@
 	flags__doc__,	/* doc */
 	flags_fields,	/* fields */
 #ifdef RISCOS
-	15
+	16
 #else
-	14
+	15
 #endif
 };
 

Modified: python/branches/tlee-ast-optimize/README
==============================================================================
--- python/branches/tlee-ast-optimize/README	(original)
+++ python/branches/tlee-ast-optimize/README	Thu May 15 00:25:06 2008
@@ -1,4 +1,4 @@
-This is Python version 2.6 alpha 2
+This is Python version 2.6 alpha 3
 ==================================
 
 Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008

Modified: python/branches/tlee-ast-optimize/Tools/buildbot/buildmsi.bat
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/buildbot/buildmsi.bat	(original)
+++ python/branches/tlee-ast-optimize/Tools/buildbot/buildmsi.bat	Thu May 15 00:25:06 2008
@@ -9,7 +9,7 @@
 
 @rem build the documentation
 bash.exe -c 'cd Doc;make PYTHON=python2.5 update htmlhelp'
-"%ProgramFiles%\HTML Help Workshop\hhc.exe" Doc\build\htmlhelp\pydoc.hhp
+"%ProgramFiles%\HTML Help Workshop\hhc.exe" Doc\build\htmlhelp\python26a3.hhp
 
 @rem buold the MSI file
 cd PC

Modified: python/branches/tlee-ast-optimize/Tools/msi/msi.py
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/msi/msi.py	(original)
+++ python/branches/tlee-ast-optimize/Tools/msi/msi.py	Thu May 15 00:25:06 2008
@@ -111,6 +111,12 @@
     "26":"{34ebecac-f046-4e1c-b0e3-9bac3cdaacfa}",
     } [major+minor]
 
+# Compute the name that Sphinx gives to the docfile
+docfile = ""
+if level < 0xf:
+    docfile = '%x%s' % (level, serial)
+docfile = 'python%s%s%s.chm' % (major, minor, docfile)
+
 # Build the mingw import library, libpythonXY.a
 # This requires 'nm' and 'dlltool' executables on your PATH
 def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib):
@@ -1072,8 +1078,8 @@
     # Add documentation
     htmlfiles.set_current()
     lib = PyDirectory(db, cab, root, "Doc", "Doc", "DOC|Doc")
-    lib.start_component("documentation", keyfile="Python%s%s.chm" % (major,minor))
-    lib.add_file("Python%s%s.chm" % (major, minor), src="build/htmlhelp/pydoc.chm")
+    lib.start_component("documentation", keyfile=docfile)
+    lib.add_file(docfile, src="build/htmlhelp/"+docfile)
 
     cab.commit(db)
 
@@ -1181,7 +1187,7 @@
               ("PythonPath", -1, prefix+r"\PythonPath", "",
                r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"),
               ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "",
-               r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY.doc"),
+               "[TARGETDIR]Doc\\"+docfile , "REGISTRY.doc"),
               ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"),
               ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe",
                "", r"[TARGETDIR]Python.exe", "REGISTRY.def")
@@ -1211,7 +1217,7 @@
               # htmlfiles.id, None, None, None, None, None, None, None),
               ## Non-advertised shortcuts: must be associated with a registry component
               ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc",
-               "[#Python%s%s.chm]" % (major,minor), None,
+               "[#%s]" % docfile, None,
                None, None, None, None, None, None),
               ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY",
                SystemFolderName+"msiexec",  "/x%s" % product_code,

Modified: python/branches/tlee-ast-optimize/Tools/msi/msisupport.c
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/msi/msisupport.c	(original)
+++ python/branches/tlee-ast-optimize/Tools/msi/msisupport.c	Thu May 15 00:25:06 2008
@@ -1,8 +1,6 @@
 #include "windows.h"
 #include "msiquery.h"
 
-int isWinNT;
-
 /* Print a debug message to the installer log file.
  * To see the debug messages, install with
  * msiexec /i pythonxy.msi /l*v python.log
@@ -30,21 +28,14 @@
 	DWORD size = PSIZE;
 	DWORD attributes;
 
-	isWinNT = (GetVersion() < 0x80000000) ? 1 : 0;
 	
-	if (isWinNT)
-		result = MsiGetPropertyW(hInstall, L"TARGETDIR", wpath, &size);
-	else
-		result = MsiGetPropertyA(hInstall, "TARGETDIR", path, &size);
+	result = MsiGetPropertyW(hInstall, L"TARGETDIR", wpath, &size);
 	if (result != ERROR_SUCCESS)
 		return result;
 	wpath[size] = L'\0';
 	path[size] = L'\0';
 
-	if (isWinNT)
-		attributes = GetFileAttributesW(wpath);
-	else
-		attributes = GetFileAttributesA(path);
+	attributes = GetFileAttributesW(wpath);
 	if (attributes == INVALID_FILE_ATTRIBUTES ||
 		!(attributes & FILE_ATTRIBUTE_DIRECTORY)) 
 	{

Modified: python/branches/tlee-ast-optimize/Tools/msi/msisupport.mak
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/msi/msisupport.mak	(original)
+++ python/branches/tlee-ast-optimize/Tools/msi/msisupport.mak	Thu May 15 00:25:06 2008
@@ -1,25 +1,9 @@
-!IF "$(CPU)" == ""
-# VS environment
-
 # /OPT: REF and ICF are added by VS.NET by default
-# NOWIN98 saves 7k of executable size, at the expense of some
-# slowdown on Win98
 msisupport.dll:	msisupport.obj
-	link.exe /OUT:msisupport.dll /INCREMENTAL:NO /NOLOGO /DLL /MACHINE:X86 /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /OPT:NOWIN98 msisupport.obj msi.lib kernel32.lib
+	link.exe /OUT:msisupport.dll /INCREMENTAL:NO /NOLOGO /DLL /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF msisupport.obj msi.lib kernel32.lib
 
 # We request a static CRT, so that there will be no CRT dependencies
 # for the target system. We cannot do without a CRT, since it provides
 # the DLL entry point.
 msisupport.obj:	msisupport.c
 	cl /O2 /D WIN32 /D NDEBUG /D _WINDOWS /MT /W3 /c msisupport.c
-
-!ELSE
-# SDK environment: assume all options are already correct
-
-msisupport.dll:	msisupport.obj
-	link.exe /OUT:msisupport.dll /INCREMENTAL:NO /NOLOGO /DLL msisupport.obj msi.lib kernel32.lib
-
-msisupport.obj:	msisupport.c
-	cl /O2 /D WIN32 /D NDEBUG /D _WINDOWS /MD /W3 /GS- /c msisupport.c
-!ENDIF
-

Modified: python/branches/tlee-ast-optimize/Tools/msi/uuids.py
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/msi/uuids.py	(original)
+++ python/branches/tlee-ast-optimize/Tools/msi/uuids.py	Thu May 15 00:25:06 2008
@@ -41,4 +41,6 @@
     '2.6.102': '{3b27e16c-56db-4570-a2d3-e9a26180c60b}', # 2.6a2
     '2.6.103': '{cd06a9c5-bde5-4bd7-9874-48933997122a}', # 2.6a3
     '2.6.104': '{dc6ed634-474a-4a50-a547-8de4b7491e53}', # 2.6a4
+    '2.6.111': '{3f82079a-5bee-4c4a-8a41-8292389e24ae}', # 2.6b1
+    '2.6.112': '{8a0e5970-f3e6-4737-9a2b-bc5ff0f15fb5}', # 2.6b2
 }

Modified: python/branches/tlee-ast-optimize/Tools/webchecker/wsgui.py
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/webchecker/wsgui.py	(original)
+++ python/branches/tlee-ast-optimize/Tools/webchecker/wsgui.py	Thu May 15 00:25:06 2008
@@ -10,7 +10,7 @@
 import websucker
 import os
 import threading
-import Queue
+import queue
 import time
 
 VERBOSE = 2
@@ -139,7 +139,7 @@
 
     def go(self, event=None):
         if not self.msgq:
-            self.msgq = Queue.Queue(0)
+            self.msgq = queue.Queue(0)
             self.check_msgq()
         if not self.sucker:
             self.sucker = SuckerThread(self.msgq)

Modified: python/branches/tlee-ast-optimize/setup.py
==============================================================================
--- python/branches/tlee-ast-optimize/setup.py	(original)
+++ python/branches/tlee-ast-optimize/setup.py	Thu May 15 00:25:06 2008
@@ -436,6 +436,8 @@
         exts.append( Extension('operator', ['operator.c']) )
         # Python 3.0 _fileio module
         exts.append( Extension("_fileio", ["_fileio.c"]) )
+        # Python 3.0 _bytesio module
+        exts.append( Extension("_bytesio", ["_bytesio.c"]) )
         # _functools
         exts.append( Extension("_functools", ["_functoolsmodule.c"]) )
         # _json speedups


More information about the Python-checkins mailing list