[Python-checkins] r67184 - in python/branches/tlee-ast-optimize: Doc/conf.py Doc/documenting/index.rst Doc/documenting/markup.rst Doc/documenting/rest.rst Doc/documenting/sphinx.rst Doc/documenting/style.rst Doc/library/ast.rst Doc/library/email.parser.rst Doc/library/functions.rst Doc/library/select.rst Doc/library/socket.rst Doc/library/sqlite3.rst Doc/library/threading.rst Doc/tutorial/controlflow.rst Doc/using/cmdline.rst Lib/lib-tk/Tkinter.py Lib/lib2to3 Lib/lib2to3/fixes/fix_import.py Lib/lib2to3/fixes/fix_imports.py Lib/lib2to3/fixes/fix_metaclass.py Lib/lib2to3/refactor.py Lib/lib2to3/tests/test_fixers.py Lib/string.py Lib/test/test_fileio.py Lib/test/test_io.py Lib/test/test_parser.py Lib/test/test_syntax.py Misc/ACKS Misc/NEWS Modules/_multiprocessing/multiprocessing.h Modules/parsermodule.c Modules/posixmodule.c Modules/readline.c PCbuild/pyd.vsprops PCbuild/pyd_d.vsprops Python/ast.c Python/compile.c Tools/msi/msi.py configure configure.in setup.py
thomas.lee
python-checkins at python.org
Tue Nov 11 12:41:00 CET 2008
Author: thomas.lee
Date: Tue Nov 11 12:40:58 2008
New Revision: 67184
Log:
Merged revisions 67077,67082,67089,67091,67098,67101,67117-67120,67123-67125,67143,67149,67154,67157-67159,67162-67163,67166,67171,67175-67176,67180 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67077 | benjamin.peterson | 2008-11-04 02:14:51 +1100 (Tue, 04 Nov 2008) | 1 line
#4048 make the parser module accept relative imports as valid
................
r67082 | hirokazu.yamamoto | 2008-11-04 05:03:06 +1100 (Tue, 04 Nov 2008) | 2 lines
Issue #3774: Fixed an error when create a Tkinter menu item without command
and then remove it. Written by Guilherme Polo (gpolo).
................
r67089 | benjamin.peterson | 2008-11-04 07:43:20 +1100 (Tue, 04 Nov 2008) | 1 line
clarify by splitting into multiple paragraphs
................
r67091 | benjamin.peterson | 2008-11-04 09:34:57 +1100 (Tue, 04 Nov 2008) | 1 line
move a FileIO test to test_fileio
................
r67098 | martin.v.loewis | 2008-11-05 07:40:09 +1100 (Wed, 05 Nov 2008) | 2 lines
Issue #4204: Fixed module build errors on FreeBSD 4.
................
r67101 | georg.brandl | 2008-11-05 07:49:35 +1100 (Wed, 05 Nov 2008) | 2 lines
#4167: fix markup glitches.
................
r67117 | georg.brandl | 2008-11-06 21:17:58 +1100 (Thu, 06 Nov 2008) | 2 lines
#4268: Use correct module for two toplevel functions.
................
r67118 | georg.brandl | 2008-11-06 21:19:11 +1100 (Thu, 06 Nov 2008) | 2 lines
#4267: small fixes in sqlite3 docs.
................
r67119 | georg.brandl | 2008-11-06 21:20:49 +1100 (Thu, 06 Nov 2008) | 2 lines
#4245: move Thread section to the top.
................
r67120 | martin.v.loewis | 2008-11-07 03:43:00 +1100 (Fri, 07 Nov 2008) | 2 lines
Issue #4120: Exclude manifest from extension modules in VS2008.
................
r67123 | georg.brandl | 2008-11-07 05:49:15 +1100 (Fri, 07 Nov 2008) | 2 lines
#4247: add "pass" examples to tutorial.
................
r67124 | andrew.kuchling | 2008-11-07 06:23:02 +1100 (Fri, 07 Nov 2008) | 1 line
Fix grammar error; reword two paragraphs
................
r67125 | martin.v.loewis | 2008-11-07 06:46:03 +1100 (Fri, 07 Nov 2008) | 2 lines
Stop including fake manifest file in DLLs directory.
................
r67143 | georg.brandl | 2008-11-07 19:27:39 +1100 (Fri, 07 Nov 2008) | 2 lines
Fix syntax.
................
r67149 | martin.v.loewis | 2008-11-08 05:51:50 +1100 (Sat, 08 Nov 2008) | 1 line
Issue #1656675: Register a drop handler for .py* files on Windows.
................
r67154 | hirokazu.yamamoto | 2008-11-08 14:46:17 +1100 (Sat, 08 Nov 2008) | 1 line
Issue #4071: ntpath.abspath returned an empty string for long unicode path.
................
r67157 | georg.brandl | 2008-11-08 22:47:44 +1100 (Sat, 08 Nov 2008) | 2 lines
Don't use "HOWTO" as the title for all howto .tex files.
................
r67158 | georg.brandl | 2008-11-08 22:48:20 +1100 (Sat, 08 Nov 2008) | 2 lines
Update "Documenting" a bit. Concentrate on Python-specifics.
................
r67159 | georg.brandl | 2008-11-08 23:52:25 +1100 (Sat, 08 Nov 2008) | 2 lines
Fix warning.
................
r67162 | benjamin.peterson | 2008-11-09 03:55:33 +1100 (Sun, 09 Nov 2008) | 1 line
a few compile() and ast doc improvements
................
r67163 | benjamin.peterson | 2008-11-09 04:04:18 +1100 (Sun, 09 Nov 2008) | 1 line
move context clue to versionchanged tag
................
r67166 | benjamin.peterson | 2008-11-09 04:07:06 +1100 (Sun, 09 Nov 2008) | 1 line
clarify what was added
................
r67171 | benjamin.peterson | 2008-11-09 05:38:54 +1100 (Sun, 09 Nov 2008) | 4 lines
check for assignment to __debug__ during AST generation
Also, give assignment to None a better error message
................
r67175 | benjamin.peterson | 2008-11-09 12:44:32 +1100 (Sun, 09 Nov 2008) | 1 line
update link
................
r67176 | benjamin.peterson | 2008-11-09 12:52:32 +1100 (Sun, 09 Nov 2008) | 1 line
fix comment
................
r67180 | benjamin.peterson | 2008-11-11 09:11:12 +1100 (Tue, 11 Nov 2008) | 29 lines
Merged revisions 66985,67170,67173,67177-67179 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r66985 | benjamin.peterson | 2008-10-20 16:43:46 -0500 (Mon, 20 Oct 2008) | 1 line
no need to use nested try, except, finally
........
r67170 | benjamin.peterson | 2008-11-08 12:28:31 -0600 (Sat, 08 Nov 2008) | 1 line
fix #4271: fix_imports didn't recognize imports with parenthesis (ie from x import (a, b))
........
r67173 | benjamin.peterson | 2008-11-08 17:42:08 -0600 (Sat, 08 Nov 2008) | 1 line
consolidate test
........
r67177 | benjamin.peterson | 2008-11-09 21:52:52 -0600 (Sun, 09 Nov 2008) | 1 line
let the metclass fixer handle complex assignments in the class body gracefully
........
r67178 | benjamin.peterson | 2008-11-10 15:26:43 -0600 (Mon, 10 Nov 2008) | 1 line
the metaclass fixers shouldn't die when bases are not a simple name
........
r67179 | benjamin.peterson | 2008-11-10 15:29:58 -0600 (Mon, 10 Nov 2008) | 1 line
allow the fix_import pattern to catch from imports with parenthesis
........
................
Removed:
python/branches/tlee-ast-optimize/Doc/documenting/sphinx.rst
Modified:
python/branches/tlee-ast-optimize/ (props changed)
python/branches/tlee-ast-optimize/Doc/conf.py
python/branches/tlee-ast-optimize/Doc/documenting/index.rst
python/branches/tlee-ast-optimize/Doc/documenting/markup.rst
python/branches/tlee-ast-optimize/Doc/documenting/rest.rst
python/branches/tlee-ast-optimize/Doc/documenting/style.rst
python/branches/tlee-ast-optimize/Doc/library/ast.rst
python/branches/tlee-ast-optimize/Doc/library/email.parser.rst
python/branches/tlee-ast-optimize/Doc/library/functions.rst
python/branches/tlee-ast-optimize/Doc/library/select.rst
python/branches/tlee-ast-optimize/Doc/library/socket.rst
python/branches/tlee-ast-optimize/Doc/library/sqlite3.rst
python/branches/tlee-ast-optimize/Doc/library/threading.rst
python/branches/tlee-ast-optimize/Doc/tutorial/controlflow.rst
python/branches/tlee-ast-optimize/Doc/using/cmdline.rst
python/branches/tlee-ast-optimize/Lib/lib-tk/Tkinter.py
python/branches/tlee-ast-optimize/Lib/lib2to3/ (props changed)
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_import.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_metaclass.py
python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py
python/branches/tlee-ast-optimize/Lib/string.py
python/branches/tlee-ast-optimize/Lib/test/test_fileio.py
python/branches/tlee-ast-optimize/Lib/test/test_io.py
python/branches/tlee-ast-optimize/Lib/test/test_parser.py
python/branches/tlee-ast-optimize/Lib/test/test_syntax.py
python/branches/tlee-ast-optimize/Misc/ACKS
python/branches/tlee-ast-optimize/Misc/NEWS
python/branches/tlee-ast-optimize/Modules/_multiprocessing/multiprocessing.h
python/branches/tlee-ast-optimize/Modules/parsermodule.c
python/branches/tlee-ast-optimize/Modules/posixmodule.c
python/branches/tlee-ast-optimize/Modules/readline.c
python/branches/tlee-ast-optimize/PCbuild/pyd.vsprops
python/branches/tlee-ast-optimize/PCbuild/pyd_d.vsprops
python/branches/tlee-ast-optimize/Python/ast.c
python/branches/tlee-ast-optimize/Python/compile.c
python/branches/tlee-ast-optimize/Tools/msi/msi.py
python/branches/tlee-ast-optimize/configure
python/branches/tlee-ast-optimize/configure.in
python/branches/tlee-ast-optimize/setup.py
Modified: python/branches/tlee-ast-optimize/Doc/conf.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/conf.py (original)
+++ python/branches/tlee-ast-optimize/Doc/conf.py Tue Nov 11 12:40:58 2008
@@ -128,7 +128,7 @@
]
# Collect all HOWTOs individually
latex_documents.extend(('howto/' + fn[:-4], 'howto-' + fn[:-4] + '.tex',
- 'HOWTO', _stdauthor, 'howto')
+ '', _stdauthor, 'howto')
for fn in os.listdir('howto')
if fn.endswith('.rst') and fn != 'index.rst')
Modified: python/branches/tlee-ast-optimize/Doc/documenting/index.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/documenting/index.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/documenting/index.rst Tue Nov 11 12:40:58 2008
@@ -8,7 +8,7 @@
The Python language has a substantial body of documentation, much of it
contributed by various authors. The markup used for the Python documentation is
`reStructuredText`_, developed by the `docutils`_ project, amended by custom
-directives and using a toolset named *Sphinx* to postprocess the HTML output.
+directives and using a toolset named `Sphinx`_ to postprocess the HTML output.
This document describes the style guide for our documentation, the custom
reStructuredText markup introduced to support Python documentation and how it
@@ -16,6 +16,7 @@
.. _reStructuredText: http://docutils.sf.net/rst.html
.. _docutils: http://docutils.sf.net/
+.. _Sphinx: http://sphinx.pocoo.org/
If you're interested in contributing to Python's documentation, there's no need
to write reStructuredText if you're not so inclined; plain text contributions
@@ -28,7 +29,3 @@
rest.rst
markup.rst
fromlatex.rst
- sphinx.rst
-
-.. XXX add credits, thanks etc.
-
Modified: python/branches/tlee-ast-optimize/Doc/documenting/markup.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/documenting/markup.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/documenting/markup.rst Tue Nov 11 12:40:58 2008
@@ -8,24 +8,11 @@
Documentation for "standard" reST constructs is not included here, though
they are used in the Python documentation.
-File-wide metadata
-------------------
-
-reST has the concept of "field lists"; these are a sequence of fields marked up
-like this::
-
- :Field name: Field content
-
-A field list at the very top of a file is parsed as the "docinfo", which in
-normal documents can be used to record the author, date of publication and
-other metadata. In Sphinx, the docinfo is used as metadata, too, but not
-displayed in the output.
-
-At the moment, only one metadata field is recognized:
+.. note::
-``nocomments``
- If set, the web application won't display a comment form for a page generated
- from this source file.
+ This is just an overview of Sphinx' extended markup capabilities; full
+ coverage can be found in `its own documentation
+ <http://sphinx.pocoo.org/contents.html>`_.
Meta-information markup
@@ -88,7 +75,6 @@
authors of the module code, just like ``sectionauthor`` names the author(s)
of a piece of documentation. It too does not result in any output currently.
-
.. note::
It is important to make the section title of a module-describing file
@@ -272,7 +258,7 @@
This language is used until the next ``highlightlang`` directive is
encountered.
-* The valid values for the highlighting language are:
+* The values normally used for the highlighting language are:
* ``python`` (the default)
* ``c``
@@ -799,7 +785,7 @@
-------------
The documentation system provides three substitutions that are defined by default.
-They are set in the build configuration file, see :ref:`doc-build-config`.
+They are set in the build configuration file :file:`conf.py`.
.. describe:: |release|
Modified: python/branches/tlee-ast-optimize/Doc/documenting/rest.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/documenting/rest.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/documenting/rest.rst Tue Nov 11 12:40:58 2008
@@ -67,12 +67,6 @@
#. This is a numbered list.
#. It has two items too.
-Note that Sphinx disables the use of enumerated lists introduced by alphabetic
-or roman numerals, such as ::
-
- A. First item
- B. Second item
-
Nested lists are possible, but be aware that they must be separated from the
parent list items by blank lines::
@@ -247,5 +241,3 @@
* **Separation of inline markup:** As said above, inline markup spans must be
separated from the surrounding text by non-word characters, you have to use
an escaped space to get around that.
-
-.. XXX more?
Deleted: python/branches/tlee-ast-optimize/Doc/documenting/sphinx.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/documenting/sphinx.rst Tue Nov 11 12:40:58 2008
+++ (empty file)
@@ -1,76 +0,0 @@
-.. highlightlang:: rest
-
-The Sphinx build system
-=======================
-
-.. XXX: intro...
-
-.. _doc-build-config:
-
-The build configuration file
-----------------------------
-
-The documentation root, that is the ``Doc`` subdirectory of the source
-distribution, contains a file named ``conf.py``. This file is called the "build
-configuration file", and it contains several variables that are read and used
-during a build run.
-
-These variables are:
-
-version : string
- A string that is used as a replacement for the ``|version|`` reST
- substitution. It should be the Python version the documentation refers to.
- This consists only of the major and minor version parts, e.g. ``2.5``, even
- for version 2.5.1.
-
-release : string
- A string that is used as a replacement for the ``|release|`` reST
- substitution. It should be the full version string including
- alpha/beta/release candidate tags, e.g. ``2.5.2b3``.
-
-Both ``release`` and ``version`` can be ``'auto'``, which means that they are
-determined at runtime from the ``Include/patchlevel.h`` file, if a complete
-Python source distribution can be found, or else from the interpreter running
-Sphinx.
-
-today_fmt : string
- A ``strftime`` format that is used to format a replacement for the
- ``|today|`` reST substitution.
-
-today : string
- A string that can contain a date that should be written to the documentation
- output literally. If this is nonzero, it is used instead of
- ``strftime(today_fmt)``.
-
-unused_files : list of strings
- A list of reST filenames that are to be disregarded during building. This
- could be docs for temporarily disabled modules or documentation that's not
- yet ready for public consumption.
-
-add_function_parentheses : bool
- If true, ``()`` will be appended to the content of ``:func:``, ``:meth:`` and
- ``:cfunc:`` cross-references.
-
-add_module_names : bool
- If true, the current module name will be prepended to all description unit
- titles (such as ``.. function::``).
-
-Builder-specific variables
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-html_download_base_url : string
- The base URL for download links on the download page.
-
-html_last_updated_fmt : string
- If this is not an empty string, it will be given to ``time.strftime()`` and
- written to each generated output file after "last updated on:".
-
-html_use_smartypants : bool
- If true, use SmartyPants to convert quotes and dashes to the typographically
- correct entities.
-
-latex_paper_size : "letter" or "a4"
- The paper size option for the LaTeX document class.
-
-latex_font_size : "10pt", "11pt" or "12pt"
- The font size option for the LaTeX document class.
\ No newline at end of file
Modified: python/branches/tlee-ast-optimize/Doc/documenting/style.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/documenting/style.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/documenting/style.rst Tue Nov 11 12:40:58 2008
@@ -66,5 +66,5 @@
1970s.
-.. _Apple Publications Style Guide: http://developer.apple.com/documentation/UserExperience/Conceptual/APStyleGuide/AppleStyleGuide2006.pdf
+.. _Apple Publications Style Guide: http://developer.apple.com/documentation/UserExperience/Conceptual/APStyleGuide/APSG_2008.pdf
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 Tue Nov 11 12:40:58 2008
@@ -21,13 +21,12 @@
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, or using the :func:`parse`
+An abstract syntax tree can be generated by passing :data:`ast.PyCF_ONLY_AST` as
+a flag to the :func:`compile` builtin function, or using the :func:`parse`
helper provided in this module. The result will be a tree of objects whose
-classes all inherit from :class:`ast.AST`.
+classes all inherit from :class:`ast.AST`. An abstract syntax tree can be
+compiled into a Python code object using the built-in :func:`compile` function.
-A modified abstract syntax tree can be compiled into a Python code object using
-the built-in :func:`compile` function.
Node classes
------------
@@ -126,7 +125,7 @@
.. function:: parse(expr, filename='<unknown>', mode='exec')
Parse an expression into an AST node. Equivalent to ``compile(expr,
- filename, mode, PyCF_ONLY_AST)``.
+ filename, mode, ast.PyCF_ONLY_AST)``.
.. function:: literal_eval(node_or_string)
Modified: python/branches/tlee-ast-optimize/Doc/library/email.parser.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/email.parser.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/email.parser.rst Tue Nov 11 12:40:58 2008
@@ -159,6 +159,7 @@
a common task, two functions are provided as a convenience. They are available
in the top-level :mod:`email` package namespace.
+.. currentmodule:: email
.. function:: message_from_string(s[, _class[, strict]])
Modified: python/branches/tlee-ast-optimize/Doc/library/functions.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/functions.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/functions.rst Tue Nov 11 12:40:58 2008
@@ -199,15 +199,8 @@
Compile the *source* into a code or AST object. Code objects can be executed
by an :keyword:`exec` statement or evaluated by a call to :func:`eval`.
- *source* can either be a string or an AST object. Refer to the :mod:`_ast`
- module documentation for information on how to compile into and from AST
- objects.
-
- When compiling a string with multi-line statements, two caveats apply: line
- endings must be represented by a single newline character (``'\n'``), and the
- input must be terminated by at least one newline character. If line endings
- are represented by ``'\r\n'``, use the string :meth:`replace` method to
- change them into ``'\n'``.
+ *source* can either be a string or an AST object. Refer to the :mod:`ast`
+ module documentation for information on how to work with AST objects.
The *filename* argument should give the file from which the code was read;
pass some recognizable value if it wasn't read from a file (``'<string>'`` is
@@ -219,15 +212,15 @@
interactive statement (in the latter case, expression statements that
evaluate to something else than ``None`` will be printed).
- The optional arguments *flags* and *dont_inherit* (which are new in Python 2.2)
- control which future statements (see :pep:`236`) affect the compilation of
- *source*. If neither is present (or both are zero) the code is compiled with
- those future statements that are in effect in the code that is calling compile.
- If the *flags* argument is given and *dont_inherit* is not (or is zero) then the
+ The optional arguments *flags* and *dont_inherit* control which future
+ statements (see :pep:`236`) affect the compilation of *source*. If neither
+ is present (or both are zero) the code is compiled with those future
+ statements that are in effect in the code that is calling compile. If the
+ *flags* argument is given and *dont_inherit* is not (or is zero) then the
future statements specified by the *flags* argument are used in addition to
those that would be used anyway. If *dont_inherit* is a non-zero integer then
- the *flags* argument is it -- the future statements in effect around the call to
- compile are ignored.
+ the *flags* argument is it -- the future statements in effect around the call
+ to compile are ignored.
Future statements are specified by bits which can be bitwise ORed together to
specify multiple statements. The bitfield required to specify a given feature
@@ -237,7 +230,18 @@
This function raises :exc:`SyntaxError` if the compiled source is invalid,
and :exc:`TypeError` if the source contains null bytes.
- .. versionadded:: 2.6
+ .. note::
+
+ When compiling a string with multi-line statements, line endings must be
+ represented by a single newline character (``'\n'``), and the input must
+ be terminated by at least one newline character. If line endings are
+ represented by ``'\r\n'``, use :meth:`str.replace` to change them into
+ ``'\n'``.
+
+ .. versionchanged:: 2.3
+ The *flags* and *dont_inherit* arguments were added.
+
+ .. versionchanged:: 2.6
Support for compiling AST objects.
Modified: python/branches/tlee-ast-optimize/Doc/library/select.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/select.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/select.rst Tue Nov 11 12:40:58 2008
@@ -363,7 +363,7 @@
Filter specific flags
- *:const:`KQ_FILTER_READ` and :const:`KQ_FILTER_WRITE` filter flags*
+ :const:`KQ_FILTER_READ` and :const:`KQ_FILTER_WRITE` filter flags
+----------------------------+--------------------------------------------+
| Constant | Meaning |
@@ -372,7 +372,7 @@
+----------------------------+--------------------------------------------+
- *:const:`KQ_FILTER_VNODE` filter flags*
+ :const:`KQ_FILTER_VNODE` filter flags
+----------------------------+--------------------------------------------+
| Constant | Meaning |
@@ -393,7 +393,7 @@
+----------------------------+--------------------------------------------+
- *:const:`KQ_FILTER_PROC` filter flags*
+ :const:`KQ_FILTER_PROC` filter flags
+----------------------------+--------------------------------------------+
| Constant | Meaning |
@@ -416,7 +416,7 @@
| :const:`KQ_NOTE_TRACKERR` | unable to attach to a child |
+----------------------------+--------------------------------------------+
- *:const:`KQ_FILTER_NETDEV` filter flags* [not available on Mac OS X]
+ :const:`KQ_FILTER_NETDEV` filter flags [not available on Mac OS X]
+----------------------------+--------------------------------------------+
| Constant | Meaning |
Modified: python/branches/tlee-ast-optimize/Doc/library/socket.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/socket.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/socket.rst Tue Nov 11 12:40:58 2008
@@ -276,11 +276,15 @@
.. function:: gethostname()
Return a string containing the hostname of the machine where the Python
- interpreter is currently executing. If you want to know the current machine's IP
- address, you may want to use ``gethostbyname(gethostname())``. This operation
- assumes that there is a valid address-to-host mapping for the host, and the
- assumption does not always hold. Note: :func:`gethostname` doesn't always return
- the fully qualified domain name; use ``getfqdn()`` (see above).
+ interpreter is currently executing.
+
+ If you want to know the current machine's IP address, you may want to use
+ ``gethostbyname(gethostname())``. This operation assumes that there is a
+ valid address-to-host mapping for the host, and the assumption does not
+ always hold.
+
+ Note: :func:`gethostname` doesn't always return the fully qualified domain
+ name; use ``getfqdn()`` (see above).
.. function:: gethostbyaddr(ip_address)
Modified: python/branches/tlee-ast-optimize/Doc/library/sqlite3.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/sqlite3.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/sqlite3.rst Tue Nov 11 12:40:58 2008
@@ -64,10 +64,10 @@
c.execute('select * from stocks where symbol=?', t)
# Larger example
- for t in (('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
+ for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00),
('2006-04-06', 'SELL', 'IBM', 500, 53.00),
- ):
+ ]:
c.execute('insert into stocks values (?,?,?,?,?)', t)
To retrieve data after executing a SELECT statement, you can either treat the
@@ -426,10 +426,9 @@
import sqlite3, os
con = sqlite3.connect('existing_db.db')
- full_dump = os.linesep.join(con.iterdump())
- f = open('dump.sql', 'w')
- f.writelines(full_dump)
- f.close()
+ with open('dump.sql', 'w') as f:
+ for line in con.iterdump():
+ f.write('%s\n' % line)
.. _sqlite3-cursor-objects:
@@ -813,8 +812,8 @@
If you want **autocommit mode**, then set :attr:`isolation_level` to None.
Otherwise leave it at its default, which will result in a plain "BEGIN"
-statement, or set it to one of SQLite's supported isolation levels: DEFERRED,
-IMMEDIATE or EXCLUSIVE.
+statement, or set it to one of SQLite's supported isolation levels: "DEFERRED",
+"IMMEDIATE" or "EXCLUSIVE".
Modified: python/branches/tlee-ast-optimize/Doc/library/threading.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/threading.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/threading.rst Tue Nov 11 12:40:58 2008
@@ -180,6 +180,166 @@
All of the methods described below are executed atomically.
+.. _thread-objects:
+
+Thread Objects
+--------------
+
+This class represents an activity that is run in a separate thread of control.
+There are two ways to specify the activity: by passing a callable object to the
+constructor, or by overriding the :meth:`run` method in a subclass. No other
+methods (except for the constructor) should be overridden in a subclass. In
+other words, *only* override the :meth:`__init__` and :meth:`run` methods of
+this class.
+
+Once a thread object is created, its activity must be started by calling the
+thread's :meth:`start` method. This invokes the :meth:`run` method in a
+separate thread of control.
+
+Once the thread's activity is started, the thread is considered 'alive'. It
+stops being alive when its :meth:`run` method terminates -- either normally, or
+by raising an unhandled exception. The :meth:`is_alive` method tests whether the
+thread is alive.
+
+Other threads can call a thread's :meth:`join` method. This blocks the calling
+thread until the thread whose :meth:`join` method is called is terminated.
+
+A thread has a name. The name can be passed to the constructor, and read or
+changed through the :attr:`name` attribute.
+
+A thread can be flagged as a "daemon thread". The significance of this flag is
+that the entire Python program exits when only daemon threads are left. The
+initial value is inherited from the creating thread. The flag can be set
+through the :attr:`daemon` attribute.
+
+There is a "main thread" object; this corresponds to the initial thread of
+control in the Python program. It is not a daemon thread.
+
+There is the possibility that "dummy thread objects" are created. These are
+thread objects corresponding to "alien threads", which are threads of control
+started outside the threading module, such as directly from C code. Dummy
+thread objects have limited functionality; they are always considered alive and
+daemonic, and cannot be :meth:`join`\ ed. They are never deleted, since it is
+impossible to detect the termination of alien threads.
+
+
+.. class:: Thread(group=None, target=None, name=None, args=(), kwargs={})
+
+ This constructor should always be called with keyword arguments. Arguments are:
+
+ *group* should be ``None``; reserved for future extension when a
+ :class:`ThreadGroup` class is implemented.
+
+ *target* is the callable object to be invoked by the :meth:`run` method.
+ Defaults to ``None``, meaning nothing is called.
+
+ *name* is the thread name. By default, a unique name is constructed of the form
+ "Thread-*N*" where *N* is a small decimal number.
+
+ *args* is the argument tuple for the target invocation. Defaults to ``()``.
+
+ *kwargs* is a dictionary of keyword arguments for the target invocation.
+ Defaults to ``{}``.
+
+ If the subclass overrides the constructor, it must make sure to invoke the base
+ class constructor (``Thread.__init__()``) before doing anything else to the
+ thread.
+
+
+.. method:: Thread.start()
+
+ Start the thread's activity.
+
+ It must be called at most once per thread object. It arranges for the object's
+ :meth:`run` method to be invoked in a separate thread of control.
+
+ This method will raise a :exc:`RuntimeException` if called more than once on the
+ same thread object.
+
+
+.. method:: Thread.run()
+
+ Method representing the thread's activity.
+
+ You may override this method in a subclass. The standard :meth:`run` method
+ invokes the callable object passed to the object's constructor as the *target*
+ argument, if any, with sequential and keyword arguments taken from the *args*
+ and *kwargs* arguments, respectively.
+
+
+.. method:: Thread.join([timeout])
+
+ Wait until the thread terminates. This blocks the calling thread until the
+ thread whose :meth:`join` method is called terminates -- either normally or
+ through an unhandled exception -- or until the optional timeout occurs.
+
+ When the *timeout* argument is present and not ``None``, it should be a floating
+ point number specifying a timeout for the operation in seconds (or fractions
+ thereof). As :meth:`join` always returns ``None``, you must call :meth:`isAlive`
+ after :meth:`join` to decide whether a timeout happened -- if the thread is
+ still alive, the :meth:`join` call timed out.
+
+ When the *timeout* argument is not present or ``None``, the operation will block
+ until the thread terminates.
+
+ A thread can be :meth:`join`\ ed many times.
+
+ :meth:`join` raises a :exc:`RuntimeError` if an attempt is made to join
+ the current thread as that would cause a deadlock. It is also an error to
+ :meth:`join` a thread before it has been started and attempts to do so
+ raises the same exception.
+
+
+.. method:: Thread.getName()
+ Thread.setName()
+
+ Old API for :attr:`~Thread.name`.
+
+
+.. attribute:: Thread.name
+
+ A string used for identification purposes only. It has no semantics.
+ Multiple threads may be given the same name. The initial name is set by the
+ constructor.
+
+
+.. attribute:: Thread.ident
+
+ The 'thread identifier' of this thread or ``None`` if the thread has not been
+ started. This is a nonzero integer. See the :func:`thread.get_ident()`
+ function. Thread identifiers may be recycled when a thread exits and another
+ thread is created. The identifier is available even after the thread has
+ exited.
+
+ .. versionadded:: 2.6
+
+
+.. method:: Thread.is_alive()
+ Thread.isAlive()
+
+ Return whether the thread is alive.
+
+ Roughly, a thread is alive from the moment the :meth:`start` method returns
+ until its :meth:`run` method terminates. The module function :func:`enumerate`
+ returns a list of all alive threads.
+
+
+.. method:: Thread.isDaemon()
+ Thread.setDaemon()
+
+ Old API for :attr:`~Thread.daemon`.
+
+
+.. attribute:: Thread.daemon
+
+ The thread's daemon flag. This must be set before :meth:`start` is called,
+ otherwise :exc:`RuntimeError` is raised.
+
+ The initial value is inherited from the creating thread.
+
+ The entire Python program exits when no alive non-daemon threads are left.
+
+
.. _lock-objects:
Lock Objects
@@ -539,166 +699,6 @@
thereof).
-.. _thread-objects:
-
-Thread Objects
---------------
-
-This class represents an activity that is run in a separate thread of control.
-There are two ways to specify the activity: by passing a callable object to the
-constructor, or by overriding the :meth:`run` method in a subclass. No other
-methods (except for the constructor) should be overridden in a subclass. In
-other words, *only* override the :meth:`__init__` and :meth:`run` methods of
-this class.
-
-Once a thread object is created, its activity must be started by calling the
-thread's :meth:`start` method. This invokes the :meth:`run` method in a
-separate thread of control.
-
-Once the thread's activity is started, the thread is considered 'alive'. It
-stops being alive when its :meth:`run` method terminates -- either normally, or
-by raising an unhandled exception. The :meth:`is_alive` method tests whether the
-thread is alive.
-
-Other threads can call a thread's :meth:`join` method. This blocks the calling
-thread until the thread whose :meth:`join` method is called is terminated.
-
-A thread has a name. The name can be passed to the constructor, and read or
-changed through the :attr:`name` attribute.
-
-A thread can be flagged as a "daemon thread". The significance of this flag is
-that the entire Python program exits when only daemon threads are left. The
-initial value is inherited from the creating thread. The flag can be set
-through the :attr:`daemon` attribute.
-
-There is a "main thread" object; this corresponds to the initial thread of
-control in the Python program. It is not a daemon thread.
-
-There is the possibility that "dummy thread objects" are created. These are
-thread objects corresponding to "alien threads", which are threads of control
-started outside the threading module, such as directly from C code. Dummy
-thread objects have limited functionality; they are always considered alive and
-daemonic, and cannot be :meth:`join`\ ed. They are never deleted, since it is
-impossible to detect the termination of alien threads.
-
-
-.. class:: Thread(group=None, target=None, name=None, args=(), kwargs={})
-
- This constructor should always be called with keyword arguments. Arguments are:
-
- *group* should be ``None``; reserved for future extension when a
- :class:`ThreadGroup` class is implemented.
-
- *target* is the callable object to be invoked by the :meth:`run` method.
- Defaults to ``None``, meaning nothing is called.
-
- *name* is the thread name. By default, a unique name is constructed of the form
- "Thread-*N*" where *N* is a small decimal number.
-
- *args* is the argument tuple for the target invocation. Defaults to ``()``.
-
- *kwargs* is a dictionary of keyword arguments for the target invocation.
- Defaults to ``{}``.
-
- If the subclass overrides the constructor, it must make sure to invoke the base
- class constructor (``Thread.__init__()``) before doing anything else to the
- thread.
-
-
-.. method:: Thread.start()
-
- Start the thread's activity.
-
- It must be called at most once per thread object. It arranges for the object's
- :meth:`run` method to be invoked in a separate thread of control.
-
- This method will raise a :exc:`RuntimeException` if called more than once on the
- same thread object.
-
-
-.. method:: Thread.run()
-
- Method representing the thread's activity.
-
- You may override this method in a subclass. The standard :meth:`run` method
- invokes the callable object passed to the object's constructor as the *target*
- argument, if any, with sequential and keyword arguments taken from the *args*
- and *kwargs* arguments, respectively.
-
-
-.. method:: Thread.join([timeout])
-
- Wait until the thread terminates. This blocks the calling thread until the
- thread whose :meth:`join` method is called terminates -- either normally or
- through an unhandled exception -- or until the optional timeout occurs.
-
- When the *timeout* argument is present and not ``None``, it should be a floating
- point number specifying a timeout for the operation in seconds (or fractions
- thereof). As :meth:`join` always returns ``None``, you must call :meth:`isAlive`
- after :meth:`join` to decide whether a timeout happened -- if the thread is
- still alive, the :meth:`join` call timed out.
-
- When the *timeout* argument is not present or ``None``, the operation will block
- until the thread terminates.
-
- A thread can be :meth:`join`\ ed many times.
-
- :meth:`join` raises a :exc:`RuntimeError` if an attempt is made to join
- the current thread as that would cause a deadlock. It is also an error to
- :meth:`join` a thread before it has been started and attempts to do so
- raises the same exception.
-
-
-.. method:: Thread.getName()
- Thread.setName()
-
- Old API for :attr:`~Thread.name`.
-
-
-.. attribute:: Thread.name
-
- A string used for identification purposes only. It has no semantics.
- Multiple threads may be given the same name. The initial name is set by the
- constructor.
-
-
-.. attribute:: Thread.ident
-
- The 'thread identifier' of this thread or ``None`` if the thread has not been
- started. This is a nonzero integer. See the :func:`thread.get_ident()`
- function. Thread identifiers may be recycled when a thread exits and another
- thread is created. The identifier is available even after the thread has
- exited.
-
- .. versionadded:: 2.6
-
-
-.. method:: Thread.is_alive()
- Thread.isAlive()
-
- Return whether the thread is alive.
-
- Roughly, a thread is alive from the moment the :meth:`start` method returns
- until its :meth:`run` method terminates. The module function :func:`enumerate`
- returns a list of all alive threads.
-
-
-.. method:: Thread.isDaemon()
- Thread.setDaemon()
-
- Old API for :attr:`~Thread.daemon`.
-
-
-.. attribute:: Thread.daemon
-
- The thread's daemon flag. This must be set before :meth:`start` is called,
- otherwise :exc:`RuntimeError` is raised.
-
- The initial value is inherited from the creating thread.
-
- The entire Python program exits when no alive non-daemon threads are left.
-
-
.. _timer-objects:
Timer Objects
Modified: python/branches/tlee-ast-optimize/Doc/tutorial/controlflow.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tutorial/controlflow.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/tutorial/controlflow.rst Tue Nov 11 12:40:58 2008
@@ -166,6 +166,41 @@
... pass # Busy-wait for keyboard interrupt (Ctrl+C)
...
+This is commonly used for creating minimal classes such as exceptions, or
+for ignoring unwanted exceptions::
+
+ >>> class ParserError(Exception):
+ ... pass
+ ...
+ >>> try:
+ ... import audioop
+ ... except ImportError:
+ ... pass
+ ...
+
+Another place :keyword:`pass` can be used is as a place-holder for a function or
+conditional body when you are working on new code, allowing you to keep
+thinking at a more abstract level. However, as :keyword:`pass` is silently
+ignored, a better choice may be to raise a :exc:`NotImplementedError`
+exception::
+
+ >>> def initlog(*args):
+ ... raise NotImplementedError # Open logfile if not already open
+ ... if not logfp:
+ ... raise NotImplementedError # Set up dummy log back-end
+ ... raise NotImplementedError('Call log initialization handler')
+ ...
+
+If :keyword:`pass` were used here and you later ran tests, they may fail
+without indicating why. Using :exc:`NotImplementedError` causes this code
+to raise an exception, telling you exactly where the incomplete code
+is. Note the two calling styles of the exceptions above.
+The first style, with no message but with an accompanying comment,
+lets you easily leave the comment when you remove the exception,
+which ideally would be a good description for
+the block of code the exception is a placeholder for. However, the
+third example, providing a message for the exception, will produce
+a more useful traceback.
.. _tut-functions:
Modified: python/branches/tlee-ast-optimize/Doc/using/cmdline.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/using/cmdline.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/using/cmdline.rst Tue Nov 11 12:40:58 2008
@@ -143,8 +143,7 @@
an empty string (``""``) and the current directory will be added to the
start of :data:`sys.path`.
- .. seealso::
- :ref:`tut-invoking`
+.. seealso:: :ref:`tut-invoking`
Generic options
Modified: python/branches/tlee-ast-optimize/Lib/lib-tk/Tkinter.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib-tk/Tkinter.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib-tk/Tkinter.py Tue Nov 11 12:40:58 2008
@@ -1921,6 +1921,8 @@
cnf = _cnfmerge((cnf, kw))
self.widgetName = widgetName
BaseWidget._setup(self, master, cnf)
+ if self._tclCommands is None:
+ self._tclCommands = []
classes = []
for k in cnf.keys():
if type(k) is ClassType:
@@ -2658,20 +2660,20 @@
"""Add separator at INDEX."""
self.insert(index, 'separator', cnf or kw)
def delete(self, index1, index2=None):
- """Delete menu items between INDEX1 and INDEX2 (not included)."""
+ """Delete menu items between INDEX1 and INDEX2 (included)."""
if index2 is None:
index2 = index1
- cmds = []
- (num_index1, num_index2) = (self.index(index1), self.index(index2))
- if (num_index1 is not None) and (num_index2 is not None):
- for i in range(num_index1, num_index2 + 1):
- if 'command' in self.entryconfig(i):
- c = str(self.entrycget(i, 'command'))
- if c in self._tclCommands:
- cmds.append(c)
+
+ num_index1, num_index2 = self.index(index1), self.index(index2)
+ if (num_index1 is None) or (num_index2 is None):
+ num_index1, num_index2 = 0, -1
+
+ for i in range(num_index1, num_index2 + 1):
+ if 'command' in self.entryconfig(i):
+ c = str(self.entrycget(i, 'command'))
+ if c:
+ self.deletecommand(c)
self.tk.call(self._w, 'delete', index1, index2)
- for c in cmds:
- self.deletecommand(c)
def entrycget(self, index, option):
"""Return the resource value of an menu item for OPTION at INDEX."""
return self.tk.call(self._w, 'entrycget', index, '-' + option)
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_import.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_import.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_import.py Tue Nov 11 12:40:58 2008
@@ -18,7 +18,7 @@
class FixImport(fixer_base.BaseFix):
PATTERN = """
- import_from< type='from' imp=any 'import' any >
+ import_from< type='from' imp=any 'import' ['('] any [')'] >
|
import_name< type='import' imp=any >
"""
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py Tue Nov 11 12:40:58 2008
@@ -66,9 +66,9 @@
yield """import_name< 'import' ((%s)
| dotted_as_names< any* (%s) any* >) >
""" % (mod_list, mod_list)
- yield """import_from< 'from' (%s) 'import'
+ yield """import_from< 'from' (%s) 'import' ['(']
( any | import_as_name< any 'as' any > |
- import_as_names< any* >) >
+ import_as_names< any* >) [')'] >
""" % mod_name_list
yield """import_name< 'import'
dotted_as_name< (%s) 'as' any > >
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_metaclass.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_metaclass.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_metaclass.py Tue Nov 11 12:40:58 2008
@@ -35,8 +35,9 @@
elif node.type == syms.simple_stmt and node.children:
expr_node = node.children[0]
if expr_node.type == syms.expr_stmt and expr_node.children:
- leaf_node = expr_node.children[0]
- if leaf_node.value == '__metaclass__':
+ left_side = expr_node.children[0]
+ if isinstance(left_side, Leaf) and \
+ left_side.value == '__metaclass__':
return True
return False
@@ -165,12 +166,10 @@
if node.children[3].type == syms.arglist:
arglist = node.children[3]
# Node(classdef, ['class', 'name', '(', 'Parent', ')', ':', suite])
- elif isinstance(node.children[3], Leaf):
+ else:
parent = node.children[3].clone()
arglist = Node(syms.arglist, [parent])
node.set_child(3, arglist)
- else:
- raise ValueError("Unexpected class inheritance arglist")
elif len(node.children) == 6:
# Node(classdef, ['class', 'name', '(', ')', ':', suite])
# 0 1 2 3 4 5
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py Tue Nov 11 12:40:58 2008
@@ -363,10 +363,9 @@
self.log_error("Can't create %s: %s", filename, err)
return
try:
- try:
- f.write(new_text)
- except os.error, err:
- self.log_error("Can't write %s: %s", filename, err)
+ f.write(new_text)
+ except os.error, err:
+ self.log_error("Can't write %s: %s", filename, err)
finally:
f.close()
self.log_debug("Wrote changes to %s", filename)
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py Tue Nov 11 12:40:58 2008
@@ -1450,6 +1450,10 @@
a = "from %s import foo, bar" % new
self.check(b, a)
+ b = "from %s import (yes, no)" % old
+ a = "from %s import (yes, no)" % new
+ self.check(b, a)
+
def test_import_module_as(self):
for old, new in self.modules.items():
b = "import %s as foo_bar" % old
@@ -3345,6 +3349,10 @@
a = "from .foo import bar"
self.check_both(b, a)
+ b = "from foo import (bar, baz)"
+ a = "from .foo import (bar, baz)"
+ self.check_both(b, a)
+
def test_dotted_from(self):
b = "from green.eggs import ham"
a = "from .green.eggs import ham"
@@ -3624,6 +3632,12 @@
"""
self.unchanged(s)
+ s = """
+ class X:
+ a[23] = 74
+ """
+ self.unchanged(s)
+
def test_comments(self):
b = """
class X:
@@ -3732,6 +3746,26 @@
a = """class m(a, arg=23, metaclass=Meta): pass"""
self.check(b, a)
+ b = """
+ class X(expression(2 + 4)):
+ __metaclass__ = Meta
+ """
+ a = """
+ class X(expression(2 + 4), metaclass=Meta):
+ pass
+ """
+ self.check(b, a)
+
+ b = """
+ class X(expression(2 + 4), x**4):
+ __metaclass__ = Meta
+ """
+ a = """
+ class X(expression(2 + 4), x**4, metaclass=Meta):
+ pass
+ """
+ self.check(b, a)
+
class Test_getcwdu(FixerTestCase):
Modified: python/branches/tlee-ast-optimize/Lib/string.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/string.py (original)
+++ python/branches/tlee-ast-optimize/Lib/string.py Tue Nov 11 12:40:58 2008
@@ -532,9 +532,8 @@
# the Formatter class
# see PEP 3101 for details and purpose of this class
-# The hard parts are reused from the C implementation. They're
-# exposed here via the sys module. sys was chosen because it's always
-# available and doesn't have to be dynamically loaded.
+# The hard parts are reused from the C implementation. They're exposed as "_"
+# prefixed methods of str and unicode.
# The overall parser is implemented in str._formatter_parser.
# The field name parser is implemented in str._formatter_field_name_split
Modified: python/branches/tlee-ast-optimize/Lib/test/test_fileio.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_fileio.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_fileio.py Tue Nov 11 12:40:58 2008
@@ -7,7 +7,7 @@
from array import array
from weakref import proxy
-from test.test_support import TESTFN, findfile, run_unittest
+from test.test_support import TESTFN, findfile, check_warnings, run_unittest
from UserList import UserList
import _fileio
@@ -241,6 +241,14 @@
def testInvalidInit(self):
self.assertRaises(TypeError, _fileio._FileIO, "1", 0, 0)
+ def testWarnings(self):
+ with check_warnings() as w:
+ self.assertEqual(w.warnings, [])
+ self.assertRaises(TypeError, _fileio._FileIO, [])
+ self.assertEqual(w.warnings, [])
+ self.assertRaises(ValueError, _fileio._FileIO, "/some/invalid/name", "rt")
+ self.assertEqual(w.warnings, [])
+
def test_main():
# Historically, these tests have been sloppy about removing TESTFN.
Modified: python/branches/tlee-ast-optimize/Lib/test/test_io.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_io.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_io.py Tue Nov 11 12:40:58 2008
@@ -1236,13 +1236,6 @@
else:
self.assert_(issubclass(obj, io.IOBase))
- def test_fileio_warnings(self):
- with test_support.check_warnings() as w:
- self.assertEqual(w.warnings, [])
- self.assertRaises(TypeError, io.FileIO, [])
- self.assertEqual(w.warnings, [])
- self.assertRaises(ValueError, io.FileIO, "/some/invalid/name", "rt")
- self.assertEqual(w.warnings, [])
def test_main():
test_support.run_unittest(IOTest, BytesIOTest, StringIOTest,
Modified: python/branches/tlee-ast-optimize/Lib/test/test_parser.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_parser.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_parser.py Tue Nov 11 12:40:58 2008
@@ -1,4 +1,5 @@
import parser
+import os
import unittest
import sys
from test import test_support
@@ -179,6 +180,7 @@
"from sys.path import (dirname, basename as my_basename)")
self.check_suite(
"from sys.path import (dirname, basename as my_basename,)")
+ self.check_suite("from .bogus import x")
def test_basic_import_statement(self):
self.check_suite("import sys")
Modified: python/branches/tlee-ast-optimize/Lib/test/test_syntax.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_syntax.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_syntax.py Tue Nov 11 12:40:58 2008
@@ -27,15 +27,13 @@
Errors from set_context():
-TODO(jhylton): "assignment to None" is inconsistent with other messages
-
>>> obj.None = 1
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[1]>, line 1)
+SyntaxError: cannot assign to None (<doctest test.test_syntax[1]>, line 1)
>>> None = 1
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[2]>, line 1)
+SyntaxError: cannot assign to None (<doctest test.test_syntax[2]>, line 1)
It's a syntax error to assign to the empty tuple. Why isn't it an
error to assign to the empty list? It will always raise some error at
@@ -95,7 +93,7 @@
>>> def f(None=1):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[14]>, line 1)
+SyntaxError: cannot assign to None (<doctest test.test_syntax[14]>, line 1)
From ast_for_arguments():
@@ -108,17 +106,17 @@
>>> def f(x, None):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[16]>, line 1)
+SyntaxError: cannot assign to None (<doctest test.test_syntax[16]>, line 1)
>>> def f(*None):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[17]>, line 1)
+SyntaxError: cannot assign to None (<doctest test.test_syntax[17]>, line 1)
>>> def f(**None):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[18]>, line 1)
+SyntaxError: cannot assign to None (<doctest test.test_syntax[18]>, line 1)
From ast_for_funcdef():
@@ -126,7 +124,7 @@
>>> def None(x):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[19]>, line 1)
+SyntaxError: cannot assign to None (<doctest test.test_syntax[19]>, line 1)
From ast_for_call():
@@ -231,7 +229,7 @@
SyntaxError: augmented assignment to generator expression not possible (<doctest test.test_syntax[31]>, line 1)
>>> None += 1
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[32]>, line 1)
+SyntaxError: cannot assign to None (<doctest test.test_syntax[32]>, line 1)
>>> f() += 1
Traceback (most recent call last):
SyntaxError: illegal expression for augmented assignment (<doctest test.test_syntax[33]>, line 1)
Modified: python/branches/tlee-ast-optimize/Misc/ACKS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/ACKS (original)
+++ python/branches/tlee-ast-optimize/Misc/ACKS Tue Nov 11 12:40:58 2008
@@ -62,6 +62,7 @@
Steven Bethard
Stephen Bevan
Ron Bickers
+David Binger
Dominic Binks
Philippe Biondi
Stuart Bishop
Modified: python/branches/tlee-ast-optimize/Misc/NEWS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/NEWS (original)
+++ python/branches/tlee-ast-optimize/Misc/NEWS Tue Nov 11 12:40:58 2008
@@ -12,6 +12,8 @@
Core and Builtins
-----------------
+- Issue #4048: The parser module now correctly validates relative imports.
+
- Issue #4225: ``from __future__ import unicode_literals`` didn't work in an
exec statement.
@@ -36,6 +38,9 @@
Library
-------
+- Issue #3774: Fixed an error when create a Tkinter menu item without command
+ and then remove it.
+
- Fixed a modulefinder crash on certain relative imports.
- Issue #4150: Pdb's "up" command now works for generator frames in post-mortem
@@ -52,12 +57,18 @@
Build
-----
+- Issue #1656675: Register a drop handler for .py* files on Windows.
+
+- Issue #4120: Exclude manifest from extension modules in VS2008.
+
- Issue #4091: Install pythonxy.dll in system32 again.
- Issue #4018: Disable "for me" installations on Vista.
- Issue #3758: Add ``patchcheck`` build target to .PHONY.
+- Issue #4204: Fixed module build errors on FreeBSD 4.
+
C-API
-----
Modified: python/branches/tlee-ast-optimize/Modules/_multiprocessing/multiprocessing.h
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_multiprocessing/multiprocessing.h (original)
+++ python/branches/tlee-ast-optimize/Modules/_multiprocessing/multiprocessing.h Tue Nov 11 12:40:58 2008
@@ -20,7 +20,9 @@
# define SEM_VALUE_MAX LONG_MAX
#else
# include <fcntl.h> /* O_CREAT and O_EXCL */
+# include <netinet/in.h>
# include <sys/socket.h>
+# include <sys/uio.h>
# include <arpa/inet.h> /* htonl() and ntohl() */
# if HAVE_SEM_OPEN
# include <semaphore.h>
Modified: python/branches/tlee-ast-optimize/Modules/parsermodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/parsermodule.c (original)
+++ python/branches/tlee-ast-optimize/Modules/parsermodule.c Tue Nov 11 12:40:58 2008
@@ -1879,10 +1879,10 @@
count_from_dots(node *tree)
{
int i;
- for (i = 0; i < NCH(tree); i++)
+ for (i = 1; i < NCH(tree); i++)
if (TYPE(CHILD(tree, i)) != DOT)
break;
- return i;
+ return i-1;
}
/* 'from' ('.'* dotted_name | '.') 'import' ('*' | '(' import_as_names ')' |
Modified: python/branches/tlee-ast-optimize/Modules/posixmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/posixmodule.c (original)
+++ python/branches/tlee-ast-optimize/Modules/posixmodule.c Tue Nov 11 12:40:58 2008
@@ -2389,13 +2389,27 @@
if (unicode_file_names()) {
PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) {
- Py_UNICODE woutbuf[MAX_PATH*2];
+ Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
+ Py_UNICODE woutbuf[MAX_PATH*2], *woutbufp = woutbuf;
Py_UNICODE *wtemp;
- if (!GetFullPathNameW(PyUnicode_AS_UNICODE(po),
- sizeof(woutbuf)/sizeof(woutbuf[0]),
- woutbuf, &wtemp))
- return win32_error("GetFullPathName", "");
- return PyUnicode_FromUnicode(woutbuf, wcslen(woutbuf));
+ DWORD result;
+ PyObject *v;
+ result = GetFullPathNameW(wpath,
+ sizeof(woutbuf)/sizeof(woutbuf[0]),
+ woutbuf, &wtemp);
+ if (result > sizeof(woutbuf)/sizeof(woutbuf[0])) {
+ woutbufp = malloc(result * sizeof(Py_UNICODE));
+ if (!woutbufp)
+ return PyErr_NoMemory();
+ result = GetFullPathNameW(wpath, result, woutbufp, &wtemp);
+ }
+ if (result)
+ v = PyUnicode_FromUnicode(woutbufp, wcslen(woutbufp));
+ else
+ v = win32_error_unicode("GetFullPathNameW", wpath);
+ if (woutbufp != woutbuf)
+ free(woutbufp);
+ return v;
}
/* Drop the argument parsing error as narrow strings
are also valid. */
Modified: python/branches/tlee-ast-optimize/Modules/readline.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/readline.c (original)
+++ python/branches/tlee-ast-optimize/Modules/readline.c Tue Nov 11 12:40:58 2008
@@ -35,7 +35,11 @@
#define completion_matches(x, y) \
rl_completion_matches((x), ((rl_compentry_func_t *)(y)))
#else
+#if defined(_RL_FUNCTION_TYPEDEF)
extern char **completion_matches(char *, rl_compentry_func_t *);
+#else
+extern char **completion_matches(char *, CPFunction *);
+#endif
#endif
static void
@@ -213,7 +217,11 @@
default completion display. */
rl_completion_display_matches_hook =
completion_display_matches_hook ?
+#if defined(_RL_FUNCTION_TYPEDEF)
(rl_compdisp_func_t *)on_completion_display_matches_hook : 0;
+#else
+ (VFunction *)on_completion_display_matches_hook : 0;
+#endif
#endif
return result;
Modified: python/branches/tlee-ast-optimize/PCbuild/pyd.vsprops
==============================================================================
--- python/branches/tlee-ast-optimize/PCbuild/pyd.vsprops (original)
+++ python/branches/tlee-ast-optimize/PCbuild/pyd.vsprops Tue Nov 11 12:40:58 2008
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="Windows-1252"?>
+
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
@@ -15,6 +15,11 @@
OutputFile="$(OutDir)\$(ProjectName).pyd"
ProgramDatabaseFile="$(OutDir)\$(ProjectName).pdb"
ImportLibrary="$(OutDir)\$(TargetName).lib"
+ GenerateManifest="false"
+ />
+ <Tool
+ Name="VCManifestTool"
+ EmbedManifest="false"
/>
<Tool
Name="VCPostBuildEventTool"
Modified: python/branches/tlee-ast-optimize/PCbuild/pyd_d.vsprops
==============================================================================
--- python/branches/tlee-ast-optimize/PCbuild/pyd_d.vsprops (original)
+++ python/branches/tlee-ast-optimize/PCbuild/pyd_d.vsprops Tue Nov 11 12:40:58 2008
@@ -19,6 +19,11 @@
LinkIncremental="1"
ProgramDatabaseFile="$(OutDir)\$(ProjectName)_d.pdb"
ImportLibrary="$(OutDir)\$(TargetName).lib"
+ GenerateManifest="false"
+ />
+ <Tool
+ Name="VCManifestTool"
+ EmbedManifest="false"
/>
<Tool
Name="VCPostBuildEventTool"
Modified: python/branches/tlee-ast-optimize/Python/ast.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/ast.c (original)
+++ python/branches/tlee-ast-optimize/Python/ast.c Tue Nov 11 12:40:58 2008
@@ -130,7 +130,9 @@
forbidden_check(struct compiling *c, const node *n, const char *x)
{
if (!strcmp(x, "None"))
- return ast_error(n, "assignment to None");
+ return ast_error(n, "cannot assign to None");
+ if (!strcmp(x, "__debug__"))
+ return ast_error(n, "cannot assign to __debug__");
if (Py_Py3kWarningFlag) {
if (!(strcmp(x, "True") && strcmp(x, "False")) &&
!ast_warn(c, n, "assignment to True or False is forbidden in 3.x"))
Modified: python/branches/tlee-ast-optimize/Python/compile.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/compile.c (original)
+++ python/branches/tlee-ast-optimize/Python/compile.c Tue Nov 11 12:40:58 2008
@@ -2399,12 +2399,6 @@
PyObject *mangled;
/* XXX AugStore isn't used anywhere! */
- /* First check for assignment to __debug__. Param? */
- if ((ctx == Store || ctx == AugStore || ctx == Del)
- && !strcmp(PyString_AS_STRING(name), "__debug__")) {
- return compiler_error(c, "can not assign to __debug__");
- }
-
mangled = _Py_Mangle(c->u->u_private, name);
if (!mangled)
return 0;
Modified: python/branches/tlee-ast-optimize/Tools/msi/msi.py
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/msi/msi.py (original)
+++ python/branches/tlee-ast-optimize/Tools/msi/msi.py Tue Nov 11 12:40:58 2008
@@ -940,10 +940,12 @@
root.add_file(manifest[0], **manifest[1])
root.add_file(crtdll[0], **crtdll[1])
# Copy the manifest
- manifest_dlls = manifest[0]+".root"
- open(manifest_dlls, "w").write(open(manifest[1]['src']).read().replace("msvcr","../msvcr"))
- DLLs.start_component("msvcr90_dlls", feature=private_crt)
- DLLs.add_file(manifest[0], src=os.path.abspath(manifest_dlls))
+ # Actually, don't do that anymore - no DLL in DLLs should have a manifest
+ # dependency on msvcr90.dll anymore, so this should not be necessary
+ #manifest_dlls = manifest[0]+".root"
+ #open(manifest_dlls, "w").write(open(manifest[1]['src']).read().replace("msvcr","../msvcr"))
+ #DLLs.start_component("msvcr90_dlls", feature=private_crt)
+ #DLLs.add_file(manifest[0], src=os.path.abspath(manifest_dlls))
# Now start the main component for the DLLs directory;
# no regular files have been added to the directory yet.
@@ -1180,6 +1182,7 @@
ewi = "Edit with IDLE"
pat2 = r"Software\Classes\%sPython.%sFile\DefaultIcon"
pat3 = r"Software\Classes\%sPython.%sFile"
+ pat4 = r"Software\Classes\%sPython.%sFile\shellex\DropHandler"
tcl_verbs = []
if have_tcl:
tcl_verbs=[
@@ -1227,6 +1230,13 @@
"Python File (no console)", "REGISTRY.def"),
("pyc.txt", -1, pat3 % (testprefix, "Compiled"), "",
"Compiled Python File", "REGISTRY.def"),
+ # Drop Handler
+ ("py.drop", -1, pat4 % (testprefix, ""), "",
+ "{60254CA5-953B-11CF-8C96-00AA00B8708C}", "REGISTRY.def"),
+ ("pyw.drop", -1, pat4 % (testprefix, "NoCon"), "",
+ "{60254CA5-953B-11CF-8C96-00AA00B8708C}", "REGISTRY.def"),
+ ("pyc.drop", -1, pat4 % (testprefix, "Compiled"), "",
+ "{60254CA5-953B-11CF-8C96-00AA00B8708C}", "REGISTRY.def"),
])
# Registry keys
Modified: python/branches/tlee-ast-optimize/configure
==============================================================================
--- python/branches/tlee-ast-optimize/configure (original)
+++ python/branches/tlee-ast-optimize/configure Tue Nov 11 12:40:58 2008
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 66295 .
+# From configure.in Revision: 66764 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 2.7.
#
@@ -2105,11 +2105,18 @@
# but used in struct sockaddr.sa_family. Reported by Tim Rice.
SCO_SV/3.2)
define_xopen_source=no;;
- # On FreeBSD 4.8 and MacOS X 10.2, a bug in ncurses.h means that
- # it craps out if _XOPEN_EXTENDED_SOURCE is defined. Apparently,
- # this is fixed in 10.3, which identifies itself as Darwin/7.*
- # This should hopefully be fixed in FreeBSD 4.9
- FreeBSD/4.8* | Darwin/6* )
+ # On FreeBSD 4, the math functions C89 does not cover are never defined
+ # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
+ FreeBSD/4.*)
+ define_xopen_source=no;;
+ # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
+ # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
+ # identifies itself as Darwin/7.*
+ # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
+ # disables platform specific features beyond repair.
+ # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
+ # has no effect, don't bother defining them
+ Darwin/[6789].*)
define_xopen_source=no;;
# On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
# used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
@@ -2121,13 +2128,6 @@
define_xopen_source=no
fi
;;
- # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
- # disables platform specific features beyond repair.
- # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
- # has no effect, don't bother defining them
- Darwin/[789].*)
- define_xopen_source=no
- ;;
# On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
# defining NI_NUMERICHOST.
QNX/6.3.2)
Modified: python/branches/tlee-ast-optimize/configure.in
==============================================================================
--- python/branches/tlee-ast-optimize/configure.in (original)
+++ python/branches/tlee-ast-optimize/configure.in Tue Nov 11 12:40:58 2008
@@ -276,11 +276,18 @@
# but used in struct sockaddr.sa_family. Reported by Tim Rice.
SCO_SV/3.2)
define_xopen_source=no;;
- # On FreeBSD 4.8 and MacOS X 10.2, a bug in ncurses.h means that
- # it craps out if _XOPEN_EXTENDED_SOURCE is defined. Apparently,
- # this is fixed in 10.3, which identifies itself as Darwin/7.*
- # This should hopefully be fixed in FreeBSD 4.9
- FreeBSD/4.8* | Darwin/6* )
+ # On FreeBSD 4, the math functions C89 does not cover are never defined
+ # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
+ FreeBSD/4.*)
+ define_xopen_source=no;;
+ # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
+ # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
+ # identifies itself as Darwin/7.*
+ # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
+ # disables platform specific features beyond repair.
+ # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
+ # has no effect, don't bother defining them
+ Darwin/@<:@6789@:>@.*)
define_xopen_source=no;;
# On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
# used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
@@ -292,13 +299,6 @@
define_xopen_source=no
fi
;;
- # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
- # disables platform specific features beyond repair.
- # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
- # has no effect, don't bother defining them
- Darwin/@<:@789@:>@.*)
- define_xopen_source=no
- ;;
# On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
# defining NI_NUMERICHOST.
QNX/6.3.2)
Modified: python/branches/tlee-ast-optimize/setup.py
==============================================================================
--- python/branches/tlee-ast-optimize/setup.py (original)
+++ python/branches/tlee-ast-optimize/setup.py Tue Nov 11 12:40:58 2008
@@ -1261,7 +1261,7 @@
)
libraries = []
- elif platform in ('freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'):
+ elif platform in ('freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'freebsd8'):
# FreeBSD's P1003.1b semaphore support is very experimental
# and has many known problems. (as of June 2008)
macros = dict( # FreeBSD
More information about the Python-checkins
mailing list