]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785...
authorBenjamin Peterson <benjamin@python.org>
Sun, 21 Dec 2008 17:01:26 +0000 (17:01 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 21 Dec 2008 17:01:26 +0000 (17:01 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

................
  r67654 | georg.brandl | 2008-12-07 16:42:09 -0600 (Sun, 07 Dec 2008) | 2 lines

  #4457: rewrite __import__() documentation.
................
  r67676 | benjamin.peterson | 2008-12-08 20:03:03 -0600 (Mon, 08 Dec 2008) | 1 line

  specify how things are copied
................
  r67677 | benjamin.peterson | 2008-12-08 20:05:11 -0600 (Mon, 08 Dec 2008) | 1 line

  revert unrelated change to installer script
................
  r67681 | jeremy.hylton | 2008-12-09 15:03:10 -0600 (Tue, 09 Dec 2008) | 2 lines

  Add simple unittests for Request
................
  r67692 | amaury.forgeotdarc | 2008-12-10 18:03:42 -0600 (Wed, 10 Dec 2008) | 2 lines

  #1030250: correctly pass the dry_run option to the mkpath() function.
................
  r67725 | benjamin.peterson | 2008-12-12 22:02:20 -0600 (Fri, 12 Dec 2008) | 1 line

  fix incorrect example
................
  r67746 | antoine.pitrou | 2008-12-13 17:12:30 -0600 (Sat, 13 Dec 2008) | 3 lines

  Issue #4163: Use unicode-friendly word splitting in the textwrap functions when given an unicode string.
................
  r67748 | benjamin.peterson | 2008-12-13 19:46:11 -0600 (Sat, 13 Dec 2008) | 1 line

  remove has_key usage
................
  r67761 | benjamin.peterson | 2008-12-14 11:26:04 -0600 (Sun, 14 Dec 2008) | 1 line

  fix missing bracket
................
  r67784 | georg.brandl | 2008-12-15 02:33:58 -0600 (Mon, 15 Dec 2008) | 2 lines

  #4446: document "platforms" argument for setup().
................
  r67785 | georg.brandl | 2008-12-15 02:36:11 -0600 (Mon, 15 Dec 2008) | 2 lines

  #4611: fix typo.
................
  r67787 | georg.brandl | 2008-12-15 02:58:59 -0600 (Mon, 15 Dec 2008) | 2 lines

  #4578: fix has_key() usage in compiler package.
................
  r67788 | georg.brandl | 2008-12-15 03:07:39 -0600 (Mon, 15 Dec 2008) | 2 lines

  #4568: remove limitation in varargs callback example.
................
  r67802 | amaury.forgeotdarc | 2008-12-15 16:29:14 -0600 (Mon, 15 Dec 2008) | 4 lines

  #3632: the "pyo" macro from gdbinit can now run when the GIL is released.

  Patch by haypo.
................
  r67832 | antoine.pitrou | 2008-12-17 16:46:54 -0600 (Wed, 17 Dec 2008) | 4 lines

  Issue #2467: gc.DEBUG_STATS reports invalid elapsed times.
  Patch by Neil Schemenauer, very slightly modified.
................
  r67848 | benjamin.peterson | 2008-12-18 20:28:56 -0600 (Thu, 18 Dec 2008) | 1 line

  fix typo
................
  r67849 | benjamin.peterson | 2008-12-18 20:31:35 -0600 (Thu, 18 Dec 2008) | 1 line

  _call_method -> _callmethod and _get_value to _getvalue
................
  r67859 | amaury.forgeotdarc | 2008-12-19 16:56:48 -0600 (Fri, 19 Dec 2008) | 4 lines

  #4700: crtlicense.txt is displayed by the license() command and should be kept ascii-only.

  Will port to 3.0
................
  r67862 | benjamin.peterson | 2008-12-19 20:48:02 -0600 (Fri, 19 Dec 2008) | 1 line

  copy sentence from docstring
................
  r67863 | benjamin.peterson | 2008-12-19 20:51:26 -0600 (Fri, 19 Dec 2008) | 1 line

  add headings
................
  r67864 | benjamin.peterson | 2008-12-19 20:57:19 -0600 (Fri, 19 Dec 2008) | 1 line

  beef up docstring
................
  r67880 | benjamin.peterson | 2008-12-20 16:49:24 -0600 (Sat, 20 Dec 2008) | 1 line

  remove redundant sentence
................
  r67882 | benjamin.peterson | 2008-12-20 16:59:49 -0600 (Sat, 20 Dec 2008) | 1 line

  add some recent releases to the list
................
  r67885 | benjamin.peterson | 2008-12-20 17:48:54 -0600 (Sat, 20 Dec 2008) | 1 line

  silence annoying DeprecationWarning
................
  r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line

  sphinx.web is long gone
................
  r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line

  update readme
................
  r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line

  there are way too many places which need to have the current version added
................
  r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines

  Merged revisions 67809 via svnmerge from
  svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3

  ........
    r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line

    fix logic error
  ........
................
  r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines

  Add Tarek for work on distutils.
................

32 files changed:
Doc/README.txt
Doc/distutils/setupscript.rst
Doc/extending/extending.rst
Doc/howto/functional.rst
Doc/library/functions.rst
Doc/library/math.rst
Doc/library/multiprocessing.rst
Doc/library/optparse.rst
Doc/library/shutil.rst
Doc/library/signal.rst
Doc/license.rst
Doc/tools/sphinx-web.py [deleted file]
Doc/tools/sphinxext/pyspecific.py
Doc/whatsnew/2.6.rst
LICENSE
Lib/compiler/misc.py
Lib/compiler/pyassem.py
Lib/compiler/symbols.py
Lib/compiler/transformer.py
Lib/compiler/visitor.py
Lib/distutils/ccompiler.py
Lib/lib2to3/main.py
Lib/logging/__init__.py
Lib/test/test_textwrap.py
Lib/test/test_urllib2.py
Lib/textwrap.py
Misc/NEWS
Misc/developers.txt
Modules/gcmodule.c
Modules/mathmodule.c
Objects/object.c
Tools/msi/crtlicense.txt

index a1ebed718a848d36df89d4bcbc4fdc82848b7c38..00f21b83cb7be3e4bbe31429aa70b25eabc9a72a 100644 (file)
@@ -74,10 +74,9 @@ Without make
 
 You'll need to checkout the Sphinx package to the `tools/` directory::
 
-   svn co http://svn.python.org/projects/doctools/trunk/sphinx tools/sphinx
+   http://svn.python.org/projects/doctools/trunk/sphinx tools/sphinx
 
-Then, you need to install Docutils 0.4 (the SVN snapshot won't work), either
-by checking it out via ::
+Then, you need to install Docutils, either by checking it out via ::
 
    svn co http://svn.python.org/projects/external/docutils-0.4/docutils tools/docutils
 
@@ -94,19 +93,18 @@ Then, make an output directory, e.g. under `build/`, and run ::
 
    python tools/sphinx-build.py -b<builder> . build/<outputdirectory>
 
-where `<builder>` is one of html, web or htmlhelp (for explanations see the make
-targets above).
+where `<builder>` is one of html, text, latex, or htmlhelp (for explanations see
+the make targets above).
 
 
 Contributing
 ============
 
-For bugs in the content, the online version at http://docs.python.org/ has a
-"suggest change" facility that can be used to correct errors in the source text
-and submit them as a patch to the maintainers.
+Bugs in the content should be reported to the Python bug tracker at
+http://bugs.python.org.
 
-Bugs in the toolset should be reported in the Python bug tracker at
-http://bugs.python.org/.
+Bugs in the toolset should be reported in the Sphinx bug tracker at
+http://www.bitbucket.org/birkenfeld/sphinx/issues/.
 
 You can also send a mail to the Python Documentation Team at docs@python.org,
 and we will process your request as soon as possible.
index 1e540edb251c3f980a13c306f4dfc7beb62080fb..7971878bba813b5fb029f7548e205bafd43d8221 100644 (file)
@@ -563,6 +563,8 @@ This information includes:
 +----------------------+---------------------------+-----------------+--------+
 | ``classifiers``      | a list of classifiers     | list of strings | \(4)   |
 +----------------------+---------------------------+-----------------+--------+
+| ``platforms``        | a list of platforms       | list of strings |        |
++----------------------+---------------------------+-----------------+--------+
 
 Notes:
 
index ae9e493c40b327e7d7b8496c71c70c4838c45b0a..8c2268ec7b8ed5e989a8cfda268d55e420831890 100644 (file)
@@ -865,7 +865,7 @@ memory and should be avoided completely. [#]_
 The advantage of borrowing over owning a reference is that you don't need to
 take care of disposing of the reference on all possible paths through the code
 --- in other words, with a borrowed reference you don't run the risk of leaking
-when a premature exit is taken.  The disadvantage of borrowing over leaking is
+when a premature exit is taken.  The disadvantage of borrowing over owning is
 that there are some subtle situations where in seemingly correct code a borrowed
 reference can be used after the owner from which it was borrowed has in fact
 disposed of it.
index 792344dac2cf75be20f82b0155125babb828f3ae..b717f80bf0543c23874fd1f949220c2937ac043b 100644 (file)
@@ -728,7 +728,7 @@ indexes at which certain conditions are met::
         if line.strip() == '':
             print 'Blank line at line #%i' % i
 
-``sorted(iterable, [cmp=None], [key=None], [reverse=False)`` collects all the
+``sorted(iterable, [cmp=None], [key=None], [reverse=False])`` collects all the
 elements of the iterable into a list, sorts the list, and returns the sorted
 result.  The ``cmp``, ``key``, and ``reverse`` arguments are passed through to
 the constructed list's ``.sort()`` method. ::
index d6c8d0538feddbea37648181da2aba786b97769b..9b408dcdf7e073b5d2eafc11f1704acbf4dbe6cd 100644 (file)
@@ -1363,8 +1363,6 @@ available.  They are listed here in alphabetical order.
 
    .. index::
       statement: import
-      module: ihooks
-      module: rexec
       module: imp
 
    .. note::
@@ -1372,46 +1370,64 @@ available.  They are listed here in alphabetical order.
       This is an advanced function that is not needed in everyday Python
       programming.
 
-   The function is invoked by the :keyword:`import` statement.  It mainly exists
-   so that you can replace it with another function that has a compatible
-   interface, in order to change the semantics of the :keyword:`import` statement.
-   See the built-in module :mod:`imp`, which defines some useful operations out
-   of which you can build your own :func:`__import__` function.
-
-   For example, the statement ``import spam`` results in the following call:
-   ``__import__('spam', globals(), locals(), [], -1)``; the statement
-   ``from spam.ham import eggs`` results in ``__import__('spam.ham', globals(),
-   locals(), ['eggs'], -1)``.  Note that even though ``locals()`` and ``['eggs']``
-   are passed in as arguments, the :func:`__import__` function does not set the
-   local variable named ``eggs``; this is done by subsequent code that is generated
-   for the import statement.  (In fact, the standard implementation does not use
-   its *locals* argument at all, and uses its *globals* only to determine the
-   package context of the :keyword:`import` statement.)
+   This function is invoked by the :keyword:`import` statement.  It can be
+   replaced (by importing the :mod:`builtins` module and assigning to
+   ``builtins.__import__``) in order to change semantics of the
+   :keyword:`import` statement, but nowadays it is usually simpler to use import
+   hooks (see :pep:`302`).  Direct use of :func:`__import__` is rare, except in
+   cases where you want to import a module whose name is only known at runtime.
+
+   The function imports the module *name*, potentially using the given *globals*
+   and *locals* to determine how to interpret the name in a package context.
+   The *fromlist* gives the names of objects or submodules that should be
+   imported from the module given by *name*.  The standard implementation does
+   not use its *locals* argument at all, and uses its *globals* only to
+   determine the package context of the :keyword:`import` statement.
+
+   *level* specifies whether to use absolute or relative imports.  The default
+   is ``-1`` which indicates both absolute and relative imports will be
+   attempted.  ``0`` means only perform absolute imports.  Positive values for
+   *level* indicate the number of parent directories to search relative to the
+   directory of the module calling :func:`__import__`.
 
    When the *name* variable is of the form ``package.module``, normally, the
    top-level package (the name up till the first dot) is returned, *not* the
    module named by *name*.  However, when a non-empty *fromlist* argument is
-   given, the module named by *name* is returned.  This is done for
-   compatibility with the :term:`bytecode` generated for the different kinds of import
-   statement; when using ``import spam.ham.eggs``, the top-level package
-   :mod:`spam` must be placed in the importing namespace, but when using ``from
-   spam.ham import eggs``, the ``spam.ham`` subpackage must be used to find the
-   ``eggs`` variable.  As a workaround for this behavior, use :func:`getattr` to
-   extract the desired components.  For example, you could define the following
-   helper::
-
-      def my_import(name):
-          mod = __import__(name)
-          components = name.split('.')
-          for comp in components[1:]:
-              mod = getattr(mod, comp)
-          return mod
-
-   *level* specifies whether to use absolute or relative imports. The default is
-   ``-1`` which indicates both absolute and relative imports will be attempted.
-   ``0`` means only perform absolute imports. Positive values for *level* indicate
-   the number of parent directories to search relative to the directory of the
-   module calling :func:`__import__`.
+   given, the module named by *name* is returned.
+
+   For example, the statement ``import spam`` results in bytecode resembling the
+   following code::
+   
+      spam = __import__('spam', globals(), locals(), [], -1)
+
+   The statement ``import spam.ham`` results in this call::
+
+      spam = __import__('spam.ham', globals(), locals(), [], -1)
+
+   Note how :func:`__import__` returns the toplevel module here because this is
+   the object that is bound to a name by the :keyword:`import` statement.
+
+   On the other hand, the statement ``from spam.ham import eggs, sausage as
+   saus`` results in ::
+
+      _temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], -1)
+      eggs = _temp.eggs
+      saus = _temp.sausage
+
+   Here, the ``spam.ham`` module is returned from :func:`__import__`.  From this
+   object, the names to import are retrieved and assigned to their respective
+   names.
+
+   If you simply want to import a module (potentially within a package) by name,
+   you can get it from :data:`sys.modules`::
+
+      >>> import sys
+      >>> name = 'foo.bar.baz'
+      >>> __import__(name)
+      <module 'foo' from ...>
+      >>> baz = sys.modules[name]
+      >>> baz
+      <module 'foo.bar.baz' from ...>
 
    .. versionchanged:: 2.5
       The level parameter was added.
index 3d297363056b655a0506a7bcdb073124a4d42156..39fde8217117c660ccb8592685c61adc9b2ccae4 100644 (file)
@@ -21,8 +21,9 @@ was generated in the first place.
 The following functions are provided by this module.  Except when explicitly
 noted otherwise, all return values are floats.
 
-Number-theoretic and representation functions:
 
+Number-theoretic and representation functions
+---------------------------------------------
 
 .. function:: ceil(x)
 
@@ -123,8 +124,8 @@ Number-theoretic and representation functions:
 
 .. function:: modf(x)
 
-   Return the fractional and integer parts of *x*.  Both results carry the sign of
-   *x*, and both are floats.
+   Return the fractional and integer parts of *x*.  Both results carry the sign
+   of *x* and are floats.
 
 
 .. function:: trunc(x)
@@ -146,7 +147,9 @@ Python floats typically carry no more than 53 bits of precision (the same as the
 platform C double type), in which case any float *x* with ``abs(x) >= 2**52``
 necessarily has no fractional bits.
 
-Power and logarithmic functions:
+
+Power and logarithmic functions
+-------------------------------
 
 .. function:: exp(x)
 
@@ -193,7 +196,8 @@ Power and logarithmic functions:
    Return the square root of *x*.
 
 
-Trigonometric functions:
+Trigonometric functions
+-----------------------
 
 .. function:: acos(x)
 
@@ -241,7 +245,8 @@ Trigonometric functions:
    Return the tangent of *x* radians.
 
 
-Angular conversion:
+Angular conversion
+------------------
 
 .. function:: degrees(x)
 
@@ -253,7 +258,8 @@ Angular conversion:
    Converts angle *x* from degrees to radians.
 
 
-Hyperbolic functions:
+Hyperbolic functions
+--------------------
 
 .. function:: acosh(x)
 
@@ -291,7 +297,8 @@ Hyperbolic functions:
    Return the hyperbolic tangent of *x*.
 
 
-The module also defines two mathematical constants:
+Constants
+---------
 
 .. data:: pi
 
index e1992cc68a93637aa2ba93c24067f394c5a58312..8297e9fcd587aaa44400b0f4c1ca2c19da77ff31 100644 (file)
@@ -1438,13 +1438,13 @@ itself.  This means, for example, that one shared object can contain a second::
 
    Proxy objects are instances of subclasses of :class:`BaseProxy`.
 
-   .. method:: _call_method(methodname[, args[, kwds]])
+   .. method:: _callmethod(methodname[, args[, kwds]])
 
       Call and return the result of a method of the proxy's referent.
 
       If ``proxy`` is a proxy whose referent is ``obj`` then the expression ::
 
-         proxy._call_method(methodname, args, kwds)
+         proxy._callmethod(methodname, args, kwds)
 
       will evaluate the expression ::
 
@@ -1457,26 +1457,26 @@ itself.  This means, for example, that one shared object can contain a second::
       argument of :meth:`BaseManager.register`.
 
       If an exception is raised by the call, then then is re-raised by
-      :meth:`_call_method`.  If some other exception is raised in the manager's
+      :meth:`_callmethod`.  If some other exception is raised in the manager's
       process then this is converted into a :exc:`RemoteError` exception and is
-      raised by :meth:`_call_method`.
+      raised by :meth:`_callmethod`.
 
       Note in particular that an exception will be raised if *methodname* has
       not been *exposed*
 
-      An example of the usage of :meth:`_call_method`::
+      An example of the usage of :meth:`_callmethod`::
 
          >>> l = manager.list(range(10))
-         >>> l._call_method('__len__')
+         >>> l._callmethod('__len__')
          10
-         >>> l._call_method('__getslice__', (2, 7))   # equiv to `l[2:7]`
+         >>> l._callmethod('__getslice__', (2, 7))   # equiv to `l[2:7]`
          [2, 3, 4, 5, 6]
-         >>> l._call_method('__getitem__', (20,))     # equiv to `l[20]`
+         >>> l._callmethod('__getitem__', (20,))     # equiv to `l[20]`
          Traceback (most recent call last):
          ...
          IndexError: list index out of range
 
-   .. method:: _get_value()
+   .. method:: _getvalue()
 
       Return a copy of the referent.
 
index 311655d09ccb084d9cae69e0166806de58650123..fbc2de2f05e46ad359ed326f8676149edba609d6 100644 (file)
@@ -1630,36 +1630,33 @@ directly).
 Nevertheless, here's a stab at a callback for an option with variable
 arguments::
 
-   def vararg_callback(option, opt_str, value, parser):
-       assert value is None
-       done = 0
-       value = []
-       rargs = parser.rargs
-       while rargs:
-           arg = rargs[0]
-
-           # Stop if we hit an arg like "--foo", "-a", "-fx", "--file=f",
-           # etc.  Note that this also stops on "-3" or "-3.0", so if
-           # your option takes numeric values, you will need to handle
-           # this.
-           if ((arg[:2] == "--" and len(arg) > 2) or
-               (arg[:1] == "-" and len(arg) > 1 and arg[1] != "-")):
-               break
-           else:
-               value.append(arg)
-               del rargs[0]
-
-       setattr(parser.values, option.dest, value)
+    def vararg_callback(option, opt_str, value, parser):
+        assert value is None
+        value = []
+
+        def floatable(str):
+            try:
+                float(str)
+                return True
+            except ValueError:
+                return False
+
+        for arg in parser.rargs:
+            # stop on --foo like options
+            if arg[:2] == "--" and len(arg) > 2:
+                break
+            # stop on -a, but not on -3 or -3.0
+            if arg[:1] == "-" and len(arg) > 1 and not floatable(arg):
+                break
+            value.append(arg)
+
+        del parser.rargs[:len(value)]
+        setattr(parser.values, option.dest, value))
 
    [...]
    parser.add_option("-c", "--callback", dest="vararg_attr",
                      action="callback", callback=vararg_callback)
 
-The main weakness with this particular implementation is that negative numbers
-in the arguments following ``"-c"`` will be interpreted as further options
-(probably causing an error), rather than as arguments to ``"-c"``.  Fixing this
-is left as an exercise for the reader.
-
 
 .. _optparse-extending-optparse:
 
index b409bb739345090811ea63a7eb3600d2aa2abdb7..7baff30a4cc06ca221ab29c128f46e195db584c6 100644 (file)
@@ -156,7 +156,7 @@ copying and removal. For operations on individual files, see also the
    Recursively move a file or directory to another location.
 
    If the destination is on the current filesystem, then simply use rename.
-   Otherwise, copy src to the dst and then remove src.
+   Otherwise, copy src (with :func:`copy2`) to the dst and then remove src.
 
    .. versionadded:: 2.3
 
index 74d5ee7e88449694c4b98f80cc6ad34b6fe174ad..561a1c7f75fba47c71b901ed807ca0168d0c635c 100644 (file)
@@ -52,10 +52,10 @@ The variables defined in the :mod:`signal` module are:
 
 .. data:: SIG_DFL
 
-   This is one of two standard signal handling options; it will simply perform the
-   default function for the signal.  For example, on most systems the default
-   action for :const:`SIGQUIT` is to dump core and exit, while the default action
-   for :const:`SIGCLD` is to simply ignore it.
+   This is one of two standard signal handling options; it will simply perform
+   the default function for the signal.  For example, on most systems the
+   default action for :const:`SIGQUIT` is to dump core and exit, while the
+   default action for :const:`SIGCHLD` is to simply ignore it.
 
 
 .. data:: SIG_IGN
index 16f029acdb45db3e7474c70203d3268f047190b2..a1742e521c9e03cb87a723a4ef43a7c3c9cfb874 100644 (file)
@@ -88,8 +88,14 @@ been GPL-compatible; the table below summarizes the various releases.
 +----------------+--------------+-----------+------------+-----------------+
 | 2.5.1          | 2.5          | 2007      | PSF        | yes             |
 +----------------+--------------+-----------+------------+-----------------+
+| 2.5.2          | 2.5.1        | 2008      | PSF        | yes             |
++----------------+--------------+-----------+------------+-----------------+
+| 2.5.3          | 2.5.2        | 2008      | PSF        | yes             |
++----------------+--------------+-----------+------------+-----------------+
 | 2.6            | 2.5          | 2008      | PSF        | yes             |
 +----------------+--------------+-----------+------------+-----------------+
+| 2.6.1          | 2.6          | 2008      | PSF        | yes             |
++----------------+--------------+-----------+------------+-----------------+
 
 .. note::
 
diff --git a/Doc/tools/sphinx-web.py b/Doc/tools/sphinx-web.py
deleted file mode 100644 (file)
index 5f7b50b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-    Sphinx - Python documentation webserver
-    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    :copyright: 2007 by Georg Brandl.
-    :license: Python license.
-"""
-
-import sys
-
-if __name__ == '__main__':
-    from sphinx.web import main
-    sys.exit(main(sys.argv))
index 00190f2a95429df5d78d891bcbd7d43f07623f76..d389243e7f9c17ca59a5998adacb20e0e263b931 100644 (file)
@@ -47,7 +47,11 @@ from time import asctime
 from pprint import pformat
 from docutils.io import StringOutput
 from docutils.utils import new_document
-from sphinx.builder import Builder
+
+try:
+    from sphinx.builders import Builder
+except ImportError:
+    from sphinx.builder import Builder
 
 try:
     from sphinx.writers.text import TextWriter
index 96b254ce0d1efa538d14a2b3fd4c2c7fd49b1654..6d0d4224d913e2224adac9c7be0e23ba7a58e36d 100644 (file)
@@ -734,7 +734,7 @@ The formatting template uses curly brackets (`{`, `}`) as special characters::
 
 Curly brackets can be escaped by doubling them::
 
-     >>> format("Empty dict: {{}}")
+     >>> "Empty dict: {{}}".format()
      "Empty dict: {}"
 
 Field names can be integers indicating positional arguments, such as
diff --git a/LICENSE b/LICENSE
index 3d41e75f1e9b5617ee515810c5bff86fa6e8e8de..69acaeb7531b670104a61bb4e0371ca516d581f1 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -55,7 +55,10 @@ the various releases.
     2.4.4           2.4.3       2006        PSF         yes
     2.5             2.4         2006        PSF         yes
     2.5.1           2.5         2007        PSF         yes
+    2.5.2           2.5.1       2008        PSF         yes
+    2.5.3           2.5.2       2008        PSF         yes
     2.6             2.5         2008        PSF         yes
+    2.6.1           2.6         2008        PSF         yes
 
 Footnotes:
 
index 8d9177092744d100c523c4ff71a03e7b87593481..588c7fbd5aed9ed0bce255c07c5ff8ac8436187b 100644 (file)
@@ -14,13 +14,13 @@ class Set:
     def __len__(self):
         return len(self.elts)
     def __contains__(self, elt):
-        return self.elts.has_key(elt)
+        return elt in self.elts
     def add(self, elt):
         self.elts[elt] = elt
     def elements(self):
         return self.elts.keys()
     def has_elt(self, elt):
-        return self.elts.has_key(elt)
+        return elt in self.elts
     def remove(self, elt):
         del self.elts[elt]
     def copy(self):
index 893fa6403a1abc360a393c8a80f48583ac19a9e3..6efec28094573aaa2523ca409549a298854b8b07 100644 (file)
@@ -210,7 +210,7 @@ def dfs_postorder(b, seen):
     order = []
     seen[b] = b
     for c in b.get_children():
-        if seen.has_key(c):
+        if c in seen:
             continue
         order = order + dfs_postorder(c, seen)
     order.append(b)
@@ -406,7 +406,7 @@ class PyFlowGraph(FlowGraph):
         seen = {}
 
         def max_depth(b, d):
-            if seen.has_key(b):
+            if b in seen:
                 return d
             seen[b] = 1
             d = d + depth[b]
@@ -482,7 +482,7 @@ class PyFlowGraph(FlowGraph):
         for name in self.cellvars:
             cells[name] = 1
         self.cellvars = [name for name in self.varnames
-                         if cells.has_key(name)]
+                         if name in cells]
         for name in self.cellvars:
             del cells[name]
         self.cellvars = self.cellvars + cells.keys()
index 8f6298060d825808bb66ef1dcd99485232f3616f..0e660ae7da1250f7800322e90de0a4ea65281adb 100644 (file)
@@ -49,9 +49,9 @@ class Scope:
 
     def add_global(self, name):
         name = self.mangle(name)
-        if self.uses.has_key(name) or self.defs.has_key(name):
+        if name in self.uses or name in self.defs:
             pass # XXX warn about global following def/use
-        if self.params.has_key(name):
+        if name in self.params:
             raise SyntaxError, "%s in %s is global and parameter" % \
                   (name, self.name)
         self.globals[name] = 1
@@ -88,14 +88,13 @@ class Scope:
 
         The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
         """
-        if self.globals.has_key(name):
+        if name in self.globals:
             return SC_GLOBAL
-        if self.cells.has_key(name):
+        if name in self.cells:
             return SC_CELL
-        if self.defs.has_key(name):
+        if name in self.defs:
             return SC_LOCAL
-        if self.nested and (self.frees.has_key(name) or
-                            self.uses.has_key(name)):
+        if self.nested and (name in self.frees or name in self.uses):
             return SC_FREE
         if self.nested:
             return SC_UNKNOWN
@@ -108,8 +107,7 @@ class Scope:
         free = {}
         free.update(self.frees)
         for name in self.uses.keys():
-            if not (self.defs.has_key(name) or
-                    self.globals.has_key(name)):
+            if name not in self.defs and name not in self.globals:
                 free[name] = 1
         return free.keys()
 
@@ -134,7 +132,7 @@ class Scope:
         free.
         """
         self.globals[name] = 1
-        if self.frees.has_key(name):
+        if name in self.frees:
             del self.frees[name]
         for child in self.children:
             if child.check_name(name) == SC_FREE:
index eccade3fd5b423d48a5a4ff4d804627fda2dfcb8..f5fe582bc95c9c052cd42dc987e020b0d3774b9e 100644 (file)
@@ -81,7 +81,7 @@ def extractLineNo(ast):
 
 def Node(*args):
     kind = args[0]
-    if nodes.has_key(kind):
+    if kind in nodes:
         try:
             return nodes[kind](*args[1:])
         except TypeError:
@@ -120,7 +120,7 @@ class Transformer:
     def transform(self, tree):
         """Transform an AST into a modified parse tree."""
         if not (isinstance(tree, tuple) or isinstance(tree, list)):
-            tree = parser.ast2tuple(tree, line_info=1)
+            tree = parser.st2tuple(tree, line_info=1)
         return self.compile_node(tree)
 
     def parsesuite(self, text):
index 9e39d3664937fbb3227e78deff752f3017be4fd1..f10f56011a3ec629c1b8cdb695b4ffbbbfefce35 100644 (file)
@@ -84,7 +84,7 @@ class ExampleASTVisitor(ASTVisitor):
             meth(node, *args)
         elif self.VERBOSE > 0:
             klass = node.__class__
-            if not self.examples.has_key(klass):
+            if klass not in self.examples:
                 self.examples[klass] = klass
                 print
                 print self.visitor
index 0ed9a40a35e29fd888846c91026abb065d882a4f..87d6e27396a25f4698f613b5835fb7a0809bd403 100644 (file)
@@ -1041,7 +1041,7 @@ main (int argc, char **argv) {
         return move_file (src, dst, dry_run=self.dry_run)
 
     def mkpath (self, name, mode=0777):
-        mkpath (name, mode, self.dry_run)
+        mkpath (name, mode, dry_run=self.dry_run)
 
 
 # class CCompiler
index a4d148d45588f3fe70158c5efeae7442be5eef54..0d65a2e976760b2c96110c1dc366676c36272f1a 100644 (file)
@@ -40,7 +40,8 @@ class StdoutRefactoringTool(refactor.RefactoringTool):
         # Actually write the new file
         super(StdoutRefactoringTool, self).write_file(new_text,
                                                       filename, old_text)
-        shutil.copymode(filename, backup)
+        if not self.nobackups:
+            shutil.copymode(filename, backup)
 
     def print_output(self, lines):
         for line in lines:
index 7b790d2de12dd6f2d1548a824c945084cc1140f4..67765009d5a92bd445b8660d5fbea980bd75bbf5 100644 (file)
@@ -846,7 +846,7 @@ class PlaceHolder:
         Add the specified logger as a child of this placeholder.
         """
         #if alogger not in self.loggers:
-        if not self.loggerMap.has_key(alogger):
+        if alogger not in self.loggerMap:
             #self.loggers.append(alogger)
             self.loggerMap[alogger] = None
 
index 1eab90cfc44fd758598606ae88493e555e0b59fc..c91e242dfdb8655e26386e406e7b706efb46d52f 100644 (file)
@@ -174,7 +174,7 @@ What a mess!
         text = ("Python 1.0.0 was released on 1994-01-26.  Python 1.0.1 was\n"
                 "released on 1994-02-15.")
 
-        self.check_wrap(text, 30, ['Python 1.0.0 was released on',
+        self.check_wrap(text, 35, ['Python 1.0.0 was released on',
                                    '1994-01-26.  Python 1.0.1 was',
                                    'released on 1994-02-15.'])
         self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.',
@@ -353,6 +353,14 @@ What a mess!
             otext = self.wrapper.fill(text)
             assert isinstance(otext, unicode)
 
+        def test_no_split_at_umlaut(self):
+            text = u"Die Empf\xe4nger-Auswahl"
+            self.check_wrap(text, 13, [u"Die", u"Empf\xe4nger-", u"Auswahl"])
+
+        def test_umlaut_followed_by_dash(self):
+            text = u"aa \xe4\xe4-\xe4\xe4"
+            self.check_wrap(text, 7, [u"aa \xe4\xe4-", u"\xe4\xe4"])
+
     def test_split(self):
         # Ensure that the standard _split() method works as advertised
         # in the comments
index e28ee71a840da81c4f140406f51c22f7d5d3082d..ff164c2058cc7dc303f163824b3a3ec4595a46a8 100644 (file)
@@ -1104,6 +1104,51 @@ class MiscTests(unittest.TestCase):
         else:
             self.assert_(False)
 
+class RequestTests(unittest.TestCase):
+
+    def setUp(self):
+        self.get = urllib2.Request("http://www.python.org/~jeremy/")
+        self.post = urllib2.Request("http://www.python.org/~jeremy/",
+                                    "data",
+                                    headers={"X-Test": "test"})
+
+    def test_method(self):
+        self.assertEqual("POST", self.post.get_method())
+        self.assertEqual("GET", self.get.get_method())
+
+    def test_add_data(self):
+        self.assert_(not self.get.has_data())
+        self.assertEqual("GET", self.get.get_method())
+        self.get.add_data("spam")
+        self.assert_(self.get.has_data())
+        self.assertEqual("POST", self.get.get_method())
+
+    def test_get_full_url(self):
+        self.assertEqual("http://www.python.org/~jeremy/",
+                         self.get.get_full_url())
+
+    def test_selector(self):
+        self.assertEqual("/~jeremy/", self.get.get_selector())
+        req = urllib2.Request("http://www.python.org/")
+        self.assertEqual("/", req.get_selector())
+
+    def test_get_type(self):
+        self.assertEqual("http", self.get.get_type())
+
+    def test_get_host(self):
+        self.assertEqual("www.python.org", self.get.get_host())
+
+    def test_get_host_unquote(self):
+        req = urllib2.Request("http://www.%70ython.org/")
+        self.assertEqual("www.python.org", req.get_host())
+
+    def test_proxy(self):
+        self.assert_(not self.get.has_proxy())
+        self.get.set_proxy("www.perl.org", "http")
+        self.assert_(self.get.has_proxy())
+        self.assertEqual("www.python.org", self.get.get_origin_req_host())
+        self.assertEqual("www.perl.org", self.get.get_host())
+
 
 def test_main(verbose=None):
     from test import test_urllib2
@@ -1112,7 +1157,8 @@ def test_main(verbose=None):
     tests = (TrivialTests,
              OpenerDirectorTests,
              HandlerTests,
-             MiscTests)
+             MiscTests,
+             RequestTests)
     test_support.run_unittest(*tests)
 
 if __name__ == "__main__":
index 53f2f1bac7c34534c5569112b60e65a9c71b1dd3..192b43b1df9459f2bc183637b1a3b3197661427e 100644 (file)
@@ -84,16 +84,16 @@ class TextWrapper:
     # splits into
     #   Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option!
     # (after stripping out empty strings).
-    wordsep_re = re.compile(
+    wordsep_re = (
         r'(\s+|'                                  # any whitespace
-        r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|'   # hyphenated words
+        r'[^\s\w]*\w+[^0-9\W]-(?=\w+[^0-9\W])|'   # hyphenated words
         r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))')   # em-dash
 
     # This less funky little regex just split on recognized spaces. E.g.
     #   "Hello there -- you goof-ball, use the -b option!"
     # splits into
     #   Hello/ /there/ /--/ /you/ /goof-ball,/ /use/ /the/ /-b/ /option!/
-    wordsep_simple_re = re.compile(r'(\s+)')
+    wordsep_simple_re = r'(\s+)'
 
     # XXX this is not locale- or charset-aware -- string.lowercase
     # is US-ASCII only (and therefore English-only)
@@ -160,10 +160,12 @@ class TextWrapper:
           'use', ' ', 'the', ' ', '-b', ' ', option!'
         otherwise.
         """
-        if self.break_on_hyphens is True:
-            chunks = self.wordsep_re.split(text)
+        flags = re.UNICODE if isinstance(text, unicode) else 0
+        if self.break_on_hyphens:
+            pat = self.wordsep_re
         else:
-            chunks = self.wordsep_simple_re.split(text)
+            pat = self.wordsep_simple_re
+        chunks = re.compile(pat, flags).split(text)
         chunks = filter(None, chunks)  # remove empty chunks
         return chunks
 
index 43f5ce71431be57fe3d45d4125ef8744874d25e8..4eba4f6d2a2f34ff67a7e3ae4bd41bad3517cef1 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -15,6 +15,10 @@ Core and Builtins
 - Issue #4597: Fixed several opcodes that weren't always propagating
   exceptions.
 
+- Issue #2467: gc.DEBUG_STATS reported invalid elapsed times. Also, always
+  print elapsed times, not only when some objects are uncollectable /
+  unreachable. Original patch by Neil Schemenauer.
+
 - Issue #4589: Fixed exception handling when the __exit__ function of a
   context manager returns a value that cannot be converted to a bool.
 
@@ -114,10 +118,21 @@ Core and Builtins
 Library
 -------
 
+- Issue #4163: Use unicode-friendly word splitting in the textwrap functions
+  when given an unicode string.
+
+- Issue #4616: TarFile.utime(): Restore directory times on Windows.
+
 - Issue #4084: Fix max, min, max_mag and min_mag Decimal methods to
   give correct results in the case where one argument is a quiet NaN
   and the other is a finite number that requires rounding.
 
+- Issue #1030250: Distutils created directories even when run with the
+  --dry-run option.
+
+- Issue #4483: _dbm module now builds on systems with gdbm & gdbm_compat
+  libs.
+
 - Issue #4529: fix the parser module's validation of try-except-finally
   statements.
 
@@ -177,6 +192,9 @@ Build
 C-API
 -----
 
+- Issue #3632: from the gdb debugger, the 'pyo' macro can now be called when
+  the GIL is released, or owned by another thread.
+
 - Issue #4122: On Windows, fix a compilation error when using the
   Py_UNICODE_ISSPACE macro in an extension module.
 
index 883246360ae9e6f1bc488f393c136a8bfc5bd340..b4f6c702aade973ad7a9c3f6abc285c4d9f4ba2d 100644 (file)
@@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise.
 Permissions History
 -------------------
 
+- Tarek Ziadé as given SVN access on Decmeber 21 2008 by NCN,
+  for maintenance of distutils.
+
 - Hirokazu Yamamoto was given SVN access on August 12 2008 by MvL,
   for contributions to the Windows build.
 
index 6f12972200b3ec7ce1ef64addf6b14b8d3faa528..c7426a58cedec80c758af80e8fada290f41a0580 100644 (file)
@@ -740,6 +740,24 @@ clear_freelists(void)
        (void)PyFloat_ClearFreeList();
 }
 
+static double
+get_time(void)
+{
+       double result = 0;
+       if (tmod != NULL) {
+               PyObject *f = PyObject_CallMethod(tmod, "time", NULL);
+               if (f == NULL) {
+                       PyErr_Clear();
+               }
+               else {
+                       if (PyFloat_Check(f))
+                               result = PyFloat_AsDouble(f);
+                       Py_DECREF(f);
+               }
+       }
+       return result;
+}
+
 /* This is the main function.  Read this to understand how the
  * collection process works. */
 static Py_ssize_t
@@ -762,16 +780,7 @@ collect(int generation)
        }
 
        if (debug & DEBUG_STATS) {
-               if (tmod != NULL) {
-                       PyObject *f = PyObject_CallMethod(tmod, "time", NULL);
-                       if (f == NULL) {
-                               PyErr_Clear();
-                       }
-                       else {
-                               t1 = PyFloat_AsDouble(f);
-                               Py_DECREF(f);
-                       }
-               }
+               t1 = get_time();
                PySys_WriteStderr("gc: collecting generation %d...\n",
                                  generation);
                PySys_WriteStderr("gc: objects in each generation:");
@@ -844,17 +853,6 @@ collect(int generation)
                if (debug & DEBUG_COLLECTABLE) {
                        debug_cycle("collectable", FROM_GC(gc));
                }
-               if (tmod != NULL && (debug & DEBUG_STATS)) {
-                       PyObject *f = PyObject_CallMethod(tmod, "time", NULL);
-                       if (f == NULL) {
-                               PyErr_Clear();
-                       }
-                       else {
-                               t1 = PyFloat_AsDouble(f)-t1;
-                               Py_DECREF(f);
-                               PySys_WriteStderr("gc: %.4fs elapsed.\n", t1);
-                       }
-               }
        }
 
        /* Clear weakrefs and invoke callbacks as necessary. */
@@ -876,14 +874,19 @@ collect(int generation)
                        debug_cycle("uncollectable", FROM_GC(gc));
        }
        if (debug & DEBUG_STATS) {
+               double t2 = get_time();
                if (m == 0 && n == 0)
-                       PySys_WriteStderr("gc: done.\n");
+                       PySys_WriteStderr("gc: done");
                else
                        PySys_WriteStderr(
                            "gc: done, "
                            "%" PY_FORMAT_SIZE_T "d unreachable, "
-                           "%" PY_FORMAT_SIZE_T "d uncollectable.\n",
+                           "%" PY_FORMAT_SIZE_T "d uncollectable",
                            n+m, n);
+               if (t1 && t2) {
+                       PySys_WriteStderr(", %.4fs elapsed", t2-t1);
+               }
+               PySys_WriteStderr(".\n");
        }
 
        /* Append instances in the uncollectable set to a Python
index 5087ecc481bbef4030c3774c31ce483310029feb..952d56a48ad6dc2af3469cb28346aa2ea5c3fce6 100644 (file)
@@ -630,7 +630,10 @@ error:
        return NULL;
 }
 
-PyDoc_STRVAR(math_factorial_doc, "Return n!");
+PyDoc_STRVAR(math_factorial_doc,
+"factorial(x) -> Integral\n"
+"\n"
+"Find x!. Raise a ValueError if x is negative or non-integral.");
 
 static PyObject *
 math_trunc(PyObject *self, PyObject *number)
@@ -764,7 +767,7 @@ PyDoc_STRVAR(math_modf_doc,
 "modf(x)\n"
 "\n"
 "Return the fractional and integer parts of x.  Both results carry the sign\n"
-"of x.  The integer part is returned as a real.");
+"of x and are floats.");
 
 /* A decent logarithm is easy to compute even for huge longs, but libm can't
    do that by itself -- loghelper can.  func is log or log10, and name is
index 9cd34b8d4e3b252b82c8472c5202cd36b6522ff1..c882cf25424f4129faea4cf82480b95c87a8f8a6 100644 (file)
@@ -331,8 +331,11 @@ void _PyObject_Dump(PyObject* op)
        if (op == NULL)
                fprintf(stderr, "NULL\n");
        else {
+               PyGILState_STATE gil;
                fprintf(stderr, "object  : ");
+               gil = PyGILState_Ensure();
                (void)PyObject_Print(op, stderr, 0);
+               PyGILState_Release(gil);
                /* XXX(twouters) cast refcount to long until %zd is
                   universally available */
                fprintf(stderr, "\n"
index 8ecd49935d57c0df50c295ed63a8707f0f9233c6..936bc5ad532d19f7ef3bb7fa53e51e6adf9cbd52 100644 (file)
@@ -26,7 +26,7 @@ complies with this agreement, provided that you do not:
 - alter any copyright, trademark or patent notice in Microsoft's
 Distributable Code;
 
-- use Microsoft\92s trademarks in your programs\92 names or in a way that
+- use Microsoft's trademarks in your programs' names or in a way that
 suggests your programs come from or are endorsed by Microsoft;
 
 - distribute Microsoft's Distributable Code to run on a platform other