Commits

Georg Brandl  committed ee9ced9

Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
r68133 | antoine.pitrou | 2009-01-01 16:38:03 +0100 (Thu, 01 Jan 2009) | 1 line

fill in actual issue number in tests
........
r68134 | hirokazu.yamamoto | 2009-01-01 16:45:39 +0100 (Thu, 01 Jan 2009) | 2 lines

Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
file with `str' filename on Windows.
........
r68141 | benjamin.peterson | 2009-01-01 17:43:12 +0100 (Thu, 01 Jan 2009) | 1 line

fix highlighting
........
r68142 | benjamin.peterson | 2009-01-01 18:29:49 +0100 (Thu, 01 Jan 2009) | 2 lines

welcome to 2009, Python!
........
r68145 | amaury.forgeotdarc | 2009-01-02 01:03:54 +0100 (Fri, 02 Jan 2009) | 5 lines

#4801 _collections module fails to build on cygwin.

_PyObject_GC_TRACK is the macro version of PyObject_GC_Track,
and according to documentation it should not be used for extension modules.
........
r68146 | ronald.oussoren | 2009-01-02 11:44:46 +0100 (Fri, 02 Jan 2009) | 2 lines

Fix for issue4472: "configure --enable-shared doesn't work on OSX"
........
r68148 | ronald.oussoren | 2009-01-02 11:48:31 +0100 (Fri, 02 Jan 2009) | 2 lines

Forgot to add a NEWS item in my previous checkin
........
r68149 | ronald.oussoren | 2009-01-02 11:50:48 +0100 (Fri, 02 Jan 2009) | 2 lines

Fix for issue4780
........
r68159 | ronald.oussoren | 2009-01-02 15:48:17 +0100 (Fri, 02 Jan 2009) | 2 lines

Fix for issue 1627952
........
r68160 | ronald.oussoren | 2009-01-02 15:52:09 +0100 (Fri, 02 Jan 2009) | 2 lines

Fix for issue r1737832
........
r68161 | ronald.oussoren | 2009-01-02 16:00:05 +0100 (Fri, 02 Jan 2009) | 3 lines

Fix for issue 1149804
........
r68162 | ronald.oussoren | 2009-01-02 16:06:00 +0100 (Fri, 02 Jan 2009) | 3 lines

Fix for issue 4472 is incompatible with Cygwin, this patch
should fix that.
........
r68166 | benjamin.peterson | 2009-01-02 19:26:23 +0100 (Fri, 02 Jan 2009) | 1 line

document PyMemberDef
........
r68171 | georg.brandl | 2009-01-02 21:25:14 +0100 (Fri, 02 Jan 2009) | 3 lines

#4811: fix markup glitches (mostly remains of the conversion),
found by Gabriel Genellina.
........
r68172 | martin.v.loewis | 2009-01-02 21:32:55 +0100 (Fri, 02 Jan 2009) | 2 lines

Issue #4075: Use OutputDebugStringW in Py_FatalError.
........
r68173 | martin.v.loewis | 2009-01-02 21:40:14 +0100 (Fri, 02 Jan 2009) | 2 lines

Issue #4051: Prevent conflict of UNICODE macros in cPickle.
........
r68174 | benjamin.peterson | 2009-01-02 21:47:27 +0100 (Fri, 02 Jan 2009) | 1 line

fix compilation on non-Windows platforms
........
r68179 | raymond.hettinger | 2009-01-02 22:26:45 +0100 (Fri, 02 Jan 2009) | 1 line

Issue #4615. Document how to use itertools for de-duping.
........
r68195 | georg.brandl | 2009-01-03 14:45:15 +0100 (Sat, 03 Jan 2009) | 2 lines

Remove useless string literal.
........
r68196 | georg.brandl | 2009-01-03 15:29:53 +0100 (Sat, 03 Jan 2009) | 2 lines

Fix indentation.
........
r68210 | georg.brandl | 2009-01-03 20:10:12 +0100 (Sat, 03 Jan 2009) | 2 lines

Set eol-style correctly for mp_distributing.py.
........
r68214 | georg.brandl | 2009-01-03 20:44:48 +0100 (Sat, 03 Jan 2009) | 2 lines

Make indentation consistent.
........
r68215 | georg.brandl | 2009-01-03 21:15:14 +0100 (Sat, 03 Jan 2009) | 2 lines

Fix role name.
........
r68217 | georg.brandl | 2009-01-03 21:30:15 +0100 (Sat, 03 Jan 2009) | 2 lines

Add rstlint, a little tool to find subtle markup problems and inconsistencies in the Doc sources.
........
r68218 | georg.brandl | 2009-01-03 21:38:59 +0100 (Sat, 03 Jan 2009) | 2 lines

Recognize usage of the default role.
........
r68219 | georg.brandl | 2009-01-03 21:47:01 +0100 (Sat, 03 Jan 2009) | 2 lines

Fix uses of the default role.
........
r68220 | georg.brandl | 2009-01-03 21:55:06 +0100 (Sat, 03 Jan 2009) | 2 lines

Remove trailing whitespace.
........
r68221 | georg.brandl | 2009-01-03 22:04:55 +0100 (Sat, 03 Jan 2009) | 2 lines

Remove tabs from the documentation.
........
r68222 | georg.brandl | 2009-01-03 22:11:58 +0100 (Sat, 03 Jan 2009) | 2 lines

Disable the line length checker by default.
........

  • Participants
  • Parent commits a92f71d
  • Branches 2.6

Comments (0)

Files changed (186)

File Doc/ACKS.txt

    * Peter Funk
    * Lele Gaifax
    * Matthew Gallagher
+   * Gabriel Genellina
    * Ben Gertzfield
    * Nadim Ghaznavi
    * Jonathan Giddy

File Doc/Makefile

 ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
                 $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
 
-.PHONY: help checkout update build html htmlhelp clean coverage dist
+.PHONY: help checkout update build html htmlhelp clean coverage dist check
 
 help:
 	@echo "Please use \`make <target>' where <target> is one of"
 	cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
 	cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
 
+check:
+	$(PYTHON) tools/rstlint.py -i tools

File Doc/c-api/arg.rst

    :ctype:`Py_ssize_t` rather than an int.
 
 ``s*`` (string, Unicode, or any buffer compatible object) [Py_buffer \*]
-  Similar to ``s#``, this code fills a Py_buffer structure provided by the caller.
-  The buffer gets locked, so that the caller can subsequently use the buffer even
-  inside a ``Py_BEGIN_ALLOW_THREADS`` block; the caller is responsible for calling
-  ``PyBuffer_Release`` with the structure after it has processed the data.
+   Similar to ``s#``, this code fills a Py_buffer structure provided by the caller.
+   The buffer gets locked, so that the caller can subsequently use the buffer even
+   inside a ``Py_BEGIN_ALLOW_THREADS`` block; the caller is responsible for calling
+   ``PyBuffer_Release`` with the structure after it has processed the data.
 
-  .. versionadded:: 2.6
+   .. versionadded:: 2.6
 
 ``z`` (string or ``None``) [const char \*]
    Like ``s``, but the Python object may also be ``None``, in which case the C
 ``z*`` (string or ``None`` or any buffer compatible object) [Py_buffer*]
    This is to ``s*`` as ``z`` is to ``s``.
 
-  .. versionadded:: 2.6
+   .. versionadded:: 2.6
 
 ``u`` (Unicode object) [Py_UNICODE \*]
    Convert a Python Unicode object to a C pointer to a NUL-terminated buffer of
 
 ``w*`` (read-write byte-oriented buffer) [Py_buffer \*]
    This is to ``w`` what ``s*`` is to ``s``.
+
    .. versionadded:: 2.6
 
 ``(items)`` (tuple) [*matching-items*]

File Doc/c-api/buffer.rst

 
 .. index:: single: PyBufferProcs
 
-More information on the buffer interface is provided in the section 
+More information on the buffer interface is provided in the section
 :ref:`buffer-structs`, under the description for :ctype:`PyBufferProcs`.
 
 A "buffer object" is defined in the :file:`bufferobject.h` header (included by

File Doc/c-api/conversion.rst

 
    .. versionadded:: 2.4
 
- 
+
 .. cfunction:: double PyOS_ascii_atof(const char *nptr)
 
    Convert a string to a :ctype:`double` in a locale-independent way.
 
    See the Unix man page :manpage:`atof(2)` for details.
 
-   
+
 .. cfunction:: char * PyOS_stricmp(char *s1, char *s2)
 
    Case insensitive comparison of strings. The function works almost

File Doc/c-api/file.rst

    Return the file object associated with *p* as a :ctype:`FILE\*`.
 
    If the caller will ever use the returned :ctype:`FILE\*` object while
-   the GIL is released it must also call the `PyFile_IncUseCount` and
-   `PyFile_DecUseCount` functions described below as appropriate.
+   the GIL is released it must also call the :cfunc:`PyFile_IncUseCount` and
+   :cfunc:`PyFile_DecUseCount` functions described below as appropriate.
 
 
 .. cfunction:: void PyFile_IncUseCount(PyFileObject \*p)
    Increments the PyFileObject's internal use count to indicate
    that the underlying :ctype:`FILE\*` is being used.
    This prevents Python from calling f_close() on it from another thread.
-   Callers of this must call `PyFile_DecUseCount` when they are
+   Callers of this must call :cfunc:`PyFile_DecUseCount` when they are
    finished with the :ctype:`FILE\*`.  Otherwise the file object will
    never be closed by Python.
 
    The GIL must be held while calling this function.
 
-   The suggested use is to call this after `PyFile_AsFile` just before
+   The suggested use is to call this after :cfunc:`PyFile_AsFile` just before
    you release the GIL.
 
    .. versionadded:: 2.6
 
    Decrements the PyFileObject's internal unlocked_count member to
    indicate that the caller is done with its own use of the :ctype:`FILE\*`.
-   This may only be called to undo a prior call to `PyFile_IncUseCount`.
+   This may only be called to undo a prior call to :cfunc:`PyFile_IncUseCount`.
 
    The GIL must be held while calling this function.
 

File Doc/c-api/init.rst

 
    Return a tuple of function call counts.  There are constants defined for the
    positions within the tuple:
-   
+
    +-------------------------------+-------+
    | Name                          | Value |
    +===============================+=======+
    +-------------------------------+-------+
    | :const:`PCALL_POP`            | 10    |
    +-------------------------------+-------+
-   
+
    :const:`PCALL_FAST_FUNCTION` means no argument tuple needs to be created.
    :const:`PCALL_FASTER_FUNCTION` means that the fast-path frame setup code is used.
 

File Doc/c-api/long.rst

 
    Return a C :ctype:`long` representation of the contents of *pylong*.  If
    *pylong* is greater than :const:`LONG_MAX`, an :exc:`OverflowError` is raised
-   and ``-1`` will be returned. 
+   and ``-1`` will be returned.
 
 
 .. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)

File Doc/c-api/module.rst

 
 .. cfunction:: int PyModule_AddIntMacro(PyObject *module, macro)
 
-   Add an int constant to *module*. The name and the value are taken from 
+   Add an int constant to *module*. The name and the value are taken from
    *macro*. For example ``PyModule_AddConstant(module, AF_INET)`` adds the int
    constant *AF_INET* with the value of *AF_INET* to *module*.
    Return ``-1`` on error, ``0`` on success.

File Doc/c-api/reflection.rst

 
    Return a dictionary of the local variables in the current execution frame,
    or *NULL* if no frame is currently executing.
-   
+
 
 .. cfunction:: PyObject* PyEval_GetGlobals()
 

File Doc/c-api/sequence.rst

 
    Return the underlying array of PyObject pointers.  Assumes that *o* was returned
    by :cfunc:`PySequence_Fast` and *o* is not *NULL*.
-   
+
    Note, if a list gets resized, the reallocation may relocate the items array.
-   So, only use the underlying array pointer in contexts where the sequence 
+   So, only use the underlying array pointer in contexts where the sequence
    cannot change.
 
    .. versionadded:: 2.4

File Doc/c-api/set.rst

 
    .. versionchanged:: 2.6
       Now guaranteed to return a brand-new :class:`frozenset`.  Formerly,
-      frozensets of zero-length were a singleton.  This got in the way of 
+      frozensets of zero-length were a singleton.  This got in the way of
       building-up new frozensets with :meth:`PySet_Add`.
 
 The following functions and macros are available for instances of :class:`set`

File Doc/c-api/structures.rst

    .. versionadded:: 2.4
 
 
+.. ctype:: PyMemberDef
+
+   Structure which describes an attribute of a type which corresponds to a C
+   struct member.  It's fields are:
+
+   +------------------+-------------+-------------------------------+
+   | Field            | C Type      | Meaning                       |
+   +==================+=============+===============================+
+   | :attr:`name`     | char \*     | name of the member            |
+   +------------------+-------------+-------------------------------+
+   | :attr:`type`     | int         | the type of the member in the |
+   |                  |             | C struct                      |
+   +------------------+-------------+-------------------------------+
+   | :attr:`offset`   | Py_ssize_t  | the offset in bytes that the  |
+   |                  |             | member is located on the      |
+   |                  |             | type's object struct          |
+   +------------------+-------------+-------------------------------+
+   | :attr:`flags`    | int         | flag bits indicating if the   |
+   |                  |             | field should be read-only or  |
+   |                  |             | writable                      |
+   +------------------+-------------+-------------------------------+
+   | :attr:`doc`      | char \*     | points to the contents of the |
+   |                  |             | docstring                     |
+   +------------------+-------------+-------------------------------+
+
+   :attr:`type` can be one of many ``T_`` macros corresponding to various C
+   types.  When the member is accessed in Python, it will be converted to the
+   equivalent Python type.
+
+   =============== ==================
+   Macro name      C type
+   =============== ==================
+   T_SHORT         short
+   T_INT           int
+   T_LONG          long
+   T_FLOAT         float
+   T_DOUBLE        double
+   T_STRING        char \*
+   T_OBJECT        PyObject \*
+   T_OBJECT_EX     PyObject \*
+   T_CHAR          char
+   T_BYTE          char
+   T_UNBYTE        unsigned char
+   T_UINT          unsigned int
+   T_USHORT        unsigned short
+   T_ULONG         unsigned long
+   T_BOOL          char
+   T_LONGLONG      long long
+   T_ULONGLONG     unsigned long long
+   T_PYSSIZET      Py_ssize_t
+   =============== ==================
+
+   :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX` differ in that
+   :cmacro:`T_OBJECT` returns ``None`` if the member is *NULL* and
+   :cmacro:`T_OBJECT_EX` raises an :exc:`AttributeError`.
+
+   :attr:`flags` can be 0 for write and read access or :cmacro:`READONLY` for
+   read-only access.  Using :cmacro:`T_STRING` for :attr:`type` implies
+   :cmacro:`READONLY`.  Only :cmacro:`T_OBJECT` and :cmacro:`T_OBJECT_EX` can be
+   deleted.  (They are set to *NULL*).
+
+
+
 .. cfunction:: PyObject* Py_FindMethod(PyMethodDef table[], PyObject *ob, char *name)
 
    Return a bound method object for an extension type implemented in C.  This can

File Doc/distutils/apiref.rst

    | *package_dir*      | A mapping of package to        | a dictionary                                                |
    |                    | directory names                |                                                             |
    +--------------------+--------------------------------+-------------------------------------------------------------+
-   
+
 
 
 .. function:: run_setup(script_name[, script_args=None, stop_after='run'])
    |                        | for C/C++ header files (in     |                           |
    |                        | Unix form for portability)     |                           |
    +------------------------+--------------------------------+---------------------------+
-   | *define_macros*        | list of macros to define; each | (string,string)  tuple or |
-   |                        | macro is defined using a       | (name,``None``)           |
-   |                        | 2-tuple, where 'value' is      |                           |
+   | *define_macros*        | list of macros to define; each | (string, string) tuple or |
+   |                        | macro is defined using a       | (name, ``None``)          |
+   |                        | 2-tuple ``(name, value)``,     |                           |
+   |                        | where *value* is               |                           |
    |                        | either the string to define it |                           |
    |                        | to or ``None`` to define it    |                           |
    |                        | without a particular value     |                           |
       standard output, otherwise do nothing.
 
 .. % \subsection{Compiler-specific modules}
-.. % 
+.. %
 .. % The following modules implement concrete subclasses of the abstract
 .. % \class{CCompiler} class. They should not be instantiated directly, but should
 .. % be created using \function{distutils.ccompiler.new_compiler()} factory
 Macintosh. Needs work to support CW on Windows or Mac OS X.
 
 .. % \subsection{Utility modules}
-.. % 
+.. %
 .. % The following modules all provide general utility functions. They haven't
 .. % all been documented yet.
 
 
    For MacOS X systems the OS version reflects the minimal version on which
    binaries will run (that is, the value of ``MACOSX_DEPLOYMENT_TARGET``
-   during the build of Python), not the OS version of the current system. 
+   during the build of Python), not the OS version of the current system.
 
    For universal binary builds on MacOS X the architecture value reflects
    the univeral binary status instead of the architecture of the current
-   processor. For 32-bit universal binaries the architecture is ``fat``, 
-   for 64-bit universal binaries the architecture is ``fat64``, and 
-   for 4-way universal binaries the architecture is ``universal``. 
+   processor. For 32-bit universal binaries the architecture is ``fat``,
+   for 64-bit universal binaries the architecture is ``fat64``, and
+   for 4-way universal binaries the architecture is ``universal``.
 
    Examples of returned values on MacOS X:
 
 
 .. % todo
 .. % \section{Distutils Commands}
-.. % 
+.. %
 .. % This part of Distutils implements the various Distutils commands, such
 .. % as \code{build}, \code{install} \&c. Each command is implemented as a
 .. % separate module, with the command name as the name of the module.

File Doc/distutils/builtdist.rst

 .. % \longprogramopt{spec-file} option; used in conjunction with
 .. % \longprogramopt{spec-only}, this gives you an opportunity to customize
 .. % the \file{.spec} file manually:
-.. % 
+.. %
 .. % \ begin{verbatim}
 .. % > python setup.py bdist_rpm --spec-only
 .. % # ...edit dist/FooBar-1.0.spec
 .. % > python setup.py bdist_rpm --spec-file=dist/FooBar-1.0.spec
 .. % \ end{verbatim}
-.. % 
+.. %
 .. % (Although a better way to do this is probably to override the standard
 .. % \command{bdist\_rpm} command with one that writes whatever else you want
 .. % to the \file{.spec} file.)
 Cross-compiling on Windows
 ==========================
 
-Starting with Python 2.6, distutils is capable of cross-compiling between 
-Windows platforms.  In practice, this means that with the correct tools 
+Starting with Python 2.6, distutils is capable of cross-compiling between
+Windows platforms.  In practice, this means that with the correct tools
 installed, you can use a 32bit version of Windows to create 64bit extensions
 and vice-versa.
 
-To build for an alternate platform, specify the :option:`--plat-name` option 
-to the build command.  Valid values are currently 'win32', 'win-amd64' and 
+To build for an alternate platform, specify the :option:`--plat-name` option
+to the build command.  Valid values are currently 'win32', 'win-amd64' and
 'win-ia64'.  For example, on a 32bit version of Windows, you could execute::
 
    python setup.py build --plat-name=win-amd64
 
-to build a 64bit version of your extension.  The Windows Installers also 
+to build a 64bit version of your extension.  The Windows Installers also
 support this option, so the command::
 
    python setup.py build --plat-name=win-amd64 bdist_wininst
 
 would create a 64bit installation executable on your 32bit version of Windows.
 
-To cross-compile, you must download the Python source code and cross-compile 
+To cross-compile, you must download the Python source code and cross-compile
 Python itself for the platform you are targetting - it is not possible from a
 binary installtion of Python (as the .lib etc file for other platforms are
-not included.)  In practice, this means the user of a 32 bit operating 
-system will need to use Visual Studio 2008 to open the 
-:file:`PCBuild/PCbuild.sln` solution in the Python source tree and build the 
-"x64" configuration of the 'pythoncore' project before cross-compiling 
+not included.)  In practice, this means the user of a 32 bit operating
+system will need to use Visual Studio 2008 to open the
+:file:`PCBuild/PCbuild.sln` solution in the Python source tree and build the
+"x64" configuration of the 'pythoncore' project before cross-compiling
 extensions is possible.
 
 Note that by default, Visual Studio 2008 does not install 64bit compilers or

File Doc/distutils/configfile.rst

      --include-dirs (-I)  list of directories to search for header files
      --define (-D)        C preprocessor macros to define
      --undef (-U)         C preprocessor macros to undefine
-     --swig-opts          list of SWIG command line options        
+     --swig-opts          list of SWIG command line options
    [...]
 
 Note that an option spelled :option:`--foo-bar` on the command-line  is spelled

File Doc/distutils/packageindex.rst

    index-servers =
      pypi
      other
- 
+
    [pypi]
    repository: <repository-url>
    username: <username>
 
    python setup.py register -r other
 
- 
+

File Doc/distutils/setupscript.rst

 this::
 
    setup(...,
-         ext_modules=[Extension('_foo', ['foo.i'], 
+         ext_modules=[Extension('_foo', ['foo.i'],
                                 swig_opts=['-modern', '-I../include'])],
          py_modules=['foo'],
         )

File Doc/distutils/uploading.rst

 be available for execution on the system :envvar:`PATH`.  You can also specify
 which key to use for signing using the :option:`--identity=*name*` option.
 
-Other :command:`upload` options include  :option:`--repository=*url*` 
-or :option:`--repository=*section*` where `url` is the url of the server
-and `section` the name of the section in :file:`$HOME/.pypirc`, and
+Other :command:`upload` options include :option:`--repository=<url>` or
+:option:`--repository=<section>` where *url* is the url of the server and
+*section* the name of the section in :file:`$HOME/.pypirc`, and
 :option:`--show-response` (which displays the full response text from the PyPI
 server for help in debugging upload problems).
 

File Doc/documenting/markup.rst

    curly braces to indicate a "variable" part, as in ``:file:``.
 
    If you don't need the "variable part" indication, use the standard
-   ````code```` instead.   
+   ````code```` instead.
 
 .. describe:: var
 
    Example::
 
       .. versionadded:: 2.5
-         The `spam` parameter.
+         The *spam* parameter.
 
    Note that there must be no blank line between the directive head and the
    explanation; this is to make these blocks visually continuous in the markup.
    Blank lines are not allowed within ``productionlist`` directive arguments.
 
    The definition can contain token names which are marked as interpreted text
-   (e.g. ``sum ::= `integer` "+" `integer```) -- this generates cross-references
+   (e.g. ``unaryneg ::= "-" `integer```) -- this generates cross-references
    to the productions of these tokens.
 
    Note that no further reST parsing is done in the production, so that you
    don't have to escape ``*`` or ``|`` characters.
 
 
-.. XXX describe optional first parameter 
+.. XXX describe optional first parameter
 
 The following is an example taken from the Python Reference Manual::
 

File Doc/extending/building.rst

 
 With this :file:`setup.py`, and a file :file:`demo.c`, running ::
 
-   python setup.py build 
+   python setup.py build
 
 will compile :file:`demo.c`, and produce an extension module named ``demo`` in
 the :file:`build` directory. Depending on the system, the module file will end

File Doc/extending/extending.rst

 :cfunc:`PyEval_CallObject`.  This function has two arguments, both pointers to
 arbitrary Python objects: the Python function, and the argument list.  The
 argument list must always be a tuple object, whose length is the number of
-arguments.  To call the Python function with no arguments, pass in NULL, or 
+arguments.  To call the Python function with no arguments, pass in NULL, or
 an empty tuple; to call it with one argument, pass a singleton tuple.
 :cfunc:`Py_BuildValue` returns a tuple when its format string consists of zero
 or more format codes between parentheses.  For example::
    if (result == NULL)
        return NULL; /* Pass error back */
    ...use result...
-   Py_DECREF(result); 
+   Py_DECREF(result);
 
 Depending on the desired interface to the Python callback function, you may also
 have to provide an argument list to :cfunc:`PyEval_CallObject`.  In some cases
 the error check!  Also note that strictly speaking this code is not complete:
 :cfunc:`Py_BuildValue` may run out of memory, and this should be checked.
 
-You may also call a function with keyword arguments by using 
+You may also call a function with keyword arguments by using
 :cfunc:`PyEval_CallObjectWithKeywords`.  As in the above example, we use
 :cfunc:`Py_BuildValue` to construct the dictionary. ::
 
 
    static PyObject *
    keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds)
-   {  
+   {
        int voltage;
        char *state = "a stiff";
        char *action = "voom";
 
        static char *kwlist[] = {"voltage", "state", "action", "type", NULL};
 
-       if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|sss", kwlist, 
+       if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|sss", kwlist,
                                         &voltage, &state, &action, &type))
-           return NULL; 
+           return NULL;
 
-       printf("-- This parrot wouldn't %s if you put %i Volts through it.\n", 
+       printf("-- This parrot wouldn't %s if you put %i Volts through it.\n",
               action, voltage);
        printf("-- Lovely plumage, the %s -- It's %s!\n", type, state);
 

File Doc/extending/newtypes.rst

 previous sections. We will break down the main differences between them. ::
 
    typedef struct {
-   	PyListObject list;
-   	int state;
+       PyListObject list;
+       int state;
    } Shoddy;
 
 The primary difference for derived type objects is that the base type's object
    static int
    Shoddy_init(Shoddy *self, PyObject *args, PyObject *kwds)
    {
-   	if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0)
-   		return -1;
-   	self->state = 0;
-   	return 0;
+       if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0)
+          return -1;
+       self->state = 0;
+       return 0;
    }
 
 In the :attr:`__init__` method for our type, we can see how to call through to
    PyMODINIT_FUNC
    initshoddy(void)
    {
-   	PyObject *m;
+       PyObject *m;
 
-   	ShoddyType.tp_base = &PyList_Type;
-   	if (PyType_Ready(&ShoddyType) < 0)
-   		return;
+       ShoddyType.tp_base = &PyList_Type;
+       if (PyType_Ready(&ShoddyType) < 0)
+           return;
 
-   	m = Py_InitModule3("shoddy", NULL, "Shoddy module");
-   	if (m == NULL)
-   		return;
+       m = Py_InitModule3("shoddy", NULL, "Shoddy module");
+       if (m == NULL)
+           return;
 
-   	Py_INCREF(&ShoddyType);
-   	PyModule_AddObject(m, "Shoddy", (PyObject *) &ShoddyType);
+       Py_INCREF(&ShoddyType);
+       PyModule_AddObject(m, "Shoddy", (PyObject *) &ShoddyType);
    }
 
 Before calling :cfunc:`PyType_Ready`, the type structure must have the
    typedef struct PyMethodDef {
        char        *ml_name;       /* method name */
        PyCFunction  ml_meth;       /* implementation function */
-       int	         ml_flags;      /* flags */
+       int          ml_flags;      /* flags */
        char        *ml_doc;        /* docstring */
    } PyMethodDef;
 
 of *NULL* is required.
 
 .. XXX Descriptors need to be explained in more detail somewhere, but not here.
-   
+
    Descriptor objects have two handler functions which correspond to the
    \member{tp_getattro} and \member{tp_setattro} handlers.  The
    \method{__get__()} handler is a function which is passed the descriptor,

File Doc/extending/windows.rst

    and it should call :cfunc:`Py_InitModule` with the string ``"spam"`` as its
    first argument (use the minimal :file:`example.c` in this directory as a guide).
    By convention, it lives in a file called :file:`spam.c` or :file:`spammodule.c`.
-   The output file should be called :file:`spam.pyd` (in Release mode) or  
+   The output file should be called :file:`spam.pyd` (in Release mode) or
    :file:`spam_d.pyd` (in Debug mode). The extension :file:`.pyd` was chosen
    to avoid confusion with a system library :file:`spam.dll` to which your module
    could be a Python interface.

File Doc/glossary.rst

    ``>>>``
       The default Python prompt of the interactive shell.  Often seen for code
       examples which can be executed interactively in the interpreter.
-    
+
    ``...``
       The default Python prompt of the interactive shell when entering code for
       an indented code block or within a pair of matching left and right
       A value associated with an object which is referenced by name using
       dotted expressions.  For example, if an object *o* has an attribute
       *a* it would be referenced as *o.a*.
-    
+
    BDFL
       Benevolent Dictator For Life, a.k.a. `Guido van Rossum
       <http://www.python.org/~guido/>`_, Python's creator.
-    
+
    bytecode
       Python source code is compiled into bytecode, the internal representation
       of a Python program in the interpreter.  The bytecode is also cached in
       A template for creating user-defined objects. Class definitions
       normally contain method definitions which operate on instances of the
       class.
-    
+
    classic class
       Any class which does not inherit from :class:`object`.  See
       :term:`new-style class`.  Classic classes will be removed in Python 3.0.
-    
+
    coercion
       The implicit conversion of an instance of one type to another during an
       operation which involves two arguments of the same type.  For example,
       ``operator.add(3.0, 4.5)``.  Without coercion, all arguments of even
       compatible types would have to be normalized to the same value by the
       programmer, e.g., ``float(3)+4.5`` rather than just ``3+4.5``.
-    
+
    complex number
       An extension of the familiar real number system in which all numbers are
       expressed as a sum of a real part and an imaginary part.  Imaginary
       :mod:`math` module, use :mod:`cmath`.  Use of complex numbers is a fairly
       advanced mathematical feature.  If you're not aware of a need for them,
       it's almost certain you can safely ignore them.
-    
+
    context manager
       An object which controls the environment seen in a :keyword:`with`
       statement by defining :meth:`__enter__` and :meth:`__exit__` methods.
       class methods, static methods, and reference to super classes.
 
       For more information about descriptors' methods, see :ref:`descriptors`.
-    
+
    dictionary
       An associative array, where arbitrary keys are mapped to values.  The use
       of :class:`dict` closely resembles that for :class:`list`, but the keys can
       of the enclosing class, function or module.  Since it is available via
       introspection, it is the canonical place for documentation of the
       object.
-    
-   duck-typing 
+
+   duck-typing
       A pythonic programming style which determines an object's type by inspection
       of its method or attribute signature rather than by explicit relationship
       to some type object ("If it looks like a duck and quacks like a duck, it
       :func:`isinstance`. (Note, however, that duck-typing can be complemented
       with abstract base classes.) Instead, it typically employs :func:`hasattr`
       tests or :term:`EAFP` programming.
-    
+
    EAFP
       Easier to ask for forgiveness than permission.  This common Python coding
       style assumes the existence of valid keys or attributes and catches
       exceptions if the assumption proves false.  This clean and fast style is
       characterized by the presence of many :keyword:`try` and :keyword:`except`
-      statements.  The technique contrasts with the :term:`LBYL` style 
+      statements.  The technique contrasts with the :term:`LBYL` style
       common to many other languages such as C.
 
    expression
       which are not compatible with the current interpreter.  For example, the
       expression ``11/4`` currently evaluates to ``2``. If the module in which
       it is executed had enabled *true division* by executing::
-    
+
          from __future__ import division
-    
+
       the expression ``11/4`` would evaluate to ``2.75``.  By importing the
       :mod:`__future__` module and evaluating its variables, you can see when a
       new feature was first added to the language and when it will become the
       default::
-    
+
          >>> import __future__
          >>> __future__.division
          _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)
       The process of freeing memory when it is not used anymore.  Python
       performs garbage collection via reference counting and a cyclic garbage
       collector that is able to detect and break reference cycles.
-    
+
    generator
       A function which returns an iterator.  It looks like a normal function
       except that values are returned to the caller using a :keyword:`yield`
       stopped at the :keyword:`yield` keyword (returning the result) and is
       resumed there when the next element is requested by calling the
       :meth:`next` method of the returned iterator.
-    
+
       .. index:: single: generator expression
-    
+
    generator expression
       An expression that returns a generator.  It looks like a normal expression
       followed by a :keyword:`for` expression defining a loop variable, range,
       and an optional :keyword:`if` expression.  The combined expression
       generates values for an enclosing function::
-    
+
          >>> sum(i*i for i in range(10))         # sum of squares 0, 1, 4, ... 81
          285
-    
+
    GIL
       See :term:`global interpreter lock`.
-    
+
    global interpreter lock
       The lock used by Python threads to assure that only one thread
       executes in the :term:`CPython` :term:`virtual machine` at a time.
       containers (such as lists or dictionaries) are.  Objects which are
       instances of user-defined classes are hashable by default; they all
       compare unequal, and their hash value is their :func:`id`.
-    
+
    IDLE
       An Integrated Development Environment for Python.  IDLE is a basic editor
       and interpreter environment which ships with the standard distribution of
       Python.  Good for beginners, it also serves as clear example code for
       those wanting to implement a moderately sophisticated, multi-platform GUI
       application.
-    
+
    immutable
       An object with a fixed value.  Immutable objects include numbers, strings and
       tuples.  Such an object cannot be altered.  A new object has to
       be created if a different value has to be stored.  They play an important
       role in places where a constant hash value is needed, for example as a key
       in a dictionary.
-    
+
    integer division
       Mathematical division discarding any remainder.  For example, the
       expression ``11/4`` currently evaluates to ``2`` in contrast to the
       divided by a float will result in a float value, possibly with a decimal
       fraction.  Integer division can be forced by using the ``//`` operator
       instead of the ``/`` operator.  See also :term:`__future__`.
-    
+
    interactive
       Python has an interactive interpreter which means you can enter
       statements and expressions at the interpreter prompt, immediately
       arguments (possibly by selecting it from your computer's main
       menu). It is a very powerful way to test out new ideas or inspect
       modules and packages (remember ``help(x)``).
-    
+
    interpreted
       Python is an interpreted language, as opposed to a compiled one,
       though the distinction can be blurry because of the presence of the
       Interpreted languages typically have a shorter development/debug cycle
       than compiled ones, though their programs generally also run more
       slowly.  See also :term:`interactive`.
-    
+
    iterable
       A container object capable of returning its members one at a
       time. Examples of iterables include all sequence types (such as
       statement does that automatically for you, creating a temporary unnamed
       variable to hold the iterator for the duration of the loop.  See also
       :term:`iterator`, :term:`sequence`, and :term:`generator`.
-    
+
    iterator
       An object representing a stream of data.  Repeated calls to the iterator's
       :meth:`next` method return successive items in the stream.  When no more
       :func:`iter` function or use it in a :keyword:`for` loop.  Attempting this
       with an iterator will just return the same exhausted iterator object used
       in the previous iteration pass, making it appear like an empty container.
-    
+
       More information can be found in :ref:`typeiter`.
 
    keyword argument
       A built-in Python :term:`sequence`.  Despite its name it is more akin
       to an array in other languages than to a linked list since access to
       elements are O(1).
-    
+
    list comprehension
       A compact way to process all or part of the elements in a sequence and
       return a list with the results.  ``result = ["0x%02x" % x for x in
       even hex numbers (0x..) in the range from 0 to 255. The :keyword:`if`
       clause is optional.  If omitted, all elements in ``range(256)`` are
       processed.
-    
+
    mapping
       A container object (such as :class:`dict`) which supports arbitrary key
       lookups using the special method :meth:`__getitem__`.
-    
+
    metaclass
       The class of a class.  Class definitions create a class name, a class
       dictionary, and a list of base classes.  The metaclass is responsible for
       of an instance of that class, the method will get the instance object as
       its first :term:`argument` (which is usually called ``self``).
       See :term:`function` and :term:`nested scope`.
-    
+
    mutable
       Mutable objects can change their value but keep their :func:`id`.  See
       also :term:`immutable`.
       :func:`collections.namedtuple`.  The latter approach automatically
       provides extra features such as a self-documenting representation like
       ``Employee(name='jones', title='programmer')``.
-    
+
    namespace
       The place where a variable is stored.  Namespaces are implemented as
       dictionaries.  There are the local, global and builtin namespaces as well
       :func:`random.seed` or :func:`itertools.izip` makes it clear that those
       functions are implemented by the :mod:`random` and :mod:`itertools`
       modules, respectively.
-    
+
    nested scope
       The ability to refer to a variable in an enclosing definition.  For
       instance, a function defined inside another function can refer to
       reference and not for assignment which will always write to the innermost
       scope.  In contrast, local variables both read and write in the innermost
       scope.  Likewise, global variables read and write to the global namespace.
-    
+
    new-style class
       Any class which inherits from :class:`object`.  This includes all built-in
       types like :class:`list` and :class:`dict`.  Only new-style classes can
       Any data with state (attributes or value) and defined behavior
       (methods).  Also the ultimate base class of any :term:`new-style
       class`.
-    
+
    positional argument
       The arguments assigned to local names inside a function or method,
       determined by the order in which they were given in the call.  ``*`` is
       definition), or pass several arguments as a list to a function.  See
       :term:`argument`.
 
-   Python 3000 
+   Python 3000
       Nickname for the next major Python version, 3.0 (coined long ago
       when the release of version 3 was something in the distant future.)  This
       is also abbreviated "Py3k".
       to loop over all elements of an iterable using a :keyword:`for`
       statement.  Many other languages don't have this type of construct, so
       people unfamiliar with Python sometimes use a numerical counter instead::
-     
+
           for i in range(len(food)):
               print food[i]
 
       dictionaries.  Though popular, the technique is somewhat tricky to get
       right and is best reserved for rare cases where there are large numbers of
       instances in a memory-critical application.
-    
+
    sequence
       An :term:`iterable` which supports efficient element access using integer
       indices via the :meth:`__getitem__` special method and defines a
    virtual machine
       A computer defined entirely in software.  Python's virtual machine
       executes the :term:`bytecode` emitted by the bytecode compiler.
-    
+
    Zen of Python
       Listing of Python design principles and philosophies that are helpful in
       understanding and using the language.  The listing can be found by typing

File Doc/howto/curses.rst

 could code::
 
    stdscr.addstr(0, 0, "Current mode: Typing mode",
-   	      curses.A_REVERSE)
+                 curses.A_REVERSE)
    stdscr.refresh()
 
 The curses library also supports color on those terminals that provide it, The
 
    curses.echo()            # Enable echoing of characters
 
-   # Get a 15-character string, with the cursor on the top line 
-   s = stdscr.getstr(0,0, 15)  
+   # Get a 15-character string, with the cursor on the top line
+   s = stdscr.getstr(0,0, 15)
 
 The Python :mod:`curses.textpad` module supplies something better. With it, you
 can turn a window into a text box that supports an Emacs-like set of

File Doc/howto/doanddont.rst

 ************************************
-  Idioms and Anti-Idioms in Python  
+  Idioms and Anti-Idioms in Python
 ************************************
 
 :Author: Moshe Zadka
    # bar.py
    from foo import a
    if something():
-       a = 2 # danger: foo.a != a 
+       a = 2 # danger: foo.a != a
 
 Good example::
 
 
 This version is bulletproof::
 
-   value = (foo.bar()['first'][0]*baz.quux(1, 2)[5:9] 
+   value = (foo.bar()['first'][0]*baz.quux(1, 2)[5:9]
            + calculate_number(10, 20)*forbulate(500, 360))
 

File Doc/howto/functional.rst

 functions are also easier to read and to check for errors.
 
 
-Ease of debugging and testing 
+Ease of debugging and testing
 -----------------------------
 
 Testing and debugging a functional-style program is easier.
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
     StopIteration
-    >>>      
+    >>>
 
 Python expects iterable objects in several different contexts, the most
 important being the ``for`` statement.  In the statement ``for X in Y``, Y must
 comprehensions are surrounded by square brackets ("[]").  Generator expressions
 have the form::
 
-    ( expression for expr in sequence1 
+    ( expression for expr in sequence1
                  if condition1
                  for expr2 in sequence2
                  if condition2
                  if not (conditionN):
                      continue   # Skip this element
 
-                 # Output the value of 
+                 # Output the value of
                  # the expression.
 
 This means that when there are multiple ``for...in`` clauses but no ``if``
     >>> seq1 = 'abc'
     >>> seq2 = (1,2,3)
     >>> [(x,y) for x in seq1 for y in seq2]
-    [('a', 1), ('a', 2), ('a', 3), 
-     ('b', 1), ('b', 2), ('b', 3), 
+    [('a', 1), ('a', 2), ('a', 3),
+     ('b', 1), ('b', 2), ('b', 3),
      ('c', 1), ('c', 2), ('c', 3)]
 
 To avoid introducing an ambiguity into Python's grammar, if ``expression`` is
     9
     >>> print it.next()
     Traceback (most recent call last):
-      File ``t.py'', line 15, in ?
+      File "t.py", line 15, in ?
         print it.next()
     StopIteration
 
     True
     >>> all([0,1,0])
     False
-    >>> all([0,0,0]) 
+    >>> all([0,0,0])
     False
     >>> all([1,1,1])
     True
 4) Convert the lambda to a def statement, using that name.
 5) Remove the comment.
 
-I really like these rules, but you're free to disagree 
+I really like these rules, but you're free to disagree
 about whether this lambda-free style is better.
 
 
 ``itertools.starmap(func, iter)`` assumes that the iterable will return a stream
 of tuples, and calls ``f()`` using these tuples as the arguments::
 
-    itertools.starmap(os.path.join, 
+    itertools.starmap(os.path.join,
                       [('/usr', 'bin', 'java'), ('/bin', 'python'),
                        ('/usr', 'bin', 'perl'),('/usr', 'bin', 'ruby')])
     =>
 
 ::
 
-    city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'), 
+    city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'),
                  ('Anchorage', 'AK'), ('Nome', 'AK'),
-                 ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ'), 
+                 ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ'),
                  ...
                 ]
 
     where
     iterator-1 =>
       ('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL')
-    iterator-2 => 
+    iterator-2 =>
       ('Anchorage', 'AK'), ('Nome', 'AK')
     iterator-3 =>
       ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')
 
     >>> double(add(5, 6))
     22
-                    
+
 The ``unpack`` keyword is provided to work around the fact that Python functions
 are not always `fully curried <http://en.wikipedia.org/wiki/Currying>`__.  By
 default, it is expected that the ``inner`` function will return a single object
 will be expanded before being passed to ``outer``. Put simply, ::
 
     compose(f, g)(5, 6)
-                    
+
 is equivalent to::
 
     f(g(5, 6))
-                    
+
 while ::
 
     compose(f, g, unpack=True)(5, 6)
-                    
+
 is equivalent to::
 
     f(*g(5, 6))
 ``functional`` and ``functools``). ::
 
     from functional import compose, partial
-        
+
     multi_compose = partial(reduce, compose)
-        
-    
+
+
 We can also use ``map()``, ``compose()`` and ``partial()`` to craft a version of
 ``"".join(...)`` that converts its arguments to string::
 
     from functional import compose, partial
-        
+
     join = compose("".join, partial(map, str))
 
 
 ``flip(func)``
-                    
+
 ``flip()`` wraps the callable in ``func`` and causes it to receive its
 non-keyword arguments in reverse order. ::
 
     (7, 6, 5)
 
 ``foldl(func, start, iterable)``
-                    
+
 ``foldl()`` takes a binary function, a starting value (usually some kind of
 'zero'), and an iterable.  The function is applied to the starting value and the
 first element of the list, then the result of that and the second element of the
 
     f(f(f(0, 1), 2), 3)
 
-    
+
 ``foldl()`` is roughly equivalent to the following recursive function::
 
     def foldl(func, start, seq):
 Text Processing".
 
 Mertz also wrote a 3-part series of articles on functional programming
-for IBM's DeveloperWorks site; see 
+for IBM's DeveloperWorks site; see
 `part 1 <http://www-128.ibm.com/developerworks/library/l-prog.html>`__,
 `part 2 <http://www-128.ibm.com/developerworks/library/l-prog2.html>`__, and
 `part 3 <http://www-128.ibm.com/developerworks/linux/library/l-prog3.html>`__,

File Doc/howto/regex.rst

 .. _regex-howto:
 
 ****************************
-  Regular Expression HOWTO  
+  Regular Expression HOWTO
 ****************************
 
 :Author: A.M. Kuchling
    is to read? ::
 
       charref = re.compile(r"""
-       &[#]		     # Start of a numeric entity reference
+       &[#]                # Start of a numeric entity reference
        (
            0[0-7]+         # Octal form
          | [0-9]+          # Decimal form
       >>> p = re.compile('\bclass\b')
       >>> print p.search('no class at all')
       None
-      >>> print p.search('\b' + 'class' + '\b')  
+      >>> print p.search('\b' + 'class' + '\b')
       <re.MatchObject instance at 80c3ee0>
 
    Second, inside a character class, where there's no use for this assertion,
 
    InternalDate = re.compile(r'INTERNALDATE "'
            r'(?P<day>[ 123][0-9])-(?P<mon>[A-Z][a-z][a-z])-'
-   	r'(?P<year>[0-9][0-9][0-9][0-9])'
+           r'(?P<year>[0-9][0-9][0-9][0-9])'
            r' (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9])'
            r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
            r'"')
 only report a successful match which will start at 0; if the match wouldn't
 start at zero,  :func:`match` will *not* report it. ::
 
-   >>> print re.match('super', 'superstition').span()  
+   >>> print re.match('super', 'superstition').span()
    (0, 5)
-   >>> print re.match('super', 'insuperable')    
+   >>> print re.match('super', 'insuperable')
    None
 
 On the other hand, :func:`search` will scan forward through the string,

File Doc/howto/sockets.rst

 ****************************
-  Socket Programming HOWTO  
+  Socket Programming HOWTO
 ****************************
 
 :Author: Gordon McMillan
    #create an INET, STREAMing socket
    s = socket.socket(
        socket.AF_INET, socket.SOCK_STREAM)
-   #now connect to the web server on port 80 
+   #now connect to the web server on port 80
    # - the normal http port
    s.connect(("www.mcmillan-inc.com", 80))
 
    #create an INET, STREAMing socket
    serversocket = socket.socket(
        socket.AF_INET, socket.SOCK_STREAM)
-   #bind the socket to a public host, 
+   #bind the socket to a public host,
    # and a well-known port
    serversocket.bind((socket.gethostname(), 80))
    #become a server socket
 length message::
 
    class mysocket:
-       '''demonstration class only 
+       '''demonstration class only
          - coded for clarity, not efficiency
        '''
 
        def __init__(self, sock=None):
-   	if sock is None:
-   	    self.sock = socket.socket(
-   		socket.AF_INET, socket.SOCK_STREAM)
-   	else:
-   	    self.sock = sock
+           if sock is None:
+               self.sock = socket.socket(
+                   socket.AF_INET, socket.SOCK_STREAM)
+           else:
+               self.sock = sock
 
        def connect(self, host, port):
-   	self.sock.connect((host, port))
+           self.sock.connect((host, port))
 
        def mysend(self, msg):
-   	totalsent = 0
-   	while totalsent < MSGLEN:
-   	    sent = self.sock.send(msg[totalsent:])
-   	    if sent == 0:
-   		raise RuntimeError, \
-   		    "socket connection broken"
-   	    totalsent = totalsent + sent
+           totalsent = 0
+           while totalsent < MSGLEN:
+               sent = self.sock.send(msg[totalsent:])
+               if sent == 0:
+                   raise RuntimeError, \
+                       "socket connection broken"
+               totalsent = totalsent + sent
 
        def myreceive(self):
-   	msg = ''
-   	while len(msg) < MSGLEN:
-   	    chunk = self.sock.recv(MSGLEN-len(msg))
-   	    if chunk == '':
-   		raise RuntimeError, \
-   		    "socket connection broken"
-   	    msg = msg + chunk
-   	return msg
+           msg = ''
+           while len(msg) < MSGLEN:
+               chunk = self.sock.recv(MSGLEN-len(msg))
+               if chunk == '':
+                   raise RuntimeError, \
+                       "socket connection broken"
+               msg = msg + chunk
+           return msg
 
 The sending code here is usable for almost any messaging scheme - in Python you
 send strings, and you can use ``len()`` to determine its length (even if it has
 
    ready_to_read, ready_to_write, in_error = \
                   select.select(
-                     potential_readers, 
-                     potential_writers, 
-                     potential_errs, 
+                     potential_readers,
+                     potential_writers,
+                     potential_errs,
                      timeout)
 
 You pass ``select`` three lists: the first contains all sockets that you might

File Doc/howto/unicode.rst

 looking at Apple ][ BASIC programs, published in French-language publications in
 the mid-1980s, that had lines like these::
 
-	PRINT "FICHIER EST COMPLETE."
-	PRINT "CARACTERE NON ACCEPTE."
+   PRINT "FICHIER EST COMPLETE."
+   PRINT "CARACTERE NON ACCEPTE."
 
 Those messages should contain accents, and they just look wrong to someone who
 can read French.
 character with value 0x12ca (4810 decimal).  The Unicode standard contains a lot
 of tables listing characters and their corresponding code points::
 
-	0061    'a'; LATIN SMALL LETTER A
-	0062    'b'; LATIN SMALL LETTER B
-	0063    'c'; LATIN SMALL LETTER C
-        ...
-	007B	'{'; LEFT CURLY BRACKET
+   0061    'a'; LATIN SMALL LETTER A
+   0062    'b'; LATIN SMALL LETTER B
+   0063    'c'; LATIN SMALL LETTER C
+   ...
+   007B    '{'; LEFT CURLY BRACKET
 
 Strictly, these definitions imply that it's meaningless to say 'this is
 character U+12ca'.  U+12ca is a code point, which represents some particular
 representation, the string "Python" would look like this::
 
        P           y           t           h           o           n
-    0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00 
-       0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 
+    0x50 00 00 00 79 00 00 00 74 00 00 00 68 00 00 00 6f 00 00 00 6e 00 00 00
+       0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 
 This representation is straightforward but using it presents a number of
 problems.
    between 128 and 255.
 3. Code points >0x7ff are turned into three- or four-byte sequences, where each
    byte of the sequence is between 128 and 255.
-    
+
 UTF-8 has several convenient properties:
 
 1. It can handle any Unicode code point.
     >>> unicode('abcdef' + chr(255))
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
-    UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 6: 
+    UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 6:
                         ordinal not in range(128)
 
 The ``errors`` argument specifies the response when the input string can't be
     >>> unicode('\x80abc', errors='strict')
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
-    UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0: 
+    UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 0:
                         ordinal not in range(128)
     >>> unicode('\x80abc', errors='replace')
     u'\ufffdabc'
     >>> u2 = utf8_version.decode('utf-8')            # Decode using UTF-8
     >>> u == u2                                      # The two strings match
     True
- 
+
 The low-level routines for registering and accessing the available encodings are
 found in the :mod:`codecs` module.  However, the encoding and decoding functions
 returned by this module are usually more low-level than is comfortable, so I'm
 The most commonly used part of the :mod:`codecs` module is the
 :func:`codecs.open` function which will be discussed in the section on input and
 output.
-            
-            
+
+
 Unicode Literals in Python Source Code
 --------------------------------------
 
 
     >>> s = u"a\xac\u1234\u20ac\U00008000"
                ^^^^ two-digit hex escape
-                   ^^^^^^ four-digit Unicode escape 
+                   ^^^^^^ four-digit Unicode escape
                                ^^^^^^^^^^ eight-digit Unicode escape
     >>> for c in s:  print ord(c),
-    ... 
+    ...
     97 172 4660 8364 32768
 
 Using escape sequences for code points greater than 127 is fine in small doses,
 
     #!/usr/bin/env python
     # -*- coding: latin-1 -*-
-    
+
     u = u'abcdé'
     print ord(u[-1])
-    
+
 The syntax is inspired by Emacs's notation for specifying variables local to a
 file.  Emacs supports many different variables, but Python only supports
 'coding'.  The ``-*-`` symbols indicate to Emacs that the comment is special;
 When you run it with Python 2.4, it will output the following warning::
 
     amk:~$ python p263.py
-    sys:1: DeprecationWarning: Non-ASCII character '\xe9' 
-         in file p263.py on line 2, but no encoding declared; 
+    sys:1: DeprecationWarning: Non-ASCII character '\xe9'
+         in file p263.py on line 2, but no encoding declared;
          see http://www.python.org/peps/pep-0263.html for details
-  
+
 
 Unicode Properties
 ------------------
 prints the numeric value of one particular character::
 
     import unicodedata
-    
+
     u = unichr(233) + unichr(0x0bf2) + unichr(3972) + unichr(6000) + unichr(13231)
-    
+
     for i, c in enumerate(u):
         print i, '%04x' % ord(c), unicodedata.category(c),
         print unicodedata.name(c)
-    
+
     # Get numeric value of second character
     print unicodedata.numeric(u[1])
 
 path will return the 8-bit versions of the filenames.  For example, assuming the
 default filesystem encoding is UTF-8, running the following program::
 
-	fn = u'filename\u4500abc'
-	f = open(fn, 'w')
-	f.close()
+   fn = u'filename\u4500abc'
+   f = open(fn, 'w')
+   f.close()
 
-	import os
-	print os.listdir('.')
-	print os.listdir(u'.')
+   import os
+   print os.listdir('.')
+   print os.listdir(u'.')
 
 will produce the following output::
 
-	amk:~$ python t.py
-	['.svn', 'filename\xe4\x94\x80abc', ...]
-	[u'.svn', u'filename\u4500abc', ...]
+   amk:~$ python t.py
+   ['.svn', 'filename\xe4\x94\x80abc', ...]
+   [u'.svn', u'filename\u4500abc', ...]
 
 The first list contains UTF-8-encoded filenames, and the second list contains
 the Unicode versions.
 
 
-	
+
 Tips for Writing Unicode-aware Programs
 ---------------------------------------
 
         unicode_name = filename.decode(encoding)
         f = open(unicode_name, 'r')
         # ... return contents of file ...
-        
+
 However, if an attacker could specify the ``'base64'`` encoding, they could pass
 ``'L2V0Yy9wYXNzd2Q='``, which is the base-64 encoded form of the string
 ``'/etc/passwd'``, to read a system file.  The above code looks for ``'/'``
 .. comment Describe obscure -U switch somewhere?
 .. comment Describe use of codecs.StreamRecoder and StreamReaderWriter
 
-.. comment 
+.. comment
    Original outline:
 
    - [ ] Unicode introduction
        - [ ] ASCII
        - [ ] Terms
-	   - [ ] Character
-	   - [ ] Code point
-	 - [ ] Encodings
-	    - [ ] Common encodings: ASCII, Latin-1, UTF-8
+           - [ ] Character
+           - [ ] Code point
+         - [ ] Encodings
+            - [ ] Common encodings: ASCII, Latin-1, UTF-8
        - [ ] Unicode Python type
-	   - [ ] Writing unicode literals
-	       - [ ] Obscurity: -U switch
-	   - [ ] Built-ins
-	       - [ ] unichr()
-	       - [ ] ord()
-	       - [ ] unicode() constructor
-	   - [ ] Unicode type
-	       - [ ] encode(), decode() methods
+           - [ ] Writing unicode literals
+               - [ ] Obscurity: -U switch
+           - [ ] Built-ins
+               - [ ] unichr()
+               - [ ] ord()
+               - [ ] unicode() constructor
+           - [ ] Unicode type
+               - [ ] encode(), decode() methods
        - [ ] Unicodedata module for character properties
        - [ ] I/O
-	   - [ ] Reading/writing Unicode data into files
-	       - [ ] Byte-order marks
-	   - [ ] Unicode filenames
+           - [ ] Reading/writing Unicode data into files
+               - [ ] Byte-order marks
+           - [ ] Unicode filenames
        - [ ] Writing Unicode programs
-	   - [ ] Do everything in Unicode
-	   - [ ] Declaring source code encodings (PEP 263)
+           - [ ] Do everything in Unicode
+           - [ ] Declaring source code encodings (PEP 263)
        - [ ] Other issues
-	   - [ ] Building Python (UCS2, UCS4)
+           - [ ] Building Python (UCS2, UCS4)

File Doc/howto/urllib2.rst

     HOWTO, available at `urllib2 - Le Manuel manquant
     <http://www.voidspace.org.uk/python/articles/urllib2_francais.shtml>`_.
 
- 
+
 
 Introduction
 ============
 
     You may also find useful the following article on fetching web resources
     with Python :
-    
+
     * `Basic Authentication <http://www.voidspace.org.uk/python/articles/authentication.shtml>`_
-    
+
         A tutorial on *Basic Authentication*, with examples in Python.
 
 **urllib2** is a `Python <http://www.python.org>`_ module for fetching URLs
 *not* from ``urllib2``. ::
 
     import urllib
-    import urllib2  
+    import urllib2
 
     url = 'http://www.someserver.com/cgi-bin/register.cgi'
     values = {'name' : 'Michael Foord',
 Explorer [#]_. ::
 
     import urllib
-    import urllib2  
-    
+    import urllib2
+
     url = 'http://www.someserver.com/cgi-bin/register.cgi'
-    user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' 
+    user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
     values = {'name' : 'Michael Foord',
               'location' : 'Northampton',
               'language' : 'Python' }
     headers = { 'User-Agent' : user_agent }
-    
+
     data = urllib.urlencode(values)
     req = urllib2.Request(url, data, headers)
     response = urllib2.urlopen(req)
 ===================
 
 *urlopen* raises :exc:`URLError` when it cannot handle a response (though as usual
-with Python APIs, builtin exceptions such as 
+with Python APIs, builtin exceptions such as
 :exc:`ValueError`, :exc:`TypeError` etc. may also
 be raised).
 
 geturl, and info, methods. ::
 
     >>> req = urllib2.Request('http://www.python.org/fish.html')
-    >>> try: 
+    >>> try:
     >>>     urllib2.urlopen(req)
     >>> except URLError, e:
     >>>     print e.code
     >>>     print e.read()
-    >>> 
+    >>>
     404
-    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
+    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
         "http://www.w3.org/TR/html4/loose.dtd">
-    <?xml-stylesheet href="./css/ht2html.css" 
+    <?xml-stylesheet href="./css/ht2html.css"
         type="text/css"?>
-    <html><head><title>Error 404: File Not Found</title> 
+    <html><head><title>Error 404: File Not Found</title>
     ...... etc...
 
 Wrapping it Up
             print 'Error code: ', e.code
     else:
         # everything is fine
-        
+
 
 info and geturl
 ===============
 and a 'realm'. The header looks like : ``Www-authenticate: SCHEME
 realm="REALM"``.
 
-e.g. :: 
+e.g. ::
 
     Www-authenticate: Basic realm="cPanel Users"
 
 than the URL you pass to .add_password() will also match. ::
 
     # create a password manager
-    password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()                        
+    password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
 
     # Add the username and password.
-    # If we knew the realm, we could use it instead of ``None``.
+    # If we knew the realm, we could use it instead of None.
     top_level_url = "http://example.com/foo/"
     password_mgr.add_password(None, top_level_url, username, password)
 
-    handler = urllib2.HTTPBasicAuthHandler(password_mgr)                            
+    handler = urllib2.HTTPBasicAuthHandler(password_mgr)
 
     # create "opener" (OpenerDirector instance)
-    opener = urllib2.build_opener(handler)                       
+    opener = urllib2.build_opener(handler)
 
     # use the opener to fetch a URL
-    opener.open(a_url)      
+    opener.open(a_url)
 
     # Install the opener.
     # Now all calls to urllib2.urlopen use our opener.
-    urllib2.install_opener(opener)                               
+    urllib2.install_opener(opener)
 
 .. note::
 
 
     # timeout in seconds
     timeout = 10
-    socket.setdefaulttimeout(timeout) 
+    socket.setdefaulttimeout(timeout)
 
     # this call to urllib2.urlopen now uses the default timeout
     # we have set in the socket module
 This document was reviewed and revised by John Lee.
 
 .. [#] For an introduction to the CGI protocol see
-       `Writing Web Applications in Python <http://www.pyzine.com/Issue008/Section_Articles/article_CGIOne.html>`_. 
+       `Writing Web Applications in Python <http://www.pyzine.com/Issue008/Section_Articles/article_CGIOne.html>`_.
 .. [#] Like Google for example. The *proper* way to use google from a program
        is to use `PyGoogle <http://pygoogle.sourceforge.net>`_ of course. See
        `Voidspace Google <http://www.voidspace.org.uk/python/recipebook.shtml#google>`_
        is set to use the proxy, which urllib2 picks up on. In order to test
        scripts with a localhost server, I have to prevent urllib2 from using
        the proxy.
-.. [#] urllib2 opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe 
+.. [#] urllib2 opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe
        <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456195>`_.
- 
+

File Doc/howto/webservers.rst

    <http://wiki.python.org/moin/CgiScripts>`_ with some additional information
    about CGI in Python.
 
-   
+
 Simple script for testing CGI
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 
    You might be interested in some WSGI-supporting modules already contained in
    the standard library, namely:
-    
+
    * :mod:`wsgiref` -- some tiny utilities and servers for WSGI
 
 
    time in looking through the most popular ones.  Some frameworks have their
    own template engine or have a recommentation for one.  It's wise to use
    these.
-  
+
    Popular template engines include:
 
    * Mako
 found in the Python wiki.
 
 .. seealso::
-    
+
    The Python wiki contains an extensive list of `web frameworks
    <http://wiki.python.org/moin/WebFrameworks>`_.
 

File Doc/includes/mp_distributing.py

-#