Skip to content

Commit

Permalink
Merged revisions 82805-82806,83523-83527,83536,83538,83542,83546-8354…
Browse files Browse the repository at this point in the history
…8,83550-83555,83558,83560 via svnmerge from

svn+ssh://svn.python.org/python/branches/py3k

........
  r82805 | georg.brandl | 2010-07-11 11:42:10 +0200 (So, 11 Jul 2010) | 1 line

  python#7935: cross-reference to ast.literal_eval() from eval() docs.
........
  r82806 | georg.brandl | 2010-07-11 12:22:44 +0200 (So, 11 Jul 2010) | 1 line

  python#9223: link to Command class reference, and move Command interface docs nearer to class docs.
........
  r83523 | georg.brandl | 2010-08-02 14:06:18 +0200 (Mo, 02 Aug 2010) | 1 line

  python#9209 and python#7781: fix two crashes in pstats interactive browser.
........
  r83524 | georg.brandl | 2010-08-02 14:20:23 +0200 (Mo, 02 Aug 2010) | 1 line

  python#9428: fix running scripts from profile/cProfile with their own name and the right namespace.  Same fix as for trace.py in #1690103.
........
  r83525 | georg.brandl | 2010-08-02 14:36:24 +0200 (Mo, 02 Aug 2010) | 1 line

  Get rid of spurious "threading" entries in trace output.
........
  r83526 | georg.brandl | 2010-08-02 14:40:22 +0200 (Mo, 02 Aug 2010) | 1 line

  Fix softspace relic.
........
  r83527 | georg.brandl | 2010-08-02 14:48:46 +0200 (Mo, 02 Aug 2010) | 1 line

  python#3821: beginnings of a trace.py unittest.
........
  r83536 | georg.brandl | 2010-08-02 19:49:25 +0200 (Mo, 02 Aug 2010) | 1 line

  python#8578: mention danger of not incref'ing weak referenced object.
........
  r83538 | georg.brandl | 2010-08-02 20:10:13 +0200 (Mo, 02 Aug 2010) | 1 line

  python#6928: fix class docs w.r.t. new metaclasses.
........
  r83542 | georg.brandl | 2010-08-02 20:56:54 +0200 (Mo, 02 Aug 2010) | 1 line

  Move test_SimpleHTTPServer into test_httpservers.
........
  r83546 | georg.brandl | 2010-08-02 21:16:34 +0200 (Mo, 02 Aug 2010) | 1 line

  python#7973: Fix distutils options spelling.
........
  r83547 | georg.brandl | 2010-08-02 21:19:26 +0200 (Mo, 02 Aug 2010) | 1 line

  python#7386: add example that shows that trailing path separators are stripped.
........
  r83548 | georg.brandl | 2010-08-02 21:23:34 +0200 (Mo, 02 Aug 2010) | 1 line

  python#8172: how does one use a property?
........
  r83550 | georg.brandl | 2010-08-02 21:32:43 +0200 (Mo, 02 Aug 2010) | 1 line

  python#9451: strengthen warning about __*__ special name usage.
........
  r83551 | georg.brandl | 2010-08-02 21:35:06 +0200 (Mo, 02 Aug 2010) | 1 line

  Remove XXX comment that was displayed.
........
  r83552 | georg.brandl | 2010-08-02 21:36:36 +0200 (Mo, 02 Aug 2010) | 1 line

  python#9438: clarify that constant names also cannot be assigned as attributes.
........
  r83553 | georg.brandl | 2010-08-02 21:39:17 +0200 (Mo, 02 Aug 2010) | 1 line

  Remove redundant information.
........
  r83554 | georg.brandl | 2010-08-02 21:43:05 +0200 (Mo, 02 Aug 2010) | 1 line

  python#7280: note about nasmw.exe.
........
  r83555 | georg.brandl | 2010-08-02 21:44:48 +0200 (Mo, 02 Aug 2010) | 1 line

  python#8861: remove unused variable.
........
  r83558 | georg.brandl | 2010-08-02 22:05:19 +0200 (Mo, 02 Aug 2010) | 1 line

  python#8648: document UTF-7 codec functions.
........
  r83560 | georg.brandl | 2010-08-02 22:16:18 +0200 (Mo, 02 Aug 2010) | 1 line

  python#9087: update json docstrings -- unicode and long do not exist anymore.
........
  • Loading branch information
birkenfeld committed Oct 6, 2010
1 parent 914a218 commit 4009c9e
Show file tree
Hide file tree
Showing 22 changed files with 268 additions and 221 deletions.
32 changes: 32 additions & 0 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,38 @@ These are the UTF-16 codec APIs:
Return *NULL* if an exception was raised by the codec.


UTF-7 Codecs
""""""""""""

These are the UTF-7 codec APIs:


.. cfunction:: PyObject* PyUnicode_DecodeUTF7(const char *s, Py_ssize_t size, const char *errors)

Create a Unicode object by decoding *size* bytes of the UTF-7 encoded string
*s*. Return *NULL* if an exception was raised by the codec.


.. cfunction:: PyObject* PyUnicode_DecodeUTF8Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)

If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF7`. If
*consumed* is not *NULL*, trailing incomplete UTF-7 base-64 sections will not
be treated as an error. Those bytes will not be decoded and the number of
bytes that have been decoded will be stored in *consumed*.


.. cfunction:: PyObject* PyUnicode_EncodeUTF7(const Py_UNICODE *s, Py_ssize_t size, int base64SetO, int base64WhiteSpace, const char *errors)

Encode the :ctype:`Py_UNICODE` buffer of the given size using UTF-7 and
return a Python bytes object. Return *NULL* if an exception was raised by
the codec.

If *base64SetO* is nonzero, "Set O" (punctuation that has no otherwise
special meaning) will be encoded in base-64. If *base64WhiteSpace* is
nonzero, whitespace will be encoded in base-64. Both are set to zero for the
Python "utf-7" codec.


Unicode-Escape Codecs
"""""""""""""""""""""

Expand Down
9 changes: 8 additions & 1 deletion Doc/c-api/weakref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ as much as it can.
.. cfunction:: PyObject* PyWeakref_GetObject(PyObject *ref)

Return the referenced object from a weak reference, *ref*. If the referent is
no longer live, returns ``None``.
no longer live, returns :const:`Py_None`.

.. warning::

This function returns a **borrowed reference** to the referenced object.
This means that you should always call :cfunc:`Py_INCREF` on the object
except if you know that it cannot be destroyed while you are still
using it.


.. cfunction:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
Expand Down
169 changes: 80 additions & 89 deletions Doc/distutils/apiref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ setup script). Indirectly provides the :class:`distutils.dist.Distribution` and
In addition, the :mod:`distutils.core` module exposed a number of classes that
live elsewhere.

* :class:`Extension` from :mod:`distutils.extension`
* :class:`~distutils.extension.Extension` from :mod:`distutils.extension`

* :class:`Command` from :mod:`distutils.cmd`
* :class:`~distutils.cmd.Command` from :mod:`distutils.cmd`

* :class:`Distribution` from :mod:`distutils.dist`
* :class:`~distutils.dist.Distribution` from :mod:`distutils.dist`

A short description of each of these follows, but see the relevant module for
the full reference.
Expand Down Expand Up @@ -1679,8 +1679,8 @@ lines, and joining lines with backslashes.
===================================================================

.. module:: distutils.cmd
:synopsis: This module provides the abstract base class Command. This class is subclassed
by the modules in the distutils.command subpackage.
:synopsis: This module provides the abstract base class Command. This class
is subclassed by the modules in the distutils.command subpackage.


This module supplies the abstract base class :class:`Command`.
Expand All @@ -1690,20 +1690,84 @@ This module supplies the abstract base class :class:`Command`.

Abstract base class for defining command classes, the "worker bees" of the
Distutils. A useful analogy for command classes is to think of them as
subroutines with local variables called *options*. The options are declared in
:meth:`initialize_options` and defined (given their final values) in
:meth:`finalize_options`, both of which must be defined by every command class.
The distinction between the two is necessary because option values might come
from the outside world (command line, config file, ...), and any options
dependent on other options must be computed after these outside influences have
been processed --- hence :meth:`finalize_options`. The body of the subroutine,
where it does all its work based on the values of its options, is the
:meth:`run` method, which must also be implemented by every command class.

The class constructor takes a single argument *dist*, a :class:`Distribution`
subroutines with local variables called *options*. The options are declared
in :meth:`initialize_options` and defined (given their final values) in
:meth:`finalize_options`, both of which must be defined by every command
class. The distinction between the two is necessary because option values
might come from the outside world (command line, config file, ...), and any
options dependent on other options must be computed after these outside
influences have been processed --- hence :meth:`finalize_options`. The body
of the subroutine, where it does all its work based on the values of its
options, is the :meth:`run` method, which must also be implemented by every
command class.

The class constructor takes a single argument *dist*, a :class:`Distribution`
instance.


Creating a new Distutils command
================================

This section outlines the steps to create a new Distutils command.

A new command lives in a module in the :mod:`distutils.command` package. There
is a sample template in that directory called :file:`command_template`. Copy
this file to a new module with the same name as the new command you're
implementing. This module should implement a class with the same name as the
module (and the command). So, for instance, to create the command
``peel_banana`` (so that users can run ``setup.py peel_banana``), you'd copy
:file:`command_template` to :file:`distutils/command/peel_banana.py`, then edit
it so that it's implementing the class :class:`peel_banana`, a subclass of
:class:`distutils.cmd.Command`.

Subclasses of :class:`Command` must define the following methods.

.. method:: Command.initialize_options()

Set default values for all the options that this command supports. Note that
these defaults may be overridden by other commands, by the setup script, by
config files, or by the command-line. Thus, this is not the place to code
dependencies between options; generally, :meth:`initialize_options`
implementations are just a bunch of ``self.foo = None`` assignments.


.. method:: Command.finalize_options()

Set final values for all the options that this command supports. This is
always called as late as possible, ie. after any option assignments from the
command-line or from other commands have been done. Thus, this is the place
to to code option dependencies: if *foo* depends on *bar*, then it is safe to
set *foo* from *bar* as long as *foo* still has the same value it was
assigned in :meth:`initialize_options`.


.. method:: Command.run()

A command's raison d'etre: carry out the action it exists to perform, controlled
by the options initialized in :meth:`initialize_options`, customized by other
commands, the setup script, the command-line, and config files, and finalized in
:meth:`finalize_options`. All terminal output and filesystem interaction should
be done by :meth:`run`.


.. attribute:: Command.sub_commands

*sub_commands* formalizes the notion of a "family" of commands,
e.g. ``install`` as the parent with sub-commands ``install_lib``,
``install_headers``, etc. The parent of a family of commands defines
*sub_commands* as a class attribute; it's a list of 2-tuples ``(command_name,
predicate)``, with *command_name* a string and *predicate* a function, a
string or ``None``. *predicate* is a method of the parent command that
determines whether the corresponding command is applicable in the current
situation. (E.g. we ``install_headers`` is only applicable if we have any C
header files to install.) If *predicate* is ``None``, that command is always
applicable.

*sub_commands* is usually defined at the *end* of a class, because
predicates can be methods of the class, so they must already have been
defined. The canonical example is the :command:`install` command.


:mod:`distutils.command` --- Individual Distutils commands
==========================================================

Expand Down Expand Up @@ -1942,76 +2006,3 @@ The ``register`` command registers the package with the Python Package Index.
This is described in more detail in :pep:`301`.

.. % todo
:mod:`distutils.command.check` --- Check the meta-data of a package
===================================================================

.. module:: distutils.command.check
:synopsis: Check the metadata of a package


The ``check`` command performs some tests on the meta-data of a package.
For example, it verifies that all required meta-data are provided as
the arguments passed to the :func:`setup` function.

.. % todo
Creating a new Distutils command
================================

This section outlines the steps to create a new Distutils command.

A new command lives in a module in the :mod:`distutils.command` package. There
is a sample template in that directory called :file:`command_template`. Copy
this file to a new module with the same name as the new command you're
implementing. This module should implement a class with the same name as the
module (and the command). So, for instance, to create the command
``peel_banana`` (so that users can run ``setup.py peel_banana``), you'd copy
:file:`command_template` to :file:`distutils/command/peel_banana.py`, then edit
it so that it's implementing the class :class:`peel_banana`, a subclass of
:class:`distutils.cmd.Command`.

Subclasses of :class:`Command` must define the following methods.


.. method:: Command.initialize_options()

Set default values for all the options that this command supports. Note that
these defaults may be overridden by other commands, by the setup script, by
config files, or by the command-line. Thus, this is not the place to code
dependencies between options; generally, :meth:`initialize_options`
implementations are just a bunch of ``self.foo = None`` assignments.


.. method:: Command.finalize_options()

Set final values for all the options that this command supports. This is
always called as late as possible, ie. after any option assignments from the
command-line or from other commands have been done. Thus, this is the place
to to code option dependencies: if *foo* depends on *bar*, then it is safe to
set *foo* from *bar* as long as *foo* still has the same value it was
assigned in :meth:`initialize_options`.


.. method:: Command.run()

A command's raison d'etre: carry out the action it exists to perform, controlled
by the options initialized in :meth:`initialize_options`, customized by other
commands, the setup script, the command-line, and config files, and finalized in
:meth:`finalize_options`. All terminal output and filesystem interaction should
be done by :meth:`run`.

*sub_commands* formalizes the notion of a "family" of commands, eg. ``install``
as the parent with sub-commands ``install_lib``, ``install_headers``, etc. The
parent of a family of commands defines *sub_commands* as a class attribute; it's
a list of 2-tuples ``(command_name, predicate)``, with *command_name* a string
and *predicate* a function, a string or None. *predicate* is a method of
the parent command that determines whether the corresponding command is
applicable in the current situation. (Eg. we ``install_headers`` is only
applicable if we have any C header files to install.) If *predicate* is None,
that command is always applicable.

*sub_commands* is usually defined at the \*end\* of a class, because predicates
can be methods of the class, so they must already have been defined. The
canonical example is the :command:`install` command.
2 changes: 1 addition & 1 deletion Doc/distutils/builtdist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ easily specify multiple formats in one run. If you need to do both, you can
explicitly specify multiple :command:`bdist_\*` commands and their options::

python setup.py bdist_rpm --packager="John Doe <jdoe@example.org>" \
bdist_wininst --target_version="2.0"
bdist_wininst --target-version="2.0"

Creating RPM packages is driven by a :file:`.spec` file, much as using the
Distutils is driven by the setup script. To make your life easier, the
Expand Down
4 changes: 2 additions & 2 deletions Doc/distutils/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ want to modify existing commands; many simply add a few file extensions that
should be copied into packages in addition to :file:`.py` files as a
convenience.

Most distutils command implementations are subclasses of the :class:`Command`
class from :mod:`distutils.cmd`. New commands may directly inherit from
Most distutils command implementations are subclasses of the
:class:`distutils.cmd.Command` class. New commands may directly inherit from
:class:`Command`, while replacements often derive from :class:`Command`
indirectly, directly subclassing the command they are replacing. Commands are
required to derive from :class:`Command`.
Expand Down
23 changes: 9 additions & 14 deletions Doc/library/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@ Built-in Constants

A small number of constants live in the built-in namespace. They are:


.. note::

:data:`None`, :data:`False`, :data:`True` and :data:`__debug__` cannot be
reassigned (assignments to them raise :exc:`SyntaxError`), so they can be
considered "true" constants.

.. XXX False, True, None are keywords too
.. data:: False

The false value of the :class:`bool` type. Assignments to ``False``
Expand Down Expand Up @@ -40,19 +31,23 @@ A small number of constants live in the built-in namespace. They are:

.. data:: Ellipsis

The same as ``...``. Special value used mostly in conjunction with extended
slicing syntax for user-defined container data types, as in ::

.. XXX Someone who understands extended slicing should fill in here.
The same as ``...``. Special value used mostly in conjunction with extended
slicing syntax for user-defined container data types.


.. data:: __debug__

This constant is true if Python was not started with an :option:`-O` option.
Assignments to :const:`__debug__` are illegal and raise a :exc:`SyntaxError`.
See also the :keyword:`assert` statement.


.. note::

The names :data:`None`, :data:`False`, :data:`True` and :data:`__debug__`
cannot be reassigned (assignments to them, even as an attribute name, raise
:exc:`SyntaxError`), so they can be considered "true" constants.


Constants added by the :mod:`site` module
-----------------------------------------

Expand Down
8 changes: 7 additions & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ are always available. They are listed here in alphabetical order.
returns the current global and local dictionary, respectively, which may be
useful to pass around for use by :func:`eval` or :func:`exec`.

See :func:`ast.literal_eval` for a function that can safely evaluate strings
with expressions containing only literals.


.. function:: exec(object[, globals[, locals]])

Expand Down Expand Up @@ -855,7 +858,7 @@ are always available. They are listed here in alphabetical order.

*fget* is a function for getting an attribute value, likewise *fset* is a
function for setting, and *fdel* a function for del'ing, an attribute. Typical
use is to define a managed attribute x::
use is to define a managed attribute ``x``::

class C(object):
def __init__(self):
Expand All @@ -869,6 +872,9 @@ are always available. They are listed here in alphabetical order.
del self._x
x = property(getx, setx, delx, "I'm the 'x' property.")

If then *c* is an instance of *C*, ``c.x`` will invoke the getter,
``c.x = value`` will invoke the setter and ``del c.x`` the deleter.

If given, *doc* will be the docstring of the property attribute. Otherwise, the
property will copy *fget*'s docstring (if it exists). This makes it possible to
create read-only properties easily using :func:`property` as a :term:`decorator`::
Expand Down
4 changes: 3 additions & 1 deletion Doc/library/os.path.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ applications should use string objects to access all files.
.. function:: normpath(path)

Normalize a pathname. This collapses redundant separators and up-level
references so that ``A//B``, ``A/./B`` and ``A/foo/../B`` all become ``A/B``.
references so that ``A//B``, ``A/B/``, ``A/./B`` and ``A/foo/../B`` all become
``A/B``.

It does not normalize the case (use :func:`normcase` for that). On Windows, it
converts forward slashes to backward slashes. It should be understood that this
may change the meaning of the path if it contains symbolic links!
Expand Down
Loading

0 comments on commit 4009c9e

Please sign in to comment.