[Python-3000-checkins] r64081 - in python/branches/py3k: Doc/ACKS.txt Doc/Makefile Doc/README.txt Doc/library/_ast.rst Doc/library/abc.rst Doc/library/ast.rst Doc/library/cmd.rst Doc/library/inspect.rst Doc/library/language.rst Doc/library/logging.rst Doc/library/parser.rst Doc/library/threading.rst Doc/whatsnew/2.5.rst Doc/whatsnew/2.6.rst Include/bytearrayobject.h Include/bytesobject.h Lib/ast.py Lib/inspect.py Lib/test/test_ast.py Lib/test/test_complex.py Lib/test/test_inspect.py Lib/test/test_threading.py Lib/threading.py Misc/ACKS Misc/developers.txt Modules/itertoolsmodule.c Objects/complexobject.c

georg.brandl python-3000-checkins at python.org
Tue Jun 10 18:37:51 CEST 2008


Author: georg.brandl
Date: Tue Jun 10 18:37:50 2008
New Revision: 64081

Log:
Merged revisions 63829-63831,63858,63865,63879,63882,63948,63970-63972,63976,63989,64014-64015,64021-64022,64063-64065,64067 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r63829 | mark.summerfield | 2008-05-31 15:05:34 +0200 (Sat, 31 May 2008) | 4 lines
  
  Added a note to [] that special forms & special chars lose their meaning
  and backrefs can't be used inside []
........
  r63830 | georg.brandl | 2008-05-31 16:40:09 +0200 (Sat, 31 May 2008) | 2 lines
  
  #3010: clarification about stdin/use_rawinput.
........
  r63831 | georg.brandl | 2008-05-31 16:45:55 +0200 (Sat, 31 May 2008) | 2 lines
  
  #3005: add explaining sentence to easydialogs docs.
........
  r63858 | georg.brandl | 2008-06-01 18:41:31 +0200 (Sun, 01 Jun 2008) | 2 lines
  
  Add plain text make target.
........
  r63865 | georg.brandl | 2008-06-01 21:24:36 +0200 (Sun, 01 Jun 2008) | 2 lines
  
  Spaces vs. tabs.
........
  r63879 | gregory.p.smith | 2008-06-02 00:57:47 +0200 (Mon, 02 Jun 2008) | 3 lines
  
  Make the _H #define's match the header file names.  Fix comments to
  mention the correct type names.
........
  r63882 | gregory.p.smith | 2008-06-02 01:48:47 +0200 (Mon, 02 Jun 2008) | 3 lines
  
  Adds a Thread.getIdent() method to provide the _get_ident() value for
  any given threading.Thread object.  feature request issue 2871.
........
  r63948 | alexandre.vassalotti | 2008-06-04 22:41:44 +0200 (Wed, 04 Jun 2008) | 2 lines
  
  Fixed complex.__getnewargs__() to not emit another complex object.
........
  r63970 | andrew.kuchling | 2008-06-06 01:33:54 +0200 (Fri, 06 Jun 2008) | 1 line
  
  Document 'utc' parameter
........
  r63971 | andrew.kuchling | 2008-06-06 01:35:31 +0200 (Fri, 06 Jun 2008) | 1 line
  
  Add various items
........
  r63972 | andrew.kuchling | 2008-06-06 01:35:48 +0200 (Fri, 06 Jun 2008) | 1 line
  
  Grammar fix
........
  r63976 | georg.brandl | 2008-06-06 09:34:50 +0200 (Fri, 06 Jun 2008) | 2 lines
  
  Markup fix.
........
  r63989 | thomas.heller | 2008-06-06 20:42:11 +0200 (Fri, 06 Jun 2008) | 2 lines
  
  Add a reminder for the maintainer of whatsnew.
........
  r64014 | georg.brandl | 2008-06-07 17:59:10 +0200 (Sat, 07 Jun 2008) | 3 lines
  
  Factor out docstring dedenting from inspect.getdoc() into inspect.cleandoc()
  to ease standalone use of the algorithm.
........
  r64015 | georg.brandl | 2008-06-07 18:04:01 +0200 (Sat, 07 Jun 2008) | 2 lines
  
  Revert unwanted changes.
........
  r64021 | georg.brandl | 2008-06-07 20:16:12 +0200 (Sat, 07 Jun 2008) | 2 lines
  
  X-ref to numbers module.
........
  r64022 | georg.brandl | 2008-06-07 20:17:37 +0200 (Sat, 07 Jun 2008) | 3 lines
  
  Document the "st" API, to avoid confusion with the "new" AST.
  Add a note about using the new AST module.
........
  r64063 | martin.v.loewis | 2008-06-10 07:03:35 +0200 (Tue, 10 Jun 2008) | 2 lines
  
  Add Gregor Lingl.
........
  r64064 | georg.brandl | 2008-06-10 09:45:28 +0200 (Tue, 10 Jun 2008) | 2 lines
  
  Add the "ast" module, containing helpers to ease use of the "_ast" classes.
........
  r64065 | raymond.hettinger | 2008-06-10 09:57:15 +0200 (Tue, 10 Jun 2008) | 1 line
  
  Add Arnaud for his efforts on multi-arg set operations.
........
  r64067 | georg.brandl | 2008-06-10 14:46:39 +0200 (Tue, 10 Jun 2008) | 2 lines
  
  #2536: fix itertools.permutations and itertools.combinations docstrings.
........


Added:
   python/branches/py3k/Doc/library/ast.rst
      - copied unchanged from r64065, /python/trunk/Doc/library/ast.rst
   python/branches/py3k/Lib/ast.py
      - copied, changed from r64065, /python/trunk/Lib/ast.py
Removed:
   python/branches/py3k/Doc/library/_ast.rst
Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Doc/ACKS.txt
   python/branches/py3k/Doc/Makefile
   python/branches/py3k/Doc/README.txt
   python/branches/py3k/Doc/library/abc.rst
   python/branches/py3k/Doc/library/cmd.rst
   python/branches/py3k/Doc/library/inspect.rst
   python/branches/py3k/Doc/library/language.rst
   python/branches/py3k/Doc/library/logging.rst
   python/branches/py3k/Doc/library/parser.rst
   python/branches/py3k/Doc/library/threading.rst
   python/branches/py3k/Doc/whatsnew/2.5.rst
   python/branches/py3k/Doc/whatsnew/2.6.rst
   python/branches/py3k/Include/bytearrayobject.h
   python/branches/py3k/Include/bytesobject.h
   python/branches/py3k/Lib/inspect.py
   python/branches/py3k/Lib/test/test_ast.py
   python/branches/py3k/Lib/test/test_complex.py
   python/branches/py3k/Lib/test/test_inspect.py
   python/branches/py3k/Lib/test/test_threading.py
   python/branches/py3k/Lib/threading.py
   python/branches/py3k/Misc/ACKS
   python/branches/py3k/Misc/developers.txt
   python/branches/py3k/Modules/itertoolsmodule.c
   python/branches/py3k/Objects/complexobject.c

Modified: python/branches/py3k/Doc/ACKS.txt
==============================================================================
--- python/branches/py3k/Doc/ACKS.txt	(original)
+++ python/branches/py3k/Doc/ACKS.txt	Tue Jun 10 18:37:50 2008
@@ -157,6 +157,7 @@
    * Bernhard Reiter
    * Armin Rigo
    * Wes Rishel
+   * Armin Ronacher
    * Jim Roskind
    * Guido van Rossum
    * Donald Wallace Rouse II

Modified: python/branches/py3k/Doc/Makefile
==============================================================================
--- python/branches/py3k/Doc/Makefile	(original)
+++ python/branches/py3k/Doc/Makefile	Tue Jun 10 18:37:50 2008
@@ -21,6 +21,7 @@
 	@echo "  web       to make file usable by Sphinx.web"
 	@echo "  htmlhelp  to make HTML files and a HTML help project"
 	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  text      to make plain text files"
 	@echo "  changes   to make an overview over all changed/added/deprecated items"
 	@echo "  linkcheck to check all external links for integrity"
 	@echo "  coverage  to check documentation coverage for library and C API"
@@ -75,6 +76,10 @@
 	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
 	      "run these through (pdf)latex."
 
+text: BUILDER = text
+text: build
+	@echo "Build finished; the text files are in build/text."
+
 changes: BUILDER = changes
 changes: build
 	@echo "The overview file is in build/changes."

Modified: python/branches/py3k/Doc/README.txt
==============================================================================
--- python/branches/py3k/Doc/README.txt	(original)
+++ python/branches/py3k/Doc/README.txt	Tue Jun 10 18:37:50 2008
@@ -56,6 +56,8 @@
  * "latex", which builds LaTeX source files that can be run with "pdflatex"
    to produce PDF documents.
 
+ * "text", which builds a plain text file for each source file.
+
  * "linkcheck", which checks all external references to see whether they are
    broken, redirected or malformed, and outputs this information to stdout
    as well as a plain-text (.txt) file.

Deleted: python/branches/py3k/Doc/library/_ast.rst
==============================================================================
--- python/branches/py3k/Doc/library/_ast.rst	Tue Jun 10 18:37:50 2008
+++ (empty file)
@@ -1,83 +0,0 @@
-.. _ast:
-
-Abstract Syntax Trees
-=====================
-
-.. module:: _ast
-   :synopsis: Abstract Syntax Tree classes.
-
-.. sectionauthor:: Martin v. Löwis <martin at v.loewis.de>
-
-
-The ``_ast`` module helps Python applications to process trees of the Python
-abstract syntax grammar.  The abstract syntax itself might change with each
-Python release; this module helps to find out programmatically what the current
-grammar looks like.
-
-An abstract syntax tree can be generated by passing :data:`_ast.PyCF_ONLY_AST`
-as a flag to the :func:`compile` builtin function. The result will be a tree of
-objects whose classes all inherit from :class:`_ast.AST`.
-
-A modified abstract syntax tree can be compiled into a Python code object using
-the built-in :func:`compile` function.
-
-The actual classes are derived from the ``Parser/Python.asdl`` file, which is
-reproduced below. There is one class defined for each left-hand side symbol in
-the abstract grammar (for example, ``_ast.stmt`` or ``_ast.expr``). In addition,
-there is one class defined for each constructor on the right-hand side; these
-classes inherit from the classes for the left-hand side trees. For example,
-``_ast.BinOp`` inherits from ``_ast.expr``. For production rules with
-alternatives (aka "sums"), the left-hand side class is abstract: only instances
-of specific constructor nodes are ever created.
-
-Each concrete class has an attribute ``_fields`` which gives the names of all
-child nodes.
-
-Each instance of a concrete class has one attribute for each child node, of the
-type as defined in the grammar. For example, ``_ast.BinOp`` instances have an
-attribute ``left`` of type ``_ast.expr``.   Instances of ``_ast.expr`` and
-``_ast.stmt`` subclasses also have lineno and col_offset attributes.  The lineno
-is the line number of source text (1 indexed so the first line is line 1) and
-the col_offset is the utf8 byte offset of the first token that generated the
-node.  The utf8 offset is recorded because the parser uses utf8 internally.
-
-If these attributes are marked as optional in the grammar (using a question
-mark), the value might be ``None``. If the attributes can have zero-or-more
-values (marked with an asterisk), the values are represented as Python lists.
-All possible attributes must be present and have valid values when compiling an
-AST with :func:`compile`.
-
-The constructor of a class ``_ast.T`` parses their arguments as follows:
-
-* If there are positional arguments, there must be as many as there are items in
-  ``T._fields``; they will be assigned as attributes of these names.
-* If there are keyword arguments, they will set the attributes of the same names
-  to the given values.
-
-For example, to create and populate a ``UnaryOp`` node, you could use ::
-
-   node = _ast.UnaryOp()
-   node.op = _ast.USub()
-   node.operand = _ast.Num()
-   node.operand.n = 5
-   node.operand.lineno = 0
-   node.operand.col_offset = 0
-   node.lineno = 0
-   node.col_offset = 0
-
-or the more compact ::
-
-   node = _ast.UnaryOp(_ast.USub(), _ast.Num(5, lineno=0, col_offset=0),
-                       lineno=0, col_offset=0)
-
-
-
-Abstract Grammar
-----------------
-
-The module defines a string constant ``__version__`` which is the decimal
-subversion revision number of the file shown below.
-
-The abstract grammar is currently defined as follows:
-
-.. literalinclude:: ../../Parser/Python.asdl

Modified: python/branches/py3k/Doc/library/abc.rst
==============================================================================
--- python/branches/py3k/Doc/library/abc.rst	(original)
+++ python/branches/py3k/Doc/library/abc.rst	Tue Jun 10 18:37:50 2008
@@ -9,9 +9,9 @@
 .. much of the content adapted from docstrings
 
 This module provides the infrastructure for defining abstract base classes
-(ABCs) in Python, as outlined in :pep:`3119`; see the PEP for why this
-was added to Python. (See also, :pep:`3141` regarding a type hierarchy
-for numbers based on ABCs.)
+(ABCs) in Python, as outlined in :pep:`3119`; see the PEP for why this was added
+to Python. (See also :pep:`3141` and the :mod:`numbers` module regarding a type
+hierarchy for numbers based on ABCs.)
 
 The :mod:`collections` module has some concrete classes that derive from
 ABCs; these can, of course, be further derived. In addition the

Modified: python/branches/py3k/Doc/library/cmd.rst
==============================================================================
--- python/branches/py3k/Doc/library/cmd.rst	(original)
+++ python/branches/py3k/Doc/library/cmd.rst	Tue Jun 10 18:37:50 2008
@@ -26,7 +26,12 @@
 
    The optional arguments *stdin* and *stdout* specify the  input and output file
    objects that the Cmd instance or subclass  instance will use for input and
-   output. If not specified, they will default to *sys.stdin* and *sys.stdout*.
+   output. If not specified, they will default to :data:`sys.stdin` and
+   :data:`sys.stdout`.
+
+   If you want a given *stdin* to be used, make sure to set the instance's
+   :attr:`use_rawinput` attribute to ``False``, otherwise *stdin* will be
+   ignored.
 
 
 .. _cmd-objects:

Modified: python/branches/py3k/Doc/library/inspect.rst
==============================================================================
--- python/branches/py3k/Doc/library/inspect.rst	(original)
+++ python/branches/py3k/Doc/library/inspect.rst	Tue Jun 10 18:37:50 2008
@@ -320,13 +320,9 @@
 Retrieving source code
 ----------------------
 
-
 .. function:: getdoc(object)
 
-   Get the documentation string for an object. All tabs are expanded to spaces.  To
-   clean up docstrings that are indented to line up with blocks of code, any
-   whitespace than can be uniformly removed from the second line onwards is
-   removed.
+   Get the documentation string for an object, cleaned up with :func:`cleandoc`.
 
 
 .. function:: getcomments(object)
@@ -373,6 +369,15 @@
    cannot be retrieved.
 
 
+.. function:: cleandoc(doc)
+
+   Clean up indentation from docstrings that are indented to line up with blocks
+   of code.  Any whitespace that can be uniformly removed from the second line
+   onwards is removed.  Also, all tabs are expanded to spaces.
+
+   .. versionadded:: 2.6
+
+
 .. _inspect-classes-functions:
 
 Classes and functions

Modified: python/branches/py3k/Doc/library/language.rst
==============================================================================
--- python/branches/py3k/Doc/library/language.rst	(original)
+++ python/branches/py3k/Doc/library/language.rst	Tue Jun 10 18:37:50 2008
@@ -15,7 +15,7 @@
 .. toctree::
 
    parser.rst
-   _ast.rst
+   ast.rst
    symbol.rst
    token.rst
    keyword.rst

Modified: python/branches/py3k/Doc/library/logging.rst
==============================================================================
--- python/branches/py3k/Doc/library/logging.rst	(original)
+++ python/branches/py3k/Doc/library/logging.rst	Tue Jun 10 18:37:50 2008
@@ -1618,7 +1618,7 @@
 timed intervals.
 
 
-.. class:: TimedRotatingFileHandler(filename [,when [,interval [,backupCount[, encoding[, delay]]]]])
+.. class:: TimedRotatingFileHandler(filename [,when [,interval [,backupCount[, encoding[, delay[, utc]]]]]])
 
    Returns a new instance of the :class:`TimedRotatingFileHandler` class. The
    specified file is opened and used as the stream for logging. On rotating it also
@@ -1626,7 +1626,7 @@
    *interval*.
 
    You can use the *when* to specify the type of *interval*. The list of possible
-   values is, note that they are not case sensitive:
+   values is below.  Note that they are not case sensitive.
 
    +----------------+-----------------------+
    | Value          | Type of interval      |
@@ -1647,7 +1647,11 @@
    The system will save old log files by appending extensions to the filename.
    The extensions are date-and-time based, using the strftime format
    ``%Y-%m-%d_%H-%M-%S`` or a leading portion thereof, depending on the
-   rollover interval. If *backupCount* is nonzero, at most *backupCount* files
+   rollover interval. 
+   If the *utc* argument is true, times in UTC will be used; otherwise
+   local time is used.
+
+   If *backupCount* is nonzero, at most *backupCount* files
    will be kept, and if more would be created when rollover occurs, the oldest
    one is deleted. The deletion logic uses the interval to determine which
    files to delete, so changing the interval may leave old files lying around.

Modified: python/branches/py3k/Doc/library/parser.rst
==============================================================================
--- python/branches/py3k/Doc/library/parser.rst	(original)
+++ python/branches/py3k/Doc/library/parser.rst	Tue Jun 10 18:37:50 2008
@@ -24,6 +24,17 @@
 code fragment as a string because parsing is performed in a manner identical to
 the code forming the application.  It is also faster.
 
+.. note::
+
+   From Python 2.5 onward, it's much more convenient to cut in at the Abstract
+   Syntax Tree (AST) generation and compilation stage, using the :mod:`ast`
+   module.
+
+   The :mod:`parser` module exports the names documented here also with "st"
+   replaced by "ast"; this is a legacy from the time when there was no other
+   AST and has nothing to do with the AST found in Python 2.5.  This is also the
+   reason for the functions' keyword arguments being called *ast*, not *st*.
+
 There are a few things to note about this module which are important to making
 use of the data structures created.  This is not a tutorial on editing the parse
 trees for Python code, but some examples of using the :mod:`parser` module are
@@ -34,9 +45,9 @@
 to :ref:`reference-index`.  The parser
 itself is created from a grammar specification defined in the file
 :file:`Grammar/Grammar` in the standard Python distribution.  The parse trees
-stored in the AST objects created by this module are the actual output from the
+stored in the ST objects created by this module are the actual output from the
 internal parser when created by the :func:`expr` or :func:`suite` functions,
-described below.  The AST objects created by :func:`sequence2ast` faithfully
+described below.  The ST objects created by :func:`sequence2st` faithfully
 simulate those structures.  Be aware that the values of the sequences which are
 considered "correct" will vary from one version of Python to another as the
 formal grammar for the language is revised.  However, transporting code from one
@@ -46,7 +57,7 @@
 language constructs.  The parse trees are not typically compatible from one
 version to another, whereas source code has always been forward-compatible.
 
-Each element of the sequences returned by :func:`ast2list` or :func:`ast2tuple`
+Each element of the sequences returned by :func:`st2list` or :func:`st2tuple`
 has a simple form.  Sequences representing non-terminal elements in the grammar
 always have a length greater than one.  The first element is an integer which
 identifies a production in the grammar.  These integers are given symbolic names
@@ -69,19 +80,19 @@
 terminal symbols are defined in the C header file :file:`Include/token.h` and
 the Python module :mod:`token`.
 
-The AST objects are not required to support the functionality of this module,
+The ST objects are not required to support the functionality of this module,
 but are provided for three purposes: to allow an application to amortize the
 cost of processing complex parse trees, to provide a parse tree representation
 which conserves memory space when compared to the Python list or tuple
 representation, and to ease the creation of additional modules in C which
 manipulate parse trees.  A simple "wrapper" class may be created in Python to
-hide the use of AST objects.
+hide the use of ST objects.
 
 The :mod:`parser` module defines functions for a few distinct purposes.  The
-most important purposes are to create AST objects and to convert AST objects to
+most important purposes are to create ST objects and to convert ST objects to
 other representations such as parse trees and compiled code objects, but there
 are also functions which serve to query the type of parse tree represented by an
-AST object.
+ST object.
 
 
 .. seealso::
@@ -94,20 +105,20 @@
       testing node values.
 
 
-.. _creating-asts:
+.. _creating-sts:
 
-Creating AST Objects
---------------------
+Creating ST Objects
+-------------------
 
-AST objects may be created from source code or from a parse tree. When creating
-an AST object from source, different functions are used to create the ``'eval'``
+ST objects may be created from source code or from a parse tree. When creating
+an ST object from source, different functions are used to create the ``'eval'``
 and ``'exec'`` forms.
 
 
 .. function:: expr(source)
 
    The :func:`expr` function parses the parameter *source* as if it were an input
-   to ``compile(source, 'file.py', 'eval')``.  If the parse succeeds, an AST object
+   to ``compile(source, 'file.py', 'eval')``.  If the parse succeeds, an ST object
    is created to hold the internal parse tree representation, otherwise an
    appropriate exception is thrown.
 
@@ -115,22 +126,22 @@
 .. function:: suite(source)
 
    The :func:`suite` function parses the parameter *source* as if it were an input
-   to ``compile(source, 'file.py', 'exec')``.  If the parse succeeds, an AST object
+   to ``compile(source, 'file.py', 'exec')``.  If the parse succeeds, an ST object
    is created to hold the internal parse tree representation, otherwise an
    appropriate exception is thrown.
 
 
-.. function:: sequence2ast(sequence)
+.. function:: sequence2st(sequence)
 
    This function accepts a parse tree represented as a sequence and builds an
    internal representation if possible.  If it can validate that the tree conforms
    to the Python grammar and all nodes are valid node types in the host version of
-   Python, an AST object is created from the internal representation and returned
+   Python, an ST object is created from the internal representation and returned
    to the called.  If there is a problem creating the internal representation, or
    if the tree cannot be validated, a :exc:`ParserError` exception is thrown.  An
-   AST object created this way should not be assumed to compile correctly; normal
-   exceptions thrown by compilation may still be initiated when the AST object is
-   passed to :func:`compileast`.  This may indicate problems not related to syntax
+   ST object created this way should not be assumed to compile correctly; normal
+   exceptions thrown by compilation may still be initiated when the ST object is
+   passed to :func:`compilest`.  This may indicate problems not related to syntax
    (such as a :exc:`MemoryError` exception), but may also be due to constructs such
    as the result of parsing ``del f(0)``, which escapes the Python parser but is
    checked by the bytecode compiler.
@@ -142,31 +153,31 @@
    symbols in the input tree.
 
 
-.. function:: tuple2ast(sequence)
+.. function:: tuple2st(sequence)
 
-   This is the same function as :func:`sequence2ast`.  This entry point is
+   This is the same function as :func:`sequence2st`.  This entry point is
    maintained for backward compatibility.
 
 
-.. _converting-asts:
+.. _converting-sts:
 
-Converting AST Objects
-----------------------
+Converting ST Objects
+---------------------
 
-AST objects, regardless of the input used to create them, may be converted to
+ST objects, regardless of the input used to create them, may be converted to
 parse trees represented as list- or tuple- trees, or may be compiled into
 executable code objects.  Parse trees may be extracted with or without line
 numbering information.
 
 
-.. function:: ast2list(ast[, line_info])
+.. function:: st2list(ast[, line_info])
 
-   This function accepts an AST object from the caller in *ast* and returns a
+   This function accepts an ST object from the caller in *ast* and returns a
    Python list representing the equivalent parse tree.  The resulting list
    representation can be used for inspection or the creation of a new parse tree in
    list form.  This function does not fail so long as memory is available to build
    the list representation.  If the parse tree will only be used for inspection,
-   :func:`ast2tuple` should be used instead to reduce memory consumption and
+   :func:`st2tuple` should be used instead to reduce memory consumption and
    fragmentation.  When the list representation is required, this function is
    significantly faster than retrieving a tuple representation and converting that
    to nested lists.
@@ -177,31 +188,31 @@
    This information is omitted if the flag is false or omitted.
 
 
-.. function:: ast2tuple(ast[, line_info])
+.. function:: st2tuple(ast[, line_info])
 
-   This function accepts an AST object from the caller in *ast* and returns a
+   This function accepts an ST object from the caller in *ast* and returns a
    Python tuple representing the equivalent parse tree.  Other than returning a
-   tuple instead of a list, this function is identical to :func:`ast2list`.
+   tuple instead of a list, this function is identical to :func:`st2list`.
 
    If *line_info* is true, line number information will be included for all
    terminal tokens as a third element of the list representing the token.  This
    information is omitted if the flag is false or omitted.
 
 
-.. function:: compileast(ast[, filename='<ast>'])
+.. function:: compilest(ast[, filename='<syntax-tree>'])
 
    .. index::
       builtin: exec
       builtin: eval
 
-   The Python byte compiler can be invoked on an AST object to produce code objects
+   The Python byte compiler can be invoked on an ST object to produce code objects
    which can be used as part of a call to the built-in :func:`exec` or :func:`eval`
    functions. This function provides the interface to the compiler, passing the
    internal parse tree from *ast* to the parser, using the source file name
    specified by the *filename* parameter. The default value supplied for *filename*
-   indicates that the source was an AST object.
+   indicates that the source was an ST object.
 
-   Compiling an AST object may result in exceptions related to compilation; an
+   Compiling an ST object may result in exceptions related to compilation; an
    example would be a :exc:`SyntaxError` caused by the parse tree for ``del f(0)``:
    this statement is considered legal within the formal grammar for Python but is
    not a legal language construct.  The :exc:`SyntaxError` raised for this
@@ -211,15 +222,15 @@
    tree.
 
 
-.. _querying-asts:
+.. _querying-sts:
 
-Queries on AST Objects
-----------------------
+Queries on ST Objects
+---------------------
 
-Two functions are provided which allow an application to determine if an AST was
+Two functions are provided which allow an application to determine if an ST was
 created as an expression or a suite.  Neither of these functions can be used to
-determine if an AST was created from source code via :func:`expr` or
-:func:`suite` or from a parse tree via :func:`sequence2ast`.
+determine if an ST was created from source code via :func:`expr` or
+:func:`suite` or from a parse tree via :func:`sequence2st`.
 
 
 .. function:: isexpr(ast)
@@ -229,19 +240,19 @@
    When *ast* represents an ``'eval'`` form, this function returns true, otherwise
    it returns false.  This is useful, since code objects normally cannot be queried
    for this information using existing built-in functions.  Note that the code
-   objects created by :func:`compileast` cannot be queried like this either, and
+   objects created by :func:`compilest` cannot be queried like this either, and
    are identical to those created by the built-in :func:`compile` function.
 
 
 .. function:: issuite(ast)
 
-   This function mirrors :func:`isexpr` in that it reports whether an AST object
+   This function mirrors :func:`isexpr` in that it reports whether an ST object
    represents an ``'exec'`` form, commonly known as a "suite."  It is not safe to
    assume that this function is equivalent to ``not isexpr(ast)``, as additional
    syntactic fragments may be supported in the future.
 
 
-.. _ast-errors:
+.. _st-errors:
 
 Exceptions and Error Handling
 -----------------------------
@@ -257,12 +268,12 @@
    generally produced for validation failures rather than the built in
    :exc:`SyntaxError` thrown during normal parsing. The exception argument is
    either a string describing the reason of the failure or a tuple containing a
-   sequence causing the failure from a parse tree passed to :func:`sequence2ast`
-   and an explanatory string.  Calls to :func:`sequence2ast` need to be able to
+   sequence causing the failure from a parse tree passed to :func:`sequence2st`
+   and an explanatory string.  Calls to :func:`sequence2st` need to be able to
    handle either type of exception, while calls to other functions in the module
    will only need to be aware of the simple string values.
 
-Note that the functions :func:`compileast`, :func:`expr`, and :func:`suite` may
+Note that the functions :func:`compilest`, :func:`expr`, and :func:`suite` may
 throw exceptions which are normally thrown by the parsing and compilation
 process.  These include the built in exceptions :exc:`MemoryError`,
 :exc:`OverflowError`, :exc:`SyntaxError`, and :exc:`SystemError`.  In these
@@ -270,49 +281,49 @@
 Refer to the descriptions of each function for detailed information.
 
 
-.. _ast-objects:
+.. _st-objects:
 
-AST Objects
------------
+ST Objects
+----------
 
-Ordered and equality comparisons are supported between AST objects. Pickling of
-AST objects (using the :mod:`pickle` module) is also supported.
+Ordered and equality comparisons are supported between ST objects. Pickling of
+ST objects (using the :mod:`pickle` module) is also supported.
 
 
-.. data:: ASTType
+.. data:: STType
 
    The type of the objects returned by :func:`expr`, :func:`suite` and
-   :func:`sequence2ast`.
+   :func:`sequence2st`.
 
-AST objects have the following methods:
+ST objects have the following methods:
 
 
-.. method:: AST.compile([filename])
+.. method:: ST.compile([filename])
 
-   Same as ``compileast(ast, filename)``.
+   Same as ``compilest(st, filename)``.
 
 
-.. method:: AST.isexpr()
+.. method:: ST.isexpr()
 
-   Same as ``isexpr(ast)``.
+   Same as ``isexpr(st)``.
 
 
-.. method:: AST.issuite()
+.. method:: ST.issuite()
 
-   Same as ``issuite(ast)``.
+   Same as ``issuite(st)``.
 
 
-.. method:: AST.tolist([line_info])
+.. method:: ST.tolist([line_info])
 
-   Same as ``ast2list(ast, line_info)``.
+   Same as ``st2list(st, line_info)``.
 
 
-.. method:: AST.totuple([line_info])
+.. method:: ST.totuple([line_info])
 
-   Same as ``ast2tuple(ast, line_info)``.
+   Same as ``st2tuple(st, line_info)``.
 
 
-.. _ast-examples:
+.. _st-examples:
 
 Examples
 --------
@@ -340,27 +351,27 @@
    10
 
 The equivalent operation using the :mod:`parser` module is somewhat longer, and
-allows the intermediate internal parse tree to be retained as an AST object::
+allows the intermediate internal parse tree to be retained as an ST object::
 
    >>> import parser
-   >>> ast = parser.expr('a + 5')
-   >>> code = ast.compile('file.py')
+   >>> st = parser.expr('a + 5')
+   >>> code = st.compile('file.py')
    >>> a = 5
    >>> eval(code)
    10
 
-An application which needs both AST and code objects can package this code into
+An application which needs both ST and code objects can package this code into
 readily available functions::
 
    import parser
 
    def load_suite(source_string):
-       ast = parser.suite(source_string)
-       return ast, ast.compile()
+       st = parser.suite(source_string)
+       return st, st.compile()
 
    def load_expression(source_string):
-       ast = parser.expr(source_string)
-       return ast, ast.compile()
+       st = parser.expr(source_string)
+       return st, st.compile()
 
 
 Information Discovery
@@ -414,8 +425,8 @@
 
    >>> import parser
    >>> import pprint
-   >>> ast = parser.suite(open('docstring.py').read())
-   >>> tup = ast.totuple()
+   >>> st = parser.suite(open('docstring.py').read())
+   >>> tup = st.totuple()
    >>> pprint.pprint(tup)
    (257,
     (264,
@@ -670,8 +681,8 @@
 
        source = open(fileName).read()
        basename = os.path.basename(os.path.splitext(fileName)[0])
-       ast = parser.suite(source)
-       return ModuleInfo(ast.totuple(), basename)
+       st = parser.suite(source)
+       return ModuleInfo(st.totuple(), basename)
 
 This provides an easy-to-use interface to the documentation of a module.  If
 information is required which is not extracted by the code of this example, the

Modified: python/branches/py3k/Doc/library/threading.rst
==============================================================================
--- python/branches/py3k/Doc/library/threading.rst	(original)
+++ python/branches/py3k/Doc/library/threading.rst	Tue Jun 10 18:37:50 2008
@@ -643,6 +643,17 @@
    constructor.
 
 
+.. method:: Thread.getIdent()
+
+   Return the 'thread identifier' of this thread or None if the thread has not
+   been started.  This is a nonzero integer.  See the :mod:`thread` module's
+   :func:`get_ident()` function.  Thread identifiers may be recycled when a
+   thread exits and another thread is created.  The identifier is returned
+   even after the thread has exited.
+
+   .. versionadded:: 2.6
+
+
 .. method:: Thread.isAlive()
 
    Return whether the thread is alive.

Modified: python/branches/py3k/Doc/whatsnew/2.5.rst
==============================================================================
--- python/branches/py3k/Doc/whatsnew/2.5.rst	(original)
+++ python/branches/py3k/Doc/whatsnew/2.5.rst	Tue Jun 10 18:37:50 2008
@@ -2205,10 +2205,10 @@
 * MacOS X (10.3 and higher): dynamic loading of modules now uses the
   :cfunc:`dlopen` function instead of MacOS-specific functions.
 
-* MacOS X: a :option:`--enable-universalsdk` switch was added to the
+* MacOS X: an :option:`--enable-universalsdk` switch was added to the
   :program:`configure` script that compiles the interpreter as a universal binary
   able to run on both PowerPC and Intel processors. (Contributed by Ronald
-  Oussoren.)
+  Oussoren; :issue:`2573`.)
 
 * Windows: :file:`.dll` is no longer supported as a filename extension for
   extension modules.  :file:`.pyd` is now the only filename extension that will be

Modified: python/branches/py3k/Doc/whatsnew/2.6.rst
==============================================================================
--- python/branches/py3k/Doc/whatsnew/2.6.rst	(original)
+++ python/branches/py3k/Doc/whatsnew/2.6.rst	Tue Jun 10 18:37:50 2008
@@ -648,6 +648,7 @@
     >>> format(75.6564, '.2f')
     '75.66'
 
+
 .. seealso::
 
    :ref:`formatstrings`
@@ -1252,6 +1253,11 @@
 
   (Contributed by Alexander Belopolsky; :issue:`1686487`.)
 
+* A new built-in, ``next(*iterator*, [*default*])`` returns the next item
+  from the specified iterator.  If the *default* argument is supplied,
+  it will be returned if *iterator* has been exhausted; otherwise,
+  the :exc:`StopIteration` exception will be raised.  (:issue:`2719`)
+
 * Tuples now have an :meth:`index` method matching the list type's
   :meth:`index` method::
 
@@ -1553,6 +1559,7 @@
   :mod:`terminalcommand`.
 
   A number of old IRIX-specific modules were deprecated:
+  :mod:`al` and :mod:`AL`,
   :mod:`cd`,
   :mod:`cddb`,
   :mod:`cdplayer`,
@@ -1664,7 +1671,11 @@
 
   (Contributed by Raymond Hettinger.)
 
-* The :mod:`ctypes` module now supports a :class:`c_bool` datatype 
+* XXX Describe the new ctypes calling convention that allows safe
+  access to errno.
+  (Implemented by Thomas Heller; :issue:`1798`.)
+
+* The :mod:`ctypes` module now supports a :class:`c_bool` datatype
   that represents the C99 ``bool`` type.  (Contributed by David Remahl;
   :issue:`1649190`.)
 
@@ -1733,7 +1744,14 @@
   to drop the built-in in the 2.x series.  (Patched by 
   Christian Heimes; :issue:`1739906`.)
 
-* The :func:`glob.glob` function can now return Unicode filenames if 
+* When possible, the :mod:`getpass` module will now use
+  :file:`/dev/tty` (when available) to print
+  a prompting message and read the password, falling back to using
+  standard error and standard input.    If the password may be echoed to 
+  the terminal, a warning is printed before the prompt is displayed.
+  (Contributed by Gregory P. Smith.)
+
+* The :func:`glob.glob` function can now return Unicode filenames if
   a Unicode path was used and Unicode filenames are matched within the
   directory.  (:issue:`1001604`)
 
@@ -1752,6 +1770,10 @@
   This is more efficient than making a call to :func:`heappush` and then
   :func:`heappop`.
 
+  :mod:`heapq` is now implemented to only use less-than comparison,
+  instead of the less-than-or-equal comparison it previously used.
+  This makes :mod:`heapq`'s usage of a type match that of the 
+  :meth:`list.sort` method.
   (Contributed by Raymond Hettinger.)
 
 * An optional ``timeout`` parameter was added to the
@@ -1846,6 +1868,11 @@
   is true, opening of the log file is deferred until the first
   :meth:`emit` call is made.  (Contributed by Vinay Sajip.)
 
+  :class:`TimedRotatingFileHandler` also has a *utc* constructor 
+  parameter.  If the argument is true, UTC time will be used 
+  in determining when midnight occurs and in generating filenames;
+  otherwise local time will be used.
+
 * The :mod:`macfs` module has been removed.  This in turn required the
   :func:`macostools.touched` function to be removed because it depended on the
   :mod:`macfs` module.  (:issue:`1490190`)
@@ -2112,13 +2139,21 @@
   are written or not.
   (Contributed by Neal Norwitz and Georg Brandl.)
 
-  Information about the command-line arguments supplied to the Python 
-  interpreter are available as attributes of a ``sys.flags`` named 
-  tuple.  For example, the :attr:`verbose` attribute is true if Python 
+  Information about the command-line arguments supplied to the Python
+  interpreter is available by reading attributes of a named
+  tuple available as ``sys.flags``.  For example, the :attr:`verbose`
+  attribute is true if Python
   was executed in verbose mode, :attr:`debug` is true in debugging mode, etc.
   These attributes are all read-only.
   (Contributed by Christian Heimes.)
 
+  A new function, :func:`getsizeof`, takes a Python object and returns 
+  the amount of memory used by the object, measured in bytes.  Built-in
+  objects return correct results; third-party extensions may not,
+  but can define a :meth:`__sizeof__` method to return the 
+  object's size.
+  (Contributed by Robert Schuppenies; :issue:`2898`.)
+
   It's now possible to determine the current profiler and tracer functions
   by calling :func:`sys.getprofile` and :func:`sys.gettrace`.  
   (Contributed by Georg Brandl; :issue:`1648`.)
@@ -2204,7 +2239,11 @@
 
   (Contributed by Dwayne Bailey; :issue:`1581073`.)
 
-* The :mod:`timeit` module now accepts callables as well as strings 
+* 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`.)
+
+* The :mod:`timeit` module now accepts callables as well as strings
   for the statement being timed and for the setup code.
   Two convenience functions were added for creating 
   :class:`Timer` instances: 
@@ -2213,6 +2252,24 @@
   the corresponding method. (Contributed by Erik Demaine;
   :issue:`1533909`.)
 
+* The :mod:`turtle` module for turtle graphics was greatly enhanced by
+  Gregor Lingl.  New features in the module include:
+
+  * Better animation of turtle movement and rotation.
+  * Control over turtle movement using the new delay(), 
+    tracer(), and speed() methods.
+  * The ability to set new shapes for the turtle, and to 
+    define a new coordinate system.
+  * Turtles now have an undo() method that can roll back actions.
+  * Simple support for reacting to input events such as mouse and keyboard
+    activity, making it possible to write simple games.
+  * A :file:`turtle.cfg` file can be used to customize the starting appearance 
+    of the turtle's screen.
+  * The module's docstrings can be replaced by new docstrings that have been
+    translated into another language.
+  
+  (:issue:`1513695`)
+
 * An optional ``timeout`` parameter was added to the
   :func:`urllib.urlopen` function and the
   :class:`urllib.ftpwrapper` class constructor, as well as the 
@@ -2255,8 +2312,10 @@
   not necessarily correct for all applications.  Code using
   :mod:`xmlrpclib` should convert :class:`date` and :class:`time` 
   instances. (:issue:`1330538`)  The code can also handle 
-  dates before 1900.  (Contributed by Ralf Schmitt; :issue:`2014`.)
-
+  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`).
+  
 * The :mod:`zipfile` module's :class:`ZipFile` class now has 
   :meth:`extract` and :meth:`extractall` methods that will unpack 
   a single file or all the files in the archive to the current directory, or 
@@ -2272,9 +2331,14 @@
 
   (Contributed by Alan McIntyre; :issue:`467924`.)
 
-  Also, :mod:`zipfile` now supports using Unicode filenames
-  for archived files.  (Contributed by Alexey Borzenkov; :issue:`1734346`.)
+  The :meth:`open`, :meth:`read` and :meth:`extract` methods can now 
+  take either a filename or a :class:`ZipInfo` object.  This is useful when an
+  archive accidentally contains a duplicated filename.
+  (Contributed by Graham Horler; :issue:`1775025`.)
 
+  Finally, :mod:`zipfile` now supports using Unicode filenames
+  for archived files.  (Contributed by Alexey Borzenkov; :issue:`1734346`.)
+  
 .. ======================================================================
 .. whole new modules get described in subsections here
 
@@ -2469,10 +2533,8 @@
   results, and then compiles using these results for optimization.
   (Contributed by Gregory P. Smith.)
 
-
 .. ======================================================================
 
-
 Port-Specific Changes: Windows
 -----------------------------------
 
@@ -2517,6 +2579,16 @@
 
 .. ======================================================================
 
+Port-Specific Changes: MacOS X
+-----------------------------------
+
+* When compiling a framework build of Python, you can now specify the 
+  framework name to be used by providing the 
+  :option:`--with-framework-name=` option to the 
+  :program:`configure` script.
+
+.. ======================================================================
+
 
 .. _section-other:
 

Modified: python/branches/py3k/Include/bytearrayobject.h
==============================================================================
--- python/branches/py3k/Include/bytearrayobject.h	(original)
+++ python/branches/py3k/Include/bytearrayobject.h	Tue Jun 10 18:37:50 2008
@@ -1,7 +1,7 @@
-/* Bytes object interface */
+/* ByteArray object interface */
 
-#ifndef Py_BYTESOBJECT_H
-#define Py_BYTESOBJECT_H
+#ifndef Py_BYTEARRAYOBJECT_H
+#define Py_BYTEARRAYOBJECT_H
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -50,4 +50,4 @@
 #ifdef __cplusplus
 }
 #endif
-#endif /* !Py_BYTESOBJECT_H */
+#endif /* !Py_BYTEARRAYOBJECT_H */

Modified: python/branches/py3k/Include/bytesobject.h
==============================================================================
--- python/branches/py3k/Include/bytesobject.h	(original)
+++ python/branches/py3k/Include/bytesobject.h	Tue Jun 10 18:37:50 2008
@@ -1,8 +1,8 @@
 
-/* String object interface */
+/* Bytes (String) object interface */
 
-#ifndef Py_STRINGOBJECT_H
-#define Py_STRINGOBJECT_H
+#ifndef Py_BYTESOBJECT_H
+#define Py_BYTESOBJECT_H
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -107,4 +107,4 @@
 #ifdef __cplusplus
 }
 #endif
-#endif /* !Py_STRINGOBJECT_H */
+#endif /* !Py_BYTESOBJECT_H */

Copied: python/branches/py3k/Lib/ast.py (from r64065, /python/trunk/Lib/ast.py)
==============================================================================
--- /python/trunk/Lib/ast.py	(original)
+++ python/branches/py3k/Lib/ast.py	Tue Jun 10 18:37:50 2008
@@ -44,7 +44,7 @@
     and None.
     """
     _safe_names = {'None': None, 'True': True, 'False': False}
-    if isinstance(node_or_string, basestring):
+    if isinstance(node_or_string, str):
         node_or_string = parse(node_or_string, mode='eval')
     if isinstance(node_or_string, Expression):
         node_or_string = node_or_string.body

Modified: python/branches/py3k/Lib/inspect.py
==============================================================================
--- python/branches/py3k/Lib/inspect.py	(original)
+++ python/branches/py3k/Lib/inspect.py	Tue Jun 10 18:37:50 2008
@@ -368,6 +368,13 @@
         return None
     if not isinstance(doc, str):
         return None
+    return cleandoc(doc)
+
+def cleandoc(doc):
+    """Clean up indentation from docstrings.
+
+    Any whitespace that can be uniformly removed from the second line
+    onwards is removed."""
     try:
         lines = doc.expandtabs().split('\n')
     except UnicodeError:

Modified: python/branches/py3k/Lib/test/test_ast.py
==============================================================================
--- python/branches/py3k/Lib/test/test_ast.py	(original)
+++ python/branches/py3k/Lib/test/test_ast.py	Tue Jun 10 18:37:50 2008
@@ -1,6 +1,6 @@
 import sys, unittest
 from test import support
-import _ast
+import ast
 
 def to_tuple(t):
     if t is None or isinstance(t, (str, int, complex)):
@@ -117,9 +117,9 @@
 class AST_Tests(unittest.TestCase):
 
     def _assert_order(self, ast_node, parent_pos):
-        if not isinstance(ast_node, _ast.AST) or ast_node._fields is None:
+        if not isinstance(ast_node, ast.AST) or ast_node._fields is None:
             return
-        if isinstance(ast_node, (_ast.expr, _ast.stmt, _ast.excepthandler)):
+        if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)):
             node_pos = (ast_node.lineno, ast_node.col_offset)
             self.assert_(node_pos >= parent_pos)
             parent_pos = (ast_node.lineno, ast_node.col_offset)
@@ -136,29 +136,29 @@
                                     (single_tests, single_results, "single"),
                                     (eval_tests, eval_results, "eval")):
             for i, o in zip(input, output):
-                ast_tree = compile(i, "?", kind, _ast.PyCF_ONLY_AST)
+                ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST)
                 self.assertEquals(to_tuple(ast_tree), o)
                 self._assert_order(ast_tree, (0, 0))
 
     def test_nodeclasses(self):
-        x = _ast.BinOp(1, 2, 3, lineno=0)
+        x = ast.BinOp(1, 2, 3, lineno=0)
         self.assertEquals(x.left, 1)
         self.assertEquals(x.op, 2)
         self.assertEquals(x.right, 3)
         self.assertEquals(x.lineno, 0)
 
         # node raises exception when not given enough arguments
-        self.assertRaises(TypeError, _ast.BinOp, 1, 2)
+        self.assertRaises(TypeError, ast.BinOp, 1, 2)
 
         # can set attributes through kwargs too
-        x = _ast.BinOp(left=1, op=2, right=3, lineno=0)
+        x = ast.BinOp(left=1, op=2, right=3, lineno=0)
         self.assertEquals(x.left, 1)
         self.assertEquals(x.op, 2)
         self.assertEquals(x.right, 3)
         self.assertEquals(x.lineno, 0)
 
         # this used to fail because Sub._fields was None
-        x = _ast.Sub()
+        x = ast.Sub()
 
     def test_pickling(self):
         import pickle
@@ -175,8 +175,99 @@
                     ast2 = mod.loads(mod.dumps(ast, protocol))
                     self.assertEquals(to_tuple(ast2), to_tuple(ast))
 
+
+class ASTHelpers_Test(unittest.TestCase):
+
+    def test_parse(self):
+        a = ast.parse('foo(1 + 1)')
+        b = compile('foo(1 + 1)', '<unknown>', 'exec', ast.PyCF_ONLY_AST)
+        self.assertEqual(ast.dump(a), ast.dump(b))
+
+    def test_dump(self):
+        node = ast.parse('spam(eggs, "and cheese")')
+        self.assertEqual(ast.dump(node),
+            "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), "
+            "args=[Name(id='eggs', ctx=Load()), Str(s='and cheese')], "
+            "keywords=[], starargs=None, kwargs=None))])"
+        )
+        self.assertEqual(ast.dump(node, annotate_fields=False),
+            "Module([Expr(Call(Name('spam', Load()), [Name('eggs', Load()), "
+            "Str('and cheese')], [], None, None))])"
+        )
+        self.assertEqual(ast.dump(node, include_attributes=True),
+            "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load(), "
+            "lineno=1, col_offset=0), args=[Name(id='eggs', ctx=Load(), "
+            "lineno=1, col_offset=5), Str(s='and cheese', lineno=1, "
+            "col_offset=11)], keywords=[], starargs=None, kwargs=None, "
+            "lineno=1, col_offset=0), lineno=1, col_offset=0)])"
+        )
+
+    def test_copy_location(self):
+        src = ast.parse('1 + 1', mode='eval')
+        src.body.right = ast.copy_location(ast.Num(2), src.body.right)
+        self.assertEqual(ast.dump(src, include_attributes=True),
+            'Expression(body=BinOp(left=Num(n=1, lineno=1, col_offset=0), '
+            'op=Add(), right=Num(n=2, lineno=1, col_offset=4), lineno=1, '
+            'col_offset=0))'
+        )
+
+    def test_fix_missing_locations(self):
+        src = ast.parse('write("spam")')
+        src.body.append(ast.Expr(ast.Call(ast.Name('spam', ast.Load()),
+                                          [ast.Str('eggs')], [], None, None)))
+        self.assertEqual(src, ast.fix_missing_locations(src))
+        self.assertEqual(ast.dump(src, include_attributes=True),
+            "Module(body=[Expr(value=Call(func=Name(id='write', ctx=Load(), "
+            "lineno=1, col_offset=0), args=[Str(s='spam', lineno=1, "
+            "col_offset=6)], keywords=[], starargs=None, kwargs=None, "
+            "lineno=1, col_offset=0), lineno=1, col_offset=0), "
+            "Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, "
+            "col_offset=0), args=[Str(s='eggs', lineno=1, col_offset=0)], "
+            "keywords=[], starargs=None, kwargs=None, lineno=1, "
+            "col_offset=0), lineno=1, col_offset=0)])"
+        )
+
+    def test_increment_lineno(self):
+        src = ast.parse('1 + 1', mode='eval')
+        self.assertEqual(ast.increment_lineno(src, n=3), src)
+        self.assertEqual(ast.dump(src, include_attributes=True),
+            'Expression(body=BinOp(left=Num(n=1, lineno=4, col_offset=0), '
+            'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, '
+            'col_offset=0))'
+        )
+
+    def test_iter_fields(self):
+        node = ast.parse('foo()', mode='eval')
+        d = dict(ast.iter_fields(node.body))
+        self.assertEqual(d.pop('func').id, 'foo')
+        self.assertEqual(d, {'keywords': [], 'kwargs': None,
+                             'args': [], 'starargs': None})
+
+    def test_iter_child_nodes(self):
+        node = ast.parse("spam(23, 42, eggs='leek')", mode='eval')
+        self.assertEqual(len(list(ast.iter_child_nodes(node.body))), 4)
+        iterator = ast.iter_child_nodes(node.body)
+        self.assertEqual(next(iterator).id, 'spam')
+        self.assertEqual(next(iterator).n, 23)
+        self.assertEqual(next(iterator).n, 42)
+        self.assertEqual(ast.dump(next(iterator)),
+            "keyword(arg='eggs', value=Str(s='leek'))"
+        )
+
+    def test_get_docstring(self):
+        node = ast.parse('def foo():\n  """line one\n  line two"""')
+        self.assertEqual(ast.get_docstring(node.body[0]),
+                         'line one\nline two')
+
+    def test_literal_eval(self):
+        self.assertEqual(ast.literal_eval('[1, 2, 3]'), [1, 2, 3])
+        self.assertEqual(ast.literal_eval('{"foo": 42}'), {"foo": 42})
+        self.assertEqual(ast.literal_eval('(True, False, None)'), (True, False, None))
+        self.assertRaises(ValueError, ast.literal_eval, 'foo()')
+
+
 def test_main():
-    support.run_unittest(AST_Tests)
+    support.run_unittest(AST_Tests, ASTHelpers_Test)
 
 def main():
     if __name__ != '__main__':

Modified: python/branches/py3k/Lib/test/test_complex.py
==============================================================================
--- python/branches/py3k/Lib/test/test_complex.py	(original)
+++ python/branches/py3k/Lib/test/test_complex.py	Tue Jun 10 18:37:50 2008
@@ -352,6 +352,14 @@
             except (OSError, IOError):
                 pass
 
+    def test_getnewargs(self):
+        self.assertEqual((1+2j).__getnewargs__(), (1.0, 2.0))
+        self.assertEqual((1-2j).__getnewargs__(), (1.0, -2.0))
+        self.assertEqual((2j).__getnewargs__(), (0.0, 2.0))
+        self.assertEqual((-0j).__getnewargs__(), (0.0, -0.0))
+        self.assertEqual(complex(0, INF).__getnewargs__(), (0.0, INF))
+        self.assertEqual(complex(INF, 0).__getnewargs__(), (INF, 0.0))
+
     if float.__getformat__("double").startswith("IEEE"):
         def test_plus_minus_0j(self):
             # test that -0j and 0j literals are not identified

Modified: python/branches/py3k/Lib/test/test_inspect.py
==============================================================================
--- python/branches/py3k/Lib/test/test_inspect.py	(original)
+++ python/branches/py3k/Lib/test/test_inspect.py	Tue Jun 10 18:37:50 2008
@@ -195,6 +195,10 @@
         self.assertEqual(inspect.getdoc(git.abuse),
                          'Another\n\ndocstring\n\ncontaining\n\ntabs')
 
+    def test_cleandoc(self):
+        self.assertEqual(inspect.cleandoc('An\n    indented\n    docstring.'),
+                         'An\nindented\ndocstring.')
+
     def test_getcomments(self):
         self.assertEqual(inspect.getcomments(mod), '# line 1\n')
         self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n')

Modified: python/branches/py3k/Lib/test/test_threading.py
==============================================================================
--- python/branches/py3k/Lib/test/test_threading.py	(original)
+++ python/branches/py3k/Lib/test/test_threading.py	Tue Jun 10 18:37:50 2008
@@ -3,6 +3,7 @@
 import test.support
 from test.support import verbose
 import random
+import re
 import sys
 import threading
 import _thread
@@ -71,6 +72,8 @@
         for i in range(NUMTASKS):
             t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
             threads.append(t)
+            self.failUnlessEqual(t.getIdent(), None)
+            self.assert_(re.match('<TestThread\(.*, initial\)>', repr(t)))
             t.start()
 
         if verbose:
@@ -78,6 +81,8 @@
         for t in threads:
             t.join(NUMTASKS)
             self.assert_(not t.isAlive())
+            self.failIfEqual(t.getIdent(), 0)
+            self.assert_(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
         if verbose:
             print('all tasks done')
         self.assertEqual(numrunning.get(), 0)

Modified: python/branches/py3k/Lib/threading.py
==============================================================================
--- python/branches/py3k/Lib/threading.py	(original)
+++ python/branches/py3k/Lib/threading.py	Tue Jun 10 18:37:50 2008
@@ -401,6 +401,7 @@
         self._args = args
         self._kwargs = kwargs
         self._daemonic = self._set_daemon()
+        self._ident = None
         self._started = Event()
         self._stopped = False
         self._block = Condition(Lock())
@@ -421,7 +422,9 @@
         if self._stopped:
             status = "stopped"
         if self._daemonic:
-            status = status + " daemon"
+            status += " daemon"
+        if self._ident is not None:
+            status += " %s" % self._ident
         return "<%s(%s, %s)>" % (self.__class__.__name__, self._name, status)
 
     def start(self):
@@ -469,9 +472,10 @@
 
     def _bootstrap_inner(self):
         try:
+            self._ident = _get_ident()
             self._started.set()
             _active_limbo_lock.acquire()
-            _active[_get_ident()] = self
+            _active[self._ident] = self
             del _limbo[self]
             _active_limbo_lock.release()
             if __debug__:
@@ -536,7 +540,7 @@
             with _active_limbo_lock:
                 self._stop()
                 try:
-                    # We don't call self.__delete() because it also
+                    # We don't call self._delete() because it also
                     # grabs _active_limbo_lock.
                     del _active[_get_ident()]
                 except:
@@ -625,6 +629,10 @@
         assert self._initialized, "Thread.__init__() not called"
         self._name = str(name)
 
+    def getIdent(self):
+        assert self._initialized, "Thread.__init__() not called"
+        return self._ident
+
     def isAlive(self):
         assert self._initialized, "Thread.__init__() not called"
         return self._started.isSet() and not self._stopped

Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS	(original)
+++ python/branches/py3k/Misc/ACKS	Tue Jun 10 18:37:50 2008
@@ -155,6 +155,7 @@
 Jonathan Dasteel
 John DeGood
 Vincent Delft
+Arnaud Delobelle
 Erik Demaine
 Roger Dev
 Raghuram Devarakonda
@@ -573,6 +574,7 @@
 Kevin Rodgers
 Giampaolo Rodola
 Mike Romberg
+Armin Ronacher
 Case Roole
 Timothy Roscoe
 Jim Roskind

Modified: python/branches/py3k/Misc/developers.txt
==============================================================================
--- python/branches/py3k/Misc/developers.txt	(original)
+++ python/branches/py3k/Misc/developers.txt	Tue Jun 10 18:37:50 2008
@@ -17,6 +17,9 @@
 Permissions History
 -------------------
 
+- Gregor Lingl was given SVN access on 10 June 2008 by MvL,
+  for work on the turtle module.
+
 - Robert Schuppenies was given SVN access on 21 May 2008 by MvL,
   for GSoC contributions.
 

Modified: python/branches/py3k/Modules/itertoolsmodule.c
==============================================================================
--- python/branches/py3k/Modules/itertoolsmodule.c	(original)
+++ python/branches/py3k/Modules/itertoolsmodule.c	Tue Jun 10 18:37:50 2008
@@ -2019,7 +2019,7 @@
 }
 
 PyDoc_STRVAR(combinations_doc,
-"combinations(iterables) --> combinations object\n\
+"combinations(iterable[, r]) --> combinations object\n\
 \n\
 Return successive r-length combinations of elements in the iterable.\n\n\
 combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)");
@@ -2294,10 +2294,10 @@
 }
 
 PyDoc_STRVAR(permutations_doc,
-"permutations(iterables[, r]) --> permutations object\n\
+"permutations(iterable[, r]) --> permutations object\n\
 \n\
 Return successive r-length permutations of elements in the iterable.\n\n\
-permutations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)");
+permutations(range(3), 2) --> (0,1), (0,2), (1,0), (1,2), (2,0), (2,1)");
 
 static PyTypeObject permutations_type = {
 	PyVarObject_HEAD_INIT(NULL, 0)

Modified: python/branches/py3k/Objects/complexobject.c
==============================================================================
--- python/branches/py3k/Objects/complexobject.c	(original)
+++ python/branches/py3k/Objects/complexobject.c	Tue Jun 10 18:37:50 2008
@@ -693,7 +693,8 @@
 static PyObject *
 complex_getnewargs(PyComplexObject *v)
 {
-	return Py_BuildValue("(D)", &v->cval);
+	Py_complex c = v->cval;
+	return Py_BuildValue("(dd)", c.real, c.imag);
 }
 
 #if 0


More information about the Python-3000-checkins mailing list