[Python-checkins] r62698 - in python/branches/tlee-ast-optimize: Doc/c-api/number.rst Doc/c-api/typeobj.rst Doc/conf.py Doc/distutils/builtdist.rst Doc/library/carbon.rst Doc/library/decimal.rst Doc/library/functions.rst Doc/library/pyclbr.rst Doc/library/robotparser.rst Doc/library/simplehttpserver.rst Doc/library/socket.rst Doc/library/tempfile.rst Doc/tools/sphinxext/indexcontent.html Doc/tools/sphinxext/layout.html Doc/tools/sphinxext/opensearch.xml Doc/tools/sphinxext/static Doc/using/cmdline.rst Doc/whatsnew/2.6.rst Lib/calendar.py Lib/contextlib.py Lib/decimal.py Lib/distutils/command/bdist_wininst.py Lib/distutils/command/wininst-6.0.exe Lib/distutils/command/wininst-7.1.exe Lib/distutils/command/wininst-9.0-amd64.exe Lib/distutils/command/wininst-9.0.exe Lib/distutils/msvc9compiler.py Lib/idlelib/AutoComplete.py Lib/idlelib/AutoCompleteWindow.py Lib/idlelib/EditorWindow.py Lib/idlelib/NEWS.txt Lib/idlelib/PyShell.py Lib/io.py Lib/lib2to3 Lib/lib2to3/refactor.py Lib/lib2to3/tests/test_fixers.py Lib/plat-mac/Carbon/AppleEvents.py Lib/plat-mac/macerrors.py Lib/plat-mac/terminalcommand.py Lib/pyclbr.py Lib/robotparser.py Lib/socket.py Lib/tempfile.py Lib/test/test_builtin.py Lib/test/test_cmd_line_script.py Lib/test/test_contextlib.py Lib/test/test_decimal.py Lib/test/test_float.py Lib/test/test_frozen.py Lib/test/test_int.py Lib/test/test_io.py Lib/test/test_list.py Lib/test/test_long.py Lib/test/test_str.py Lib/test/test_sundry.py Lib/test/test_support.py Lib/test/test_tempfile.py Lib/test/test_traceback.py Lib/test/test_tuple.py Lib/test/test_types.py Lib/test/test_warnings.py Lib/test/test_with.py Mac/BuildScript/build-installer.py Mac/BuildScript/resources/ReadMe.txt Mac/IDLE/Makefile.in Mac/Makefile.in Mac/PythonLauncher/Makefile.in Mac/PythonLauncher/MyDocument.m Mac/PythonLauncher/doscript.m Mac/Resources/app/Info.plist Mac/Resources/app/Info.plist.in Mac/Resources/app/Resources/English.lproj/InfoPlist.strings Mac/Resources/framework/English.lproj Mac/Resources/framework/Info.plist Mac/Resources/framework/Info.plist.in Mac/Resources/framework/version.plist Makefile.pre.in Misc/NEWS Misc/developers.txt Modules/_testcapimodule.c Modules/arraymodule.c Objects/cellobject.c Objects/codeobject.c Objects/dictobject.c Objects/exceptions.c Objects/fileobject.c Objects/listobject.c Objects/methodobject.c PC/bdist_wininst/install.c PC/bdist_wininst/wininst-7.1.vcproj PC/bdist_wininst/wininst.dsp Python/_warnings.c Python/ast.c Python/bltinmodule.c Python/ceval.c Python/pystrtod.c Python/sysmodule.c Python/traceback.c configure configure.in

thomas.lee python-checkins at python.org
Sun May 4 12:13:32 CEST 2008


Author: thomas.lee
Date: Sun May  4 12:13:28 2008
New Revision: 62698

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

................
  r62531 | georg.brandl | 2008-04-28 03:38:55 +1000 (Mon, 28 Apr 2008) | 2 lines
  
  Use correct XHTML tags.
................
  r62535 | benjamin.peterson | 2008-04-28 04:14:39 +1000 (Mon, 28 Apr 2008) | 2 lines
  
  #2700 Document PyNumber_ToBase
................
  r62536 | benjamin.peterson | 2008-04-28 04:40:21 +1000 (Mon, 28 Apr 2008) | 2 lines
  
  A little reformating of Py3k warnings
................
  r62540 | georg.brandl | 2008-04-28 06:03:05 +1000 (Mon, 28 Apr 2008) | 2 lines
  
  Add OpenSearch and a Python logo to the HTML output.
................
  r62545 | skip.montanaro | 2008-04-28 06:53:57 +1000 (Mon, 28 Apr 2008) | 1 line
  
  minor wording changes, rewrap a few lines
................
  r62546 | kurt.kaiser | 2008-04-28 07:07:41 +1000 (Mon, 28 Apr 2008) | 7 lines
  
  Home / Control-A toggles between left margin and end of leading white
  space.  Patch 1196903 Jeff Shute.
  
  M    idlelib/PyShell.py
  M    idlelib/EditorWindow.py
  M    idlelib/NEWS.txt
................
  r62548 | kurt.kaiser | 2008-04-28 07:38:05 +1000 (Mon, 28 Apr 2008) | 2 lines
  
  Improved AutoCompleteWindow logic.  Patch 2062 Tal Einat. 
................
  r62549 | kurt.kaiser | 2008-04-28 07:52:19 +1000 (Mon, 28 Apr 2008) | 4 lines
  
  Autocompletion of filenames now support alternate separators, e.g. the
  '/' char on Windows.  Patch 2061 Tal Einat.
................
  r62550 | skip.montanaro | 2008-04-28 08:49:56 +1000 (Mon, 28 Apr 2008) | 6 lines
  
  A few small changes:
  * The only exception we should catch when trying to import cStringIO is an
    ImportError.
  * Delete the function signatures embedded in the mk*temp docstrings.
  * The tempdir global variable was initialized twice.
................
  r62551 | skip.montanaro | 2008-04-28 08:52:02 +1000 (Mon, 28 Apr 2008) | 4 lines
  
  Wrap some long paragraphs and include the default values for optional
  function parameters.
................
  r62553 | skip.montanaro | 2008-04-28 12:57:23 +1000 (Mon, 28 Apr 2008) | 7 lines
  
  Minor cleanups:
  * Avoid creating unused local variables where we can.  Where we can't prefix
    the unused variables with '_'.
  * Avoid shadowing builtins where it won't change the external interface of a
    function.
  * Use None as default path arg to readmodule and readmodule_ex.
................
  r62554 | skip.montanaro | 2008-04-28 12:59:45 +1000 (Mon, 28 Apr 2008) | 6 lines
  
  Correct documentation to match implementation: "Class" instead of
  "class_descriptor", "Function" instead of "function_descriptor".  Note
  default path value for readmodule*.  Wrap some long paragraphs.  Don't
  mention 'inpackage' which isn't part of the public API.
................
  r62555 | brett.cannon | 2008-04-28 13:23:50 +1000 (Mon, 28 Apr 2008) | 5 lines
  
  Fix a bug introduced by the warnings rewrite where tracebacks were being
  improperly indented.
  
  Closes issue #2699.
................
  r62556 | skip.montanaro | 2008-04-28 13:25:37 +1000 (Mon, 28 Apr 2008) | 2 lines
  
  Wrap some long lines.
................
  r62557 | skip.montanaro | 2008-04-28 13:27:53 +1000 (Mon, 28 Apr 2008) | 6 lines
  
  Get rid of _test(), _main(), _debug() and _check().  Tests are no longer
  needed (better set available in Lib/test/test_robotparser.py).  Clean up a
  few PEP 8 nits (compound statements on a single line, whitespace around
  operators).
................
  r62558 | brett.cannon | 2008-04-28 14:50:06 +1000 (Mon, 28 Apr 2008) | 3 lines
  
  Rename the test_traceback_print() function to traceback_print() to prevent
  test_capi from automatically calling the function.
................
  r62559 | georg.brandl | 2008-04-28 15:16:30 +1000 (Mon, 28 Apr 2008) | 2 lines
  
  Fix markup.
................
  r62569 | amaury.forgeotdarc | 2008-04-29 07:07:06 +1000 (Tue, 29 Apr 2008) | 5 lines
  
  test_sundry performs minimal tests (a simple import...) on modules that are not tested otherwise.
  
  Some of them now have tests and can be removed.
  Only 70 to go...
................
  r62574 | andrew.kuchling | 2008-04-29 12:03:54 +1000 (Tue, 29 Apr 2008) | 1 line
  
  Strip down SSL docs; I'm not managing to get test programs working, so I'll just give a minimal description
................
  r62577 | martin.v.loewis | 2008-04-29 16:10:53 +1000 (Tue, 29 Apr 2008) | 2 lines
  
  Add Rodrigo and Heiko.
................
  r62586 | eric.smith | 2008-04-30 11:09:30 +1000 (Wed, 30 Apr 2008) | 5 lines
  
  Issue 2526, float.__format__ 'n' specifier does not support thousands grouping.
  
  Implemented grouping, with tests.
  Cleaned up PyOS_ascii_formatd by breaking reformatting into smaller functions.
................
  r62593 | nick.coghlan | 2008-05-01 00:23:36 +1000 (Thu, 01 May 2008) | 1 line
  
  Update command line usage documentation to reflect 2.6 changes (also includes some minor cleanups). Addresses TODO list issue 2258
................
  r62595 | andrew.kuchling | 2008-05-01 02:19:55 +1000 (Thu, 01 May 2008) | 1 line
  
  Typo fix
................
  r62599 | georg.brandl | 2008-05-01 05:47:09 +1000 (Thu, 01 May 2008) | 2 lines
  
  #2719: backport next() from 3k.
................
  r62602 | georg.brandl | 2008-05-01 06:02:37 +1000 (Thu, 01 May 2008) | 2 lines
  
  #2727: clarify tp_iternext docs.
................
  r62604 | benjamin.peterson | 2008-05-01 07:03:58 +1000 (Thu, 01 May 2008) | 2 lines
  
  make test_support's captured_output a bit more robust when exceptions happen
................
  r62605 | georg.brandl | 2008-05-01 07:08:42 +1000 (Thu, 01 May 2008) | 2 lines
  
  #1748: use functools.wraps instead of rolling own metadata update.
................
  r62606 | benjamin.peterson | 2008-05-01 07:25:55 +1000 (Thu, 01 May 2008) | 2 lines
  
  Remove some from __future__ import with_statements
................
  r62608 | benjamin.peterson | 2008-05-01 08:03:36 +1000 (Thu, 01 May 2008) | 2 lines
  
  Fix typo in whatsnew
................
  r62616 | georg.brandl | 2008-05-02 04:24:32 +1000 (Fri, 02 May 2008) | 2 lines
  
  Fix synopsis.
................
  r62626 | brett.cannon | 2008-05-02 12:25:09 +1000 (Fri, 02 May 2008) | 6 lines
  
  Fix a backwards-compatibility mistake where a new optional argument for
  warnings.showwarning() was being used. This broke pre-existing replacements for
  the function since they didn't support the extra argument.
  
  Closes issue 2705.
................
  r62627 | gregory.p.smith | 2008-05-02 17:26:52 +1000 (Fri, 02 May 2008) | 20 lines
  
  This should fix issue2632.  A long description of the two competing
  problems is in the bug report (one old, one recently introduced trying
  to fix the old one).  In short:
  
  buffer data during socket._fileobject.read() and readlines() within a
  cStringIO object instead of a [] of str()s returned from the recv()
  call.
  
  This prevents excessive memory use due to the size parameter being
  passed to recv() being grossly larger than the actual size of the data
  returned *and* prevents excessive cpu usage due to looping in python
  calling recv() with a very tiny size value if min() is used as the
  previous memory-use bug "fix" did.
  
  It also documents what the socket._fileobject._rbufsize member is
  actually used for.
  
  This is a candidate for back porting to 2.5.
................
  r62636 | mark.hammond | 2008-05-02 22:48:15 +1000 (Fri, 02 May 2008) | 2 lines
  
  #2581: Vista UAC/elevation support for bdist_wininst
................
  r62638 | facundo.batista | 2008-05-03 03:39:00 +1000 (Sat, 03 May 2008) | 3 lines
  
  
  Fixed some test structures. Thanks Mark Dickinson.
................
  r62644 | ronald.oussoren | 2008-05-03 05:45:11 +1000 (Sat, 03 May 2008) | 7 lines
  
  Fix for issue #2573: Can't change the framework name on OS X builds
  
  This introduces a new configure option: --with-framework-name=NAME 
  (defaulting to 'Python'). This allows you to install several copies
  of the Python framework with different names (such as a normal build
  and a debug build).
................
  r62645 | ronald.oussoren | 2008-05-03 05:58:56 +1000 (Sat, 03 May 2008) | 2 lines
  
  Finish fix for issue2573, previous patch was incomplete. 
................
  r62647 | martin.v.loewis | 2008-05-03 07:30:20 +1000 (Sat, 03 May 2008) | 13 lines
  
  Merged revisions 62263-62646 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
  
  ........
    r62470 | david.wolever | 2008-04-24 02:11:07 +0200 (Do, 24 Apr 2008) | 3 lines
    
    Fixed up and applied the patch for #2431 -- speeding up 2to3 with a lookup table.
  ........
    r62646 | martin.v.loewis | 2008-05-02 23:29:27 +0200 (Fr, 02 Mai 2008) | 2 lines
    
    Fix whitespace.
  ........
................
  r62648 | ronald.oussoren | 2008-05-03 07:42:35 +1000 (Sat, 03 May 2008) | 4 lines
  
  Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
  
  This fixes both Python Launchar and the terminalcommand module. 
................
  r62651 | ronald.oussoren | 2008-05-03 07:54:56 +1000 (Sat, 03 May 2008) | 2 lines
  
  Fix for issue #2520 (cannot import macerrors)
................
  r62652 | benjamin.peterson | 2008-05-03 08:12:58 +1000 (Sat, 03 May 2008) | 2 lines
  
  capitalization nit for reStructuredText
................
  r62653 | brett.cannon | 2008-05-03 11:02:41 +1000 (Sat, 03 May 2008) | 2 lines
  
  Fix some indentation errors.
................
  r62656 | brett.cannon | 2008-05-03 13:19:39 +1000 (Sat, 03 May 2008) | 6 lines
  
  Fix the C implementation of 'warnings' to infer the filename of the module that
  raised an exception properly when __file__ is not set, __name__ == '__main__',
  and sys.argv[0] is a false value.
  
  Closes issue2743.
................
  r62661 | amaury.forgeotdarc | 2008-05-03 22:21:13 +1000 (Sat, 03 May 2008) | 8 lines
  
  In test_io, StatefulIncrementalDecoderTest was not part of the test suite.
  And of course, the test failed:
  a bytearray was used without reason in io.TextIOWrapper.tell().
  
  The difference is that iterating over bytes (i.e. str in python2.6) returns 1-char bytes, 
  whereas bytearrays yield integers.
  This code should still work with python3.0
................
  r62663 | benjamin.peterson | 2008-05-04 01:56:42 +1000 (Sun, 04 May 2008) | 2 lines
  
  The compiling struct is now passed around to all AST helpers (see issue 2720)
................
  r62666 | mark.dickinson | 2008-05-04 04:23:14 +1000 (Sun, 04 May 2008) | 3 lines
  
  Backport Raymond's changes in r60508 to Python 2.6.
  'Context flags get set, not incremented'
................
  r62671 | georg.brandl | 2008-05-04 06:16:47 +1000 (Sun, 04 May 2008) | 2 lines
  
  Insert correct OpenSearch base URL.
................
  r62680 | benjamin.peterson | 2008-05-04 07:35:18 +1000 (Sun, 04 May 2008) | 2 lines
  
  Moved testing of builtin types out of test_builtin and into type specific modules
................
  r62684 | mark.dickinson | 2008-05-04 12:05:06 +1000 (Sun, 04 May 2008) | 9 lines
  
  Some very minor changes to decimal.py in Python 2.6, aimed
  at reducing the size of the diff between the 2.x decimal.py
  and 3.x decimal.py and thereby making future merges easier:
  
  - replace one instnace of an old-style raise statement
  - define __div__ in terms of __truediv__ instead of the
    other way around
  - make wording match on an exception message
................
  r62686 | mark.dickinson | 2008-05-04 12:25:46 +1000 (Sun, 04 May 2008) | 4 lines
  
  Make sure that Context traps and flags dictionaries have values 0 and 1 
  (as documented) rather than True and False.
................
  r62687 | benjamin.peterson | 2008-05-04 13:05:49 +1000 (Sun, 04 May 2008) | 2 lines
  
  Fix typo in whatsnew
................
  r62696 | georg.brandl | 2008-05-04 19:15:04 +1000 (Sun, 04 May 2008) | 2 lines
  
  #2752: wrong meaning of '' for socket host.
................


Added:
   python/branches/tlee-ast-optimize/Doc/tools/sphinxext/layout.html
      - copied unchanged from r62696, /python/trunk/Doc/tools/sphinxext/layout.html
   python/branches/tlee-ast-optimize/Doc/tools/sphinxext/opensearch.xml
      - copied unchanged from r62696, /python/trunk/Doc/tools/sphinxext/opensearch.xml
   python/branches/tlee-ast-optimize/Doc/tools/sphinxext/static/
      - copied from r62696, /python/trunk/Doc/tools/sphinxext/static/
   python/branches/tlee-ast-optimize/Lib/test/test_int.py
      - copied unchanged from r62696, /python/trunk/Lib/test/test_int.py
   python/branches/tlee-ast-optimize/Mac/Resources/app/Info.plist.in
      - copied unchanged from r62696, /python/trunk/Mac/Resources/app/Info.plist.in
   python/branches/tlee-ast-optimize/Mac/Resources/framework/Info.plist.in
      - copied unchanged from r62696, /python/trunk/Mac/Resources/framework/Info.plist.in
Removed:
   python/branches/tlee-ast-optimize/Mac/Resources/app/Info.plist
   python/branches/tlee-ast-optimize/Mac/Resources/app/Resources/English.lproj/InfoPlist.strings
   python/branches/tlee-ast-optimize/Mac/Resources/framework/English.lproj/
   python/branches/tlee-ast-optimize/Mac/Resources/framework/Info.plist
   python/branches/tlee-ast-optimize/Mac/Resources/framework/version.plist
Modified:
   python/branches/tlee-ast-optimize/   (props changed)
   python/branches/tlee-ast-optimize/Doc/c-api/number.rst
   python/branches/tlee-ast-optimize/Doc/c-api/typeobj.rst
   python/branches/tlee-ast-optimize/Doc/conf.py
   python/branches/tlee-ast-optimize/Doc/distutils/builtdist.rst
   python/branches/tlee-ast-optimize/Doc/library/carbon.rst
   python/branches/tlee-ast-optimize/Doc/library/decimal.rst
   python/branches/tlee-ast-optimize/Doc/library/functions.rst
   python/branches/tlee-ast-optimize/Doc/library/pyclbr.rst
   python/branches/tlee-ast-optimize/Doc/library/robotparser.rst
   python/branches/tlee-ast-optimize/Doc/library/simplehttpserver.rst
   python/branches/tlee-ast-optimize/Doc/library/socket.rst
   python/branches/tlee-ast-optimize/Doc/library/tempfile.rst
   python/branches/tlee-ast-optimize/Doc/tools/sphinxext/indexcontent.html
   python/branches/tlee-ast-optimize/Doc/using/cmdline.rst
   python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst
   python/branches/tlee-ast-optimize/Lib/calendar.py
   python/branches/tlee-ast-optimize/Lib/contextlib.py
   python/branches/tlee-ast-optimize/Lib/decimal.py
   python/branches/tlee-ast-optimize/Lib/distutils/command/bdist_wininst.py
   python/branches/tlee-ast-optimize/Lib/distutils/command/wininst-6.0.exe
   python/branches/tlee-ast-optimize/Lib/distutils/command/wininst-7.1.exe
   python/branches/tlee-ast-optimize/Lib/distutils/command/wininst-9.0-amd64.exe
   python/branches/tlee-ast-optimize/Lib/distutils/command/wininst-9.0.exe
   python/branches/tlee-ast-optimize/Lib/distutils/msvc9compiler.py
   python/branches/tlee-ast-optimize/Lib/idlelib/AutoComplete.py
   python/branches/tlee-ast-optimize/Lib/idlelib/AutoCompleteWindow.py
   python/branches/tlee-ast-optimize/Lib/idlelib/EditorWindow.py
   python/branches/tlee-ast-optimize/Lib/idlelib/NEWS.txt
   python/branches/tlee-ast-optimize/Lib/idlelib/PyShell.py
   python/branches/tlee-ast-optimize/Lib/io.py
   python/branches/tlee-ast-optimize/Lib/lib2to3/   (props changed)
   python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py
   python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/Carbon/AppleEvents.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/macerrors.py
   python/branches/tlee-ast-optimize/Lib/plat-mac/terminalcommand.py
   python/branches/tlee-ast-optimize/Lib/pyclbr.py
   python/branches/tlee-ast-optimize/Lib/robotparser.py
   python/branches/tlee-ast-optimize/Lib/socket.py
   python/branches/tlee-ast-optimize/Lib/tempfile.py
   python/branches/tlee-ast-optimize/Lib/test/test_builtin.py
   python/branches/tlee-ast-optimize/Lib/test/test_cmd_line_script.py
   python/branches/tlee-ast-optimize/Lib/test/test_contextlib.py
   python/branches/tlee-ast-optimize/Lib/test/test_decimal.py
   python/branches/tlee-ast-optimize/Lib/test/test_float.py
   python/branches/tlee-ast-optimize/Lib/test/test_frozen.py
   python/branches/tlee-ast-optimize/Lib/test/test_io.py
   python/branches/tlee-ast-optimize/Lib/test/test_list.py
   python/branches/tlee-ast-optimize/Lib/test/test_long.py
   python/branches/tlee-ast-optimize/Lib/test/test_str.py
   python/branches/tlee-ast-optimize/Lib/test/test_sundry.py
   python/branches/tlee-ast-optimize/Lib/test/test_support.py
   python/branches/tlee-ast-optimize/Lib/test/test_tempfile.py
   python/branches/tlee-ast-optimize/Lib/test/test_traceback.py
   python/branches/tlee-ast-optimize/Lib/test/test_tuple.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_with.py
   python/branches/tlee-ast-optimize/Mac/BuildScript/build-installer.py
   python/branches/tlee-ast-optimize/Mac/BuildScript/resources/ReadMe.txt
   python/branches/tlee-ast-optimize/Mac/IDLE/Makefile.in
   python/branches/tlee-ast-optimize/Mac/Makefile.in
   python/branches/tlee-ast-optimize/Mac/PythonLauncher/Makefile.in
   python/branches/tlee-ast-optimize/Mac/PythonLauncher/MyDocument.m
   python/branches/tlee-ast-optimize/Mac/PythonLauncher/doscript.m
   python/branches/tlee-ast-optimize/Makefile.pre.in
   python/branches/tlee-ast-optimize/Misc/NEWS
   python/branches/tlee-ast-optimize/Misc/developers.txt
   python/branches/tlee-ast-optimize/Modules/_testcapimodule.c
   python/branches/tlee-ast-optimize/Modules/arraymodule.c
   python/branches/tlee-ast-optimize/Objects/cellobject.c
   python/branches/tlee-ast-optimize/Objects/codeobject.c
   python/branches/tlee-ast-optimize/Objects/dictobject.c
   python/branches/tlee-ast-optimize/Objects/exceptions.c
   python/branches/tlee-ast-optimize/Objects/fileobject.c
   python/branches/tlee-ast-optimize/Objects/listobject.c
   python/branches/tlee-ast-optimize/Objects/methodobject.c
   python/branches/tlee-ast-optimize/PC/bdist_wininst/install.c
   python/branches/tlee-ast-optimize/PC/bdist_wininst/wininst-7.1.vcproj
   python/branches/tlee-ast-optimize/PC/bdist_wininst/wininst.dsp
   python/branches/tlee-ast-optimize/Python/_warnings.c
   python/branches/tlee-ast-optimize/Python/ast.c
   python/branches/tlee-ast-optimize/Python/bltinmodule.c
   python/branches/tlee-ast-optimize/Python/ceval.c
   python/branches/tlee-ast-optimize/Python/pystrtod.c
   python/branches/tlee-ast-optimize/Python/sysmodule.c
   python/branches/tlee-ast-optimize/Python/traceback.c
   python/branches/tlee-ast-optimize/configure
   python/branches/tlee-ast-optimize/configure.in

Modified: python/branches/tlee-ast-optimize/Doc/c-api/number.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/c-api/number.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/c-api/number.rst	Sun May  4 12:13:28 2008
@@ -290,6 +290,17 @@
    .. versionadded:: 2.5
 
 
+.. cfunction:: PyObject* PyNumber_ToBase(PyObject *n, int base)
+
+   Returns the the integer *n* converted to *base* as a string with a base
+   marker of ``'0b'``, ``'0o'``, or ``'0x'`` if appended applicable.  When
+   *base* is not 2, 8, 10, or 16, the format is ``'x#num'`` where x is the
+   base. If *n* is not an int object, it is converted with
+   :cfunc:`PyNumber_Index` first.
+
+   .. versionadded:: 2.6
+
+
 .. cfunction:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)
 
    Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an

Modified: python/branches/tlee-ast-optimize/Doc/c-api/typeobj.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/c-api/typeobj.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/c-api/typeobj.rst	Sun May  4 12:13:28 2008
@@ -753,11 +753,12 @@
 
 .. cmember:: iternextfunc PyTypeObject.tp_iternext
 
-   An optional pointer to a function that returns the next item in an iterator, or
-   raises :exc:`StopIteration` when the iterator is exhausted.  Its presence
-   normally signals that the instances of this type are iterators (although classic
-   instances always have this function, even if they don't define a :meth:`next`
-   method).
+   An optional pointer to a function that returns the next item in an iterator.
+   When the iterator is exhausted, it must return *NULL*; a :exc:`StopIteration`
+   exception may or may not be set.  When another error occurs, it must return
+   *NULL* too.  Its presence normally signals that the instances of this type
+   are iterators (although classic instances always have this function, even if
+   they don't define a :meth:`next` method).
 
    Iterator types should also define the :attr:`tp_iter` function, and that
    function should return the iterator instance itself (not a new iterator

Modified: python/branches/tlee-ast-optimize/Doc/conf.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/conf.py	(original)
+++ python/branches/tlee-ast-optimize/Doc/conf.py	Sun May  4 12:13:28 2008
@@ -85,6 +85,12 @@
     'index': 'indexcontent.html',
 }
 
+# Output an OpenSearch description file.
+html_use_opensearch = 'http://docs.python.org/dev'
+
+# Additional static files.
+html_static_path = ['tools/sphinxext/static']
+
 # Output file base name for HTML help builder.
 htmlhelp_basename = 'python' + release.replace('.', '')
 

Modified: python/branches/tlee-ast-optimize/Doc/distutils/builtdist.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/distutils/builtdist.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/distutils/builtdist.rst	Sun May  4 12:13:28 2008
@@ -426,6 +426,13 @@
    also the configuration.  For details refer to Microsoft's documentation of the
    :cfunc:`SHGetSpecialFolderPath` function.
 
+Vista User Access Control (UAC)
+===============================
+
+Starting with Python 2.6, bdist_wininst supports a :option:`--user-access-control`
+option.  The default is 'none' (meaning no UAC handling is done), and other
+valid values are 'auto' (meaning prompt for UAC elevation if Python was
+installed for all users) and 'force' (meaning always prompt for elevation)
 
 .. function:: create_shortcut(target, description, filename[, arguments[, workdir[, iconpath[, iconindex]]]])
 
@@ -437,5 +444,3 @@
    and *iconindex* is the index of the icon in the file *iconpath*.  Again, for
    details consult the Microsoft documentation for the :class:`IShellLink`
    interface.
-
-

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	Sun May  4 12:13:28 2008
@@ -70,7 +70,7 @@
 
 .. module:: Carbon.CG
    :platform: Mac
-   :synopsis: Interface to the Component Manager.
+   :synopsis: Interface to Core Graphics.
 
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/decimal.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/decimal.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/decimal.rst	Sun May  4 12:13:28 2008
@@ -100,7 +100,7 @@
 :const:`Overflow`, and :const:`Underflow`.
 
 For each signal there is a flag and a trap enabler.  When a signal is
-encountered, its flag is incremented from zero and, then, if the trap enabler is
+encountered, its flag is set to one, then, if the trap enabler is
 set to one, an exception is raised.  Flags are sticky, so the user needs to
 reset them before monitoring a calculation.
 
@@ -1121,7 +1121,7 @@
 Signals represent conditions that arise during computation. Each corresponds to
 one context flag and one context trap enabler.
 
-The context flag is incremented whenever the condition is encountered. After the
+The context flag is set whenever the condition is encountered. After the
 computation, flags may be checked for informational purposes (for instance, to
 determine whether a computation was exact). After checking the flags, be sure to
 clear all flags before starting the next computation.

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	Sun May  4 12:13:28 2008
@@ -710,6 +710,15 @@
       Added support for the optional *key* argument.
 
 
+.. function:: next(iterator[, default])
+
+   Retrieve the next item from the *iterator* by calling its :meth:`next`
+   method.  If *default* is given, it is returned if the iterator is exhausted,
+   otherwise :exc:`StopIteration` is raised.
+
+   .. versionadded:: 2.6
+
+
 .. function:: object()
 
    Return a new featureless object.  :class:`object` is a base for all new style

Modified: python/branches/tlee-ast-optimize/Doc/library/pyclbr.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/pyclbr.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/pyclbr.rst	Sun May  4 12:13:28 2008
@@ -7,75 +7,75 @@
 .. sectionauthor:: Fred L. Drake, Jr. <fdrake at acm.org>
 
 
-The :mod:`pyclbr` can be used to determine some limited information about the
-classes, methods and top-level functions defined in a module.  The information
-provided is sufficient to implement a traditional three-pane class browser.  The
-information is extracted from the source code rather than by importing the
-module, so this module is safe to use with untrusted source code.  This
-restriction makes it impossible to use this module with modules not implemented
-in Python, including many standard and optional extension modules.
-
-
-.. function:: readmodule(module[, path])
-
-   Read a module and return a dictionary mapping class names to class descriptor
-   objects.  The parameter *module* should be the name of a module as a string;
-   it may be the name of a module within a package.  The *path* parameter should
-   be a sequence, and is used to augment the value of ``sys.path``, which is
-   used to locate module source code.
-
-   .. The 'inpackage' parameter appears to be for internal use only....
-
-
-.. function:: readmodule_ex(module[, path])
-
-   Like :func:`readmodule`, but the returned dictionary, in addition to mapping
-   class names to class descriptor objects, also maps top-level function names to
-   function descriptor objects.  Moreover, if the module being read is a package,
-   the key ``'__path__'`` in the returned dictionary has as its value a list which
-   contains the package search path.
-
-   .. The 'inpackage' parameter appears to be for internal use only....
+The :mod:`pyclbr` module can be used to determine some limited information
+about the classes, methods and top-level functions defined in a module.  The
+information provided is sufficient to implement a traditional three-pane
+class browser.  The information is extracted from the source code rather
+than by importing the module, so this module is safe to use with untrusted
+code.  This restriction makes it impossible to use this module with modules
+not implemented in Python, including all standard and optional extension
+modules.
+
+
+.. function:: readmodule(module[, path=None])
+
+   Read a module and return a dictionary mapping class names to class
+   descriptor objects.  The parameter *module* should be the name of a
+   module as a string; it may be the name of a module within a package.  The
+   *path* parameter should be a sequence, and is used to augment the value
+   of ``sys.path``, which is used to locate module source code.
+
+
+.. function:: readmodule_ex(module[, path=None])
+
+   Like :func:`readmodule`, but the returned dictionary, in addition to
+   mapping class names to class descriptor objects, also maps top-level
+   function names to function descriptor objects.  Moreover, if the module
+   being read is a package, the key ``'__path__'`` in the returned
+   dictionary has as its value a list which contains the package search
+   path.
 
 
 .. _pyclbr-class-objects:
 
-Class Descriptor Objects
-------------------------
+Class Objects
+-------------
 
-The class descriptor objects used as values in the dictionary returned by
-:func:`readmodule` and :func:`readmodule_ex` provide the following data members:
+The :class:`Class` objects used as values in the dictionary returned by
+:func:`readmodule` and :func:`readmodule_ex` provide the following data
+members:
 
 
-.. attribute:: class_descriptor.module
+.. attribute:: Class.module
 
    The name of the module defining the class described by the class descriptor.
 
 
-.. attribute:: class_descriptor.name
+.. attribute:: Class.name
 
    The name of the class.
 
 
-.. attribute:: class_descriptor.super
+.. attribute:: Class.super
 
-   A list of class descriptors which describe the immediate base classes of the
-   class being described.  Classes which are named as superclasses but which are
-   not discoverable by :func:`readmodule` are listed as a string with the class
-   name instead of class descriptors.
+   A list of :class:`Class` objects which describe the immediate base
+   classes of the class being described.  Classes which are named as
+   superclasses but which are not discoverable by :func:`readmodule` are
+   listed as a string with the class name instead of as :class:`Class`
+   objects.
 
 
-.. attribute:: class_descriptor.methods
+.. attribute:: Class.methods
 
    A dictionary mapping method names to line numbers.
 
 
-.. attribute:: class_descriptor.file
+.. attribute:: Class.file
 
    Name of the file containing the ``class`` statement defining the class.
 
 
-.. attribute:: class_descriptor.lineno
+.. attribute:: Class.lineno
 
    The line number of the ``class`` statement within the file named by
    :attr:`file`.
@@ -83,30 +83,31 @@
 
 .. _pyclbr-function-objects:
 
-Function Descriptor Objects
----------------------------
+Function Objects
+----------------
 
-The function descriptor objects used as values in the dictionary returned by
+The :class:`Function` objects used as values in the dictionary returned by
 :func:`readmodule_ex` provide the following data members:
 
 
-.. attribute:: function_descriptor.module
+.. attribute:: Function.module
 
    The name of the module defining the function described by the function
    descriptor.
 
 
-.. attribute:: function_descriptor.name
+.. attribute:: Function.name
 
    The name of the function.
 
 
-.. attribute:: function_descriptor.file
+.. attribute:: Function.file
 
    Name of the file containing the ``def`` statement defining the function.
 
 
-.. attribute:: function_descriptor.lineno
+.. attribute:: Function.lineno
 
-   The line number of the ``def`` statement within the file named by :attr:`file`.
+   The line number of the ``def`` statement within the file named by
+   :attr:`file`.
 

Modified: python/branches/tlee-ast-optimize/Doc/library/robotparser.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/robotparser.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/robotparser.rst	Sun May  4 12:13:28 2008
@@ -3,7 +3,8 @@
 =============================================
 
 .. module:: robotparser
-   :synopsis: Loads a robots.txt file and answers questions about fetchability of other URLs.
+   :synopsis: Loads a robots.txt file and answers questions about
+              fetchability of other URLs.
 .. sectionauthor:: Skip Montanaro <skip at pobox.com>
 
 
@@ -21,8 +22,8 @@
 
 .. class:: RobotFileParser()
 
-   This class provides a set of methods to read, parse and answer questions about a
-   single :file:`robots.txt` file.
+   This class provides a set of methods to read, parse and answer questions
+   about a single :file:`robots.txt` file.
 
 
    .. method:: set_url(url)
@@ -42,20 +43,22 @@
 
    .. method:: can_fetch(useragent, url)
 
-      Returns ``True`` if the *useragent* is allowed to fetch the *url* according to
-      the rules contained in the parsed :file:`robots.txt` file.
+      Returns ``True`` if the *useragent* is allowed to fetch the *url*
+      according to the rules contained in the parsed :file:`robots.txt`
+      file.
 
 
    .. method:: mtime()
 
-      Returns the time the ``robots.txt`` file was last fetched.  This is useful for
-      long-running web spiders that need to check for new ``robots.txt`` files
-      periodically.
+      Returns the time the ``robots.txt`` file was last fetched.  This is
+      useful for long-running web spiders that need to check for new
+      ``robots.txt`` files periodically.
 
 
    .. method:: modified()
 
-      Sets the time the ``robots.txt`` file was last fetched to the current time.
+      Sets the time the ``robots.txt`` file was last fetched to the current
+      time.
 
 The following example demonstrates basic use of the RobotFileParser class. ::
 

Modified: python/branches/tlee-ast-optimize/Doc/library/simplehttpserver.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/simplehttpserver.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/simplehttpserver.rst	Sun May  4 12:13:28 2008
@@ -7,39 +7,40 @@
 .. sectionauthor:: Moshe Zadka <moshez at zadka.site.co.il>
 
 
-The :mod:`SimpleHTTPServer` module defines a request-handler class,
-interface-compatible with :class:`BaseHTTPServer.BaseHTTPRequestHandler`, that
-serves files only from a base directory.
+The :mod:`SimpleHTTPServer` module defines a single class,
+:class:`SimpleHTTPRequestHandler`, which is interface-compatible with
+:class:`BaseHTTPServer.BaseHTTPRequestHandler`.
 
 The :mod:`SimpleHTTPServer` module defines the following class:
 
 
 .. class:: SimpleHTTPRequestHandler(request, client_address, server)
 
-   This class is used to serve files from the current directory and below, directly
+   This class serves files from the current directory and below, directly
    mapping the directory structure to HTTP requests.
 
    A lot of the work, such as parsing the request, is done by the base class
    :class:`BaseHTTPServer.BaseHTTPRequestHandler`.  This class implements the
    :func:`do_GET` and :func:`do_HEAD` functions.
 
-   The :class:`SimpleHTTPRequestHandler` defines the following member variables:
+   The following are defined as class-level attributes of
+   :class:`SimpleHTTPRequestHandler`:
 
 
    .. attribute:: server_version
 
-      This will be ``"SimpleHTTP/" + __version__``, where ``__version__`` is
-      defined in the module.
+   This will be ``"SimpleHTTP/" + __version__``, where ``__version__`` is
+   defined at the module level.
 
 
    .. attribute:: extensions_map
 
-      A dictionary mapping suffixes into MIME types. The default is signified by
-      an empty string, and is considered to be ``application/octet-stream``. The
-      mapping is used case-insensitively, and so should contain only lower-cased
-      keys.
+      A dictionary mapping suffixes into MIME types. The default is
+      signified by an empty string, and is considered to be
+      ``application/octet-stream``. The mapping is used case-insensitively,
+      and so should contain only lower-cased keys.
 
-   The :class:`SimpleHTTPRequestHandler` defines the following methods:
+   The :class:`SimpleHTTPRequestHandler` class defines the following methods:
 
 
    .. method:: do_HEAD()

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	Sun May  4 12:13:28 2008
@@ -808,7 +808,7 @@
    # Echo server program
    import socket
 
-   HOST = ''                 # Symbolic name meaning the local host
+   HOST = ''                 # Symbolic name meaning all available interfaces
    PORT = 50007              # Arbitrary non-privileged port
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((HOST, PORT))

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	Sun May  4 12:13:28 2008
@@ -23,51 +23,53 @@
 no longer contain the process ID; instead a string of six random characters is
 used.
 
-Also, all the user-callable functions now take additional arguments which allow
-direct control over the location and name of temporary files.  It is no longer
-necessary to use the global *tempdir* and *template* variables.  To maintain
-backward compatibility, the argument order is somewhat odd; it is recommended to
-use keyword arguments for clarity.
+Also, all the user-callable functions now take additional arguments which
+allow direct control over the location and name of temporary files.  It is
+no longer necessary to use the global *tempdir* and *template* variables.
+To maintain backward compatibility, the argument order is somewhat odd; it
+is recommended to use keyword arguments for clarity.
 
 The module defines the following user-callable functions:
 
 
-.. function:: TemporaryFile([mode='w+b'[, bufsize=-1[, suffix[, prefix[, dir]]]]])
+.. function:: TemporaryFile([mode='w+b'[, bufsize=-1[, suffix=''[, prefix='tmp'[, dir=None]]]]])
 
-   Return a file-like object that can be used as a temporary storage
-   area.  The file is created using :func:`mkstemp`. It will be destroyed as soon
+   Return a file-like object that can be used as a temporary storage area.
+   The file is created using :func:`mkstemp`. It will be destroyed as soon
    as it is closed (including an implicit close when the object is garbage
-   collected).  Under Unix, the directory entry for the file is removed immediately
-   after the file is created.  Other platforms do not support this; your code
-   should not rely on a temporary file created using this function having or not
-   having a visible name in the file system.
-
-   The *mode* parameter defaults to ``'w+b'`` so that the file created can be read
-   and written without being closed.  Binary mode is used so that it behaves
-   consistently on all platforms without regard for the data that is stored.
-   *bufsize* defaults to ``-1``, meaning that the operating system default is used.
+   collected).  Under Unix, the directory entry for the file is removed
+   immediately after the file is created.  Other platforms do not support
+   this; your code should not rely on a temporary file created using this
+   function having or not having a visible name in the file system.
+
+   The *mode* parameter defaults to ``'w+b'`` so that the file created can
+   be read and written without being closed.  Binary mode is used so that it
+   behaves consistently on all platforms without regard for the data that is
+   stored.  *bufsize* defaults to ``-1``, meaning that the operating system
+   default is used.
 
    The *dir*, *prefix* and *suffix* parameters are passed to :func:`mkstemp`.
 
    The returned object is a true file object on POSIX platforms.  On other
    platforms, it is a file-like object whose :attr:`file` attribute is the
-   underlying true file object. This file-like object can be used in a :keyword:`with`
-   statement, just like a normal file.
+   underlying true file object. This file-like object can be used in a
+   :keyword:`with` statement, just like a normal file.
 
 
-.. function:: NamedTemporaryFile([mode='w+b'[, bufsize=-1[, suffix[, prefix[, dir[, delete]]]]]])
+.. function:: NamedTemporaryFile([mode='w+b'[, bufsize=-1[, suffix=''[, prefix='tmp'[, dir=None[, delete=True]]]]]])
 
-   This function operates exactly as :func:`TemporaryFile` does, except that the
-   file is guaranteed to have a visible name in the file system (on Unix, the
-   directory entry is not unlinked).  That name can be retrieved from the
-   :attr:`name` member of the file object.  Whether the name can be used to open
-   the file a second time, while the named temporary file is still open, varies
-   across platforms (it can be so used on Unix; it cannot on Windows NT or later).
-   If *delete* is true (the default), the file is deleted as soon as it is closed.
-
-   The returned object is always a file-like object whose :attr:`file` attribute
-   is the underlying true file object. This file-like object can be used in a :keyword:`with`
-   statement, just like a normal file.
+   This function operates exactly as :func:`TemporaryFile` does, except that
+   the file is guaranteed to have a visible name in the file system (on
+   Unix, the directory entry is not unlinked).  That name can be retrieved
+   from the :attr:`name` member of the file object.  Whether the name can be
+   used to open the file a second time, while the named temporary file is
+   still open, varies across platforms (it can be so used on Unix; it cannot
+   on Windows NT or later).  If *delete* is true (the default), the file is
+   deleted as soon as it is closed.
+
+   The returned object is always a file-like object whose :attr:`file`
+   attribute is the underlying true file object. This file-like object can
+   be used in a :keyword:`with` statement, just like a normal file.
 
    .. versionadded:: 2.3
 
@@ -75,107 +77,113 @@
       The *delete* parameter.
 
 
-.. function:: SpooledTemporaryFile([max_size=0, [mode='w+b'[, bufsize=-1[, suffix[, prefix[, dir]]]]]])
+.. function:: SpooledTemporaryFile([max_size=0, [mode='w+b'[, bufsize=-1[, suffix=''[, prefix='tmp'[, dir=None]]]]]])
 
-   This function operates exactly as :func:`TemporaryFile` does, except that data
-   is spooled in memory until the file size exceeds *max_size*, or until the file's
-   :func:`fileno` method is called, at which point the contents are written to disk
-   and operation proceeds as with :func:`TemporaryFile`.
+   This function operates exactly as :func:`TemporaryFile` does, except that
+   data is spooled in memory until the file size exceeds *max_size*, or
+   until the file's :func:`fileno` method is called, at which point the
+   contents are written to disk and operation proceeds as with
+   :func:`TemporaryFile`.
 
-   The resulting file has one additional method, :func:`rollover`, which causes the
-   file to roll over to an on-disk file regardless of its size.
+   The resulting file has one additional method, :func:`rollover`, which
+   causes the file to roll over to an on-disk file regardless of its size.
 
    The returned object is a file-like object whose :attr:`_file` attribute
    is either a :class:`StringIO` object or a true file object, depending on
-   whether :func:`rollover` has been called. This file-like object can be used in a
-   :keyword:`with` statement, just like a normal file.
+   whether :func:`rollover` has been called. This file-like object can be
+   used in a :keyword:`with` statement, just like a normal file.
 
    .. versionadded:: 2.6
 
 
-.. function:: mkstemp([suffix[, prefix[, dir[, text]]]])
+.. function:: mkstemp([suffix=''[, prefix='tmp'[, dir=None[, text=False]]]])
 
-   Creates a temporary file in the most secure manner possible.  There are no
-   race conditions in the file's creation, assuming that the platform properly
-   implements the :const:`os.O_EXCL` flag for :func:`os.open`.  The file is
-   readable and writable only by the creating user ID.  If the platform uses
-   permission bits to indicate whether a file is executable, the file is
-   executable by no one.  The file descriptor is not inherited by child
-   processes.
-
-   Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible for
-   deleting the temporary file when done with it.
-
-   If *suffix* is specified, the file name will end with that suffix, otherwise
-   there will be no suffix.  :func:`mkstemp` does not put a dot between the file
-   name and the suffix; if you need one, put it at the beginning of *suffix*.
-
-   If *prefix* is specified, the file name will begin with that prefix; otherwise,
-   a default prefix is used.
-
-   If *dir* is specified, the file will be created in that directory; otherwise,
-   a default directory is used.  The default directory is chosen from a
-   platform-dependent list, but the user of the application can control the
-   directory location by setting the *TMPDIR*, *TEMP* or *TMP* environment
-   variables.  There is thus no guarantee that the generated filename will have
-   any nice properties, such as not requiring quoting when passed to external
-   commands via ``os.popen()``.
-
-   If *text* is specified, it indicates whether to open the file in binary mode
-   (the default) or text mode.  On some platforms, this makes no difference.
-
-   :func:`mkstemp` returns a tuple containing an OS-level handle to an open file
-   (as would be returned by :func:`os.open`) and the absolute pathname of that
-   file, in that order.
+   Creates a temporary file in the most secure manner possible.  There are
+   no race conditions in the file's creation, assuming that the platform
+   properly implements the :const:`os.O_EXCL` flag for :func:`os.open`.  The
+   file is readable and writable only by the creating user ID.  If the
+   platform uses permission bits to indicate whether a file is executable,
+   the file is executable by no one.  The file descriptor is not inherited
+   by child processes.
+
+   Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible
+   for deleting the temporary file when done with it.
+
+   If *suffix* is specified, the file name will end with that suffix,
+   otherwise there will be no suffix.  :func:`mkstemp` does not put a dot
+   between the file name and the suffix; if you need one, put it at the
+   beginning of *suffix*.
+
+   If *prefix* is specified, the file name will begin with that prefix;
+   otherwise, a default prefix is used.
+
+   If *dir* is specified, the file will be created in that directory;
+   otherwise, a default directory is used.  The default directory is chosen
+   from a platform-dependent list, but the user of the application can
+   control the directory location by setting the *TMPDIR*, *TEMP* or *TMP*
+   environment variables.  There is thus no guarantee that the generated
+   filename will have any nice properties, such as not requiring quoting
+   when passed to external commands via ``os.popen()``.
+
+   If *text* is specified, it indicates whether to open the file in binary
+   mode (the default) or text mode.  On some platforms, this makes no
+   difference.
+
+   :func:`mkstemp` returns a tuple containing an OS-level handle to an open
+   file (as would be returned by :func:`os.open`) and the absolute pathname
+   of that file, in that order.
 
    .. versionadded:: 2.3
 
 
-.. function:: mkdtemp([suffix[, prefix[, dir]]])
+.. function:: mkdtemp([suffix=''[, prefix='tmp'[, dir=None]]])
 
-   Creates a temporary directory in the most secure manner possible. There are no
-   race conditions in the directory's creation.  The directory is readable,
-   writable, and searchable only by the creating user ID.
+   Creates a temporary directory in the most secure manner possible. There
+   are no race conditions in the directory's creation.  The directory is
+   readable, writable, and searchable only by the creating user ID.
 
-   The user of :func:`mkdtemp` is responsible for deleting the temporary directory
-   and its contents when done with it.
+   The user of :func:`mkdtemp` is responsible for deleting the temporary
+   directory and its contents when done with it.
 
-   The *prefix*, *suffix*, and *dir* arguments are the same as for :func:`mkstemp`.
+   The *prefix*, *suffix*, and *dir* arguments are the same as for
+   :func:`mkstemp`.
 
    :func:`mkdtemp` returns the absolute pathname of the new directory.
 
    .. versionadded:: 2.3
 
 
-.. function:: mktemp([suffix[, prefix[, dir]]])
+.. function:: mktemp([suffix=''[, prefix='tmp'[, dir=None]]])
 
    .. deprecated:: 2.3
       Use :func:`mkstemp` instead.
 
-   Return an absolute pathname of a file that did not exist at the time the call is
-   made.  The *prefix*, *suffix*, and *dir* arguments are the same as for
-   :func:`mkstemp`.
+   Return an absolute pathname of a file that did not exist at the time the
+   call is made.  The *prefix*, *suffix*, and *dir* arguments are the same
+   as for :func:`mkstemp`.
 
    .. warning::
 
-      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.
-
-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 functions above.
-The caller may change them, but this is discouraged; use the appropriate
-function arguments, instead.
+      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.
+
+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
+functions above.  The caller may change them, but this is discouraged; use
+the appropriate function arguments, instead.
 
 
 .. data:: tempdir
 
-   When set to a value other than ``None``, this variable defines the default value
-   for the *dir* argument to all the functions defined in this module.
-
-   If ``tempdir`` is unset or ``None`` at any call to any of the above functions,
-   Python searches a standard list of directories and sets *tempdir* to the first
-   one which the calling user can create files in.  The list is:
+   When set to a value other than ``None``, this variable defines the
+   default value for the *dir* argument to all the functions defined in this
+   module.
+
+   If ``tempdir`` is unset or ``None`` at any call to any of the above
+   functions, Python searches a standard list of directories and sets
+   *tempdir* to the first one which the calling user can create files in.
+   The list is:
 
    #. The directory named by the :envvar:`TMPDIR` environment variable.
 

Modified: python/branches/tlee-ast-optimize/Doc/tools/sphinxext/indexcontent.html
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tools/sphinxext/indexcontent.html	(original)
+++ python/branches/tlee-ast-optimize/Doc/tools/sphinxext/indexcontent.html	Sun May  4 12:13:28 2008
@@ -3,28 +3,28 @@
   <p><strong>Parts of the documentation:</strong></p>
   <table class="contentstable" align="center"><tr>
     <td width="50%">
-      <p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">What's new in Python {{ version }}?</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">What's new in Python {{ version }}?</a><br/>
          <span class="linkdescr">changes since previous major release</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br/>
          <span class="linkdescr">start here</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Using Python</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Using Python</a><br/>
          <span class="linkdescr">how to use Python on different platforms</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("reference/index") }}">Language Reference</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("reference/index") }}">Language Reference</a><br/>
          <span class="linkdescr">describes syntax and language elements</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("library/index") }}">Library Reference</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("library/index") }}">Library Reference</a><br/>
          <span class="linkdescr">keep this under your pillow</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("howto/index") }}">Python HOWTOs</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("howto/index") }}">Python HOWTOs</a><br/>
          <span class="linkdescr">in-depth documents on specific topics</span></p>
     </td><td width="50%">
-      <p class="biglink"><a class="biglink" href="{{ pathto("extending/index") }}">Extending and Embedding</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("extending/index") }}">Extending and Embedding</a><br/>
          <span class="linkdescr">tutorial for C/C++ programmers</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("c-api/index") }}">Python/C API</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("c-api/index") }}">Python/C API</a><br/>
          <span class="linkdescr">reference for C/C++ programmers</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("install/index") }}">Installing Python Modules</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("install/index") }}">Installing Python Modules</a><br/>
          <span class="linkdescr">information for installers &amp; sys-admins</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("distutils/index") }}">Distributing Python Modules</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("distutils/index") }}">Distributing Python Modules</a><br/>
          <span class="linkdescr">sharing modules with others</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("documenting/index") }}">Documenting Python</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("documenting/index") }}">Documenting Python</a><br/>
          <span class="linkdescr">guide for documentation authors</span></p>
     </td></tr>
   </table>
@@ -32,16 +32,16 @@
   <p><strong>Indices and tables:</strong></p>
   <table class="contentstable" align="center"><tr>
     <td width="50%">
-      <p class="biglink"><a class="biglink" href="{{ pathto("modindex") }}">Global Module Index</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("modindex") }}">Global Module Index</a><br/>
          <span class="linkdescr">quick access to all modules</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">General Index</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">General Index</a><br/>
          <span class="linkdescr">all functions, classes, terms</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("glossary") }}">Glossary</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("glossary") }}">Glossary</a><br/>
          <span class="linkdescr">the most important terms explained</span></p>
     </td><td width="50%">
-      <p class="biglink"><a class="biglink" href="{{ pathto("search") }}">Search page</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("search") }}">Search page</a><br/>
          <span class="linkdescr">search this documentation</span></p>
-      <p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">Complete Table of Contents</a><br>
+      <p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">Complete Table of Contents</a><br/>
          <span class="linkdescr">lists all sections and subsections</span></p>
     </td></tr>
   </table>

Modified: python/branches/tlee-ast-optimize/Doc/using/cmdline.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/using/cmdline.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/using/cmdline.rst	Sun May  4 12:13:28 2008
@@ -28,20 +28,25 @@
     python myscript.py
 
 
+.. _using-on-interface-options:
+
 Interface options
 ~~~~~~~~~~~~~~~~~
 
-The interpreter interface resembles that of the UNIX shell:
+The interpreter interface resembles that of the UNIX shell, but provides some
+additional methods of invocation:
 
 * When called with standard input connected to a tty device, it prompts for
   commands and executes them until an EOF (an end-of-file character, you can
   produce that with *Ctrl-D* on UNIX or *Ctrl-Z, Enter* on Windows) is read.
 * When called with a file name argument or with a file as standard input, it
   reads and executes a script from that file.
+* When called with a directory name argument, it reads and executes an
+  appropriately named script from that directory.
 * When called with ``-c command``, it executes the Python statement(s) given as
   *command*.  Here *command* may contain multiple statements separated by
   newlines. Leading whitespace is significant in Python statements!
-* When called with ``-m module-name``, the given module is searched on the
+* When called with ``-m module-name``, the given module is located on the
   Python module path and executed as a script.
 
 In non-interactive mode, the entire input is parsed before it is executed.
@@ -58,25 +63,31 @@
    normal module code.
    
    If this option is given, the first element of :data:`sys.argv` will be
-   ``"-c"``.
+   ``"-c"`` and the current directory will be added to the start of
+   :data:`sys.path` (allowing modules in that directory to be imported as top
+   level modules).
 
 
 .. cmdoption:: -m <module-name>
 
-   Search :data:`sys.path` for the named module and run the corresponding module
-   file as if it were executed with ``python modulefile.py`` as a script.
+   Search :data:`sys.path` for the named module and execute its contents as
+   the :mod:`__main__` module.
    
    Since the argument is a *module* name, you must not give a file extension
-   (``.py``).  However, the ``module-name`` does not have to be a valid Python
-   identifer (e.g. you can use a file name including a hyphen).
+   (``.py``).  The ``module-name`` should be a valid Python module name, but
+   the implementation may not always enforce this (e.g. it may allow you to
+   use a name that includes a hyphen).
 
    .. note::
 
       This option cannot be used with builtin modules and extension modules
-      written in C, since they do not have Python module files.
+      written in C, since they do not have Python module files. However, it
+      can still be used for precompiled modules, even if the original source
+      file is not available.
    
    If this option is given, the first element of :data:`sys.argv` will be the
-   full path to the module file.
+   full path to the module file. As with the :option:`-c` option, the current
+   directory will be added to the start of :data:`sys.path`.
    
    Many standard library modules contain code that is invoked on their execution
    as a script.  An example is the :mod:`timeit` module::
@@ -90,34 +101,52 @@
 
       :pep:`338` -- Executing modules as scripts
 
+   .. versionadded:: 2.4
+
    .. versionchanged:: 2.5
-      The module name can now include packages.
+      The named module can now be located inside a package.
+
+
+.. describe:: -
+
+   Read commands from standard input (:data:`sys.stdin`).  If standard input is
+   a terminal, :option:`-i` is implied.
+
+   If this option is given, the first element of :data:`sys.argv` will be
+   ``"-"`` and the current directory will be added to the start of
+   :data:`sys.path`.
 
 
 .. describe:: <script>
 
-   Execute the Python code contained in *script*, which must be an (absolute or
-   relative) file name.
+   Execute the Python code contained in *script*, which must be a filesystem
+   path (absolute or relative) referring to either a Python file, a directory
+   containing a ``__main__.py`` file, or a zipfile containing a
+   ``__main__.py`` file.
 
    If this option is given, the first element of :data:`sys.argv` will be the
-   script file name as given on the command line.
+   script name as given on the command line.
 
+   If the script name refers directly to a Python file, the directory
+   containing that file is added to the start of :data:`sys.path`, and the
+   file is executed as the :mod:`__main__` module.
+
+   If the script name refers to a directory or zipfile, the script name is
+   added to the start of :data:`sys.path` and the ``__main__.py`` file in
+   that location is executed as the :mod:`__main__` module.
 
-.. describe:: -
-
-   Read commands from standard input (:data:`sys.stdin`).  If standard input is
-   a terminal, :option:`-i` is implied.
+   .. versionchanged:: 2.5
+      Directories and zipfiles containing a ``__main__.py`` file at the top
+      level are now considered valid Python scripts.
 
-   If this option is given, the first element of :data:`sys.argv` will be
-   ``"-"``.
+If no interface option is given, :option:`-i` is implied, ``sys.argv[0]`` is
+an empty string (``""``) and the current directory will be added to the
+start of :data:`sys.path`.
 
    .. seealso:: 
       :ref:`tut-invoking`
 
 
-If no script name is given, ``sys.argv[0]`` is an empty string (``""``).
-
-
 Generic options
 ~~~~~~~~~~~~~~~
 
@@ -127,7 +156,7 @@
 
    Print a short description of all command line options.
 
-   .. versionadded:: 2.5
+   .. versionchanged:: 2.5
       The ``--help`` variant.
 
 
@@ -138,7 +167,7 @@
     
        Python 2.5.1
 
-   .. versionadded:: 2.5
+   .. versionchanged:: 2.5
       The ``--version`` variant.
 
 
@@ -302,6 +331,7 @@
    thus equivalent to an omitted line number.
 
    .. seealso::
+      :mod:`warnings` -- the warnings module
 
       :pep:`230` -- Warning framework
 
@@ -358,14 +388,19 @@
    the shell's :envvar:`PATH`: one or more directory pathnames separated by
    :data:`os.pathsep` (e.g. colons on Unix or semicolons on Windows).
    Non-existent directories are silently ignored.
+
+   In addition to normal directories, individual :envvar:`PYTHONPATH` entries
+   may refer to zipfiles containing pure Python modules (in either source or
+   compiled form). Extension modules cannot be imported from zipfiles.
    
    The default search path is installation dependent, but generally begins with
    :file:`{prefix}/lib/python{version}`` (see :envvar:`PYTHONHOME` above).  It
    is *always* appended to :envvar:`PYTHONPATH`.
    
-   If a script argument is given, the directory containing the script is
-   inserted in the path in front of :envvar:`PYTHONPATH`.  The search path can
-   be manipulated from within a Python program as the variable :data:`sys.path`.
+   An additional directory will be inserted in the search path in front of
+   :envvar:`PYTHONPATH` as described above under
+   :ref:`using-on-interface-options`. The search path can be manipulated from
+   within a Python program as the variable :data:`sys.path`.
 
 
 .. envvar:: PYTHONSTARTUP
@@ -451,7 +486,7 @@
 
 .. envvar:: PYTHONTHREADDEBUG
 
-   If set, Python will print debug threading debug info.
+   If set, Python will print threading debug info.
 
    .. versionchanged:: 2.6
       Previously, this variable was called ``THREADDEBUG``.

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	Sun May  4 12:13:28 2008
@@ -137,7 +137,7 @@
 <http://www.atlassian.com/software/jira/>`__, 
 `Launchpad <http://www.launchpad.net>`__, 
 `Roundup <http://roundup.sourceforge.net/>`__, and 
-Trac <http://trac.edgewall.org/>`__.  
+`Trac <http://trac.edgewall.org/>`__.  
 The committee eventually settled on Jira
 and Roundup as the two candidates.  Jira is a commercial product that
 offers a no-cost hosted instance to free-software projects; Roundup 
@@ -171,7 +171,7 @@
     Roundup downloads and documentation.
 
 
-New Documentation Format: ReStructuredText Using Sphinx
+New Documentation Format: reStructuredText Using Sphinx
 -----------------------------------------------------------
 
 Since the Python project's inception around 1989, the documentation
@@ -734,7 +734,8 @@
 
 There's also a ``__future__`` import that causes all string literals
 to become Unicode strings.  This means that ``\u`` escape sequences 
-can be used to include Unicode characters.
+can be used to include Unicode characters::
+
 
     from __future__ import unicode_literals
 
@@ -744,6 +745,7 @@
     print len(s)               # 12 Unicode characters
 
 
+
 .. seealso::
 
    :pep:`3112` - Bytes literals in Python 3000
@@ -2158,17 +2160,12 @@
 
 To use the new module, first you must create a TCP connection in the
 usual way and then pass it to the :func:`ssl.wrap_socket` function.
-XXX describe parameters.
-
-XXX Can specify if certificate is required, and obtain certificate info
-by calling getpeercert method.
-
-XXX Certain features require the OpenSSL package to be installed, notably
-  the 'openssl' binary.
+It's possible to specify whether a certificate is required, and to
+obtain certificate info by calling the :meth:`getpeercert` method.
 
 .. seealso::
 
-   SSL module documentation.
+   The documentation for the :mod:`ssl` module.
 
 
 .. ======================================================================

Modified: python/branches/tlee-ast-optimize/Lib/calendar.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/calendar.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/calendar.py	Sun May  4 12:13:28 2008
@@ -5,7 +5,6 @@
 Sunday as the last (the European convention). Use setfirstweekday() to
 set the first day of the week (0=Monday, 6=Sunday)."""
 
-from __future__ import with_statement
 import sys
 import datetime
 import locale as _locale

Modified: python/branches/tlee-ast-optimize/Lib/contextlib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/contextlib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/contextlib.py	Sun May  4 12:13:28 2008
@@ -1,6 +1,7 @@
 """Utilities for with-statement contexts.  See PEP 343."""
 
 import sys
+from functools import wraps
 
 __all__ = ["contextmanager", "nested", "closing"]
 
@@ -77,14 +78,9 @@
             <cleanup>
 
     """
+    @wraps(func)
     def helper(*args, **kwds):
         return GeneratorContextManager(func(*args, **kwds))
-    try:
-        helper.__name__ = func.__name__
-        helper.__doc__ = func.__doc__
-        helper.__dict__ = func.__dict__
-    except:
-        pass
     return helper
 
 

Modified: python/branches/tlee-ast-optimize/Lib/decimal.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/decimal.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/decimal.py	Sun May  4 12:13:28 2008
@@ -477,11 +477,7 @@
                  # General Decimal Arithmetic Specification
              return +s  # Convert result to normal context
 
-    """
-    # The string below can't be included in the docstring until Python 2.6
-    # as the doctest module doesn't understand __future__ statements
-    """
-    >>> from __future__ import with_statement
+    >>> setcontext(DefaultContext)
     >>> print getcontext().prec
     28
     >>> with localcontext():
@@ -1210,7 +1206,7 @@
         return ans
     __rmul__ = __mul__
 
-    def __div__(self, other, context=None):
+    def __truediv__(self, other, context=None):
         """Return self / other."""
         other = _convert_other(other)
         if other is NotImplemented:
@@ -1269,8 +1265,6 @@
         ans = _dec_from_triple(sign, str(coeff), exp)
         return ans._fix(context)
 
-    __truediv__ = __div__
-
     def _divide(self, other, context):
         """Return (self // other, self % other), to context.prec precision.
 
@@ -1304,13 +1298,15 @@
                                    'quotient too large in //, % or divmod')
         return ans, ans
 
-    def __rdiv__(self, other, context=None):
-        """Swaps self/other and returns __div__."""
+    def __rtruediv__(self, other, context=None):
+        """Swaps self/other and returns __truediv__."""
         other = _convert_other(other)
         if other is NotImplemented:
             return other
-        return other.__div__(self, context=context)
-    __rtruediv__ = __rdiv__
+        return other.__truediv__(self, context=context)
+
+    __div__ = __truediv__
+    __rdiv__ = __rtruediv__
 
     def __divmod__(self, other, context=None):
         """
@@ -1510,7 +1506,7 @@
                 context = getcontext()
                 return context._raise_error(InvalidContext)
             elif self._isinfinity():
-                raise OverflowError("Cannot convert infinity to long")
+                raise OverflowError("Cannot convert infinity to int")
         s = (-1)**self._sign
         if self._exp >= 0:
             return s*int(self._int)*10**self._exp
@@ -3597,7 +3593,7 @@
     traps - If traps[exception] = 1, then the exception is
                     raised when it is caused.  Otherwise, a value is
                     substituted in.
-    flags  - When an exception is caused, flags[exception] is incremented.
+    flags  - When an exception is caused, flags[exception] is set.
              (Whether or not the trap_enabler is set)
              Should be reset by user of Decimal instance.
     Emin -   Minimum exponent
@@ -3617,10 +3613,10 @@
         if _ignored_flags is None:
             _ignored_flags = []
         if not isinstance(flags, dict):
-            flags = dict([(s,s in flags) for s in _signals])
+            flags = dict([(s, int(s in flags)) for s in _signals])
             del s
         if traps is not None and not isinstance(traps, dict):
-            traps = dict([(s,s in traps) for s in _signals])
+            traps = dict([(s, int(s in traps)) for s in _signals])
             del s
         for name, val in locals().items():
             if val is None:
@@ -3665,23 +3661,23 @@
         """Handles an error
 
         If the flag is in _ignored_flags, returns the default response.
-        Otherwise, it increments the flag, then, if the corresponding
+        Otherwise, it sets the flag, then, if the corresponding
         trap_enabler is set, it reaises the exception.  Otherwise, it returns
-        the default value after incrementing the flag.
+        the default value after setting the flag.
         """
         error = _condition_map.get(condition, condition)
         if error in self._ignored_flags:
             # Don't touch the flag
             return error().handle(self, *args)
 
-        self.flags[error] += 1
+        self.flags[error] = 1
         if not self.traps[error]:
             # The errors define how to handle themselves.
             return condition().handle(self, *args)
 
         # Errors should only be risked on copies of the context
         # self._ignored_flags = []
-        raise error, explanation
+        raise error(explanation)
 
     def _ignore_all_flags(self):
         """Ignore all flags, if they are raised"""

Modified: python/branches/tlee-ast-optimize/Lib/distutils/command/bdist_wininst.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/command/bdist_wininst.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/command/bdist_wininst.py	Sun May  4 12:13:28 2008
@@ -50,6 +50,10 @@
                      "Fully qualified filename of a script to be run before "
                      "any files are installed.  This script need not be in the "
                      "distribution"),
+                    ('user-access-control=', None,
+                     "specify Vista's UAC handling - 'none'/default=no "
+                     "handling, 'auto'=use UAC if target Python installed for "
+                     "all users, 'force'=always use UAC"),
                    ]
 
     boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize',
@@ -68,6 +72,7 @@
         self.skip_build = 0
         self.install_script = None
         self.pre_install_script = None
+        self.user_access_control = None
 
     # initialize_options()
 
@@ -220,6 +225,8 @@
         lines.append("target_optimize=%d" % (not self.no_target_optimize))
         if self.target_version:
             lines.append("target_version=%s" % self.target_version)
+        if self.user_access_control:
+            lines.append("user_access_control=%s" % self.user_access_control)
 
         title = self.title or self.distribution.get_fullname()
         lines.append("title=%s" % escape(title))

Modified: python/branches/tlee-ast-optimize/Lib/distutils/command/wininst-6.0.exe
==============================================================================
Binary files. No diff available.

Modified: python/branches/tlee-ast-optimize/Lib/distutils/command/wininst-7.1.exe
==============================================================================
Binary files. No diff available.

Modified: python/branches/tlee-ast-optimize/Lib/distutils/command/wininst-9.0-amd64.exe
==============================================================================
Binary files. No diff available.

Modified: python/branches/tlee-ast-optimize/Lib/distutils/command/wininst-9.0.exe
==============================================================================
Binary files. No diff available.

Modified: python/branches/tlee-ast-optimize/Lib/distutils/msvc9compiler.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/msvc9compiler.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/msvc9compiler.py	Sun May  4 12:13:28 2008
@@ -594,14 +594,25 @@
             # needed! Make sure they are generated in the temporary build
             # directory. Since they have different names for debug and release
             # builds, they can go into the same directory.
+            build_temp = os.path.dirname(objects[0])
             if export_symbols is not None:
                 (dll_name, dll_ext) = os.path.splitext(
                     os.path.basename(output_filename))
                 implib_file = os.path.join(
-                    os.path.dirname(objects[0]),
+                    build_temp,
                     self.library_filename(dll_name))
                 ld_args.append ('/IMPLIB:' + implib_file)
 
+            # Embedded manifests are recommended - see MSDN article titled
+            # "How to: Embed a Manifest Inside a C/C++ Application"
+            # (currently at http://msdn2.microsoft.com/en-us/library/ms235591(VS.80).aspx)
+            # Ask the linker to generate the manifest in the temp dir, so
+            # we can embed it later.
+            temp_manifest = os.path.join(
+                    build_temp,
+                    os.path.basename(output_filename) + ".manifest")
+            ld_args.append('/MANIFESTFILE:' + temp_manifest)
+
             if extra_preargs:
                 ld_args[:0] = extra_preargs
             if extra_postargs:
@@ -613,6 +624,18 @@
             except DistutilsExecError as msg:
                 raise LinkError(msg)
 
+            # embed the manifest
+            # XXX - this is somewhat fragile - if mt.exe fails, distutils
+            # will still consider the DLL up-to-date, but it will not have a
+            # manifest.  Maybe we should link to a temp file?  OTOH, that
+            # implies a build environment error that shouldn't go undetected.
+            mfid = 1 if target_desc == CCompiler.EXECUTABLE else 2
+            out_arg = '-outputresource:%s;%s' % (output_filename, mfid)
+            try:
+                self.spawn(['mt.exe', '-nologo', '-manifest',
+                            temp_manifest, out_arg])
+            except DistutilsExecError as msg:
+                raise LinkError(msg)
         else:
             log.debug("skipping %s (up-to-date)", output_filename)
 

Modified: python/branches/tlee-ast-optimize/Lib/idlelib/AutoComplete.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/idlelib/AutoComplete.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/idlelib/AutoComplete.py	Sun May  4 12:13:28 2008
@@ -23,6 +23,10 @@
 # These constants represent the two different types of completions
 COMPLETE_ATTRIBUTES, COMPLETE_FILES = range(1, 2+1)
 
+SEPS = os.sep
+if os.altsep:  # e.g. '/' on Windows...
+    SEPS += os.altsep
+
 class AutoComplete:
 
     menudefs = [
@@ -70,7 +74,7 @@
         if lastchar == ".":
             self._open_completions_later(False, False, False,
                                          COMPLETE_ATTRIBUTES)
-        elif lastchar == os.sep:
+        elif lastchar in SEPS:
             self._open_completions_later(False, False, False,
                                          COMPLETE_FILES)
 
@@ -126,7 +130,7 @@
                 i -= 1
             comp_start = curline[i:j]
             j = i
-            while i and curline[i-1] in FILENAME_CHARS+os.sep:
+            while i and curline[i-1] in FILENAME_CHARS + SEPS:
                 i -= 1
             comp_what = curline[i:j]
         elif hp.is_in_code() and (not mode or mode==COMPLETE_ATTRIBUTES):

Modified: python/branches/tlee-ast-optimize/Lib/idlelib/AutoCompleteWindow.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/idlelib/AutoCompleteWindow.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/idlelib/AutoCompleteWindow.py	Sun May  4 12:13:28 2008
@@ -54,9 +54,9 @@
         self.lastkey_was_tab = False
 
     def _change_start(self, newstart):
+        min_len = min(len(self.start), len(newstart))
         i = 0
-        while i < len(self.start) and i < len(newstart) and \
-              self.start[i] == newstart[i]:
+        while i < min_len and self.start[i] == newstart[i]:
             i += 1
         if i < len(self.start):
             self.widget.delete("%s+%dc" % (self.startindex, i),
@@ -98,13 +98,17 @@
                 i = m + 1
         last = i-1
 
+        if first == last: # only one possible completion
+            return self.completions[first]
+
         # We should return the maximum prefix of first and last
+        first_comp = self.completions[first]
+        last_comp = self.completions[last]
+        min_len = min(len(first_comp), len(last_comp))
         i = len(s)
-        while len(self.completions[first]) > i and \
-              len(self.completions[last]) > i and \
-              self.completions[first][i] == self.completions[last][i]:
+        while i < min_len and first_comp[i] == last_comp[i]:
             i += 1
-        return self.completions[first][:i]
+        return first_comp[:i]
 
     def _selection_changed(self):
         """Should be called when the selection of the Listbox has changed.
@@ -118,8 +122,9 @@
         if self._binary_search(lts) == cursel:
             newstart = lts
         else:
+            min_len = min(len(lts), len(selstart))
             i = 0
-            while i < len(lts) and i < len(selstart) and lts[i] == selstart[i]:
+            while i < min_len and lts[i] == selstart[i]:
                 i += 1
             newstart = selstart[:i]
         self._change_start(newstart)

Modified: python/branches/tlee-ast-optimize/Lib/idlelib/EditorWindow.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/idlelib/EditorWindow.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/idlelib/EditorWindow.py	Sun May  4 12:13:28 2008
@@ -153,6 +153,7 @@
         text.bind("<Right>", self.move_at_edge_if_selection(1))
         text.bind("<<del-word-left>>", self.del_word_left)
         text.bind("<<del-word-right>>", self.del_word_right)
+        text.bind("<<beginning-of-line>>", self.home_callback)
 
         if flist:
             flist.inversedict[self] = key
@@ -281,6 +282,50 @@
         self.flist.new(dirname)
         return "break"
 
+    def home_callback(self, event):
+        if (event.state & 12) != 0 and event.keysym == "Home":
+            # state&1==shift, state&4==control, state&8==alt
+            return # <Modifier-Home>; fall back to class binding
+
+        if self.text.index("iomark") and \
+           self.text.compare("iomark", "<=", "insert lineend") and \
+           self.text.compare("insert linestart", "<=", "iomark"):
+            insertpt = int(self.text.index("iomark").split(".")[1])
+        else:
+            line = self.text.get("insert linestart", "insert lineend")
+            for insertpt in xrange(len(line)):
+                if line[insertpt] not in (' ','\t'):
+                    break
+            else:
+                insertpt=len(line)
+
+        lineat = int(self.text.index("insert").split('.')[1])
+
+        if insertpt == lineat:
+            insertpt = 0
+
+        dest = "insert linestart+"+str(insertpt)+"c"
+
+        if (event.state&1) == 0:
+            # shift not pressed
+            self.text.tag_remove("sel", "1.0", "end")
+        else:
+            if not self.text.index("sel.first"):
+                self.text.mark_set("anchor","insert")
+
+            first = self.text.index(dest)
+            last = self.text.index("anchor")
+
+            if self.text.compare(first,">",last):
+                first,last = last,first
+
+            self.text.tag_remove("sel", "1.0", "end")
+            self.text.tag_add("sel", first, last)
+
+        self.text.mark_set("insert", dest)
+        self.text.see("insert")
+        return "break"
+
     def set_status_bar(self):
         self.status_bar = self.MultiStatusBar(self.top)
         if macosxSupport.runningAsOSXApp():

Modified: python/branches/tlee-ast-optimize/Lib/idlelib/NEWS.txt
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/idlelib/NEWS.txt	(original)
+++ python/branches/tlee-ast-optimize/Lib/idlelib/NEWS.txt	Sun May  4 12:13:28 2008
@@ -6,6 +6,14 @@
 - Issue #2665: On Windows, an IDLE installation upgraded from an old version
   would not start if a custom theme was defined.
 
+- Home / Control-A toggles between left margin and end of leading white
+  space.  Patch 1196903 Jeff Shute.
+
+- Improved AutoCompleteWindow logic.  Patch 2062 Tal Einat.
+
+- Autocompletion of filenames now support alternate separators, e.g. the
+  '/' char on Windows.  Patch 2061 Tal Einat.
+
 What's New in IDLE 2.6a1?
 =========================
 

Modified: python/branches/tlee-ast-optimize/Lib/idlelib/PyShell.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/idlelib/PyShell.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/idlelib/PyShell.py	Sun May  4 12:13:28 2008
@@ -826,7 +826,6 @@
         text.bind("<<newline-and-indent>>", self.enter_callback)
         text.bind("<<plain-newline-and-indent>>", self.linefeed_callback)
         text.bind("<<interrupt-execution>>", self.cancel_callback)
-        text.bind("<<beginning-of-line>>", self.home_callback)
         text.bind("<<end-of-file>>", self.eof_callback)
         text.bind("<<open-stack-viewer>>", self.open_stack_viewer)
         text.bind("<<toggle-debugger>>", self.toggle_debugger)
@@ -1063,16 +1062,6 @@
             self.top.quit()
         return "break"
 
-    def home_callback(self, event):
-        if event.state != 0 and event.keysym == "Home":
-            return # <Modifier-Home>; fall back to class binding
-        if self.text.compare("iomark", "<=", "insert") and \
-           self.text.compare("insert linestart", "<=", "iomark"):
-            self.text.mark_set("insert", "iomark")
-            self.text.tag_remove("sel", "1.0", "end")
-            self.text.see("insert")
-            return "break"
-
     def linefeed_callback(self, event):
         # Insert a linefeed without entering anything (still autoindented)
         if self.reading:

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	Sun May  4 12:13:28 2008
@@ -1528,8 +1528,7 @@
             # nearest "safe start point" before the current location
             # (a point where the decoder has nothing buffered, so seek()
             # can safely start from there and advance to this location).
-            next_byte = bytearray(1)
-            for next_byte[0] in next_input:
+            for next_byte in next_input:
                 bytes_fed += 1
                 chars_decoded += len(decoder.decode(next_byte))
                 dec_buffer, dec_flags = decoder.getstate()

Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py	Sun May  4 12:13:28 2008
@@ -18,6 +18,8 @@
 import difflib
 import optparse
 import logging
+from collections import defaultdict
+from itertools import chain
 
 # Local imports
 from .pgen2 import driver
@@ -96,6 +98,43 @@
     fix_names.sort()
     return fix_names
 
+def get_head_types(pat):
+    """ Accepts a pytree Pattern Node and returns a set
+        of the pattern types which will match first. """
+
+    if isinstance(pat, (pytree.NodePattern, pytree.LeafPattern)):
+        # NodePatters must either have no type and no content
+        #   or a type and content -- so they don't get any farther
+        # Always return leafs
+        return set([pat.type])
+
+    if isinstance(pat, pytree.NegatedPattern):
+        if pat.content:
+            return get_head_types(pat.content)
+        return set([None]) # Negated Patterns don't have a type
+
+    if isinstance(pat, pytree.WildcardPattern):
+        # Recurse on each node in content
+        r = set()
+        for p in pat.content:
+            for x in p:
+                r.update(get_head_types(x))
+        return r
+
+    raise Exception("Oh no! I don't understand pattern %s" %(pat))
+
+def get_headnode_dict(fixer_list):
+    """ Accepts a list of fixers and returns a dictionary
+        of head node type --> fixer list.  """
+    head_nodes = defaultdict(list)
+    for fixer in fixer_list:
+        if not fixer.pattern:
+            head_nodes[None].append(fixer)
+            continue
+        for t in get_head_types(fixer.pattern):
+            head_nodes[t].append(fixer)
+    return head_nodes
+
 
 class RefactoringTool(object):
 
@@ -114,6 +153,10 @@
                                     convert=pytree.convert,
                                     logger=self.logger)
         self.pre_order, self.post_order = self.get_fixers()
+
+        self.pre_order = get_headnode_dict(self.pre_order)
+        self.post_order = get_headnode_dict(self.post_order)
+
         self.files = []  # List of files that were or should be modified
 
     def get_fixers(self):
@@ -286,7 +329,11 @@
         Returns:
             True if the tree was modified, False otherwise.
         """
-        all_fixers = self.pre_order + self.post_order
+        # Two calls to chain are required because pre_order.values()
+        #   will be a list of lists of fixers:
+        #   [[<fixer ...>, <fixer ...>], [<fixer ...>]]
+        all_fixers = chain(chain(*self.pre_order.values()),\
+                           chain(*self.post_order.values()))
         for fixer in all_fixers:
             fixer.start_tree(tree, name)
 
@@ -312,7 +359,7 @@
         if not fixers:
             return
         for node in traversal:
-            for fixer in fixers:
+            for fixer in fixers[node.type] + fixers[None]:
                 results = fixer.match(node)
                 if results:
                     new = fixer.transform(node, results)

Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py	Sun May  4 12:13:28 2008
@@ -33,8 +33,10 @@
         self.fixer_log = []
         self.filename = "<string>"
 
-        for order in (self.refactor.pre_order, self.refactor.post_order):
-            for fixer in order:
+        from itertools import chain
+        for order in (self.refactor.pre_order.values(),\
+                      self.refactor.post_order.values()):
+            for fixer in chain(*order):
                 fixer.log = self.fixer_log
 
     def _check(self, before, after):

Modified: python/branches/tlee-ast-optimize/Lib/plat-mac/Carbon/AppleEvents.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/Carbon/AppleEvents.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/Carbon/AppleEvents.py	Sun May  4 12:13:28 2008
@@ -1,6 +1,7 @@
 # Generated from 'AEDataModel.h'
 
 def FOUR_CHAR_CODE(x): return x
+typeApplicationBundleID = FOUR_CHAR_CODE('bund')
 typeBoolean = FOUR_CHAR_CODE('bool')
 typeChar = FOUR_CHAR_CODE('TEXT')
 typeSInt16 = FOUR_CHAR_CODE('shor')

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	Sun May  4 12:13:28 2008
@@ -1,3 +1,4 @@
+# -coding=latin1-
 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/terminalcommand.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/plat-mac/terminalcommand.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/plat-mac/terminalcommand.py	Sun May  4 12:13:28 2008
@@ -27,7 +27,7 @@
 
 def run(command):
     """Run a shell command in a new Terminal.app window."""
-    termAddress = AE.AECreateDesc(typeApplSignature, TERMINAL_SIG)
+    termAddress = AE.AECreateDesc(typeApplicationBundleID, "com.apple.Terminal")
     theEvent = AE.AECreateAppleEvent(kAECoreSuite, kAEDoScript, termAddress,
                                      kAutoGenerateReturnID, kAnyTransactionID)
     commandDesc = AE.AECreateDesc(typeChar, command)

Modified: python/branches/tlee-ast-optimize/Lib/pyclbr.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/pyclbr.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/pyclbr.py	Sun May  4 12:13:28 2008
@@ -41,8 +41,8 @@
 
 import sys
 import imp
-import tokenize # Python tokenizer
-from token import NAME, DEDENT, NEWLINE, OP
+import tokenize
+from token import NAME, DEDENT, OP
 from operator import itemgetter
 
 __all__ = ["readmodule", "readmodule_ex", "Class", "Function"]
@@ -73,37 +73,37 @@
         self.file = file
         self.lineno = lineno
 
-def readmodule(module, path=[]):
+def readmodule(module, path=None):
     '''Backwards compatible interface.
 
     Call readmodule_ex() and then only keep Class objects from the
     resulting dictionary.'''
 
-    dict = _readmodule(module, path)
     res = {}
-    for key, value in dict.items():
+    for key, value in _readmodule(module, path or []).items():
         if isinstance(value, Class):
             res[key] = value
     return res
 
-def readmodule_ex(module, path=[]):
+def readmodule_ex(module, path=None):
     '''Read a module file and return a dictionary of classes.
 
     Search for MODULE in PATH and sys.path, read and parse the
     module and return a dictionary with one entry for each class
     found in the module.
+    '''
+    return _readmodule(module, path or [])
+
+def _readmodule(module, path, inpackage=None):
+    '''Do the hard work for readmodule[_ex].
 
-    If INPACKAGE is true, it must be the dotted name of the package in
+    If INPACKAGE is given, it must be the dotted name of the package in
     which we are searching for a submodule, and then PATH must be the
     package search path; otherwise, we are searching for a top-level
     module, and PATH is combined with sys.path.
     '''
-    return _readmodule(module, path)
-
-def _readmodule(module, path, inpackage=None):
-    '''Do the hard work for readmodule[_ex].'''
     # Compute the full module name (prepending inpackage if set)
-    if inpackage:
+    if inpackage is not None:
         fullmodule = "%s.%s" % (inpackage, module)
     else:
         fullmodule = module
@@ -116,7 +116,7 @@
     dict = {}
 
     # Check if it is a built-in module; we don't do much for these
-    if module in sys.builtin_module_names and not inpackage:
+    if module in sys.builtin_module_names and inpackage is None:
         _modules[module] = dict
         return dict
 
@@ -126,22 +126,22 @@
         package = module[:i]
         submodule = module[i+1:]
         parent = _readmodule(package, path, inpackage)
-        if inpackage:
+        if inpackage is not None:
             package = "%s.%s" % (inpackage, package)
         return _readmodule(submodule, parent['__path__'], package)
 
     # Search the path for the module
     f = None
-    if inpackage:
-        f, file, (suff, mode, type) = imp.find_module(module, path)
+    if inpackage is not None:
+        f, fname, (_s, _m, ty) = imp.find_module(module, path)
     else:
-        f, file, (suff, mode, type) = imp.find_module(module, path + sys.path)
-    if type == imp.PKG_DIRECTORY:
-        dict['__path__'] = [file]
-        path = [file] + path
-        f, file, (suff, mode, type) = imp.find_module('__init__', [file])
+        f, fname, (_s, _m, ty) = imp.find_module(module, path + sys.path)
+    if ty == imp.PKG_DIRECTORY:
+        dict['__path__'] = [fname]
+        path = [fname] + path
+        f, fname, (_s, _m, ty) = imp.find_module('__init__', [fname])
     _modules[fullmodule] = dict
-    if type != imp.PY_SOURCE:
+    if ty != imp.PY_SOURCE:
         # not Python source, can't do anything with this module
         f.close()
         return dict
@@ -150,7 +150,7 @@
 
     g = tokenize.generate_tokens(f.readline)
     try:
-        for tokentype, token, start, end, line in g:
+        for tokentype, token, start, _end, _line in g:
             if tokentype == DEDENT:
                 lineno, thisindent = start
                 # close nested classes and defs
@@ -161,7 +161,7 @@
                 # close previous nested classes and defs
                 while stack and stack[-1][1] >= thisindent:
                     del stack[-1]
-                tokentype, meth_name, start, end, line = g.next()
+                tokentype, meth_name, start = g.next()[0:3]
                 if tokentype != NAME:
                     continue # Syntax error
                 if stack:
@@ -172,18 +172,19 @@
                     # else it's a nested def
                 else:
                     # it's a function
-                    dict[meth_name] = Function(fullmodule, meth_name, file, lineno)
+                    dict[meth_name] = Function(fullmodule, meth_name,
+                                               fname, lineno)
                 stack.append((None, thisindent)) # Marker for nested fns
             elif token == 'class':
                 lineno, thisindent = start
                 # close previous nested classes and defs
                 while stack and stack[-1][1] >= thisindent:
                     del stack[-1]
-                tokentype, class_name, start, end, line = g.next()
+                tokentype, class_name, start = g.next()[0:3]
                 if tokentype != NAME:
                     continue # Syntax error
                 # parse what follows the class name
-                tokentype, token, start, end, line = g.next()
+                tokentype, token, start = g.next()[0:3]
                 inherit = None
                 if token == '(':
                     names = [] # List of superclasses
@@ -191,7 +192,7 @@
                     level = 1
                     super = [] # Tokens making up current superclass
                     while True:
-                        tokentype, token, start, end, line = g.next()
+                        tokentype, token, start = g.next()[0:3]
                         if token in (')', ',') and level == 1:
                             n = "".join(super)
                             if n in dict:
@@ -224,16 +225,17 @@
                             super.append(token)
                         # expressions in the base list are not supported
                     inherit = names
-                cur_class = Class(fullmodule, class_name, inherit, file, lineno)
+                cur_class = Class(fullmodule, class_name, inherit,
+                                  fname, lineno)
                 if not stack:
                     dict[class_name] = cur_class
                 stack.append((cur_class, thisindent))
             elif token == 'import' and start[1] == 0:
                 modules = _getnamelist(g)
-                for mod, mod2 in modules:
+                for mod, _mod2 in modules:
                     try:
                         # Recursively read the imported module
-                        if not inpackage:
+                        if inpackage is None:
                             _readmodule(mod, path)
                         else:
                             try:
@@ -287,7 +289,7 @@
             name2 = None
         names.append((name, name2))
         while token != "," and "\n" not in token:
-            tokentype, token, start, end, line = g.next()
+            token = g.next()[1]
         if token != ",":
             break
     return names
@@ -297,15 +299,15 @@
     # name is the dotted name, or None if there was no dotted name,
     # and token is the next input token.
     parts = []
-    tokentype, token, start, end, line = g.next()
+    tokentype, token = g.next()[0:2]
     if tokentype != NAME and token != '*':
         return (None, token)
     parts.append(token)
     while True:
-        tokentype, token, start, end, line = g.next()
+        tokentype, token = g.next()[0:2]
         if token != '.':
             break
-        tokentype, token, start, end, line = g.next()
+        tokentype, token = g.next()[0:2]
         if tokentype != NAME:
             break
         parts.append(token)

Modified: python/branches/tlee-ast-optimize/Lib/robotparser.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/robotparser.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/robotparser.py	Sun May  4 12:13:28 2008
@@ -9,15 +9,11 @@
     The robots.txt Exclusion Protocol is implemented as specified in
     http://info.webcrawler.com/mak/projects/robots/norobots-rfc.html
 """
-import urlparse,urllib
+import urlparse
+import urllib
 
 __all__ = ["RobotFileParser"]
 
-debug = 0
-
-def _debug(msg):
-    if debug: print msg
-
 
 class RobotFileParser:
     """ This class provides a set of methods to read, parse and answer
@@ -67,12 +63,9 @@
         self.errcode = opener.errcode
         if self.errcode in (401, 403):
             self.disallow_all = True
-            _debug("disallow all")
         elif self.errcode >= 400:
             self.allow_all = True
-            _debug("allow all")
         elif self.errcode == 200 and lines:
-            _debug("parse lines")
             self.parse(lines)
 
     def _add_entry(self, entry):
@@ -93,19 +86,16 @@
         for line in lines:
             linenumber = linenumber + 1
             if not line:
-                if state==1:
-                    _debug("line %d: warning: you should insert"
-                           " allow: or disallow: directives below any"
-                           " user-agent: line" % linenumber)
+                if state == 1:
                     entry = Entry()
                     state = 0
-                elif state==2:
+                elif state == 2:
                     self._add_entry(entry)
                     entry = Entry()
                     state = 0
             # remove optional comment and strip line
             i = line.find('#')
-            if i>=0:
+            if i >= 0:
                 line = line[:i]
             line = line.strip()
             if not line:
@@ -115,41 +105,24 @@
                 line[0] = line[0].strip().lower()
                 line[1] = urllib.unquote(line[1].strip())
                 if line[0] == "user-agent":
-                    if state==2:
-                        _debug("line %d: warning: you should insert a blank"
-                               " line before any user-agent"
-                               " directive" % linenumber)
+                    if state == 2:
                         self._add_entry(entry)
                         entry = Entry()
                     entry.useragents.append(line[1])
                     state = 1
                 elif line[0] == "disallow":
-                    if state==0:
-                        _debug("line %d: error: you must insert a user-agent:"
-                               " directive before this line" % linenumber)
-                    else:
+                    if state != 0:
                         entry.rulelines.append(RuleLine(line[1], False))
                         state = 2
                 elif line[0] == "allow":
-                    if state==0:
-                        _debug("line %d: error: you must insert a user-agent:"
-                               " directive before this line" % linenumber)
-                    else:
+                    if state != 0:
                         entry.rulelines.append(RuleLine(line[1], True))
-                else:
-                    _debug("line %d: warning: unknown key %s" % (linenumber,
-                               line[0]))
-            else:
-                _debug("line %d: error: malformed line %s"%(linenumber, line))
-        if state==2:
+        if state == 2:
             self.entries.append(entry)
-        _debug("Parsed rules:\n%s" % str(self))
 
 
     def can_fetch(self, useragent, url):
         """using the parsed robots.txt decide if useragent can fetch url"""
-        _debug("Checking robots.txt allowance for:\n  user agent: %s\n  url: %s" %
-               (useragent, url))
         if self.disallow_all:
             return False
         if self.allow_all:
@@ -182,10 +155,10 @@
         self.allowance = allowance
 
     def applies_to(self, filename):
-        return self.path=="*" or filename.startswith(self.path)
+        return self.path == "*" or filename.startswith(self.path)
 
     def __str__(self):
-        return (self.allowance and "Allow" or "Disallow")+": "+self.path
+        return (self.allowance and "Allow" or "Disallow") + ": " + self.path
 
 
 class Entry:
@@ -207,7 +180,7 @@
         # split the name token and make it lower case
         useragent = useragent.split("/")[0].lower()
         for agent in self.useragents:
-            if agent=='*':
+            if agent == '*':
                 # we have the catch-all agent
                 return True
             agent = agent.lower()
@@ -220,7 +193,6 @@
         - our agent applies to this entry
         - filename is URL decoded"""
         for line in self.rulelines:
-            _debug((filename, str(line), line.allowance))
             if line.applies_to(filename):
                 return line.allowance
         return True
@@ -239,56 +211,3 @@
         self.errcode = errcode
         return urllib.FancyURLopener.http_error_default(self, url, fp, errcode,
                                                         errmsg, headers)
-
-def _check(a,b):
-    if not b:
-        ac = "access denied"
-    else:
-        ac = "access allowed"
-    if a!=b:
-        print "failed"
-    else:
-        print "ok (%s)" % ac
-    print
-
-def _test():
-    global debug
-    rp = RobotFileParser()
-    debug = 1
-
-    # robots.txt that exists, gotten to by redirection
-    rp.set_url('http://www.musi-cal.com/robots.txt')
-    rp.read()
-
-    # test for re.escape
-    _check(rp.can_fetch('*', 'http://www.musi-cal.com/'), 1)
-    # this should match the first rule, which is a disallow
-    _check(rp.can_fetch('', 'http://www.musi-cal.com/'), 0)
-    # various cherry pickers
-    _check(rp.can_fetch('CherryPickerSE',
-                       'http://www.musi-cal.com/cgi-bin/event-search'
-                       '?city=San+Francisco'), 0)
-    _check(rp.can_fetch('CherryPickerSE/1.0',
-                       'http://www.musi-cal.com/cgi-bin/event-search'
-                       '?city=San+Francisco'), 0)
-    _check(rp.can_fetch('CherryPickerSE/1.5',
-                       'http://www.musi-cal.com/cgi-bin/event-search'
-                       '?city=San+Francisco'), 0)
-    # case sensitivity
-    _check(rp.can_fetch('ExtractorPro', 'http://www.musi-cal.com/blubba'), 0)
-    _check(rp.can_fetch('extractorpro', 'http://www.musi-cal.com/blubba'), 0)
-    # substring test
-    _check(rp.can_fetch('toolpak/1.1', 'http://www.musi-cal.com/blubba'), 0)
-    # tests for catch-all * agent
-    _check(rp.can_fetch('spam', 'http://www.musi-cal.com/search'), 0)
-    _check(rp.can_fetch('spam', 'http://www.musi-cal.com/Musician/me'), 1)
-    _check(rp.can_fetch('spam', 'http://www.musi-cal.com/'), 1)
-    _check(rp.can_fetch('spam', 'http://www.musi-cal.com/'), 1)
-
-    # robots.txt that does not exist
-    rp.set_url('http://www.lycos.com/robots.txt')
-    rp.read()
-    _check(rp.can_fetch('Mozilla', 'http://www.lycos.com/search'), 1)
-
-if __name__ == '__main__':
-    _test()

Modified: python/branches/tlee-ast-optimize/Lib/socket.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/socket.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/socket.py	Sun May  4 12:13:28 2008
@@ -79,6 +79,11 @@
 import os, sys, warnings
 
 try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
+
+try:
     from errno import EBADF
 except ImportError:
     EBADF = 9
@@ -234,6 +239,9 @@
             bufsize = self.default_bufsize
         self.bufsize = bufsize
         self.softspace = False
+        # _rbufsize is the suggested recv buffer size.  It is *strictly*
+        # obeyed within readline() for recv calls.  If it is larger than
+        # default_bufsize it will be used for recv calls within read().
         if bufsize == 0:
             self._rbufsize = 1
         elif bufsize == 1:
@@ -241,7 +249,11 @@
         else:
             self._rbufsize = bufsize
         self._wbufsize = bufsize
-        self._rbuf = "" # A string
+        # We use StringIO for the read buffer to avoid holding a list
+        # of variously sized string objects which have been known to
+        # fragment the heap due to how they are malloc()ed and often
+        # realloc()ed down much smaller than their original allocation.
+        self._rbuf = StringIO()
         self._wbuf = [] # A list of strings
         self._close = close
 
@@ -299,56 +311,86 @@
         return buf_len
 
     def read(self, size=-1):
-        data = self._rbuf
+        # Use max, disallow tiny reads in a loop as they are very inefficient.
+        # We never leave read() with any leftover data in our internal buffer.
+        rbufsize = max(self._rbufsize, self.default_bufsize)
+        # Our use of StringIO rather than lists of string objects returned by
+        # recv() minimizes memory usage and fragmentation that occurs when
+        # rbufsize is large compared to the typical return value of recv().
+        buf = self._rbuf
+        buf.seek(0, 2)  # seek end
         if size < 0:
             # Read until EOF
-            buffers = []
-            if data:
-                buffers.append(data)
-            self._rbuf = ""
-            if self._rbufsize <= 1:
-                recv_size = self.default_bufsize
-            else:
-                recv_size = self._rbufsize
+            self._rbuf = StringIO()  # reset _rbuf.  we consume it via buf.
             while True:
-                data = self._sock.recv(recv_size)
+                data = self._sock.recv(rbufsize)
                 if not data:
                     break
-                buffers.append(data)
-            return "".join(buffers)
+                buf.write(data)
+            return buf.getvalue()
         else:
             # Read until size bytes or EOF seen, whichever comes first
-            buf_len = len(data)
+            buf_len = buf.tell()
             if buf_len >= size:
-                self._rbuf = data[size:]
-                return data[:size]
-            buffers = []
-            if data:
-                buffers.append(data)
-            self._rbuf = ""
+                # Already have size bytes in our buffer?  Extract and return.
+                buf.seek(0)
+                rv = buf.read(size)
+                self._rbuf = StringIO()
+                self._rbuf.write(buf.read())
+                return rv
+
+            self._rbuf = StringIO()  # reset _rbuf.  we consume it via buf.
             while True:
                 left = size - buf_len
-                recv_size = min(self._rbufsize, left)
+                # Using max() here means that recv() can malloc a
+                # large amount of memory even though recv may return
+                # much less data than that.  But the returned data
+                # string is short lived in that case as we copy it
+                # into a StringIO and free it.
+                recv_size = max(rbufsize, left)
                 data = self._sock.recv(recv_size)
                 if not data:
                     break
-                buffers.append(data)
                 n = len(data)
+                if n == size and not buf_len:
+                    # Shortcut.  Avoid buffer data copies when:
+                    # - We have no data in our buffer.
+                    # AND
+                    # - Our call to recv returned exactly the
+                    #   number of bytes we were asked to read.
+                    return data
                 if n >= left:
-                    self._rbuf = data[left:]
-                    buffers[-1] = data[:left]
+                    # avoids data copy of: buf.write(data[:left])
+                    buf.write(buffer(data, 0, left))
+                    # avoids data copy of: self._rbuf.write(data[left:])
+                    self._rbuf.write(buffer(data, left))
+                    del data  # explicit free
                     break
+                buf.write(data)
                 buf_len += n
-            return "".join(buffers)
+                del data  # explicit free
+                #assert buf_len == buf.tell()
+            return buf.getvalue()
 
     def readline(self, size=-1):
-        data = self._rbuf
+        buf = self._rbuf
+        if self._rbufsize > 1:
+            # if we're buffering, check if we already have it in our buffer
+            buf.seek(0)
+            bline = buf.readline(size)
+            if bline.endswith('\n') or len(bline) == size:
+                self._rbuf = StringIO()
+                self._rbuf.write(buf.read())
+                return bline
+            del bline
+        buf.seek(0, 2)  # seek end
         if size < 0:
             # Read until \n or EOF, whichever comes first
             if self._rbufsize <= 1:
                 # Speed up unbuffered case
-                assert data == ""
+                assert buf.tell() == 0
                 buffers = []
+                data = None
                 recv = self._sock.recv
                 while data != "\n":
                     data = recv(1)
@@ -356,61 +398,64 @@
                         break
                     buffers.append(data)
                 return "".join(buffers)
-            nl = data.find('\n')
-            if nl >= 0:
-                nl += 1
-                self._rbuf = data[nl:]
-                return data[:nl]
-            buffers = []
-            if data:
-                buffers.append(data)
-            self._rbuf = ""
+
+            buf = self._rbuf
+            buf.seek(0, 2)  # seek end
+            self._rbuf = StringIO()  # reset _rbuf.  we consume it via buf.
             while True:
                 data = self._sock.recv(self._rbufsize)
                 if not data:
                     break
-                buffers.append(data)
                 nl = data.find('\n')
                 if nl >= 0:
                     nl += 1
-                    self._rbuf = data[nl:]
-                    buffers[-1] = data[:nl]
+                    buf.write(buffer(data, 0, nl))
+                    self._rbuf.write(buffer(data, nl))
+                    del data
                     break
-            return "".join(buffers)
+                buf.write(data)
+            return buf.getvalue()
         else:
             # Read until size bytes or \n or EOF seen, whichever comes first
-            nl = data.find('\n', 0, size)
-            if nl >= 0:
-                nl += 1
-                self._rbuf = data[nl:]
-                return data[:nl]
-            buf_len = len(data)
+            buf_len = buf.tell()
             if buf_len >= size:
-                self._rbuf = data[size:]
-                return data[:size]
-            buffers = []
-            if data:
-                buffers.append(data)
-            self._rbuf = ""
+                buf.seek(0)
+                rv = buf.read(size)
+                self._rbuf = StringIO()
+                self._rbuf.write(buf.read())
+                return rv
+            self._rbuf = StringIO()  # reset _rbuf.  we consume it via buf.
             while True:
                 data = self._sock.recv(self._rbufsize)
                 if not data:
                     break
-                buffers.append(data)
                 left = size - buf_len
+                # did we just receive a newline?
                 nl = data.find('\n', 0, left)
                 if nl >= 0:
                     nl += 1
-                    self._rbuf = data[nl:]
-                    buffers[-1] = data[:nl]
-                    break
+                    # save the excess data to _rbuf
+                    self._rbuf.write(buffer(data, nl))
+                    if buf_len:
+                        buf.write(buffer(data, 0, nl))
+                        break
+                    else:
+                        # Shortcut.  Avoid data copy through buf when returning
+                        # a substring of our first recv().
+                        return data[:nl]
                 n = len(data)
+                if n == size and not buf_len:
+                    # Shortcut.  Avoid data copy through buf when
+                    # returning exactly all of our first recv().
+                    return data
                 if n >= left:
-                    self._rbuf = data[left:]
-                    buffers[-1] = data[:left]
+                    buf.write(buffer(data, 0, left))
+                    self._rbuf.write(buffer(data, left))
                     break
+                buf.write(data)
                 buf_len += n
-            return "".join(buffers)
+                #assert buf_len == buf.tell()
+            return buf.getvalue()
 
     def readlines(self, sizehint=0):
         total = 0

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	Sun May  4 12:13:28 2008
@@ -39,7 +39,7 @@
 
 try:
     from cStringIO import StringIO as _StringIO
-except:
+except ImportError:
     from StringIO import StringIO as _StringIO
 
 try:
@@ -82,8 +82,6 @@
 
 template = "tmp"
 
-tempdir = None
-
 # Internal routines.
 
 _once_lock = _allocate_lock()
@@ -259,7 +257,7 @@
 tempdir = None
 
 def gettempdir():
-    """Accessor for tempdir.tempdir."""
+    """Accessor for tempfile.tempdir."""
     global tempdir
     if tempdir is None:
         _once_lock.acquire()
@@ -271,8 +269,7 @@
     return tempdir
 
 def mkstemp(suffix="", prefix=template, dir=None, text=False):
-    """mkstemp([suffix, [prefix, [dir, [text]]]])
-    User-callable function to create and return a unique temporary
+    """User-callable function to create and return a unique temporary
     file.  The return value is a pair (fd, name) where fd is the
     file descriptor returned by os.open, and name is the filename.
 
@@ -309,8 +306,7 @@
 
 
 def mkdtemp(suffix="", prefix=template, dir=None):
-    """mkdtemp([suffix, [prefix, [dir]]])
-    User-callable function to create and return a unique temporary
+    """User-callable function to create and return a unique temporary
     directory.  The return value is the pathname of the directory.
 
     Arguments are as for mkstemp, except that the 'text' argument is
@@ -341,8 +337,7 @@
     raise IOError, (_errno.EEXIST, "No usable temporary directory name found")
 
 def mktemp(suffix="", prefix=template, dir=None):
-    """mktemp([suffix, [prefix, [dir]]])
-    User-callable function to return a unique temporary file name.  The
+    """User-callable function to return a unique temporary file name.  The
     file is not created.
 
     Arguments are as for mkstemp, except that the 'text' argument is

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	Sun May  4 12:13:28 2008
@@ -53,45 +53,6 @@
     def write(self, line):
         pass
 
-L = [
-        ('0', 0),
-        ('1', 1),
-        ('9', 9),
-        ('10', 10),
-        ('99', 99),
-        ('100', 100),
-        ('314', 314),
-        (' 314', 314),
-        ('314 ', 314),
-        ('  \t\t  314  \t\t  ', 314),
-        (repr(sys.maxint), sys.maxint),
-        ('  1x', ValueError),
-        ('  1  ', 1),
-        ('  1\02  ', ValueError),
-        ('', ValueError),
-        (' ', ValueError),
-        ('  \t\t  ', ValueError)
-]
-if have_unicode:
-    L += [
-        (unicode('0'), 0),
-        (unicode('1'), 1),
-        (unicode('9'), 9),
-        (unicode('10'), 10),
-        (unicode('99'), 99),
-        (unicode('100'), 100),
-        (unicode('314'), 314),
-        (unicode(' 314'), 314),
-        (unicode('\u0663\u0661\u0664 ','raw-unicode-escape'), 314),
-        (unicode('  \t\t  314  \t\t  '), 314),
-        (unicode('  1x'), ValueError),
-        (unicode('  1  '), 1),
-        (unicode('  1\02  '), ValueError),
-        (unicode(''), ValueError),
-        (unicode(' '), ValueError),
-        (unicode('  \t\t  '), ValueError),
-        (unichr(0x200), ValueError),
-]
 
 class TestFailingBool:
     def __nonzero__(self):
@@ -612,115 +573,6 @@
                     self.assertEqual(outp, exp)
                     self.assert_(not isinstance(outp, cls))
 
-    def test_float(self):
-        self.assertEqual(float(3.14), 3.14)
-        self.assertEqual(float(314), 314.0)
-        self.assertEqual(float(314L), 314.0)
-        self.assertEqual(float("  3.14  "), 3.14)
-        self.assertRaises(ValueError, float, "  0x3.1  ")
-        self.assertRaises(ValueError, float, "  -0x3.p-1  ")
-        self.assertRaises(ValueError, float, "  +0x3.p-1  ")
-        self.assertRaises(ValueError, float, "++3.14")
-        self.assertRaises(ValueError, float, "+-3.14")
-        self.assertRaises(ValueError, float, "-+3.14")
-        self.assertRaises(ValueError, float, "--3.14")
-        if have_unicode:
-            self.assertEqual(float(unicode("  3.14  ")), 3.14)
-            self.assertEqual(float(unicode("  \u0663.\u0661\u0664  ",'raw-unicode-escape')), 3.14)
-            # Implementation limitation in PyFloat_FromString()
-            self.assertRaises(ValueError, float, unicode("1"*10000))
-
-    @run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
-    def test_float_with_comma(self):
-        # set locale to something that doesn't use '.' for the decimal point
-        # float must not accept the locale specific decimal point but
-        # it still has to accept the normal python syntac
-        import locale
-        if not locale.localeconv()['decimal_point'] == ',':
-            return
-
-        self.assertEqual(float("  3.14  "), 3.14)
-        self.assertEqual(float("+3.14  "), 3.14)
-        self.assertEqual(float("-3.14  "), -3.14)
-        self.assertEqual(float(".14  "), .14)
-        self.assertEqual(float("3.  "), 3.0)
-        self.assertEqual(float("3.e3  "), 3000.0)
-        self.assertEqual(float("3.2e3  "), 3200.0)
-        self.assertEqual(float("2.5e-1  "), 0.25)
-        self.assertEqual(float("5e-1"), 0.5)
-        self.assertRaises(ValueError, float, "  3,14  ")
-        self.assertRaises(ValueError, float, "  +3,14  ")
-        self.assertRaises(ValueError, float, "  -3,14  ")
-        self.assertRaises(ValueError, float, "  0x3.1  ")
-        self.assertRaises(ValueError, float, "  -0x3.p-1  ")
-        self.assertRaises(ValueError, float, "  +0x3.p-1  ")
-        self.assertEqual(float("  25.e-1  "), 2.5)
-        self.assertEqual(fcmp(float("  .25e-1  "), .025), 0)
-
-    def test_floatconversion(self):
-        # Make sure that calls to __float__() work properly
-        class Foo0:
-            def __float__(self):
-                return 42.
-
-        class Foo1(object):
-            def __float__(self):
-                return 42.
-
-        class Foo2(float):
-            def __float__(self):
-                return 42.
-
-        class Foo3(float):
-            def __new__(cls, value=0.):
-                return float.__new__(cls, 2*value)
-
-            def __float__(self):
-                return self
-
-        class Foo4(float):
-            def __float__(self):
-                return 42
-
-        self.assertAlmostEqual(float(Foo0()), 42.)
-        self.assertAlmostEqual(float(Foo1()), 42.)
-        self.assertAlmostEqual(float(Foo2()), 42.)
-        self.assertAlmostEqual(float(Foo3(21)), 42.)
-        self.assertRaises(TypeError, float, Foo4(42))
-
-    def test_floatasratio(self):
-        for f, ratio in [
-                (0.875, (7, 8)),
-                (-0.875, (-7, 8)),
-                (0.0, (0, 1)),
-                (11.5, (23, 2)),
-            ]:
-            self.assertEqual(f.as_integer_ratio(), ratio)
-
-        for i in range(10000):
-            f = random.random()
-            f *= 10 ** random.randint(-100, 100)
-            n, d = f.as_integer_ratio()
-            self.assertEqual(float(n).__truediv__(d), f)
-
-        R = fractions.Fraction
-        self.assertEqual(R(0, 1),
-                         R(*float(0.0).as_integer_ratio()))
-        self.assertEqual(R(5, 2),
-                         R(*float(2.5).as_integer_ratio()))
-        self.assertEqual(R(1, 2),
-                         R(*float(0.5).as_integer_ratio()))
-        self.assertEqual(R(4728779608739021, 2251799813685248),
-                         R(*float(2.1).as_integer_ratio()))
-        self.assertEqual(R(-4728779608739021, 2251799813685248),
-                         R(*float(-2.1).as_integer_ratio()))
-        self.assertEqual(R(-2100, 1),
-                         R(*float(-2100.0).as_integer_ratio()))
-
-        self.assertRaises(OverflowError, float('inf').as_integer_ratio)
-        self.assertRaises(OverflowError, float('-inf').as_integer_ratio)
-        self.assertRaises(ValueError, float('nan').as_integer_ratio)
-
     def test_getattr(self):
         import sys
         self.assert_(getattr(sys, 'stdout') is sys.stdout)
@@ -782,285 +634,6 @@
 
     # Test input() later, together with raw_input
 
-    def test_int(self):
-        self.assertEqual(int(314), 314)
-        self.assertEqual(int(3.14), 3)
-        self.assertEqual(int(314L), 314)
-        # Check that conversion from float truncates towards zero
-        self.assertEqual(int(-3.14), -3)
-        self.assertEqual(int(3.9), 3)
-        self.assertEqual(int(-3.9), -3)
-        self.assertEqual(int(3.5), 3)
-        self.assertEqual(int(-3.5), -3)
-        # Different base:
-        self.assertEqual(int("10",16), 16L)
-        if have_unicode:
-            self.assertEqual(int(unicode("10"),16), 16L)
-        # Test conversion from strings and various anomalies
-        for s, v in L:
-            for sign in "", "+", "-":
-                for prefix in "", " ", "\t", "  \t\t  ":
-                    ss = prefix + sign + s
-                    vv = v
-                    if sign == "-" and v is not ValueError:
-                        vv = -v
-                    try:
-                        self.assertEqual(int(ss), vv)
-                    except v:
-                        pass
-
-        s = repr(-1-sys.maxint)
-        x = int(s)
-        self.assertEqual(x+1, -sys.maxint)
-        self.assert_(isinstance(x, int))
-        # should return long
-        self.assertEqual(int(s[1:]), sys.maxint+1)
-
-        # should return long
-        x = int(1e100)
-        self.assert_(isinstance(x, long))
-        x = int(-1e100)
-        self.assert_(isinstance(x, long))
-
-
-        # SF bug 434186:  0x80000000/2 != 0x80000000>>1.
-        # Worked by accident in Windows release build, but failed in debug build.
-        # Failed in all Linux builds.
-        x = -1-sys.maxint
-        self.assertEqual(x >> 1, x//2)
-
-        self.assertRaises(ValueError, int, '123\0')
-        self.assertRaises(ValueError, int, '53', 40)
-
-        # SF bug 1545497: embedded NULs were not detected with
-        # explicit base
-        self.assertRaises(ValueError, int, '123\0', 10)
-        self.assertRaises(ValueError, int, '123\x00 245', 20)
-
-        x = int('1' * 600)
-        self.assert_(isinstance(x, long))
-
-        if have_unicode:
-            x = int(unichr(0x661) * 600)
-            self.assert_(isinstance(x, long))
-
-        self.assertRaises(TypeError, int, 1, 12)
-
-        self.assertEqual(int('0123', 0), 83)
-        self.assertEqual(int('0x123', 16), 291)
-
-        # Bug 1679: "0x" is not a valid hex literal
-        self.assertRaises(ValueError, int, "0x", 16)
-        self.assertRaises(ValueError, int, "0x", 0)
-
-        self.assertRaises(ValueError, int, "0o", 8)
-        self.assertRaises(ValueError, int, "0o", 0)
-
-        self.assertRaises(ValueError, int, "0b", 2)
-        self.assertRaises(ValueError, int, "0b", 0)
-
-
-        # SF bug 1334662: int(string, base) wrong answers
-        # Various representations of 2**32 evaluated to 0
-        # rather than 2**32 in previous versions
-
-        self.assertEqual(int('100000000000000000000000000000000', 2), 4294967296L)
-        self.assertEqual(int('102002022201221111211', 3), 4294967296L)
-        self.assertEqual(int('10000000000000000', 4), 4294967296L)
-        self.assertEqual(int('32244002423141', 5), 4294967296L)
-        self.assertEqual(int('1550104015504', 6), 4294967296L)
-        self.assertEqual(int('211301422354', 7), 4294967296L)
-        self.assertEqual(int('40000000000', 8), 4294967296L)
-        self.assertEqual(int('12068657454', 9), 4294967296L)
-        self.assertEqual(int('4294967296', 10), 4294967296L)
-        self.assertEqual(int('1904440554', 11), 4294967296L)
-        self.assertEqual(int('9ba461594', 12), 4294967296L)
-        self.assertEqual(int('535a79889', 13), 4294967296L)
-        self.assertEqual(int('2ca5b7464', 14), 4294967296L)
-        self.assertEqual(int('1a20dcd81', 15), 4294967296L)
-        self.assertEqual(int('100000000', 16), 4294967296L)
-        self.assertEqual(int('a7ffda91', 17), 4294967296L)
-        self.assertEqual(int('704he7g4', 18), 4294967296L)
-        self.assertEqual(int('4f5aff66', 19), 4294967296L)
-        self.assertEqual(int('3723ai4g', 20), 4294967296L)
-        self.assertEqual(int('281d55i4', 21), 4294967296L)
-        self.assertEqual(int('1fj8b184', 22), 4294967296L)
-        self.assertEqual(int('1606k7ic', 23), 4294967296L)
-        self.assertEqual(int('mb994ag', 24), 4294967296L)
-        self.assertEqual(int('hek2mgl', 25), 4294967296L)
-        self.assertEqual(int('dnchbnm', 26), 4294967296L)
-        self.assertEqual(int('b28jpdm', 27), 4294967296L)
-        self.assertEqual(int('8pfgih4', 28), 4294967296L)
-        self.assertEqual(int('76beigg', 29), 4294967296L)
-        self.assertEqual(int('5qmcpqg', 30), 4294967296L)
-        self.assertEqual(int('4q0jto4', 31), 4294967296L)
-        self.assertEqual(int('4000000', 32), 4294967296L)
-        self.assertEqual(int('3aokq94', 33), 4294967296L)
-        self.assertEqual(int('2qhxjli', 34), 4294967296L)
-        self.assertEqual(int('2br45qb', 35), 4294967296L)
-        self.assertEqual(int('1z141z4', 36), 4294967296L)
-
-        # tests with base 0
-        # this fails on 3.0, but in 2.x the old octal syntax is allowed
-        self.assertEqual(int(' 0123  ', 0), 83)
-        self.assertEqual(int(' 0123  ', 0), 83)
-        self.assertEqual(int('000', 0), 0)
-        self.assertEqual(int('0o123', 0), 83)
-        self.assertEqual(int('0x123', 0), 291)
-        self.assertEqual(int('0b100', 0), 4)
-        self.assertEqual(int(' 0O123   ', 0), 83)
-        self.assertEqual(int(' 0X123  ', 0), 291)
-        self.assertEqual(int(' 0B100 ', 0), 4)
-
-        # without base still base 10
-        self.assertEqual(int('0123'), 123)
-        self.assertEqual(int('0123', 10), 123)
-
-        # tests with prefix and base != 0
-        self.assertEqual(int('0x123', 16), 291)
-        self.assertEqual(int('0o123', 8), 83)
-        self.assertEqual(int('0b100', 2), 4)
-        self.assertEqual(int('0X123', 16), 291)
-        self.assertEqual(int('0O123', 8), 83)
-        self.assertEqual(int('0B100', 2), 4)
-
-        # the code has special checks for the first character after the
-        #  type prefix
-        self.assertRaises(ValueError, int, '0b2', 2)
-        self.assertRaises(ValueError, int, '0b02', 2)
-        self.assertRaises(ValueError, int, '0B2', 2)
-        self.assertRaises(ValueError, int, '0B02', 2)
-        self.assertRaises(ValueError, int, '0o8', 8)
-        self.assertRaises(ValueError, int, '0o08', 8)
-        self.assertRaises(ValueError, int, '0O8', 8)
-        self.assertRaises(ValueError, int, '0O08', 8)
-        self.assertRaises(ValueError, int, '0xg', 16)
-        self.assertRaises(ValueError, int, '0x0g', 16)
-        self.assertRaises(ValueError, int, '0Xg', 16)
-        self.assertRaises(ValueError, int, '0X0g', 16)
-
-        # SF bug 1334662: int(string, base) wrong answers
-        # Checks for proper evaluation of 2**32 + 1
-        self.assertEqual(int('100000000000000000000000000000001', 2), 4294967297L)
-        self.assertEqual(int('102002022201221111212', 3), 4294967297L)
-        self.assertEqual(int('10000000000000001', 4), 4294967297L)
-        self.assertEqual(int('32244002423142', 5), 4294967297L)
-        self.assertEqual(int('1550104015505', 6), 4294967297L)
-        self.assertEqual(int('211301422355', 7), 4294967297L)
-        self.assertEqual(int('40000000001', 8), 4294967297L)
-        self.assertEqual(int('12068657455', 9), 4294967297L)
-        self.assertEqual(int('4294967297', 10), 4294967297L)
-        self.assertEqual(int('1904440555', 11), 4294967297L)
-        self.assertEqual(int('9ba461595', 12), 4294967297L)
-        self.assertEqual(int('535a7988a', 13), 4294967297L)
-        self.assertEqual(int('2ca5b7465', 14), 4294967297L)
-        self.assertEqual(int('1a20dcd82', 15), 4294967297L)
-        self.assertEqual(int('100000001', 16), 4294967297L)
-        self.assertEqual(int('a7ffda92', 17), 4294967297L)
-        self.assertEqual(int('704he7g5', 18), 4294967297L)
-        self.assertEqual(int('4f5aff67', 19), 4294967297L)
-        self.assertEqual(int('3723ai4h', 20), 4294967297L)
-        self.assertEqual(int('281d55i5', 21), 4294967297L)
-        self.assertEqual(int('1fj8b185', 22), 4294967297L)
-        self.assertEqual(int('1606k7id', 23), 4294967297L)
-        self.assertEqual(int('mb994ah', 24), 4294967297L)
-        self.assertEqual(int('hek2mgm', 25), 4294967297L)
-        self.assertEqual(int('dnchbnn', 26), 4294967297L)
-        self.assertEqual(int('b28jpdn', 27), 4294967297L)
-        self.assertEqual(int('8pfgih5', 28), 4294967297L)
-        self.assertEqual(int('76beigh', 29), 4294967297L)
-        self.assertEqual(int('5qmcpqh', 30), 4294967297L)
-        self.assertEqual(int('4q0jto5', 31), 4294967297L)
-        self.assertEqual(int('4000001', 32), 4294967297L)
-        self.assertEqual(int('3aokq95', 33), 4294967297L)
-        self.assertEqual(int('2qhxjlj', 34), 4294967297L)
-        self.assertEqual(int('2br45qc', 35), 4294967297L)
-        self.assertEqual(int('1z141z5', 36), 4294967297L)
-
-    def test_intconversion(self):
-        # Test __int__()
-        class ClassicMissingMethods:
-            pass
-        self.assertRaises(AttributeError, int, ClassicMissingMethods())
-
-        class MissingMethods(object):
-            pass
-        self.assertRaises(TypeError, int, MissingMethods())
-
-        class Foo0:
-            def __int__(self):
-                return 42
-
-        class Foo1(object):
-            def __int__(self):
-                return 42
-
-        class Foo2(int):
-            def __int__(self):
-                return 42
-
-        class Foo3(int):
-            def __int__(self):
-                return self
-
-        class Foo4(int):
-            def __int__(self):
-                return 42L
-
-        class Foo5(int):
-            def __int__(self):
-                return 42.
-
-        self.assertEqual(int(Foo0()), 42)
-        self.assertEqual(int(Foo1()), 42)
-        self.assertEqual(int(Foo2()), 42)
-        self.assertEqual(int(Foo3()), 0)
-        self.assertEqual(int(Foo4()), 42L)
-        self.assertRaises(TypeError, int, Foo5())
-
-        class Classic:
-            pass
-        for base in (object, Classic):
-            class IntOverridesTrunc(base):
-                def __int__(self):
-                    return 42
-                def __trunc__(self):
-                    return -12
-            self.assertEqual(int(IntOverridesTrunc()), 42)
-
-            class JustTrunc(base):
-                def __trunc__(self):
-                    return 42
-            self.assertEqual(int(JustTrunc()), 42)
-
-            for trunc_result_base in (object, Classic):
-                class Integral(trunc_result_base):
-                    def __int__(self):
-                        return 42
-
-                class TruncReturnsNonInt(base):
-                    def __trunc__(self):
-                        return Integral()
-                self.assertEqual(int(TruncReturnsNonInt()), 42)
-
-                class NonIntegral(trunc_result_base):
-                    def __trunc__(self):
-                        # Check that we avoid infinite recursion.
-                        return NonIntegral()
-
-                class TruncReturnsNonIntegral(base):
-                    def __trunc__(self):
-                        return NonIntegral()
-                try:
-                    int(TruncReturnsNonIntegral())
-                except TypeError as e:
-                    self.assertEquals(str(e),
-                                      "__trunc__ returned non-Integral"
-                                      " (type NonIntegral)")
-                else:
-                    self.fail("Failed to raise TypeError with %s" %
-                              ((base, trunc_result_base),))
-
     def test_intern(self):
         self.assertRaises(TypeError, intern)
         s = "never interned before"
@@ -1144,247 +717,6 @@
                 raise ValueError
         self.assertRaises(ValueError, len, BadSeq())
 
-    def test_list(self):
-        self.assertEqual(list([]), [])
-        l0_3 = [0, 1, 2, 3]
-        l0_3_bis = list(l0_3)
-        self.assertEqual(l0_3, l0_3_bis)
-        self.assert_(l0_3 is not l0_3_bis)
-        self.assertEqual(list(()), [])
-        self.assertEqual(list((0, 1, 2, 3)), [0, 1, 2, 3])
-        self.assertEqual(list(''), [])
-        self.assertEqual(list('spam'), ['s', 'p', 'a', 'm'])
-
-        if sys.maxint == 0x7fffffff:
-            # This test can currently only work on 32-bit machines.
-            # XXX If/when PySequence_Length() returns a ssize_t, it should be
-            # XXX re-enabled.
-            # Verify clearing of bug #556025.
-            # This assumes that the max data size (sys.maxint) == max
-            # address size this also assumes that the address size is at
-            # least 4 bytes with 8 byte addresses, the bug is not well
-            # tested
-            #
-            # Note: This test is expected to SEGV under Cygwin 1.3.12 or
-            # earlier due to a newlib bug.  See the following mailing list
-            # thread for the details:
-
-            #     http://sources.redhat.com/ml/newlib/2002/msg00369.html
-            self.assertRaises(MemoryError, list, xrange(sys.maxint // 2))
-
-        # This code used to segfault in Py2.4a3
-        x = []
-        x.extend(-y for y in x)
-        self.assertEqual(x, [])
-
-    def test_long(self):
-        self.assertEqual(long(314), 314L)
-        self.assertEqual(long(3.14), 3L)
-        self.assertEqual(long(314L), 314L)
-        # Check that conversion from float truncates towards zero
-        self.assertEqual(long(-3.14), -3L)
-        self.assertEqual(long(3.9), 3L)
-        self.assertEqual(long(-3.9), -3L)
-        self.assertEqual(long(3.5), 3L)
-        self.assertEqual(long(-3.5), -3L)
-        self.assertEqual(long("-3"), -3L)
-        if have_unicode:
-            self.assertEqual(long(unicode("-3")), -3L)
-        # Different base:
-        self.assertEqual(long("10",16), 16L)
-        if have_unicode:
-            self.assertEqual(long(unicode("10"),16), 16L)
-        # Check conversions from string (same test set as for int(), and then some)
-        LL = [
-                ('1' + '0'*20, 10L**20),
-                ('1' + '0'*100, 10L**100)
-        ]
-        L2 = L[:]
-        if have_unicode:
-            L2 += [
-                (unicode('1') + unicode('0')*20, 10L**20),
-                (unicode('1') + unicode('0')*100, 10L**100),
-        ]
-        for s, v in L2 + LL:
-            for sign in "", "+", "-":
-                for prefix in "", " ", "\t", "  \t\t  ":
-                    ss = prefix + sign + s
-                    vv = v
-                    if sign == "-" and v is not ValueError:
-                        vv = -v
-                    try:
-                        self.assertEqual(long(ss), long(vv))
-                    except v:
-                        pass
-
-        self.assertRaises(ValueError, long, '123\0')
-        self.assertRaises(ValueError, long, '53', 40)
-        self.assertRaises(TypeError, long, 1, 12)
-
-        # SF patch #1638879: embedded NULs were not detected with
-        # explicit base
-        self.assertRaises(ValueError, long, '123\0', 10)
-        self.assertRaises(ValueError, long, '123\x00 245', 20)
-
-        self.assertEqual(long('100000000000000000000000000000000', 2),
-                         4294967296)
-        self.assertEqual(long('102002022201221111211', 3), 4294967296)
-        self.assertEqual(long('10000000000000000', 4), 4294967296)
-        self.assertEqual(long('32244002423141', 5), 4294967296)
-        self.assertEqual(long('1550104015504', 6), 4294967296)
-        self.assertEqual(long('211301422354', 7), 4294967296)
-        self.assertEqual(long('40000000000', 8), 4294967296)
-        self.assertEqual(long('12068657454', 9), 4294967296)
-        self.assertEqual(long('4294967296', 10), 4294967296)
-        self.assertEqual(long('1904440554', 11), 4294967296)
-        self.assertEqual(long('9ba461594', 12), 4294967296)
-        self.assertEqual(long('535a79889', 13), 4294967296)
-        self.assertEqual(long('2ca5b7464', 14), 4294967296)
-        self.assertEqual(long('1a20dcd81', 15), 4294967296)
-        self.assertEqual(long('100000000', 16), 4294967296)
-        self.assertEqual(long('a7ffda91', 17), 4294967296)
-        self.assertEqual(long('704he7g4', 18), 4294967296)
-        self.assertEqual(long('4f5aff66', 19), 4294967296)
-        self.assertEqual(long('3723ai4g', 20), 4294967296)
-        self.assertEqual(long('281d55i4', 21), 4294967296)
-        self.assertEqual(long('1fj8b184', 22), 4294967296)
-        self.assertEqual(long('1606k7ic', 23), 4294967296)
-        self.assertEqual(long('mb994ag', 24), 4294967296)
-        self.assertEqual(long('hek2mgl', 25), 4294967296)
-        self.assertEqual(long('dnchbnm', 26), 4294967296)
-        self.assertEqual(long('b28jpdm', 27), 4294967296)
-        self.assertEqual(long('8pfgih4', 28), 4294967296)
-        self.assertEqual(long('76beigg', 29), 4294967296)
-        self.assertEqual(long('5qmcpqg', 30), 4294967296)
-        self.assertEqual(long('4q0jto4', 31), 4294967296)
-        self.assertEqual(long('4000000', 32), 4294967296)
-        self.assertEqual(long('3aokq94', 33), 4294967296)
-        self.assertEqual(long('2qhxjli', 34), 4294967296)
-        self.assertEqual(long('2br45qb', 35), 4294967296)
-        self.assertEqual(long('1z141z4', 36), 4294967296)
-
-        self.assertEqual(long('100000000000000000000000000000001', 2),
-                         4294967297)
-        self.assertEqual(long('102002022201221111212', 3), 4294967297)
-        self.assertEqual(long('10000000000000001', 4), 4294967297)
-        self.assertEqual(long('32244002423142', 5), 4294967297)
-        self.assertEqual(long('1550104015505', 6), 4294967297)
-        self.assertEqual(long('211301422355', 7), 4294967297)
-        self.assertEqual(long('40000000001', 8), 4294967297)
-        self.assertEqual(long('12068657455', 9), 4294967297)
-        self.assertEqual(long('4294967297', 10), 4294967297)
-        self.assertEqual(long('1904440555', 11), 4294967297)
-        self.assertEqual(long('9ba461595', 12), 4294967297)
-        self.assertEqual(long('535a7988a', 13), 4294967297)
-        self.assertEqual(long('2ca5b7465', 14), 4294967297)
-        self.assertEqual(long('1a20dcd82', 15), 4294967297)
-        self.assertEqual(long('100000001', 16), 4294967297)
-        self.assertEqual(long('a7ffda92', 17), 4294967297)
-        self.assertEqual(long('704he7g5', 18), 4294967297)
-        self.assertEqual(long('4f5aff67', 19), 4294967297)
-        self.assertEqual(long('3723ai4h', 20), 4294967297)
-        self.assertEqual(long('281d55i5', 21), 4294967297)
-        self.assertEqual(long('1fj8b185', 22), 4294967297)
-        self.assertEqual(long('1606k7id', 23), 4294967297)
-        self.assertEqual(long('mb994ah', 24), 4294967297)
-        self.assertEqual(long('hek2mgm', 25), 4294967297)
-        self.assertEqual(long('dnchbnn', 26), 4294967297)
-        self.assertEqual(long('b28jpdn', 27), 4294967297)
-        self.assertEqual(long('8pfgih5', 28), 4294967297)
-        self.assertEqual(long('76beigh', 29), 4294967297)
-        self.assertEqual(long('5qmcpqh', 30), 4294967297)
-        self.assertEqual(long('4q0jto5', 31), 4294967297)
-        self.assertEqual(long('4000001', 32), 4294967297)
-        self.assertEqual(long('3aokq95', 33), 4294967297)
-        self.assertEqual(long('2qhxjlj', 34), 4294967297)
-        self.assertEqual(long('2br45qc', 35), 4294967297)
-        self.assertEqual(long('1z141z5', 36), 4294967297)
-
-
-    def test_longconversion(self):
-        # Test __long__()
-        class ClassicMissingMethods:
-            pass
-        self.assertRaises(AttributeError, long, ClassicMissingMethods())
-
-        class MissingMethods(object):
-            pass
-        self.assertRaises(TypeError, long, MissingMethods())
-
-        class Foo0:
-            def __long__(self):
-                return 42L
-
-        class Foo1(object):
-            def __long__(self):
-                return 42L
-
-        class Foo2(long):
-            def __long__(self):
-                return 42L
-
-        class Foo3(long):
-            def __long__(self):
-                return self
-
-        class Foo4(long):
-            def __long__(self):
-                return 42
-
-        class Foo5(long):
-            def __long__(self):
-                return 42.
-
-        self.assertEqual(long(Foo0()), 42L)
-        self.assertEqual(long(Foo1()), 42L)
-        self.assertEqual(long(Foo2()), 42L)
-        self.assertEqual(long(Foo3()), 0)
-        self.assertEqual(long(Foo4()), 42)
-        self.assertRaises(TypeError, long, Foo5())
-
-        class Classic:
-            pass
-        for base in (object, Classic):
-            class LongOverridesTrunc(base):
-                def __long__(self):
-                    return 42
-                def __trunc__(self):
-                    return -12
-            self.assertEqual(long(LongOverridesTrunc()), 42)
-
-            class JustTrunc(base):
-                def __trunc__(self):
-                    return 42
-            self.assertEqual(long(JustTrunc()), 42)
-
-            for trunc_result_base in (object, Classic):
-                class Integral(trunc_result_base):
-                    def __int__(self):
-                        return 42
-
-                class TruncReturnsNonLong(base):
-                    def __trunc__(self):
-                        return Integral()
-                self.assertEqual(long(TruncReturnsNonLong()), 42)
-
-                class NonIntegral(trunc_result_base):
-                    def __trunc__(self):
-                        # Check that we avoid infinite recursion.
-                        return NonIntegral()
-
-                class TruncReturnsNonIntegral(base):
-                    def __trunc__(self):
-                        return NonIntegral()
-                try:
-                    long(TruncReturnsNonIntegral())
-                except TypeError as e:
-                    self.assertEquals(str(e),
-                                      "__trunc__ returned non-Integral"
-                                      " (type NonIntegral)")
-                else:
-                    self.fail("Failed to raise TypeError with %s" %
-                              ((base, trunc_result_base),))
-
     def test_map(self):
         self.assertEqual(
             map(None, 'hello world'),
@@ -1539,6 +871,33 @@
         self.assertEqual(min(data, key=f),
                          sorted(data, key=f)[0])
 
+    def test_next(self):
+        it = iter(range(2))
+        self.assertEqual(next(it), 0)
+        self.assertEqual(next(it), 1)
+        self.assertRaises(StopIteration, next, it)
+        self.assertRaises(StopIteration, next, it)
+        self.assertEquals(next(it, 42), 42)
+
+        class Iter(object):
+            def __iter__(self):
+                return self
+            def next(self):
+                raise StopIteration
+
+        it = iter(Iter())
+        self.assertEquals(next(it, 42), 42)
+        self.assertRaises(StopIteration, next, it)
+
+        def gen():
+            yield 1
+            return
+
+        it = gen()
+        self.assertEquals(next(it), 1)
+        self.assertRaises(StopIteration, next, it)
+        self.assertEquals(next(it, 42), 42)
+
     def test_oct(self):
         self.assertEqual(oct(100), '0144')
         self.assertEqual(oct(100L), '0144L')
@@ -1892,20 +1251,6 @@
         self.assertRaises(TypeError, setattr, sys, 1, 'spam')
         self.assertRaises(TypeError, setattr)
 
-    def test_str(self):
-        self.assertEqual(str(''), '')
-        self.assertEqual(str(0), '0')
-        self.assertEqual(str(0L), '0')
-        self.assertEqual(str(()), '()')
-        self.assertEqual(str([]), '[]')
-        self.assertEqual(str({}), '{}')
-        a = []
-        a.append(a)
-        self.assertEqual(str(a), '[[...]]')
-        a = {}
-        a[0] = a
-        self.assertEqual(str(a), '{0: {...}}')
-
     def test_sum(self):
         self.assertEqual(sum([]), 0)
         self.assertEqual(sum(range(2,8)), 27)
@@ -1927,16 +1272,6 @@
                 raise ValueError
         self.assertRaises(ValueError, sum, BadSeq())
 
-    def test_tuple(self):
-        self.assertEqual(tuple(()), ())
-        t0_3 = (0, 1, 2, 3)
-        t0_3_bis = tuple(t0_3)
-        self.assert_(t0_3 is t0_3_bis)
-        self.assertEqual(tuple([]), ())
-        self.assertEqual(tuple([0, 1, 2, 3]), (0, 1, 2, 3))
-        self.assertEqual(tuple(''), ())
-        self.assertEqual(tuple('spam'), ('s', 'p', 'a', 'm'))
-
     def test_type(self):
         self.assertEqual(type(''),  type('123'))
         self.assertNotEqual(type(''), type(()))

Modified: python/branches/tlee-ast-optimize/Lib/test/test_cmd_line_script.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_cmd_line_script.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_cmd_line_script.py	Sun May  4 12:13:28 2008
@@ -1,5 +1,4 @@
 # Tests command line execution of scripts
-from __future__ import with_statement
 
 import unittest
 import os

Modified: python/branches/tlee-ast-optimize/Lib/test/test_contextlib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_contextlib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_contextlib.py	Sun May  4 12:13:28 2008
@@ -1,6 +1,5 @@
 """Unit tests for contextlib.py, and other context managers."""
 
-from __future__ import with_statement
 
 import sys
 import os

Modified: python/branches/tlee-ast-optimize/Lib/test/test_decimal.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_decimal.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_decimal.py	Sun May  4 12:13:28 2008
@@ -23,7 +23,6 @@
 you're working through IDLE, you can import this test module and call test_main()
 with the corresponding argument.
 """
-from __future__ import with_statement
 
 import glob
 import math
@@ -47,10 +46,12 @@
 def init():
     global ORIGINAL_CONTEXT
     ORIGINAL_CONTEXT = getcontext().copy()
-    DefaultContext.prec = 9
-    DefaultContext.rounding = ROUND_HALF_EVEN
-    DefaultContext.traps = dict.fromkeys(Signals, 0)
-    setcontext(DefaultContext)
+    DefaultTestContext = Context(
+        prec = 9,
+        rounding = ROUND_HALF_EVEN,
+        traps = dict.fromkeys(Signals, 0)
+        )
+    setcontext(DefaultTestContext)
 
 TESTDATADIR = 'decimaltestdata'
 if __name__ == '__main__':
@@ -180,8 +181,6 @@
     """
     def setUp(self):
         self.context = Context()
-        for key in DefaultContext.traps.keys():
-            DefaultContext.traps[key] = 1
         self.ignore_list = ['#']
         # Basically, a # means return NaN InvalidOperation.
         # Different from a sNaN in trim
@@ -192,13 +191,6 @@
                       'minexponent' : self.change_min_exponent,
                       'clamp' : self.change_clamp}
 
-    def tearDown(self):
-        """Cleaning up enviroment."""
-        # leaving context in original state
-        for key in DefaultContext.traps.keys():
-            DefaultContext.traps[key] = 0
-        return
-
     def eval_file(self, file):
         global skip_expected
         if skip_expected:
@@ -960,8 +952,8 @@
     test2 = d1/d3
     cls.finish1.set()
 
-    cls.assertEqual(test1, Decimal('0.333333333'))
-    cls.assertEqual(test2, Decimal('0.333333333'))
+    cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
+    cls.assertEqual(test2, Decimal('0.3333333333333333333333333333'))
     return
 
 def thfunc2(cls):
@@ -974,7 +966,7 @@
     cls.synchro.set()
     cls.finish2.set()
 
-    cls.assertEqual(test1, Decimal('0.333333333'))
+    cls.assertEqual(test1, Decimal('0.3333333333333333333333333333'))
     cls.assertEqual(test2, Decimal('0.333333333333333333'))
     return
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_float.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_float.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_float.py	Sun May  4 12:13:28 2008
@@ -9,6 +9,117 @@
 INF = float("inf")
 NAN = float("nan")
 
+class GeneralFloatCases(unittest.TestCase):
+
+    def test_float(self):
+        self.assertEqual(float(3.14), 3.14)
+        self.assertEqual(float(314), 314.0)
+        self.assertEqual(float(314L), 314.0)
+        self.assertEqual(float("  3.14  "), 3.14)
+        self.assertRaises(ValueError, float, "  0x3.1  ")
+        self.assertRaises(ValueError, float, "  -0x3.p-1  ")
+        self.assertRaises(ValueError, float, "  +0x3.p-1  ")
+        self.assertRaises(ValueError, float, "++3.14")
+        self.assertRaises(ValueError, float, "+-3.14")
+        self.assertRaises(ValueError, float, "-+3.14")
+        self.assertRaises(ValueError, float, "--3.14")
+        if have_unicode:
+            self.assertEqual(float(unicode("  3.14  ")), 3.14)
+            self.assertEqual(float(unicode("  \u0663.\u0661\u0664  ",'raw-unicode-escape')), 3.14)
+            # Implementation limitation in PyFloat_FromString()
+            self.assertRaises(ValueError, float, unicode("1"*10000))
+
+    @test_support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
+    def test_float_with_comma(self):
+        # set locale to something that doesn't use '.' for the decimal point
+        # float must not accept the locale specific decimal point but
+        # it still has to accept the normal python syntac
+        import locale
+        if not locale.localeconv()['decimal_point'] == ',':
+            return
+
+        self.assertEqual(float("  3.14  "), 3.14)
+        self.assertEqual(float("+3.14  "), 3.14)
+        self.assertEqual(float("-3.14  "), -3.14)
+        self.assertEqual(float(".14  "), .14)
+        self.assertEqual(float("3.  "), 3.0)
+        self.assertEqual(float("3.e3  "), 3000.0)
+        self.assertEqual(float("3.2e3  "), 3200.0)
+        self.assertEqual(float("2.5e-1  "), 0.25)
+        self.assertEqual(float("5e-1"), 0.5)
+        self.assertRaises(ValueError, float, "  3,14  ")
+        self.assertRaises(ValueError, float, "  +3,14  ")
+        self.assertRaises(ValueError, float, "  -3,14  ")
+        self.assertRaises(ValueError, float, "  0x3.1  ")
+        self.assertRaises(ValueError, float, "  -0x3.p-1  ")
+        self.assertRaises(ValueError, float, "  +0x3.p-1  ")
+        self.assertEqual(float("  25.e-1  "), 2.5)
+        self.assertEqual(fcmp(float("  .25e-1  "), .025), 0)
+
+    def test_floatconversion(self):
+        # Make sure that calls to __float__() work properly
+        class Foo0:
+            def __float__(self):
+                return 42.
+
+        class Foo1(object):
+            def __float__(self):
+                return 42.
+
+        class Foo2(float):
+            def __float__(self):
+                return 42.
+
+        class Foo3(float):
+            def __new__(cls, value=0.):
+                return float.__new__(cls, 2*value)
+
+            def __float__(self):
+                return self
+
+        class Foo4(float):
+            def __float__(self):
+                return 42
+
+        self.assertAlmostEqual(float(Foo0()), 42.)
+        self.assertAlmostEqual(float(Foo1()), 42.)
+        self.assertAlmostEqual(float(Foo2()), 42.)
+        self.assertAlmostEqual(float(Foo3(21)), 42.)
+        self.assertRaises(TypeError, float, Foo4(42))
+
+    def test_floatasratio(self):
+        for f, ratio in [
+                (0.875, (7, 8)),
+                (-0.875, (-7, 8)),
+                (0.0, (0, 1)),
+                (11.5, (23, 2)),
+            ]:
+            self.assertEqual(f.as_integer_ratio(), ratio)
+
+        for i in range(10000):
+            f = random.random()
+            f *= 10 ** random.randint(-100, 100)
+            n, d = f.as_integer_ratio()
+            self.assertEqual(float(n).__truediv__(d), f)
+
+        R = fractions.Fraction
+        self.assertEqual(R(0, 1),
+                         R(*float(0.0).as_integer_ratio()))
+        self.assertEqual(R(5, 2),
+                         R(*float(2.5).as_integer_ratio()))
+        self.assertEqual(R(1, 2),
+                         R(*float(0.5).as_integer_ratio()))
+        self.assertEqual(R(4728779608739021, 2251799813685248),
+                         R(*float(2.1).as_integer_ratio()))
+        self.assertEqual(R(-4728779608739021, 2251799813685248),
+                         R(*float(-2.1).as_integer_ratio()))
+        self.assertEqual(R(-2100, 1),
+                         R(*float(-2100.0).as_integer_ratio()))
+
+        self.assertRaises(OverflowError, float('inf').as_integer_ratio)
+        self.assertRaises(OverflowError, float('-inf').as_integer_ratio)
+        self.assertRaises(ValueError, float('nan').as_integer_ratio)
+
 class FormatFunctionsTestCase(unittest.TestCase):
 
     def setUp(self):

Modified: python/branches/tlee-ast-optimize/Lib/test/test_frozen.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_frozen.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_frozen.py	Sun May  4 12:13:28 2008
@@ -1,5 +1,4 @@
 # Test the frozen module defined in frozen.c.
-from __future__ import with_statement
 
 from test.test_support import captured_stdout, run_unittest
 import unittest

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	Sun May  4 12:13:28 2008
@@ -560,9 +560,9 @@
 
     def process_word(self):
         output = ''
-        if self.buffer[0] == 'i':
+        if self.buffer[0] == ord('i'):
             self.i = min(99, int(self.buffer[1:] or 0)) # set input length
-        elif self.buffer[0] == 'o':
+        elif self.buffer[0] == ord('o'):
             self.o = min(99, int(self.buffer[1:] or 0)) # set output length
         else:
             output = self.buffer.decode('ascii')
@@ -1160,10 +1160,10 @@
 
 def test_main():
     test_support.run_unittest(IOTest, BytesIOTest, StringIOTest,
-                              BufferedReaderTest,
-                              BufferedWriterTest, BufferedRWPairTest,
-                              BufferedRandomTest, TextIOWrapperTest,
-                              MiscIOTest)
+                              BufferedReaderTest, BufferedWriterTest,
+                              BufferedRWPairTest, BufferedRandomTest,
+                              StatefulIncrementalDecoderTest,
+                              TextIOWrapperTest, MiscIOTest)
 
 if __name__ == "__main__":
     unittest.main()

Modified: python/branches/tlee-ast-optimize/Lib/test/test_list.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_list.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_list.py	Sun May  4 12:13:28 2008
@@ -4,6 +4,39 @@
 class ListTest(list_tests.CommonTest):
     type2test = list
 
+    def test_basic(self):
+        self.assertEqual(list([]), [])
+        l0_3 = [0, 1, 2, 3]
+        l0_3_bis = list(l0_3)
+        self.assertEqual(l0_3, l0_3_bis)
+        self.assert_(l0_3 is not l0_3_bis)
+        self.assertEqual(list(()), [])
+        self.assertEqual(list((0, 1, 2, 3)), [0, 1, 2, 3])
+        self.assertEqual(list(''), [])
+        self.assertEqual(list('spam'), ['s', 'p', 'a', 'm'])
+
+        if sys.maxint == 0x7fffffff:
+            # This test can currently only work on 32-bit machines.
+            # XXX If/when PySequence_Length() returns a ssize_t, it should be
+            # XXX re-enabled.
+            # Verify clearing of bug #556025.
+            # This assumes that the max data size (sys.maxint) == max
+            # address size this also assumes that the address size is at
+            # least 4 bytes with 8 byte addresses, the bug is not well
+            # tested
+            #
+            # Note: This test is expected to SEGV under Cygwin 1.3.12 or
+            # earlier due to a newlib bug.  See the following mailing list
+            # thread for the details:
+
+            #     http://sources.redhat.com/ml/newlib/2002/msg00369.html
+            self.assertRaises(MemoryError, list, xrange(sys.maxint // 2))
+
+        # This code used to segfault in Py2.4a3
+        x = []
+        x.extend(-y for y in x)
+        self.assertEqual(x, [])
+
     def test_truth(self):
         super(ListTest, self).test_truth()
         self.assert_(not [])

Modified: python/branches/tlee-ast-optimize/Lib/test/test_long.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_long.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_long.py	Sun May  4 12:13:28 2008
@@ -1,5 +1,6 @@
 import unittest
 from test import test_support
+import sys
 
 import random
 
@@ -36,6 +37,46 @@
 special = special + map(lambda x: ~x, special) + \
                     map(lambda x: -x, special)
 
+L = [
+        ('0', 0),
+        ('1', 1),
+        ('9', 9),
+        ('10', 10),
+        ('99', 99),
+        ('100', 100),
+        ('314', 314),
+        (' 314', 314),
+        ('314 ', 314),
+        ('  \t\t  314  \t\t  ', 314),
+        (repr(sys.maxint), sys.maxint),
+        ('  1x', ValueError),
+        ('  1  ', 1),
+        ('  1\02  ', ValueError),
+        ('', ValueError),
+        (' ', ValueError),
+        ('  \t\t  ', ValueError)
+]
+if test_support.have_unicode:
+    L += [
+        (unicode('0'), 0),
+        (unicode('1'), 1),
+        (unicode('9'), 9),
+        (unicode('10'), 10),
+        (unicode('99'), 99),
+        (unicode('100'), 100),
+        (unicode('314'), 314),
+        (unicode(' 314'), 314),
+        (unicode('\u0663\u0661\u0664 ','raw-unicode-escape'), 314),
+        (unicode('  \t\t  314  \t\t  '), 314),
+        (unicode('  1x'), ValueError),
+        (unicode('  1  '), 1),
+        (unicode('  1\02  '), ValueError),
+        (unicode(''), ValueError),
+        (unicode(' '), ValueError),
+        (unicode('  \t\t  '), ValueError),
+        (unichr(0x200), ValueError),
+]
+
 
 class LongTest(unittest.TestCase):
 
@@ -234,8 +275,215 @@
                 x = self.getran(lenx)
                 self.check_format_1(x)
 
+    def test_long(self):
+        self.assertEqual(long(314), 314L)
+        self.assertEqual(long(3.14), 3L)
+        self.assertEqual(long(314L), 314L)
+        # Check that conversion from float truncates towards zero
+        self.assertEqual(long(-3.14), -3L)
+        self.assertEqual(long(3.9), 3L)
+        self.assertEqual(long(-3.9), -3L)
+        self.assertEqual(long(3.5), 3L)
+        self.assertEqual(long(-3.5), -3L)
+        self.assertEqual(long("-3"), -3L)
+        if test_support.have_unicode:
+            self.assertEqual(long(unicode("-3")), -3L)
+        # Different base:
+        self.assertEqual(long("10",16), 16L)
+        if test_support.have_unicode:
+            self.assertEqual(long(unicode("10"),16), 16L)
+        # Check conversions from string (same test set as for int(), and then some)
+        LL = [
+                ('1' + '0'*20, 10L**20),
+                ('1' + '0'*100, 10L**100)
+        ]
+        L2 = L[:]
+        if test_support.have_unicode:
+            L2 += [
+                (unicode('1') + unicode('0')*20, 10L**20),
+                (unicode('1') + unicode('0')*100, 10L**100),
+        ]
+        for s, v in L2 + LL:
+            for sign in "", "+", "-":
+                for prefix in "", " ", "\t", "  \t\t  ":
+                    ss = prefix + sign + s
+                    vv = v
+                    if sign == "-" and v is not ValueError:
+                        vv = -v
+                    try:
+                        self.assertEqual(long(ss), long(vv))
+                    except v:
+                        pass
+
+        self.assertRaises(ValueError, long, '123\0')
+        self.assertRaises(ValueError, long, '53', 40)
+        self.assertRaises(TypeError, long, 1, 12)
+
+        # SF patch #1638879: embedded NULs were not detected with
+        # explicit base
+        self.assertRaises(ValueError, long, '123\0', 10)
+        self.assertRaises(ValueError, long, '123\x00 245', 20)
+
+        self.assertEqual(long('100000000000000000000000000000000', 2),
+                         4294967296)
+        self.assertEqual(long('102002022201221111211', 3), 4294967296)
+        self.assertEqual(long('10000000000000000', 4), 4294967296)
+        self.assertEqual(long('32244002423141', 5), 4294967296)
+        self.assertEqual(long('1550104015504', 6), 4294967296)
+        self.assertEqual(long('211301422354', 7), 4294967296)
+        self.assertEqual(long('40000000000', 8), 4294967296)
+        self.assertEqual(long('12068657454', 9), 4294967296)
+        self.assertEqual(long('4294967296', 10), 4294967296)
+        self.assertEqual(long('1904440554', 11), 4294967296)
+        self.assertEqual(long('9ba461594', 12), 4294967296)
+        self.assertEqual(long('535a79889', 13), 4294967296)
+        self.assertEqual(long('2ca5b7464', 14), 4294967296)
+        self.assertEqual(long('1a20dcd81', 15), 4294967296)
+        self.assertEqual(long('100000000', 16), 4294967296)
+        self.assertEqual(long('a7ffda91', 17), 4294967296)
+        self.assertEqual(long('704he7g4', 18), 4294967296)
+        self.assertEqual(long('4f5aff66', 19), 4294967296)
+        self.assertEqual(long('3723ai4g', 20), 4294967296)
+        self.assertEqual(long('281d55i4', 21), 4294967296)
+        self.assertEqual(long('1fj8b184', 22), 4294967296)
+        self.assertEqual(long('1606k7ic', 23), 4294967296)
+        self.assertEqual(long('mb994ag', 24), 4294967296)
+        self.assertEqual(long('hek2mgl', 25), 4294967296)
+        self.assertEqual(long('dnchbnm', 26), 4294967296)
+        self.assertEqual(long('b28jpdm', 27), 4294967296)
+        self.assertEqual(long('8pfgih4', 28), 4294967296)
+        self.assertEqual(long('76beigg', 29), 4294967296)
+        self.assertEqual(long('5qmcpqg', 30), 4294967296)
+        self.assertEqual(long('4q0jto4', 31), 4294967296)
+        self.assertEqual(long('4000000', 32), 4294967296)
+        self.assertEqual(long('3aokq94', 33), 4294967296)
+        self.assertEqual(long('2qhxjli', 34), 4294967296)
+        self.assertEqual(long('2br45qb', 35), 4294967296)
+        self.assertEqual(long('1z141z4', 36), 4294967296)
+
+        self.assertEqual(long('100000000000000000000000000000001', 2),
+                         4294967297)
+        self.assertEqual(long('102002022201221111212', 3), 4294967297)
+        self.assertEqual(long('10000000000000001', 4), 4294967297)
+        self.assertEqual(long('32244002423142', 5), 4294967297)
+        self.assertEqual(long('1550104015505', 6), 4294967297)
+        self.assertEqual(long('211301422355', 7), 4294967297)
+        self.assertEqual(long('40000000001', 8), 4294967297)
+        self.assertEqual(long('12068657455', 9), 4294967297)
+        self.assertEqual(long('4294967297', 10), 4294967297)
+        self.assertEqual(long('1904440555', 11), 4294967297)
+        self.assertEqual(long('9ba461595', 12), 4294967297)
+        self.assertEqual(long('535a7988a', 13), 4294967297)
+        self.assertEqual(long('2ca5b7465', 14), 4294967297)
+        self.assertEqual(long('1a20dcd82', 15), 4294967297)
+        self.assertEqual(long('100000001', 16), 4294967297)
+        self.assertEqual(long('a7ffda92', 17), 4294967297)
+        self.assertEqual(long('704he7g5', 18), 4294967297)
+        self.assertEqual(long('4f5aff67', 19), 4294967297)
+        self.assertEqual(long('3723ai4h', 20), 4294967297)
+        self.assertEqual(long('281d55i5', 21), 4294967297)
+        self.assertEqual(long('1fj8b185', 22), 4294967297)
+        self.assertEqual(long('1606k7id', 23), 4294967297)
+        self.assertEqual(long('mb994ah', 24), 4294967297)
+        self.assertEqual(long('hek2mgm', 25), 4294967297)
+        self.assertEqual(long('dnchbnn', 26), 4294967297)
+        self.assertEqual(long('b28jpdn', 27), 4294967297)
+        self.assertEqual(long('8pfgih5', 28), 4294967297)
+        self.assertEqual(long('76beigh', 29), 4294967297)
+        self.assertEqual(long('5qmcpqh', 30), 4294967297)
+        self.assertEqual(long('4q0jto5', 31), 4294967297)
+        self.assertEqual(long('4000001', 32), 4294967297)
+        self.assertEqual(long('3aokq95', 33), 4294967297)
+        self.assertEqual(long('2qhxjlj', 34), 4294967297)
+        self.assertEqual(long('2br45qc', 35), 4294967297)
+        self.assertEqual(long('1z141z5', 36), 4294967297)
+
+
+    def test_conversion(self):
+        # Test __long__()
+        class ClassicMissingMethods:
+            pass
+        self.assertRaises(AttributeError, long, ClassicMissingMethods())
+
+        class MissingMethods(object):
+            pass
+        self.assertRaises(TypeError, long, MissingMethods())
+
+        class Foo0:
+            def __long__(self):
+                return 42L
+
+        class Foo1(object):
+            def __long__(self):
+                return 42L
+
+        class Foo2(long):
+            def __long__(self):
+                return 42L
+
+        class Foo3(long):
+            def __long__(self):
+                return self
+
+        class Foo4(long):
+            def __long__(self):
+                return 42
+
+        class Foo5(long):
+            def __long__(self):
+                return 42.
+
+        self.assertEqual(long(Foo0()), 42L)
+        self.assertEqual(long(Foo1()), 42L)
+        self.assertEqual(long(Foo2()), 42L)
+        self.assertEqual(long(Foo3()), 0)
+        self.assertEqual(long(Foo4()), 42)
+        self.assertRaises(TypeError, long, Foo5())
+
+        class Classic:
+            pass
+        for base in (object, Classic):
+            class LongOverridesTrunc(base):
+                def __long__(self):
+                    return 42
+                def __trunc__(self):
+                    return -12
+            self.assertEqual(long(LongOverridesTrunc()), 42)
+
+            class JustTrunc(base):
+                def __trunc__(self):
+                    return 42
+            self.assertEqual(long(JustTrunc()), 42)
+
+            for trunc_result_base in (object, Classic):
+                class Integral(trunc_result_base):
+                    def __int__(self):
+                        return 42
+
+                class TruncReturnsNonLong(base):
+                    def __trunc__(self):
+                        return Integral()
+                self.assertEqual(long(TruncReturnsNonLong()), 42)
+
+                class NonIntegral(trunc_result_base):
+                    def __trunc__(self):
+                        # Check that we avoid infinite recursion.
+                        return NonIntegral()
+
+                class TruncReturnsNonIntegral(base):
+                    def __trunc__(self):
+                        return NonIntegral()
+                try:
+                    long(TruncReturnsNonIntegral())
+                except TypeError as e:
+                    self.assertEquals(str(e),
+                                      "__trunc__ returned non-Integral"
+                                      " (type NonIntegral)")
+                else:
+                    self.fail("Failed to raise TypeError with %s" %
+                              ((base, trunc_result_base),))
+
     def test_misc(self):
-        import sys
 
         # check the extremes in int<->long conversion
         hugepos = sys.maxint
@@ -417,7 +665,6 @@
     def test_mixed_compares(self):
         eq = self.assertEqual
         import math
-        import sys
 
         # We're mostly concerned with that mixing floats and longs does the
         # right stuff, even when longs are too large to fit in a float.

Modified: python/branches/tlee-ast-optimize/Lib/test/test_str.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_str.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_str.py	Sun May  4 12:13:28 2008
@@ -17,6 +17,20 @@
     def fixtype(self, obj):
         return obj
 
+    def test_basic_creation(self):
+        self.assertEqual(str(''), '')
+        self.assertEqual(str(0), '0')
+        self.assertEqual(str(0L), '0')
+        self.assertEqual(str(()), '()')
+        self.assertEqual(str([]), '[]')
+        self.assertEqual(str({}), '{}')
+        a = []
+        a.append(a)
+        self.assertEqual(str(a), '[[...]]')
+        a = {}
+        a[0] = a
+        self.assertEqual(str(a), '{0: {...}}')
+
     def test_formatting(self):
         string_tests.MixinStrUnicodeUserStringTest.test_formatting(self)
         self.assertRaises(OverflowError, '%c'.__mod__, 0x1234)

Modified: python/branches/tlee-ast-optimize/Lib/test/test_sundry.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_sundry.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_sundry.py	Sun May  4 12:13:28 2008
@@ -9,41 +9,24 @@
 class TestUntestedModules(unittest.TestCase):
     def test_at_least_import_untested_modules(self):
         with test_support.catch_warning():
-            import BaseHTTPServer
-            import DocXMLRPCServer
             import CGIHTTPServer
-            import SimpleHTTPServer
-            import SimpleXMLRPCServer
             import aifc
             import audiodev
             import bdb
             import cgitb
-            import cmd
             import code
             import compileall
 
-            import distutils.archive_util
             import distutils.bcppcompiler
             import distutils.ccompiler
-            import distutils.cmd
-            import distutils.core
             import distutils.cygwinccompiler
-            import distutils.dep_util
-            import distutils.dir_util
             import distutils.emxccompiler
-            import distutils.errors
-            import distutils.extension
-            import distutils.file_util
             import distutils.filelist
-            import distutils.log
             if sys.platform.startswith('win'):
                 import distutils.msvccompiler
             import distutils.mwerkscompiler
-            import distutils.sysconfig
             import distutils.text_file
             import distutils.unixccompiler
-            import distutils.util
-            import distutils.version
 
             import distutils.command.bdist_dumb
             if sys.platform.startswith('win'):
@@ -54,23 +37,18 @@
             import distutils.command.build_clib
             import distutils.command.build_ext
             import distutils.command.build
-            import distutils.command.build_py
-            import distutils.command.build_scripts
             import distutils.command.clean
             import distutils.command.config
             import distutils.command.install_data
             import distutils.command.install_egg_info
             import distutils.command.install_headers
             import distutils.command.install_lib
-            import distutils.command.install
-            import distutils.command.install_scripts
             import distutils.command.register
             import distutils.command.sdist
             import distutils.command.upload
 
             import encodings
             import formatter
-            import ftplib
             import getpass
             import htmlentitydefs
             import ihooks
@@ -81,7 +59,6 @@
             import macurl2path
             import mailcap
             import mimify
-            import mutex
             import nntplib
             import nturl2path
             import opcode
@@ -93,7 +70,6 @@
             import rexec
             import rlcompleter
             import sched
-            import smtplib
             import sndhdr
             import statvfs
             import stringold
@@ -101,7 +77,6 @@
             import sunaudio
             import symbol
             import tabnanny
-            import telnetlib
             import timeit
             import toaiff
             import token

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	Sun May  4 12:13:28 2008
@@ -482,8 +482,10 @@
     import StringIO
     orig_stdout = getattr(sys, stream_name)
     setattr(sys, stream_name, StringIO.StringIO())
-    yield getattr(sys, stream_name)
-    setattr(sys, stream_name, orig_stdout)
+    try:
+        yield getattr(sys, stream_name)
+    finally:
+        setattr(sys, stream_name, orig_stdout)
 
 def captured_stdout():
     return captured_output("stdout")

Modified: python/branches/tlee-ast-optimize/Lib/test/test_tempfile.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_tempfile.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_tempfile.py	Sun May  4 12:13:28 2008
@@ -1,5 +1,4 @@
 # tempfile.py unit tests.
-from __future__ import with_statement
 import tempfile
 import os
 import sys

Modified: python/branches/tlee-ast-optimize/Lib/test/test_traceback.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_traceback.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_traceback.py	Sun May  4 12:13:28 2008
@@ -1,10 +1,24 @@
 """Test cases for traceback module"""
 
+from _testcapi import traceback_print
+from StringIO import StringIO
+import sys
 import unittest
-from test.test_support import run_unittest, is_jython
+from test.test_support import run_unittest, is_jython, Error
 
 import traceback
 
+try:
+    raise KeyError
+except KeyError:
+    type_, value, tb = sys.exc_info()
+    file_ = StringIO()
+    traceback_print(tb, file_)
+    example_traceback = file_.getvalue()
+else:
+    raise Error("unable to create test traceback string")
+
+
 class TracebackCases(unittest.TestCase):
     # For now, a very minimal set of tests.  I want to be sure that
     # formatting of SyntaxErrors works based on changes for 2.1.
@@ -154,8 +168,20 @@
         self.assertEqual(err, ['None\n'])
 
 
+class TracebackFormatTests(unittest.TestCase):
+
+    def test_traceback_indentation(self):
+        # Make sure that the traceback is properly indented.
+        tb_lines = example_traceback.splitlines()
+        self.assertEquals(len(tb_lines), 3)
+        banner, location, source_line = tb_lines
+        self.assert_(banner.startswith('Traceback'))
+        self.assert_(location.startswith('  File'))
+        self.assert_(source_line.startswith('raise'))
+
+
 def test_main():
-    run_unittest(TracebackCases)
+    run_unittest(TracebackCases, TracebackFormatTests)
 
 
 if __name__ == "__main__":

Modified: python/branches/tlee-ast-optimize/Lib/test/test_tuple.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_tuple.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_tuple.py	Sun May  4 12:13:28 2008
@@ -7,6 +7,13 @@
         super(TupleTest, self).test_len()
         # calling built-in types without argument must return empty
         self.assertEqual(tuple(), ())
+        t0_3 = (0, 1, 2, 3)
+        t0_3_bis = tuple(t0_3)
+        self.assert_(t0_3 is t0_3_bis)
+        self.assertEqual(tuple([]), ())
+        self.assertEqual(tuple([0, 1, 2, 3]), (0, 1, 2, 3))
+        self.assertEqual(tuple(''), ())
+        self.assertEqual(tuple('spam'), ('s', 'p', 'a', 'm'))
 
     def test_truth(self):
         super(TupleTest, self).test_truth()

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	Sun May  4 12:13:28 2008
@@ -1,8 +1,9 @@
 # Python test set -- part 6, built-in types
 
-from test.test_support import run_unittest, have_unicode
+from test.test_support import run_unittest, have_unicode, run_with_locale
 import unittest
 import sys
+import locale
 
 class TypesTests(unittest.TestCase):
 
@@ -476,6 +477,15 @@
                 self.assertEqual(value.__format__(format_spec),
                                  float(value).__format__(format_spec))
 
+    @run_with_locale('LC_NUMERIC', 'en_US.UTF8')
+    def test_float__format__locale(self):
+        # test locale support for __format__ code 'n'
+
+        for i in range(-10, 10):
+            x = 1234567890.0 * (10.0 ** i)
+            self.assertEqual(locale.format('%g', x, grouping=True), format(x, 'n'))
+            self.assertEqual(locale.format('%.10g', x, grouping=True), format(x, '.10n'))
+
     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	Sun May  4 12:13:28 2008
@@ -229,6 +229,77 @@
                 warning_tests.inner("spam7", stacklevel=9999)
                 self.assertEqual(os.path.basename(w.filename), "sys")
 
+    def test_missing_filename_not_main(self):
+        # If __file__ is not specified and __main__ is not the module name,
+        # then __file__ should be set to the module name.
+        filename = warning_tests.__file__
+        try:
+            del warning_tests.__file__
+            with warnings_state(self.module):
+                with test_support.catch_warning(self.module) as w:
+                    warning_tests.inner("spam8", stacklevel=1)
+                    self.assertEqual(w.filename, warning_tests.__name__)
+        finally:
+            warning_tests.__file__ = filename
+
+    def test_missing_filename_main_with_argv(self):
+        # If __file__ is not specified and the caller is __main__ and sys.argv
+        # exists, then use sys.argv[0] as the file.
+        if not hasattr(sys, 'argv'):
+            return
+        filename = warning_tests.__file__
+        module_name = warning_tests.__name__
+        try:
+            del warning_tests.__file__
+            warning_tests.__name__ = '__main__'
+            with warnings_state(self.module):
+                with test_support.catch_warning(self.module) as w:
+                    warning_tests.inner('spam9', stacklevel=1)
+                    self.assertEqual(w.filename, sys.argv[0])
+        finally:
+            warning_tests.__file__ = filename
+            warning_tests.__name__ = module_name
+
+    def test_missing_filename_main_without_argv(self):
+        # If __file__ is not specified, the caller is __main__, and sys.argv
+        # is not set, then '__main__' is the file name.
+        filename = warning_tests.__file__
+        module_name = warning_tests.__name__
+        argv = sys.argv
+        try:
+            del warning_tests.__file__
+            warning_tests.__name__ = '__main__'
+            del sys.argv
+            with warnings_state(self.module):
+                with test_support.catch_warning(self.module) as w:
+                    warning_tests.inner('spam10', stacklevel=1)
+                    self.assertEqual(w.filename, '__main__')
+        finally:
+            warning_tests.__file__ = filename
+            warning_tests.__name__ = module_name
+            sys.argv = argv
+
+    def test_missing_filename_main_with_argv_empty_string(self):
+        # If __file__ is not specified, the caller is __main__, and sys.argv[0]
+        # is the empty string, then '__main__ is the file name.
+        # Tests issue 2743.
+        file_name = warning_tests.__file__
+        module_name = warning_tests.__name__
+        argv = sys.argv
+        try:
+            del warning_tests.__file__
+            warning_tests.__name__ = '__main__'
+            sys.argv = ['']
+            with warnings_state(self.module):
+                with test_support.catch_warning(self.module) as w:
+                    warning_tests.inner('spam11', stacklevel=1)
+                    self.assertEqual(w.filename, '__main__')
+        finally:
+            warning_tests.__file__ = file_name
+            warning_tests.__name__ = module_name
+            sys.argv = argv
+
+
 
 class CWarnTests(BaseTest, WarnTests):
     module = c_warnings

Modified: python/branches/tlee-ast-optimize/Lib/test/test_with.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_with.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_with.py	Sun May  4 12:13:28 2008
@@ -2,7 +2,6 @@
 
 """Unit tests for the with statement specified in PEP 343."""
 
-from __future__ import with_statement
 
 __author__ = "Mike Bland"
 __email__ = "mbland at acm dot org"

Modified: python/branches/tlee-ast-optimize/Mac/BuildScript/build-installer.py
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/BuildScript/build-installer.py	(original)
+++ python/branches/tlee-ast-optimize/Mac/BuildScript/build-installer.py	Sun May  4 12:13:28 2008
@@ -199,7 +199,7 @@
     dict(
         name="PythonApplications",
         long_name="GUI Applications",
-        source="/Applications/MacPython %(VER)s",
+        source="/Applications/Python %(VER)s",
         readme="""\
             This package installs IDLE (an interactive Python IDE),
             Python Launcher and Build Applet (create application bundles

Modified: python/branches/tlee-ast-optimize/Mac/BuildScript/resources/ReadMe.txt
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/BuildScript/resources/ReadMe.txt	(original)
+++ python/branches/tlee-ast-optimize/Mac/BuildScript/resources/ReadMe.txt	Sun May  4 12:13:28 2008
@@ -19,7 +19,7 @@
 extension modules that open up specific Macintosh technologies 
 to Python programs (Carbon, AppleScript, Quicktime, more).
 
-The installer puts the applications in "MacPython $VERSION" 
+The installer puts the applications in "Python $VERSION" 
 in your Applications folder, command-line tools in
 /usr/local/bin and the underlying machinery in
 $PYTHONFRAMEWORKINSTALLDIR.

Modified: python/branches/tlee-ast-optimize/Mac/IDLE/Makefile.in
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/IDLE/Makefile.in	(original)
+++ python/branches/tlee-ast-optimize/Mac/IDLE/Makefile.in	Sun May  4 12:13:28 2008
@@ -9,6 +9,7 @@
 VERSION=	@VERSION@
 UNIVERSALSDK=@UNIVERSALSDK@
 builddir=	../..
+PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
 
 RUNSHARED=      @RUNSHARED@
 BUILDEXE=       @BUILDEXEEXT@
@@ -21,7 +22,7 @@
 
 BUNDLEBULDER=$(srcdir)/../../Lib/plat-mac/bundlebuilder.py
 
-PYTHONAPPSDIR=/Applications/MacPython $(VERSION)
+PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
 
 all: IDLE.app
 

Modified: python/branches/tlee-ast-optimize/Mac/Makefile.in
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Makefile.in	(original)
+++ python/branches/tlee-ast-optimize/Mac/Makefile.in	Sun May  4 12:13:28 2008
@@ -13,14 +13,16 @@
 DESTDIR=
 LDFLAGS=@LDFLAGS@
 FRAMEWORKUNIXTOOLSPREFIX=@FRAMEWORKUNIXTOOLSPREFIX@
+PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
+
 
 # These are normally glimpsed from the previous set
 bindir=$(prefix)/bin
-PYTHONAPPSDIR=/Applications/MacPython $(VERSION)
+PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
 APPINSTALLDIR=$(prefix)/Resources/Python.app
 
 # Variables for installing the "normal" unix binaries
-INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/Python
+INSTALLED_PYTHONAPP=$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)
 
 # Items more-or-less copied from the main Makefile
 DIRMODE=755
@@ -103,7 +105,7 @@
 
 pythonw: $(srcdir)/Tools/pythonw.c Makefile
 	$(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \
-		-DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/Python"'
+		-DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"'
 
 
 install_PythonLauncher:
@@ -155,7 +157,7 @@
 			esac; \
 		done; \
 	done
-	$(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/Python"
+	$(INSTALL_PROGRAM) $(STRIPFLAG) $(BUILDPYTHON) "$(DESTDIR)$(APPINSTALLDIR)/Contents/MacOS/$(PYTHONFRAMEWORK)"
 
 install_IDLE:
 	cd IDLE && make install

Modified: python/branches/tlee-ast-optimize/Mac/PythonLauncher/Makefile.in
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/PythonLauncher/Makefile.in	(original)
+++ python/branches/tlee-ast-optimize/Mac/PythonLauncher/Makefile.in	Sun May  4 12:13:28 2008
@@ -12,6 +12,7 @@
 RUNSHARED=      @RUNSHARED@
 BUILDEXE=       @BUILDEXEEXT@
 BUILDPYTHON=    $(builddir)/python$(BUILDEXE)
+PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
 
 # Deployment target selected during configure, to be checked
 # by distutils  
@@ -20,7 +21,7 @@
 
 BUNDLEBULDER=$(srcdir)/../../Lib/plat-mac/bundlebuilder.py
 
-PYTHONAPPSDIR=/Applications/MacPython $(VERSION)
+PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
 OBJECTS=FileSettings.o MyAppDelegate.o MyDocument.o PreferencesWindowController.o doscript.o main.o
 
 all: Python\ Launcher.app

Modified: python/branches/tlee-ast-optimize/Mac/PythonLauncher/MyDocument.m
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/PythonLauncher/MyDocument.m	(original)
+++ python/branches/tlee-ast-optimize/Mac/PythonLauncher/MyDocument.m	Sun May  4 12:13:28 2008
@@ -121,8 +121,8 @@
         return YES;
     } else {
         [self run];
-        [self close];
-        return NO;
+	[self performSelector:@selector(close) withObject:nil afterDelay:0.0];
+        return YES;
     }
 }
 

Modified: python/branches/tlee-ast-optimize/Mac/PythonLauncher/doscript.m
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/PythonLauncher/doscript.m	(original)
+++ python/branches/tlee-ast-optimize/Mac/PythonLauncher/doscript.m	Sun May  4 12:13:28 2008
@@ -11,108 +11,49 @@
 #import <ApplicationServices/ApplicationServices.h>
 #import "doscript.h"
 
-/* I assume I could pick these up from somewhere, but where... */
-#define CREATOR 'trmx'
-
-#define ACTIVATE_CMD 'misc'
-#define ACTIVATE_SUITE 'actv'
-
-#define DOSCRIPT_CMD 'dosc'
-#define DOSCRIPT_SUITE 'core'
-#define WITHCOMMAND 'cmnd'
-
-/* ... and there's probably also a better way to do this... */
-#define START_TERMINAL "/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal &"
-
 extern int 
 doscript(const char *command)
 {
-    OSErr err;
-    AppleEvent theAEvent, theReply;
-    AEAddressDesc terminalAddress;
-    AEDesc commandDesc;
-    OSType terminalCreator = CREATOR;
-    
-    /* set up locals  */
-    AECreateDesc(typeNull, NULL, 0, &theAEvent);
-    AECreateDesc(typeNull, NULL, 0, &terminalAddress);
-    AECreateDesc(typeNull, NULL, 0, &theReply);
-    AECreateDesc(typeNull, NULL, 0, &commandDesc);
-    
-    /* create the "activate" event for Terminal */
-    err = AECreateDesc(typeApplSignature, (Ptr) &terminalCreator,
-            sizeof(terminalCreator), &terminalAddress);
-    if (err != noErr) {
-        NSLog(@"doscript: AECreateDesc: error %d\n", err);
-        goto bail;
-    }
-    err = AECreateAppleEvent(ACTIVATE_SUITE, ACTIVATE_CMD,
-            &terminalAddress, kAutoGenerateReturnID,
-            kAnyTransactionID, &theAEvent);
-    
-    if (err != noErr) {
-        NSLog(@"doscript: AECreateAppleEvent(activate): error %d\n", err);
-        goto bail;
-    }
-    /* send the event  */
-    err = AESend(&theAEvent, &theReply, kAEWaitReply,
-            kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
-    if ( err == -600 ) {
-        int count=10;
-        /* If it failed with "no such process" try to start Terminal */
-        err = system(START_TERMINAL);
-        if ( err ) {
-            NSLog(@"doscript: system(): %s\n", strerror(errno));
-            goto bail;
-        }
-        do {
-            sleep(1);
-            /* send the event again */
-            err = AESend(&theAEvent, &theReply, kAEWaitReply,
-                    kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
-        } while (err == -600 && --count > 0);
-        if ( err == -600 )
-            NSLog(@"doscript: Could not activate Terminal\n");
-    }
-    if (err != noErr) {
-        NSLog(@"doscript: AESend(activate): error %d\n", err);
-        goto bail;
-    }
-            
-    /* create the "doscript with command" event for Terminal */
-    err = AECreateAppleEvent(DOSCRIPT_SUITE, DOSCRIPT_CMD,
-            &terminalAddress, kAutoGenerateReturnID,
-            kAnyTransactionID, &theAEvent);
-    if (err != noErr) {
-        NSLog(@"doscript: AECreateAppleEvent(doscript): error %d\n", err);
-        goto bail;
-    }
-    
-    /* add the command to the apple event */
-    err = AECreateDesc(typeChar, command, strlen(command), &commandDesc);
-    if (err != noErr) {
-        NSLog(@"doscript: AECreateDesc(command): error %d\n", err);
-        goto bail;
-    }
-    err = AEPutParamDesc(&theAEvent, WITHCOMMAND, &commandDesc);
-    if (err != noErr) {
-        NSLog(@"doscript: AEPutParamDesc: error %d\n", err);
-        goto bail;
-    }
+	char *bundleID = "com.apple.Terminal";
+	AppleEvent evt, res;
+	AEDesc desc;
+	OSStatus err;
+
+	[[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/Utilities/Terminal.app/"];
+
+	// Build event
+	err = AEBuildAppleEvent(kAECoreSuite, kAEDoScript,
+	                         typeApplicationBundleID,
+	                         bundleID, strlen(bundleID),
+	                         kAutoGenerateReturnID,
+	                         kAnyTransactionID,
+	                         &evt, NULL,
+	                         "'----':utf8(@)", strlen(command),
+	                         command);
+	if (err) {
+		NSLog(@"AEBuildAppleEvent failed: %d\n", err);
+		return err;
+	}
+
+	// Send event and check for any Apple Event Manager errors
+	err = AESendMessage(&evt, &res, kAEWaitReply, kAEDefaultTimeout);
+	AEDisposeDesc(&evt);
+	if (err) {
+		NSLog(@"AESendMessage failed: %d\n", err);
+		return err;
+	}
+	// Check for any application errors
+	err = AEGetParamDesc(&res, keyErrorNumber, typeSInt32, &desc);
+	AEDisposeDesc(&res);
+	if (!err) {
+		AEGetDescData(&desc, &err, sizeof(err));
+		NSLog(@"Terminal returned an error: %d", err);
+		AEDisposeDesc(&desc);
+	} else if (err == errAEDescNotFound) {
+		err = noErr;
+	} else {
+		NSLog(@"AEGetPArmDesc returned an error: %d", err);
+	}
 
-    /* send the command event to Terminal.app */
-    err = AESend(&theAEvent, &theReply, kAEWaitReply,
-            kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
-    
-    if (err != noErr) {
-        NSLog(@"doscript: AESend(docommand): error %d\n", err);
-        goto bail;
-    }
-    /* clean up and leave */
-bail:
-    AEDisposeDesc(&commandDesc);
-    AEDisposeDesc(&theAEvent);
-    AEDisposeDesc(&terminalAddress);
-    AEDisposeDesc(&theReply);
-    return err;
+	return err;
 }

Deleted: python/branches/tlee-ast-optimize/Mac/Resources/app/Info.plist
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Resources/app/Info.plist	Sun May  4 12:13:28 2008
+++ (empty file)
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleDocumentTypes</key>
-	<array>
-		<dict>
-			<key>CFBundleTypeOSTypes</key>
-			<array>
-				<string>****</string>
-				<string>fold</string>
-				<string>disk</string>
-			</array>
-			<key>CFBundleTypeRole</key>
-			<string>Viewer</string>
-		</dict>
-	</array>
-	<key>CFBundleExecutable</key>
-	<string>Python</string>
-	<key>CFBundleGetInfoString</key>
-	<string>2.5alpha0, (c) 2004 Python Software Foundation.</string>
-	<key>CFBundleHelpBookFolder</key>
-	<array>
-		<string>Documentation</string>
-		<string>PythonDocumentation</string>
-	</array>
-	<key>CFBundleHelpBookName</key>
-	<string>MacPython Help</string>
-	<key>CFBundleHelpTOCFile</key>
-	<string>index.html</string>
-	<key>CFBundleIconFile</key>
-	<string>PythonInterpreter.icns</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.python.python</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleLongVersionString</key>
-	<string>2.5alpha0, (c) 2004 Python Software Foundation.</string>
-	<key>CFBundleName</key>
-	<string>Python</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>2.5alpha0</string>
-	<key>CFBundleSignature</key>
-	<string>PytX</string>
-	<key>CFBundleVersion</key>
-	<string>2.5alpha0</string>
-	<key>CSResourcesFileMapped</key>
-	<true/>
-	<key>LSRequiresCarbon</key>
-	<true/>
-	<key>NSAppleScriptEnabled</key>
-	<true/>
-	<key>NSHumanReadableCopyright</key>
-	<string>(c) 2004 Python Software Foundation.</string>
-</dict>
-</plist>

Deleted: python/branches/tlee-ast-optimize/Mac/Resources/app/Resources/English.lproj/InfoPlist.strings
==============================================================================
Binary file. No diff available.

Deleted: python/branches/tlee-ast-optimize/Mac/Resources/framework/Info.plist
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Resources/framework/Info.plist	Sun May  4 12:13:28 2008
+++ (empty file)
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
-<plist version="0.9">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>Python</string>
-	<key>CFBundleGetInfoString</key>
-	<string>Python Runtime and Library</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.python.python</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>Python</string>
-	<key>CFBundlePackageType</key>
-	<string>FMWK</string>
-	<key>CFBundleShortVersionString</key>
-	<string>2.5</string>
-	<key>CFBundleSignature</key>
-	<string>????</string>
-	<key>CFBundleVersion</key>
-	<string>2.5</string>
-</dict>
-</plist>

Deleted: python/branches/tlee-ast-optimize/Mac/Resources/framework/version.plist
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/Resources/framework/version.plist	Sun May  4 12:13:28 2008
+++ (empty file)
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>BuildVersion</key>
-	<string>1</string>
-	<key>CFBundleShortVersionString</key>
-	<string>2.5alpha0</string>
-	<key>CFBundleVersion</key>
-	<string>2.5alpha0</string>
-	<key>ProjectName</key>
-	<string>Python</string>
-	<key>ReleaseStatus</key>
-	<string>alfa</string>
-	<key>SourceVersion</key>
-	<string>2.4a0</string>
-</dict>
-</plist>

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	Sun May  4 12:13:28 2008
@@ -419,18 +419,16 @@
 # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
 # minimal framework (not including the Lib directory and such) in the current
 # directory.
-RESSRCDIR=$(srcdir)/Mac/Resources/framework
+RESSRCDIR=Mac/Resources/framework
 $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
 		$(LIBRARY) \
-		$(RESSRCDIR)/Info.plist \
-                $(RESSRCDIR)/version.plist \
-                $(RESSRCDIR)/English.lproj/InfoPlist.strings
+		$(RESSRCDIR)/Info.plist
 	$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
 	if test "${UNIVERSALSDK}"; then \
 		$(CC) -o $(LDLIBRARY) -arch i386 -arch ppc -dynamiclib \
 			-isysroot "${UNIVERSALSDK}" \
 			-all_load $(LIBRARY) -Wl,-single_module \
-			-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/Python \
+			-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
 			-compatibility_version $(VERSION) \
 			-current_version $(VERSION); \
         else \
@@ -441,10 +439,6 @@
 		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
 	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
 		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
-	$(INSTALL_DATA) $(RESSRCDIR)/version.plist \
-		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/version.plist
-	$(INSTALL_DATA) $(RESSRCDIR)/English.lproj/InfoPlist.strings \
-		$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj/InfoPlist.strings
 	$(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
 	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
 	$(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
@@ -1031,12 +1025,9 @@
 		fi; \
 	done
 	$(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
-	$(INSTALL_DATA) $(RESSRCDIR)/Info.plist $(DESTDIR)$(prefix)/Resources/Info.plist
-	$(INSTALL_DATA) $(RESSRCDIR)/version.plist $(DESTDIR)$(prefix)/Resources/version.plist
-	$(INSTALL_DATA) $(RESSRCDIR)/English.lproj/InfoPlist.strings \
-		$(DESTDIR)$(prefix)/Resources/English.lproj/InfoPlist.strings
+	sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
 	$(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
-	$(LN) -fsn Versions/Current/Python $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Python
+	$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
 	$(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
 	$(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
 	$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
@@ -1045,7 +1036,7 @@
 # Install a number of symlinks to keep software that expects a normal unix
 # install (which includes python-config) happy.
 frameworkinstallmaclib:
-	ln -fs "../../../Python" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
+	ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
 	cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
 
 # This installs the IDE, the Launcher and other apps into /Applications

Modified: python/branches/tlee-ast-optimize/Misc/NEWS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/NEWS	(original)
+++ python/branches/tlee-ast-optimize/Misc/NEWS	Sun May  4 12:13:28 2008
@@ -12,14 +12,16 @@
 Core and builtins
 -----------------
 
+- Issue #2719: backported the ``next()`` builtin from Python 3.
+
 - Issue #2681: The octal literal ``0o8`` was incorrecly acctepted. Now it
   properly raises a SyntaxError.
 
 - Patch #2617: Reserved -J and -X arguments for Jython, IronPython and other
   implementations of Python. 
 
-Extensions Modules
-------------------
+Extension Modules
+-----------------
 
 - Issue #2670:  Fix a failure in urllib2.build_opener(), when passed two
   handlers that derive the same default base class.
@@ -38,11 +40,15 @@
 - Issue #1631171: Re-implement the 'warnings' module in C (the original Python
   code has been kept as backup). This will allow for using the 'warning's
   machinery in such places as the parser where use of pure Python code is not
-  possible.
+  possible.  Both the ``showarning()`` and ``formatwarning()`` gain an
+  optional 'line' argument which is not called by default for
+  backwards-compatibility reasons.
 
 Library
 -------
 
+- Issue #2581: distutils: Vista UAC/elevation support for bdist_wininst
+
 - Issue #2635: Fix bug in 'fix_sentence_endings' textwrap.fill option,
   where an extra space was added after a word containing (but not
   ending in) '.', '!' or '?'.
@@ -135,6 +141,9 @@
 - Issue #2544: On HP-UX systems, use 'gcc -shared' for linking when
   gcc is used as compiler.
 
+- Issue #2573: On MacOS X it is now possible to install the framework
+  with a different name using --with-framework-name=NAME. 
+
 C API
 -----
 
@@ -227,8 +236,8 @@
 
 - Issue #2143: Fix embedded readline() hang on SSL socket EOF.
 
-Extensions Modules
-------------------
+Extension Modules
+-----------------
 
 - Patch #2240: Implement signal.setitimer and signal.getitimer.
 

Modified: python/branches/tlee-ast-optimize/Misc/developers.txt
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/developers.txt	(original)
+++ python/branches/tlee-ast-optimize/Misc/developers.txt	Sun May  4 12:13:28 2008
@@ -17,6 +17,12 @@
 Permissions History
 -------------------
 
+- Rodrigo Bernardo Pimentel was given SVN access on 29 April 2008 by MvL,
+  for GSoC contributions.
+
+- Heiko Weinen was given SVN access on 29 April 2008 by MvL,
+  for GSoC contributions.
+
 - Jesus Cea was was given SVN access on 24 April 2008 by MvL,
   for maintenance of bsddb.
 

Modified: python/branches/tlee-ast-optimize/Modules/_testcapimodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_testcapimodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/_testcapimodule.c	Sun May  4 12:13:28 2008
@@ -734,6 +734,24 @@
 	Py_RETURN_NONE;
 }
 
+/* To test the format of tracebacks as printed out. */
+static PyObject *
+traceback_print(PyObject *self, PyObject *args)
+{
+	PyObject *file;
+	PyObject *traceback;
+	int result;
+	
+	if (!PyArg_ParseTuple(args, "OO:traceback_print",
+				&traceback, &file))
+		return NULL;
+		
+	result = PyTraceBack_Print(traceback, file);
+	if (result < 0)
+		return NULL;
+	Py_RETURN_NONE;
+}
+
 static PyMethodDef TestMethods[] = {
 	{"raise_exception",	raise_exception,		 METH_VARARGS},
 	{"test_config",		(PyCFunction)test_config,	 METH_NOARGS},
@@ -774,6 +792,7 @@
 #ifdef WITH_THREAD
 	{"_test_thread_state",  test_thread_state, 		 METH_VARARGS},
 #endif
+	{"traceback_print", traceback_print, 	         METH_VARARGS},
 	{NULL, NULL} /* sentinel */
 };
 

Modified: python/branches/tlee-ast-optimize/Modules/arraymodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/arraymodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/arraymodule.c	Sun May  4 12:13:28 2008
@@ -1258,7 +1258,7 @@
 array_fromfile_as_read(arrayobject *self, PyObject *args)
 {
 	if (PyErr_WarnPy3k("array.read() not supported in 3.x; "
-		       "use array.fromfile()", 1) < 0)
+			   "use array.fromfile()", 1) < 0)
 		return NULL;
 	return array_fromfile(self, args);
 }
@@ -1297,7 +1297,7 @@
 array_tofile_as_write(arrayobject *self, PyObject *f)
 {
 	if (PyErr_WarnPy3k("array.write() not supported in 3.x; "
-		       "use array.tofile()", 1) < 0)
+			   "use array.tofile()", 1) < 0)
 		return NULL;
 	return array_tofile(self, f);
 }

Modified: python/branches/tlee-ast-optimize/Objects/cellobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/cellobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/cellobject.c	Sun May  4 12:13:28 2008
@@ -56,7 +56,7 @@
 {
 	/* Py3K warning for comparisons  */
 	if (PyErr_WarnPy3k("cell comparisons not supported in 3.x",
-                           1) < 0) {
+			   1) < 0) {
 		return -2;
 	}
 

Modified: python/branches/tlee-ast-optimize/Objects/codeobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/codeobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/codeobject.c	Sun May  4 12:13:28 2008
@@ -339,9 +339,9 @@
 	    !PyCode_Check(other)) {
 
 		/* Py3K warning if types are not equal and comparison
-                   isn't == or !=  */
+		isn't == or !=  */
 		if (PyErr_WarnPy3k("code inequality comparisons not supported "
-			       "in 3.x", 1) < 0) {
+				   "in 3.x", 1) < 0) {
 			return NULL;
 		}
 

Modified: python/branches/tlee-ast-optimize/Objects/dictobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/dictobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/dictobject.c	Sun May  4 12:13:28 2008
@@ -1779,7 +1779,7 @@
 	else {
 		/* Py3K warning if comparison isn't == or !=  */
 		if (PyErr_WarnPy3k("dict inequality comparisons not supported "
-			       "in 3.x", 1) < 0) {
+				   "in 3.x", 1) < 0) {
 			return NULL;
 		}
 		res = Py_NotImplemented;
@@ -1810,7 +1810,7 @@
 dict_has_key(register PyDictObject *mp, PyObject *key)
 {
 	if (PyErr_WarnPy3k("dict.has_key() not supported in 3.x; "
-		       "use the in operator", 1) < 0)
+			   "use the in operator", 1) < 0)
 		return NULL;
 	return dict_contains(mp, key);
 }

Modified: python/branches/tlee-ast-optimize/Objects/exceptions.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/exceptions.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/exceptions.c	Sun May  4 12:13:28 2008
@@ -279,9 +279,8 @@
 	int ret;
 	ret = PyErr_WarnEx(PyExc_DeprecationWarning,
 				"BaseException.message has been deprecated as "
-					"of Python 2.6",
-				1);
-	if (ret == -1)
+				"of Python 2.6", 1);
+	if (ret < 0)
 		return NULL;
 
 	Py_INCREF(self->message);
@@ -294,9 +293,8 @@
 	int ret;
 	ret = PyErr_WarnEx(PyExc_DeprecationWarning,
 				"BaseException.message has been deprecated as "
-					"of Python 2.6",
-				1);
-	if (ret == -1)
+				"of Python 2.6", 1);
+	if (ret < 0)
 		return -1;
 	Py_INCREF(val);
 	Py_DECREF(self->message);

Modified: python/branches/tlee-ast-optimize/Objects/fileobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/fileobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/fileobject.c	Sun May  4 12:13:28 2008
@@ -627,8 +627,9 @@
 			return NULL;
 		/* Deprecated in 2.6 */
 		PyErr_Clear();
-		if (PyErr_Warn(PyExc_DeprecationWarning,
-			       "integer argument expected, got float"))
+		if (PyErr_WarnEx(PyExc_DeprecationWarning,
+				 "integer argument expected, got float",
+				 1) < 0)
 			return NULL;
 		off_index = offobj;
 		Py_INCREF(offobj);

Modified: python/branches/tlee-ast-optimize/Objects/listobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/listobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/listobject.c	Sun May  4 12:13:28 2008
@@ -2038,7 +2038,7 @@
 	if (compare == Py_None)
 		compare = NULL;
 	if (compare != NULL && 
-            PyErr_WarnPy3k("the cmp argument is not supported in 3.x", 1) < 0)
+	    PyErr_WarnPy3k("the cmp argument is not supported in 3.x", 1) < 0)
 		return NULL;
 	if (keyfunc == Py_None)
 		keyfunc = NULL;

Modified: python/branches/tlee-ast-optimize/Objects/methodobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/methodobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/methodobject.c	Sun May  4 12:13:28 2008
@@ -236,7 +236,7 @@
 	{
 		/* Py3K warning if types are not equal and comparison isn't == or !=  */
 		if (PyErr_WarnPy3k("builtin_function_or_method inequality "
-			       "comparisons not supported in 3.x", 1) < 0) {
+				   "comparisons not supported in 3.x", 1) < 0) {
 			return NULL;
 		}
 
@@ -352,9 +352,8 @@
 {
 	if (name[0] == '_' && name[1] == '_') {
 		if (strcmp(name, "__methods__") == 0) {
-			if (Py_Py3kWarningFlag &&
-			    PyErr_Warn(PyExc_DeprecationWarning,
-				       "__methods__ not supported in 3.x") < 0)
+			if (PyErr_WarnPy3k("__methods__ not supported in 3.x",
+					   1) < 0)
 				return NULL;
 			return listmethodchain(chain);
 		}

Modified: python/branches/tlee-ast-optimize/PC/bdist_wininst/install.c
==============================================================================
--- python/branches/tlee-ast-optimize/PC/bdist_wininst/install.c	(original)
+++ python/branches/tlee-ast-optimize/PC/bdist_wininst/install.c	Sun May  4 12:13:28 2008
@@ -133,6 +133,7 @@
 char install_script[MAX_PATH];
 char *pre_install_script; /* run before we install a single file */
 
+char user_access_control[10]; // one of 'auto', 'force', otherwise none.
 
 int py_major, py_minor;		/* Python version selected for installation */
 
@@ -344,8 +345,15 @@
 };
 typedef struct PyMethodDef PyMethodDef;
 
+// XXX - all of these are potentially fragile!  We load and unload
+// the Python DLL multiple times - so storing functions pointers 
+// is dangerous (although things *look* OK at present)
+// Better might be to roll prepare_script_environment() into
+// LoadPythonDll(), and create a new UnloadPythonDLL() which also
+// clears the global pointers.
 void *(*g_Py_BuildValue)(char *, ...);
 int (*g_PyArg_ParseTuple)(PyObject *, char *, ...);
+PyObject * (*g_PyLong_FromVoidPtr)(void *);
 
 PyObject *g_PyExc_ValueError;
 PyObject *g_PyExc_OSError;
@@ -597,7 +605,7 @@
 
 static PyObject *GetRootHKey(PyObject *self)
 {
-	return g_Py_BuildValue("l", hkey_root);
+	return g_PyLong_FromVoidPtr(hkey_root);
 }
 
 #define METH_VARARGS 0x0001
@@ -631,7 +639,9 @@
 		 "SOFTWARE\\Python\\PythonCore\\%d.%d\\InstallPath",
 		 py_major, py_minor);
 	if (ERROR_SUCCESS != RegQueryValue(HKEY_CURRENT_USER, subkey_name,
-					   fullpath, &size))
+	                                   fullpath, &size) &&
+	    ERROR_SUCCESS != RegQueryValue(HKEY_LOCAL_MACHINE, subkey_name,
+	                                   fullpath, &size))
 		return NULL;
 	strcat(fullpath, "\\");
 	strcat(fullpath, fname);
@@ -648,6 +658,7 @@
 	DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...));
 	DECLPROC(hPython, int, PyArg_ParseTuple, (PyObject *, char *, ...));
 	DECLPROC(hPython, PyObject *, PyErr_Format, (PyObject *, char *));
+	DECLPROC(hPython, PyObject *, PyLong_FromVoidPtr, (void *));
 	if (!PyImport_ImportModule || !PyObject_GetAttrString || 
 	    !PyObject_SetAttrString || !PyCFunction_New)
 		return 1;
@@ -667,6 +678,7 @@
 	g_Py_BuildValue = Py_BuildValue;
 	g_PyArg_ParseTuple = PyArg_ParseTuple;
 	g_PyErr_Format = PyErr_Format;
+	g_PyLong_FromVoidPtr = PyLong_FromVoidPtr;
 
 	return 0;
 }
@@ -777,7 +789,9 @@
 
 	hPython = LoadPythonDll(pythondll);
 	if (!hPython) {
-		set_failure_reason("Can't load Python for pre-install script");
+		char reason[128];
+		wsprintf(reason, "Can't load Python for pre-install script (%d)", GetLastError());
+		set_failure_reason(reason);
 		return -1;
 	}
 	rc = do_run_simple_script(hPython, script);
@@ -2073,6 +2087,71 @@
 		PropertySheet(&psh);
 }
 
+// subtly different from HasLocalMachinePrivs(), in that after executing
+// an 'elevated' process, we expect this to return TRUE - but there is no
+// such implication for HasLocalMachinePrivs
+BOOL MyIsUserAnAdmin()
+{
+	typedef BOOL (WINAPI *PFNIsUserAnAdmin)();
+	static PFNIsUserAnAdmin pfnIsUserAnAdmin = NULL;
+	HMODULE shell32;
+	// This function isn't guaranteed to be available (and it can't hurt 
+	// to leave the library loaded)
+	if (0 == (shell32=LoadLibrary("shell32.dll")))
+		return FALSE;
+	if (0 == (pfnIsUserAnAdmin=(PFNIsUserAnAdmin)GetProcAddress(shell32, "IsUserAnAdmin")))
+		return FALSE;
+	return (*pfnIsUserAnAdmin)();
+}
+
+// Some magic for Vista's UAC.  If there is a target_version, and
+// if that target version is installed in the registry under
+// HKLM, and we are not current administrator, then
+// re-execute ourselves requesting elevation.
+// Split into 2 functions - "should we elevate" and "spawn elevated"
+
+// Returns TRUE if we should spawn an elevated child
+BOOL NeedAutoUAC()
+{
+	HKEY hk;
+	char key_name[80];
+	OSVERSIONINFO winverinfo;
+	winverinfo.dwOSVersionInfoSize = sizeof(winverinfo);
+	// If less than XP, then we can't do it (and its not necessary).
+	if (!GetVersionEx(&winverinfo) || winverinfo.dwMajorVersion < 5)
+		return FALSE;
+	// no Python version info == we can't know yet.
+	if (target_version[0] == '\0')
+		return FALSE;
+	// see how python is current installed
+	wsprintf(key_name,
+			 "Software\\Python\\PythonCore\\%s\\InstallPath",
+			 target_version);
+	if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
+	                                  key_name, 0, KEY_READ, &hk))
+		return FALSE;
+	RegCloseKey(hk);
+	// Python is installed in HKLM - we must elevate.
+	return TRUE;
+}
+
+// Spawn ourself as an elevated application.  On failure, a message is
+// displayed to the user - but this app will always terminate, even
+// on error.
+void SpawnUAC()
+{
+	// interesting failure scenario that has been seen: initial executable
+	// runs from a network drive - but once elevated, that network share
+	// isn't seen, and ShellExecute fails with SE_ERR_ACCESSDENIED.
+	int ret = (int)ShellExecute(0, "runas", modulename, "", NULL, 
+	                            SW_SHOWNORMAL);
+	if (ret <= 32) {
+		char msg[128];
+		wsprintf(msg, "Failed to start elevated process (ShellExecute returned %d)", ret);
+		MessageBox(0, msg, "Setup", MB_OK | MB_ICONERROR);
+	}
+}
+
 int DoInstall(void)
 {
 	char ini_buffer[4096];
@@ -2106,6 +2185,31 @@
 				 install_script, sizeof(install_script),
 				 ini_file);
 
+	GetPrivateProfileString("Setup", "user_access_control", "",
+				 user_access_control, sizeof(user_access_control), ini_file);
+
+	// See if we need to do the Vista UAC magic.
+	if (strcmp(user_access_control, "force")==0) {
+		if (!MyIsUserAnAdmin()) {
+			SpawnUAC();
+			return 0;
+		}
+		// already admin - keep going
+	} else if (strcmp(user_access_control, "auto")==0) {
+		// Check if it looks like we need UAC control, based
+		// on how Python itself was installed.
+		if (!MyIsUserAnAdmin() && NeedAutoUAC()) {
+			SpawnUAC();
+			return 0;
+		}
+	} else {
+		// display a warning about unknown values - only the developer
+		// of the extension will see it (until they fix it!)
+		if (user_access_control[0] && strcmp(user_access_control, "none") != 0) {
+			MessageBox(GetFocus(), "Bad user_access_control value", "oops", MB_OK);
+		// nothing to do.
+		}
+	}
 
 	hwndMain = CreateBackground(title);
 

Modified: python/branches/tlee-ast-optimize/PC/bdist_wininst/wininst-7.1.vcproj
==============================================================================
--- python/branches/tlee-ast-optimize/PC/bdist_wininst/wininst-7.1.vcproj	(original)
+++ python/branches/tlee-ast-optimize/PC/bdist_wininst/wininst-7.1.vcproj	Sun May  4 12:13:28 2008
@@ -24,7 +24,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="1"
 				InlineFunctionExpansion="1"
-				AdditionalIncludeDirectories="..\..\Include,..\..\..\zlib-1.2.1"
+				AdditionalIncludeDirectories="..\..\Include,..\..\..\zlib-1.2.3"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -41,7 +41,7 @@
 				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="..\..\..\zlib-1.2.1\zlib.lib imagehlp.lib comctl32.lib"
+				AdditionalDependencies="..\..\..\zlib-1.2.3\zlib.lib imagehlp.lib comctl32.lib"
 				OutputFile="..\..\lib\distutils\command/wininst-7.1.exe"
 				LinkIncremental="1"
 				SuppressStartupBanner="TRUE"

Modified: python/branches/tlee-ast-optimize/PC/bdist_wininst/wininst.dsp
==============================================================================
--- python/branches/tlee-ast-optimize/PC/bdist_wininst/wininst.dsp	(original)
+++ python/branches/tlee-ast-optimize/PC/bdist_wininst/wininst.dsp	Sun May  4 12:13:28 2008
@@ -43,7 +43,7 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /O1 /I "..\..\Include" /I "..\..\..\zlib-1.2.1" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /O1 /I "..\..\Include" /I "..\..\..\zlib-1.2.3" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
 # ADD BASE RSC /l 0x407 /d "NDEBUG"
@@ -53,7 +53,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
-# ADD LINK32 ..\..\..\zlib-1.2.1\zlib.lib imagehlp.lib comdlg32.lib ole32.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"LIBC" /out:"..\..\lib\distutils\command/wininst-6.exe"
+# ADD LINK32 ..\..\..\zlib-1.2.3\zlib.lib imagehlp.lib comdlg32.lib ole32.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"LIBC" /out:"..\..\lib\distutils\command/wininst-6.0.exe"
 
 !ELSEIF  "$(CFG)" == "wininst - Win32 Debug"
 
@@ -79,7 +79,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 ..\..\..\zlib-1.2.1\zlib.lib imagehlp.lib comdlg32.lib ole32.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /pdb:none /debug /machine:I386 /nodefaultlib:"LIBC" /out:"..\..\lib\distutils\command/wininst-6_d.exe"
+# ADD LINK32 ..\..\..\zlib-1.2.3\zlib.lib imagehlp.lib comdlg32.lib ole32.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /pdb:none /debug /machine:I386 /nodefaultlib:"LIBC" /out:"..\..\lib\distutils\command/wininst-6.0_d.exe"
 
 !ENDIF 
 

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	Sun May  4 12:13:28 2008
@@ -382,9 +382,6 @@
             
             res = PyObject_CallFunctionObjArgs(show_fxn, message, category,
                                                     filename, lineno_obj,
-                                                    Py_None,
-                                                    sourceline ?
-                                                        sourceline: Py_None,
                                                     NULL);
             Py_DECREF(show_fxn);
             Py_XDECREF(res);
@@ -465,9 +462,9 @@
     /* Setup filename. */
     *filename = PyDict_GetItemString(globals, "__file__");
     if (*filename != NULL) {
-	Py_ssize_t len = PyString_Size(*filename);
+	    Py_ssize_t len = PyString_Size(*filename);
         const char *file_str = PyString_AsString(*filename);
-	if (file_str == NULL || (len < 0 && PyErr_Occurred()))
+	    if (file_str == NULL || (len < 0 && PyErr_Occurred()))
             goto handle_error;
 
         /* if filename.lower().endswith((".pyc", ".pyo")): */
@@ -476,12 +473,13 @@
             tolower(file_str[len-3]) == 'p' &&
             tolower(file_str[len-2]) == 'y' &&
             (tolower(file_str[len-1]) == 'c' ||
-             tolower(file_str[len-1]) == 'o')) {
+                tolower(file_str[len-1]) == 'o'))
+        {
             *filename = PyString_FromStringAndSize(file_str, len-1);
-	    if (*filename == NULL)
-		    goto handle_error;
-	}
-	else
+	        if (*filename == NULL)
+		        goto handle_error;
+	    }
+	    else
             Py_INCREF(*filename);
     }
     else {
@@ -489,14 +487,27 @@
         if (module_str && strcmp(module_str, "__main__") == 0) {
             PyObject *argv = PySys_GetObject("argv");
             if (argv != NULL && PyList_Size(argv) > 0) {
+                int is_true;
                 *filename = PyList_GetItem(argv, 0);
                 Py_INCREF(*filename);
+                /* If sys.argv[0] is false, then use '__main__'. */
+                is_true = PyObject_IsTrue(*filename);
+                if (is_true < 0) {
+                    Py_DECREF(*filename);
+                    goto handle_error;
+                }
+                else if (!is_true) {
+                    Py_DECREF(*filename);
+                    *filename = PyString_FromString("__main__");
+                    if (*filename == NULL)
+                        goto handle_error;
+                }
             }
             else {
                 /* embedded interpreters don't have sys.argv, see bug #839151 */
                 *filename = PyString_FromString("__main__");
-	        if (*filename == NULL)
-	            goto handle_error;
+	            if (*filename == NULL)
+	                goto handle_error;
             }
         }
         if (*filename == NULL) {

Modified: python/branches/tlee-ast-optimize/Python/ast.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/ast.c	(original)
+++ python/branches/tlee-ast-optimize/Python/ast.c	Sun May  4 12:13:28 2008
@@ -36,7 +36,7 @@
 /* Note different signature for ast_for_call */
 static expr_ty ast_for_call(struct compiling *, const node *, expr_ty);
 
-static PyObject *parsenumber(const char *);
+static PyObject *parsenumber(struct compiling *, const char *);
 static PyObject *parsestr(struct compiling *, const char *);
 static PyObject *parsestrplus(struct compiling *, const node *n);
 
@@ -332,7 +332,7 @@
 */
 
 static int
-set_context(expr_ty e, expr_context_ty ctx, const node *n)
+set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
 {
     asdl_seq *s = NULL;
     /* If a particular expression type can't be used for assign / delete,
@@ -434,7 +434,7 @@
         int i;
 
         for (i = 0; i < asdl_seq_LEN(s); i++) {
-            if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n))
+            if (!set_context(c, (expr_ty)asdl_seq_GET(s, i), ctx, n))
                 return 0;
         }
     }
@@ -442,7 +442,7 @@
 }
 
 static operator_ty
-ast_for_augassign(const node *n)
+ast_for_augassign(struct compiling *c, const node *n)
 {
     REQ(n, augassign);
     n = CHILD(n, 0);
@@ -480,7 +480,7 @@
 }
 
 static cmpop_ty
-ast_for_comp_op(const node *n)
+ast_for_comp_op(struct compiling *c, const node *n)
 {
     /* comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'
                |'is' 'not'
@@ -606,7 +606,7 @@
     }
 
     result = Tuple(args, Store, LINENO(n), n->n_col_offset, c->c_arena);
-    if (!set_context(result, Store, n))
+    if (!set_context(c, result, Store, n))
         return NULL;
     return result;
 }
@@ -947,7 +947,7 @@
 */
 
 static int
-count_list_fors(const node *n)
+count_list_fors(struct compiling *c, const node *n)
 {
     int n_fors = 0;
     node *ch = CHILD(n, 1);
@@ -984,7 +984,7 @@
 */
 
 static int
-count_list_ifs(const node *n)
+count_list_ifs(struct compiling *c, const node *n)
 {
     int n_ifs = 0;
 
@@ -1022,7 +1022,7 @@
     if (!elt)
         return NULL;
 
-    n_fors = count_list_fors(n);
+    n_fors = count_list_fors(c, n);
     if (n_fors == -1)
         return NULL;
 
@@ -1066,7 +1066,7 @@
             expr_ty list_for_expr;
 
             ch = CHILD(ch, 4);
-            n_ifs = count_list_ifs(ch);
+            n_ifs = count_list_ifs(c, ch);
             if (n_ifs == -1)
                 return NULL;
 
@@ -1104,7 +1104,7 @@
 */
 
 static int
-count_gen_fors(const node *n)
+count_gen_fors(struct compiling *c, const node *n)
 {
     int n_fors = 0;
     node *ch = CHILD(n, 1);
@@ -1142,7 +1142,7 @@
 */
 
 static int
-count_gen_ifs(const node *n)
+count_gen_ifs(struct compiling *c, const node *n)
 {
     int n_ifs = 0;
 
@@ -1177,7 +1177,7 @@
     if (!elt)
         return NULL;
     
-    n_fors = count_gen_fors(n);
+    n_fors = count_gen_fors(c, n);
     if (n_fors == -1)
         return NULL;
 
@@ -1220,7 +1220,7 @@
             asdl_seq *ifs;
             
             ch = CHILD(ch, 4);
-            n_ifs = count_gen_ifs(ch);
+            n_ifs = count_gen_ifs(c, ch);
             if (n_ifs == -1)
                 return NULL;
 
@@ -1293,7 +1293,7 @@
         return Str(str, LINENO(n), n->n_col_offset, c->c_arena);
     }
     case NUMBER: {
-        PyObject *pynum = parsenumber(STR(ch));
+        PyObject *pynum = parsenumber(c, STR(ch));
         if (!pynum)
             return NULL;
 
@@ -1766,7 +1766,7 @@
                 for (i = 1; i < NCH(n); i += 2) {
                     cmpop_ty newoperator;
 
-                    newoperator = ast_for_comp_op(CHILD(n, i));
+                    newoperator = ast_for_comp_op(c, CHILD(n, i));
                     if (!newoperator) {
                         return NULL;
                     }
@@ -2065,7 +2065,7 @@
                           "assignment");
                 return NULL;
         }
-        if(!set_context(expr1, Store, ch))
+        if(!set_context(c, expr1, Store, ch))
             return NULL;
 
         ch = CHILD(n, 2);
@@ -2076,7 +2076,7 @@
         if (!expr2)
             return NULL;
 
-        newoperator = ast_for_augassign(CHILD(n, 1));
+        newoperator = ast_for_augassign(c, CHILD(n, 1));
         if (!newoperator)
             return NULL;
 
@@ -2107,7 +2107,7 @@
             if (!e) 
                 return NULL;
 
-            if (!set_context(e, Store, CHILD(n, i)))
+            if (!set_context(c, e, Store, CHILD(n, i)))
                 return NULL;
 
             asdl_seq_SET(targets, i / 2, e);
@@ -2172,7 +2172,7 @@
         if (!e)
             return NULL;
         asdl_seq_SET(seq, i / 2, e);
-        if (context && !set_context(e, context, CHILD(n, i)))
+        if (context && !set_context(c, e, context, CHILD(n, i)))
             return NULL;
     }
     return seq;
@@ -2853,7 +2853,7 @@
         expr_ty e = ast_for_expr(c, CHILD(exc, 3));
         if (!e)
             return NULL;
-        if (!set_context(e, Store, CHILD(exc, 3)))
+        if (!set_context(c, e, Store, CHILD(exc, 3)))
             return NULL;
         expression = ast_for_expr(c, CHILD(exc, 1));
         if (!expression)
@@ -2975,7 +2975,7 @@
         if (!optional_vars) {
             return NULL;
         }
-        if (!set_context(optional_vars, Store, n)) {
+        if (!set_context(c, optional_vars, Store, n)) {
             return NULL;
         }
         suite_index = 4;
@@ -3107,13 +3107,13 @@
 }
 
 static PyObject *
-parsenumber(const char *s)
+parsenumber(struct compiling *c, const char *s)
 {
         const char *end;
         long x;
         double dx;
 #ifndef WITHOUT_COMPLEX
-        Py_complex c;
+        Py_complex complex;
         int imflag;
 #endif
 
@@ -3142,11 +3142,11 @@
         /* XXX Huge floats may silently fail */
 #ifndef WITHOUT_COMPLEX
         if (imflag) {
-                c.real = 0.;
+                complex.real = 0.;
                 PyFPE_START_PROTECT("atof", return 0)
-                c.imag = PyOS_ascii_atof(s);
-                PyFPE_END_PROTECT(c)
-                return PyComplex_FromCComplex(c);
+                complex.imag = PyOS_ascii_atof(s);
+                PyFPE_END_PROTECT(complex)
+                return PyComplex_FromCComplex(complex);
         }
         else
 #endif
@@ -3159,7 +3159,7 @@
 }
 
 static PyObject *
-decode_utf8(const char **sPtr, const char *end, char* encoding)
+decode_utf8(struct compiling *c, const char **sPtr, const char *end, char* encoding)
 {
 #ifndef Py_USING_UNICODE
         Py_FatalError("decode_utf8 should not be called in this build.");
@@ -3182,7 +3182,7 @@
 
 #ifdef Py_USING_UNICODE
 static PyObject *
-decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
+decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, const char *encoding)
 {
         PyObject *v, *u;
         char *buf;
@@ -3213,7 +3213,7 @@
                                 PyObject *w;
                                 char *r;
                                 Py_ssize_t rn, i;
-                                w = decode_utf8(&s, end, "utf-16-be");
+                                w = decode_utf8(c, &s, end, "utf-16-be");
                                 if (w == NULL) {
                                         Py_DECREF(u);
                                         return NULL;
@@ -3296,7 +3296,7 @@
         }
 #ifdef Py_USING_UNICODE
         if (unicode || Py_UnicodeFlag) {
-                return decode_unicode(s, len, rawmode, c->c_encoding);
+                return decode_unicode(c, s, len, rawmode, c->c_encoding);
         }
 #endif
         need_encoding = (c->c_encoding != NULL &&

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	Sun May  4 12:13:28 2008
@@ -167,7 +167,7 @@
 	PyObject *t = NULL, *retval = NULL;
 
 	if (PyErr_WarnPy3k("apply() not supported in 3.x; "
-		       "use func(*args, **kwargs)", 1) < 0)
+			   "use func(*args, **kwargs)", 1) < 0)
 		return NULL;
 
 	if (!PyArg_UnpackTuple(args, "apply", 1, 3, &func, &alist, &kwdict))
@@ -225,7 +225,7 @@
 builtin_callable(PyObject *self, PyObject *v)
 {
 	if (PyErr_WarnPy3k("callable() not supported in 3.x; "
-		       "use hasattr(o, '__call__')", 1) < 0)
+			   "use hasattr(o, '__call__')", 1) < 0)
 		return NULL;
 	return PyBool_FromLong((long)PyCallable_Check(v));
 }
@@ -714,7 +714,7 @@
 	int exists;
 
 	if (PyErr_WarnPy3k("execfile() not supported in 3.x; use exec()",
-                           1) < 0)
+			   1) < 0)
 		return NULL;
 
 	if (!PyArg_ParseTuple(args, "s|O!O:execfile",
@@ -941,7 +941,7 @@
 
 	if (func == Py_None) {
 		if (PyErr_WarnPy3k("map(None, ...) not supported in 3.x; "
-			       "use list(...)", 1) < 0)
+				   "use list(...)", 1) < 0)
 			return NULL;
 		if (n == 1) {
 			/* map(None, S) is the same as list(S). */
@@ -1081,6 +1081,47 @@
 
 
 static PyObject *
+builtin_next(PyObject *self, PyObject *args)
+{
+	PyObject *it, *res;
+	PyObject *def = NULL;
+
+	if (!PyArg_UnpackTuple(args, "next", 1, 2, &it, &def))
+		return NULL;
+	if (!PyIter_Check(it)) {
+		PyErr_Format(PyExc_TypeError,
+			"%.200s object is not an iterator",
+			it->ob_type->tp_name);
+		return NULL;
+	}
+	
+	res = (*it->ob_type->tp_iternext)(it);
+	if (res != NULL) {
+		return res;
+	} else if (def != NULL) {
+		if (PyErr_Occurred()) {
+			if (!PyErr_ExceptionMatches(PyExc_StopIteration))
+				return NULL;
+			PyErr_Clear();
+		}
+		Py_INCREF(def);
+		return def;
+	} else if (PyErr_Occurred()) {
+		return NULL;
+	} else {
+		PyErr_SetNone(PyExc_StopIteration);
+		return NULL;
+	}
+}
+
+PyDoc_STRVAR(next_doc,
+"next(iterator[, default])\n\
+\n\
+Return the next item from the iterator. If default is given and the iterator\n\
+is exhausted, it is returned instead of raising StopIteration.");
+
+
+static PyObject *
 builtin_setattr(PyObject *self, PyObject *args)
 {
 	PyObject *v;
@@ -1969,7 +2010,7 @@
 	PyObject *seq, *func, *result = NULL, *it;
 
 	if (PyErr_WarnPy3k("reduce() not supported in 3.x; "
-		       "use functools.reduce()", 1) < 0)
+			   "use functools.reduce()", 1) < 0)
 		return NULL;
 
 	if (!PyArg_UnpackTuple(args, "reduce", 2, 3, &func, &seq, &result))
@@ -2045,7 +2086,7 @@
 builtin_reload(PyObject *self, PyObject *v)
 {
 	if (PyErr_WarnPy3k("In 3.x, reload() is renamed to imp.reload()",
-                           1) < 0)
+			   1) < 0)
 		return NULL;
 
 	return PyImport_ReloadModule(v);
@@ -2519,6 +2560,7 @@
  	{"map",		builtin_map,        METH_VARARGS, map_doc},
  	{"max",		(PyCFunction)builtin_max,        METH_VARARGS | METH_KEYWORDS, max_doc},
  	{"min",		(PyCFunction)builtin_min,        METH_VARARGS | METH_KEYWORDS, min_doc},
+	{"next", 	builtin_next,       METH_VARARGS, next_doc},
  	{"oct",		builtin_oct,        METH_O, oct_doc},
  	{"open",	(PyCFunction)builtin_open,       METH_VARARGS | METH_KEYWORDS, open_doc},
  	{"ord",		builtin_ord,        METH_O, ord_doc},

Modified: python/branches/tlee-ast-optimize/Python/ceval.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/ceval.c	(original)
+++ python/branches/tlee-ast-optimize/Python/ceval.c	Sun May  4 12:13:28 2008
@@ -3157,16 +3157,16 @@
 		/* Not something you can raise.  You get an exception
 		   anyway, just not what you specified :-) */
 		PyErr_Format(PyExc_TypeError,
-			     "exceptions must be classes or instances, not %s",
-			     type->ob_type->tp_name);
+			"exceptions must be classes or instances, not %s",
+			type->ob_type->tp_name);
 		goto raise_error;
 	}
 
 	assert(PyExceptionClass_Check(type));
 	if (Py_Py3kWarningFlag && PyClass_Check(type)) {
 		if (PyErr_WarnEx(PyExc_DeprecationWarning,
-			       "exceptions must derive from BaseException "
-			       "in 3.x", 1) == -1)
+				"exceptions must derive from BaseException "
+				"in 3.x", 1) < 0)
 			goto raise_error;
 	}
 
@@ -4092,7 +4092,7 @@
 						PyExc_DeprecationWarning,
 						"catching of string "
 						"exceptions is deprecated", 1);
-					if (ret_val == -1)
+					if (ret_val < 0)
 						return NULL;
 				}
 				else if (Py_Py3kWarningFlag  &&
@@ -4103,7 +4103,7 @@
 					ret_val = PyErr_WarnEx(
 						PyExc_DeprecationWarning,
 						CANNOT_CATCH_MSG, 1);
-					if (ret_val == -1)
+					if (ret_val < 0)
 						return NULL;
 				}
 			}
@@ -4115,7 +4115,7 @@
 						PyExc_DeprecationWarning,
 						"catching of string "
 						"exceptions is deprecated", 1);
-				if (ret_val == -1)
+				if (ret_val < 0)
 					return NULL;
 			}
 			else if (Py_Py3kWarningFlag  &&
@@ -4126,7 +4126,7 @@
 				ret_val = PyErr_WarnEx(
 					PyExc_DeprecationWarning,
 					CANNOT_CATCH_MSG, 1);
-				if (ret_val == -1)
+				if (ret_val < 0)
 					return 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	Sun May  4 12:13:28 2008
@@ -187,6 +187,38 @@
 	return val;
 }
 
+/* Given a string that may have a decimal point in the current
+   locale, change it back to a dot.  Since the string cannot get
+   longer, no need for a maximum buffer size parameter. */
+Py_LOCAL_INLINE(void)
+change_decimal_from_locale_to_dot(char* buffer)
+{
+	struct lconv *locale_data = localeconv();
+	const char *decimal_point = locale_data->decimal_point;
+
+	if (decimal_point[0] != '.' || decimal_point[1] != 0) {
+		size_t decimal_point_len = strlen(decimal_point);
+
+		if (*buffer == '+' || *buffer == '-')
+			buffer++;
+		while (isdigit(Py_CHARMASK(*buffer)))
+			buffer++;
+		if (strncmp(buffer, decimal_point, decimal_point_len) == 0) {
+			*buffer = '.';
+			buffer++;
+			if (decimal_point_len > 1) {
+				/* buffer needs to get smaller */
+				size_t rest_len = strlen(buffer +
+						     (decimal_point_len - 1));
+				memmove(buffer,
+					buffer + (decimal_point_len - 1),
+					rest_len);
+				buffer[rest_len] = 0;
+			}
+		}
+	}
+}
+
 
 /* From the C99 standard, section 7.19.6:
 The exponent always contains at least two digits, and only as many more digits
@@ -194,6 +226,189 @@
 */
 #define MIN_EXPONENT_DIGITS 2
 
+/* Ensure that any exponent, if present, is at least MIN_EXPONENT_DIGITS
+   in length. */
+Py_LOCAL_INLINE(void)
+ensure_minumim_exponent_length(char* buffer, size_t buf_size)
+{
+	char *p = strpbrk(buffer, "eE");
+	if (p && (*(p + 1) == '-' || *(p + 1) == '+')) {
+		char *start = p + 2;
+		int exponent_digit_cnt = 0;
+		int leading_zero_cnt = 0;
+		int in_leading_zeros = 1;
+		int significant_digit_cnt;
+
+		/* Skip over the exponent and the sign. */
+		p += 2;
+
+		/* Find the end of the exponent, keeping track of leading
+		   zeros. */
+		while (*p && isdigit(Py_CHARMASK(*p))) {
+			if (in_leading_zeros && *p == '0')
+				++leading_zero_cnt;
+			if (*p != '0')
+				in_leading_zeros = 0;
+			++p;
+			++exponent_digit_cnt;
+		}
+
+		significant_digit_cnt = exponent_digit_cnt - leading_zero_cnt;
+		if (exponent_digit_cnt == MIN_EXPONENT_DIGITS) {
+			/* If there are 2 exactly digits, we're done,
+			   regardless of what they contain */
+		}
+		else if (exponent_digit_cnt > MIN_EXPONENT_DIGITS) {
+			int extra_zeros_cnt;
+
+			/* There are more than 2 digits in the exponent.  See
+			   if we can delete some of the leading zeros */
+			if (significant_digit_cnt < MIN_EXPONENT_DIGITS)
+				significant_digit_cnt = MIN_EXPONENT_DIGITS;
+			extra_zeros_cnt = exponent_digit_cnt -
+				significant_digit_cnt;
+
+			/* Delete extra_zeros_cnt worth of characters from the
+			   front of the exponent */
+			assert(extra_zeros_cnt >= 0);
+
+			/* Add one to significant_digit_cnt to copy the
+			   trailing 0 byte, thus setting the length */
+			memmove(start,
+				start + extra_zeros_cnt,
+				significant_digit_cnt + 1);
+		}
+		else {
+			/* If there are fewer than 2 digits, add zeros
+			   until there are 2, if there's enough room */
+			int zeros = MIN_EXPONENT_DIGITS - exponent_digit_cnt;
+			if (start + zeros + exponent_digit_cnt + 1
+			      < buffer + buf_size) {
+				memmove(start + zeros, start,
+					exponent_digit_cnt + 1);
+				memset(start, '0', zeros);
+			}
+		}
+	}
+}
+
+/* Ensure that buffer has a decimal point in it.  The decimal point
+   will not be in the current locale, it will always be '.' */
+Py_LOCAL_INLINE(void)
+ensure_decimal_point(char* buffer, size_t buf_size)
+{
+	int insert_count = 0;
+	char* chars_to_insert;
+
+	/* search for the first non-digit character */
+	char *p = buffer;
+	while (*p && isdigit(Py_CHARMASK(*p)))
+		++p;
+
+	if (*p == '.') {
+		if (isdigit(Py_CHARMASK(*(p+1)))) {
+			/* Nothing to do, we already have a decimal
+			   point and a digit after it */
+		}
+		else {
+			/* We have a decimal point, but no following
+			   digit.  Insert a zero after the decimal. */
+			++p;
+			chars_to_insert = "0";
+			insert_count = 1;
+		}
+	}
+	else {
+		chars_to_insert = ".0";
+		insert_count = 2;
+	}
+	if (insert_count) {
+		size_t buf_len = strlen(buffer);
+		if (buf_len + insert_count + 1 >= buf_size) {
+			/* If there is not enough room in the buffer
+			   for the additional text, just skip it.  It's
+			   not worth generating an error over. */
+		}
+		else {
+			memmove(p + insert_count, p,
+				buffer + strlen(buffer) - p + 1);
+			memcpy(p, chars_to_insert, insert_count);
+		}
+	}
+}
+
+/* Add the locale specific grouping characters to buffer.  Note
+   that any decimal point (if it's present) in buffer is already
+   locale-specific.  Return 0 on error, else 1. */
+Py_LOCAL_INLINE(int)
+add_thousands_grouping(char* buffer, size_t buf_size)
+{
+	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
+	   adding grouping. */
+	char *p = strstr(buffer, decimal_point);
+	if (!p) {
+		/* No decimal, use the entire string. */
+
+		/* If any exponent, adjust p. */
+		p = strpbrk(buffer, "eE");
+		if (!p)
+			/* No exponent and no decimal.  Use the entire
+			   string. */
+			p = pend;
+	}
+	/* 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;
+}
+
 /* see FORMATBUFLEN in unicodeobject.c */
 #define FLOAT_FORMATBUFLEN 120
 
@@ -222,7 +437,6 @@
 		   const char *format, 
 		   double      d)
 {
-	char *p;
 	char format_char;
 	size_t format_len = strlen(format);
 
@@ -277,144 +491,31 @@
 	/* Have PyOS_snprintf do the hard work */
 	PyOS_snprintf(buffer, buf_size, format, d);
 
-	/* Get the current local, and find the decimal point character (or
-	   string?).  Convert that string back to a dot.  Do not do this if
-	   using the 'n' (number) format code. */
-	if (format_char != 'n') {
-		struct lconv *locale_data = localeconv();
-		const char *decimal_point = locale_data->decimal_point;
-		size_t decimal_point_len = strlen(decimal_point);
-		size_t rest_len;
-
-		assert(decimal_point_len != 0);
+	/* Do various fixups on the return string */
 
-		if (decimal_point[0] != '.' || decimal_point[1] != 0) {
-			p = buffer;
-
-			if (*p == '+' || *p == '-')
-				p++;
-
-			while (isdigit(Py_CHARMASK(*p)))
-				p++;
-
-			if (strncmp(p, decimal_point,
-				    decimal_point_len) == 0) {
-				*p = '.';
-				p++;
-				if (decimal_point_len > 1) {
-					rest_len = strlen(p +
-						      (decimal_point_len - 1));
-					memmove(p, p + (decimal_point_len - 1),
-						rest_len);
-					p[rest_len] = 0;
-				}
-			}
-		}
-	}
+	/* Get the current locale, and find the decimal point string.
+	   Convert that string back to a dot.  Do not do this if using the
+	   'n' (number) format code, since we want to keep the localized
+	   decimal point in that case. */
+	if (format_char != 'n')
+		change_decimal_from_locale_to_dot(buffer);
 
 	/* If an exponent exists, ensure that the exponent is at least
 	   MIN_EXPONENT_DIGITS digits, providing the buffer is large enough
 	   for the extra zeros.  Also, if there are more than
 	   MIN_EXPONENT_DIGITS, remove as many zeros as possible until we get
 	   back to MIN_EXPONENT_DIGITS */
-	p = strpbrk(buffer, "eE");
-	if (p && (*(p + 1) == '-' || *(p + 1) == '+')) {
-		char *start = p + 2;
-		int exponent_digit_cnt = 0;
-		int leading_zero_cnt = 0;
-		int in_leading_zeros = 1;
-		int significant_digit_cnt;
-
-		p += 2;
-		while (*p && isdigit(Py_CHARMASK(*p))) {
-			if (in_leading_zeros && *p == '0')
-				++leading_zero_cnt;
-			if (*p != '0')
-				in_leading_zeros = 0;
-			++p;
-			++exponent_digit_cnt;
-		}
-
-		significant_digit_cnt = exponent_digit_cnt - leading_zero_cnt;
-		if (exponent_digit_cnt == MIN_EXPONENT_DIGITS) {
-			/* If there are 2 exactly digits, we're done,
-			   regardless of what they contain */
-		}
-		else if (exponent_digit_cnt > MIN_EXPONENT_DIGITS) {
-			int extra_zeros_cnt;
-
-			/* There are more than 2 digits in the exponent.  See
-			   if we can delete some of the leading zeros */
-			if (significant_digit_cnt < MIN_EXPONENT_DIGITS)
-				significant_digit_cnt = MIN_EXPONENT_DIGITS;
-			extra_zeros_cnt = exponent_digit_cnt -
-				significant_digit_cnt;
-
-			/* Delete extra_zeros_cnt worth of characters from the
-			   front of the exponent */
-			assert(extra_zeros_cnt >= 0);
-
-			/* Add one to significant_digit_cnt to copy the
-			   trailing 0 byte, thus setting the length */
-			memmove(start,
-				start + extra_zeros_cnt,
-				significant_digit_cnt + 1);
-		}
-		else {
-			/* If there are fewer than 2 digits, add zeros
-			   until there are 2, if there's enough room */
-			int zeros = MIN_EXPONENT_DIGITS - exponent_digit_cnt;
-			if (start + zeros + exponent_digit_cnt + 1
-			      < buffer + buf_size) {
-				memmove(start + zeros, start,
-					exponent_digit_cnt + 1);
-				memset(start, '0', zeros);
-			}
-		}
-	}
+	ensure_minumim_exponent_length(buffer, buf_size);
 
 	/* If format_char is 'Z', make sure we have at least one character
 	   after the decimal point (and make sure we have a decimal point). */
-	if (format_char == 'Z') {
-		int insert_count = 0;
-		char* chars_to_insert;
-
-		/* search for the first non-digit character */
-		p = buffer;
-		while (*p && isdigit(Py_CHARMASK(*p)))
-			++p;
+	if (format_char == 'Z')
+		ensure_decimal_point(buffer, buf_size);
 
-		if (*p == '.') {
-			if (isdigit(Py_CHARMASK(*(p+1)))) {
-				/* Nothing to do, we already have a decimal
-				   point and a digit after it */
-			}
-			else {
-				/* We have a decimal point, but no following
-				   digit.  Insert a zero after the decimal. */
-				++p;
-				chars_to_insert = "0";
-				insert_count = 1;
-			}
-		}
-		else {
-			chars_to_insert = ".0";
-			insert_count = 2;
-		}
-		if (insert_count) {
-			size_t buf_len = strlen(buffer);
-			if (buf_len + insert_count + 1 >= buf_size) {
-				/* If there is not enough room in the buffer
-				   for the additional text, just skip it.  It's
-				   not worth generating an error over. */
-			}
-			else {
-				memmove(p + insert_count, p,
-					buffer + strlen(buffer) - p + 1);
-				memcpy(p, chars_to_insert, insert_count);
-			}
-		}
-	}
+	/* If format_char is 'n', add the thousands grouping. */
+	if (format_char == 'n')
+		if (!add_thousands_grouping(buffer, buf_size))
+			return NULL;
 
 	return buffer;
 }

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	Sun May  4 12:13:28 2008
@@ -173,7 +173,7 @@
 	PyObject *tmp_type, *tmp_value, *tmp_tb;
 
 	if (PyErr_WarnPy3k("sys.exc_clear() not supported in 3.x; "
-		       "use except clauses", 1) < 0)
+			   "use except clauses", 1) < 0)
 		return NULL;
 
 	tstate = PyThreadState_GET();

Modified: python/branches/tlee-ast-optimize/Python/traceback.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/traceback.c	(original)
+++ python/branches/tlee-ast-optimize/Python/traceback.c	Sun May  4 12:13:28 2008
@@ -222,8 +222,6 @@
 	err = PyFile_WriteString(linebuf, f);
 	if (err != 0)
 		return err;
-
-        err = PyFile_WriteString("    ", f);
         return Py_DisplaySourceLine(f, filename, lineno);
 }
 

Modified: python/branches/tlee-ast-optimize/configure
==============================================================================
--- python/branches/tlee-ast-optimize/configure	(original)
+++ python/branches/tlee-ast-optimize/configure	Sun May  4 12:13:28 2008
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 62451 .
+# From configure.in Revision: 62499 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for python 2.6.
 #
@@ -658,6 +658,7 @@
 CONFIG_ARGS
 UNIVERSALSDK
 PYTHONFRAMEWORK
+PYTHONFRAMEWORKIDENTIFIER
 PYTHONFRAMEWORKDIR
 PYTHONFRAMEWORKPREFIX
 PYTHONFRAMEWORKINSTALLDIR
@@ -1327,6 +1328,9 @@
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-framework-name=FRAMEWORK
+                          specify an alternate name of the framework built
+                          with --enable-framework
   --without-gcc           never use gcc
   --with-cxx-main=<compiler>
                           compile main() and link python executable with C++
@@ -1879,6 +1883,22 @@
 
 
 
+
+# Check whether --with-framework-name was given.
+if test "${with_framework_name+set}" = set; then
+  withval=$with_framework_name;
+    PYTHONFRAMEWORK=${withval}
+    PYTHONFRAMEWORKDIR=${withval}.framework
+    PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr 'A-Z' 'a-z'`
+
+else
+
+    PYTHONFRAMEWORK=Python
+    PYTHONFRAMEWORKDIR=Python.framework
+    PYTHONFRAMEWORKIDENTIFIER=org.python.python
+
+fi
+
 # Check whether --enable-framework was given.
 if test "${enable_framework+set}" = set; then
   enableval=$enable_framework;
@@ -1904,8 +1924,6 @@
 		enable_framework=
 		;;
 	*)
-		PYTHONFRAMEWORK=Python
-		PYTHONFRAMEWORKDIR=Python.framework
 		PYTHONFRAMEWORKPREFIX=$enableval
 		PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
 		FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
@@ -1919,7 +1937,7 @@
 		fi
 		prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
 
-		# Add makefiles for Mac specific code to the list of output
+		# Add files for Mac specific code to the list of output
 		# files:
 		ac_config_files="$ac_config_files Mac/Makefile"
 
@@ -1927,6 +1945,10 @@
 
 		ac_config_files="$ac_config_files Mac/IDLE/Makefile"
 
+		ac_config_files="$ac_config_files Mac/Resources/framework/Info.plist"
+
+		ac_config_files="$ac_config_files Mac/Resources/app/Info.plist"
+
 	esac
 
 else
@@ -1958,6 +1980,7 @@
 
 
 
+
 ##AC_ARG_WITH(dyld,
 ##            AC_HELP_STRING(--with-dyld,
 ##                           Use (OpenStep|Rhapsody) dynamic linker))
@@ -24579,6 +24602,8 @@
     "Mac/Makefile") CONFIG_FILES="$CONFIG_FILES Mac/Makefile" ;;
     "Mac/PythonLauncher/Makefile") CONFIG_FILES="$CONFIG_FILES Mac/PythonLauncher/Makefile" ;;
     "Mac/IDLE/Makefile") CONFIG_FILES="$CONFIG_FILES Mac/IDLE/Makefile" ;;
+    "Mac/Resources/framework/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/framework/Info.plist" ;;
+    "Mac/Resources/app/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/app/Info.plist" ;;
     "Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;;
     "Modules/Setup.config") CONFIG_FILES="$CONFIG_FILES Modules/Setup.config" ;;
 
@@ -24684,6 +24709,7 @@
 CONFIG_ARGS!$CONFIG_ARGS$ac_delim
 UNIVERSALSDK!$UNIVERSALSDK$ac_delim
 PYTHONFRAMEWORK!$PYTHONFRAMEWORK$ac_delim
+PYTHONFRAMEWORKIDENTIFIER!$PYTHONFRAMEWORKIDENTIFIER$ac_delim
 PYTHONFRAMEWORKDIR!$PYTHONFRAMEWORKDIR$ac_delim
 PYTHONFRAMEWORKPREFIX!$PYTHONFRAMEWORKPREFIX$ac_delim
 PYTHONFRAMEWORKINSTALLDIR!$PYTHONFRAMEWORKINSTALLDIR$ac_delim
@@ -24738,7 +24764,6 @@
 CFLAGSFORSHARED!$CFLAGSFORSHARED$ac_delim
 SHLIBS!$SHLIBS$ac_delim
 USE_SIGNAL_MODULE!$USE_SIGNAL_MODULE$ac_delim
-SIGNAL_OBJS!$SIGNAL_OBJS$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -24780,6 +24805,7 @@
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
+SIGNAL_OBJS!$SIGNAL_OBJS$ac_delim
 USE_THREAD_MODULE!$USE_THREAD_MODULE$ac_delim
 LDLAST!$LDLAST$ac_delim
 THREADOBJ!$THREADOBJ$ac_delim
@@ -24801,7 +24827,7 @@
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 19; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 20; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

Modified: python/branches/tlee-ast-optimize/configure.in
==============================================================================
--- python/branches/tlee-ast-optimize/configure.in	(original)
+++ python/branches/tlee-ast-optimize/configure.in	Sun May  4 12:13:28 2008
@@ -83,6 +83,18 @@
 ])
 AC_SUBST(UNIVERSALSDK)
 
+AC_ARG_WITH(framework-name,
+              AC_HELP_STRING(--with-framework-name=FRAMEWORK, 
+                             specify an alternate name of the framework built with --enable-framework),
+[
+    PYTHONFRAMEWORK=${withval}
+    PYTHONFRAMEWORKDIR=${withval}.framework
+    PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
+    ],[
+    PYTHONFRAMEWORK=Python
+    PYTHONFRAMEWORKDIR=Python.framework
+    PYTHONFRAMEWORKIDENTIFIER=org.python.python
+])
 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
 AC_ARG_ENABLE(framework,
               AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
@@ -109,8 +121,6 @@
 		enable_framework=
 		;;
 	*)
-		PYTHONFRAMEWORK=Python
-		PYTHONFRAMEWORKDIR=Python.framework
 		PYTHONFRAMEWORKPREFIX=$enableval
 		PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
 		FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
@@ -124,11 +134,13 @@
 		fi
 		prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
 
-		# Add makefiles for Mac specific code to the list of output
+		# Add files for Mac specific code to the list of output
 		# files:
 		AC_CONFIG_FILES(Mac/Makefile)
 		AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
 		AC_CONFIG_FILES(Mac/IDLE/Makefile)
+		AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
+		AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
 	esac
 	],[
 	PYTHONFRAMEWORK=
@@ -147,6 +159,7 @@
 	enable_framework=
 ])
 AC_SUBST(PYTHONFRAMEWORK)
+AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
 AC_SUBST(PYTHONFRAMEWORKDIR)
 AC_SUBST(PYTHONFRAMEWORKPREFIX)
 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)


More information about the Python-checkins mailing list