[Python-checkins] r64454 - in python/branches/tlee-ast-optimize: Doc/library/ast.rst Doc/library/cgi.rst Doc/library/commands.rst Doc/library/decimal.rst Doc/library/os.path.rst Doc/library/os.rst Doc/library/popen2.rst Doc/library/pprint.rst Doc/library/py_compile.rst Doc/library/stdtypes.rst Doc/library/subprocess.rst Doc/library/zlib.rst Doc/whatsnew/2.6.rst Include/object.h Lib/ast.py Lib/cgi.py Lib/fractions.py Lib/pprint.py Lib/test/test_builtin.py Lib/test/test_cgi.py Lib/test/test_fractions.py Lib/test/test_pprint.py Lib/test/test_slice.py Lib/test/test_sys.py Makefile.pre.in Misc/NEWS Modules/mathmodule.c Objects/bytearrayobject.c Objects/floatobject.c Objects/intobject.c Objects/longobject.c Objects/sliceobject.c Objects/typeobject.c Python/bltinmodule.c

thomas.lee python-checkins at python.org
Sun Jun 22 15:47:10 CEST 2008


Author: thomas.lee
Date: Sun Jun 22 15:47:08 2008
New Revision: 64454

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

........
  r64420 | andrew.kuchling | 2008-06-20 12:05:57 +1000 (Fri, 20 Jun 2008) | 1 line
  
  Various items
........
  r64421 | andrew.kuchling | 2008-06-20 12:11:42 +1000 (Fri, 20 Jun 2008) | 1 line
  
  Fix comment typos
........
  r64422 | benjamin.peterson | 2008-06-20 12:47:03 +1000 (Fri, 20 Jun 2008) | 1 line
  
  add multiprocessing to the Makefile
........
  r64424 | raymond.hettinger | 2008-06-20 14:18:15 +1000 (Fri, 20 Jun 2008) | 1 line
  
  Make bin() implementation parallel oct() and hex() so that int/long subclasses can override or so that other classes can support.
........
  r64425 | andrew.kuchling | 2008-06-20 21:39:54 +1000 (Fri, 20 Jun 2008) | 1 line
  
  Various items
........
  r64426 | mark.dickinson | 2008-06-21 00:53:43 +1000 (Sat, 21 Jun 2008) | 4 lines
  
  Issue #3004:  Minor fix to slice.indices().  slice(-10).indices(9) now
  returns (0, 0, 1) instead of (0, -1, 1), and slice(None, 10, -1).indices(10)
  returns (9, 9, -1) instead of (9, 10, -1).
........
  r64427 | mark.dickinson | 2008-06-21 01:17:41 +1000 (Sat, 21 Jun 2008) | 2 lines
  
  Fix outdated count of the number of new math module functions.
........
  r64428 | mark.dickinson | 2008-06-21 01:26:19 +1000 (Sat, 21 Jun 2008) | 2 lines
  
  Fix another typo in math_sum comment
........
  r64429 | georg.brandl | 2008-06-21 05:28:18 +1000 (Sat, 21 Jun 2008) | 2 lines
  
  Change references to the new math functions to generate proper x-refs.
........
  r64431 | benjamin.peterson | 2008-06-21 06:33:33 +1000 (Sat, 21 Jun 2008) | 1 line
  
  rephrase
........
  r64434 | andrew.kuchling | 2008-06-21 09:13:58 +1000 (Sat, 21 Jun 2008) | 1 line
  
  Remove request for e-mail; it's unlikely these classes will be saved
........
  r64435 | andrew.kuchling | 2008-06-21 09:14:32 +1000 (Sat, 21 Jun 2008) | 1 line
  
  Grammar fixes
........
  r64436 | andrew.kuchling | 2008-06-21 09:43:12 +1000 (Sat, 21 Jun 2008) | 1 line
  
  Various items
........
  r64437 | andrew.kuchling | 2008-06-21 10:17:22 +1000 (Sat, 21 Jun 2008) | 1 line
  
  Correct two versionchanged directives, to improve the 'changes' output
........
  r64438 | raymond.hettinger | 2008-06-21 16:39:53 +1000 (Sat, 21 Jun 2008) | 1 line
  
  Issue 3008: hex/oct/bin can show floats exactly.
........
  r64439 | hyeshik.chang | 2008-06-21 21:15:30 +1000 (Sat, 21 Jun 2008) | 2 lines
  
  Fix build on FreeBSD gcc.
........
  r64440 | andrew.kuchling | 2008-06-21 23:29:12 +1000 (Sat, 21 Jun 2008) | 1 line
  
  Docstring typo
........
  r64441 | andrew.kuchling | 2008-06-21 23:47:20 +1000 (Sat, 21 Jun 2008) | 1 line
  
  Use repr() for bad input strings; this makes the empty string or binary characters more visible
........
  r64442 | andrew.kuchling | 2008-06-21 23:48:38 +1000 (Sat, 21 Jun 2008) | 1 line
  
  Docstring correction
........
  r64443 | georg.brandl | 2008-06-22 00:26:19 +1000 (Sun, 22 Jun 2008) | 2 lines
  
  Documentation fix.
........
  r64445 | facundo.batista | 2008-06-22 03:30:06 +1000 (Sun, 22 Jun 2008) | 3 lines
  
  
  Reviewed and updated the documentation. Fixes #3017.
........
  r64446 | facundo.batista | 2008-06-22 03:43:56 +1000 (Sun, 22 Jun 2008) | 4 lines
  
  
  Fixed issue #2888. Now the behaviour of pprint when working with nested
  structures follows the common sense (and works like in 2.5 and 3.0).
........
  r64447 | facundo.batista | 2008-06-22 04:58:04 +1000 (Sun, 22 Jun 2008) | 6 lines
  
  
  Now a from submitted via POST that also has a query string
  will contain both FieldStorage and MiniFieldStorage items.
  
  Fixes #1817.
........
  r64448 | facundo.batista | 2008-06-22 05:48:19 +1000 (Sun, 22 Jun 2008) | 5 lines
  
  
  In the deprecated functions I added an alert to review
  specially a section of the subprocess documentation
  that helps with the replacing of those functionss.
........
  r64450 | georg.brandl | 2008-06-22 19:05:29 +1000 (Sun, 22 Jun 2008) | 2 lines
  
  Turn section references into proper cross-references.
........


Modified:
   python/branches/tlee-ast-optimize/   (props changed)
   python/branches/tlee-ast-optimize/Doc/library/ast.rst
   python/branches/tlee-ast-optimize/Doc/library/cgi.rst
   python/branches/tlee-ast-optimize/Doc/library/commands.rst
   python/branches/tlee-ast-optimize/Doc/library/decimal.rst
   python/branches/tlee-ast-optimize/Doc/library/os.path.rst
   python/branches/tlee-ast-optimize/Doc/library/os.rst
   python/branches/tlee-ast-optimize/Doc/library/popen2.rst
   python/branches/tlee-ast-optimize/Doc/library/pprint.rst
   python/branches/tlee-ast-optimize/Doc/library/py_compile.rst
   python/branches/tlee-ast-optimize/Doc/library/stdtypes.rst
   python/branches/tlee-ast-optimize/Doc/library/subprocess.rst
   python/branches/tlee-ast-optimize/Doc/library/zlib.rst
   python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst
   python/branches/tlee-ast-optimize/Include/object.h
   python/branches/tlee-ast-optimize/Lib/ast.py
   python/branches/tlee-ast-optimize/Lib/cgi.py
   python/branches/tlee-ast-optimize/Lib/fractions.py
   python/branches/tlee-ast-optimize/Lib/pprint.py
   python/branches/tlee-ast-optimize/Lib/test/test_builtin.py
   python/branches/tlee-ast-optimize/Lib/test/test_cgi.py
   python/branches/tlee-ast-optimize/Lib/test/test_fractions.py
   python/branches/tlee-ast-optimize/Lib/test/test_pprint.py
   python/branches/tlee-ast-optimize/Lib/test/test_slice.py
   python/branches/tlee-ast-optimize/Lib/test/test_sys.py
   python/branches/tlee-ast-optimize/Makefile.pre.in
   python/branches/tlee-ast-optimize/Misc/NEWS
   python/branches/tlee-ast-optimize/Modules/mathmodule.c
   python/branches/tlee-ast-optimize/Objects/bytearrayobject.c
   python/branches/tlee-ast-optimize/Objects/floatobject.c
   python/branches/tlee-ast-optimize/Objects/intobject.c
   python/branches/tlee-ast-optimize/Objects/longobject.c
   python/branches/tlee-ast-optimize/Objects/sliceobject.c
   python/branches/tlee-ast-optimize/Objects/typeobject.c
   python/branches/tlee-ast-optimize/Python/bltinmodule.c

Modified: python/branches/tlee-ast-optimize/Doc/library/ast.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/ast.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/ast.rst	Sun Jun 22 15:47:08 2008
@@ -258,5 +258,5 @@
    debugging purposes.  The returned string will show the names and the values
    for fields.  This makes the code impossible to evaluate, so if evaluation is
    wanted *annotate_fields* must be set to False.  Attributes such as line
-   numbers and column offsets are dumped by default.  If this is wanted,
+   numbers and column offsets are not dumped by default.  If this is wanted,
    *include_attributes* can be set to ``True``.

Modified: python/branches/tlee-ast-optimize/Doc/library/cgi.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/cgi.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/cgi.rst	Sun Jun 22 15:47:08 2008
@@ -165,6 +165,8 @@
 actually be instances of the class :class:`MiniFieldStorage`.  In this case, the
 :attr:`list`, :attr:`file`, and :attr:`filename` attributes are always ``None``.
 
+A form submitted via POST that also has a query string will contain both
+:class:`FieldStorage` and :class:`MiniFieldStorage` items.
 
 Higher Level Interface
 ----------------------
@@ -264,9 +266,7 @@
 with the same name.
 
 Other classes (:class:`FormContent`, :class:`InterpFormContentDict`) are present
-for backwards compatibility with really old applications only. If you still use
-these and would be inconvenienced when they disappeared from a next version of
-this module, drop me a note.
+for backwards compatibility with really old applications only.
 
 
 .. _functions-in-cgi-module:

Modified: python/branches/tlee-ast-optimize/Doc/library/commands.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/commands.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/commands.rst	Sun Jun 22 15:47:08 2008
@@ -47,7 +47,7 @@
    the argument.
 
    .. deprecated:: 2.6
-      This function is nonobvious and useless, also the name is misleading in the
+      This function is nonobvious and useless.  The name is also misleading in the
       presence of :func:`getstatusoutput`.
 
 

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 Jun 22 15:47:08 2008
@@ -140,6 +140,7 @@
 :const:`NaN` which stands for "Not a number", positive and negative
 :const:`Infinity`, and :const:`-0`.
 
+   >>> getcontext().prec = 28
    >>> Decimal(10)
    Decimal('10')
    >>> Decimal('3.14')
@@ -206,6 +207,7 @@
 
 And some mathematical functions are also available to Decimal:
 
+   >>> getcontext().prec = 28
    >>> Decimal(2).sqrt()
    Decimal('1.414213562373095048801688724')
    >>> Decimal(1).exp()
@@ -434,6 +436,13 @@
 
       .. versionadded:: 2.6
 
+   .. method:: conjugate()
+
+      Just returns self, this method is only to comply with the Decimal
+      Specification.
+
+      .. versionadded:: 2.6
+
    .. method:: copy_abs()
 
       Return the absolute value of the argument.  This operation is unaffected
@@ -812,15 +821,6 @@
          renamed from ``to_integral`` to ``to_integral_value``.  The old name
          remains valid for compatibility.
 
-   .. method:: trim()
-
-      Return the decimal with *insignificant* trailing zeros removed.  Here, a
-      trailing zero is considered insignificant either if it follows the decimal
-      point, or if the exponent of the argument (that is, the last element of
-      the :meth:`as_tuple` representation) is positive.
-
-      .. versionadded:: 2.6
-
 .. _logical_operands_label:
 
 Logical operands
@@ -1036,6 +1036,46 @@
       Return the sum of *x* and *y*.
 
 
+   .. method:: canonical(x)
+
+      Returns the same Decimal object *x*.
+
+
+   .. method:: compare(x, y)
+
+      Compares *x* and *y* numerically.
+
+
+   .. method:: compare_signal(x, y)
+
+      Compares the values of the two operands numerically.
+
+
+   .. method:: compare_total(x, y)
+
+      Compares two operands using their abstract representation.
+
+
+   .. method:: compare_total_mag(x, y)
+
+      Compares two operands using their abstract representation, ignoring sign.
+
+
+   .. method:: copy_abs(x)
+
+      Returns a copy of *x* with the sign set to 0.
+
+
+   .. method:: copy_negate(x)
+
+      Returns a copy of *x* with the sign inverted.
+
+
+   .. method:: copy_sign(x, y)
+
+      Copies the sign from *y* to *x*.
+
+
    .. method:: divide(x, y)
 
       Return *x* divided by *y*.
@@ -1051,6 +1091,121 @@
       Divides two numbers and returns the integer part of the result.
 
 
+   .. method:: exp(x)
+
+      Returns `e ** x`.
+
+
+   .. method:: fma(x, y, z)
+
+      Returns *x* multiplied by *y*, plus *z*.
+
+
+   .. method:: is_canonical(x)
+
+      Returns True if *x* is canonical; otherwise returns False.
+
+
+   .. method:: is_finite(x)
+
+      Returns True if *x* is finite; otherwise returns False.
+
+
+   .. method:: is_infinite(x)
+
+      Returns True if *x* is infinite; otherwise returns False.
+
+
+   .. method:: is_nan(x)
+
+      Returns True if *x* is a qNaN or sNaN; otherwise returns False.
+
+
+   .. method:: is_normal(x)
+
+      Returns True if *x* is a normal number; otherwise returns False.
+
+
+   .. method:: is_qnan(x)
+
+      Returns True if *x* is a quiet NaN; otherwise returns False.
+
+
+   .. method:: is_signed(x)
+
+      Returns True if *x* is negative; otherwise returns False.
+
+
+   .. method:: is_snan(x)
+
+      Returns True if *x* is a signaling NaN; otherwise returns False.
+
+
+   .. method:: is_subnormal(x)
+
+      Returns True if *x* is subnormal; otherwise returns False.
+
+
+   .. method:: is_zero(x)
+
+      Returns True if *x* is a zero; otherwise returns False.
+
+
+   .. method:: ln(x)
+
+      Returns the natural (base e) logarithm of *x*.
+
+
+   .. method:: log10(x)
+
+      Returns the base 10 logarithm of *x*.
+
+
+   .. method:: logb(x)
+
+       Returns the exponent of the magnitude of the operand's MSD.
+
+
+   .. method:: logical_and(x, y)
+
+      Applies the logical operation `and` between each operand's digits.
+
+
+   .. method:: logical_invert(x)
+
+      Invert all the digits in *x*.
+
+
+   .. method:: logical_or(x, y)
+
+      Applies the logical operation `or` between each operand's digits.
+
+
+   .. method:: logical_xor(x, y)
+
+      Applies the logical operation `xor` between each operand's digits.
+
+
+   .. method:: max(x, y)
+
+      Compares two values numerically and returns the maximum.
+
+
+   .. method:: max_mag(x, y)
+
+      Compares the values numerically with their sign ignored.
+
+
+   .. method:: min(x, y)
+
+      Compares two values numerically and returns the minimum.
+
+
+   .. method:: min_mag(x, y)
+
+      Compares the values numerically with their sign ignored.
+
+
    .. method:: minus(x)
 
       Minus corresponds to the unary prefix minus operator in Python.
@@ -1061,6 +1216,31 @@
       Return the product of *x* and *y*.
 
 
+   .. method:: next_minus(x)
+
+      Returns the largest representable number smaller than *x*.
+
+
+   .. method:: next_plus(x)
+
+      Returns the smallest representable number larger than *x*.
+
+
+   .. method:: next_toward(x, y)
+
+      Returns the number closest to *x*, in direction towards *y*.
+
+
+   .. method:: normalize(x)
+
+      Reduces *x* to its simplest form.
+
+
+   .. method:: number_class(x)
+
+      Returns an indication of the class of *x*.
+
+
    .. method:: plus(x)
 
       Plus corresponds to the unary prefix plus operator in Python.  This
@@ -1095,6 +1275,16 @@
          Stricter requirements for the three-argument version.
 
 
+   .. method:: quantize(x, y)
+
+      Returns a value equal to *x* (rounded), having the exponent of *y*.
+
+
+   .. method:: radix()
+
+      Just returns 10, as this is Decimal, :)
+
+
    .. method:: remainder(x, y)
 
       Returns the remainder from integer division.
@@ -1102,10 +1292,52 @@
       The sign of the result, if non-zero, is the same as that of the original
       dividend.
 
+   .. method:: remainder_near(x, y)
+
+      Returns `x - y * n`, where *n* is the integer nearest the exact value
+      of `x / y` (if the result is `0` then its sign will be the sign of *x*).
+
+
+   .. method:: rotate(x, y)
+
+      Returns a rotated copy of *x*, *y* times.
+
+
+   .. method:: same_quantum(x, y)
+
+      Returns True if the two operands have the same exponent.
+
+
+   .. method:: scaleb (x, y)
+
+      Returns the first operand after adding the second value its exp.
+
+
+   .. method:: shift(x, y)
+
+      Returns a shifted copy of *x*, *y* times.
+
+
+   .. method:: sqrt(x)
+
+      Square root of a non-negative number to context precision.
+
+
    .. method:: subtract(x, y)
 
       Return the difference between *x* and *y*.
 
+
+   .. method:: to_eng_string(x)
+
+      Converts a number to a string, using scientific notation.
+
+
+   .. method:: to_integral_exact(x)
+
+      Rounds to an integer.
+
+
    .. method:: to_sci_string(x)
 
       Converts a number to a string using scientific notation.

Modified: python/branches/tlee-ast-optimize/Doc/library/os.path.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/os.path.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/os.path.rst	Sun Jun 22 15:47:08 2008
@@ -305,7 +305,7 @@
 
    .. warning::
 
-      This function is deprecated and is removed in 3.0 in favor of
+      This function is deprecated and has been removed in 3.0 in favor of
       :func:`os.walk`.
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/os.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/os.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/os.rst	Sun Jun 22 15:47:08 2008
@@ -362,7 +362,8 @@
    is returned. Availability: Macintosh, Unix, Windows.
 
    .. deprecated:: 2.6
-      This function is obsolete.  Use the :mod:`subprocess` module.
+      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
+      especially the :ref:`subprocess-replacements` section.
 
    .. versionchanged:: 2.0
       This function worked unreliably under Windows in earlier versions of Python.
@@ -411,8 +412,8 @@
    child_stdout)``.
 
    .. deprecated:: 2.6
-      All of the :func:`popen\*` functions are obsolete. Use the :mod:`subprocess`
-      module.
+      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
+      especially the :ref:`subprocess-replacements` section.
 
    Availability: Macintosh, Unix, Windows.
 
@@ -425,8 +426,8 @@
    child_stdout, child_stderr)``.
 
    .. deprecated:: 2.6
-      All of the :func:`popen\*` functions are obsolete. Use the :mod:`subprocess`
-      module.
+      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
+      especially the :ref:`subprocess-replacements` section.
 
    Availability: Macintosh, Unix, Windows.
 
@@ -439,8 +440,8 @@
    child_stdout_and_stderr)``.
 
    .. deprecated:: 2.6
-      All of the :func:`popen\*` functions are obsolete. Use the :mod:`subprocess`
-      module.
+      This function is obsolete.  Use the :mod:`subprocess` module.  Check 
+      especially the :ref:`subprocess-replacements` section.
 
    Availability: Macintosh, Unix, Windows.
 
@@ -1707,7 +1708,8 @@
 
    (Note that the :mod:`subprocess` module provides more powerful facilities for
    spawning new processes and retrieving their results; using that module is
-   preferable to using these functions.)
+   preferable to using these functions.  Check specially the *Replacing Older 
+   Functions with the subprocess Module* section in that documentation page.)
 
    If *mode* is :const:`P_NOWAIT`, this function returns the process id of the new
    process; if *mode* is :const:`P_WAIT`, returns the process's exit code if it
@@ -1842,7 +1844,8 @@
 
    The :mod:`subprocess` module provides more powerful facilities for spawning new
    processes and retrieving their results; using that module is preferable to using
-   this function.
+   this function.  Use the :mod:`subprocess` module.  Check especially the
+   :ref:`subprocess-replacements` section.
 
 
 .. function:: times()

Modified: python/branches/tlee-ast-optimize/Doc/library/popen2.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/popen2.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/popen2.rst	Sun Jun 22 15:47:08 2008
@@ -9,7 +9,8 @@
 
 
 .. deprecated:: 2.6
-   This module is obsolete.  Use the :mod:`subprocess` module.
+   This module is obsolete.  Use the :mod:`subprocess` module.  Check 
+   especially the :ref:`subprocess-replacements` section.
 
 This module allows you to spawn processes and connect to their
 input/output/error pipes and obtain their return codes under Unix and Windows.

Modified: python/branches/tlee-ast-optimize/Doc/library/pprint.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/pprint.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/pprint.rst	Sun Jun 22 15:47:08 2008
@@ -56,7 +56,7 @@
       >>> stuff.insert(0, stuff[:])
       >>> pp = pprint.PrettyPrinter(indent=4)
       >>> pp.pprint(stuff)
-      [   [   'spam', 'eggs', 'lumberjack', 'knights', 'ni'],
+      [   ['spam', 'eggs', 'lumberjack', 'knights', 'ni'],
           'spam',
           'eggs',
           'lumberjack',

Modified: python/branches/tlee-ast-optimize/Doc/library/py_compile.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/py_compile.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/py_compile.rst	Sun Jun 22 15:47:08 2008
@@ -46,8 +46,7 @@
 could not be compiled.
 
 .. versionchanged:: 2.6
-
-   Added the nonzero exit status.
+   Added the nonzero exit status when module is run as a script.
 
 
 .. seealso::

Modified: python/branches/tlee-ast-optimize/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/stdtypes.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/stdtypes.rst	Sun Jun 22 15:47:08 2008
@@ -2185,7 +2185,7 @@
 
 .. attribute:: file.errors
 
-   The Unicode error handler used to along with the encoding.
+   The Unicode error handler used along with the encoding.
 
    .. versionadded:: 2.6
 

Modified: python/branches/tlee-ast-optimize/Doc/library/subprocess.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/subprocess.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/subprocess.rst	Sun Jun 22 15:47:08 2008
@@ -273,6 +273,8 @@
    ``N`` (Unix only).
 
 
+.. _subprocess-replacements:
+
 Replacing Older Functions with the subprocess Module
 ----------------------------------------------------
 

Modified: python/branches/tlee-ast-optimize/Doc/library/zlib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/zlib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/zlib.rst	Sun Jun 22 15:47:08 2008
@@ -44,9 +44,9 @@
 
    This function always returns an integer object.
 
-.. versionchanged:: 2.6
-   For consistent cross-platform behavior we always return a signed integer.
-   ie: Results in the (2**31)...(2**32-1) range will be negative.
+   .. versionchanged:: 2.6
+     For consistent cross-platform behavior we always return a signed integer.
+     ie: Results in the (2**31)...(2**32-1) range will be negative.
 
 
 .. function:: compress(string[, level])
@@ -82,9 +82,9 @@
 
    This function always returns an integer object.
 
-.. versionchanged:: 2.6
-   For consistent cross-platform behavior we always return a signed integer.
-   ie: Results in the (2**31)...(2**32-1) range will be negative.
+   .. versionchanged:: 2.6
+     For consistent cross-platform behavior we always return a signed integer.
+     ie: Results in the (2**31)...(2**32-1) range will be negative.
 
 
 .. function:: decompress(string[, wbits[, bufsize]])

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 Jun 22 15:47:08 2008
@@ -532,7 +532,7 @@
 
    :pep:`371` - Per-user ``site-packages`` Directory
      PEP written by Jesse Noller and Richard Oudkerk; 
-     implemented by Jesse Noller.
+     implemented by Richard Oudkerk and Jesse Noller.
 
 .. ======================================================================
 
@@ -762,7 +762,7 @@
 PEP 3112: Byte Literals
 =====================================================
 
-Python 3.0 adopts Unicode as the language's fundamental string type, and
+Python 3.0 adopts Unicode as the language's fundamental string type and
 denotes 8-bit literals differently, either as ``b'string'``
 or using a :class:`bytes` constructor.  For future compatibility,
 Python 2.6 adds :class:`bytes` as a synonym for the :class:`str` type,
@@ -780,7 +780,38 @@
 
     print len(s)               # 12 Unicode characters
 
-
+At the C level, Python 3.0 will rename the existing 8-bit 
+string type, called :ctype:`PyStringObject` in Python 2.x, 
+to :ctype:`PyBytesObject`.  Python 2.6 uses ``#define``
+to support using the names :cfunc:`PyBytesObject`, 
+:cfunc:`PyBytes_Check`, :cfunc:`PyBytes_FromStringAndSize`,
+and all the other functions and macros used with strings.
+
+Instances of the :class:`bytes` type are immutable just 
+as strings are.  A new :class:`bytearray` type stores a mutable 
+sequence of bytes::
+
+    >>> bytearray([65, 66, 67])
+    bytearray(b'ABC')
+    >>> b = bytearray(u'\u21ef\u3244', 'utf-8')
+    >>> b
+    bytearray(b'\xe2\x87\xaf \xe3\x89\x84')
+    >>> b[0] = '\xe3'
+    >>> b
+    bytearray(b'\xe3\x87\xaf \xe3\x89\x84')
+    >>> unicode(str(b), 'utf-8')
+    u'\u31ef \u3244'
+
+Byte arrays support most of the methods of string types, such as 
+:meth:`startswith`/:meth:`endswith`, :meth:`find`/:meth:`rfind`,
+and some of the methods of lists, such as :meth:`append`, 
+:meth:`pop`,  and :meth:`reverse`.
+
+    >>> b = bytearray('ABC')
+    >>> b.append('d')
+    >>> b.append(ord('e'))
+    >>> b
+    bytearray(b'ABCde')
 
 .. seealso::
 
@@ -1205,11 +1236,11 @@
 The :mod:`fractions` Module
 --------------------------------------------------
 
-To fill out the hierarchy of numeric types, a rational-number class
-has been added as the :mod:`fractions` module.  Rational numbers are
-represented as a fraction, and can exactly represent
-numbers such as two-thirds that floating-point numbers can only
-approximate.
+To fill out the hierarchy of numeric types, a rational-number class is
+provided by the :mod:`fractions` module.  Rational numbers store their
+values as a numerator and denominator forming a fraction, and can
+exactly represent numbers such as ``2/3`` that floating-point numbers
+can only approximate.
 
 The :class:`Fraction` constructor takes two :class:`Integral` values
 that will be the numerator and denominator of the resulting fraction. ::
@@ -1252,6 +1283,14 @@
 
 Here are all of the changes that Python 2.6 makes to the core Python language.
 
+* The :func:`hasattr` function was catching and ignoring all errors,
+  under the assumption that they meant a :meth:`__getattr__` method has 
+  failing somewhere and the return value of :func:`hasattr` would therefore
+  be ``False``.  This logic shouldn't be applied to 
+  :exc:`KeyboardInterrupt` and :exc:`SystemExit`, however; Python 2.6 will
+  no longer discard such exceptions when :func:`hasattr` encounters them.
+  (Fixed by Benjamin Peterson; :issue:`2196`.)
+
 * When calling a function using the ``**`` syntax to provide keyword
   arguments, you are no longer required to use a Python dictionary;
   any mapping will now work::
@@ -1313,18 +1352,26 @@
         def x(self, value):
             self._x = value / 2
 
+* Several methods of the built-in set types now accept multiple iterables:
+  :meth:`intersection`, 
+  :meth:`intersection_update`, 
+  :meth:`union`, :meth:`update`,
+  :meth:`difference` and :meth:`difference_update`.
 
-* C functions and methods that use
-  :cfunc:`PyComplex_AsCComplex` will now accept arguments that
-  have a :meth:`__complex__` method.  In particular, the functions in the
-  :mod:`cmath` module will now accept objects with this method.
-  This is a backport of a Python 3.0 change.
-  (Contributed by Mark Dickinson; :issue:`1675423`.)
+  ::
+
+    >>> s=set('1234567890')
+    >>> s.intersection('abc123', 'cdf246')  # Intersection between all inputs
+    set(['2'])
+    >>> s.difference('246', '789')
+    set(['1', '0', '3', '5'])
+
+  (Contributed by Raymond Hettinger.)
 
-  A numerical nicety: when creating a complex number from two floats
+* A numerical nicety: when creating a complex number from two floats
   on systems that support signed zeros (-0 and +0), the
   :func:`complex` constructor will now preserve the sign
-  of the zero.  (:issue:`1507`)
+  of the zero.  (Fixed by Mark T. Dickinson; :issue:`1507`)
 
 * More floating-point features were also added.  The :func:`float` function
   will now turn the strings ``+nan`` and ``-nan`` into the corresponding
@@ -1336,28 +1383,34 @@
   :func:`isnan`, return true if their floating-point argument is
   infinite or Not A Number.  (:issue:`1640`)
 
-* The :mod:`math` module has seven new functions, and the existing
+* The :mod:`math` module has a number of new functions, and the existing
   functions have been improved to give more consistent behaviour
   across platforms, especially with respect to handling of
   floating-point exceptions and IEEE 754 special values.
   The new functions are:
 
-  * :func:`isinf` and :func:`isnan` determine whether a given float is
-    a (positive or negative) infinity or a NaN (Not a Number),
-    respectively.
+  * :func:`~math.isinf` and :func:`~math.isnan` determine whether a given float
+    is a (positive or negative) infinity or a NaN (Not a Number), respectively.
 
-  * ``copysign(x, y)`` copies the sign bit of an IEEE 754 number,
+  * :func:`~math.copysign` copies the sign bit of an IEEE 754 number,
     returning the absolute value of *x* combined with the sign bit of
     *y*.  For example, ``math.copysign(1, -0.0)`` returns -1.0.
     (Contributed by Christian Heimes.)
 
-  * The inverse hyperbolic functions :func:`acosh`, :func:`asinh` and
-    :func:`atanh`.
+  * :func:`~math.factorial` computes the factorial of a number.
+    (Contributed by Raymond Hettinger; :issue:`2138`.)
 
-  * The function :func:`log1p`, returning the natural logarithm of
-    *1+x* (base *e*).
+  * :func:`~math.sum` adds up the stream of numbers from an iterable,
+    and is careful to avoid loss of precision by calculating partial sums.
+    (Contributed by Jean Brouwers; :issue:`2819`.)
 
-  There's also a new :func:`trunc` function as a result of the
+  * The inverse hyperbolic functions :func:`~math.acosh`, :func:`~math.asinh`
+    and :func:`~math.atanh`.
+
+  * The function :func:`~math.log1p`, returning the natural logarithm of *1+x*
+    (base *e*).
+
+  There's also a new :func:`trunc` built-in function as a result of the
   backport of `PEP 3141's type hierarchy for numbers <#pep-3141>`__.
 
   The existing math functions have been modified to follow the
@@ -1468,9 +1521,9 @@
 
 .. ======================================================================
 
-.. _new-26-interactive:
+.. _new-26-interpreter:
 
-Interactive Interpreter Changes
+Interpreter Changes
 -------------------------------
 
 Two command-line options have been reserved for use by other Python
@@ -1481,6 +1534,25 @@
 Jython, or IronPython.  If either option is used with Python 2.6, the
 interpreter will report that the option isn't currently used.
 
+It's now possible to prevent Python from writing :file:`.pyc` or
+:file:`.pyo` files on importing a module by supplying the :option:`-B`
+switch to the Python interpreter, or by setting the
+:envvar:`PYTHONDONTWRITEBYTECODE` environment variable before running
+the interpreter.  This setting is available to Python programs as the
+``sys.dont_write_bytecode`` variable, and can be changed by Python
+code to modify the interpreter's behaviour.  (Contributed by Neal
+Norwitz and Georg Brandl.)
+
+The encoding used for standard input, output, and standard error can
+be specified by setting the :envvar:`PYTHONIOENCODING` environment
+variable before running the interpreter.  The value should be a string 
+in the form ``**encoding**`` or ``**encoding**:**errorhandler**``.  
+The **encoding** part specifies the encoding's name, e.g. ``utf-8`` or
+``latin-1``; the optional **errorhandler** part specifies 
+what to do with characters that can't be handled by the encoding,
+and  should be one of "error", "ignore", or "replace".   (Contributed
+by Martin von Loewis.)
+
 .. ======================================================================
 
 New, Improved, and Deprecated Modules
@@ -1493,24 +1565,10 @@
 details.
 
 * (3.0-warning mode) Python 3.0 will feature a reorganized standard
-  library; many outdated modules are being dropped,
-  and some modules are being renamed or moved into packages.
+  library; many outdated modules are being dropped.
   Python 2.6 running in 3.0-warning mode will warn about these modules
   when they are imported.
 
-  The modules that have been renamed are:
-
-  * :mod:`ConfigParser` has become :mod:`configparser`.
-  * :mod:`copy_reg` has become :mod:`copyreg`.
-  * :mod:`htmlentitydefs` has become :mod:`html.entities`.
-  * :mod:`HTMLParser` has become :mod:`html.parser`.
-  * :mod:`repr` (the module) has become :mod:`reprlib`.
-  * :mod:`SocketServer` has become :mod:`socketserver`.
-  * :mod:`Tkinter` has become the :mod:`tkinter` package.
-  * :mod:`Queue` has become :mod:`queue`.
-
-  .. XXX no warnings anymore for renamed modules!
-
   The list of deprecated modules is:
   :mod:`audiodev`,
   :mod:`bgenlocations`,
@@ -1527,6 +1585,7 @@
   :mod:`imgfile`,
   :mod:`linuxaudiodev`,
   :mod:`mhlib`,
+  :mod:`mimetools`,
   :mod:`multifile`,
   :mod:`new`,
   :mod:`popen2`,
@@ -1599,6 +1658,11 @@
   :mod:`videoreader`,
   :mod:`WAIT`.
 
+* The :mod:`asyncore` and :mod:`asynchat` modules are 
+  being actively maintained again, and a number of patches and bugfixes 
+  were applied.  (Maintained by Josiah Carlson; see :issue:`1736190` for 
+  one patch.)
+
 * The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
   available, instead of restricting itself to protocol 1.
   (Contributed by W. Barnes; :issue:`1551443`.)
@@ -2033,11 +2097,15 @@
 
 * Long regular expression searches carried out by the  :mod:`re`
   module will now check for signals being delivered, so especially
-  long searches can now be interrupted.
+  time-consuming searches can now be interrupted.
   (Contributed by Josh Hoyt and Ralf Schmitt; :issue:`846388`.)
 
 * The :mod:`rgbimg` module has been removed.
 
+* The :mod:`rlcompleter` module's :meth:`Completer.complete()` method
+  will now ignore exceptions triggered while evaluating a name.
+  (Fixed by Lorenz Quack; :issue:`2250`.)
+
 * The :mod:`sched` module's :class:`scheduler` instances now
   have a read-only :attr:`queue` attribute that returns the
   contents of the scheduler's queue, represented as a list of
@@ -2257,7 +2325,8 @@
 
 * The :mod:`threading` module's :class:`Thread` objects 
   gained a :meth:`getIdent` method that returns the thread's 
-  identifier, a nonzero integer.  (Contributed by XXX; :issue:`2871`.)
+  identifier, a nonzero integer.  (Contributed by Gregory P. Smith; 
+  :issue:`2871`.)
 
 * The :mod:`timeit` module now accepts callables as well as strings
   for the statement being timed and for the setup code.
@@ -2268,6 +2337,11 @@
   the corresponding method. (Contributed by Erik Demaine;
   :issue:`1533909`.)
 
+* The :mod:`Tkinter` module now accepts lists and tuples for options,
+  separating the elements by spaces before passing the resulting value to 
+  Tcl/Tk.
+  (Contributed by Guilherme Polo; :issue:`2906`.)
+
 * The :mod:`turtle` module for turtle graphics was greatly enhanced by
   Gregor Lingl.  New features in the module include:
 
@@ -2330,7 +2404,7 @@
   instances. (:issue:`1330538`)  The code can also handle
   dates before 1900 (contributed by Ralf Schmitt; :issue:`2014`)
   and 64-bit integers represented by using ``<i8>`` in XML-RPC responses
-  (contributed by XXX; :issue:`2985`).
+  (contributed by Riku Lindblad; :issue:`2985`).
   
 * The :mod:`zipfile` module's :class:`ZipFile` class now has
   :meth:`extract` and :meth:`extractall` methods that will unpack
@@ -2358,6 +2432,93 @@
 .. ======================================================================
 .. whole new modules get described in subsections here
 
+The :mod:`ast` module
+----------------------
+
+The :mod:`ast` module provides an Abstract Syntax Tree representation
+of Python code.  For Python 2.6, Armin Ronacher contributed a set of
+helper functions that perform various common tasks.  These will be useful
+for HTML templating packages, code analyzers, and similar tools that
+process Python code. 
+
+The :func:`parse` function takes an expression and returns an AST.
+The :func:`dump` function outputs a representation of a tree, suitable
+for debugging::
+
+    import ast
+
+    t = ast.parse("""
+    d = {}
+    for i in 'abcdefghijklm':
+	d[i + i] = ord(i) - ord('a') + 1
+    print d
+    """)
+    print ast.dump(t)
+
+This outputs::
+
+    Module(body=[Assign(targets=[Name(id='d', ctx=Store())],
+    value=Dict(keys=[], values=[])), For(target=Name(id='i',
+    ctx=Store()), iter=Str(s='abcdefghijklm'),
+    body=[Assign(targets=[Subscript(value=Name(id='d', ctx=Load()),
+    slice=Index(value=BinOp(left=Name(id='i', ctx=Load()), op=Add(),
+    right=Name(id='i', ctx=Load()))), ctx=Store())],
+    value=BinOp(left=BinOp(left=Call(func=Name(id='ord', ctx=Load()),
+    args=[Name(id='i', ctx=Load())], keywords=[], starargs=None,
+    kwargs=None), op=Sub(), right=Call(func=Name(id='ord',
+    ctx=Load()), args=[Str(s='a')], keywords=[], starargs=None,
+    kwargs=None)), op=Add(), right=Num(n=1)))], orelse=[]),
+    Print(dest=None, values=[Name(id='d', ctx=Load())], nl=True)])
+
+The :func:`literal_eval` method takes a string or an AST
+representing a literal expression, one that contains a Python
+expression containing only strings, numbers, dictionaries, etc. but no
+statements or function calls, and returns the resulting value.  If you
+need to unserialize an expression but need to worry about security 
+and can't risk using an :func:`eval` call, :func:`literal_eval` will
+handle it safely::
+
+    >>> literal = '("a", "b", {2:4, 3:8, 1:2})'
+    >>> print ast.literal_eval(literal)
+    ('a', 'b', {1: 2, 2: 4, 3: 8})
+    >>> print ast.literal_eval('"a" + "b"')
+    Traceback (most recent call last):
+      ...
+    ValueError: malformed string
+
+The module also includes 
+:class:`NodeVisitor` and :class:`NodeTransformer` classes 
+for traversing and modifying an AST, and functions for common transformations such as changing line numbers.
+
+.. ======================================================================
+
+The :mod:`future_builtins` module
+--------------------------------------
+
+Python 3.0 makes various changes to the repertoire of built-in
+functions, and most of the changes can't be introduced in the Python
+2.x series because they would break compatibility.
+The :mod:`future_builtins` module provides versions 
+of these built-in functions that can be imported when writing 
+3.0-compatible code.
+
+The functions in this module currently include:
+
+* ``ascii(**obj**)``: equivalent to :func:`repr`.  In Python 3.0, 
+  :func:`repr` will return a Unicode string, while :func:`ascii` will 
+  return a pure ASCII bytestring.
+
+* ``filter(**predicate**, **iterable**)``, 
+  ``map(**func**, **iterable1**, ...)``: the 3.0 versions 
+  return iterators, differing from the 2.x built-ins that return lists.
+
+* ``hex(**value**)``, ``oct(**value**)``: instead of calling the 
+  :meth:`__hex__` or :meth:`__oct__` methods, these versions will 
+  call the :meth:`__index__` method and convert the result to hexadecimal
+  or octal.
+
+.. ======================================================================
+
 The :mod:`json` module
 ----------------------
 
@@ -2383,28 +2544,6 @@
 :mod:`json` (originally called simplejson) was written by Bob Ippolito.
 
 
-Improved SSL Support
---------------------------------------------------
-
-Bill Janssen made extensive improvements to Python 2.6's support for
-the Secure Sockets Layer by adding a new module, :mod:`ssl`, on top of
-the `OpenSSL <http://www.openssl.org/>`__ library.  This new module
-provides more control over the protocol negotiated, the X.509
-certificates used, and has better support for writing SSL servers (as
-opposed to clients) in Python.  The existing SSL support in the
-:mod:`socket` module hasn't been removed and continues to work,
-though it will be removed in Python 3.0.
-
-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.
-It's possible to specify whether a certificate is required, and to
-obtain certificate info by calling the :meth:`getpeercert` method.
-
-.. seealso::
-
-   The documentation for the :mod:`ssl` module.
-
-
 .. ======================================================================
 
 plistlib: A Property-List Parser
@@ -2444,6 +2583,28 @@
     # read/writePlist accepts file-like objects as well as paths.
     plistlib.writePlist(data_struct, sys.stdout)
 
+.. ======================================================================
+
+Improved SSL Support
+--------------------------------------------------
+
+Bill Janssen made extensive improvements to Python 2.6's support for
+the Secure Sockets Layer by adding a new module, :mod:`ssl`, on top of
+the `OpenSSL <http://www.openssl.org/>`__ library.  This new module
+provides more control over the protocol negotiated, the X.509
+certificates used, and has better support for writing SSL servers (as
+opposed to clients) in Python.  The existing SSL support in the
+:mod:`socket` module hasn't been removed and continues to work,
+though it will be removed in Python 3.0.
+
+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.
+It's possible to specify whether a certificate is required, and to
+obtain certificate info by calling the :meth:`getpeercert` method.
+
+.. seealso::
+
+   The documentation for the :mod:`ssl` module.
 
 .. ======================================================================
 
@@ -2457,6 +2618,13 @@
   See the :file:`PCbuild9` directory for the build files.
   (Implemented by Christian Heimes.)
 
+* On MacOS X, Python 2.6 can be compiled as a 4-way universal build.
+  The :program:`configure` script 
+  can take a :option:`--with-universal-archs=[32-bit|64-bit|all]`
+  switch, controlling whether the binaries are built for 32-bit
+  architectures (x86, PowerPC), 64-bit (x86-64 and PPC-64), or both.
+  (Contributed by Ronald Oussoren.)
+
 * Python now can only be compiled with C89 compilers (after 19
   years!).  This means that the Python source tree can now drop its
   own implementations of :cfunc:`memmove` and :cfunc:`strerror`, which
@@ -2504,6 +2672,13 @@
   representable), and several others.
   (Contributed by Christian Heimes; :issue:`1534`.)
 
+* C functions and methods that use
+  :cfunc:`PyComplex_AsCComplex` will now accept arguments that
+  have a :meth:`__complex__` method.  In particular, the functions in the
+  :mod:`cmath` module will now accept objects with this method.
+  This is a backport of a Python 3.0 change.
+  (Contributed by Mark Dickinson; :issue:`1675423`.)
+
 * Python's C API now includes two functions for case-insensitive string
   comparisons, ``PyOS_stricmp(char*, char*)``
   and ``PyOS_strnicmp(char*, char*, Py_ssize_t)``.
@@ -2585,6 +2760,11 @@
   registry reflection for 32-bit processes running on 64-bit systems.
   (:issue:`1753245`)
 
+* The :mod:`msilib` module's :class:`Record` object 
+  gained :meth:`GetInteger` and :meth:`GetString` methods that 
+  return field values as an integer or a string.  
+  (Contributed by Floris Bruynooghe; :issue:`2125`.)
+
 * The new default compiler on Windows is Visual Studio 2008 (VS 9.0). The
   build directories for Visual Studio 2003 (VS7.1) and 2005 (VS8.0)
   were moved into the PC/ directory. The new PCbuild directory supports

Modified: python/branches/tlee-ast-optimize/Include/object.h
==============================================================================
--- python/branches/tlee-ast-optimize/Include/object.h	(original)
+++ python/branches/tlee-ast-optimize/Include/object.h	Sun Jun 22 15:47:08 2008
@@ -267,6 +267,9 @@
 
 	/* Added in release 2.5 */
 	unaryfunc nb_index;
+
+	/* Added in release 2.6 */
+	unaryfunc nb_bin;
 } PyNumberMethods;
 
 typedef struct {

Modified: python/branches/tlee-ast-optimize/Lib/ast.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/ast.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/ast.py	Sun Jun 22 15:47:08 2008
@@ -73,7 +73,7 @@
     debugging purposes.  The returned string will show the names and the values
     for fields.  This makes the code impossible to evaluate, so if evaluation is
     wanted *annotate_fields* must be set to False.  Attributes such as line
-    numbers and column offsets are dumped by default.  If this is wanted,
+    numbers and column offsets are not dumped by default.  If this is wanted,
     *include_attributes* can be set to True.
     """
     def _format(node):

Modified: python/branches/tlee-ast-optimize/Lib/cgi.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/cgi.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/cgi.py	Sun Jun 22 15:47:08 2008
@@ -456,6 +456,7 @@
         self.strict_parsing = strict_parsing
         if 'REQUEST_METHOD' in environ:
             method = environ['REQUEST_METHOD'].upper()
+        self.qs_on_post = None
         if method == 'GET' or method == 'HEAD':
             if 'QUERY_STRING' in environ:
                 qs = environ['QUERY_STRING']
@@ -474,6 +475,8 @@
                 headers['content-type'] = "application/x-www-form-urlencoded"
             if 'CONTENT_TYPE' in environ:
                 headers['content-type'] = environ['CONTENT_TYPE']
+            if 'QUERY_STRING' in environ:
+                self.qs_on_post = environ['QUERY_STRING']
             if 'CONTENT_LENGTH' in environ:
                 headers['content-length'] = environ['CONTENT_LENGTH']
         self.fp = fp or sys.stdin
@@ -631,6 +634,8 @@
     def read_urlencoded(self):
         """Internal: read data in query string format."""
         qs = self.fp.read(self.length)
+        if self.qs_on_post:
+            qs += '&' + self.qs_on_post
         self.list = list = []
         for key, value in parse_qsl(qs, self.keep_blank_values,
                                     self.strict_parsing):
@@ -645,6 +650,12 @@
         if not valid_boundary(ib):
             raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,)
         self.list = []
+        if self.qs_on_post:
+            for key, value in parse_qsl(self.qs_on_post, self.keep_blank_values,
+                                        self.strict_parsing):
+                self.list.append(MiniFieldStorage(key, value))
+            FieldStorageClass = None
+
         klass = self.FieldStorageClass or self.__class__
         part = klass(self.fp, {}, ib,
                      environ, keep_blank_values, strict_parsing)

Modified: python/branches/tlee-ast-optimize/Lib/fractions.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/fractions.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/fractions.py	Sun Jun 22 15:47:08 2008
@@ -70,7 +70,7 @@
                 input = numerator
                 m = _RATIONAL_FORMAT.match(input)
                 if m is None:
-                    raise ValueError('Invalid literal for Fraction: ' + input)
+                    raise ValueError('Invalid literal for Fraction: %r' % input)
                 numerator = m.group('num')
                 decimal = m.group('decimal')
                 if decimal:

Modified: python/branches/tlee-ast-optimize/Lib/pprint.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/pprint.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/pprint.py	Sun Jun 22 15:47:08 2008
@@ -194,7 +194,7 @@
             else:
                 write('(')
                 endchar = ')'
-            if self._indent_per_level > 1:
+            if self._indent_per_level > 1 and sepLines:
                 write((self._indent_per_level - 1) * ' ')
             if length:
                 context[objid] = 1

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 Jun 22 15:47:08 2008
@@ -631,6 +631,15 @@
         self.assertEqual(hex(-16), '-0x10')
         self.assertEqual(hex(-16L), '-0x10L')
         self.assertRaises(TypeError, hex, {})
+        self.assertEqual(hex(3.125), '0x19 * 2.0 ** -3')
+        self.assertEqual(hex(0.0), '0x0 * 2.0 ** 0')
+        for sv in float('nan'), float('inf'), float('-inf'):
+            self.assertEqual(hex(sv), repr(sv))
+        for i in range(100):
+            x = random.expovariate(.05)
+            self.assertEqual(eval(hex(x)), x, (x, hex(x), eval(hex(x))))
+            self.assertEqual(eval(hex(-x)), -x)
+            self.assertEqual(hex(-x), ('-' + hex(x)))
 
     def test_id(self):
         id(None)
@@ -914,6 +923,15 @@
         self.assertEqual(oct(-100), '-0144')
         self.assertEqual(oct(-100L), '-0144L')
         self.assertRaises(TypeError, oct, ())
+        self.assertEqual(oct(3.125), '031 * 2.0 ** -3')
+        self.assertEqual(oct(0.0), '0 * 2.0 ** 0')
+        for sv in float('nan'), float('inf'), float('-inf'):
+            self.assertEqual(oct(sv), repr(sv))
+        for i in range(100):
+            x = random.expovariate(.05)
+            self.assertEqual(eval(oct(x)), x)
+            self.assertEqual(eval(oct(-x)), -x)
+            self.assertEqual(oct(-x), ('-' + oct(x)))
 
     def write_testfile(self):
         # NB the first 4 lines are also used to test input and raw_input, below
@@ -1466,6 +1484,15 @@
         self.assertEqual(bin(2**65-1), '0b' + '1' * 65)
         self.assertEqual(bin(-(2**65)), '-0b1' + '0' * 65)
         self.assertEqual(bin(-(2**65-1)), '-0b' + '1' * 65)
+        self.assertEqual(bin(3.125), '0b11001 * 2.0 ** -3')
+        self.assertEqual(bin(0.0), '0b0 * 2.0 ** 0')
+        for sv in float('nan'), float('inf'), float('-inf'):
+            self.assertEqual(bin(sv), repr(sv))
+        for i in range(100):
+            x = random.expovariate(.05)
+            self.assertEqual(eval(bin(x)), x)
+            self.assertEqual(eval(bin(-x)), -x)
+            self.assertEqual(bin(-x), ('-' + bin(x)))
 
 class TestSorted(unittest.TestCase):
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_cgi.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_cgi.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_cgi.py	Sun Jun 22 15:47:08 2008
@@ -130,6 +130,17 @@
 def first_second_elts(list):
     return map(lambda p:(p[0], p[1][0]), list)
 
+def gen_result(data, environ):
+    fake_stdin = StringIO(data)
+    fake_stdin.seek(0)
+    form = cgi.FieldStorage(fp=fake_stdin, environ=environ)
+
+    result = {}
+    for k, v in dict(form).items():
+        result[k] = type(v) is list and form.getlist(k) or v.value
+
+    return result
+
 class CgiTests(unittest.TestCase):
 
     def test_qsl(self):
@@ -278,6 +289,83 @@
                 got = getattr(fs.list[x], k)
                 self.assertEquals(got, exp)
 
+    _qs_result = {
+        'key1': 'value1',
+        'key2': ['value2x', 'value2y'],
+        'key3': 'value3',
+        'key4': 'value4'
+    }
+    def testQSAndUrlEncode(self):
+        data = "key2=value2x&key3=value3&key4=value4"
+        environ = {
+            'CONTENT_LENGTH':   str(len(data)),
+            'CONTENT_TYPE':     'application/x-www-form-urlencoded',
+            'QUERY_STRING':     'key1=value1&key2=value2y',
+            'REQUEST_METHOD':   'POST',
+        }
+        v = gen_result(data, environ)
+        self.assertEqual(self._qs_result, v)
+
+    def testQSAndFormData(self):
+        data = """
+---123
+Content-Disposition: form-data; name="key2"
+
+value2y
+---123
+Content-Disposition: form-data; name="key3"
+
+value3
+---123
+Content-Disposition: form-data; name="key4"
+
+value4
+---123--
+"""
+        environ = {
+            'CONTENT_LENGTH':   str(len(data)),
+            'CONTENT_TYPE':     'multipart/form-data; boundary=-123',
+            'QUERY_STRING':     'key1=value1&key2=value2x',
+            'REQUEST_METHOD':   'POST',
+        }
+        v = gen_result(data, environ)
+        self.assertEqual(self._qs_result, v)
+
+    def testQSAndFormDataFile(self):
+        data = """
+---123
+Content-Disposition: form-data; name="key2"
+
+value2y
+---123
+Content-Disposition: form-data; name="key3"
+
+value3
+---123
+Content-Disposition: form-data; name="key4"
+
+value4
+---123
+Content-Disposition: form-data; name="upload"; filename="fake.txt"
+Content-Type: text/plain
+
+this is the content of the fake file
+
+---123--
+"""
+        environ = {
+            'CONTENT_LENGTH':   str(len(data)),
+            'CONTENT_TYPE':     'multipart/form-data; boundary=-123',
+            'QUERY_STRING':     'key1=value1&key2=value2x',
+            'REQUEST_METHOD':   'POST',
+        }
+        result = self._qs_result.copy()
+        result.update({
+            'upload': 'this is the content of the fake file\n'
+        })
+        v = gen_result(data, environ)
+        self.assertEqual(result, v)
+
 def test_main():
     run_unittest(CgiTests)
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_fractions.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_fractions.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_fractions.py	Sun Jun 22 15:47:08 2008
@@ -86,38 +86,38 @@
             ZeroDivisionError, "Fraction(3, 0)",
             F, "3/0")
         self.assertRaisesMessage(
-            ValueError, "Invalid literal for Fraction: 3/",
+            ValueError, "Invalid literal for Fraction: '3/'",
             F, "3/")
         self.assertRaisesMessage(
-            ValueError, "Invalid literal for Fraction: 3 /2",
+            ValueError, "Invalid literal for Fraction: '3 /2'",
             F, "3 /2")
         self.assertRaisesMessage(
             # Denominators don't need a sign.
-            ValueError, "Invalid literal for Fraction: 3/+2",
+            ValueError, "Invalid literal for Fraction: '3/+2'",
             F, "3/+2")
         self.assertRaisesMessage(
             # Imitate float's parsing.
-            ValueError, "Invalid literal for Fraction: + 3/2",
+            ValueError, "Invalid literal for Fraction: '+ 3/2'",
             F, "+ 3/2")
         self.assertRaisesMessage(
             # Avoid treating '.' as a regex special character.
-            ValueError, "Invalid literal for Fraction: 3a2",
+            ValueError, "Invalid literal for Fraction: '3a2'",
             F, "3a2")
         self.assertRaisesMessage(
             # Only parse ordinary decimals, not scientific form.
-            ValueError, "Invalid literal for Fraction: 3.2e4",
+            ValueError, "Invalid literal for Fraction: '3.2e4'",
             F, "3.2e4")
         self.assertRaisesMessage(
             # Don't accept combinations of decimals and fractions.
-            ValueError, "Invalid literal for Fraction: 3/7.2",
+            ValueError, "Invalid literal for Fraction: '3/7.2'",
             F, "3/7.2")
         self.assertRaisesMessage(
             # Don't accept combinations of decimals and fractions.
-            ValueError, "Invalid literal for Fraction: 3.2/7",
+            ValueError, "Invalid literal for Fraction: '3.2/7'",
             F, "3.2/7")
         self.assertRaisesMessage(
             # Allow 3. and .3, but not .
-            ValueError, "Invalid literal for Fraction: .",
+            ValueError, "Invalid literal for Fraction: '.'",
             F, ".")
 
     def testImmutable(self):

Modified: python/branches/tlee-ast-optimize/Lib/test/test_pprint.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_pprint.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_pprint.py	Sun Jun 22 15:47:08 2008
@@ -170,6 +170,17 @@
         for type in [list, list2]:
             self.assertEqual(pprint.pformat(type(o), indent=4), exp)
 
+    def test_nested_indentations(self):
+        o1 = list(range(10))
+        o2 = dict(first=1, second=2, third=3)
+        o = [o1, o2]
+        expected = """\
+[   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
+    {   'first': 1,
+        'second': 2,
+        'third': 3}]"""
+        self.assertEqual(pprint.pformat(o, indent=4, width=42), expected)
+
     def test_sorted_dict(self):
         # Starting in Python 2.5, pprint sorts dict displays by key regardless
         # of how small the dictionary may be.

Modified: python/branches/tlee-ast-optimize/Lib/test/test_slice.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_slice.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_slice.py	Sun Jun 22 15:47:08 2008
@@ -79,6 +79,20 @@
         self.assertEqual(slice(None,  None, -1).indices(10), (9, -1, -1))
         self.assertEqual(slice(None,  None, -2).indices(10), (9, -1, -2))
         self.assertEqual(slice(3,     None, -2).indices(10), (3, -1, -2))
+        # issue 3004 tests
+        self.assertEqual(slice(None, -9).indices(10), (0, 1, 1))
+        self.assertEqual(slice(None, -10).indices(10), (0, 0, 1))
+        self.assertEqual(slice(None, -11).indices(10), (0, 0, 1))
+        self.assertEqual(slice(None, -10, -1).indices(10), (9, 0, -1))
+        self.assertEqual(slice(None, -11, -1).indices(10), (9, -1, -1))
+        self.assertEqual(slice(None, -12, -1).indices(10), (9, -1, -1))
+        self.assertEqual(slice(None, 9).indices(10), (0, 9, 1))
+        self.assertEqual(slice(None, 10).indices(10), (0, 10, 1))
+        self.assertEqual(slice(None, 11).indices(10), (0, 10, 1))
+        self.assertEqual(slice(None, 8, -1).indices(10), (9, 8, -1))
+        self.assertEqual(slice(None, 9, -1).indices(10), (9, 9, -1))
+        self.assertEqual(slice(None, 10, -1).indices(10), (9, 9, -1))
+
         self.assertEqual(
             slice(-100,  100     ).indices(10),
             slice(None).indices(10)

Modified: python/branches/tlee-ast-optimize/Lib/test/test_sys.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_sys.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_sys.py	Sun Jun 22 15:47:08 2008
@@ -523,7 +523,7 @@
         len_typeobject = p + 2*l + 15*p + l + 4*p + l + 9*p +\
                          l + 11*p + self.align(4)
         self.check_sizeof(class_newstyle,
-                          h + len_typeobject + 41*p + 10*p + 3*p + 6*p)
+                          h + len_typeobject + 42*p + 10*p + 3*p + 6*p)
 
     def test_specialtypes(self):
         i = self.i

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 Jun 22 15:47:08 2008
@@ -820,6 +820,7 @@
 		lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
 		ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
 		distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
+		multiprocessing multiprocessing/dummy \
 		lib-old \
 		curses $(MACHDEPS)
 libinstall:	build_all $(srcdir)/Lib/$(PLATDIR)

Modified: python/branches/tlee-ast-optimize/Misc/NEWS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/NEWS	(original)
+++ python/branches/tlee-ast-optimize/Misc/NEWS	Sun Jun 22 15:47:08 2008
@@ -4,6 +4,25 @@
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
+What's New in Python 2.6 beta 2?
+================================
+
+Core and Builtins
+-----------------
+
+- Issue #3004: Minor change to slice.indices(): the start and stop
+  arguments are now treated identically, making the behaviour easier
+  to describe and understand.  For example, slice(None, -10,
+  1).indices(9) now returns (0, 0, 1) instead of (0, -1, 1), and
+  slice(None, 10, -1).indices(10) returns (9, 9, -1) instead of (9,
+  10, -1).
+
+- Issue 3008: hex(), oct(), and bin() can now create exact reprs 
+  for floats.
+
+- Make bin() implementation parallel oct() and hex().
+
+
 What's New in Python 2.6 beta 1?
 ================================
 
@@ -89,6 +108,12 @@
 Library
 -------
 
+- Issue #2888: Fixed the behaviour of pprint when working with nested
+  structures, to match the behaviour of 2.5 and 3.0 (now follows the common
+  sense).
+
+- Issue #1817: cgi now correctly handles the querystring on POST requests
+
 - Issue #3136: fileConfig()'s disabling of old loggers is now conditional via
   an optional disable_existing_loggers parameter, but the default value is
   such that the old behaviour is preserved. Thanks to Leandro Lucarella for

Modified: python/branches/tlee-ast-optimize/Modules/mathmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/mathmodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/mathmodule.c	Sun Jun 22 15:47:08 2008
@@ -327,11 +327,11 @@
    sum([1e+308, 1e+308, 1e-308]) raises an OverflowError due to the
    overflow of the first partial sum.
 
-   Note 3: The itermediate values lo, yr, and hi are declared volatile so
-   aggressive compilers won't algebraicly reduce lo to always be exactly 0.0.
+   Note 3: The intermediate values lo, yr, and hi are declared volatile so
+   aggressive compilers won't algebraically reduce lo to always be exactly 0.0.
    Also, the volatile declaration forces the values to be stored in memory as
    regular doubles instead of extended long precision (80-bit) values.  This
-   prevents double rounding because any addition or substraction of two doubles
+   prevents double rounding because any addition or subtraction of two doubles
    can be resolved exactly into double-sized hi and lo values.  As long as the 
    hi value gets forced into a double before yr and lo are computed, the extra
    bits in downstream extended precision operations (x87 for example) will be

Modified: python/branches/tlee-ast-optimize/Objects/bytearrayobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/bytearrayobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/bytearrayobject.c	Sun Jun 22 15:47:08 2008
@@ -2725,7 +2725,7 @@
 "B.pop([index]) -> int\n\
 \n\
 Remove and return a single item from B. If no index\n\
-argument is give, will pop the last value.");
+argument is given, will pop the last value.");
 static PyObject *
 bytes_pop(PyByteArrayObject *self, PyObject *args)
 {

Modified: python/branches/tlee-ast-optimize/Objects/floatobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/floatobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/floatobject.c	Sun Jun 22 15:47:08 2008
@@ -405,11 +405,11 @@
    obj is not of float, int or long type, Py_NotImplemented is incref'ed,
    stored in obj, and returned from the function invoking this macro.
 */
-#define CONVERT_TO_DOUBLE(obj, dbl)			\
-	if (PyFloat_Check(obj))				\
-		dbl = PyFloat_AS_DOUBLE(obj);		\
-	else if (convert_to_double(&(obj), &(dbl)) < 0)	\
-		return obj;
+#define CONVERT_TO_DOUBLE(obj, dbl)					\
+	if (PyFloat_Check(obj))						\
+		dbl = PyFloat_AS_DOUBLE(obj);				\
+	else if (convert_to_double((PyObject **)&(obj), &(dbl)) < 0)	\
+		return (PyObject *)(obj);
 
 static int
 convert_to_double(PyObject **v, double *dbl)
@@ -1204,6 +1204,62 @@
 ">>> (-.25).as_integer_ratio()\n"
 "(-1, 4)");
 
+static PyObject *
+_float_to_base(PyFloatObject *v, unaryfunc int_to_base)
+{
+	PyObject *mant, *conv, *result;
+	double x, fr;
+	int i, exp, n;
+	char *conv_str;
+
+	CONVERT_TO_DOUBLE(v, x);
+	if (!Py_IS_FINITE(x))
+		return PyObject_Repr((PyObject *)v);
+	fr = frexp(x, &exp);
+	for (i=0; i<300 && fr != floor(fr) ; i++) {
+		fr *= 2.0;
+		exp--;
+	}
+	mant = PyLong_FromDouble(floor(fr));
+	if (mant == NULL)
+		return NULL;
+	conv = int_to_base(mant);
+	Py_DECREF(mant);
+	if (conv== NULL)
+		return NULL;
+	n = PyString_GET_SIZE(conv);
+	conv_str = PyString_AS_STRING(conv);
+	/* Remove the trailing 'L' if present */
+	if (n && conv_str[n-1] == 'L') {
+		PyObject *newconv = PySequence_GetSlice(conv, 0, -1);
+		Py_DECREF(conv);
+		if (newconv == NULL)
+			return NULL;
+		conv = newconv;
+		conv_str = PyString_AS_STRING(conv);
+	}
+	result = PyString_FromFormat("%s * 2.0 ** %d", conv_str, exp);
+	Py_DECREF(conv);
+	return result;
+}
+
+static PyObject *
+float_hex(PyFloatObject *v)
+{
+	return _float_to_base(v, PyLong_Type.tp_as_number->nb_hex);
+}
+
+static PyObject *
+float_oct(PyFloatObject *v)
+{
+	return _float_to_base(v, PyLong_Type.tp_as_number->nb_oct);
+}
+
+static PyObject *
+float_bin(PyFloatObject *v)
+{
+	return _float_to_base(v, PyLong_Type.tp_as_number->nb_bin);
+}
 
 static PyObject *
 float_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
@@ -1490,8 +1546,8 @@
 	float_trunc, 	/*nb_int*/
 	float_trunc, 	/*nb_long*/
 	float_float,	/*nb_float*/
-	0,		/* nb_oct */
-	0,		/* nb_hex */
+	(unaryfunc)float_oct,		/* nb_oct */
+	(unaryfunc)float_hex,		/* nb_hex */
 	0,		/* nb_inplace_add */
 	0,		/* nb_inplace_subtract */
 	0,		/* nb_inplace_multiply */
@@ -1507,6 +1563,8 @@
 	float_div,	/* nb_true_divide */
 	0,		/* nb_inplace_floor_divide */
 	0,		/* nb_inplace_true_divide */
+	0,		/* nb_index */
+	(unaryfunc)float_bin,		/* nb_bin */
 };
 
 PyTypeObject PyFloat_Type = {

Modified: python/branches/tlee-ast-optimize/Objects/intobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/intobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/intobject.c	Sun Jun 22 15:47:08 2008
@@ -934,6 +934,12 @@
 }
 
 static PyObject *
+int_bin(PyObject *v)
+{
+        return PyNumber_ToBase(v, 2);
+}
+
+static PyObject *
 int_oct(PyIntObject *v)
 {
 	return _PyInt_Format(v, 8, 0);
@@ -1231,6 +1237,7 @@
 	0,			/* nb_inplace_floor_divide */
 	0,			/* nb_inplace_true_divide */
 	(unaryfunc)int_int,	/* nb_index */
+	(unaryfunc)int_bin, 	/* nb_bin */
 };
 
 PyTypeObject PyInt_Type = {

Modified: python/branches/tlee-ast-optimize/Objects/longobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/longobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/longobject.c	Sun Jun 22 15:47:08 2008
@@ -3301,6 +3301,12 @@
 }
 
 static PyObject *
+long_bin(PyObject *v)
+{
+        return PyNumber_ToBase(v, 2);
+}
+
+static PyObject *
 long_oct(PyObject *v)
 {
 	return _PyLong_Format(v, 8, 1, 0);
@@ -3540,6 +3546,7 @@
 	0,				/* nb_inplace_floor_divide */
 	0,				/* nb_inplace_true_divide */
 	long_long,			/* nb_index */
+	long_bin,			/* nb_bin */
 };
 
 PyTypeObject PyLong_Type = {

Modified: python/branches/tlee-ast-optimize/Objects/sliceobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/sliceobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/sliceobject.c	Sun Jun 22 15:47:08 2008
@@ -169,8 +169,9 @@
 	else {
 		if (!_PyEval_SliceIndex(r->stop, stop)) return -1;
 		if (*stop < 0) *stop += length;
-		if (*stop < 0) *stop = -1;
-		if (*stop > length) *stop = length;
+		if (*stop < 0) *stop = (*step < 0) ? -1 : 0;
+		if (*stop >= length)
+			*stop = (*step < 0) ? length - 1 : length;
 	}
 
 	if ((*step < 0 && *stop >= *start) 

Modified: python/branches/tlee-ast-optimize/Objects/typeobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/typeobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/typeobject.c	Sun Jun 22 15:47:08 2008
@@ -3743,6 +3743,7 @@
 		if (base->tp_flags & Py_TPFLAGS_HAVE_INDEX) {
 			COPYNUM(nb_index);
 		}
+		COPYNUM(nb_hex);
 	}
 
 	if (type->tp_as_sequence != NULL && base->tp_as_sequence != NULL) {
@@ -5135,6 +5136,7 @@
 SLOT0(slot_nb_int, "__int__")
 SLOT0(slot_nb_long, "__long__")
 SLOT0(slot_nb_float, "__float__")
+SLOT0(slot_nb_bin, "__bin__")
 SLOT0(slot_nb_oct, "__oct__")
 SLOT0(slot_nb_hex, "__hex__")
 SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *, "O")
@@ -5802,6 +5804,8 @@
 	       "long(x)"),
 	UNSLOT("__float__", nb_float, slot_nb_float, wrap_unaryfunc,
 	       "float(x)"),
+	UNSLOT("__bin__", nb_bin, slot_nb_bin, wrap_unaryfunc,
+	       "bin(x)"),
 	UNSLOT("__oct__", nb_oct, slot_nb_oct, wrap_unaryfunc,
 	       "oct(x)"),
 	UNSLOT("__hex__", nb_hex, slot_nb_hex, wrap_unaryfunc,

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 Jun 22 15:47:08 2008
@@ -213,7 +213,24 @@
 static PyObject *
 builtin_bin(PyObject *self, PyObject *v)
 {
-        return PyNumber_ToBase(v, 2);
+	PyNumberMethods *nb;
+	PyObject *res;
+
+	if ((nb = v->ob_type->tp_as_number) == NULL ||
+	    nb->nb_hex == NULL) {
+		PyErr_SetString(PyExc_TypeError,
+			   "bin() argument can't be converted to hex");
+		return NULL;
+	}
+	res = (*nb->nb_bin)(v);
+	if (res && !PyString_Check(res)) {
+		PyErr_Format(PyExc_TypeError,
+			     "__bin__ returned non-string (type %.200s)",
+			     res->ob_type->tp_name);
+		Py_DECREF(res);
+		return NULL;
+	}
+	return res;
 }
 
 PyDoc_STRVAR(bin_doc,


More information about the Python-checkins mailing list